|
@@ -2,11 +2,15 @@ package com.business.slfh.manager.stationweathermanager.service.impl;
|
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
+import com.business.slfh.manager.forestdevicemanager.domain.TResForestdevice;
|
|
|
|
+import com.business.slfh.manager.stationteammanager.domain.TResStationteam;
|
|
import com.business.slfh.manager.stationweathermanager.domain.TResStationweather;
|
|
import com.business.slfh.manager.stationweathermanager.domain.TResStationweather;
|
|
import com.business.slfh.manager.stationweathermanager.mapper.TResStationweatherMapper;
|
|
import com.business.slfh.manager.stationweathermanager.mapper.TResStationweatherMapper;
|
|
import com.business.slfh.manager.stationweathermanager.service.ITResStationweatherService;
|
|
import com.business.slfh.manager.stationweathermanager.service.ITResStationweatherService;
|
|
|
|
+import com.business.slfh.tools.UUID_Tools;
|
|
import com.business.slfh.tools.UserInfoUtil;
|
|
import com.business.slfh.tools.UserInfoUtil;
|
|
import com.sooka.common.annotation.DataScope;
|
|
import com.sooka.common.annotation.DataScope;
|
|
|
|
+import com.sooka.common.core.domain.AjaxResult;
|
|
import com.sooka.common.core.text.Convert;
|
|
import com.sooka.common.core.text.Convert;
|
|
import com.sooka.common.utils.DateUtils;
|
|
import com.sooka.common.utils.DateUtils;
|
|
import com.sooka.system.domain.SysUser;
|
|
import com.sooka.system.domain.SysUser;
|
|
@@ -72,6 +76,55 @@ public class TResStationweatherServiceImpl implements ITResStationweatherService
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * 导入【请填写功能名称】
|
|
|
|
+ *
|
|
|
|
+ * @param tResStationweather 【请填写功能名称】
|
|
|
|
+ * @return 结果
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public AjaxResult importExcel(TResStationweather tResStationweather)
|
|
|
|
+ {
|
|
|
|
+ int lsSize;//导入数据条数
|
|
|
|
+ int breakLine = 0;//此处数不完整
|
|
|
|
+ try{
|
|
|
|
+ System.out.println("importExcel Controller");
|
|
|
|
+ System.out.println(tResStationweather.getFilename()+"=filename");
|
|
|
|
+ List<String[]> ls = com.business.slfh.tools.ExcelUtil.readExcel(tResStationweather.getFilename(),"Sheet1");//filename,sheetname
|
|
|
|
+ final int num = 6;
|
|
|
|
+ boolean isLengthLegal = true;
|
|
|
|
+ for (int i = 0; i < ls.size(); i++) {//检查每行数据长度一致性
|
|
|
|
+ String[] row = ls.get(i);
|
|
|
|
+ if(num != row.length){
|
|
|
|
+ isLengthLegal = false;
|
|
|
|
+ breakLine = i + 1;//此行数据不完整 行数按照数据所在行号计算
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(isLengthLegal){
|
|
|
|
+ lsSize = ls.size();
|
|
|
|
+ for (int i = 1; i < ls.size(); i++) {
|
|
|
|
+ String[] row = ls.get(i);
|
|
|
|
+ TResStationweather tResStationweatherInsert = new TResStationweather();
|
|
|
|
+ tResStationweatherInsert.setId(UUID_Tools.getUUID());
|
|
|
|
+ tResStationweatherInsert.setName(row[0]);//名称
|
|
|
|
+ tResStationweatherInsert.setLongitude(row[1]);//经度
|
|
|
|
+ tResStationweatherInsert.setLatitude(row[2]);//纬度
|
|
|
|
+ tResStationweatherInsert.setAddress(row[3]);//地址
|
|
|
|
+ tResStationweatherInsert.setContactUser(row[4]);//联系人
|
|
|
|
+ tResStationweatherInsert.setContactPhone(row[5]);//电话
|
|
|
|
+ tResStationweatherMapper.insertTResStationweather(tResStationweatherInsert);
|
|
|
|
+ }
|
|
|
|
+ return AjaxResult.success(lsSize+"条数据导入成功!");
|
|
|
|
+ }else {
|
|
|
|
+ return AjaxResult.error("请检查,第"+breakLine+"行数据不完整!");
|
|
|
|
+ }
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ return AjaxResult.error("导入失败,请稍后尝试!");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
* 修改【请填写功能名称】
|
|
* 修改【请填写功能名称】
|
|
*
|
|
*
|
|
* @param tResStationweather 【请填写功能名称】
|
|
* @param tResStationweather 【请填写功能名称】
|