From f3a0bb75eeac9b01a482ecf40e3f72988355e529 Mon Sep 17 00:00:00 2001 From: chendaofei <857448963@qq.com> Date: Wed, 15 Jan 2025 14:22:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../detection/handler/SocketDevResponseService.java | 7 +++++-- .../gather/detection/util/socket/CnSocketUtil.java | 13 +++++++++++++ .../detection/util/socket/WebServiceManager.java | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java b/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java index f061daec..42259cf2 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 @@ -684,7 +684,7 @@ public class SocketDevResponseService { socketMsg.setRequestId(SourceOperateCodeEnum.YJC_XYJY.getValue()); socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_INIT_GATHER_03.getValue()); socketMsg.setData(jsonString); - System.out.println("开始3协议校验++++++++++"); + System.out.println("开始暂态协议校验++++++++++"); SocketManager.sendMsg(s, JSON.toJSONString(socketMsg)); } @@ -954,7 +954,6 @@ public class SocketDevResponseService { if (successComm.size() == FormalTestManager.monitorIdListComm.size()) { - System.out.println(sourceIssue.getType() + splitTag + sourceIssue.getIndex() + "当前测试小项读取数据已经全部结束。。。。。。。。。"); //修改装置为监测中 adPlanService.updateTestState(param.getPlanId(), param.getDevIds()); @@ -996,6 +995,7 @@ public class SocketDevResponseService { SocketManager.addTargetMap(sourceIssue.getType(), tem); System.out.println("该大项还有" + tem + "个小项没有进行检测!!!!!!!!"); if (tem == 0) { + System.out.println(sourceIssue.getType() + sourceIssue.getIndex() + "当前测试大项已经全部结束》》》》》》》》"); //当val为0则认为大项中的小项已经全部跑完,开始组装信息推送给前端 List resultList = new ArrayList<>(); @@ -1013,6 +1013,8 @@ public class SocketDevResponseService { resultList.add(devTem); }); + allDevTestList.clear(); + webSocketVO = new WebSocketVO<>(); webSocketVO.setRequestId(socketDataMsg.getRequestId().split(stepTag)[1] + stepEnd); webSocketVO.setData(resultList); @@ -1342,6 +1344,7 @@ public class SocketDevResponseService { this.devInfo.clear(); this.devDataMap.clear(); this.realDataXiList.clear(); + this.allDevTestList.clear(); List pqDevList = iPqDevService.getDevInfo(param.getDevIds()); FormalTestManager.devList = pqDevList; diff --git a/detection/src/main/java/com/njcn/gather/detection/util/socket/CnSocketUtil.java b/detection/src/main/java/com/njcn/gather/detection/util/socket/CnSocketUtil.java index a654893e..03de6087 100644 --- a/detection/src/main/java/com/njcn/gather/detection/util/socket/CnSocketUtil.java +++ b/detection/src/main/java/com/njcn/gather/detection/util/socket/CnSocketUtil.java @@ -4,7 +4,12 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum; import com.njcn.gather.detection.pojo.param.PreDetectionParam; +import com.njcn.gather.detection.pojo.vo.CoefficientVO; import com.njcn.gather.detection.pojo.vo.SocketMsg; +import com.njcn.gather.detection.pojo.vo.WebSocketVO; +import com.njcn.gather.detection.util.socket.web.WebSocketHandler; + +import java.util.Objects; /** * @Author: cdf @@ -38,4 +43,12 @@ public class CnSocketUtil { socketMsg.setData(jsonObject.toJSONString()); SocketManager.sendMsg(param.getUserPageId() + sourceTag, JSON.toJSONString(socketMsg)); } + + public static void sendToWebSocket(String userId,String requestId, String operatorType, Object data){ + WebSocketVO webSocketVO = new WebSocketVO<>(); + webSocketVO.setRequestId(requestId); + webSocketVO.setOperateCode(operatorType); + webSocketVO.setData(data); + WebServiceManager.sendMessage(userId,webSocketVO); + } } diff --git a/detection/src/main/java/com/njcn/gather/detection/util/socket/WebServiceManager.java b/detection/src/main/java/com/njcn/gather/detection/util/socket/WebServiceManager.java index f8098ec9..c486a259 100644 --- a/detection/src/main/java/com/njcn/gather/detection/util/socket/WebServiceManager.java +++ b/detection/src/main/java/com/njcn/gather/detection/util/socket/WebServiceManager.java @@ -60,7 +60,7 @@ public class WebServiceManager { } - public static void sendMessage(String userId, WebSocketVO webSocketVO) { + public static void sendMessage(String userId, WebSocketVO webSocketVO) { Channel channel = userSessions.get(userId); if(Objects.nonNull(channel) && channel.isActive()){ TextWebSocketFrame wd = new TextWebSocketFrame(JSON.toJSONString(webSocketVO));