From b96d0cdeb158e9e056865e70983ead25df510a5a Mon Sep 17 00:00:00 2001 From: caozehui <2427765068@qq.com> Date: Wed, 9 Apr 2025 16:16:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handler/SocketDevResponseService.java | 88 +++++++++++++---- .../gather/icd/mapper/PqIcdPathMapper.java | 8 ++ .../icd/mapper/mapping/PqIcdPathMapper.xml | 6 ++ .../gather/icd/service/IPqIcdPathService.java | 8 ++ .../service/impl/PqIcdPathServiceImpl.java | 5 + .../report/controller/ReportController.java | 1 - .../report/service/IPqReportService.java | 2 + .../service/impl/PqReportServiceImpl.java | 99 ++++++++++++++++++- .../script/controller/PqScriptController.java | 24 +++++ .../script/service/IPqScriptDtlsService.java | 20 +++- .../service/impl/PqScriptDtlsServiceImpl.java | 58 +++++++++++ .../service/impl/PqScriptServiceImpl.java | 1 + 12 files changed, 294 insertions(+), 26 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 ff63f08d..5cfa5adb 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 @@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.njcn.gather.detection.pojo.dto.DevXiNumData; import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum; import com.njcn.gather.detection.pojo.enums.SourceResponseCodeEnum; +import com.njcn.gather.detection.pojo.param.DevPhaseSequenceParam; import com.njcn.gather.detection.pojo.param.PreDetectionParam; import com.njcn.gather.detection.pojo.po.DevData; import com.njcn.gather.detection.pojo.po.SourceCompareDev; @@ -18,12 +19,12 @@ import com.njcn.gather.detection.util.socket.*; import com.njcn.gather.device.pojo.po.PqDev; import com.njcn.gather.device.pojo.vo.PreDetection; import com.njcn.gather.device.service.IPqDevService; +import com.njcn.gather.plan.service.IAdPlanService; import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam; import com.njcn.gather.script.pojo.param.PqScriptIssueParam; import com.njcn.gather.script.pojo.po.SourceIssue; import com.njcn.gather.script.service.IPqScriptCheckDataService; import com.njcn.gather.script.service.IPqScriptDtlsService; -import com.njcn.gather.plan.service.IAdPlanService; import com.njcn.gather.storage.pojo.param.StorageParam; import com.njcn.gather.storage.pojo.po.AdHarmonicResult; import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult; @@ -67,6 +68,8 @@ public class SocketDevResponseService { // ISO 8601格式 private final DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE_TIME; + private DevPhaseSequenceParam devPhaseSequenceParam; + private final List nonHarmonicList = Stream.of(DicDataEnum.FREQ.getCode(), DicDataEnum.V.getCode(), DicDataEnum.I.getCode(), DicDataEnum.IMBV.getCode(), DicDataEnum.IMBA.getCode(), DicDataEnum.VOLTAGE.getCode(), DicDataEnum.F.getCode()).collect(Collectors.toList()); private final List harmonicList = Stream.of(DicDataEnum.HV.getCode(), DicDataEnum.HI.getCode(), DicDataEnum.HP.getCode(), DicDataEnum.HSV.getCode(), DicDataEnum.HSI.getCode()).collect(Collectors.toList()); @@ -1081,7 +1084,7 @@ public class SocketDevResponseService { checkDataParam.setIsValueTypeName(false); List valueType = iPqScriptCheckDataService.getValueType(checkDataParam); - iPqDevService.updateResult(param.getDevIds(), valueType, param.getCode(),param.getUserId()); + iPqDevService.updateResult(param.getDevIds(), valueType, param.getCode(), param.getUserId()); CnSocketUtil.quitSend(param); } successComm.clear(); @@ -1271,7 +1274,6 @@ public class SocketDevResponseService { } /** - * * @param issue * @return key为V或I,value为对应的源下发信息 */ @@ -1299,8 +1301,8 @@ public class SocketDevResponseService { List data, List dataPhase) { StringBuffer str = new StringBuffer(); - if(isPhaseAngle){ - if(CollUtil.isNotEmpty(data)&&CollUtil.isNotEmpty(dataPhase)){ + if (isPhaseAngle) { + if (CollUtil.isNotEmpty(data) && CollUtil.isNotEmpty(dataPhase)) { if (data.size() == dataPhase.size()) { DevData.SqlDataDTO.ListDTO dto = data.get(0).getList(); DevData.SqlDataDTO.ListDTO phase = dataPhase.get(0).getList(); @@ -1310,11 +1312,11 @@ public class SocketDevResponseService { str.append(")"); } } - }else{ + } else { DevData.SqlDataDTO.ListDTO dto = data.get(0).getList(); str.append("装置(" + type + "a=" + String.format("%.4f", dto.getA()) + - type + "b=" + String.format("%.4f", dto.getB()) + - type + "c=" + String.format("%.4f", dto.getC()) ); + type + "b=" + String.format("%.4f", dto.getB()) + + type + "c=" + String.format("%.4f", dto.getC())); str.append(")"); } return str.toString(); @@ -1390,11 +1392,11 @@ public class SocketDevResponseService { Map sourceMap = channelList.stream() .collect(Collectors.toMap(x -> x.getChannelType(), Function.identity())); Boolean a = getaBoolean(sourceMap.get(type + "a"), CollUtil.isNotEmpty(data) ? data.get(0).getList().getA() : null, - CollUtil.isNotEmpty(dataPhase) ? dataPhase.get(0).getList().getA(): null); - Boolean b = getaBoolean(sourceMap.get(type + "b"), CollUtil.isNotEmpty(data) ? data.get(0).getList().getB(): null, - CollUtil.isNotEmpty(dataPhase) ? dataPhase.get(0).getList().getB(): null); - Boolean c = getaBoolean(sourceMap.get(type + "c"), CollUtil.isNotEmpty(data) ? data.get(0).getList().getC(): null, - CollUtil.isNotEmpty(dataPhase) ? dataPhase.get(0).getList().getC(): null); + CollUtil.isNotEmpty(dataPhase) ? dataPhase.get(0).getList().getA() : null); + Boolean b = getaBoolean(sourceMap.get(type + "b"), CollUtil.isNotEmpty(data) ? data.get(0).getList().getB() : null, + CollUtil.isNotEmpty(dataPhase) ? dataPhase.get(0).getList().getB() : null); + Boolean c = getaBoolean(sourceMap.get(type + "c"), CollUtil.isNotEmpty(data) ? data.get(0).getList().getC() : null, + CollUtil.isNotEmpty(dataPhase) ? dataPhase.get(0).getList().getC() : null); compareDev.setIsQualified(a && b && c); compareDev.setDesc(name + (compareDev.getIsQualified() ? "合格->" : "不合格->") + stepTag + desc + stepTag + devMessage(type, data, dataPhase)); return compareDev; @@ -1402,25 +1404,26 @@ public class SocketDevResponseService { /** * 相须校验-从幅值、相角两个维度判断是否合格 + * * @param channelListDTO * @param devData * @param devPhase * @return */ - private Boolean getaBoolean(SourceIssue.ChannelListDTO channelListDTO, Double devData, Double devPhase) { + private Boolean getaBoolean(SourceIssue.ChannelListDTO channelListDTO, Double devData, Double devPhase) { Boolean isDev = false; Boolean isPhase = false; - if(ObjectUtil.isNotNull(devData)){ - isDev= NumberUtil.isIn(BigDecimal.valueOf(devData), + if (ObjectUtil.isNotNull(devData)) { + isDev = NumberUtil.isIn(BigDecimal.valueOf(devData), BigDecimal.valueOf(channelListDTO.getFAmp() * 0.95), BigDecimal.valueOf(channelListDTO.getFAmp() * 1.05)); } - if(isPhaseAngle){ - if(ObjectUtil.isNotNull(devPhase)){ + if (isPhaseAngle) { + if (ObjectUtil.isNotNull(devPhase)) { isPhase = phaseBoolean(channelListDTO, devPhase); } - }else{ - isPhase=true; + } else { + isPhase = true; } return isDev && isPhase; @@ -1434,7 +1437,7 @@ public class SocketDevResponseService { * @param devPhase 装置返回角度 * @return */ - private Boolean phaseBoolean(SourceIssue.ChannelListDTO channelListDTO, Double devPhase) { + private Boolean phaseBoolean(SourceIssue.ChannelListDTO channelListDTO, Double devPhase) { Double phase = devPhase; if (devPhase < -180) { phase = devPhase + 360; @@ -1755,4 +1758,47 @@ public class SocketDevResponseService { } } + /** + * 脚本与设备校验 + * + * @param param + * @param socketDataMsg + */ + public void scriptToDeviceCheck(PreDetectionParam param,SocketDataMsg socketDataMsg) { + String data = socketDataMsg.getData(); + DevData devData = JSON.parseObject(data, DevData.class); + SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode()); + //SourceIssue sourceIssue = SocketManager.getSourceList().get(0); + + switch (Objects.requireNonNull(dictDataEnumByCode)) { + case SUCCESS: + List dataTypeList = new ArrayList<>(); + devData.getSqlData().forEach(obj -> { + dataTypeList.add(obj.getDesc()); + }); + devData.getSqlDataHarm().forEach(obj -> { + dataTypeList.add(obj.getDesc()); + }); + List dataTypeCopy = new ArrayList<>(devPhaseSequenceParam.getDataType()); + dataTypeCopy.removeAll(dataTypeList); + + + break; + case UNPROCESSED_BUSINESS: + break; + case NORMAL_RESPONSE: + break; + case DEV_ERROR: + break; + case DEV_TARGET: + break; + case RE_OPERATE: + break; + case MESSAGE_PARSING_ERROR: + break; + default: + CnSocketUtil.sendUnSocket(param.getUserPageId()); + break; + } + } } diff --git a/detection/src/main/java/com/njcn/gather/icd/mapper/PqIcdPathMapper.java b/detection/src/main/java/com/njcn/gather/icd/mapper/PqIcdPathMapper.java index 2897346b..9072150a 100644 --- a/detection/src/main/java/com/njcn/gather/icd/mapper/PqIcdPathMapper.java +++ b/detection/src/main/java/com/njcn/gather/icd/mapper/PqIcdPathMapper.java @@ -2,6 +2,7 @@ package com.njcn.gather.icd.mapper; import com.github.yulichang.base.MPJBaseMapper; import com.njcn.gather.icd.pojo.po.PqIcdPath; +import org.apache.ibatis.annotations.Param; /** * @author caozehui @@ -9,5 +10,12 @@ import com.njcn.gather.icd.pojo.po.PqIcdPath; */ public interface PqIcdPathMapper extends MPJBaseMapper { + /** + * 根据设备类型id获取Icd + * + * @param devTypeId + * @return + */ + PqIcdPath selectIcdByDevType(@Param("devTypeId") String devTypeId); } diff --git a/detection/src/main/java/com/njcn/gather/icd/mapper/mapping/PqIcdPathMapper.xml b/detection/src/main/java/com/njcn/gather/icd/mapper/mapping/PqIcdPathMapper.xml index a4062903..ec38e399 100644 --- a/detection/src/main/java/com/njcn/gather/icd/mapper/mapping/PqIcdPathMapper.xml +++ b/detection/src/main/java/com/njcn/gather/icd/mapper/mapping/PqIcdPathMapper.xml @@ -3,5 +3,11 @@ + diff --git a/detection/src/main/java/com/njcn/gather/icd/service/IPqIcdPathService.java b/detection/src/main/java/com/njcn/gather/icd/service/IPqIcdPathService.java index bc0e26c5..e0272b98 100644 --- a/detection/src/main/java/com/njcn/gather/icd/service/IPqIcdPathService.java +++ b/detection/src/main/java/com/njcn/gather/icd/service/IPqIcdPathService.java @@ -51,4 +51,12 @@ public interface IPqIcdPathService extends IService { * @return 成功返回true,失败返回false */ boolean deleteIcd(List ids); + + /** + * 根据设备类型id获取Icd + * + * @param devTypeId + * @return + */ + PqIcdPath getIcdByDevType(String devTypeId); } diff --git a/detection/src/main/java/com/njcn/gather/icd/service/impl/PqIcdPathServiceImpl.java b/detection/src/main/java/com/njcn/gather/icd/service/impl/PqIcdPathServiceImpl.java index 84cfbe69..9a7d77b9 100644 --- a/detection/src/main/java/com/njcn/gather/icd/service/impl/PqIcdPathServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/icd/service/impl/PqIcdPathServiceImpl.java @@ -69,6 +69,11 @@ public class PqIcdPathServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); wrapper.eq(PqIcdPath::getName, param.getName()) diff --git a/detection/src/main/java/com/njcn/gather/report/controller/ReportController.java b/detection/src/main/java/com/njcn/gather/report/controller/ReportController.java index 5c46f48d..46ce3390 100644 --- a/detection/src/main/java/com/njcn/gather/report/controller/ReportController.java +++ b/detection/src/main/java/com/njcn/gather/report/controller/ReportController.java @@ -21,7 +21,6 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; import java.util.List; diff --git a/detection/src/main/java/com/njcn/gather/report/service/IPqReportService.java b/detection/src/main/java/com/njcn/gather/report/service/IPqReportService.java index 8bc0872a..a374c512 100644 --- a/detection/src/main/java/com/njcn/gather/report/service/IPqReportService.java +++ b/detection/src/main/java/com/njcn/gather/report/service/IPqReportService.java @@ -66,4 +66,6 @@ public interface IPqReportService extends IService { void generateReport(DevReportParam devReportParam); void downloadReport(DevReportParam devReportParam, HttpServletResponse response); + + Map getMap(DevReportParam devReportParam); } diff --git a/detection/src/main/java/com/njcn/gather/report/service/impl/PqReportServiceImpl.java b/detection/src/main/java/com/njcn/gather/report/service/impl/PqReportServiceImpl.java index d12cef93..04db917a 100644 --- a/detection/src/main/java/com/njcn/gather/report/service/impl/PqReportServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/report/service/impl/PqReportServiceImpl.java @@ -8,6 +8,7 @@ import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONUtil; +import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; @@ -72,6 +73,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.io.*; +import java.lang.reflect.Field; import java.math.BigDecimal; import java.math.RoundingMode; import java.nio.file.Files; @@ -265,7 +267,7 @@ public class PqReportServiceImpl extends ServiceImpl i if (baseOriginalFilename.equals(detailOriginalFilename)) { throw new BusinessException(ReportResponseEnum.FILE_NAME_SAME_ERROR); } - if(baseFile.getSize() > FILE_SIZE_LIMIT || detailFile.getSize() > FILE_SIZE_LIMIT){ + if (baseFile.getSize() > FILE_SIZE_LIMIT || detailFile.getSize() > FILE_SIZE_LIMIT) { throw new BusinessException(ReportResponseEnum.FILE_SIZE_ERROR); } @@ -289,7 +291,7 @@ public class PqReportServiceImpl extends ServiceImpl i if (!baseFileOriginalFilename.endsWith(".docx")) { throw new BusinessException(ReportResponseEnum.FILE_SUFFIX_ERROR); } - if(baseFile.getSize() > FILE_SIZE_LIMIT){ + if (baseFile.getSize() > FILE_SIZE_LIMIT) { throw new BusinessException(ReportResponseEnum.FILE_SIZE_ERROR); } } @@ -300,7 +302,7 @@ public class PqReportServiceImpl extends ServiceImpl i if (!detailFileOriginalFilename.endsWith(".docx")) { throw new BusinessException(ReportResponseEnum.FILE_SUFFIX_ERROR); } - if(detailFile.getSize() > FILE_SIZE_LIMIT){ + if (detailFile.getSize() > FILE_SIZE_LIMIT) { throw new BusinessException(ReportResponseEnum.FILE_SIZE_ERROR); } } @@ -1639,4 +1641,95 @@ public class PqReportServiceImpl extends ServiceImpl i } return "/"; } + + + @Override + public Map getMap(DevReportParam devReportParam) { + HashMap resultMap = new HashMap<>(); + List adNonHarmonicResultList = adNonHarmonicService.listAll(devReportParam.getScriptId(), "result_" + devReportParam.getPlanCode(), devReportParam.getDevId()); + List adHarmonicResultList = adHarmonicService.listAll(devReportParam.getScriptId(), "result_" + devReportParam.getPlanCode(), devReportParam.getDevId()); + + Map> monitorIdMap1 = adNonHarmonicResultList.stream() + .sorted(Comparator.comparing(AdNonHarmonicResult::getMonitorId)) + .collect(Collectors.groupingBy(AdNonHarmonicResult::getMonitorId, LinkedHashMap::new, Collectors.toList())); + Map> monitorIdMap2 = adHarmonicResultList.stream() + .sorted(Comparator.comparing(AdHarmonicResult::getMonitorId)) + .collect(Collectors.groupingBy(AdHarmonicResult::getMonitorId, LinkedHashMap::new, Collectors.toList())); + + String[] monitorIds = monitorIdMap1.keySet().stream().map(String::valueOf).toArray(String[]::new); + + monitorIdMap1.get(monitorIds[0]).stream().forEach(adNonHarmonicResult -> { + DictTree dictTree = dictTreeService.getById(adNonHarmonicResult.getAdType()); + + DetectionData detectionDataA = JSON.parseObject(adNonHarmonicResult.getAValue(), DetectionData.class); + DetectionData detectionDataB = JSON.parseObject(adNonHarmonicResult.getBValue(), DetectionData.class); + DetectionData detectionDataC = JSON.parseObject(adNonHarmonicResult.getCValue(), DetectionData.class); + + DetectionData detectionDataT = JSON.parseObject(adNonHarmonicResult.getTValue(), DetectionData.class); + // 标准值 + Double standardValue = null; + if (ObjectUtil.isNotNull(detectionDataT)) { + standardValue = detectionDataT.getResultData(); + + resultMap.putIfAbsent(dictTree.getCode() + "_" + standardValue + "_T_Standard", detectionDataT.getResultData()); + resultMap.putIfAbsent(dictTree.getCode() + "_" + standardValue + "_T_Test", detectionDataT.getData()); + } else { + standardValue = detectionDataA.getResultData(); + + resultMap.putIfAbsent(dictTree.getCode() + "_" + standardValue + "_A_Standard", detectionDataA.getResultData()); + resultMap.putIfAbsent(dictTree.getCode() + "_" + standardValue + "_A_Test", detectionDataA.getData()); + + resultMap.putIfAbsent(dictTree.getCode() + "_" + standardValue + "_B_Standard", detectionDataB.getResultData()); + resultMap.putIfAbsent(dictTree.getCode() + "_" + standardValue + "_B_Test", detectionDataB.getData()); + + resultMap.putIfAbsent(dictTree.getCode() + "_" + standardValue + "_C_Standard", detectionDataC.getResultData()); + resultMap.putIfAbsent(dictTree.getCode() + "_" + standardValue + "_C_Test", detectionDataC.getData()); + } + resultMap.putIfAbsent(dictTree.getCode() + "_" + standardValue + "_Result", getResultStr(adNonHarmonicResult.getResultFlag())); + }); + + monitorIdMap2.get(monitorIds[0]).stream().forEach(adHarmonicResult -> { + DictTree dictTree = dictTreeService.getById(adHarmonicResult.getAdType()); + + for (int i = 2; i <= 50; i++) { + try { + Field fieldA = adHarmonicResult.getClass().getDeclaredField("aValue" + i); + fieldA.setAccessible(true); + Object a = fieldA.get(adHarmonicResult); + + Field fieldB = adHarmonicResult.getClass().getDeclaredField("bValue" + i); + fieldB.setAccessible(true); + Object b = fieldB.get(adHarmonicResult); + + Field fieldC = adHarmonicResult.getClass().getDeclaredField("cValue" + i); + fieldC.setAccessible(true); + Object c = fieldC.get(adHarmonicResult); + + List isDataList = new ArrayList<>(); + if (ObjectUtil.isNotNull(a) && ObjectUtil.isNotNull(b) && ObjectUtil.isNotNull(c)) { + DetectionData detectionData = JSON.parseObject(a.toString(), DetectionData.class); + resultMap.putIfAbsent(dictTree.getCode() + "_" + detectionData.getResultData() + "_" + i + "_A_Standard", detectionData.getResultData()); + resultMap.putIfAbsent(dictTree.getCode() + "_" + detectionData.getResultData() + "_" + i + "_A_Test", detectionData.getData()); + isDataList.add(detectionData.getIsData()); + + detectionData = JSON.parseObject(b.toString(), DetectionData.class); + resultMap.putIfAbsent(dictTree.getCode() + "_" + detectionData.getResultData() + "_" + i + "_B_Standard", detectionData.getResultData()); + resultMap.putIfAbsent(dictTree.getCode() + "_" + detectionData.getResultData() + "_" + i + "_B_Test", detectionData.getData()); + isDataList.add(detectionData.getIsData()); + + detectionData = JSON.parseObject(c.toString(), DetectionData.class); + resultMap.putIfAbsent(dictTree.getCode() + "_" + detectionData.getResultData() + "_" + i + "_C_Standard", detectionData.getResultData()); + resultMap.putIfAbsent(dictTree.getCode() + "_" + detectionData.getResultData() + "_" + i + "_C_Test", detectionData.getData()); + isDataList.add(detectionData.getIsData()); + } + + resultMap.putIfAbsent(dictTree.getCode() + "_" + i + "_Result", getResultStr(isDataList.stream().allMatch(data -> data == 1) ? 1 : (isDataList.stream().anyMatch(data -> data == 2) ? 2 : 4))); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + }); + + return resultMap; + } } diff --git a/detection/src/main/java/com/njcn/gather/script/controller/PqScriptController.java b/detection/src/main/java/com/njcn/gather/script/controller/PqScriptController.java index 70488be6..1419c981 100644 --- a/detection/src/main/java/com/njcn/gather/script/controller/PqScriptController.java +++ b/detection/src/main/java/com/njcn/gather/script/controller/PqScriptController.java @@ -4,9 +4,12 @@ import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.constant.OperateType; +import com.njcn.common.pojo.enums.common.LogEnum; import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.utils.LogUtil; +import com.njcn.gather.detection.pojo.param.DevPhaseSequenceParam; +import com.njcn.gather.detection.pojo.param.PreDetectionParam; import com.njcn.gather.script.pojo.param.PqScriptDtlsParam; import com.njcn.gather.script.pojo.param.PqScriptIssueParam; import com.njcn.gather.script.pojo.param.PqScriptParam; @@ -217,5 +220,26 @@ public class PqScriptController extends BaseController { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, checkData, methodDescribe); } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getCheckInfo1") + @ApiOperation("获取脚本与设备校验所需要的信息") + public HttpResult getIcdCheckInfo1(@RequestBody PreDetectionParam param) { + String methodDescribe = getMethodDescribe("getIcdCheckInfo1"); + LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe); + DevPhaseSequenceParam result = pqScriptDtlsService.getScriptToDeviceCheckInfo(param); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getCheckInfo2") + @ApiOperation("获取脚本与icd校验所需要的信息") + public HttpResult> getIcdCheckInfo2(@RequestBody PreDetectionParam param) { + String methodDescribe = getMethodDescribe("getIcdCheckInfo2"); + LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe); + Map result = pqScriptDtlsService.getScriptToIcdCheckInfo(param); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); + } + } diff --git a/detection/src/main/java/com/njcn/gather/script/service/IPqScriptDtlsService.java b/detection/src/main/java/com/njcn/gather/script/service/IPqScriptDtlsService.java index e784c8f1..d9e3e881 100644 --- a/detection/src/main/java/com/njcn/gather/script/service/IPqScriptDtlsService.java +++ b/detection/src/main/java/com/njcn/gather/script/service/IPqScriptDtlsService.java @@ -1,6 +1,8 @@ package com.njcn.gather.script.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.njcn.gather.detection.pojo.param.DevPhaseSequenceParam; +import com.njcn.gather.detection.pojo.param.PreDetectionParam; import com.njcn.gather.script.pojo.param.PqScriptDtlsParam; import com.njcn.gather.script.pojo.param.PqScriptIssueParam; import com.njcn.gather.script.pojo.param.ScriptParam; @@ -9,6 +11,7 @@ import com.njcn.gather.script.pojo.po.PqScriptDtls; import com.njcn.gather.script.pojo.po.SourceIssue; import java.util.List; +import java.util.Map; /** * @author caozehui @@ -114,11 +117,26 @@ public interface IPqScriptDtlsService extends IService { List checkDataList(ScriptParam param); /** - * @Description: 获取脚本详情描述 * @param param + * @Description: 获取脚本详情描述 * @return: java.lang.String * @Author: wr * @Date: 2025/3/31 9:40 */ String getScriptDtlsDesc(ScriptParam.Desc param); + + /** + * 获取脚本与设备校验所需要的信息 + * + * @param param + * @return + */ + DevPhaseSequenceParam getScriptToDeviceCheckInfo(PreDetectionParam param); + + /** + * 获取脚本与icd校验时所需要的信息 + * + * @return + */ + Map getScriptToIcdCheckInfo(PreDetectionParam param); } diff --git a/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java b/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java index 1f1a943d..0017928d 100644 --- a/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java @@ -10,9 +10,14 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.njcn.common.pojo.enums.common.DataStateEnum; import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum; +import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum; +import com.njcn.gather.detection.pojo.param.DevPhaseSequenceParam; +import com.njcn.gather.detection.pojo.param.PreDetectionParam; import com.njcn.gather.device.pojo.enums.CommonEnum; import com.njcn.gather.device.pojo.po.PqDev; import com.njcn.gather.device.service.IPqDevService; +import com.njcn.gather.icd.pojo.po.PqIcdPath; +import com.njcn.gather.icd.service.IPqIcdPathService; import com.njcn.gather.script.mapper.PqScriptCheckDataMapper; import com.njcn.gather.script.mapper.PqScriptDtlsMapper; import com.njcn.gather.script.mapper.PqScriptMapper; @@ -30,6 +35,7 @@ import com.njcn.gather.script.util.ScriptDtlsDesc; import com.njcn.gather.script.util.ThreePhaseUnbalance; import com.njcn.gather.system.dictionary.pojo.po.DictTree; import com.njcn.gather.system.dictionary.service.IDictTreeService; +import com.njcn.gather.system.pojo.enums.DicDataEnum; import com.njcn.gather.type.pojo.po.DevType; import com.njcn.gather.type.service.IDevTypeService; import lombok.RequiredArgsConstructor; @@ -83,6 +89,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl map = new HashMap<>(); + + PqScriptIssueParam issueParam = new PqScriptIssueParam(); +// issueParam.setPlanId(param.getPlanId()); + issueParam.setSourceId(param.getSourceId()); + issueParam.setDevIds(param.getDevIds()); + issueParam.setScriptId(param.getScriptId()); + issueParam.setIsPhaseSequence(SourceOperateCodeEnum.FORMAL_TEST.getValue()); + List sourceIssues = this.listSourceIssue(issueParam); + sourceIssues = sourceIssues.stream().filter(x -> !DicDataEnum.F.getCode().equals(x.getType()) && !DicDataEnum.VOLTAGE.getCode().equals(x.getType()) && !DicDataEnum.HP.getCode().equals(x.getType())).collect(Collectors.toList()); + + DevPhaseSequenceParam phaseSequenceParam = new DevPhaseSequenceParam(); + List dataTypeList = new ArrayList<>(); + sourceIssues.forEach(x -> { + dataTypeList.addAll(x.getDevValueTypeList()); + }); + phaseSequenceParam.setIgnoreCount(0); + phaseSequenceParam.setReadCount(1); + phaseSequenceParam.setDataType(dataTypeList); + + return phaseSequenceParam; + } + + @Override + public Map getScriptToIcdCheckInfo(PreDetectionParam param) { + Map map = new HashMap<>(); + + PqScriptIssueParam issueParam = new PqScriptIssueParam(); +// issueParam.setPlanId(param.getPlanId()); + issueParam.setSourceId(param.getSourceId()); + issueParam.setDevIds(param.getDevIds()); + issueParam.setScriptId(param.getScriptId()); + issueParam.setIsPhaseSequence(SourceOperateCodeEnum.FORMAL_TEST.getValue()); + List sourceIssues = this.listSourceIssue(issueParam); + sourceIssues = sourceIssues.stream().filter(x -> !DicDataEnum.F.getCode().equals(x.getType()) && !DicDataEnum.VOLTAGE.getCode().equals(x.getType()) && !DicDataEnum.HP.getCode().equals(x.getType())).collect(Collectors.toList()); + + map.put("scriptList", sourceIssues); + +// List devList = pqDevService.listByIds(param.getDevIds()); +// // 是否存在多个设备类型? +// List devTypeList = devList.stream().map(PqDev::getDevType).distinct().collect(Collectors.toList()); +// if (devTypeList.size() == 1) { +// DevType devType = devTypeService.getById(devTypeList.get(0)); +// PqIcdPath icd = pqIcdPathService.getIcdByDevType(devType.getId()); +// map.put("icdName", icd.getName()); +// } + return map; + } + private void unbanCheck(List info, PqScriptDtlsParam.CheckData channelListDTO, List list, diff --git a/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptServiceImpl.java b/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptServiceImpl.java index 38b0d198..01ad6444 100644 --- a/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptServiceImpl.java @@ -130,6 +130,7 @@ public class PqScriptServiceImpl extends ServiceImpl i */ private void checkRepeat(PqScriptParam param, boolean isExcludeSelf) { QueryWrapper wrapper = new QueryWrapper(); + wrapper.eq("state", DataStateEnum.ENABLE.getCode()); wrapper.eq("name", param.getName()); if (isExcludeSelf) { if(param instanceof PqScriptParam.UpdateParam){