From 6288aa565e2486f4ce1895227619c67203547521 Mon Sep 17 00:00:00 2001 From: caozehui <2427765068@qq.com> Date: Mon, 19 Jan 2026 14:23:23 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B3=BB=E6=95=B0=E4=B8=8B=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PreDetectionController.java | 21 ++ .../SocketContrastResponseService.java | 293 +++++++++++++++++- .../service/PreDetectionService.java | 5 + .../service/impl/DetectionServiceImpl.java | 259 ++++++++++++---- .../service/impl/PreDetectionServiceImpl.java | 35 +++ .../gather/detection/util/DetectionUtil.java | 91 ++++++ .../controller/PqStandardDevController.java | 5 +- .../mapper/PqStandardDevGainMapper.java | 13 + .../mapper/PqStandardDevGainRecordMapper.java | 13 + .../mapping/PqStandardDevGainMapper.xml | 7 + .../mapping/PqStandardDevGainRecordMapper.xml | 7 + .../device/pojo/po/PqStandardDevGain.java | 61 ++++ .../pojo/po/PqStandardDevGainRecord.java | 35 +++ .../device/pojo/vo/PqStandardDevVO.java | 20 ++ .../IPqStandardDevGainRecordService.java | 29 ++ .../service/IPqStandardDevGainService.java | 19 ++ .../device/service/IPqStandardDevService.java | 3 +- .../PqStandardDevGainRecordServiceImpl.java | 45 +++ .../impl/PqStandardDevGainServiceImpl.java | 42 +++ .../impl/PqStandardDevServiceImpl.java | 18 +- .../monitor/service/IPqMonitorService.java | 4 +- .../service/impl/PqMonitorServiceImpl.java | 4 +- .../service/impl/PqReportServiceImpl.java | 4 +- .../result/controller/ResultController.java | 2 +- .../result/pojo/param/MonitorQueryParam.java | 2 + .../gather/result/service/IResultService.java | 3 +- .../service/impl/ResultServiceImpl.java | 4 +- .../cfg/pojo/param/SysTestConfigParam.java | 3 + .../system/cfg/pojo/po/SysTestConfig.java | 5 + .../impl/SysTestConfigServiceImpl.java | 1 + 30 files changed, 958 insertions(+), 95 deletions(-) create mode 100644 detection/src/main/java/com/njcn/gather/device/mapper/PqStandardDevGainMapper.java create mode 100644 detection/src/main/java/com/njcn/gather/device/mapper/PqStandardDevGainRecordMapper.java create mode 100644 detection/src/main/java/com/njcn/gather/device/mapper/mapping/PqStandardDevGainMapper.xml create mode 100644 detection/src/main/java/com/njcn/gather/device/mapper/mapping/PqStandardDevGainRecordMapper.xml create mode 100644 detection/src/main/java/com/njcn/gather/device/pojo/po/PqStandardDevGain.java create mode 100644 detection/src/main/java/com/njcn/gather/device/pojo/po/PqStandardDevGainRecord.java create mode 100644 detection/src/main/java/com/njcn/gather/device/pojo/vo/PqStandardDevVO.java create mode 100644 detection/src/main/java/com/njcn/gather/device/service/IPqStandardDevGainRecordService.java create mode 100644 detection/src/main/java/com/njcn/gather/device/service/IPqStandardDevGainService.java create mode 100644 detection/src/main/java/com/njcn/gather/device/service/impl/PqStandardDevGainRecordServiceImpl.java create mode 100644 detection/src/main/java/com/njcn/gather/device/service/impl/PqStandardDevGainServiceImpl.java diff --git a/detection/src/main/java/com/njcn/gather/detection/controller/PreDetectionController.java b/detection/src/main/java/com/njcn/gather/detection/controller/PreDetectionController.java index 37409c91..f3b2700a 100644 --- a/detection/src/main/java/com/njcn/gather/detection/controller/PreDetectionController.java +++ b/detection/src/main/java/com/njcn/gather/detection/controller/PreDetectionController.java @@ -155,4 +155,25 @@ public class PreDetectionController extends BaseController { LogUtil.njcnDebug(log, "{}", methodDescribe); preDetectionService.exportAlignData(); } + + @OperateInfo(info = LogEnum.SYSTEM_COMMON) + @GetMapping("/canCoefficient") + @ApiOperation("比对模式是否能够进行系数校验") + public HttpResult canCoefficient() { + String methodDescribe = getMethodDescribe("canCoefficient"); + LogUtil.njcnDebug(log, "{}", methodDescribe); + + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, preDetectionService.getCanCoefficient(), methodDescribe); + } + + @OperateInfo(info = LogEnum.SYSTEM_COMMON) + @GetMapping("/startCoefficient") + @ApiOperation("比对模式开启系数校验") + public HttpResult startCoefficient() { + String methodDescribe = getMethodDescribe("startCoefficient"); + LogUtil.njcnDebug(log, "{}", methodDescribe); + + preDetectionService.startCoefficient(); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); + } } diff --git a/detection/src/main/java/com/njcn/gather/detection/handler/SocketContrastResponseService.java b/detection/src/main/java/com/njcn/gather/detection/handler/SocketContrastResponseService.java index 76ae946e..24c24280 100644 --- a/detection/src/main/java/com/njcn/gather/detection/handler/SocketContrastResponseService.java +++ b/detection/src/main/java/com/njcn/gather/detection/handler/SocketContrastResponseService.java @@ -11,7 +11,9 @@ import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.serializer.SerializerFeature; import com.google.common.collect.HashBiMap; +import com.njcn.common.pojo.enums.common.DataStateEnum; import com.njcn.common.pojo.exception.BusinessException; +import com.njcn.gather.detection.pojo.dto.DevXiNumData; import com.njcn.gather.detection.pojo.dto.WaveCommandDTO; import com.njcn.gather.detection.pojo.dto.WaveResultDTO; import com.njcn.gather.detection.pojo.enums.*; @@ -24,15 +26,17 @@ import com.njcn.gather.detection.pojo.vo.*; import com.njcn.gather.detection.service.IAdPariService; import com.njcn.gather.detection.service.impl.DetectionServiceImpl; import com.njcn.gather.detection.util.DetectionUtil; -import com.njcn.gather.detection.util.socket.CnSocketUtil; -import com.njcn.gather.detection.util.socket.FormalTestManager; -import com.njcn.gather.detection.util.socket.MsgUtil; -import com.njcn.gather.detection.util.socket.SocketManager; +import com.njcn.gather.detection.util.socket.*; import com.njcn.gather.detection.util.socket.websocket.WebServiceManager; import com.njcn.gather.device.pojo.enums.PatternEnum; +import com.njcn.gather.device.pojo.po.PqStandardDevGain; +import com.njcn.gather.device.pojo.po.PqStandardDevGainRecord; import com.njcn.gather.device.pojo.vo.PreDetection; import com.njcn.gather.device.service.IPqDevService; +import com.njcn.gather.device.service.IPqStandardDevGainRecordService; +import com.njcn.gather.device.service.IPqStandardDevGainService; import com.njcn.gather.device.service.IPqStandardDevService; +import com.njcn.gather.monitor.pojo.po.PqMonitor; import com.njcn.gather.monitor.service.IPqMonitorService; import com.njcn.gather.plan.pojo.enums.DataSourceEnum; import com.njcn.gather.plan.service.IAdPlanService; @@ -62,6 +66,7 @@ import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Field; import java.math.BigDecimal; +import java.math.RoundingMode; import java.text.DecimalFormat; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -92,6 +97,8 @@ public class SocketContrastResponseService { private final IAdPariService adPairService; private final ICompareWaveService compareWaveService; private final IAdPlanTestConfigService adPlanTestConfigService; + private final IPqStandardDevGainService pqStandardDevGainService; + private final IPqStandardDevGainRecordService pqStandardDevGainRecordService; /** @@ -185,6 +192,7 @@ public class SocketContrastResponseService { FormalTestManager.isXu = param.getPhaseCheck() == 1 ? true : false; // FormalTestManager.isXu = true; FormalTestManager.nonWaveDataSourceEnum = null; + DetectionServiceImpl.vAndIResultMap = new HashMap<>(); String[] datasourceIds = FormalTestManager.currentTestPlan.getDatasourceId().split(","); for (String datasourceId : datasourceIds) { @@ -377,6 +385,10 @@ public class SocketContrastResponseService { case RECORD_WAVE_STEP1: this.recordWave(param, socketDataMsg); break; + //系数校验 + case Coefficient_Check: + this.coefficient(param, socketDataMsg); + break; //退出关闭 case QUITE: quitDeal(socketDataMsg, param); @@ -1405,6 +1417,28 @@ public class SocketContrastResponseService { pqDevService.updateResult(id1.split(CnSocketUtil.SPLIT_TAG)[0], param.getUserId()); }); FormalTestManager.isTesting = false; + +// if (CollUtil.isNotEmpty(DetectionServiceImpl.vAndIResultMap)) { +// // 是否进行系数校准 +// //万一录波了这里就进不来了,但是在误差处理的时候DetectionServiceImpl.vAndIResultMap该集合会保留不符合的结果 +// +// XiNumberManager.xiDevList.clear(); +// XiNumberManager.devXiNumDataMap.clear(); +// List stdIpList = DetectionServiceImpl.vAndIResultMap.values().stream().map(DetectionServiceImpl.VAndIResult::getIp).collect(Collectors.toList()); +// XiNumberManager.xiDevList = FormalTestManager.standardDevList.stream().filter(d -> stdIpList.contains(d.getDevIP())).collect(Collectors.toList()); +// // 逐一设备向通讯模块要原始系数 +// SocketMsg socketMsg = new SocketMsg<>(); +// socketMsg.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue()); +// socketMsg.setOperateCode(SourceOperateCodeEnum.DATA_CHNFACTOR$01.getValue()); +// PreDetection preDetection = XiNumberManager.xiDevList.get(0); +// Map map = new HashMap<>(); +// map.put("devIP", preDetection.getDevIP()); +// map.put("chnNum", preDetection.getDevChns()); +// socketMsg.setData(JSON.toJSONString(map)); +// SocketManager.sendMsg(param.getUserPageId() + CnSocketUtil.CONTRAST_DEV_TAG, JSON.toJSONString(socketMsg)); +// +// FormalTestManager.currentStep = SourceOperateCodeEnum.Coefficient_Check; +// } } } else { // 配对关系入库 @@ -1682,6 +1716,160 @@ public class SocketContrastResponseService { } } + private void coefficient(PreDetectionParam param, SocketDataMsg socketDataMsg) { + SourceOperateCodeEnum sourceOperateCodeEnum = SourceOperateCodeEnum.getDictDataEnumByCode(socketDataMsg.getOperateCode()); + SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode()); + SocketMsg xiSocket = new SocketMsg<>(); + xiSocket.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue()); + + switch (Objects.requireNonNull(sourceOperateCodeEnum)) { + case DATA_CHNFACTOR$01: + //获取系数 + switch (Objects.requireNonNull(dictDataEnumByCode)) { + case SUCCESS: + if (CollUtil.isNotEmpty(XiNumberManager.xiDevList)) { + List gfList = JSON.parseArray(socketDataMsg.getData(), DevXiNumData.GF.class); + DevXiNumData devXiNumData = new DevXiNumData(); + String ip = XiNumberManager.xiDevList.get(0).getDevIP(); + devXiNumData.setDevIP(ip); + //String stdMonitorId = DetectionServiceImpl.vAndIResultMap.keySet().stream().filter(key -> key.contains(ip)).findFirst().get(); + + List pqStandardDevGainList = new ArrayList<>(); + List recordList = new ArrayList<>(); + for (int i = 0; i < gfList.size(); i++) { + DevXiNumData.GF gf = gfList.get(i); + String stdDevMonitorId = FormalTestManager.devIdMapComm.get(ip) + CnSocketUtil.SPLIT_TAG + (gf.getUMonitorPoint() + 1); + String devMonitorId = FormalTestManager.pairsIdMap.inverse().get(stdDevMonitorId); + PqStandardDevGain pqStandardDevGain = new PqStandardDevGain(); + pqStandardDevGain.setStdDevMonitorId(stdDevMonitorId); + + DevXiNumData.F f = gf.getF(); + pqStandardDevGain.setUaGain(f.getUa_gain()); + pqStandardDevGain.setUbGain(f.getUb_gain()); + pqStandardDevGain.setUcGain(f.getUc_gain()); + pqStandardDevGain.setU0Gain(f.getU0_gain()); + pqStandardDevGain.setIaGain(f.getIa_gain()); + pqStandardDevGain.setIbGain(f.getIb_gain()); + pqStandardDevGain.setIcGain(f.getIc_gain()); + pqStandardDevGain.setI0Gain(f.getI0_gain()); + pqStandardDevGain.setUabGain(f.getUab_gain()); + pqStandardDevGain.setUbcGain(f.getUbc_gain()); + pqStandardDevGain.setUcaGain(f.getUca_gain()); + pqStandardDevGain.setState(DataStateEnum.ENABLE.getCode()); + pqStandardDevGainList.add(pqStandardDevGain); + DetectionServiceImpl.VAndIResult vAndIResult = DetectionServiceImpl.vAndIResultMap.get(ip + CnSocketUtil.SPLIT_TAG + (gf.getUMonitorPoint() + 1)); + if (ObjectUtil.isNotNull(vAndIResult)) { + int maxNum = pqStandardDevGainRecordService.getMaxNum(stdDevMonitorId, devMonitorId); + PqStandardDevGainRecord record = new PqStandardDevGainRecord(); + record.setStdDevMonitorId(stdDevMonitorId); + record.setDevMonitorId(devMonitorId); + record.setNum(maxNum + 1); + recordList.add(record); + updateGfList(f, vAndIResult, stdDevMonitorId, maxNum); + } + } + + xiSocket.setOperateCode(SourceOperateCodeEnum.DATA_CHNFACTOR$02.getValue()); + devXiNumData.setGf(gfList); + xiSocket.setData(JSON.toJSONString(devXiNumData)); + SocketManager.sendMsg(param.getUserPageId() + CnSocketUtil.CONTRAST_DEV_TAG, JSON.toJSONString(xiSocket)); + + // 原始系数入库 + pqStandardDevGainService.add(pqStandardDevGainList); + pqStandardDevGainRecordService.addOrUpdate(recordList); + } + break; + case UNPROCESSED_BUSINESS: + break; + case NORMAL_RESPONSE: + break; + case DATA_RESOLVE: + break; + case COMMUNICATION_ERR: + break; + default: + break; + } + + break; + case DATA_CHNFACTOR$02: + //系数下发后的响应 + switch (Objects.requireNonNull(dictDataEnumByCode)) { + case SUCCESS: + //单台装置系数下发后,需要删除集合中存在的当前装置 + XiNumberManager.xiDevList.remove(0); + //继续下发每台装置系数,只到集合为空 + if (CollUtil.isNotEmpty(XiNumberManager.xiDevList)) { + xiSocket.setOperateCode(SourceOperateCodeEnum.DATA_CHNFACTOR$01.getValue()); + xiSocket.setData(JSON.toJSONString(XiNumberManager.devXiNumDataMap.get(XiNumberManager.xiDevList.get(0)))); + PreDetection preDetection = XiNumberManager.xiDevList.get(0); + Map map = new HashMap<>(); + map.put("devIP", preDetection.getDevIP()); + map.put("chnNum", preDetection.getDevChns()); + xiSocket.setData(JSON.toJSONString(map)); + SocketManager.sendMsg(param.getUserPageId() + CnSocketUtil.CONTRAST_DEV_TAG, JSON.toJSONString(xiSocket)); + } else { + //{"requestId":"Coefficient_Check","operateCode":"DATA_CHNFACTOR$02","data":"end","code":10200} + // 通知前端全部下发系数完成 + } + break; + case UNPROCESSED_BUSINESS: + break; + case NORMAL_RESPONSE: + break; + case DATA_RESOLVE: + //quitSend(param); + break; + case COMMUNICATION_ERR: + break; + default: + break; + } + break; +// case DEV_DATA_REQUEST_02: +// //实时采集申请 +// String data = socketDataMsg.getData(); +// DevData devData = JSON.parseObject(data, DevData.class); +// if (ObjectUtil.isNotNull(dictDataEnumByCode)) { +// switch (dictDataEnumByCode) { +// case SUCCESS: +// if (devData.getResult()) { +// FormalTestManager.realDataXiList.add(devData); +// successComm.add(devData.getId()); +// System.out.println(successComm.size() + " ==" + FormalTestManager.monitorIdListComm.size() + "FormalTestManager.realDataXiList:" + FormalTestManager.realDataXiList.size() + "当前步骤" + XiNumberManager.stepNumber); +// if (successComm.size() == FormalTestManager.monitorIdListComm.size()) { +// processData(param, xiSocket); +// } +// } else { +// System.out.println("系数校准抛除数据" + devData); +// } +// break; +// case UNPROCESSED_BUSINESS: +// WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg)); +// break; +// case NORMAL_RESPONSE: +// if (devData.getResult()) { +// FormalTestManager.realDataXiList.add(devData); +// } else { +// System.out.println("系数校准抛除数据" + devData); +// } +// break; +// default: +// xiSocket.setRequestId(socketDataMsg.getRequestId()); +// xiSocket.setOperateCode(socketDataMsg.getOperateCode()); +// xiSocket.setData(dictDataEnumByCode.getMessage()); +// WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(xiSocket)); +// break; +// } +// } +// break; + default: + WebServiceManager.sendUnknownErrorMessage(param.getUserPageId()); + break; + } + + } + /** * 退出检测返回 @@ -1948,8 +2136,13 @@ public class SocketContrastResponseService { isStar = true; isDelta = false; } else { - isStar = false; - isDelta = true; + if (DetectionCodeEnum.STAR.getCode().equals(monitorListDTO.getConnection())) { + isStar = true; + isDelta = false; + } else { + isStar = false; + isDelta = true; + } } } @@ -2052,8 +2245,13 @@ public class SocketContrastResponseService { isStar = true; isDelta = false; } else { - isStar = false; - isDelta = true; + if (DetectionCodeEnum.STAR.getCode().equals(monitorListDTO.getConnection())) { + isStar = true; + isDelta = false; + } else { + isStar = false; + isDelta = true; + } } } @@ -2273,8 +2471,13 @@ public class SocketContrastResponseService { isStar = true; isDelta = false; } else { - isStar = false; - isDelta = true; + if (DetectionCodeEnum.STAR.getCode().equals(monitorListDTO.getConnection())) { + isStar = true; + isDelta = false; + } else { + isStar = false; + isDelta = true; + } } } @@ -2592,18 +2795,30 @@ public class SocketContrastResponseService { devInfo = pqDevService.getDevInfo(Collections.singletonList(devId)); } Integer usePhaseIndex = devInfo.get(0).getUsePhaseIndex(); - List allDesc = data.getSqlData().stream().map(x -> x.getDesc()).collect(Collectors.toList()); allDesc.addAll(data.getSqlDataHarm().stream().map(x -> x.getDesc()).collect(Collectors.toList())); + String bzDevId = devId; + if (isStdDev) { + String s = FormalTestManager.pairsIdMap.inverse().get(devId + CnSocketUtil.SPLIT_TAG + splitArr[1]); + bzDevId = s.split(CnSocketUtil.SPLIT_TAG)[0]; + } + PqMonitor monitor = pqMonitorService.getByDevIdAndNum(bzDevId, Integer.parseInt(splitArr[1])); + DictData dictData = dictDataService.getById(monitor.getConnection()); for (DevData.SqlDataDTO sqlDataDTO : data.getSqlData()) { if (usePhaseIndex.equals(1)) { if (DetectionCodeEnum.PVRMS.getCode().equals(sqlDataDTO.getDesc()) || DetectionCodeEnum.PU1.getCode().equals(sqlDataDTO.getDesc())) { continue; } } else { - if (DetectionCodeEnum.VRMS.getCode().equals(sqlDataDTO.getDesc()) || DetectionCodeEnum.U1.getCode().equals(sqlDataDTO.getDesc())) { - continue; + if (DetectionCodeEnum.STAR.getCode().equals(dictData.getCode())) { + if (DetectionCodeEnum.PVRMS.getCode().equals(sqlDataDTO.getDesc()) || DetectionCodeEnum.PU1.getCode().equals(sqlDataDTO.getDesc())) { + continue; + } + } else { + if ((DetectionCodeEnum.VRMS.getCode().equals(sqlDataDTO.getDesc()) || DetectionCodeEnum.U1.getCode().equals(sqlDataDTO.getDesc()))) { + continue; + } } } @@ -2651,8 +2866,14 @@ public class SocketContrastResponseService { continue; } } else { - if (DetectionCodeEnum.V2_50.getCode().equals(sqlDataDTO.getDesc()) || DetectionCodeEnum.SV_1_49.getCode().equals(sqlDataDTO.getDesc())) { - continue; + if (DetectionCodeEnum.STAR.getCode().equals(dictData.getCode())) { + if (DetectionCodeEnum.PV2_50.getCode().equals(sqlDataDTO.getDesc()) || DetectionCodeEnum.PSV_1_49.getCode().equals(sqlDataDTO.getDesc())) { + continue; + } + } else { + if (DetectionCodeEnum.V2_50.getCode().equals(sqlDataDTO.getDesc()) || DetectionCodeEnum.SV_1_49.getCode().equals(sqlDataDTO.getDesc())) { + continue; + } } } @@ -3289,4 +3510,46 @@ public class SocketContrastResponseService { devData.setSqlDataHarm(sqlDataHarmDTOS); return devData; } + + /** + * 修改通道系数 + * + * @param f + */ + private void updateGfList(DevXiNumData.F f, DetectionServiceImpl.VAndIResult vAndIResult, String stdDevMonitorId, int maxNum) { + DevXiNumData.F originF = BeanUtil.copyProperties(f, DevXiNumData.F.class); + if (maxNum != 0) { + PqStandardDevGain pqStandardDevGain = pqStandardDevGainService.get(stdDevMonitorId); + originF.setUa_gain(pqStandardDevGain.getUaGain()); + originF.setUb_gain(pqStandardDevGain.getUbGain()); + originF.setUc_gain(pqStandardDevGain.getUcGain()); + originF.setU0_gain(pqStandardDevGain.getU0Gain()); + originF.setIa_gain(pqStandardDevGain.getIaGain()); + originF.setIb_gain(pqStandardDevGain.getIbGain()); + originF.setIc_gain(pqStandardDevGain.getIcGain()); + originF.setI0_gain(pqStandardDevGain.getI0Gain()); + originF.setUab_gain(pqStandardDevGain.getUabGain()); + originF.setUbc_gain(pqStandardDevGain.getUbcGain()); + originF.setUca_gain(pqStandardDevGain.getUcaGain()); + } + + if (vAndIResult.getVa() && NumberUtil.isIn(BigDecimal.valueOf(vAndIResult.getVaXi() * 10000), BigDecimal.valueOf(originF.getUa_gain() * 0.95), BigDecimal.valueOf(originF.getUa_gain() * 1.05))) { + f.setUa_gain(BigDecimal.valueOf(f.getUa_gain()).multiply(BigDecimal.valueOf(vAndIResult.getVaXi())).setScale(0, RoundingMode.HALF_UP).intValue()); + } + if (vAndIResult.getVb() && NumberUtil.isIn(BigDecimal.valueOf(vAndIResult.getVbXi() * 10000), BigDecimal.valueOf(originF.getUb_gain() * 0.95), BigDecimal.valueOf(originF.getUb_gain() * 1.05))) { + f.setUb_gain(BigDecimal.valueOf(f.getUb_gain()).multiply(BigDecimal.valueOf(vAndIResult.getVbXi())).setScale(0, RoundingMode.HALF_UP).intValue()); + } + if (vAndIResult.getVc() && NumberUtil.isIn(BigDecimal.valueOf(vAndIResult.getVcXi() * 10000), BigDecimal.valueOf(originF.getUc_gain() * 0.95), BigDecimal.valueOf(originF.getUc_gain() * 1.05))) { + f.setUc_gain(BigDecimal.valueOf(f.getUc_gain()).multiply(BigDecimal.valueOf(vAndIResult.getVcXi())).setScale(0, RoundingMode.HALF_UP).intValue()); + } + if (vAndIResult.getIa() && NumberUtil.isIn(BigDecimal.valueOf(vAndIResult.getIaXi() * 10000), BigDecimal.valueOf(originF.getIa_gain() * 0.95), BigDecimal.valueOf(originF.getIa_gain() * 1.05))) { + f.setIa_gain(BigDecimal.valueOf(f.getIa_gain()).multiply(BigDecimal.valueOf(vAndIResult.getIaXi())).setScale(0, RoundingMode.HALF_UP).intValue()); + } + if (vAndIResult.getIb() && NumberUtil.isIn(BigDecimal.valueOf(vAndIResult.getIbXi() * 10000), BigDecimal.valueOf(originF.getIb_gain() * 0.95), BigDecimal.valueOf(originF.getIb_gain() * 1.05))) { + f.setIb_gain(BigDecimal.valueOf(f.getIb_gain()).multiply(BigDecimal.valueOf(vAndIResult.getIbXi())).setScale(0, RoundingMode.HALF_UP).intValue()); + } + if (vAndIResult.getIc() && NumberUtil.isIn(BigDecimal.valueOf(vAndIResult.getIcXi() * 10000), BigDecimal.valueOf(originF.getIc_gain() * 0.95), BigDecimal.valueOf(originF.getIc_gain() * 1.05))) { + f.setIc_gain(BigDecimal.valueOf(f.getIc_gain()).multiply(BigDecimal.valueOf(vAndIResult.getIcXi())).setScale(0, RoundingMode.HALF_UP).intValue()); + } + } } diff --git a/detection/src/main/java/com/njcn/gather/detection/service/PreDetectionService.java b/detection/src/main/java/com/njcn/gather/detection/service/PreDetectionService.java index 64f9e9ba..0dd75a53 100644 --- a/detection/src/main/java/com/njcn/gather/detection/service/PreDetectionService.java +++ b/detection/src/main/java/com/njcn/gather/detection/service/PreDetectionService.java @@ -4,6 +4,7 @@ import com.njcn.gather.detection.pojo.param.ContrastDetectionParam; import com.njcn.gather.detection.pojo.param.PreDetectionParam; import com.njcn.gather.detection.pojo.param.SimulateDetectionParam; +import java.util.List; import java.util.Map; @@ -63,4 +64,8 @@ public interface PreDetectionService { * 导出实时数据对齐过程中的数据 */ void exportAlignData(); + + boolean getCanCoefficient(); + + void startCoefficient(); } diff --git a/detection/src/main/java/com/njcn/gather/detection/service/impl/DetectionServiceImpl.java b/detection/src/main/java/com/njcn/gather/detection/service/impl/DetectionServiceImpl.java index 14f372e9..fa026234 100644 --- a/detection/src/main/java/com/njcn/gather/detection/service/impl/DetectionServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/detection/service/impl/DetectionServiceImpl.java @@ -16,8 +16,10 @@ import com.njcn.gather.detection.pojo.vo.DetectionData; import com.njcn.gather.detection.pojo.vo.DevLineTestResult; import com.njcn.gather.detection.util.DetectionUtil; import com.njcn.gather.detection.util.socket.CnSocketUtil; +import com.njcn.gather.detection.util.socket.FormalTestManager; import com.njcn.gather.device.pojo.vo.PreDetection; import com.njcn.gather.device.service.IPqDevService; +import com.njcn.gather.device.service.IPqStandardDevGainRecordService; import com.njcn.gather.err.pojo.param.PqErrSysParam; import com.njcn.gather.err.pojo.po.PqErrSysDtls; import com.njcn.gather.err.pojo.vo.ErrDtlsCheckDataVO; @@ -36,6 +38,8 @@ import com.njcn.gather.system.cfg.pojo.po.SysTestConfig; import com.njcn.gather.system.cfg.service.ISysTestConfigService; import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum; import com.njcn.gather.util.StorageUtil; +import lombok.AllArgsConstructor; +import lombok.Data; import lombok.RequiredArgsConstructor; import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; @@ -66,6 +70,7 @@ public class DetectionServiceImpl { private final ISysTestConfigService sysTestConfigService; private final IPqMonitorService pqMonitorService; private final IPqDevService pqDevService; + private final IPqStandardDevGainRecordService pqStandardDevGainRecordService; public static final String TYPE_A = "A"; public static final String TYPE_B = "B"; @@ -82,6 +87,41 @@ public class DetectionServiceImpl { private static final Integer INHARMONIC_FLAG = 1; private static final Integer HARMONIC_FLAG = 2; + @Data + @AllArgsConstructor + public static class VAndIResult { + private String ip; + private Integer chnNum; + private Boolean va; + private Boolean vb; + private Boolean vc; + private Boolean ia; + private Boolean ib; + private Boolean ic; + private Double vaXi; + private Double vbXi; + private Double vcXi; + private Double iaXi; + private Double ibXi; + private Double icXi; + // 皮尔逊相关系数 + private BigDecimal pearsonCorrelationCoefficientVa; + private BigDecimal pearsonCorrelationCoefficientVb; + private BigDecimal pearsonCorrelationCoefficientVc; + private BigDecimal pearsonCorrelationCoefficientIa; + private BigDecimal pearsonCorrelationCoefficientIb; + private BigDecimal pearsonCorrelationCoefficientIc; + // 比值一致性 CV 系数 + private BigDecimal cVCoefficientVa; + private BigDecimal cVCoefficientVb; + private BigDecimal cVCoefficientVc; + private BigDecimal cVCoefficientIa; + private BigDecimal cVCoefficientIb; + private BigDecimal cVCoefficientIc; + } + + public static Map vAndIResultMap = null; + /** * 开始处理指标类型 @@ -1738,18 +1778,24 @@ public class DetectionServiceImpl { List info = new ArrayList<>(); if (CollUtil.isNotEmpty(devDataList) && CollUtil.isNotEmpty(standardDevDataList) && CollUtil.isNotEmpty(errSysDtls)) { - Map>> map = devListMap(devDataList, standardDevDataList, desc, dataRule); + Map>> phaseValueList = this.getPhaseValueList(devDataList, standardDevDataList, desc); + Map>> map = devListMap(phaseValueList, dataRule); if (ObjectUtil.isNull(map)) { return 4; } ContrastNonHarmonicResult result = new ContrastNonHarmonicResult(); result.setWaveNum(waveNum); - String[] split1 = devDataList.get(0).getId().split(CnSocketUtil.SPLIT_TAG); - String[] split2 = standardDevDataList.get(0).getId().split(CnSocketUtil.SPLIT_TAG); + String devId = devDataList.get(0).getId(); + String stdId = standardDevDataList.get(0).getId(); + + String[] split1 = devId.split(CnSocketUtil.SPLIT_TAG); + String[] split2 = stdId.split(CnSocketUtil.SPLIT_TAG); result.setNum(num); - result.setDevMonitorId(devIdMapComm.get(split1[0]) + "_" + split1[1]); - result.setStdDevMonitorId(devIdMapComm.get(split2[0]) + "_" + split2[1]); + String devMonitorId = devIdMapComm.get(split1[0]) + "_" + split1[1]; + result.setDevMonitorId(devMonitorId); + String stdDevMonitorId = devIdMapComm.get(split2[0]) + "_" + split2[1]; + result.setStdDevMonitorId(stdDevMonitorId); result.setAdType(errSysDtls.get(0).getScriptType()); result.setDataType(dataSourceEnum.getValue()); if (ObjectUtil.isNotNull(waveNum)) { @@ -1790,6 +1836,78 @@ public class DetectionServiceImpl { List phaseList = rangeComparisonList(map.get(phase).get(0), map.get(phase).get(1), errSysDtls, fData, scale, dataRule); this.setValidGroupNum(phaseList, validGroupNum); resultFlag.addAll(phaseList); + if (FormalTestManager.isTesting && ObjectUtil.isNull(waveNum)) { //只有“正式检测并且不是录波数据”的时候才能进入这段代码,重新计算、切换误差体系额操作不会进入这段代码,提升效率。 +// if (true) { //只有“正式检测并且不是录波数据”的时候才能进入这段代码,重新计算、切换误差体系额操作不会进入这段代码,提升效率。 + if (DetectionCodeEnum.PVRMS.getCode().equals(desc) || DetectionCodeEnum.VRMS.getCode().equals(desc) || DetectionCodeEnum.IRMS.getCode().equals(desc)) { + Integer phaseResultFlag = setResultFlag(phaseList); + boolean b = phaseResultFlag == 2 ? true : false; + + SysTestConfig oneConfig = sysTestConfigService.getOneConfig(); + if (b && oneConfig.getCoefficient() == 1) { + BigDecimal pearsonCorrelationCoefficient = DetectionUtil.getPearsonCorrelationCoefficient(phaseValueList.get(phase).get(0), phaseValueList.get(phase).get(1)); + if (NumberUtil.isGreaterOrEqual(pearsonCorrelationCoefficient, BigDecimal.valueOf(0.8))) { + BigDecimal cvCoefficient = DetectionUtil.getCvCoefficient(phaseValueList.get(phase).get(0), phaseValueList.get(phase).get(1)); + if (NumberUtil.isLess(cvCoefficient, BigDecimal.valueOf(0.05))) { + int maxNum = pqStandardDevGainRecordService.getMaxNum(stdDevMonitorId, devMonitorId); + // 如果没有超出次数限制 + if (maxNum + 1 <= 5) { + VAndIResult vAndIResult = vAndIResultMap.getOrDefault(stdId, new VAndIResult(split2[0], Integer.valueOf(split2[1]), false, false, false, false, false, false, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, + BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, + BigDecimal.valueOf(0.2), BigDecimal.valueOf(0.2), BigDecimal.valueOf(0.2), BigDecimal.valueOf(0.2), BigDecimal.valueOf(0.2), BigDecimal.valueOf(0.2))); + + Double newXi = DetectionUtil.getNewXi(map.get(phase).get(0), map.get(phase).get(1)); + switch (phase) { + case TYPE_A: + if (DetectionCodeEnum.IRMS.getCode().equals(desc)) { + vAndIResult.setIa(b); + vAndIResult.setIaXi(newXi); + vAndIResult.setPearsonCorrelationCoefficientIa(pearsonCorrelationCoefficient); + vAndIResult.setCVCoefficientIa(cvCoefficient); + } else { + vAndIResult.setVa(b); + vAndIResult.setVaXi(newXi); + vAndIResult.setPearsonCorrelationCoefficientVa(pearsonCorrelationCoefficient); + vAndIResult.setCVCoefficientVa(cvCoefficient); + } + break; + case TYPE_B: + if (DetectionCodeEnum.IRMS.getCode().equals(desc)) { + vAndIResult.setIb(b); + vAndIResult.setIbXi(newXi); + vAndIResult.setPearsonCorrelationCoefficientIb(pearsonCorrelationCoefficient); + vAndIResult.setCVCoefficientIb(cvCoefficient); + } else { + vAndIResult.setVb(b); + vAndIResult.setVbXi(newXi); + vAndIResult.setPearsonCorrelationCoefficientVb(pearsonCorrelationCoefficient); + vAndIResult.setCVCoefficientVb(cvCoefficient); + } + break; + case TYPE_C: + if (DetectionCodeEnum.IRMS.getCode().equals(desc)) { + vAndIResult.setIc(b); + vAndIResult.setIcXi(newXi); + vAndIResult.setPearsonCorrelationCoefficientIc(pearsonCorrelationCoefficient); + vAndIResult.setCVCoefficientIc(cvCoefficient); + } else { + vAndIResult.setVc(b); + vAndIResult.setVcXi(newXi); + vAndIResult.setPearsonCorrelationCoefficientVc(pearsonCorrelationCoefficient); + vAndIResult.setCVCoefficientVc(cvCoefficient); + } + break; + default: + break; + } + + vAndIResultMap.put(stdId, vAndIResult); + } + } + } + } + } + } BiConsumer> setter = setters.get(phase); setter.accept(result, phaseList); } @@ -2141,67 +2259,20 @@ public class DetectionServiceImpl { /** * 处理非谐波类取值 * - * @param dev 被检设备原始数据 - * @param standardDev 与之对齐的标准设备原始数据 - * @param desc 检测项 - * @param dataRule 数据处理原则 + * @param dataRule 数据处理原则 */ - public Map>> devListMap(List dev, List standardDev, String desc, DictDataEnum dataRule) { + public Map>> devListMap(Map>> phaseValueList, DictDataEnum dataRule) { Map>> resultMap = new HashMap<>(3); - List aDev = new ArrayList<>(); - List aStandardDev = new ArrayList<>(); - List bDev = new ArrayList<>(); - List bStandardDev = new ArrayList<>(); - List cDev = new ArrayList<>(); - List cStandardDev = new ArrayList<>(); - List tDev = new ArrayList<>(); - List tStandardDev = new ArrayList<>(); + List aDev = BeanUtil.copyToList(phaseValueList.get(TYPE_A).get(0), Double.class); + List aStandardDev = BeanUtil.copyToList(phaseValueList.get(TYPE_A).get(1), Double.class); + List bDev = BeanUtil.copyToList(phaseValueList.get(TYPE_B).get(0), Double.class); + List bStandardDev = BeanUtil.copyToList(phaseValueList.get(TYPE_B).get(1), Double.class); + List cDev = BeanUtil.copyToList(phaseValueList.get(TYPE_C).get(0), Double.class); + List cStandardDev = BeanUtil.copyToList(phaseValueList.get(TYPE_C).get(1), Double.class); + List tDev = BeanUtil.copyToList(phaseValueList.get(TYPE_T).get(0), Double.class); + List tStandardDev = BeanUtil.copyToList(phaseValueList.get(TYPE_T).get(1), Double.class); - for (int i = 0; i < dev.size(); i++) { - List devSqlData = dev.get(i).getSqlData(); - List standardDevSqlData = standardDev.get(i).getSqlData(); - - String finalDesc = desc; - List devList = devSqlData.stream().filter(j -> finalDesc.equals(j.getDesc())) - .map(DevData.SqlDataDTO::getList).collect(Collectors.toList()); - List standardDevList = standardDevSqlData.stream().filter(j -> finalDesc.equals(j.getDesc())) - .map(DevData.SqlDataDTO::getList).collect(Collectors.toList()); - - if (CollUtil.isEmpty(devList) || CollUtil.isEmpty(standardDevList)) { - return null; - } - - aDev.addAll(devList.stream().filter(x -> ObjectUtil.isNotNull(x.getA())) - .map(x -> x.getA().doubleValue()) - .collect(Collectors.toList())); - aStandardDev.addAll(standardDevList.stream().filter(x -> ObjectUtil.isNotNull(x.getA())) - .map(x -> x.getA().doubleValue()) - .collect(Collectors.toList())); - - bDev.addAll(devList.stream().filter(x -> ObjectUtil.isNotNull(x.getB())) - .map(x -> x.getB().doubleValue()) - .collect(Collectors.toList())); - - bStandardDev.addAll(standardDevList.stream().filter(x -> ObjectUtil.isNotNull(x.getB())) - .map(x -> x.getB().doubleValue()) - .collect(Collectors.toList())); - - cDev.addAll(devList.stream().filter(x -> ObjectUtil.isNotNull(x.getC())) - .map(x -> x.getC().doubleValue()) - .collect(Collectors.toList())); - - cStandardDev.addAll(standardDevList.stream().filter(x -> ObjectUtil.isNotNull(x.getC())) - .map(x -> x.getC().doubleValue()) - .collect(Collectors.toList())); - - tDev.addAll(devList.stream().filter(x -> ObjectUtil.isNotNull(x.getT())) - .map(x -> x.getT().doubleValue()) - .collect(Collectors.toList())); - tStandardDev.addAll(standardDevList.stream().filter(x -> ObjectUtil.isNotNull(x.getT())) - .map(x -> x.getT().doubleValue()) - .collect(Collectors.toList())); - } List aIdxs = DetectionUtil.sort(aStandardDev, false); List bIdxs = DetectionUtil.sort(bStandardDev, false); List cIdxs = DetectionUtil.sort(cStandardDev, false); @@ -2286,6 +2357,70 @@ public class DetectionServiceImpl { return resultMap; } + private Map>> getPhaseValueList(List dev, List standardDev, String desc) { + Map>> resultMap = new HashMap<>(3); + List aDev = new ArrayList<>(); + List aStandardDev = new ArrayList<>(); + List bDev = new ArrayList<>(); + List bStandardDev = new ArrayList<>(); + List cDev = new ArrayList<>(); + List cStandardDev = new ArrayList<>(); + List tDev = new ArrayList<>(); + List tStandardDev = new ArrayList<>(); + + for (int i = 0; i < dev.size(); i++) { + List devSqlData = dev.get(i).getSqlData(); + List standardDevSqlData = standardDev.get(i).getSqlData(); + + String finalDesc = desc; + List devList = devSqlData.stream().filter(j -> finalDesc.equals(j.getDesc())) + .map(DevData.SqlDataDTO::getList).collect(Collectors.toList()); + List standardDevList = standardDevSqlData.stream().filter(j -> finalDesc.equals(j.getDesc())) + .map(DevData.SqlDataDTO::getList).collect(Collectors.toList()); + + if (CollUtil.isEmpty(devList) || CollUtil.isEmpty(standardDevList)) { + return null; + } + + aDev.addAll(devList.stream().filter(x -> ObjectUtil.isNotNull(x.getA())) + .map(x -> x.getA().doubleValue()) + .collect(Collectors.toList())); + aStandardDev.addAll(standardDevList.stream().filter(x -> ObjectUtil.isNotNull(x.getA())) + .map(x -> x.getA().doubleValue()) + .collect(Collectors.toList())); + + bDev.addAll(devList.stream().filter(x -> ObjectUtil.isNotNull(x.getB())) + .map(x -> x.getB().doubleValue()) + .collect(Collectors.toList())); + + bStandardDev.addAll(standardDevList.stream().filter(x -> ObjectUtil.isNotNull(x.getB())) + .map(x -> x.getB().doubleValue()) + .collect(Collectors.toList())); + + cDev.addAll(devList.stream().filter(x -> ObjectUtil.isNotNull(x.getC())) + .map(x -> x.getC().doubleValue()) + .collect(Collectors.toList())); + + cStandardDev.addAll(standardDevList.stream().filter(x -> ObjectUtil.isNotNull(x.getC())) + .map(x -> x.getC().doubleValue()) + .collect(Collectors.toList())); + + tDev.addAll(devList.stream().filter(x -> ObjectUtil.isNotNull(x.getT())) + .map(x -> x.getT().doubleValue()) + .collect(Collectors.toList())); + tStandardDev.addAll(standardDevList.stream().filter(x -> ObjectUtil.isNotNull(x.getT())) + .map(x -> x.getT().doubleValue()) + .collect(Collectors.toList())); + } + + resultMap.put(TYPE_A, Arrays.asList(aDev, aStandardDev)); + resultMap.put(TYPE_B, Arrays.asList(bDev, bStandardDev)); + resultMap.put(TYPE_C, Arrays.asList(cDev, cStandardDev)); + resultMap.put(TYPE_T, Arrays.asList(tDev, tStandardDev)); + + return resultMap; + } + /** * 处理谐波类取值 * diff --git a/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java b/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java index a523787b..87cd8833 100644 --- a/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java @@ -21,6 +21,8 @@ import com.njcn.gather.detection.util.business.DetectionCommunicateUtil; import com.njcn.gather.detection.util.socket.CnSocketUtil; import com.njcn.gather.detection.util.socket.FormalTestManager; import com.njcn.gather.detection.util.socket.SocketManager; +import com.njcn.gather.detection.util.socket.XiNumberManager; +import com.njcn.gather.detection.util.socket.cilent.NettyContrastClientHandler; import com.njcn.gather.detection.util.socket.websocket.WebServiceManager; import com.njcn.gather.device.pojo.po.PqDev; import com.njcn.gather.device.pojo.vo.PreDetection; @@ -38,6 +40,7 @@ import com.njcn.gather.script.service.IPqScriptCheckDataService; import com.njcn.gather.script.service.IPqScriptDtlsService; import com.njcn.gather.source.pojo.po.SourceInitialize; import com.njcn.gather.source.service.IPqSourceService; +import com.njcn.gather.system.cfg.service.ISysTestConfigService; import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum; import com.njcn.gather.system.dictionary.service.IDictDataService; import com.njcn.web.utils.HttpServletUtil; @@ -75,6 +78,8 @@ public class PreDetectionServiceImpl implements PreDetectionService { private final SocketContrastResponseService socketContrastResponseService; private final IPqScriptCheckDataService iPqScriptCheckDataService; private final SocketManager socketManager; + private final ISysTestConfigService sysTestConfigService; + @Value("${report.reportDir}") private String alignDataFilePath; @@ -358,6 +363,36 @@ public class PreDetectionServiceImpl implements PreDetectionService { } } + @Override + public boolean getCanCoefficient() { + return CollUtil.isNotEmpty(DetectionServiceImpl.vAndIResultMap); + } + + @Override + public void startCoefficient() { + if (CollUtil.isNotEmpty(DetectionServiceImpl.vAndIResultMap)) { + // 是否进行系数校准 + //万一录波了这里就进不来了,但是在误差处理的时候DetectionServiceImpl.vAndIResultMap该集合会保留不符合的结果 + + XiNumberManager.xiDevList.clear(); + XiNumberManager.devXiNumDataMap.clear(); + List stdIpList = DetectionServiceImpl.vAndIResultMap.values().stream().map(DetectionServiceImpl.VAndIResult::getIp).collect(Collectors.toList()); + XiNumberManager.xiDevList = FormalTestManager.standardDevList.stream().filter(d -> stdIpList.contains(d.getDevIP())).collect(Collectors.toList()); + // 逐一设备向通讯模块要原始系数 + SocketMsg socketMsg = new SocketMsg<>(); + socketMsg.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue()); + socketMsg.setOperateCode(SourceOperateCodeEnum.DATA_CHNFACTOR$01.getValue()); + PreDetection preDetection = XiNumberManager.xiDevList.get(0); + Map map = new HashMap<>(); + map.put("devIP", preDetection.getDevIP()); + map.put("chnNum", preDetection.getDevChns()); + socketMsg.setData(JSON.toJSONString(map)); + SocketManager.sendMsg(NettyContrastClientHandler.param.getUserPageId() + CnSocketUtil.CONTRAST_DEV_TAG, JSON.toJSONString(socketMsg)); + + FormalTestManager.currentStep = SourceOperateCodeEnum.Coefficient_Check; + } + } + /** * 比对式-与通信模块进行连接 * diff --git a/detection/src/main/java/com/njcn/gather/detection/util/DetectionUtil.java b/detection/src/main/java/com/njcn/gather/detection/util/DetectionUtil.java index 03cb9bcb..9438754a 100644 --- a/detection/src/main/java/com/njcn/gather/detection/util/DetectionUtil.java +++ b/detection/src/main/java/com/njcn/gather/detection/util/DetectionUtil.java @@ -1,6 +1,7 @@ package com.njcn.gather.detection.util; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; import com.njcn.gather.detection.pojo.po.DevData; import lombok.extern.slf4j.Slf4j; @@ -437,4 +438,94 @@ public class DetectionUtil { System.out.println(" 文件大小: " + file.length() + " bytes"); } } + + /** + * 获取皮尔逊系数 + * + *

相关系数绝对值|r|所代表的相关强度

+ *
    + *
  • 0.8 - 1.0:极强相关
  • + *
  • 0.6 - 0.8:强相关
  • + *
  • 0.4 - 0.6:中等程度相关
  • + *
  • 0.2 - 0.4:弱相关
  • + *
  • 0.0 - 0.2:极弱相关或无相关
  • + *
+ * + * @return + */ + public static BigDecimal getPearsonCorrelationCoefficient(List x, List y) { + Double xAvg = x.parallelStream().mapToDouble(Double::doubleValue).average().orElse(0.0); + Double yAvg = y.parallelStream().mapToDouble(Double::doubleValue).average().orElse(0.0); + + // 协方差求和 + BigDecimal covarianceSum = BigDecimal.ZERO; + // x的方差 + BigDecimal varianceX = BigDecimal.ZERO; + // y的方差 + BigDecimal varianceY = BigDecimal.ZERO; + for (int i = 0; i < x.size(); i++) { + covarianceSum = covarianceSum.add(BigDecimal.valueOf((x.get(i) - xAvg) * (y.get(i) - yAvg))); + varianceX = varianceX.add(BigDecimal.valueOf(Math.pow(x.get(i) - xAvg, 2))); + varianceY = varianceY.add(BigDecimal.valueOf(Math.pow(y.get(i) - yAvg, 2))); + } + BigDecimal fm = BigDecimal.valueOf(Math.sqrt(varianceX.doubleValue()) * Math.sqrt(varianceY.doubleValue())); + if (NumberUtil.equals(fm.doubleValue(), BigDecimal.ZERO.doubleValue())) { + if (NumberUtil.equals(covarianceSum, BigDecimal.ZERO)) { + return BigDecimal.valueOf(1.0); + } else { + return BigDecimal.ZERO; + } + } else { + return BigDecimal.valueOf(Math.abs(covarianceSum.divide(fm, 8, BigDecimal.ROUND_HALF_UP).doubleValue())); //相关系数 + } + } + + /** + * 比值一致性,获取CV系数 + * + *

一致性等级

+ *
    + *
  • CV<1%:非常优秀
  • + *
  • 1%≤CV<5%:优良
  • + *
  • 5%≤CV<10%:良好
  • + *
  • 10%≤CV<20%:中等
  • + *
  • 20%≤CV:较差
  • + *
+ * + * @param x + * @param y + * @return + */ + public static BigDecimal getCvCoefficient(List x, List y) { + List ratioList = new ArrayList<>(); + for (int i = 0; i < x.size(); i++) { + ratioList.add(BigDecimal.valueOf(x.get(i) / y.get(i))); + } + + BigDecimal avg = BigDecimal.valueOf(ratioList.parallelStream().mapToDouble(BigDecimal::doubleValue).average().orElse(0.0)); + BigDecimal variance = BigDecimal.valueOf( + ratioList.parallelStream().mapToDouble(BigDecimal::doubleValue) + .map(v -> Math.pow(v - avg.doubleValue(), 2)).average().orElse(0.0)); + + return BigDecimal.valueOf(Math.sqrt(variance.doubleValue()) / avg.doubleValue()); + } + + /** + * 计算新的系数 + * + * @param devList + * @param stdDevList + * @return + */ + public static Double getNewXi(List devList, List stdDevList) { + ArrayList xiList = new ArrayList<>(); + for (int i = 0; i < stdDevList.size(); i++) { + if (!stdDevList.get(i).equals(0)) { + BigDecimal bigDecimalDev = BigDecimal.valueOf(devList.get(i)); + BigDecimal bigDecimalStdDev = BigDecimal.valueOf(stdDevList.get(i)); + xiList.add((bigDecimalDev.subtract(bigDecimalStdDev)).divide(BigDecimal.valueOf(2.0).multiply(bigDecimalDev), 8, BigDecimal.ROUND_HALF_UP).doubleValue() + 1.0); + } + } + return xiList.stream().mapToDouble(Double::doubleValue).average().orElse(1.0); + } } diff --git a/detection/src/main/java/com/njcn/gather/device/controller/PqStandardDevController.java b/detection/src/main/java/com/njcn/gather/device/controller/PqStandardDevController.java index f18bd690..78b43308 100644 --- a/detection/src/main/java/com/njcn/gather/device/controller/PqStandardDevController.java +++ b/detection/src/main/java/com/njcn/gather/device/controller/PqStandardDevController.java @@ -12,6 +12,7 @@ import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.utils.LogUtil; import com.njcn.gather.device.pojo.param.PqStandardDevParam; import com.njcn.gather.device.pojo.po.PqStandardDev; +import com.njcn.gather.device.pojo.vo.PqStandardDevVO; import com.njcn.gather.device.service.IPqStandardDevService; import com.njcn.web.controller.BaseController; import com.njcn.web.utils.FileUtil; @@ -55,10 +56,10 @@ public class PqStandardDevController extends BaseController { @GetMapping("/getById") @ApiOperation("根据id查询标准设备") @ApiImplicitParam(name = "id", value = "标准设备id", required = true) - public HttpResult getById(@RequestParam("id") String id) { + public HttpResult getById(@RequestParam("id") String id) { String methodDescribe = getMethodDescribe("getById"); LogUtil.njcnDebug(log, "{},查询ID为:{}", methodDescribe, id); - PqStandardDev result = pqStandardDevService.getPqStandardDevById(id); + PqStandardDevVO result = pqStandardDevService.getPqStandardDevById(id); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); } diff --git a/detection/src/main/java/com/njcn/gather/device/mapper/PqStandardDevGainMapper.java b/detection/src/main/java/com/njcn/gather/device/mapper/PqStandardDevGainMapper.java new file mode 100644 index 00000000..31e3dd50 --- /dev/null +++ b/detection/src/main/java/com/njcn/gather/device/mapper/PqStandardDevGainMapper.java @@ -0,0 +1,13 @@ +package com.njcn.gather.device.mapper; + +import com.github.yulichang.base.MPJBaseMapper; +import com.njcn.gather.device.pojo.po.PqStandardDevGain; + +/** + * @author caozehui + * @date 2026-01-12 + */ +public interface PqStandardDevGainMapper extends MPJBaseMapper { + +} + diff --git a/detection/src/main/java/com/njcn/gather/device/mapper/PqStandardDevGainRecordMapper.java b/detection/src/main/java/com/njcn/gather/device/mapper/PqStandardDevGainRecordMapper.java new file mode 100644 index 00000000..69207b2e --- /dev/null +++ b/detection/src/main/java/com/njcn/gather/device/mapper/PqStandardDevGainRecordMapper.java @@ -0,0 +1,13 @@ +package com.njcn.gather.device.mapper; + +import com.github.yulichang.base.MPJBaseMapper; +import com.njcn.gather.device.pojo.po.PqStandardDevGainRecord; + +/** + * @author caozehui + * @date 2026-01-15 + */ +public interface PqStandardDevGainRecordMapper extends MPJBaseMapper { + +} + diff --git a/detection/src/main/java/com/njcn/gather/device/mapper/mapping/PqStandardDevGainMapper.xml b/detection/src/main/java/com/njcn/gather/device/mapper/mapping/PqStandardDevGainMapper.xml new file mode 100644 index 00000000..59fa57ef --- /dev/null +++ b/detection/src/main/java/com/njcn/gather/device/mapper/mapping/PqStandardDevGainMapper.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/detection/src/main/java/com/njcn/gather/device/mapper/mapping/PqStandardDevGainRecordMapper.xml b/detection/src/main/java/com/njcn/gather/device/mapper/mapping/PqStandardDevGainRecordMapper.xml new file mode 100644 index 00000000..caef96fe --- /dev/null +++ b/detection/src/main/java/com/njcn/gather/device/mapper/mapping/PqStandardDevGainRecordMapper.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/detection/src/main/java/com/njcn/gather/device/pojo/po/PqStandardDevGain.java b/detection/src/main/java/com/njcn/gather/device/pojo/po/PqStandardDevGain.java new file mode 100644 index 00000000..2105c299 --- /dev/null +++ b/detection/src/main/java/com/njcn/gather/device/pojo/po/PqStandardDevGain.java @@ -0,0 +1,61 @@ +package com.njcn.gather.device.pojo.po; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.njcn.db.mybatisplus.bo.BaseEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @author caozehui + * @date 2026-01-12 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("pq_standard_dev_gain") +public class PqStandardDevGain extends BaseEntity implements Serializable { + private static final long serialVersionUID = -46280767885558804L; + + + /** + * 标准设备Id_通道号 + */ + @TableId + private String stdDevMonitorId; + + private Integer uaGain; + + private Integer ubGain; + + + private Integer ucGain; + + + private Integer u0Gain; + + + private Integer iaGain; + + + private Integer ibGain; + + + private Integer icGain; + + + private Integer i0Gain; + + + private Integer uabGain; + + + private Integer ubcGain; + + + private Integer ucaGain; + + private Integer state; +} + diff --git a/detection/src/main/java/com/njcn/gather/device/pojo/po/PqStandardDevGainRecord.java b/detection/src/main/java/com/njcn/gather/device/pojo/po/PqStandardDevGainRecord.java new file mode 100644 index 00000000..ee170c21 --- /dev/null +++ b/detection/src/main/java/com/njcn/gather/device/pojo/po/PqStandardDevGainRecord.java @@ -0,0 +1,35 @@ +package com.njcn.gather.device.pojo.po; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.njcn.db.mybatisplus.bo.BaseEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @author caozehui + * @date 2026-01-15 + */ +@Data +@TableName("pq_standard_dev_gain_record") +public class PqStandardDevGainRecord implements Serializable { + private static final long serialVersionUID = 477276215572686991L; + + /** + * 标准设备监测点id,由设备id_通道号组成 + */ + private String stdDevMonitorId; + + /** + * 被检设备监测点id,由设备id_通道号组成 + */ + private String devMonitorId; + + /** + * 系数下发次数 + */ + private Integer num; + +} + diff --git a/detection/src/main/java/com/njcn/gather/device/pojo/vo/PqStandardDevVO.java b/detection/src/main/java/com/njcn/gather/device/pojo/vo/PqStandardDevVO.java new file mode 100644 index 00000000..f034f0a2 --- /dev/null +++ b/detection/src/main/java/com/njcn/gather/device/pojo/vo/PqStandardDevVO.java @@ -0,0 +1,20 @@ +package com.njcn.gather.device.pojo.vo; + +import com.njcn.gather.device.pojo.po.PqStandardDev; +import com.njcn.gather.device.pojo.po.PqStandardDevGain; +import lombok.Data; + +import java.util.List; + +/** + * @author caozehui + * @data 2026-01-19 + */ +@Data +public class PqStandardDevVO extends PqStandardDev { + + /** + * 通道系数 + */ + List gainList; +} diff --git a/detection/src/main/java/com/njcn/gather/device/service/IPqStandardDevGainRecordService.java b/detection/src/main/java/com/njcn/gather/device/service/IPqStandardDevGainRecordService.java new file mode 100644 index 00000000..9a982ab8 --- /dev/null +++ b/detection/src/main/java/com/njcn/gather/device/service/IPqStandardDevGainRecordService.java @@ -0,0 +1,29 @@ +package com.njcn.gather.device.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.njcn.gather.device.pojo.po.PqStandardDevGainRecord; + +import java.util.List; + +/** + * @author caozehui + * @date 2026-01-15 + */ +public interface IPqStandardDevGainRecordService extends IService { + + /** + * 获取最大下发系数的次数 + * + * @param stdDevMonitorId + * @param devMonitorId + * @return + */ + int getMaxNum(String stdDevMonitorId, String devMonitorId); + + /** + * 批量新增或更新记录 + * @param recordList + * @return + */ + boolean addOrUpdate(List recordList); +} diff --git a/detection/src/main/java/com/njcn/gather/device/service/IPqStandardDevGainService.java b/detection/src/main/java/com/njcn/gather/device/service/IPqStandardDevGainService.java new file mode 100644 index 00000000..92e6907d --- /dev/null +++ b/detection/src/main/java/com/njcn/gather/device/service/IPqStandardDevGainService.java @@ -0,0 +1,19 @@ +package com.njcn.gather.device.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.njcn.gather.device.pojo.po.PqStandardDevGain; + +import java.util.List; + +/** + * @author caozehui + * @date 2026-01-12 + */ +public interface IPqStandardDevGainService extends IService { + + boolean add(List pqStandardDevGainList); + + PqStandardDevGain get(String stdDevMonitorId); + + List list(String stdDevId); +} diff --git a/detection/src/main/java/com/njcn/gather/device/service/IPqStandardDevService.java b/detection/src/main/java/com/njcn/gather/device/service/IPqStandardDevService.java index 63e5e2e3..c3013c14 100644 --- a/detection/src/main/java/com/njcn/gather/device/service/IPqStandardDevService.java +++ b/detection/src/main/java/com/njcn/gather/device/service/IPqStandardDevService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.njcn.gather.device.pojo.param.PqStandardDevParam; import com.njcn.gather.device.pojo.po.PqStandardDev; +import com.njcn.gather.device.pojo.vo.PqStandardDevVO; import com.njcn.gather.device.pojo.vo.PreDetection; import org.springframework.web.multipart.MultipartFile; @@ -30,7 +31,7 @@ public interface IPqStandardDevService extends IService { * @param id 设备id * @return 设备对象 */ - PqStandardDev getPqStandardDevById(String id); + PqStandardDevVO getPqStandardDevById(String id); /** * 新增标准设备 diff --git a/detection/src/main/java/com/njcn/gather/device/service/impl/PqStandardDevGainRecordServiceImpl.java b/detection/src/main/java/com/njcn/gather/device/service/impl/PqStandardDevGainRecordServiceImpl.java new file mode 100644 index 00000000..e4fc4739 --- /dev/null +++ b/detection/src/main/java/com/njcn/gather/device/service/impl/PqStandardDevGainRecordServiceImpl.java @@ -0,0 +1,45 @@ +package com.njcn.gather.device.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.njcn.gather.device.mapper.PqStandardDevGainRecordMapper; +import com.njcn.gather.device.pojo.po.PqStandardDevGainRecord; +import com.njcn.gather.device.service.IPqStandardDevGainRecordService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @author caozehui + * @date 2026-01-15 + */ +@Slf4j +@Service +@RequiredArgsConstructor +public class PqStandardDevGainRecordServiceImpl extends ServiceImpl implements IPqStandardDevGainRecordService { + + @Override + public int getMaxNum(String stdDevMonitorId, String devMonitorId) { + return this.lambdaQuery().eq(PqStandardDevGainRecord::getStdDevMonitorId, stdDevMonitorId) + .eq(PqStandardDevGainRecord::getDevMonitorId, devMonitorId) + .list().stream().mapToInt(PqStandardDevGainRecord::getNum).max().orElse(0); + } + + @Override + public boolean addOrUpdate(List recordList) { + recordList.forEach(record -> { + List list = this.lambdaQuery().eq(PqStandardDevGainRecord::getStdDevMonitorId, record.getStdDevMonitorId()) + .eq(PqStandardDevGainRecord::getDevMonitorId, record.getDevMonitorId()).list(); + if (CollectionUtil.isNotEmpty(list)) { + this.lambdaUpdate().eq(PqStandardDevGainRecord::getStdDevMonitorId, record.getStdDevMonitorId()) + .eq(PqStandardDevGainRecord::getDevMonitorId, record.getDevMonitorId()) + .set(PqStandardDevGainRecord::getNum, record.getNum()).update(); + } else { + this.save(record); + } + }); + return true; + } +} diff --git a/detection/src/main/java/com/njcn/gather/device/service/impl/PqStandardDevGainServiceImpl.java b/detection/src/main/java/com/njcn/gather/device/service/impl/PqStandardDevGainServiceImpl.java new file mode 100644 index 00000000..793e70df --- /dev/null +++ b/detection/src/main/java/com/njcn/gather/device/service/impl/PqStandardDevGainServiceImpl.java @@ -0,0 +1,42 @@ +package com.njcn.gather.device.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.njcn.gather.device.mapper.PqStandardDevGainMapper; +import com.njcn.gather.device.pojo.po.PqStandardDevGain; +import com.njcn.gather.device.service.IPqStandardDevGainService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author caozehui + * @date 2026-01-12 + */ +@Slf4j +@Service +@RequiredArgsConstructor +public class PqStandardDevGainServiceImpl extends ServiceImpl implements IPqStandardDevGainService { + + @Override + public boolean add(List pqStandardDevGainList) { + log.info("add PqStandardDevGainList: {}", pqStandardDevGainList.size()); + List stdMonitorIdList = pqStandardDevGainList.stream().map(PqStandardDevGain::getStdDevMonitorId).distinct().collect(Collectors.toList()); + List existingStdMonitorIdList = this.listByIds(stdMonitorIdList).stream().map(PqStandardDevGain::getStdDevMonitorId).collect(Collectors.toList()); + + pqStandardDevGainList = pqStandardDevGainList.stream().filter(pqStandardDevGain -> !existingStdMonitorIdList.contains(pqStandardDevGain.getStdDevMonitorId())).collect(Collectors.toList()); + return this.saveBatch(pqStandardDevGainList); + } + + @Override + public PqStandardDevGain get(String stdDevMonitorId) { + return this.lambdaQuery().eq(PqStandardDevGain::getStdDevMonitorId, stdDevMonitorId).one(); + } + + @Override + public List list(String stdDevId) { + return this.lambdaQuery().likeRight(PqStandardDevGain::getStdDevMonitorId, stdDevId).orderByAsc(PqStandardDevGain::getStdDevMonitorId).list(); + } +} diff --git a/detection/src/main/java/com/njcn/gather/device/service/impl/PqStandardDevServiceImpl.java b/detection/src/main/java/com/njcn/gather/device/service/impl/PqStandardDevServiceImpl.java index f5155547..883fe2a2 100644 --- a/detection/src/main/java/com/njcn/gather/device/service/impl/PqStandardDevServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/device/service/impl/PqStandardDevServiceImpl.java @@ -19,8 +19,11 @@ import com.njcn.common.utils.EncryptionUtil; import com.njcn.gather.device.mapper.PqStandardDevMapper; import com.njcn.gather.device.pojo.param.PqStandardDevParam; import com.njcn.gather.device.pojo.po.PqStandardDev; +import com.njcn.gather.device.pojo.po.PqStandardDevGain; import com.njcn.gather.device.pojo.vo.PqStandardDevExcel; +import com.njcn.gather.device.pojo.vo.PqStandardDevVO; import com.njcn.gather.device.pojo.vo.PreDetection; +import com.njcn.gather.device.service.IPqStandardDevGainService; import com.njcn.gather.device.service.IPqStandardDevService; import com.njcn.gather.plan.mapper.AdPlanStandardDevMapper; import com.njcn.gather.plan.service.IAdPlanStandardDevService; @@ -58,8 +61,7 @@ public class PqStandardDevServiceImpl extends ServiceImpl listPqStandardDevs(PqStandardDevParam.QueryParam queryParam) { @@ -73,13 +75,17 @@ public class PqStandardDevServiceImpl extends ServiceImpl gainList = pqStandardDevGainService.list(id); + pqStandardDevVO.setGainList(gainList); + return pqStandardDevVO; } @Override diff --git a/detection/src/main/java/com/njcn/gather/monitor/service/IPqMonitorService.java b/detection/src/main/java/com/njcn/gather/monitor/service/IPqMonitorService.java index 388f52f2..da3e150e 100644 --- a/detection/src/main/java/com/njcn/gather/monitor/service/IPqMonitorService.java +++ b/detection/src/main/java/com/njcn/gather/monitor/service/IPqMonitorService.java @@ -121,8 +121,8 @@ public interface IPqMonitorService extends IService { /** * 根据被检设备id和监测点编号获取监测点信息 - * @param id 被检设备id + * @param devId 设备id * @param monitorNum 监测点编号 */ - PqMonitor getByDevAndNum(String id, int monitorNum); + PqMonitor getByDevIdAndNum(String devId, int monitorNum); } diff --git a/detection/src/main/java/com/njcn/gather/monitor/service/impl/PqMonitorServiceImpl.java b/detection/src/main/java/com/njcn/gather/monitor/service/impl/PqMonitorServiceImpl.java index 7661172c..1d8a036e 100644 --- a/detection/src/main/java/com/njcn/gather/monitor/service/impl/PqMonitorServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/monitor/service/impl/PqMonitorServiceImpl.java @@ -84,6 +84,7 @@ public class PqMonitorServiceImpl extends ServiceImpl wrapper = new QueryWrapper<>(); wrapper.eq("pq_monitor.Dev_Id", devId) .eq("pq_monitor.Num", monitorNum); 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 b4856e98..acb83abb 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 @@ -1173,7 +1173,7 @@ public class PqReportServiceImpl extends ServiceImpl i Integer monitorNum = next.getKey(); // 线路下的指标数据 List contrastTestResults = next.getValue(); - PqMonitor pqMonitor = pqMonitorService.getByDevAndNum(pqDevVO.getId(), monitorNum); + PqMonitor pqMonitor = pqMonitorService.getByDevIdAndNum(pqDevVO.getId(), monitorNum); // 插入回路号前,先换个页 todoInsertList.add(Docx4jUtil.createPageBreakParagraph()); // 回路标题 @@ -2503,7 +2503,7 @@ public class PqReportServiceImpl extends ServiceImpl i * 创建回路标题到报告中 */ private P getContrastLineTitle(Map> contentMap, int monitorNum, int index, ObjectFactory factory, PqDevVO pqDevVO) { - PqMonitor pqMonitor = pqMonitorService.getByDevAndNum(pqDevVO.getId(), monitorNum); + PqMonitor pqMonitor = pqMonitorService.getByDevIdAndNum(pqDevVO.getId(), monitorNum); String monitorInfoName = ""; if (StrUtil.isNotBlank(pqDevVO.getSubName()) && Objects.nonNull(pqMonitor)) { monitorInfoName = "(" + pqDevVO.getSubName() + "-" + pqMonitor.getName() + ")"; diff --git a/detection/src/main/java/com/njcn/gather/result/controller/ResultController.java b/detection/src/main/java/com/njcn/gather/result/controller/ResultController.java index 248bb577..5341f93a 100644 --- a/detection/src/main/java/com/njcn/gather/result/controller/ResultController.java +++ b/detection/src/main/java/com/njcn/gather/result/controller/ResultController.java @@ -198,7 +198,7 @@ public class ResultController extends BaseController { String methodDescribe = getMethodDescribe("getCheckItem"); LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, monitorQueryParam); - List result = resultService.getCheckItem(monitorQueryParam.getPlanId(), monitorQueryParam.getDevId(), monitorQueryParam.getChnNum(), monitorQueryParam.getNum()); + List result = resultService.getCheckItem(monitorQueryParam.getPlanId(), monitorQueryParam.getDevId(), monitorQueryParam.getChnNum(), monitorQueryParam.getNum(), monitorQueryParam.getCode()); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); } } diff --git a/detection/src/main/java/com/njcn/gather/result/pojo/param/MonitorQueryParam.java b/detection/src/main/java/com/njcn/gather/result/pojo/param/MonitorQueryParam.java index cfa65cd3..db02205f 100644 --- a/detection/src/main/java/com/njcn/gather/result/pojo/param/MonitorQueryParam.java +++ b/detection/src/main/java/com/njcn/gather/result/pojo/param/MonitorQueryParam.java @@ -17,4 +17,6 @@ public class MonitorQueryParam { private Integer waveNum; private String planId; + + private String code; } diff --git a/detection/src/main/java/com/njcn/gather/result/service/IResultService.java b/detection/src/main/java/com/njcn/gather/result/service/IResultService.java index be21552b..f17675e0 100644 --- a/detection/src/main/java/com/njcn/gather/result/service/IResultService.java +++ b/detection/src/main/java/com/njcn/gather/result/service/IResultService.java @@ -123,9 +123,10 @@ public interface IResultService { * @param devId * @param chnNum * @param num + * @param code * @return */ - List getCheckItem(String planId, String devId, String chnNum, Integer num); + List getCheckItem(String planId, String devId, String chnNum, Integer num,String code); /** * 获取设备比对式结果,用于出比对检测的报告 diff --git a/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java b/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java index 1c25eddb..6ebd0849 100644 --- a/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java @@ -1883,10 +1883,10 @@ public class ResultServiceImpl implements IResultService { } @Override - public List getCheckItem(String planId, String devId, String chnNum, Integer num) { + public List getCheckItem(String planId, String devId, String chnNum, Integer num,String code) { // PqDev dev = pqDevService.getById(devId); AdPlan plan = adPlanService.getById(planId); - String code = String.valueOf(plan.getCode()); +// String code = String.valueOf(plan.getCode()); String monitorId = devId + CnSocketUtil.SPLIT_TAG + chnNum; diff --git a/system/src/main/java/com/njcn/gather/system/cfg/pojo/param/SysTestConfigParam.java b/system/src/main/java/com/njcn/gather/system/cfg/pojo/param/SysTestConfigParam.java index f3f8e971..89de5914 100644 --- a/system/src/main/java/com/njcn/gather/system/cfg/pojo/param/SysTestConfigParam.java +++ b/system/src/main/java/com/njcn/gather/system/cfg/pojo/param/SysTestConfigParam.java @@ -28,6 +28,9 @@ public class SysTestConfigParam { @ApiModelProperty(value = "场景") private String scene; + @ApiModelProperty(value = "比对监测后,当电压、电流不符合时,是否对标准设备进行系数校准") + private Integer coefficient; + @Data public static class UpdateParam extends SysTestConfigParam { @ApiModelProperty("id") diff --git a/system/src/main/java/com/njcn/gather/system/cfg/pojo/po/SysTestConfig.java b/system/src/main/java/com/njcn/gather/system/cfg/pojo/po/SysTestConfig.java index 5853e4c9..f881beee 100644 --- a/system/src/main/java/com/njcn/gather/system/cfg/pojo/po/SysTestConfig.java +++ b/system/src/main/java/com/njcn/gather/system/cfg/pojo/po/SysTestConfig.java @@ -51,6 +51,11 @@ public class SysTestConfig extends BaseEntity implements Serializable { */ private Integer scale; + /** + * 比对监测后,当电压、电流不符合时,是否对标准设备进行系数校准 + */ + private Integer coefficient; + /** * 状态:0-删除 1-正常 diff --git a/system/src/main/java/com/njcn/gather/system/cfg/service/impl/SysTestConfigServiceImpl.java b/system/src/main/java/com/njcn/gather/system/cfg/service/impl/SysTestConfigServiceImpl.java index e447c3dd..83832668 100644 --- a/system/src/main/java/com/njcn/gather/system/cfg/service/impl/SysTestConfigServiceImpl.java +++ b/system/src/main/java/com/njcn/gather/system/cfg/service/impl/SysTestConfigServiceImpl.java @@ -49,6 +49,7 @@ public class SysTestConfigServiceImpl extends ServiceImpl