|
@@ -13,23 +13,23 @@ import com.railway.business.bi.domain.ShowYdts;
|
|
|
import com.railway.business.bi.enums.ImpFileTypeEnum;
|
|
import com.railway.business.bi.enums.ImpFileTypeEnum;
|
|
|
import com.railway.business.bi.enums.ImpSheetEnum;
|
|
import com.railway.business.bi.enums.ImpSheetEnum;
|
|
|
import com.railway.business.bi.enums.YcxxFoundModeEnum;
|
|
import com.railway.business.bi.enums.YcxxFoundModeEnum;
|
|
|
|
|
+import com.railway.business.bi.mapper.ShowBdycMapper;
|
|
|
|
|
+import com.railway.business.bi.mapper.ShowBpdjxjhMapper;
|
|
|
|
|
+import com.railway.business.bi.mapper.ShowDlycMapper;
|
|
|
import com.railway.business.bi.mapper.ShowFileMapper;
|
|
import com.railway.business.bi.mapper.ShowFileMapper;
|
|
|
-import com.railway.business.bi.service.IShowBdycService;
|
|
|
|
|
-import com.railway.business.bi.service.IShowBpdjxjhService;
|
|
|
|
|
-import com.railway.business.bi.service.IShowDlycService;
|
|
|
|
|
|
|
+import com.railway.business.bi.mapper.ShowGsdMapper;
|
|
|
|
|
+import com.railway.business.bi.mapper.ShowGsyMapper;
|
|
|
|
|
+import com.railway.business.bi.mapper.ShowSbxjMapper;
|
|
|
|
|
+import com.railway.business.bi.mapper.ShowTestPlanDtMapper;
|
|
|
|
|
+import com.railway.business.bi.mapper.ShowTestPlanKgMapper;
|
|
|
|
|
+import com.railway.business.bi.mapper.ShowYdtsMapper;
|
|
|
import com.railway.business.bi.service.IShowFileService;
|
|
import com.railway.business.bi.service.IShowFileService;
|
|
|
-import com.railway.business.bi.service.IShowGsdService;
|
|
|
|
|
-import com.railway.business.bi.service.IShowGsyService;
|
|
|
|
|
-import com.railway.business.bi.service.IShowSbxjService;
|
|
|
|
|
-import com.railway.business.bi.service.IShowTestPlanDtService;
|
|
|
|
|
-import com.railway.business.bi.service.IShowTestPlanKgService;
|
|
|
|
|
-import com.railway.business.bi.service.IShowYdtsService;
|
|
|
|
|
import com.railway.common.core.domain.AjaxResult;
|
|
import com.railway.common.core.domain.AjaxResult;
|
|
|
import com.railway.common.enums.BusinessStatus;
|
|
import com.railway.common.enums.BusinessStatus;
|
|
|
-import com.railway.common.enums.DelFlagEnum;
|
|
|
|
|
import com.railway.common.utils.SecurityUtils;
|
|
import com.railway.common.utils.SecurityUtils;
|
|
|
import com.railway.common.utils.StringUtils;
|
|
import com.railway.common.utils.StringUtils;
|
|
|
import com.railway.common.utils.poi.ExcelUtil;
|
|
import com.railway.common.utils.poi.ExcelUtil;
|
|
|
|
|
+import com.railway.framework.datasource.MybatisBatchUtils;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
@@ -47,34 +47,13 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
public class ShowFileServiceImpl implements IShowFileService {
|
|
public class ShowFileServiceImpl implements IShowFileService {
|
|
|
|
|
|
|
|
private final ShowFileMapper showFileMapper;
|
|
private final ShowFileMapper showFileMapper;
|
|
|
- private final IShowBdycService bdycService;
|
|
|
|
|
- private final IShowDlycService dlycService;
|
|
|
|
|
- private final IShowTestPlanDtService dtService;
|
|
|
|
|
- private final IShowTestPlanKgService kgService;
|
|
|
|
|
- private final IShowBpdjxjhService bpdjxjhService;
|
|
|
|
|
- private final IShowGsdService gsdService;
|
|
|
|
|
- private final IShowGsyService gsyService;
|
|
|
|
|
- private final IShowYdtsService ydtsService;
|
|
|
|
|
- private final IShowSbxjService sbxjService;
|
|
|
|
|
|
|
+ private final MybatisBatchUtils batchUtils;
|
|
|
|
|
|
|
|
- public ShowFileServiceImpl(ShowFileMapper showFileMapper, IShowBdycService bdycService,
|
|
|
|
|
- IShowDlycService dlycService, IShowTestPlanDtService dtService,
|
|
|
|
|
- IShowTestPlanKgService kgService, IShowBpdjxjhService bpdjxjhService,
|
|
|
|
|
- IShowGsdService gsdService, IShowGsyService gsyService, IShowYdtsService ydtsService,
|
|
|
|
|
- IShowSbxjService sbxjService) {
|
|
|
|
|
|
|
+ public ShowFileServiceImpl(ShowFileMapper showFileMapper, MybatisBatchUtils batchUtils) {
|
|
|
this.showFileMapper = showFileMapper;
|
|
this.showFileMapper = showFileMapper;
|
|
|
- this.bdycService = bdycService;
|
|
|
|
|
- this.dlycService = dlycService;
|
|
|
|
|
- this.dtService = dtService;
|
|
|
|
|
- this.kgService = kgService;
|
|
|
|
|
- this.bpdjxjhService = bpdjxjhService;
|
|
|
|
|
- this.gsdService = gsdService;
|
|
|
|
|
- this.gsyService = gsyService;
|
|
|
|
|
- this.ydtsService = ydtsService;
|
|
|
|
|
- this.sbxjService = sbxjService;
|
|
|
|
|
|
|
+ this.batchUtils = batchUtils;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* 检修兑现情况-2022年变配电所检修计划表(检测数字化)
|
|
* 检修兑现情况-2022年变配电所检修计划表(检测数字化)
|
|
|
*
|
|
*
|
|
@@ -96,16 +75,12 @@ public class ShowFileServiceImpl implements IShowFileService {
|
|
|
ExcelUtil<ShowBpdjxjh> util = new ExcelUtil<>(ShowBpdjxjh.class);
|
|
ExcelUtil<ShowBpdjxjh> util = new ExcelUtil<>(ShowBpdjxjh.class);
|
|
|
List<ShowBpdjxjh> bdList;
|
|
List<ShowBpdjxjh> bdList;
|
|
|
try {
|
|
try {
|
|
|
- bdList = util.importExcel(sheetName, wb, 3);
|
|
|
|
|
|
|
+ bdList = util.importExcel(fileId, wb, sheetName, 3);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
return AjaxResult.error("文件读取失败");
|
|
return AjaxResult.error("文件读取失败");
|
|
|
}
|
|
}
|
|
|
- for (ShowBpdjxjh show : bdList) {
|
|
|
|
|
- show.setFileId(fileId);
|
|
|
|
|
- show.setDelFlag(DelFlagEnum.NOT_DELETE.getCode());
|
|
|
|
|
- bpdjxjhService.create(show);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ batchUtils.batchInsert(bdList, ShowBpdjxjhMapper.class, ShowBpdjxjhMapper::insert);
|
|
|
}
|
|
}
|
|
|
showFile.setImpResult(String.valueOf(BusinessStatus.SUCCESS.ordinal()));
|
|
showFile.setImpResult(String.valueOf(BusinessStatus.SUCCESS.ordinal()));
|
|
|
return AjaxResult.success();
|
|
return AjaxResult.success();
|
|
@@ -131,31 +106,23 @@ public class ShowFileServiceImpl implements IShowFileService {
|
|
|
ExcelUtil<ShowTestPlanKg> bdUtil = new ExcelUtil<>(ShowTestPlanKg.class);
|
|
ExcelUtil<ShowTestPlanKg> bdUtil = new ExcelUtil<>(ShowTestPlanKg.class);
|
|
|
List<ShowTestPlanKg> bdList;
|
|
List<ShowTestPlanKg> bdList;
|
|
|
try {
|
|
try {
|
|
|
- bdList = bdUtil.importExcel(sheetName, wb, 2, 4);
|
|
|
|
|
|
|
+ bdList = bdUtil.importExcel(fileId, wb, sheetName, 2, 4);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
return AjaxResult.error("文件读取失败");
|
|
return AjaxResult.error("文件读取失败");
|
|
|
}
|
|
}
|
|
|
- for (ShowTestPlanKg bdyc : bdList) {
|
|
|
|
|
- bdyc.setFileId(fileId);
|
|
|
|
|
- bdyc.setDelFlag(DelFlagEnum.NOT_DELETE.getCode());
|
|
|
|
|
- kgService.create(bdyc);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ batchUtils.batchInsert(bdList, ShowTestPlanKgMapper.class, ShowTestPlanKgMapper::insert);
|
|
|
break;
|
|
break;
|
|
|
case DTSY:
|
|
case DTSY:
|
|
|
ExcelUtil<ShowTestPlanDt> dlUtil = new ExcelUtil<>(ShowTestPlanDt.class);
|
|
ExcelUtil<ShowTestPlanDt> dlUtil = new ExcelUtil<>(ShowTestPlanDt.class);
|
|
|
List<ShowTestPlanDt> dlList;
|
|
List<ShowTestPlanDt> dlList;
|
|
|
try {
|
|
try {
|
|
|
- dlList = dlUtil.importExcel(sheetName, wb, 1);
|
|
|
|
|
|
|
+ dlList = dlUtil.importExcel(fileId, wb, sheetName, 1);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
return AjaxResult.error("文件读取失败");
|
|
return AjaxResult.error("文件读取失败");
|
|
|
}
|
|
}
|
|
|
- for (ShowTestPlanDt dlyc : dlList) {
|
|
|
|
|
- dlyc.setFileId(fileId);
|
|
|
|
|
- dlyc.setDelFlag(DelFlagEnum.NOT_DELETE.getCode());
|
|
|
|
|
- dtService.create(dlyc);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ batchUtils.batchInsert(dlList, ShowTestPlanDtMapper.class, ShowTestPlanDtMapper::insert);
|
|
|
break;
|
|
break;
|
|
|
default:
|
|
default:
|
|
|
break;
|
|
break;
|
|
@@ -183,57 +150,42 @@ public class ShowFileServiceImpl implements IShowFileService {
|
|
|
switch (sheetEnum) {
|
|
switch (sheetEnum) {
|
|
|
case YDTS:
|
|
case YDTS:
|
|
|
ExcelUtil<ShowYdts> bdUtil = new ExcelUtil<>(ShowYdts.class);
|
|
ExcelUtil<ShowYdts> bdUtil = new ExcelUtil<>(ShowYdts.class);
|
|
|
- List<ShowYdts> bdList;
|
|
|
|
|
|
|
+ List<ShowYdts> ydtsList;
|
|
|
try {
|
|
try {
|
|
|
- bdList = bdUtil.importExcel(sheetName, wb, 1, 3);
|
|
|
|
|
|
|
+ ydtsList = bdUtil.importExcel(fileId, wb, sheetName, 1, 3);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
return AjaxResult.error("文件读取失败");
|
|
return AjaxResult.error("文件读取失败");
|
|
|
}
|
|
}
|
|
|
- for (ShowYdts bdyc : bdList) {
|
|
|
|
|
- if(StringUtils.isEmpty(bdyc.getSubstationName()) || "0".equals(bdyc.getSubstationName())){
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- bdyc.setDelFlag(DelFlagEnum.NOT_DELETE.getCode());
|
|
|
|
|
- bdyc.setFileId(fileId);
|
|
|
|
|
- ydtsService.create(bdyc);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ ydtsList.removeIf(ydts -> StringUtils.isEmpty(ydts.getSubstationName()) || "0".equals(
|
|
|
|
|
+ ydts.getSubstationName()));
|
|
|
|
|
+ batchUtils.batchInsert(ydtsList, ShowYdtsMapper.class, ShowYdtsMapper::insert);
|
|
|
break;
|
|
break;
|
|
|
case GSD:
|
|
case GSD:
|
|
|
ExcelUtil<ShowGsd> dlUtil = new ExcelUtil<>(ShowGsd.class);
|
|
ExcelUtil<ShowGsd> dlUtil = new ExcelUtil<>(ShowGsd.class);
|
|
|
- List<ShowGsd> dlList;
|
|
|
|
|
|
|
+ List<ShowGsd> gsdList;
|
|
|
try {
|
|
try {
|
|
|
- dlList = dlUtil.importExcel(sheetName, wb, 2, 4);
|
|
|
|
|
|
|
+ gsdList = dlUtil.importExcel(fileId, wb, sheetName, 2, 4);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
return AjaxResult.error("文件读取失败");
|
|
return AjaxResult.error("文件读取失败");
|
|
|
}
|
|
}
|
|
|
- for (ShowGsd dlyc : dlList) {
|
|
|
|
|
- if(StringUtils.isEmpty(dlyc.getLineName()) || "0".equals(dlyc.getLineName())){
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- dlyc.setFileId(fileId);
|
|
|
|
|
- dlyc.setDelFlag(DelFlagEnum.NOT_DELETE.getCode());
|
|
|
|
|
- gsdService.create(dlyc);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ gsdList.removeIf(gsd -> StringUtils.isEmpty(gsd.getLineName()) || "0".equals(
|
|
|
|
|
+ gsd.getLineName()));
|
|
|
|
|
+ batchUtils.batchInsert(gsdList, ShowGsdMapper.class, ShowGsdMapper::insert);
|
|
|
break;
|
|
break;
|
|
|
case GSY:
|
|
case GSY:
|
|
|
ExcelUtil<ShowGsy> syUtil = new ExcelUtil<>(ShowGsy.class);
|
|
ExcelUtil<ShowGsy> syUtil = new ExcelUtil<>(ShowGsy.class);
|
|
|
- List<ShowGsy> syList;
|
|
|
|
|
|
|
+ List<ShowGsy> gsyList;
|
|
|
try {
|
|
try {
|
|
|
- syList = syUtil.importExcel(sheetName, wb, 1, 3);
|
|
|
|
|
|
|
+ gsyList = syUtil.importExcel(fileId, wb, sheetName, 1, 3);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
return AjaxResult.error("文件读取失败");
|
|
return AjaxResult.error("文件读取失败");
|
|
|
}
|
|
}
|
|
|
- for (ShowGsy dlyc : syList) {
|
|
|
|
|
- if(StringUtils.isEmpty(dlyc.getSubstationName()) || "0".equals(dlyc.getSubstationName())){
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- dlyc.setFileId(fileId);
|
|
|
|
|
- dlyc.setDelFlag(DelFlagEnum.NOT_DELETE.getCode());
|
|
|
|
|
- gsyService.create(dlyc);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ gsyList.removeIf(gsy -> StringUtils.isEmpty(gsy.getSubstationName()) || "0".equals(
|
|
|
|
|
+ gsy.getSubstationName()));
|
|
|
|
|
+ batchUtils.batchInsert(gsyList, ShowGsyMapper.class, ShowGsyMapper::insert);
|
|
|
break;
|
|
break;
|
|
|
default:
|
|
default:
|
|
|
break;
|
|
break;
|
|
@@ -259,38 +211,29 @@ public class ShowFileServiceImpl implements IShowFileService {
|
|
|
for (String sheetName : sheetList) {
|
|
for (String sheetName : sheetList) {
|
|
|
ImpSheetEnum sheetEnum = ImpSheetEnum.ofValue(sheetName);
|
|
ImpSheetEnum sheetEnum = ImpSheetEnum.ofValue(sheetName);
|
|
|
ExcelUtil<ShowSbxj> bdUtil = new ExcelUtil<>(ShowSbxj.class);
|
|
ExcelUtil<ShowSbxj> bdUtil = new ExcelUtil<>(ShowSbxj.class);
|
|
|
- List<ShowSbxj> bdList;
|
|
|
|
|
|
|
+ List<ShowSbxj> list = null;
|
|
|
switch (sheetEnum) {
|
|
switch (sheetEnum) {
|
|
|
case BD:
|
|
case BD:
|
|
|
try {
|
|
try {
|
|
|
- bdList = bdUtil.importExcel(sheetName, wb, 1);
|
|
|
|
|
|
|
+ list = bdUtil.importExcel(fileId, wb, sheetName, 1);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
return AjaxResult.error("文件读取失败");
|
|
return AjaxResult.error("文件读取失败");
|
|
|
}
|
|
}
|
|
|
- for (ShowSbxj bdyc : bdList) {
|
|
|
|
|
- bdyc.setFileId(fileId);
|
|
|
|
|
- bdyc.setQybds("1");
|
|
|
|
|
- bdyc.setDelFlag(DelFlagEnum.NOT_DELETE.getCode());
|
|
|
|
|
- sbxjService.create(bdyc);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ list.forEach(bdyc -> bdyc.setQybds("1"));
|
|
|
break;
|
|
break;
|
|
|
case DL:
|
|
case DL:
|
|
|
try {
|
|
try {
|
|
|
- bdList = bdUtil.importExcel(sheetName, wb, 1, 3);
|
|
|
|
|
|
|
+ list = bdUtil.importExcel(fileId, wb, sheetName, 1, 3);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
return AjaxResult.error("文件读取失败");
|
|
return AjaxResult.error("文件读取失败");
|
|
|
}
|
|
}
|
|
|
- for (ShowSbxj dlyc : bdList) {
|
|
|
|
|
- dlyc.setFileId(fileId);
|
|
|
|
|
- dlyc.setDelFlag(DelFlagEnum.NOT_DELETE.getCode());
|
|
|
|
|
- sbxjService.create(dlyc);
|
|
|
|
|
- }
|
|
|
|
|
break;
|
|
break;
|
|
|
default:
|
|
default:
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
|
|
+ batchUtils.batchInsert(list, ShowSbxjMapper.class, ShowSbxjMapper::insert);
|
|
|
}
|
|
}
|
|
|
showFile.setImpResult(String.valueOf(BusinessStatus.SUCCESS.ordinal()));
|
|
showFile.setImpResult(String.valueOf(BusinessStatus.SUCCESS.ordinal()));
|
|
|
return AjaxResult.success();
|
|
return AjaxResult.success();
|
|
@@ -321,40 +264,30 @@ public class ShowFileServiceImpl implements IShowFileService {
|
|
|
ExcelUtil<ShowBdyc> bdUtil = new ExcelUtil<>(ShowBdyc.class);
|
|
ExcelUtil<ShowBdyc> bdUtil = new ExcelUtil<>(ShowBdyc.class);
|
|
|
List<ShowBdyc> bdList;
|
|
List<ShowBdyc> bdList;
|
|
|
try {
|
|
try {
|
|
|
- bdList = bdUtil.importExcel(sheetName, wb);
|
|
|
|
|
|
|
+ bdList = bdUtil.importExcel(fileId, wb, sheetName);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
return AjaxResult.error("文件读取失败");
|
|
return AjaxResult.error("文件读取失败");
|
|
|
}
|
|
}
|
|
|
- for (ShowBdyc bdyc : bdList) {
|
|
|
|
|
- if (null == bdyc.getFoundDate()) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- bdyc.setFileId(fileId);
|
|
|
|
|
- bdyc.setFoundMode(foundMode);
|
|
|
|
|
- bdyc.setDelFlag(DelFlagEnum.NOT_DELETE.getCode());
|
|
|
|
|
- bdycService.create(bdyc);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ String foundMode1 = foundMode;
|
|
|
|
|
+ bdList.removeIf(bdyc -> null == bdyc.getFoundDate());
|
|
|
|
|
+ bdList.forEach(bdyc -> bdyc.setFoundMode(foundMode1));
|
|
|
|
|
+ batchUtils.batchInsert(bdList, ShowBdycMapper.class, ShowBdycMapper::insert);
|
|
|
break;
|
|
break;
|
|
|
case YCT3:
|
|
case YCT3:
|
|
|
case YCT4:
|
|
case YCT4:
|
|
|
ExcelUtil<ShowDlyc> dlUtil = new ExcelUtil<>(ShowDlyc.class);
|
|
ExcelUtil<ShowDlyc> dlUtil = new ExcelUtil<>(ShowDlyc.class);
|
|
|
List<ShowDlyc> dlList;
|
|
List<ShowDlyc> dlList;
|
|
|
try {
|
|
try {
|
|
|
- dlList = dlUtil.importExcel(sheetName, wb);
|
|
|
|
|
|
|
+ dlList = dlUtil.importExcel(fileId, wb, sheetName);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
return AjaxResult.error("文件读取失败");
|
|
return AjaxResult.error("文件读取失败");
|
|
|
}
|
|
}
|
|
|
- for (ShowDlyc dlyc : dlList) {
|
|
|
|
|
- if (null == dlyc.getFoundDate()) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- dlyc.setFileId(fileId);
|
|
|
|
|
- dlyc.setFoundMode(foundMode);
|
|
|
|
|
- dlyc.setDelFlag(DelFlagEnum.NOT_DELETE.getCode());
|
|
|
|
|
- dlycService.create(dlyc);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ String foundMode2 = foundMode;
|
|
|
|
|
+ dlList.removeIf(dlyc -> null == dlyc.getFoundDate());
|
|
|
|
|
+ dlList.forEach(dlyc -> dlyc.setFoundMode(foundMode2));
|
|
|
|
|
+ batchUtils.batchInsert(dlList, ShowDlycMapper.class, ShowDlycMapper::insert);
|
|
|
break;
|
|
break;
|
|
|
default:
|
|
default:
|
|
|
break;
|
|
break;
|