From 0200607c0ced39b6eb75a0c9eec5f09a89a21ad2 Mon Sep 17 00:00:00 2001 From: wr <1754607820@qq.com> Date: Fri, 28 Mar 2025 16:13:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=80=E6=9C=AF=E7=9B=91=E7=9D=A3=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pojo/dto/SupervisionPlanExcel.java | 24 ++-- .../survey/SurveyPlanController.java | 4 +- ...SupervisionDevMainReportPOServiceImpl.java | 27 ---- .../survey/impl/SurveyPlanServiceImpl.java | 134 ++++++++---------- pqs-system/system-boot/pom.xml | 5 - .../algorithm/DeviceAlgorithmTaskRunner.java | 39 ----- .../MeasurementAlgorithmTaskRunner.java | 39 ----- .../MeasurementHourAlgorithmTaskRunner.java | 41 ------ .../algorithm/OrgAlgorithmTaskRunner.java | 37 ----- .../SubstationAlgorithmTaskRunner.java | 37 ----- 10 files changed, 71 insertions(+), 316 deletions(-) delete mode 100644 pqs-system/system-boot/src/main/java/com/njcn/system/timer/tasks/algorithm/DeviceAlgorithmTaskRunner.java delete mode 100644 pqs-system/system-boot/src/main/java/com/njcn/system/timer/tasks/algorithm/MeasurementAlgorithmTaskRunner.java delete mode 100644 pqs-system/system-boot/src/main/java/com/njcn/system/timer/tasks/algorithm/MeasurementHourAlgorithmTaskRunner.java delete mode 100644 pqs-system/system-boot/src/main/java/com/njcn/system/timer/tasks/algorithm/OrgAlgorithmTaskRunner.java delete mode 100644 pqs-system/system-boot/src/main/java/com/njcn/system/timer/tasks/algorithm/SubstationAlgorithmTaskRunner.java diff --git a/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/dto/SupervisionPlanExcel.java b/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/dto/SupervisionPlanExcel.java index d6fdf16d6..4d7e1336c 100644 --- a/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/dto/SupervisionPlanExcel.java +++ b/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/dto/SupervisionPlanExcel.java @@ -4,8 +4,8 @@ import cn.afterturn.easypoi.excel.annotation.Excel; import lombok.Data; import lombok.EqualsAndHashCode; -import javax.validation.constraints.NotBlank; import java.io.Serializable; +import java.util.Date; /** * @Description: @@ -19,56 +19,48 @@ public class SupervisionPlanExcel { * 负责单位ID */ @Excel(name = "*计划负责单位", width = 30) - @NotBlank(message = "计划负责单位不能为空") private String deptId; /** - * 普测计划名称 + * 计划名称 */ - @Excel(name = "*普测计划名称", width = 30) - @NotBlank(message = "不能为空") + @Excel(name = "*计划名称", width = 30) private String planName; /** * 监督类型 */ @Excel(name = "*监督类型", width = 30) - @NotBlank(message = "监督类型不能为空") private String supvType; /** * 监督对象名称 */ @Excel(name = "*监督对象名称", width = 30) - @NotBlank(message = "监督对象名称不能为空") private String supvObjectName; /** * 计划开始时间 */ - @Excel(name = "*计划开始时间(yyyy-MM-dd)", width = 30) - @NotBlank(message = "计划开始时间不能为空") - private String planStartTime; + @Excel(name = "*计划开始时间(yyyy/MM/dd)", width = 30,exportFormat = "yyyy/MM/dd") + private Date planStartTime; /** * 计划结束时间 */ - @Excel(name = "*计划结束时间(yyyy-MM-dd)", width = 30) - @NotBlank(message = "计划结束时间不能为空") - private String planEndTime; + @Excel(name = "*计划结束时间(yyyy/MM/dd)", width = 30,exportFormat = "yyyy/MM/dd") + private Date planEndTime; /** * 0 关联系统内变电站;1 用户手动输入变电站 */ - @Excel(name = "*是否系统电站", width = 30, replace = {"是_1", "否_0",}) - @NotBlank(message = "是否系统电站不能为空") + @Excel(name = "*是否系统电站", width = 30, replace = {"是_0", "否_1",}) private String customSubstationFlag ; /** * 变电站台账ID或者用户手动输入的变电站名称 */ @Excel(name = "*关联电站一", width = 30) - @NotBlank(message = "关联电站一不能为空") private String substation; /** diff --git a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/controller/survey/SurveyPlanController.java b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/controller/survey/SurveyPlanController.java index fc3095087..f45e9bcfa 100644 --- a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/controller/survey/SurveyPlanController.java +++ b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/controller/survey/SurveyPlanController.java @@ -121,11 +121,11 @@ public class SurveyPlanController extends BaseController { } - @PostMapping(value = "/importPlanData", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) + @PostMapping(value = "/importPlanData") @ApiOperation("批量导入技术监督计划") @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD) public HttpResult importPlanData(@ApiParam(value = "文件", required = true) @RequestPart("file") MultipartFile file, HttpServletResponse response) { - String methodDescribe = getMethodDescribe("importDevData"); + String methodDescribe = getMethodDescribe("importPlanData"); surveyPlanService.importPlanData(file, response); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); } diff --git a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/device/impl/SupervisionDevMainReportPOServiceImpl.java b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/device/impl/SupervisionDevMainReportPOServiceImpl.java index 8c28da0ac..0fc557944 100644 --- a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/device/impl/SupervisionDevMainReportPOServiceImpl.java +++ b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/device/impl/SupervisionDevMainReportPOServiceImpl.java @@ -357,33 +357,6 @@ public class SupervisionDevMainReportPOServiceImpl extends ServiceImpl pullDowns = new ArrayList<>(); PullDown pullDown; - pullDown = new PullDown(); - pullDown.setFirstCol(0); - pullDown.setLastCol(0); - pullDown.setIsText(true); - pullDowns.add(pullDown); - - pullDown = new PullDown(); - pullDown.setFirstCol(10); - pullDown.setLastCol(10); - pullDown.setIsText(true); - pullDowns.add(pullDown); - - - pullDown = new PullDown(); - pullDown.setFirstCol(11); - pullDown.setLastCol(11); - pullDown.setIsText(true); - pullDowns.add(pullDown); - - - pullDown = new PullDown(); - pullDown.setFirstCol(20); - pullDown.setLastCol(20); - pullDown.setIsText(true); - pullDowns.add(pullDown); - - pullDown = new PullDown(); pullDown.setFirstCol(1); pullDown.setLastCol(1); diff --git a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/survey/impl/SurveyPlanServiceImpl.java b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/survey/impl/SurveyPlanServiceImpl.java index 9517dcf00..d45854669 100644 --- a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/survey/impl/SurveyPlanServiceImpl.java +++ b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/survey/impl/SurveyPlanServiceImpl.java @@ -66,6 +66,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; +import java.time.ZoneId; import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -144,12 +145,16 @@ public class SurveyPlanServiceImpl extends ServiceImpl planMsgList = new ArrayList<>(); ImportParams params = new ImportParams(); //表头 params.setHeadRows(1); @@ -455,19 +437,13 @@ public class SurveyPlanServiceImpl extends ServiceImpl planExcels; try { - planExcels = ExcelImportUtil.importExcel(file.getInputStream(), SupervisionPlanExcel.class, params); - + planExcels = ExcelImportUtil.importExcel(file.getInputStream(), SupervisionPlanExcel.class, params); //如果存在非法数据,将不合格的数据导出 -// if (CollectionUtil.isEmpty(objectExcelImportResult.getList())) { -// throw new BusinessException(SupervisionResponseEnum.IMPORT_PLAN_DATA_ERROR); -// } - if (planExcels.size() > 1) { + if (CollUtil.isEmpty(planExcels)) { throw new BusinessException(SupervisionResponseEnum.IMPORT_PLAN_DATA_ERROR); } - - List planMsgList = new ArrayList<>(); //各地市 - List deptS = deptFeignClient.getDepSonDetailByDeptId(RequestUtil.getDeptIndex()).getData(); + List deptS = deptFeignClient.getDepSonDetailByDeptId("0d52f9f6e43ec0ee83013cd32da93f66").getData(); List supType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.SUPV_TYPE.getCode()).getData(); SubstationParam substationParam = new SubstationParam(); @@ -489,18 +465,12 @@ public class SurveyPlanServiceImpl extends ServiceImpl subList = new ArrayList<>(); - List list = Arrays.asList(planExcel.getSubstation(), planExcel.getSubstation2(), planExcel.getSubstation3()); - if (CollUtil.isEmpty(list)) { - msg.append("关联电站不能为空!"); + if (StrUtil.isEmpty(planExcel.getPlanName())) { + msg.append("计划名称不能为空!"); } else { - if ("1".equals(planExcel.getCustomSubstationFlag())) { - subList.addAll(data.stream().filter(x -> list.contains(x.getName())).collect(Collectors.toList())); - if (CollUtil.isEmpty(subList)) { - msg.append("关联电站不存在!"); - } - } + po.setPlanName(planExcel.getPlanName()); } + if (StrUtil.isEmpty(planExcel.getSupvType())) { msg.append("监督类型不能为空!"); } else { @@ -513,24 +483,38 @@ public class SurveyPlanServiceImpl extends ServiceImpl subIds = subList.stream().map(SubGetBase::getId).collect(Collectors.toList()); - po.setSubstation(String.join(",", subIds)); + if (StrUtil.isEmpty(planExcel.getCustomSubstationFlag())) { + msg.append("是否系统电站不能为空!"); + } else { + po.setCustomSubstationFlag(Integer.valueOf(planExcel.getCustomSubstationFlag())); + } + List list = Arrays.asList(planExcel.getSubstation(), planExcel.getSubstation2(), planExcel.getSubstation3()) + .stream().filter(Objects::nonNull).distinct().collect(Collectors.toList()); + if (CollUtil.isEmpty(list)) { + msg.append("关联电站不能为空!"); + } else { + if ("0".equals(planExcel.getCustomSubstationFlag())) { + List subIds = data.stream().filter(x -> list.contains(x.getName())).map(SubGetBase::getId).collect(Collectors.toList()); + if (CollUtil.isEmpty(subIds)) { + msg.append("关联电站不存在!"); + } else { + po.setSubstation(String.join(",", subIds)); + } } else { po.setSubstation(planExcel.getSubstation()); } - po.setCustomSubstationFlag(Integer.valueOf(planExcel.getCustomSubstationFlag())); - po.setSubstation(subList.get(0).getId()); - } catch (Exception e) { - msg.append("计划时间格式有误!"); } String string = msg.toString(); if (StrUtil.isNotBlank(string)) { @@ -543,23 +527,27 @@ public class SurveyPlanServiceImpl extends ServiceImpl processInstanceVariables = new HashMap<>(16); -// BpmProcessInstanceCreateReqDTO bpmProcessInstanceCreateReqDTO = new BpmProcessInstanceCreateReqDTO(); -// bpmProcessInstanceCreateReqDTO.setProcessDefinitionKey(SupervisionKeyEnum.SURVEY_PLAN.getKey()); -// bpmProcessInstanceCreateReqDTO.setBusinessKey(surveyPlan.getId()); -// bpmProcessInstanceCreateReqDTO.setStartUserSelectAssignees(new HashMap<>(16)); -// bpmProcessInstanceCreateReqDTO.setVariables(processInstanceVariables); -// String processInstanceId = bpmProcessFeignClient.createProcessInstance(surveyPlan.getCreateBy(), bpmProcessInstanceCreateReqDTO).getData(); -// // 将工作流的编号,更新到流程单中 -// surveyPlan.setProcessInstanceId(processInstanceId); -// this.baseMapper.updateById(surveyPlan); + } + } + if (CollUtil.isNotEmpty(info)) { + for (SurveyPlan surveyPlan : info) { + this.saveOrUpdate(surveyPlan); + SurveyPlan plan = this.baseMapper.selectById(surveyPlan.getId()); + Map processInstanceVariables = new HashMap<>(16); + BpmProcessInstanceCreateReqDTO bpmProcessInstanceCreateReqDTO = new BpmProcessInstanceCreateReqDTO(); + bpmProcessInstanceCreateReqDTO.setProcessDefinitionKey(SupervisionKeyEnum.SURVEY_PLAN.getKey()); + bpmProcessInstanceCreateReqDTO.setBusinessKey(plan.getId()); + bpmProcessInstanceCreateReqDTO.setStartUserSelectAssignees(new HashMap<>(16)); + bpmProcessInstanceCreateReqDTO.setVariables(processInstanceVariables); + String processInstanceId = bpmProcessFeignClient.createProcessInstance(plan.getCreateBy(), bpmProcessInstanceCreateReqDTO).getData(); + // 将工作流的编号,更新到流程单中 + plan.setProcessInstanceId(processInstanceId); + this.baseMapper.updateById(plan); } } //判断有没有错误信息 if (CollectionUtil.isNotEmpty(planMsgList)) { - ExcelUtil.exportExcel("失败列表.xlsx", SupervisionDevMainReportExcel.ExcelMsg.class, planMsgList); + ExcelUtil.exportExcel("失败列表.xlsx", SupervisionPlanExcel.ExcelMsg.class, planMsgList); } } catch (Exception e) { throw new BusinessException(SupervisionResponseEnum.IMPORT_PLAN_ERROR); diff --git a/pqs-system/system-boot/pom.xml b/pqs-system/system-boot/pom.xml index 77edcbbe6..7e982c8c7 100644 --- a/pqs-system/system-boot/pom.xml +++ b/pqs-system/system-boot/pom.xml @@ -91,11 +91,6 @@ cs-device-api 1.0.0 - - com.njcn.platform - algorithm-api - ${project.version} - diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/timer/tasks/algorithm/DeviceAlgorithmTaskRunner.java b/pqs-system/system-boot/src/main/java/com/njcn/system/timer/tasks/algorithm/DeviceAlgorithmTaskRunner.java deleted file mode 100644 index 2acdfbd2c..000000000 --- a/pqs-system/system-boot/src/main/java/com/njcn/system/timer/tasks/algorithm/DeviceAlgorithmTaskRunner.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.njcn.system.timer.tasks.algorithm; - -import cn.hutool.core.date.DatePattern; -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.StrUtil; -import com.njcn.algorithm.pojo.bo.BaseParam; -import com.njcn.algorithm.pojo.liteflow.LiteFlowAlgorithmFeignClient; -import com.njcn.system.timer.TimerTaskRunner; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Component; - -/** - * 类的介绍:装置算法执行链定时任务 - * - * @author xuyang - * @version 1.0.0 - * @createTime 2023/12/6 9:35 - */ -@Component -@RequiredArgsConstructor -public class DeviceAlgorithmTaskRunner implements TimerTaskRunner { - - private final LiteFlowAlgorithmFeignClient liteFlowFeignClient; - - @Override - public void action(String date) { - BaseParam baseParam = new BaseParam(); - baseParam.setFullChain(true); - baseParam.setRepair(false); - if(StrUtil.isBlank(date)){ - baseParam.setDataDate(DateUtil.yesterday().toString(DatePattern.NORM_DATE_PATTERN)); - }else { - baseParam.setDataDate(date); - } - liteFlowFeignClient.deviceExecutor(baseParam); - } - - -} diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/timer/tasks/algorithm/MeasurementAlgorithmTaskRunner.java b/pqs-system/system-boot/src/main/java/com/njcn/system/timer/tasks/algorithm/MeasurementAlgorithmTaskRunner.java deleted file mode 100644 index e480a8c5c..000000000 --- a/pqs-system/system-boot/src/main/java/com/njcn/system/timer/tasks/algorithm/MeasurementAlgorithmTaskRunner.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.njcn.system.timer.tasks.algorithm; - -import cn.hutool.core.date.DatePattern; -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.StrUtil; -import com.njcn.algorithm.pojo.bo.BaseParam; -import com.njcn.algorithm.pojo.liteflow.LiteFlowAlgorithmFeignClient; -import com.njcn.system.timer.TimerTaskRunner; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Component; - -/** - * 类的介绍:监测点算法执行链定时任务 - * - * @author xuyang - * @version 1.0.0 - * @createTime 2023/12/6 9:35 - */ -@Component -@RequiredArgsConstructor -public class MeasurementAlgorithmTaskRunner implements TimerTaskRunner { - - private final LiteFlowAlgorithmFeignClient liteFlowFeignClient; - - @Override - public void action(String date) { - BaseParam baseParam = new BaseParam(); - baseParam.setFullChain(true); - baseParam.setRepair(false); - if(StrUtil.isBlank(date)){ - baseParam.setDataDate(DateUtil.yesterday().toString(DatePattern.NORM_DATE_PATTERN)); - }else { - baseParam.setDataDate(date); - } - liteFlowFeignClient.measurementPointExecutor(baseParam); - } - - -} diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/timer/tasks/algorithm/MeasurementHourAlgorithmTaskRunner.java b/pqs-system/system-boot/src/main/java/com/njcn/system/timer/tasks/algorithm/MeasurementHourAlgorithmTaskRunner.java deleted file mode 100644 index 42e6b6eed..000000000 --- a/pqs-system/system-boot/src/main/java/com/njcn/system/timer/tasks/algorithm/MeasurementHourAlgorithmTaskRunner.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.njcn.system.timer.tasks.algorithm; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.StrUtil; -import com.njcn.algorithm.pojo.bo.BaseParam; -import com.njcn.algorithm.pojo.liteflow.LiteFlowAlgorithmFeignClient; -import com.njcn.system.timer.TimerTaskRunner; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Component; - -/** - * 类的介绍:监测点算法执行链定时任务 - * - * @author xuyang - * @version 1.0.0 - * @createTime 2023/12/6 9:35 - */ -@Component -@RequiredArgsConstructor -public class MeasurementHourAlgorithmTaskRunner implements TimerTaskRunner { - - private final LiteFlowAlgorithmFeignClient liteFlowFeignClient; - - @Override - public void action(String date) { - BaseParam baseParam = new BaseParam(); - baseParam.setFullChain(true); - //由于是按小时跑的,前端其他算法都是按天跑的,因此修改参数 - if(StrUtil.isBlank(date)){ - baseParam.setRepair(false); - baseParam.setDataDate(DateUtil.now()); - }else { - baseParam.setRepair(true); - baseParam.setBeginTime(date+ " 00:00:00"); - baseParam.setEndTime(date+ " 24:00:00"); - } - liteFlowFeignClient.measurementPointExecutorByHour(baseParam); - } - - -} diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/timer/tasks/algorithm/OrgAlgorithmTaskRunner.java b/pqs-system/system-boot/src/main/java/com/njcn/system/timer/tasks/algorithm/OrgAlgorithmTaskRunner.java deleted file mode 100644 index 3364999a7..000000000 --- a/pqs-system/system-boot/src/main/java/com/njcn/system/timer/tasks/algorithm/OrgAlgorithmTaskRunner.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.njcn.system.timer.tasks.algorithm; - -import cn.hutool.core.date.DatePattern; -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.StrUtil; -import com.njcn.algorithm.pojo.bo.BaseParam; -import com.njcn.algorithm.pojo.liteflow.LiteFlowAlgorithmFeignClient; -import com.njcn.system.timer.TimerTaskRunner; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Component; - -/** - * 类的介绍:单位监测点算法执行链定时任务 - * - * @author xuyang - * @version 1.0.0 - * @createTime 2023/12/6 9:35 - */ -@Component -@RequiredArgsConstructor -public class OrgAlgorithmTaskRunner implements TimerTaskRunner { - - private final LiteFlowAlgorithmFeignClient liteFlowFeignClient; - - @Override - public void action(String date) { - BaseParam baseParam = new BaseParam(); - baseParam.setFullChain(true); - baseParam.setRepair(false); - if(StrUtil.isBlank(date)){ - baseParam.setDataDate(DateUtil.yesterday().toString(DatePattern.NORM_DATE_PATTERN)); - }else { - baseParam.setDataDate(date); - } - liteFlowFeignClient.orgPointExecutor(baseParam); - } -} diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/timer/tasks/algorithm/SubstationAlgorithmTaskRunner.java b/pqs-system/system-boot/src/main/java/com/njcn/system/timer/tasks/algorithm/SubstationAlgorithmTaskRunner.java deleted file mode 100644 index f82fa9c6f..000000000 --- a/pqs-system/system-boot/src/main/java/com/njcn/system/timer/tasks/algorithm/SubstationAlgorithmTaskRunner.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.njcn.system.timer.tasks.algorithm; - -import cn.hutool.core.date.DatePattern; -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.StrUtil; -import com.njcn.algorithm.pojo.bo.BaseParam; -import com.njcn.algorithm.pojo.liteflow.LiteFlowAlgorithmFeignClient; -import com.njcn.system.timer.TimerTaskRunner; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Component; - -/** - * 类的介绍:变电站算法执行链定时任务 - * - * @author xuyang - * @version 1.0.0 - * @createTime 2023/12/6 9:35 - */ -@Component -@RequiredArgsConstructor -public class SubstationAlgorithmTaskRunner implements TimerTaskRunner { - - private final LiteFlowAlgorithmFeignClient liteFlowFeignClient; - - @Override - public void action(String date) { - BaseParam baseParam = new BaseParam(); - baseParam.setFullChain(true); - baseParam.setRepair(false); - if(StrUtil.isBlank(date)){ - baseParam.setDataDate(DateUtil.yesterday().toString(DatePattern.NORM_DATE_PATTERN)); - }else { - baseParam.setDataDate(date); - } - liteFlowFeignClient.substationExecutor(baseParam); - } -}