From 57b08a99c6efe87fd9e8b1b428d1aa6bba6d42dc Mon Sep 17 00:00:00 2001 From: caozehui <2427765068@qq.com> Date: Mon, 26 May 2025 15:21:21 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=A3=80=E6=B5=8B=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E3=80=81=E8=A2=AB=E6=A3=80=E8=AE=BE=E5=A4=87=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E5=8A=9F=E8=83=BD=E8=B0=83=E6=95=B4=202?= =?UTF-8?q?=E3=80=81=E5=A4=9A=E5=8F=B0=E8=AE=BE=E5=A4=87=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=90=8C=E6=97=B6=E8=BF=9B=E8=A1=8C=E8=84=9A=E6=9C=AC=E4=B8=8E?= =?UTF-8?q?ICD=E6=A3=80=E9=AA=8C=E6=97=B6Socket=E5=BC=82=E5=B8=B8=E4=B8=AD?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handler/SocketDevResponseService.java | 2 + .../gather/device/pojo/vo/CNDevExcel.java | 2 +- .../device/pojo/vo/ProvinceDevExcel.java | 11 +- .../device/service/impl/PqDevServiceImpl.java | 83 +++++++++++--- .../njcn/gather/plan/mapper/AdPlanMapper.java | 10 ++ .../plan/mapper/mapping/AdPlanMapper.xml | 5 + .../gather/plan/pojo/param/AdPlanParam.java | 1 + .../njcn/gather/plan/pojo/vo/AdPlanExcel.java | 19 +++- .../njcn/gather/plan/pojo/vo/CNPlanExcel.java | 2 +- .../plan/pojo/vo/ProvincePlanExcel.java | 3 +- .../plan/service/impl/AdPlanServiceImpl.java | 104 +++++++++++++++--- .../pojo/constant/DetectionValidMessage.java | 1 + .../pojo/enums/DetectionResponseEnum.java | 17 ++- 13 files changed, 217 insertions(+), 43 deletions(-) diff --git a/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java b/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java index 60802cf9..adad9d72 100644 --- a/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java +++ b/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java @@ -922,6 +922,8 @@ public class SocketDevResponseService { map.put("dataType", dataTypeList); map.put("icdType", icdType); socketMsg.setData(JSON.toJSONString(map)); + socketMsg.setRequestId(SourceOperateCodeEnum.YJC_XYJY.getValue()); + socketMsg.setOperateCode(SourceOperateCodeEnum.VERIFY_MAPPING$01.getValue()); System.out.println("开始脚本与icd校验:++++++++++"); SocketManager.sendMsg(s, JSON.toJSONString(socketMsg)); } diff --git a/detection/src/main/java/com/njcn/gather/device/pojo/vo/CNDevExcel.java b/detection/src/main/java/com/njcn/gather/device/pojo/vo/CNDevExcel.java index 0d4fe914..ac5934f0 100644 --- a/detection/src/main/java/com/njcn/gather/device/pojo/vo/CNDevExcel.java +++ b/detection/src/main/java/com/njcn/gather/device/pojo/vo/CNDevExcel.java @@ -21,7 +21,7 @@ public class CNDevExcel { @NotBlank(message = DetectionValidMessage.PREINVESTMENT_PLAN_NOT_BLANK) private String preinvestmentPlan; - @Excel(name = "设备编号(开始编号-结束编号,编号为数字)*", width = 50, orderNum = "2") + @Excel(name = "装置编号(开始编号-结束编号,编号为数字)*", width = 50, orderNum = "2") @NotBlank(message = DetectionValidMessage.NAME_NOT_BLANK) @Pattern(regexp = PatternRegex.CN_DEV_NAME_REGEX_IMPORT, message = DetectionValidMessage.CN_DEV_NAME_FORMAT_ERROR) private String name; diff --git a/detection/src/main/java/com/njcn/gather/device/pojo/vo/ProvinceDevExcel.java b/detection/src/main/java/com/njcn/gather/device/pojo/vo/ProvinceDevExcel.java index 7e0032cb..268b9cfa 100644 --- a/detection/src/main/java/com/njcn/gather/device/pojo/vo/ProvinceDevExcel.java +++ b/detection/src/main/java/com/njcn/gather/device/pojo/vo/ProvinceDevExcel.java @@ -39,7 +39,7 @@ public class ProvinceDevExcel implements Serializable { @NotBlank(message = DetectionValidMessage.MANUFACTURER_NOT_BLANK) private String manufacturer; - @Excel(name = "出厂日期*", width = 25, format = "yyyy-MM-dd", orderNum = "8") + @Excel(name = "出厂日期(yyyy-MM-dd)*", width = 25, format = "yyyy-MM-dd", orderNum = "8") @NotNull(message = DetectionValidMessage.CREATEDATETIME_NOT_NULL) private LocalDate createDate; @@ -75,4 +75,13 @@ public class ProvinceDevExcel implements Serializable { @NotNull(message = DetectionValidMessage.PORT_NOT_NULL) @Range(min = 1, max = 65535, message = DetectionValidMessage.PORT_RANGE_ERROR) private Integer port; + + @Excel(name = "样品编号", width = 20, orderNum = "17") + private String sampleId; + + @Excel(name = "送样日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd", orderNum = "18") + private String arrivedDate; + + @Excel(name="委托方", width = 40, orderNum = "19") + private String delegate; } diff --git a/detection/src/main/java/com/njcn/gather/device/service/impl/PqDevServiceImpl.java b/detection/src/main/java/com/njcn/gather/device/service/impl/PqDevServiceImpl.java index a3f3feef..cf1827dc 100644 --- a/detection/src/main/java/com/njcn/gather/device/service/impl/PqDevServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/device/service/impl/PqDevServiceImpl.java @@ -82,10 +82,10 @@ public class PqDevServiceImpl extends ServiceImpl implements public Page listPqDevs(PqDevParam.QueryParam queryParam) { Page page1 = this.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), this.getQueryWrapper(queryParam)); page1.getRecords().forEach(p -> { - if (ObjectUtil.isNotNull(p.getSeries())) { + if (StrUtil.isNotBlank(p.getSeries())) { p.setSeries(EncryptionUtil.decoderString(1, p.getSeries())); } - if (ObjectUtil.isNotNull(p.getDevKey())) { + if (StrUtil.isNotBlank(p.getDevKey())) { p.setDevKey(EncryptionUtil.decoderString(1, p.getDevKey())); } }); @@ -688,6 +688,9 @@ public class PqDevServiceImpl extends ServiceImpl implements } else { throw new BusinessException(DetectionResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK); } + } else { + pqDev.setSeries(null); + pqDev.setDevKey(null); } String name = pqDev.getName(); @@ -730,7 +733,7 @@ public class PqDevServiceImpl extends ServiceImpl implements this.checkRepeat(param, false); pqDev.setManufacturer("8fa73802c9e1abab973adcbeb0d58567"); // 南京灿能字典项目对应的id - long count = newDevList.stream().filter(dev -> dev.getName().equals(pqDev.getName())).count(); + long count = newDevList.stream().filter(dev -> dev.getName().equals(pqDev.getName()) && dev.getCreateId().equals(pqDev.getCreateId())).count(); if (count == 0) { newDevList.add(pqDev); } @@ -837,12 +840,17 @@ public class PqDevServiceImpl extends ServiceImpl implements pullDown.setStrings(Arrays.asList("是", "否")); pullDowns.add(pullDown); - // 是否支持系数校准 -// pullDown = new PullDown(); -// pullDown.setFirstCol(startCol + 11); -// pullDown.setLastCol(startCol + 11); -// pullDown.setStrings(Arrays.asList("是", "否")); -// pullDowns.add(pullDown); + // 委托方 + dictType = dictTypeService.getByCode("Delegate"); + if (ObjectUtil.isNotNull(dictType)) { + dictDataList = dictDataService.getDictDataByTypeId(dictType.getId()); + + pullDown = new PullDown(); + pullDown.setFirstCol(startCol + 15); + pullDown.setLastCol(startCol + 15); + pullDown.setStrings(dictDataList.stream().map(DictData::getName).collect(Collectors.toList())); + pullDowns.add(pullDown); + } return pullDowns; } @@ -925,11 +933,26 @@ public class PqDevServiceImpl extends ServiceImpl implements */ public void reverseVisualizeCNDev(List pqDevs, String patternId) { pqDevs.forEach(pqDev -> { - pqDev.setPreinvestmentPlan(dictDataService.getDictDataByName(pqDev.getPreinvestmentPlan()).getId()); + DictData preinvestmentPlanDictData = dictDataService.getDictDataByName(pqDev.getPreinvestmentPlan()); + if (ObjectUtil.isNull(preinvestmentPlanDictData)) { + throw new BusinessException(DetectionResponseEnum.PREINVESTMENT_PLAN_NOT_EXIST); + } else { + pqDev.setPreinvestmentPlan(preinvestmentPlanDictData.getId()); + } + DevType devType = devTypeService.getByName(pqDev.getDevType()); - pqDev.setDevType(devType.getId()); + if (ObjectUtil.isNull(devType)) { + throw new BusinessException(DetectionResponseEnum.DEV_TYPE_NOT_EXIST); + } else { + pqDev.setDevType(devType.getId()); + } pqDev.setPattern(patternId); - pqDev.setProtocol(dictDataService.getDictDataByName(pqDev.getProtocol()).getId()); + DictData protocolDictData = dictDataService.getDictDataByName(pqDev.getProtocol()); + if (ObjectUtil.isNull(protocolDictData)) { + throw new BusinessException(DetectionResponseEnum.PROTOCOL_NOT_EXIST); + } else { + pqDev.setProtocol(protocolDictData.getId()); + } pqDev.setCreateDate(LocalDateTime.now().toLocalDate()); pqDev.setCreateId(pqDev.getName()); pqDev.setTimeCheckResult(TimeCheckResultEnum.UNKNOWN.getValue()); @@ -1010,6 +1033,9 @@ public class PqDevServiceImpl extends ServiceImpl implements } else { throw new BusinessException(DetectionResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK); } + } else { + pqDev.setSeries(null); + pqDev.setDevKey(null); } String name = pqDev.getName(); @@ -1051,7 +1077,7 @@ public class PqDevServiceImpl extends ServiceImpl implements param.setDevType(pqDev.getDevType()); this.checkRepeat(param, false); - long count = newDevList.stream().filter(dev -> dev.getName().equals(pqDev.getName())).count(); + long count = newDevList.stream().filter(dev -> dev.getName().equals(pqDev.getName()) && dev.getCreateId().equals(pqDev.getCreateId())).count(); if (count == 0) { newDevList.add(pqDev); } @@ -1068,6 +1094,9 @@ public class PqDevServiceImpl extends ServiceImpl implements pqDev.setDevType(devTypeService.getById(pqDev.getDevType()).getName()); pqDev.setManufacturer(dictDataService.getDictDataById(pqDev.getManufacturer()).getName()); pqDev.setProtocol(dictDataService.getDictDataById(pqDev.getProtocol()).getName()); + if (StrUtil.isNotBlank(pqDev.getDelegate())) { + pqDev.setDelegate(dictDataService.getDictDataById(pqDev.getDelegate()).getName()); + } }); } @@ -1075,10 +1104,32 @@ public class PqDevServiceImpl extends ServiceImpl implements public void reverseVisualizeProvinceDev(List pqDevs, String patternId) { pqDevs.forEach(pqDev -> { DevType devType = devTypeService.getByName(pqDev.getDevType()); - pqDev.setDevType(devType.getId()); + if (ObjectUtil.isNull(devType)) { + throw new BusinessException(DetectionResponseEnum.DEV_TYPE_NOT_EXIST); + } else { + pqDev.setDevType(devType.getId()); + } pqDev.setPattern(patternId); - pqDev.setManufacturer(dictDataService.getDictDataByName(pqDev.getManufacturer()).getId()); - pqDev.setProtocol(dictDataService.getDictDataByName(pqDev.getProtocol()).getId()); + DictData manufacturerDictData = dictDataService.getDictDataByName(pqDev.getManufacturer()); + if (ObjectUtil.isNull(manufacturerDictData)) { + throw new BusinessException(DetectionResponseEnum.MANUFACTURER_NOT_EXIST); + } else { + pqDev.setManufacturer(manufacturerDictData.getId()); + } + DictData protocolDictData = dictDataService.getDictDataByName(pqDev.getProtocol()); + if (ObjectUtil.isNull(protocolDictData)) { + throw new BusinessException(DetectionResponseEnum.PROTOCOL_NOT_EXIST); + } else { + pqDev.setProtocol(protocolDictData.getId()); + } + if (StrUtil.isNotBlank(pqDev.getDelegate())) { + DictData delegateDictData = dictDataService.getDictDataByName(pqDev.getDelegate()); + if (ObjectUtil.isNull(delegateDictData)) { + throw new BusinessException(DetectionResponseEnum.DELEGATE_NOT_EXIST); + } else { + pqDev.setDelegate(delegateDictData.getId()); + } + } pqDev.setTimeCheckResult(TimeCheckResultEnum.UNKNOWN.getValue()); pqDev.setFactorCheckResult(FactorCheckResultEnum.UNKNOWN.getValue()); pqDev.setCheckState(CheckStateEnum.UNCHECKED.getValue()); diff --git a/detection/src/main/java/com/njcn/gather/plan/mapper/AdPlanMapper.java b/detection/src/main/java/com/njcn/gather/plan/mapper/AdPlanMapper.java index f6fab33c..bd33d7f5 100644 --- a/detection/src/main/java/com/njcn/gather/plan/mapper/AdPlanMapper.java +++ b/detection/src/main/java/com/njcn/gather/plan/mapper/AdPlanMapper.java @@ -5,6 +5,8 @@ import com.njcn.gather.plan.pojo.po.AdPlan; import com.njcn.gather.report.pojo.po.PqReport; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** * @author caozehui * @date 2024-12-09 @@ -27,5 +29,13 @@ public interface AdPlanMapper extends MPJBaseMapper { * @return */ PqReport getPqReportById(String id); + + /** + * 获取所有报告模板名称 + * + * @return + */ + List listAllReportTemplateName(); + } diff --git a/detection/src/main/java/com/njcn/gather/plan/mapper/mapping/AdPlanMapper.xml b/detection/src/main/java/com/njcn/gather/plan/mapper/mapping/AdPlanMapper.xml index 2ed76027..dd9a7351 100644 --- a/detection/src/main/java/com/njcn/gather/plan/mapper/mapping/AdPlanMapper.xml +++ b/detection/src/main/java/com/njcn/gather/plan/mapper/mapping/AdPlanMapper.xml @@ -17,5 +17,10 @@ WHERE id = #{id} and state = 1 + diff --git a/detection/src/main/java/com/njcn/gather/plan/pojo/param/AdPlanParam.java b/detection/src/main/java/com/njcn/gather/plan/pojo/param/AdPlanParam.java index d77b19b2..27fef24d 100644 --- a/detection/src/main/java/com/njcn/gather/plan/pojo/param/AdPlanParam.java +++ b/detection/src/main/java/com/njcn/gather/plan/pojo/param/AdPlanParam.java @@ -60,6 +60,7 @@ public class AdPlanParam { private List devIds; @ApiModelProperty(value = "是否关联报告") + @NotNull(message = DetectionValidMessage.ASSOCIATE_REPORT_NOT_NULL) private Integer associateReport; @ApiModelProperty(value = "报告模板名称") diff --git a/detection/src/main/java/com/njcn/gather/plan/pojo/vo/AdPlanExcel.java b/detection/src/main/java/com/njcn/gather/plan/pojo/vo/AdPlanExcel.java index 4184af0a..1b8348bf 100644 --- a/detection/src/main/java/com/njcn/gather/plan/pojo/vo/AdPlanExcel.java +++ b/detection/src/main/java/com/njcn/gather/plan/pojo/vo/AdPlanExcel.java @@ -33,19 +33,30 @@ public class AdPlanExcel { @NotBlank(message = DetectionValidMessage.ERRORSYS_NOT_BLANK) private String errorSysId; - @Excel(name = "是否做守时检测*", width = 15, replace = {"否_0", "是_1"}, needMerge = true, orderNum = "5") + @Excel(name = "数据处理原则*", width = 20, needMerge = true, orderNum = "5") + @NotBlank(message = DetectionValidMessage.DATA_RULE_NOT_BLANK) + private String dataRule; + + @Excel(name = "是否做守时检测*", width = 20, replace = {"否_0", "是_1"}, needMerge = true, orderNum = "6") @NotNull(message = DetectionValidMessage.TIMECHECK_NOT_NULL) private Integer timeCheck; - @Excel(name = "检测状态*", width = 10, replace = {"未检_0", "检测中_1", "检测完成_2"}, needMerge = true, orderNum = "6") + @Excel(name = "关联报告模版*", width = 20, replace = {"否_0", "是_1"}, needMerge = true, orderNum = "7") + @NotNull(message = DetectionValidMessage.ASSOCIATE_REPORT_NOT_NULL) + private Integer associateReport; + + @Excel(name = "报告模版(当关联报告模版为是时必填)", width = 40, needMerge = true, orderNum = "8") + private String reportTemplateId; + + @Excel(name = "检测状态*", width = 10, replace = {"未检_0", "检测中_1", "检测完成_2"}, needMerge = true, orderNum = "9") @NotNull(message = DetectionValidMessage.TEST_STATE_NOT_NULL) private Integer testState; - @Excel(name = "报告生成状态*", width = 15, replace = {"未生成_0", "部分生成_1", "全部生成_2"}, needMerge = true, orderNum = "7") + @Excel(name = "报告生成状态*", width = 15, replace = {"未生成_0", "部分生成_1", "全部生成_2"}, needMerge = true, orderNum = "10") @NotNull(message = DetectionValidMessage.REPORT_STATE_NOT_NULL) private Integer reportState; - @Excel(name = "检测结果*", width = 10, replace = {"不符合_0", "符合_1", "未检_2"}, needMerge = true, orderNum = "8") + @Excel(name = "检测结果*", width = 10, replace = {"不符合_0", "符合_1", "未检_2"}, needMerge = true, orderNum = "11") @NotNull(message = DetectionValidMessage.CHECK_RESULT_STATE_NOT_NULL) private Integer result; } diff --git a/detection/src/main/java/com/njcn/gather/plan/pojo/vo/CNPlanExcel.java b/detection/src/main/java/com/njcn/gather/plan/pojo/vo/CNPlanExcel.java index 02674991..ee6133e3 100644 --- a/detection/src/main/java/com/njcn/gather/plan/pojo/vo/CNPlanExcel.java +++ b/detection/src/main/java/com/njcn/gather/plan/pojo/vo/CNPlanExcel.java @@ -14,6 +14,6 @@ import java.util.List; public class CNPlanExcel extends AdPlanExcel { - @ExcelCollection(name = "绑定的设备", orderNum = "9") + @ExcelCollection(name = "绑定的设备", orderNum = "12") private List devices; } diff --git a/detection/src/main/java/com/njcn/gather/plan/pojo/vo/ProvincePlanExcel.java b/detection/src/main/java/com/njcn/gather/plan/pojo/vo/ProvincePlanExcel.java index a0904245..4a2f87cb 100644 --- a/detection/src/main/java/com/njcn/gather/plan/pojo/vo/ProvincePlanExcel.java +++ b/detection/src/main/java/com/njcn/gather/plan/pojo/vo/ProvincePlanExcel.java @@ -1,5 +1,6 @@ package com.njcn.gather.plan.pojo.vo; +import cn.afterturn.easypoi.excel.annotation.Excel; import cn.afterturn.easypoi.excel.annotation.ExcelCollection; import com.njcn.gather.device.pojo.vo.ProvinceDevExcel; import lombok.Data; @@ -13,6 +14,6 @@ import java.util.List; @Data public class ProvincePlanExcel extends AdPlanExcel { - @ExcelCollection(name = "绑定的设备", orderNum = "9") + @ExcelCollection(name = "绑定的设备", orderNum = "12") private List devices; } diff --git a/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java b/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java index 6ce1c74b..f9c97413 100644 --- a/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java @@ -38,8 +38,8 @@ import com.njcn.gather.plan.service.IAdPlanService; import com.njcn.gather.plan.service.IAdPlanSourceService; import com.njcn.gather.pojo.enums.DetectionResponseEnum; import com.njcn.gather.report.pojo.po.PqReport; +import com.njcn.gather.script.pojo.po.PqScript; import com.njcn.gather.script.pojo.po.PqScriptDtls; -import com.njcn.gather.script.service.IPqScriptCheckDataService; import com.njcn.gather.script.service.IPqScriptDtlsService; import com.njcn.gather.script.service.IPqScriptService; import com.njcn.gather.source.pojo.po.PqSource; @@ -104,7 +104,6 @@ public class AdPlanServiceImpl extends ServiceImpl impleme private final IDevTypeService devTypeService; private final IDictTypeService dictTypeService; private final AdHarmonicService adHarmonicService; - private final IPqScriptCheckDataService pqScriptCheckDataService; @Override public Page listAdPlan(AdPlanParam.QueryParam queryParam) { @@ -308,6 +307,14 @@ public class AdPlanServiceImpl extends ServiceImpl impleme if (StrUtil.isNotBlank(adPlan.getErrorSysId())) { adPlan.setErrorSysId(pqErrSysService.getPqErrSysById(adPlan.getErrorSysId()).getName()); } + if (StrUtil.isNotBlank(adPlan.getDataRule())) { + String dataRule = adPlan.getDataRule(); + adPlan.setDataRule(dictDataService.getDictDataById(dataRule).getName()); + } + if (StrUtil.isNotBlank(adPlan.getReportTemplateId())) { + PqReport report = this.baseMapper.getPqReportById(adPlan.getReportTemplateId()); + adPlan.setReportTemplateId(report.getName() + "_" + report.getVersion()); + } }); } @@ -632,6 +639,8 @@ public class AdPlanServiceImpl extends ServiceImpl impleme if (!PatternEnum.CONTRAST.getValue().equals(patternCode) && datasourceIds.length > 1) { throw new BusinessException(DetectionResponseEnum.IMPORT_DATASOURCE_ERROR); } + planExcel.setAssociateReport(0); + planExcel.setReportTemplateId(null); List sourceIds = pqSourceService.listPqSourceIdByName(sourceNames); adPlanSourceService.addAdPlanSource(planId, sourceIds); @@ -712,6 +721,9 @@ public class AdPlanServiceImpl extends ServiceImpl impleme if (!PatternEnum.CONTRAST.getValue().equals(patternCode) && datasourceIds.length > 1) { throw new BusinessException(DetectionResponseEnum.IMPORT_DATASOURCE_ERROR); } + if ((planExcel.getAssociateReport().equals(1) && "".equals(planExcel.getReportTemplateId()))) { + throw new BusinessException(DetectionResponseEnum.IMPORT_REPORT_TEMPLATE_ERROR); + } List sourceIds = pqSourceService.listPqSourceIdByName(sourceNames); adPlanSourceService.addAdPlanSource(planId, sourceIds); @@ -826,13 +838,46 @@ public class AdPlanServiceImpl extends ServiceImpl impleme private void reverseVisualize(List planList) { planList.forEach(adPlan -> { String[] datasourceIds = adPlan.getDatasourceId().split(StrUtil.COMMA); - adPlan.setDatasourceId(Arrays.stream(datasourceIds).map(id -> DataSourceEnum.getValueByMsg(id)).collect(Collectors.joining(StrUtil.COMMA))); + adPlan.setDatasourceId(Arrays.stream(datasourceIds).map(id -> { + String value = DataSourceEnum.getValueByMsg(id); + if (StrUtil.isBlank(value)) { + throw new BusinessException(DetectionResponseEnum.DATA_SOURCE_NOT_EXIST); + } else { + return value; + } + }).collect(Collectors.joining(StrUtil.COMMA))); - adPlan.setScriptId(pqScriptService.getPqScriptByName(adPlan.getScriptId()).getId()); + PqScript pqScript = pqScriptService.getPqScriptByName(adPlan.getScriptId()); + if (ObjectUtil.isNull(pqScript)) { + throw new BusinessException(DetectionResponseEnum.SCRIPT_NOT_EXIST); + } else { + adPlan.setScriptId(pqScript.getId()); + } - adPlan.setErrorSysId(pqErrSysService.getPqErrSysByName(adPlan.getErrorSysId()).getId()); + PqErrSys pqErrSys = pqErrSysService.getPqErrSysByName(adPlan.getErrorSysId()); + if (ObjectUtil.isNull(pqErrSys)) { + throw new BusinessException(DetectionResponseEnum.ERROR_SYSTEM_NOT_EXIST); + } else { + adPlan.setErrorSysId(pqErrSys.getId()); + } + + DictData dataRuleDictData = dictDataService.getDictDataByName(adPlan.getDataRule()); + if (ObjectUtil.isNull(dataRuleDictData)) { + throw new BusinessException(DetectionResponseEnum.DATA_RULE_NOT_EXIST); + } else { + adPlan.setDataRule(dataRuleDictData.getId()); + } + + if (StrUtil.isNotBlank(adPlan.getReportTemplateId())) { + String[] split = adPlan.getReportTemplateId().split("_"); + String reportId = this.baseMapper.getReportIdByNameAndVersion(split[0], split[1]); + if (ObjectUtil.isNull(reportId)) { + throw new BusinessException(DetectionResponseEnum.REPORT_TEMPLATE_NOT_EXIST); + } else { + adPlan.setReportTemplateId(reportId); + } + } adPlan.setCode(this.generateCode()); - adPlan.setState(DataStateEnum.ENABLE.getCode()); // 默认为顶级检测计划 adPlan.setFatherPlanId(CommonEnum.FATHER_ID.getValue()); @@ -1070,41 +1115,68 @@ public class AdPlanServiceImpl extends ServiceImpl impleme pullDown.setStrings(errSysNameList); pullDowns.add(pullDown); + // 数据处理原则 + dictType = dictTypeService.getByCode("Data_Rule"); + if (ObjectUtil.isNotNull(dictType)) { + List dictDataList = dictDataService.getDictDataByTypeId(dictType.getId()); + + pullDown = new PullDown(); + pullDown.setFirstCol(5); + pullDown.setLastCol(5); + pullDown.setStrings(dictDataList.stream().map(DictData::getName).collect(Collectors.toList())); + pullDowns.add(pullDown); + } + // 是否做守时检测 pullDown = new PullDown(); - pullDown.setFirstCol(5); - pullDown.setLastCol(5); + pullDown.setFirstCol(6); + pullDown.setLastCol(6); pullDown.setStrings(Arrays.asList("是", "否")); pullDowns.add(pullDown); + // 是否关联报告模板 + pullDown = new PullDown(); + pullDown.setFirstCol(7); + pullDown.setLastCol(7); + pullDown.setStrings(Arrays.asList("是", "否")); + pullDowns.add(pullDown); + + // 报告模板 + List strings = this.baseMapper.listAllReportTemplateName(); + pullDown = new PullDown(); + pullDown.setFirstCol(8); + pullDown.setLastCol(8); + pullDown.setStrings(strings); + pullDowns.add(pullDown); + // 检测状态 pullDown = new PullDown(); - pullDown.setFirstCol(6); - pullDown.setLastCol(6); + pullDown.setFirstCol(9); + pullDown.setLastCol(9); pullDown.setStrings(Arrays.asList(CheckStateEnum.UNCHECKED.getMsg(), CheckStateEnum.CHECKING.getMsg(), CheckStateEnum.CHECKED.getMsg())); pullDowns.add(pullDown); // 报告生成状态 pullDown = new PullDown(); - pullDown.setFirstCol(7); - pullDown.setLastCol(7); + pullDown.setFirstCol(10); + pullDown.setLastCol(10); pullDown.setStrings(Arrays.asList(PlanReportStateEnum.REPORT_STATE_NOT_GENERATED.getMsg(), PlanReportStateEnum.REPORT_STATE_PARTIALLY_GENERATED.getMsg(), PlanReportStateEnum.REPORT_STATE_ALL_GENERATED.getMsg())); pullDowns.add(pullDown); //检测结果 pullDown = new PullDown(); - pullDown.setFirstCol(8); - pullDown.setLastCol(8); + pullDown.setFirstCol(11); + pullDown.setLastCol(11); pullDown.setStrings(Arrays.asList(CheckResultEnum.UNCHECKED.getMsg(), CheckResultEnum.ACCORD.getMsg(), CheckResultEnum.UNCHECKED.getMsg())); pullDowns.add(pullDown); switch (scene) { case PROVINCE_PLATFORM: - List provinceDevPullDownList = pqDevService.getProvinceDevPullDownList(9); + List provinceDevPullDownList = pqDevService.getProvinceDevPullDownList(12); pullDowns.addAll(provinceDevPullDownList); break; case LEAVE_FACTORY_TEST: - List cnDevPullDownList = pqDevService.getCNDevPullDownList(9); + List cnDevPullDownList = pqDevService.getCNDevPullDownList(12); pullDowns.addAll(cnDevPullDownList); break; case SELF_TEST: diff --git a/detection/src/main/java/com/njcn/gather/pojo/constant/DetectionValidMessage.java b/detection/src/main/java/com/njcn/gather/pojo/constant/DetectionValidMessage.java index 235349b8..bdcb4e2d 100644 --- a/detection/src/main/java/com/njcn/gather/pojo/constant/DetectionValidMessage.java +++ b/detection/src/main/java/com/njcn/gather/pojo/constant/DetectionValidMessage.java @@ -180,4 +180,5 @@ public interface DetectionValidMessage { String DEV_TYPE_NAME_FORMAT_ERROR = "设备类型名称格式错误,只能包含字母、数字、中文、下划线、中划线、点号、空格,长度为1-32个字符"; String REPORT_NAME_NOT_BLANK = "报告模板不能为空"; String DATA_RULE_NOT_BLANK = "数据处理原则不能为空"; + String ASSOCIATE_REPORT_NOT_NULL = "是否关联报告模板不能为空"; } diff --git a/detection/src/main/java/com/njcn/gather/pojo/enums/DetectionResponseEnum.java b/detection/src/main/java/com/njcn/gather/pojo/enums/DetectionResponseEnum.java index 0f58be96..614b6a47 100644 --- a/detection/src/main/java/com/njcn/gather/pojo/enums/DetectionResponseEnum.java +++ b/detection/src/main/java/com/njcn/gather/pojo/enums/DetectionResponseEnum.java @@ -26,7 +26,7 @@ public enum DetectionResponseEnum { ICD_PATH_NAME_REPEAT("A02012", "icd名称重复"), ERR_SYS_BOUND_NOT_DELETE("A02013", "误差体系已被计划所绑定,无法删除!"), ERR_SYS_REPEAT("A02014", "已存在相同标准号、标准推行年份、适用设备等级的误差体系!"), - SCRIPT_NAME_REPEAT("A02015","脚本名称重复"), + SCRIPT_NAME_REPEAT("A02015", "脚本名称重复"), IMPORT_DATA_FAIL("A02040", "导入数据失败"), @@ -48,8 +48,19 @@ public enum DetectionResponseEnum { DEVICE_DELETE("A02056", "设备无法删除,已绑定计划!"), CREATE_DIRECTORY_FAILED("A02057", "创建目录失败"), DELETE_DIRECTORY_FAILED("A02058", "删除目录失败"), - CN_DEV_NAME_FORMAT_ERROR("A02059","设备名称格式错误,只能包含数字,长度为1-32位"), - PROVINCE_DEV_NAME_FORMAT_ERROR("A02060","设备名称格式错误,只能包含字母、数字、下划线、中划线、空格,长度为1-32位" ); + CN_DEV_NAME_FORMAT_ERROR("A02059", "设备名称格式错误,只能包含数字,长度为1-32位"), + PROVINCE_DEV_NAME_FORMAT_ERROR("A02060", "设备名称格式错误,只能包含字母、数字、下划线、中划线、空格,长度为1-32位"), + IMPORT_REPORT_TEMPLATE_ERROR("A02061", "当关联报告模板为是时,报告模板不能为空"), + DEV_TYPE_NOT_EXIST("A02062", "设备类型不存在,请先添加设备类型"), + MANUFACTURER_NOT_EXIST("A02063", "该设备厂家不存在,请先在\"设备厂家\"字典中添加"), + PROTOCOL_NOT_EXIST("A02064", "该协议不存在,请先在\"通讯协议\"字典中添加"), + DELEGATE_NOT_EXIST("A02065", "该委托方不存在,请先在\"委托方\"字典中添加"), + PREINVESTMENT_PLAN_NOT_EXIST("A02066", "该预投计划不存在,请先在\"预投计划\"字典中添加"), + DATA_SOURCE_NOT_EXIST("A02067", "该数据源不存在,请先在\"数据源\"字典中添加"), + SCRIPT_NOT_EXIST("A02068", "该脚本不存在,请先添加该脚本"), + ERROR_SYSTEM_NOT_EXIST("A02069", "该误差体系不存在,请先添加该误差体系"), + DATA_RULE_NOT_EXIST("A02070", "该数据处理原则不存在,请先在\"数据处理原则\"字典中添加"), + REPORT_TEMPLATE_NOT_EXIST("A02071", "该报告模板不存在,请先添加该报告模板"); private final String code;