From e9a294acdb985f461e9c4482c7ebaa9ed0dee354 Mon Sep 17 00:00:00 2001 From: chendaofei <857448963@qq.com> Date: Wed, 18 Dec 2024 11:00:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handler/SocketDevResponseService.java | 66 +++++++++++++++++-- 1 file changed, 60 insertions(+), 6 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 4174ea98..c8b609e3 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 @@ -8,6 +8,7 @@ import com.njcn.gather.detection.pojo.enums.SourceResponseCodeEnum; import com.njcn.gather.detection.pojo.param.PreDetectionParam; import com.njcn.gather.detection.pojo.vo.SocketDataMsg; import com.njcn.gather.detection.pojo.vo.SocketMsg; +import com.njcn.gather.detection.pojo.vo.WebSocketVO; import com.njcn.gather.detection.util.socket.MsgUtil; import com.njcn.gather.detection.util.socket.SocketManager; import com.njcn.gather.detection.util.socket.cilent.NettyClient; @@ -31,7 +32,10 @@ import java.util.*; public class SocketDevResponseService { + private final String handlerStr = "_dev"; private final WebSocketHandler webSocketHandler; + private final IPqDevService iPqDevService; + @@ -41,11 +45,11 @@ public class SocketDevResponseService { switch (sourceOperateCodeEnum) { case YJC_SBTXJY: - + devComm(socketDataMsg,param,msg); break; case YJC_XYJY: + devXieyi(socketDataMsg,param,msg); break; - case YJC_XUJY: break; } @@ -57,10 +61,63 @@ public class SocketDevResponseService { - private void devComm(SocketDataMsg socketDataMsg,PreDetectionParam param){ + private void devComm(SocketDataMsg socketDataMsg,PreDetectionParam param,String msg){ + SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode()); + String s = param.getUserPageId() + handlerStr; + SocketMsg socketMsg=new SocketMsg(); + switch (dictDataEnumByCode){ + case SUCCESS: + //通讯校验成功 + webSocketHandler.sendMsgToUser(param.getUserPageId(), msg); + //开始进行协议校验 + List devList = iPqDevService.getDevInfo(param.getDevIds()); + Map> map = new HashMap(1); + map.put("deviceList", devList); + String jsonString = JSON.toJSONString(map); + socketMsg.setRequestId(SourceOperateCodeEnum.YJC_XYJY.getValue()); + socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_INIT_GATHER_02.getValue()); + socketMsg.setData(jsonString); + String json = JSON.toJSONString(socketMsg); + SocketManager.sendMsg(s,json); + + break; + case UNPROCESSED_BUSINESS: + break; + case RE_OPERATE: + //发起关闭操作 + //SocketMsg socketMsg = new SocketMsg(); + // socketMsg.setRequestId("quit"); + // socketMsg.setOperateCode("QUIT_FUNEND$01"); + // SocketManager.sendMsg(s,JSON.toJSONString(socketMsg)); + + break; + default: + WebSocketVO webSocketVO = new WebSocketVO(); + + + break; + } + } + + + private void devXieyi(SocketDataMsg socketDataMsg,PreDetectionParam param,String msg){ SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode()); switch (dictDataEnumByCode){ + case SUCCESS: + webSocketHandler.sendMsgToUser(param.getUserPageId(), msg); + String s = param.getUserPageId() + handlerStr; + break; + case UNPROCESSED_BUSINESS: + break; + case RE_OPERATE: + //发起关闭操作 + break; + default: + WebSocketVO webSocketVO = new WebSocketVO(); + + + break; } } @@ -70,7 +127,4 @@ public class SocketDevResponseService { - - - }