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 4f0c960f..f6769385 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 @@ -319,7 +319,7 @@ public class SocketContrastResponseService { CnSocketUtil.quitSend(param); break; default: - CnSocketUtil.sendUnSocket(param.getUserPageId()); + WebServiceManager.sendUnknownErrorMessage(param.getUserPageId()); break; } } @@ -422,7 +422,7 @@ public class SocketContrastResponseService { CnSocketUtil.quitSend(param); break; default: - CnSocketUtil.sendUnSocket(param.getUserPageId()); + WebServiceManager.sendUnknownErrorMessage(param.getUserPageId()); break; } } @@ -517,7 +517,7 @@ public class SocketContrastResponseService { CnSocketUtil.quitSend(param); break; default: - CnSocketUtil.sendUnSocket(param.getUserPageId()); + WebServiceManager.sendUnknownErrorMessage(param.getUserPageId()); break; } } @@ -621,7 +621,7 @@ public class SocketContrastResponseService { CnSocketUtil.quitSend(param); break; default: - CnSocketUtil.sendUnSocket(param.getUserPageId()); + WebServiceManager.sendUnknownErrorMessage(param.getUserPageId()); break; } } @@ -787,7 +787,7 @@ public class SocketContrastResponseService { WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg)); break; default: - CnSocketUtil.sendUnSocket(param.getUserPageId()); + WebServiceManager.sendUnknownErrorMessage(param.getUserPageId()); break; } } 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 2f05bd39..523dd16d 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 @@ -307,7 +307,7 @@ public class SocketDevResponseService { } break; default: - CnSocketUtil.sendUnSocket(param.getUserPageId()); + WebServiceManager.sendUnknownErrorMessage(param.getUserPageId()); break; } @@ -549,7 +549,7 @@ public class SocketDevResponseService { DevXiNumData.GF gfItem = createGFItem(monitorId, F); gf.add(gfItem); //表格数据 - CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.Coefficient_Check.getValue(), SourceOperateCodeEnum.DATA_CHNFACTOR$02.getValue(), coefficientVO, null); + WebServiceManager.sendDetectionMessage(param.getUserPageId(), SourceOperateCodeEnum.Coefficient_Check.getValue(), SourceOperateCodeEnum.DATA_CHNFACTOR$02.getValue(), coefficientVO, null); }); DevXiNumData devXiNumData = createDevXiNumData(devIp, gf, xiFlag.get()); saveDevXiNumData(devIp, devXiNumData); @@ -761,7 +761,7 @@ public class SocketDevResponseService { CnSocketUtil.quitSend(param); break; default: - CnSocketUtil.sendUnSocket(param.getUserPageId()); + WebServiceManager.sendUnknownErrorMessage(param.getUserPageId()); break; } } @@ -996,7 +996,7 @@ public class SocketDevResponseService { CnSocketUtil.quitSend(param); break; default: - CnSocketUtil.sendUnSocket(param.getUserPageId()); + WebServiceManager.sendUnknownErrorMessage(param.getUserPageId()); break; } } @@ -1206,7 +1206,7 @@ public class SocketDevResponseService { CnSocketUtil.quitSend(param); break; default: - CnSocketUtil.sendUnSocket(param.getUserPageId()); + WebServiceManager.sendUnknownErrorMessage(param.getUserPageId()); break; } } @@ -1282,7 +1282,7 @@ public class SocketDevResponseService { resultList.add(devTem); }); allDevTestList.clear(); - CnSocketUtil.sendToWebSocket(param.getUserPageId(), socketDataMsg.getRequestId().split(CnSocketUtil.STEP_TAG)[1] + CnSocketUtil.END_TAG, null, resultList, null); + WebServiceManager.sendDetectionMessage(param.getUserPageId(), socketDataMsg.getRequestId().split(CnSocketUtil.STEP_TAG)[1] + CnSocketUtil.END_TAG, null, resultList, null); } //在这一步判断是否已经触发暂停按钮 if (FormalTestManager.stopFlag && CollUtil.isNotEmpty(SocketManager.getSourceList())) { @@ -1300,7 +1300,7 @@ public class SocketDevResponseService { SourceIssue sourceIssues = SocketManager.getSourceList().get(0); // 如果上一个大项检测完成,则检测下一个大项,并向前端推送消息 if (residueCount == 0) { - CnSocketUtil.sendToWebSocket(param.getUserPageId(), sourceIssues.getType() + CnSocketUtil.START_TAG, null, new ArrayList<>(), null); + WebServiceManager.sendDetectionMessage(param.getUserPageId(), sourceIssues.getType() + CnSocketUtil.START_TAG, null, new ArrayList<>(), null); } //控源下发下一个小项脚本 @@ -1351,7 +1351,7 @@ public class SocketDevResponseService { case MESSAGE_PARSING_ERROR: break; default: - CnSocketUtil.sendUnSocket(param.getUserPageId()); + WebServiceManager.sendUnknownErrorMessage(param.getUserPageId()); break; } } @@ -1490,7 +1490,7 @@ public class SocketDevResponseService { } break; default: - CnSocketUtil.sendUnSocket(param.getUserPageId()); + WebServiceManager.sendUnknownErrorMessage(param.getUserPageId()); break; } diff --git a/detection/src/main/java/com/njcn/gather/detection/handler/SocketSourceResponseService.java b/detection/src/main/java/com/njcn/gather/detection/handler/SocketSourceResponseService.java index 37220161..9145eb46 100644 --- a/detection/src/main/java/com/njcn/gather/detection/handler/SocketSourceResponseService.java +++ b/detection/src/main/java/com/njcn/gather/detection/handler/SocketSourceResponseService.java @@ -135,7 +135,7 @@ public class SocketSourceResponseService { WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg)); break; default: - CnSocketUtil.sendUnSocket(param.getUserPageId()); + WebServiceManager.sendUnknownErrorMessage(param.getUserPageId()); break; } } @@ -273,7 +273,7 @@ public class SocketSourceResponseService { WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg)); break; default: - CnSocketUtil.sendUnSocket(param.getUserPageId()); + WebServiceManager.sendUnknownErrorMessage(param.getUserPageId()); break; } } diff --git a/detection/src/main/java/com/njcn/gather/detection/pojo/enums/DetectionResponseEnum.java b/detection/src/main/java/com/njcn/gather/detection/pojo/enums/DetectionResponseEnum.java index 584ce551..20360bc9 100644 --- a/detection/src/main/java/com/njcn/gather/detection/pojo/enums/DetectionResponseEnum.java +++ b/detection/src/main/java/com/njcn/gather/detection/pojo/enums/DetectionResponseEnum.java @@ -9,6 +9,7 @@ import lombok.Getter; @Getter public enum DetectionResponseEnum { PLAN_PATTERN_NOT("A020001", "计划模式查询为空"), + PLAN_NOT_EXIST("A020001", "计划信息缺失"), SCRIPT_PATTERN_NOT("A020001", "检测脚本查询为空"), SOURCE_INFO_NOT("A020002", "源表信息不存在"), PLAN_AND_SOURCE_NOT("A020003", "计划和源关系不存在"), 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 d32a6178..daf621b1 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 @@ -93,9 +93,9 @@ public class PreDetectionServiceImpl implements PreDetectionService { //用于处理异常导致的socket通道未关闭,socket交互异常 DetectionCommunicateUtil.checkCommunicateChannel(param); /* - 先组装源通讯协议 - 查询计划什么模式的(除了对比式,其他都是一个计划对应一个源) - */ + * 先组装源通讯协议 + * 查询计划什么模式的(除了对比式,其他都是一个计划对应一个源) + */ AdPlan plan = iAdPlanService.getById(param.getPlanId()); param.setScriptId(plan.getScriptId()); param.setErrorSysId(plan.getErrorSysId()); @@ -103,19 +103,24 @@ public class PreDetectionServiceImpl implements PreDetectionService { if (ObjectUtil.isNotNull(plan)) { String code = dictDataService.getDictDataById(plan.getPattern()).getCode(); DictDataEnum dictDataEnumByCode = DictDataEnum.getDictDataEnumByCode(code); - switch (dictDataEnumByCode) { - case DIGITAL: - case SIMULATE: - sendYtxSocket(param); - break; - case CONTRAST: - break; - default: - throw new BusinessException(DetectionResponseEnum.PLAN_PATTERN_NOT); + if (Objects.nonNull(dictDataEnumByCode)) { + switch (dictDataEnumByCode) { + case DIGITAL: + case SIMULATE: + sendYtxSocket(param); + break; + case CONTRAST: + break; + default: + throw new BusinessException(DetectionResponseEnum.PLAN_PATTERN_NOT); + } + } else { + throw new BusinessException(DetectionResponseEnum.PLAN_PATTERN_NOT); } + } else { + throw new BusinessException(DetectionResponseEnum.PLAN_NOT_EXIST); } - } @Override @@ -149,7 +154,7 @@ public class PreDetectionServiceImpl implements PreDetectionService { /** * 发送源通信校验Socket连接(数字式和模拟式检测模式) - * + * *

该方法用于建立与程控源设备的Socket连接,进行源通信校验。主要流程:

* - * + * * @param param 预检测参数,包含计划ID、用户ID等信息 * @throws BusinessException 当计划源信息不存在或源初始化参数为空时抛出 - * * @see SourceOperateCodeEnum#YJC_YTXJY 源通信校验操作码 * @see SourceOperateCodeEnum#INIT_GATHER 初始化采集操作码 */ private void sendYtxSocket(PreDetectionParam param) { - String loginName = RequestUtil.getLoginNameByToken(); - WebServiceManager.addPreDetectionParam(loginName, param); AdPlanSource planSource = adPlanSourceService.getOne(new LambdaQueryWrapper().eq(AdPlanSource::getPlanId, param.getPlanId())); param.setSourceId(planSource.getSourceId()); + String loginName = RequestUtil.getLoginNameByToken(); + WebServiceManager.addPreDetectionParam(loginName, param); if (ObjectUtil.isNotNull(planSource)) { //获取源初始化参数 SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(planSource.getSourceId()); @@ -183,7 +187,6 @@ public class PreDetectionServiceImpl implements PreDetectionService { socketMsg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue()); socketMsg.setData(JSON.toJSONString(sourceParam)); //建立与源控程序的socket连接, -// NettyClient.socketClient(ip, port, param, JSON.toJSONString(socketMsg), new NettySourceClientHandler(param, sourceResponseService)); NettyClient.socketClient(ip, port, param, JSON.toJSONString(socketMsg), new NettySourceClientHandler(param, socketSourceResponseService)); } else { throw new BusinessException(DetectionResponseEnum.SOURCE_INFO_NOT); @@ -195,17 +198,16 @@ public class PreDetectionServiceImpl implements PreDetectionService { /** * 发送源通信校验Socket连接(仿真模式) - * + * *

该方法专门用于仿真检测模式下的源通信校验。与普通模式的区别:

* - * + * * @param param 预检测参数,必须包含sourceId和userPageId * @throws BusinessException 当源初始化参数为空时抛出 - * * @see #sendYtxSocket(PreDetectionParam) 普通检测模式的源通信校验 * @see SourceOperateCodeEnum#YJC_YTXJY 源通信校验操作码 * @see SourceOperateCodeEnum#INIT_GATHER 初始化采集操作码 diff --git a/detection/src/main/java/com/njcn/gather/detection/util/business/DetectionCommunicateUtil.java b/detection/src/main/java/com/njcn/gather/detection/util/business/DetectionCommunicateUtil.java index 36716463..e17ff7f7 100644 --- a/detection/src/main/java/com/njcn/gather/detection/util/business/DetectionCommunicateUtil.java +++ b/detection/src/main/java/com/njcn/gather/detection/util/business/DetectionCommunicateUtil.java @@ -28,29 +28,32 @@ public class DetectionCommunicateUtil { Channel channelSource = SocketManager.getChannelByUserId(param.getUserPageId() + DetectionCommunicateConstant.SOURCE); Channel channelDev = SocketManager.getChannelByUserId(param.getUserPageId() + DetectionCommunicateConstant.DEV); - if (Objects.nonNull(channelSource) && channelSource.isActive()) { - System.out.println("发送关闭源指令。。。。。。。。"); - CnSocketUtil.quitSendSource(param); - } - if (Objects.nonNull(channelDev) && channelDev.isActive()) { - System.out.println("发送关闭设备通讯指令。。。。。。。。"); - CnSocketUtil.quitSend(param); + boolean channelSourceActive = channelSource != null && channelSource.isActive(); + boolean channelDevActive = channelDev != null && channelDev.isActive(); + if(channelSourceActive || channelDevActive){ + if(channelSourceActive){ + System.out.println("发送关闭源指令。。。。。。。。"); + CnSocketUtil.quitSendSource(param); + } + + if(channelDevActive){ + System.out.println("发送关闭设备通讯指令。。。。。。。。"); + CnSocketUtil.quitSend(param); + } + // 休眠4秒 + try { + Thread.sleep(4000); + } catch (InterruptedException e) { + log.error(e.getMessage()); + } } - try { - Thread.sleep(4000); - } catch (InterruptedException e) { - log.error(e.getMessage()); - } - SocketManager.removeUser(param.getUserPageId() + DetectionCommunicateConstant.SOURCE); - SocketManager.removeUser(param.getUserPageId() + DetectionCommunicateConstant.DEV); - try { - Thread.sleep(2000); - } catch (InterruptedException e) { - log.error(e.getMessage()); - } +// SocketManager.removeUser(param.getUserPageId() + DetectionCommunicateConstant.SOURCE); +// SocketManager.removeUser(param.getUserPageId() + DetectionCommunicateConstant.DEV); + + } 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 954fd1e7..a3094748 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 @@ -5,7 +5,6 @@ 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.SocketMsg; -import com.njcn.gather.detection.pojo.vo.WebSocketVO; import com.njcn.gather.detection.util.socket.websocket.WebServiceManager; /** @@ -35,6 +34,7 @@ public class CnSocketUtil { socketMsg.setRequestId(SourceOperateCodeEnum.QUITE.getValue()); socketMsg.setOperateCode(SourceOperateCodeEnum.QUIT_INIT_03.getValue()); SocketManager.sendMsg(param.getUserPageId() + DEV_TAG, JSON.toJSONString(socketMsg)); + WebServiceManager.removePreDetectionParam(); } @@ -52,29 +52,6 @@ public class CnSocketUtil { WebServiceManager.removePreDetectionParam(); } - /** - * 推送webSocket数据 - */ - public static void sendToWebSocket(String userId, String requestId, String operatorType, Object data, String desc) { - WebSocketVO webSocketVO = new WebSocketVO<>(); - webSocketVO.setRequestId(requestId); - webSocketVO.setOperateCode(operatorType); - webSocketVO.setData(data); - webSocketVO.setDesc(desc); - WebServiceManager.sendMessage(userId, webSocketVO); - } - - - /** - * 推送未知异常的webSocket数据 - */ - public static void sendUnSocket(String userId) { - WebSocketVO webSocketVO = new WebSocketVO<>(); - webSocketVO.setRequestId(SourceOperateCodeEnum.UNKNOWN_OPERATE.getValue()); - webSocketVO.setData(SourceOperateCodeEnum.UNKNOWN_OPERATE.getMsg()); - webSocketVO.setOperateCode(SourceOperateCodeEnum.UNKNOWN_OPERATE.getMsg()); - WebServiceManager.sendMessage(userId, webSocketVO); - } /** 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 0c691619..70a341f8 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 @@ -53,7 +53,6 @@ public class NettyClient { .addLast(handler); } else { ch.pipeline() - // 添加LineBasedFrameDecoder来按行分割数据 .addLast(new LineBasedFrameDecoder(10240)) .addLast(new StringDecoder(CharsetUtil.UTF_8)) diff --git a/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettyContrastClientHandler.java b/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettyContrastClientHandler.java index fca4fae9..45b725b2 100644 --- a/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettyContrastClientHandler.java +++ b/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettyContrastClientHandler.java @@ -5,6 +5,7 @@ import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum; import com.njcn.gather.detection.pojo.param.PreDetectionParam; import com.njcn.gather.detection.util.socket.CnSocketUtil; import com.njcn.gather.detection.util.socket.SocketManager; +import com.njcn.gather.detection.util.socket.websocket.WebServiceManager; import com.njcn.gather.plan.pojo.enums.DataSourceEnum; import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; @@ -155,7 +156,7 @@ public class NettyContrastClientHandler extends SimpleChannelInboundHandler { fly = true; //为空则认为是常规步骤,设定一分钟超时 CnSocketUtil.quitSend(param); - CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.SOCKET_TIMEOUT.getValue(), SourceOperateCodeEnum.SOCKET_TIMEOUT.getValue(), SourceOperateCodeEnum.SOCKET_TIMEOUT.getMsg(), null); + WebServiceManager.sendDetectionErrorMessage(param.getUserPageId(), SourceOperateCodeEnum.SOCKET_TIMEOUT); } if (fly) { socketResponseService.backCheckState(param); @@ -152,7 +152,7 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler { System.out.println("当前进入暂停操作超时函数-----------------" + FormalTestManager.stopTime); if (FormalTestManager.stopTime > 600) { CnSocketUtil.quitSend(param); - CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.FORMAL_REAL.getValue(), SourceOperateCodeEnum.STOP_TIMEOUT.getValue(), SourceOperateCodeEnum.STOP_TIMEOUT.getMsg(), null); + WebServiceManager.sendDetectionErrorMessage(param.getUserPageId(), SourceOperateCodeEnum.STOP_TIMEOUT); } } } @@ -181,7 +181,7 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler { } else if (cause instanceof IOException) { // 处理I/O异常,例如读写错误 System.out.println("IOException caught: There was an I/O error."); - CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.DEVICE_ERROR.getValue(), SourceOperateCodeEnum.DEVICE_ERROR.getValue(), SourceOperateCodeEnum.DEVICE_ERROR.getMsg(), null); + WebServiceManager.sendDetectionErrorMessage(param.getUserPageId(), SourceOperateCodeEnum.DEVICE_ERROR); // 例如,可以记录更详细的I/O错误信息 } else if (cause instanceof TimeoutException) { @@ -195,7 +195,7 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler { } else { // 处理其他类型的异常 System.out.println("Unknown exception caught: " + cause.getMessage()); - CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.DEVICE_ERROR.getValue(), SourceOperateCodeEnum.DEVICE_ERROR.getValue(), SourceOperateCodeEnum.DEVICE_ERROR.getMsg(), null); + WebServiceManager.sendDetectionErrorMessage(param.getUserPageId(), SourceOperateCodeEnum.DEVICE_ERROR); // 可以记录未知异常信息 } CnSocketUtil.quitSend(param); diff --git a/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettySourceClientHandler.java b/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettySourceClientHandler.java index f56aa9bd..4a1f79d1 100644 --- a/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettySourceClientHandler.java +++ b/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettySourceClientHandler.java @@ -5,6 +5,7 @@ import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum; import com.njcn.gather.detection.pojo.param.PreDetectionParam; import com.njcn.gather.detection.util.socket.CnSocketUtil; import com.njcn.gather.detection.util.socket.SocketManager; +import com.njcn.gather.detection.util.socket.websocket.WebServiceManager; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; import io.netty.handler.timeout.IdleState; @@ -118,7 +119,7 @@ public class NettySourceClientHandler extends SimpleChannelInboundHandler getOnlineUserIds() { return new java.util.HashSet<>(userSessions.keySet()); } + + // ================================ 检测消息推送方法 ================================ + + /** + * 发送检测相关消息给指定用户 + *

用于推送检测状态、进度、结果等结构化消息

+ * + * @param userId 目标用户ID + * @param requestId 请求ID,用于标识消息类型和流程 + * @param operateCode 操作代码,标识具体的操作类型 + * @param data 数据载荷,可以是任意类型的数据 + * @param desc 描述信息 + * @since v2.3.12 重构版本 + */ + public static void sendDetectionMessage(String userId, String requestId, String operateCode, Object data, String desc) { + WebSocketVO webSocketVO = new WebSocketVO<>(); + webSocketVO.setRequestId(requestId); + webSocketVO.setOperateCode(operateCode); + webSocketVO.setData(data); + webSocketVO.setDesc(desc); + sendMessage(userId, webSocketVO); + } + + /** + * 发送未知错误消息给指定用户 + *

用于处理系统无法识别的操作或未知异常情况

+ * + * @param userId 目标用户ID + * @since v2.3.12 重构版本 + */ + public static void sendUnknownErrorMessage(String userId) { + WebSocketVO webSocketVO = new WebSocketVO<>(); + webSocketVO.setRequestId(SourceOperateCodeEnum.UNKNOWN_OPERATE.getValue()); + webSocketVO.setData(SourceOperateCodeEnum.UNKNOWN_OPERATE.getMsg()); + webSocketVO.setOperateCode(SourceOperateCodeEnum.UNKNOWN_OPERATE.getMsg()); + sendMessage(userId, webSocketVO); + } + + /** + * 发送检测错误消息给指定用户 + *

用于推送特定类型的检测错误信息

+ * + * @param userId 目标用户ID + * @param errorType 错误类型枚举 + * @since v2.3.12 重构版本 + */ + public static void sendDetectionErrorMessage(String userId, SourceOperateCodeEnum errorType) { + WebSocketVO webSocketVO = new WebSocketVO<>(); + webSocketVO.setRequestId(errorType.getValue()); + webSocketVO.setData(errorType.getMsg()); + webSocketVO.setOperateCode(errorType.getValue()); + sendMessage(userId, webSocketVO); + } } \ No newline at end of file diff --git a/entrance/src/main/resources/application.yml b/entrance/src/main/resources/application.yml index 9097c056..aa1e2990 100644 --- a/entrance/src/main/resources/application.yml +++ b/entrance/src/main/resources/application.yml @@ -49,10 +49,10 @@ phaseAngle: socket: source: - ip: 127.0.0.1 + ip: 192.168.1.124 port: 62000 device: - ip: 127.0.0.1 + ip: 192.168.1.124 port: 61000 # source: # ip: 192.168.1.121