|
@@ -2,10 +2,14 @@ package com.business.slfh.manager.stationforestmanager.service.impl;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
+import com.business.slfh.manager.forestdevicemanager.domain.TResForestdevice;
|
|
|
+import com.business.slfh.manager.stationfiremanager.domain.TResStationfire;
|
|
|
import com.business.slfh.manager.stationforestmanager.domain.TResStationforest;
|
|
|
import com.business.slfh.manager.stationforestmanager.mapper.TResStationforestMapper;
|
|
|
+import com.business.slfh.tools.UUID_Tools;
|
|
|
import com.business.slfh.tools.UserInfoUtil;
|
|
|
import com.sooka.common.annotation.DataScope;
|
|
|
+import com.sooka.common.core.domain.AjaxResult;
|
|
|
import com.sooka.common.core.text.Convert;
|
|
|
import com.sooka.common.utils.DateUtils;
|
|
|
import com.sooka.system.domain.SysUser;
|
|
@@ -72,6 +76,57 @@ public class TResStationforestServiceImpl implements ITResStationforestService
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 导入【请填写功能名称】
|
|
|
+ *
|
|
|
+ * @param tResStationforest 【请填写功能名称】
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public AjaxResult importExcel(TResStationforest tResStationforest)
|
|
|
+ {
|
|
|
+ int lsSize;//导入数据条数
|
|
|
+ int breakLine = 0;//此处数不完整
|
|
|
+ try{
|
|
|
+ System.out.println("importExcel Controller");
|
|
|
+ System.out.println(tResStationforest.getFilename()+"=filename");
|
|
|
+ List<String[]> ls = com.business.slfh.tools.ExcelUtil.readExcel(tResStationforest.getFilename(),"Sheet1");//filename,sheetname
|
|
|
+ final int num = 7;
|
|
|
+ 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);
|
|
|
+ TResStationforest tResStationforestInsert = new TResStationforest();
|
|
|
+ tResStationforestInsert.setId(UUID_Tools.getUUID());
|
|
|
+ tResStationforestInsert.setName(row[0]);//名称
|
|
|
+ String forestType = row[1].equals("1")?"林业局":row[1].equals("2")?"林场":"";
|
|
|
+ tResStationforestInsert.setForestType(forestType);//森林类型 //1林业局 2林场
|
|
|
+ tResStationforestInsert.setLongitude(row[2]);//经度
|
|
|
+ tResStationforestInsert.setLatitude(row[3]);//纬度
|
|
|
+ tResStationforestInsert.setAddress(row[4]);//地址
|
|
|
+ tResStationforestInsert.setContactUser(row[5]);//联系人
|
|
|
+ tResStationforestInsert.setContactPhone(row[6]);//电话
|
|
|
+ tResStationforestMapper.insertTResStationforest(tResStationforestInsert);
|
|
|
+ }
|
|
|
+ return AjaxResult.success(lsSize+"条数据导入成功!");
|
|
|
+ }else {
|
|
|
+ return AjaxResult.error("请检查,第"+breakLine+"行数据不完整!");
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ return AjaxResult.error("导入失败,请稍后尝试!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 修改【请填写功能名称】
|
|
|
*
|
|
|
* @param tResStationforest 【请填写功能名称】
|