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 b7a0fd67..739839bb 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 @@ -12,6 +12,7 @@ import com.njcn.gather.detection.pojo.po.DevData; import com.njcn.gather.detection.pojo.po.SourceCompareDev; import com.njcn.gather.detection.pojo.vo.*; import com.njcn.gather.detection.service.impl.DetectionServiceImpl; +import com.njcn.gather.detection.util.socket.CnSocketUtil; import com.njcn.gather.detection.util.socket.MsgUtil; import com.njcn.gather.detection.util.socket.SocketManager; import com.njcn.gather.detection.util.socket.web.WebSocketHandler; @@ -58,7 +59,7 @@ public class SocketDevResponseService { private final DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE_TIME; - private final List nonHarmonicList = Stream.of(DicDataEnum.FREQ.getCode(), DicDataEnum.V.getCode(), DicDataEnum.I.getCode(), DicDataEnum.IMBV.getCode(), DicDataEnum.IMBA.getCode()).collect(Collectors.toList()); + private final List nonHarmonicList = Stream.of(DicDataEnum.FREQ.getCode(), DicDataEnum.V.getCode(), DicDataEnum.I.getCode(), DicDataEnum.IMBV.getCode(), DicDataEnum.IMBA.getCode(),DicDataEnum.VOLTAGE.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()); private final WebSocketHandler webSocketHandler; @@ -389,7 +390,7 @@ public class SocketDevResponseService { } else if (XiNumberManager.stepNumber == 3) { sendWebSocket(param.getUserPageId(), SourceOperateCodeEnum.Coefficient_Check.getValue(), SourceOperateCodeEnum.small_comp_end.getValue(), XiNumberManager.devParameterList.get(1)); System.out.println("-------------------------已经全部结束----------------------"); - quitSend(param); + CnSocketUtil.quitSend(param); } } @@ -547,22 +548,20 @@ public class SocketDevResponseService { case DEV_ERROR: webSocketHandler.sendMsgToUser(param.getUserPageId(), MsgUtil.msgToWebData(socketDataMsg, devNameMapComm, 2)); - quitSend(param); - quitSendSource(param); + CnSocketUtil.quitSend(param); break; case DEV_TARGET: webSocketHandler.sendMsgToUser(param.getUserPageId(), MsgUtil.msgToWebData(socketDataMsg, devNameMapComm, 2)); - quitSend(param); - quitSendSource(param); + CnSocketUtil.quitSend(param); break; case RE_OPERATE: //出现已经初始化情况,发送用户用户确认是否继续检测 webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketDataMsg)); - quitSend(param); + CnSocketUtil.quitSend(param); break; case NO_INIT_DEV: //发起关闭操作 - quitSend(param); + CnSocketUtil.quitSend(param); break; default: WebSocketVO webSocketVO = new WebSocketVO<>(); @@ -678,17 +677,17 @@ public class SocketDevResponseService { break; case DEV_ERROR: webSocketHandler.sendMsgToUser(param.getUserPageId(), MsgUtil.msgToWebData(socketDataMsg, devNameMapComm, 2)); - quitSend(param); + CnSocketUtil.quitSend(param); break; case DEV_TARGET: webSocketHandler.sendMsgToUser(param.getUserPageId(), MsgUtil.msgToWebData(socketDataMsg, devNameMapComm, 2)); - quitSend(param); + CnSocketUtil.quitSend(param); break; case RE_OPERATE: //出现已经初始化情况,发送用户用户确认是否继续检测 webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketDataMsg)); - quitSend(param); + CnSocketUtil.quitSend(param); break; default: WebSocketVO webSocketVO = new WebSocketVO<>(); @@ -752,7 +751,7 @@ public class SocketDevResponseService { if(param.getOperateType().equals(SourceOperateCodeEnum.PRE_TEST.getValue())){ System.out.println("预检测流程接受-----------------关闭源"); //同时关闭设备三个步骤 - quitSend(param); + CnSocketUtil.quitSend(param); }else if(param.getOperateType().equals(SourceOperateCodeEnum.COEFFICIENT_TEST.getValue())){ WebSocketVO webSocketVO = new WebSocketVO<>(); webSocketVO.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue()); @@ -785,13 +784,11 @@ public class SocketDevResponseService { break; case DEV_ERROR: webSocketHandler.sendMsgToUser(param.getUserPageId(), MsgUtil.msgToWebData(socketDataMsg, devNameMapComm, 2)); - quitSend(param); - quitSendSource(param); + CnSocketUtil.quitSend(param); break; case DEV_TARGET: webSocketHandler.sendMsgToUser(param.getUserPageId(), MsgUtil.msgToWebData(socketDataMsg, devNameMapComm, 2)); - quitSend(param); - quitSendSource(param); + CnSocketUtil.quitSend(param); break; case RE_OPERATE: break; @@ -877,7 +874,7 @@ public class SocketDevResponseService { SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, MsgUtil.toJsonWithNewLinePlain(xuMsg)); } else { //TODO 是否最终检测完成需要推送给用户 - quitSend(param); + CnSocketUtil.quitSend(param); } successComm.clear(); @@ -932,7 +929,7 @@ public class SocketDevResponseService { case QUIT_INIT_01: //关闭所有 SocketManager.removeUser(s); - quitSendSource(param); + CnSocketUtil.quitSendSource(param); break; case QUIT_INIT_02: socketMsg.setRequestId("quit"); @@ -954,7 +951,7 @@ public class SocketDevResponseService { switch (operateCodeEnum) { case QUIT_INIT_01: SocketManager.removeUser(s); - quitSendSource(param); + CnSocketUtil.quitSendSource(param); break; case QUIT_INIT_02: socketMsg.setRequestId("quit"); @@ -1179,7 +1176,10 @@ public class SocketDevResponseService { * @date 2024/12/29 */ private void baseDataInsert(List devDataList, SourceIssue sourceIssue, PreDetectionParam param, Map checkDataMap) { - Runnable runnable = () -> { + // Runnable runnable = () -> { + + + System.out.println("原始数据插入数据库开始执行========================================="); List adNonHarmonicResultList = new ArrayList<>(); List adHarmonicResultList = new ArrayList<>(); @@ -1286,8 +1286,8 @@ public class SocketDevResponseService { detectionDataDealService.acceptAd(adHarmonicResultList, "1"); } System.out.println("原始数据插入数据库执行成功========================================="); - }; - executorPool.submit(runnable); + // }; + // executorPool.submit(runnable); } 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 8ad2a0be..fe617984 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 @@ -665,7 +665,7 @@ public class DetectionServiceImpl { */ private void setDetection(DictDataEnum dataRule, List harmDataList, PqErrSysDtls errSysDtl, DetectionData data, Double v) { List qualifiedList = harmDataList.stream() - .filter(x -> v == 0 ? x == v : NumberUtil.isIn(devSubtractChannelData(x, v, errSysDtl.getErrorValueType()), + .filter(x -> v == 0 ? x == v : x > 0 && NumberUtil.isIn(devSubtractChannelData(x, v, errSysDtl.getErrorValueType()), BigDecimal.valueOf(-errSysDtl.getMaxErrorValue()), BigDecimal.valueOf(errSysDtl.getMaxErrorValue()))).collect(Collectors.toList()); data.setRadius(-errSysDtl.getMaxErrorValue() + "~" + errSysDtl.getMaxErrorValue()); @@ -764,7 +764,7 @@ public class DetectionServiceImpl { public DetectionData rangeComparisonList(List list, List pqErrSysDtls, Double data, Double channelData, DictDataEnum dataRule) { DetectionData detectionData = new DetectionData(); detectionData.setIsData(4); - detectionData.setData(list.get(0)); + detectionData.setData(CollUtil.isNotEmpty(list) ? list.get(0) : null); //先根据源所下发的数据,是否在误差体系范围内在则可以进行误差体系判断 //获得误差体系 List errSysDtls = pqErrSysDtls.stream().filter(x -> rangeComparison(multiply(x.getStartValue(), data, x.getConditionType()), diff --git a/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettyDevClientHandler.java b/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettyDevClientHandler.java index 8d605f22..966d8c69 100644 --- a/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettyDevClientHandler.java +++ b/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettyDevClientHandler.java @@ -100,6 +100,8 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler { //闪变 //CnSocketUtil.quitSend(param); } else if (sourceIssue.getType().equals(DicDataEnum.VOLTAGE.getCode()) || sourceIssue.getType().equals(DicDataEnum.HP.getCode())) { + + System.out.println("进入统计数据3分钟读超时。。。。。。"); CnSocketUtil.quitSend(param); WebSocketVO socketVO = new WebSocketVO<>(); @@ -109,6 +111,7 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler { WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketVO)); //统计数据项 }else { + System.out.println("进入实时数据3分钟读超时。。。。。。"); //实时数据 CnSocketUtil.quitSend(param); } @@ -116,8 +119,8 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler { } } - System.out.println("进入10S超时。。。。。。"); - //当连接超过10S和发送消息后10S无响应时候,关闭channel + + } diff --git a/device/src/main/java/com/njcn/gather/device/script/service/impl/PqScriptDtlsServiceImpl.java b/device/src/main/java/com/njcn/gather/device/script/service/impl/PqScriptDtlsServiceImpl.java index 27418545..f4a93384 100644 --- a/device/src/main/java/com/njcn/gather/device/script/service/impl/PqScriptDtlsServiceImpl.java +++ b/device/src/main/java/com/njcn/gather/device/script/service/impl/PqScriptDtlsServiceImpl.java @@ -215,7 +215,8 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl @@ -37,7 +37,7 @@ B_Value json NULL COMMENT 'B相值', C_Value json NULL COMMENT 'C相值', T_Value json NULL COMMENT 'T相值(没有相别的则存这里)', - PRIMARY KEY (Monitor_Id, Script_Id, Sort, Data_Type) + PRIMARY KEY (Monitor_Id, Script_Id, Sort, AD_Type) ) COMMENT='监测数据表'; diff --git a/storage/src/main/java/com/njcn/gather/storage/service/impl/TableGenServiceImpl.java b/storage/src/main/java/com/njcn/gather/storage/service/impl/TableGenServiceImpl.java index 464d068c..642c73f2 100644 --- a/storage/src/main/java/com/njcn/gather/storage/service/impl/TableGenServiceImpl.java +++ b/storage/src/main/java/com/njcn/gather/storage/service/impl/TableGenServiceImpl.java @@ -44,7 +44,7 @@ public class TableGenServiceImpl implements TableGenService { " Data_Type CHAR(32) NOT NULL COMMENT '数据指标,只有数据源为分钟统计时候才会使用(最大、最小、平均、CP95,默认平均值),字典表',\n" + " Result_Flag int(1) NULL COMMENT '0.不合格 1.合格',\n" + A+B+C+ - " PRIMARY KEY (Monitor_Id, Script_Id, Sort, Data_Type)\n" + + " PRIMARY KEY (Monitor_Id,Time_Id, Script_Id, Sort, AD_Type)\n" + ") COMMENT='监测数据表';"; tableGenMapper.genAdHarmonicTable(sql); @@ -57,7 +57,7 @@ public class TableGenServiceImpl implements TableGenService { " Data_Type CHAR(32) NOT NULL COMMENT '数据指标,只有数据源为分钟统计时候才会使用(最大、最小、平均、CP95,默认平均值),字典表',\n" + " Result_Flag int(1) NOT NULL COMMENT '0.不合格 1.合格',\n" + A+B+C+ - " PRIMARY KEY (Monitor_Id, Script_Id, Sort, Data_Type)\n" + + " PRIMARY KEY (Monitor_Id, Script_Id, Sort, AD_Type)\n" + ") COMMENT='监测数据表';"; tableGenMapper.genAdHarmonicTable(sql2); }