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 b774351f..54f1b55d 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 @@ -52,7 +52,7 @@ public class PreDetectionController extends BaseController { */ @PostMapping("/closePreTest") @OperateInfo - @ApiOperation("终止预检测") + @ApiOperation("终止检测") @ApiImplicitParam(name = "param", value = "查询参数", required = true) public HttpResult closePreTest(@RequestBody PreDetectionParam param){ String methodDescribe = getMethodDescribe("closePreTest"); 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 739839bb..52a63c47 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 @@ -15,6 +15,7 @@ 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.XiNumberManager; import com.njcn.gather.detection.util.socket.web.WebSocketHandler; import com.njcn.gather.device.device.pojo.vo.PreDetection; import com.njcn.gather.device.device.service.IPqDevService; @@ -1108,7 +1109,7 @@ public class SocketDevResponseService { .collect(Collectors.toList()); this.devNameMapComm = pqDevList.stream().collect(Collectors.toMap(PreDetection::getDevIP, PreDetection::getDevName)); this.devIdMapComm = pqDevList.stream().collect(Collectors.toMap(PreDetection::getDevIP, PreDetection::getDevId)); - + SocketManager.clockMap.clear(); //初始化有效数据数 Map sysRegResMap = iSysRegResService.listRegRes(); @@ -1141,7 +1142,7 @@ public class SocketDevResponseService { issueParam.setPlanId(param.getPlanId()); issueParam.setSourceId(param.getSourceId()); issueParam.setDevIds(param.getDevIds()); - issueParam.setScriptId("a303b2224845fcc6f60198b8ca23dca9"); + issueParam.setScriptId(param.getScriptId()); issueParam.setIsPhaseSequence(SourceOperateCodeEnum.COEFFICIENT_TEST.getValue()); List sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam); for (int j = 0; j < sourceIssues.size(); j++) { @@ -1178,8 +1179,6 @@ public class SocketDevResponseService { private void baseDataInsert(List devDataList, SourceIssue sourceIssue, PreDetectionParam param, Map checkDataMap) { // Runnable runnable = () -> { - - System.out.println("原始数据插入数据库开始执行========================================="); List adNonHarmonicResultList = new ArrayList<>(); List adHarmonicResultList = new ArrayList<>(); 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 eb14ff46..20974e98 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 @@ -213,16 +213,8 @@ public class PreDetectionServiceImpl implements PreDetectionService { @Override public boolean closePreTest(PreDetectionParam param) { - SocketMsg socketMsg = new SocketMsg(); - socketMsg.setRequestId(SourceOperateCodeEnum.QUITE.getValue()); - socketMsg.setOperateCode(SourceOperateCodeEnum.QUIT_INIT_03.getValue()); - SocketManager.sendMsg(param.getUserPageId() + dev, JSON.toJSONString(socketMsg)); - socketMsg.setRequestId(SourceOperateCodeEnum.QUITE_SOURCE.getValue()); - socketMsg.setOperateCode(SourceOperateCodeEnum.CLOSE_GATHER.getValue()); - SocketManager.sendMsg(param.getUserPageId() + source, JSON.toJSONString(socketMsg)); - return true; } } \ No newline at end of file diff --git a/detection/src/main/java/com/njcn/gather/detection/util/socket/FormTestManager.java b/detection/src/main/java/com/njcn/gather/detection/util/socket/FormTestManager.java new file mode 100644 index 00000000..20f6a429 --- /dev/null +++ b/detection/src/main/java/com/njcn/gather/detection/util/socket/FormTestManager.java @@ -0,0 +1,16 @@ +package com.njcn.gather.detection.util.socket; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * @Author: cdf + * @CreateTime: 2025-01-08 + * @Description: 正式检测对象管理 + */ +public class FormTestManager { + + public static Map devXiNumDataMap = new ConcurrentHashMap<>(); + + +} diff --git a/detection/src/main/java/com/njcn/gather/detection/handler/XiNumberManager.java b/detection/src/main/java/com/njcn/gather/detection/util/socket/XiNumberManager.java similarity index 92% rename from detection/src/main/java/com/njcn/gather/detection/handler/XiNumberManager.java rename to detection/src/main/java/com/njcn/gather/detection/util/socket/XiNumberManager.java index 6c07521a..99ee6167 100644 --- a/detection/src/main/java/com/njcn/gather/detection/handler/XiNumberManager.java +++ b/detection/src/main/java/com/njcn/gather/detection/util/socket/XiNumberManager.java @@ -1,11 +1,10 @@ -package com.njcn.gather.detection.handler; +package com.njcn.gather.detection.util.socket; import com.njcn.gather.detection.pojo.dto.DevXiNumData; import com.njcn.gather.detection.pojo.vo.CoefficientVO; import com.njcn.gather.device.script.pojo.po.SourceIssue; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -13,7 +12,7 @@ import java.util.concurrent.ConcurrentHashMap; /** * @Author: cdf * @CreateTime: 2025-01-05 - * @Description: 系数管理器 + * @Description: 系数校验管理器 */ public class XiNumberManager { diff --git a/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettyClient.java b/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettyClient.java index e2766828..2b91c55e 100644 --- a/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettyClient.java +++ b/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettyClient.java @@ -54,7 +54,7 @@ public class NettyClient { //空闲状态的handler // 添加LineBasedFrameDecoder来按行分割数据 .addLast(new LineBasedFrameDecoder(10240)) - .addLast(new IdleStateHandler(180, 0, 0, TimeUnit.SECONDS)) + .addLast(new IdleStateHandler(60, 0, 0, TimeUnit.SECONDS)) .addLast(new StringDecoder(CharsetUtil.UTF_8)) .addLast(new StringEncoder(CharsetUtil.UTF_8)) .addLast(handler); 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 966d8c69..bc0dc3e0 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 @@ -94,29 +94,61 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler { if (evt instanceof IdleStateEvent) { if (((IdleStateEvent) evt).state() == IdleState.READER_IDLE) { + + if(CollUtil.isNotEmpty(SocketManager.getSourceList())) { SourceIssue sourceIssue = SocketManager.getSourceList().get(0); + if(SocketManager.clockMap.containsKey(sourceIssue.getIndex())){ + SocketManager.clockMap.put(sourceIssue.getIndex(),SocketManager.clockMap.get(sourceIssue.getIndex())+60L); + }else { + SocketManager.clockMap.put(sourceIssue.getIndex(),60L); + } + + System.out.println("超时函数进入-----》"+sourceIssue.getType()+"----:"+SocketManager.clockMap.get(sourceIssue.getIndex())+"S"); + if (sourceIssue.getType().equals(DicDataEnum.F.getCode())) { //闪变 - //CnSocketUtil.quitSend(param); + if(SocketManager.clockMap.get(sourceIssue.getIndex()) > 1800){ + System.out.println("超时处理-----》"+sourceIssue.getType()+"已超时----------------关闭"); + CnSocketUtil.quitSend(param); + + WebSocketVO socketVO = new WebSocketVO<>(); + socketVO.setRequestId(SourceOperateCodeEnum.SOCKET_TIMEOUT.getValue()); + socketVO.setOperateCode(sourceIssue.getType()); + socketVO.setData(SourceOperateCodeEnum.SOCKET_TIMEOUT.getMsg()); + WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketVO)); + + } } 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<>(); - socketVO.setRequestId(SourceOperateCodeEnum.SOCKET_TIMEOUT.getValue()); - socketVO.setOperateCode(sourceIssue.getType()); - socketVO.setData(SourceOperateCodeEnum.SOCKET_TIMEOUT.getMsg()); - WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketVO)); //统计数据项 + if(SocketManager.clockMap.get(sourceIssue.getIndex()) > 180){ + CnSocketUtil.quitSend(param); + System.out.println("超时处理-----》"+sourceIssue.getType()+"已超时----------------关闭"); + + + WebSocketVO socketVO = new WebSocketVO<>(); + socketVO.setRequestId(SourceOperateCodeEnum.SOCKET_TIMEOUT.getValue()); + socketVO.setOperateCode(sourceIssue.getType()); + socketVO.setData(SourceOperateCodeEnum.SOCKET_TIMEOUT.getMsg()); + WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketVO)); + } + }else { - System.out.println("进入实时数据3分钟读超时。。。。。。"); //实时数据 - CnSocketUtil.quitSend(param); + if(SocketManager.clockMap.get(sourceIssue.getIndex()) > 60){ + CnSocketUtil.quitSend(param); + System.out.println("超时处理-----》"+sourceIssue.getType()+"已超时----------------关闭"); + + + WebSocketVO socketVO = new WebSocketVO<>(); + socketVO.setRequestId(SourceOperateCodeEnum.SOCKET_TIMEOUT.getValue()); + socketVO.setOperateCode(sourceIssue.getType()); + socketVO.setData(SourceOperateCodeEnum.SOCKET_TIMEOUT.getMsg()); + WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketVO)); + } } } - + System.out.println("已经等了一分钟了。。。。。。。。。。。。"); } } 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 f4a93384..e6dea178 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 adNonHarmonicResultList,String code) { + public Boolean acceptAdNon(List adNonHarmonicResultList, String code) { String adNonTable = "ad_non_harmonic_"; - DynamicTableNameHandler.setTableName(adNonTable +code); - for(AdNonHarmonicResult item :adNonHarmonicResultList){ - adNonHarmonicService.remove(new LambdaQueryWrapper() - .eq(AdNonHarmonicResult::getMonitorId,item.getMonitorId()) - .eq(AdNonHarmonicResult::getSort,item.getSort()) - .eq(AdNonHarmonicResult::getScriptId,item.getScriptId()) - ); + DynamicTableNameHandler.setTableName(adNonTable + code); + List monitorIds = adNonHarmonicResultList.stream().map(AdNonHarmonicResult::getMonitorId).distinct().collect(Collectors.toList()); + if(CollUtil.isNotEmpty(monitorIds)){ + adNonHarmonicService.remove(new LambdaQueryWrapper().in(AdNonHarmonicResult::getMonitorId, monitorIds).eq(AdNonHarmonicResult::getScriptId,adNonHarmonicResultList.get(0).getScriptId())); + adNonHarmonicService.saveBatch(adNonHarmonicResultList, 100); } - - adNonHarmonicService.saveBatch(adNonHarmonicResultList,100); DynamicTableNameHandler.remove(); return true; } @Override - public Boolean acceptAd(List adHarmonicResultList,String code) { + public Boolean acceptAd(List adHarmonicResultList, String code) { String adTable = "ad_harmonic_"; - DynamicTableNameHandler.setTableName(adTable +code); + DynamicTableNameHandler.setTableName(adTable + code); + List monitorIds = adHarmonicResultList.stream().map(AdHarmonicResult::getMonitorId).distinct().collect(Collectors.toList()); + if(CollUtil.isNotEmpty(monitorIds)){ + this.remove(new LambdaQueryWrapper().in(AdHarmonicResult::getMonitorId, monitorIds).eq(AdHarmonicResult::getScriptId,adHarmonicResultList.get(0).getScriptId())); + this.saveBatch(adHarmonicResultList, 100); - for(AdHarmonicResult item :adHarmonicResultList){ - this.remove(new LambdaQueryWrapper() - .eq(AdHarmonicResult::getMonitorId,item.getMonitorId()) - .eq(AdHarmonicResult::getSort,item.getSort()) - .eq(AdHarmonicResult::getScriptId,item.getScriptId()) - ); } - - this.saveBatch(adHarmonicResultList,100); DynamicTableNameHandler.remove(); return true; } @Override - public Boolean acceptAdNonResult(List adNonHarmonicResultList,String code) { + public Boolean acceptAdNonResult(List adNonHarmonicResultList, String code) { String adNonTableResult = "ad_non_harmonic_result_"; - DynamicTableNameHandler.setTableName(adNonTableResult +code); + DynamicTableNameHandler.setTableName(adNonTableResult + code); - for(AdNonHarmonicResult item :adNonHarmonicResultList){ + for (AdNonHarmonicResult item : adNonHarmonicResultList) { adNonHarmonicService.remove(new LambdaQueryWrapper() - .eq(AdNonHarmonicResult::getMonitorId,item.getMonitorId()) - .eq(AdNonHarmonicResult::getSort,item.getSort()) - .eq(AdNonHarmonicResult::getScriptId,item.getScriptId()) + .eq(AdNonHarmonicResult::getMonitorId, item.getMonitorId()) + .eq(AdNonHarmonicResult::getSort, item.getSort()) + .eq(AdNonHarmonicResult::getScriptId, item.getScriptId()) ); } - adNonHarmonicService.saveBatch(adNonHarmonicResultList,100); + adNonHarmonicService.saveBatch(adNonHarmonicResultList, 100); DynamicTableNameHandler.remove(); return true; } @Override - public Boolean acceptAdResult(List adHarmonicResultList,String code) { + public Boolean acceptAdResult(List adHarmonicResultList, String code) { String adTableResult = "ad_harmonic_result_"; - DynamicTableNameHandler.setTableName(adTableResult +code); - for(AdHarmonicResult item :adHarmonicResultList){ + DynamicTableNameHandler.setTableName(adTableResult + code); + for (AdHarmonicResult item : adHarmonicResultList) { this.remove(new LambdaQueryWrapper() - .eq(AdHarmonicResult::getMonitorId,item.getMonitorId()) - .eq(AdHarmonicResult::getSort,item.getSort()) - .eq(AdHarmonicResult::getScriptId,item.getScriptId()) + .eq(AdHarmonicResult::getMonitorId, item.getMonitorId()) + .eq(AdHarmonicResult::getSort, item.getSort()) + .eq(AdHarmonicResult::getScriptId, item.getScriptId()) ); } - this.saveBatch(adHarmonicResultList,100); + this.saveBatch(adHarmonicResultList, 100); DynamicTableNameHandler.remove(); return true; }