|
|
@@ -1,13 +1,39 @@
|
|
|
package com.railway.business.bi.service.impl;
|
|
|
|
|
|
+import com.railway.business.bi.domain.ShowBdyc;
|
|
|
+import com.railway.business.bi.domain.ShowBpdjxjh;
|
|
|
+import com.railway.business.bi.domain.ShowDlyc;
|
|
|
import com.railway.business.bi.domain.ShowFile;
|
|
|
+import com.railway.business.bi.domain.ShowGsd;
|
|
|
+import com.railway.business.bi.domain.ShowGsy;
|
|
|
+import com.railway.business.bi.domain.ShowSbxj;
|
|
|
+import com.railway.business.bi.domain.ShowTestPlanDt;
|
|
|
+import com.railway.business.bi.domain.ShowTestPlanKg;
|
|
|
+import com.railway.business.bi.domain.ShowYdts;
|
|
|
+import com.railway.business.bi.enums.ImpFileTypeEnum;
|
|
|
+import com.railway.business.bi.enums.ImpSheetEnum;
|
|
|
+import com.railway.business.bi.enums.YcxxFoundModeEnum;
|
|
|
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.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.enums.BusinessStatus;
|
|
|
import com.railway.common.utils.SecurityUtils;
|
|
|
+import com.railway.common.utils.poi.ExcelUtil;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.List;
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
/**
|
|
|
* 大屏展示-导入文件记录
|
|
|
@@ -16,13 +42,314 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
* @date 2023/02/10
|
|
|
*/
|
|
|
@Service
|
|
|
-@Transactional(readOnly = true)
|
|
|
public class ShowFileServiceImpl implements IShowFileService {
|
|
|
|
|
|
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;
|
|
|
|
|
|
- public ShowFileServiceImpl(ShowFileMapper showFileMapper) {
|
|
|
+ public ShowFileServiceImpl(ShowFileMapper showFileMapper, IShowBdycService bdycService,
|
|
|
+ IShowDlycService dlycService, IShowTestPlanDtService dtService,
|
|
|
+ IShowTestPlanKgService kgService, IShowBpdjxjhService bpdjxjhService,
|
|
|
+ IShowGsdService gsdService, IShowGsyService gsyService, IShowYdtsService ydtsService,
|
|
|
+ IShowSbxjService sbxjService) {
|
|
|
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;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 检修兑现情况-2022年变配电所检修计划表(检测数字化)
|
|
|
+ *
|
|
|
+ * @param file 2022年变配电所检修计划表(检测数字化)
|
|
|
+ * @return 导入结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public AjaxResult impXlsBdsjxjhb(MultipartFile file) {
|
|
|
+ ImpFileTypeEnum fileTypeEnum = ImpFileTypeEnum.BDSJXJHB;
|
|
|
+ Workbook wb = ExcelUtil.getWorkbook(file);
|
|
|
+ ShowFile showFile = create(file, fileTypeEnum);
|
|
|
+ Long fileId = showFile.getId();
|
|
|
+ String[] sheetList = fileTypeEnum.getSheetList();
|
|
|
+ for (String sheetName : sheetList) {
|
|
|
+ ImpSheetEnum sheetEnum = ImpSheetEnum.ofValue(sheetName);
|
|
|
+ if (sheetEnum != ImpSheetEnum.BD) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ ExcelUtil<ShowBpdjxjh> util = new ExcelUtil<>(ShowBpdjxjh.class);
|
|
|
+ List<ShowBpdjxjh> bdList;
|
|
|
+ try {
|
|
|
+ bdList = util.importExcel(sheetName, wb, 3);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return AjaxResult.error("文件读取失败");
|
|
|
+ }
|
|
|
+ for (ShowBpdjxjh show : bdList) {
|
|
|
+ show.setFileId(fileId);
|
|
|
+ bpdjxjhService.create(show);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ showFile.setImpResult(String.valueOf(BusinessStatus.SUCCESS.ordinal()));
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 试验计划兑现情况-2022检修计划兑现表
|
|
|
+ *
|
|
|
+ * @param file 2022检修计划兑现表
|
|
|
+ * @return 导入结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public AjaxResult impXlsJxjhdxb(MultipartFile file) {
|
|
|
+ ImpFileTypeEnum fileTypeEnum = ImpFileTypeEnum.JXJHDXB;
|
|
|
+ Workbook wb = ExcelUtil.getWorkbook(file);
|
|
|
+ ShowFile showFile = create(file, fileTypeEnum);
|
|
|
+ Long fileId = showFile.getId();
|
|
|
+ String[] sheetList = fileTypeEnum.getSheetList();
|
|
|
+ for (String sheetName : sheetList) {
|
|
|
+ ImpSheetEnum sheetEnum = ImpSheetEnum.ofValue(sheetName);
|
|
|
+ switch (sheetEnum) {
|
|
|
+ case KGFH:
|
|
|
+ ExcelUtil<ShowTestPlanKg> bdUtil = new ExcelUtil<>(ShowTestPlanKg.class);
|
|
|
+ List<ShowTestPlanKg> bdList;
|
|
|
+ try {
|
|
|
+ bdList = bdUtil.importExcel(sheetName, wb, 2, 4);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return AjaxResult.error("文件读取失败");
|
|
|
+ }
|
|
|
+ for (ShowTestPlanKg bdyc : bdList) {
|
|
|
+ bdyc.setFileId(fileId);
|
|
|
+ kgService.create(bdyc);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case DTSY:
|
|
|
+ ExcelUtil<ShowTestPlanDt> dlUtil = new ExcelUtil<>(ShowTestPlanDt.class);
|
|
|
+ List<ShowTestPlanDt> dlList;
|
|
|
+ try {
|
|
|
+ dlList = dlUtil.importExcel(sheetName, wb, 1);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return AjaxResult.error("文件读取失败");
|
|
|
+ }
|
|
|
+ for (ShowTestPlanDt dlyc : dlList) {
|
|
|
+ dlyc.setFileId(fileId);
|
|
|
+ dtService.create(dlyc);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ showFile.setImpResult(String.valueOf(BusinessStatus.SUCCESS.ordinal()));
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生产任务报表
|
|
|
+ *
|
|
|
+ * @param file (5月18日)长春高铁基础设施段生产任务报表
|
|
|
+ * @return 导入结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public AjaxResult impXlsScrw(MultipartFile file) {
|
|
|
+ ImpFileTypeEnum fileTypeEnum = ImpFileTypeEnum.SCRWB;
|
|
|
+ Workbook wb = ExcelUtil.getWorkbook(file);
|
|
|
+ ShowFile showFile = create(file, fileTypeEnum);
|
|
|
+ Long fileId = showFile.getId();
|
|
|
+ String[] sheetList = fileTypeEnum.getSheetList();
|
|
|
+ for (String sheetName : sheetList) {
|
|
|
+ ImpSheetEnum sheetEnum = ImpSheetEnum.ofValue(sheetName);
|
|
|
+ switch (sheetEnum) {
|
|
|
+ case YDTS:
|
|
|
+ ExcelUtil<ShowYdts> bdUtil = new ExcelUtil<>(ShowYdts.class);
|
|
|
+ List<ShowYdts> bdList;
|
|
|
+ try {
|
|
|
+ bdList = bdUtil.importExcel(sheetName, wb);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return AjaxResult.error("文件读取失败");
|
|
|
+ }
|
|
|
+ for (ShowYdts bdyc : bdList) {
|
|
|
+ bdyc.setFileId(fileId);
|
|
|
+ ydtsService.create(bdyc);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case GSD:
|
|
|
+ ExcelUtil<ShowGsd> dlUtil = new ExcelUtil<>(ShowGsd.class);
|
|
|
+ List<ShowGsd> dlList;
|
|
|
+ try {
|
|
|
+ dlList = dlUtil.importExcel(sheetName, wb);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return AjaxResult.error("文件读取失败");
|
|
|
+ }
|
|
|
+ for (ShowGsd dlyc : dlList) {
|
|
|
+ dlyc.setFileId(fileId);
|
|
|
+ gsdService.create(dlyc);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case GSY:
|
|
|
+ ExcelUtil<ShowGsy> syUtil = new ExcelUtil<>(ShowGsy.class);
|
|
|
+ List<ShowGsy> syList;
|
|
|
+ try {
|
|
|
+ syList = syUtil.importExcel(sheetName, wb);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return AjaxResult.error("文件读取失败");
|
|
|
+ }
|
|
|
+ for (ShowGsy dlyc : syList) {
|
|
|
+ dlyc.setFileId(fileId);
|
|
|
+ gsyService.create(dlyc);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ showFile.setImpResult(String.valueOf(BusinessStatus.SUCCESS.ordinal()));
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 牵变、电力设备巡检兑现(本月)-电力车间2023巡检兑现表
|
|
|
+ *
|
|
|
+ * @param file 电力车间2023巡检兑现表
|
|
|
+ * @return 导入结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public AjaxResult impXlsXjdx(MultipartFile file) {
|
|
|
+ ImpFileTypeEnum fileTypeEnum = ImpFileTypeEnum.XJDXB;
|
|
|
+ Workbook wb = ExcelUtil.getWorkbook(file);
|
|
|
+ ShowFile showFile = create(file, fileTypeEnum);
|
|
|
+ Long fileId = showFile.getId();
|
|
|
+ String[] sheetList = fileTypeEnum.getSheetList();
|
|
|
+ for (String sheetName : sheetList) {
|
|
|
+ ImpSheetEnum sheetEnum = ImpSheetEnum.ofValue(sheetName);
|
|
|
+ ExcelUtil<ShowSbxj> bdUtil = new ExcelUtil<>(ShowSbxj.class);
|
|
|
+ List<ShowSbxj> bdList;
|
|
|
+ switch (sheetEnum) {
|
|
|
+ case BD:
|
|
|
+ try {
|
|
|
+ bdList = bdUtil.importExcel(sheetName, wb, 1);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return AjaxResult.error("文件读取失败");
|
|
|
+ }
|
|
|
+ for (ShowSbxj bdyc : bdList) {
|
|
|
+ bdyc.setFileId(fileId);
|
|
|
+ bdyc.setQybds("1");
|
|
|
+ sbxjService.create(bdyc);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case DL:
|
|
|
+ try {
|
|
|
+ bdList = bdUtil.importExcel(sheetName, wb, 2);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return AjaxResult.error("文件读取失败");
|
|
|
+ }
|
|
|
+ for (ShowSbxj dlyc : bdList) {
|
|
|
+ dlyc.setFileId(fileId);
|
|
|
+ sbxjService.create(dlyc);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ showFile.setImpResult(String.valueOf(BusinessStatus.SUCCESS.ordinal()));
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 异常信息-10月23日电力变电专业每日异常信息统计表
|
|
|
+ *
|
|
|
+ * @param file 10月23日电力变电专业每日异常信息统计表
|
|
|
+ * @return 导入结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public AjaxResult impXlsYctjb(MultipartFile file) {
|
|
|
+ ImpFileTypeEnum fileTypeEnum = ImpFileTypeEnum.YCTJB;
|
|
|
+ Workbook wb = ExcelUtil.getWorkbook(file);
|
|
|
+ ShowFile showFile = create(file, fileTypeEnum);
|
|
|
+ Long fileId = showFile.getId();
|
|
|
+ String[] sheetList = fileTypeEnum.getSheetList();
|
|
|
+ for (String sheetName : sheetList) {
|
|
|
+ ImpSheetEnum sheetEnum = ImpSheetEnum.ofValue(sheetName);
|
|
|
+ String foundMode = YcxxFoundModeEnum.PUSH.getCode();
|
|
|
+ if (sheetEnum == ImpSheetEnum.YCT4 || sheetEnum == ImpSheetEnum.YCT5) {
|
|
|
+ foundMode = YcxxFoundModeEnum.SELF.getCode();
|
|
|
+ }
|
|
|
+ switch (sheetEnum) {
|
|
|
+ case YCT2:
|
|
|
+ case YCT5:
|
|
|
+ ExcelUtil<ShowBdyc> bdUtil = new ExcelUtil<>(ShowBdyc.class);
|
|
|
+ List<ShowBdyc> bdList;
|
|
|
+ try {
|
|
|
+ bdList = bdUtil.importExcel(sheetName, wb);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return AjaxResult.error("文件读取失败");
|
|
|
+ }
|
|
|
+ for (ShowBdyc bdyc : bdList) {
|
|
|
+ if (null == bdyc.getFoundDate()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ bdyc.setFileId(fileId);
|
|
|
+ bdyc.setFoundMode(foundMode);
|
|
|
+ bdycService.create(bdyc);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case YCT3:
|
|
|
+ case YCT4:
|
|
|
+ ExcelUtil<ShowDlyc> dlUtil = new ExcelUtil<>(ShowDlyc.class);
|
|
|
+ List<ShowDlyc> dlList;
|
|
|
+ try {
|
|
|
+ dlList = dlUtil.importExcel(sheetName, wb);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return AjaxResult.error("文件读取失败");
|
|
|
+ }
|
|
|
+ for (ShowDlyc dlyc : dlList) {
|
|
|
+ if (null == dlyc.getFoundDate()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ dlyc.setFileId(fileId);
|
|
|
+ dlyc.setFoundMode(foundMode);
|
|
|
+ dlycService.create(dlyc);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ showFile.setImpResult(String.valueOf(BusinessStatus.SUCCESS.ordinal()));
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ private ShowFile create(MultipartFile file, ImpFileTypeEnum fileTypeEnum) {
|
|
|
+ ShowFile showFile = new ShowFile();
|
|
|
+ showFile.setImpResult(String.valueOf(BusinessStatus.FAIL.ordinal()));
|
|
|
+ showFile.setDataType(fileTypeEnum.getCode());
|
|
|
+ showFile.setFileName(file.getName());
|
|
|
+ create(showFile);
|
|
|
+ return showFile;
|
|
|
}
|
|
|
|
|
|
/**
|