Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -319,7 +319,7 @@ public class SocketContrastResponseService {
|
|||||||
CnSocketUtil.quitSend(param);
|
CnSocketUtil.quitSend(param);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CnSocketUtil.sendUnSocket(param.getUserPageId());
|
WebServiceManager.sendUnknownErrorMessage(param.getUserPageId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -422,7 +422,7 @@ public class SocketContrastResponseService {
|
|||||||
CnSocketUtil.quitSend(param);
|
CnSocketUtil.quitSend(param);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CnSocketUtil.sendUnSocket(param.getUserPageId());
|
WebServiceManager.sendUnknownErrorMessage(param.getUserPageId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -517,7 +517,7 @@ public class SocketContrastResponseService {
|
|||||||
CnSocketUtil.quitSend(param);
|
CnSocketUtil.quitSend(param);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CnSocketUtil.sendUnSocket(param.getUserPageId());
|
WebServiceManager.sendUnknownErrorMessage(param.getUserPageId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -621,7 +621,7 @@ public class SocketContrastResponseService {
|
|||||||
CnSocketUtil.quitSend(param);
|
CnSocketUtil.quitSend(param);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CnSocketUtil.sendUnSocket(param.getUserPageId());
|
WebServiceManager.sendUnknownErrorMessage(param.getUserPageId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -787,7 +787,7 @@ public class SocketContrastResponseService {
|
|||||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CnSocketUtil.sendUnSocket(param.getUserPageId());
|
WebServiceManager.sendUnknownErrorMessage(param.getUserPageId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ public class SocketDevResponseService {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CnSocketUtil.sendUnSocket(param.getUserPageId());
|
WebServiceManager.sendUnknownErrorMessage(param.getUserPageId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -549,7 +549,7 @@ public class SocketDevResponseService {
|
|||||||
DevXiNumData.GF gfItem = createGFItem(monitorId, F);
|
DevXiNumData.GF gfItem = createGFItem(monitorId, F);
|
||||||
gf.add(gfItem);
|
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());
|
DevXiNumData devXiNumData = createDevXiNumData(devIp, gf, xiFlag.get());
|
||||||
saveDevXiNumData(devIp, devXiNumData);
|
saveDevXiNumData(devIp, devXiNumData);
|
||||||
@@ -761,7 +761,7 @@ public class SocketDevResponseService {
|
|||||||
CnSocketUtil.quitSend(param);
|
CnSocketUtil.quitSend(param);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CnSocketUtil.sendUnSocket(param.getUserPageId());
|
WebServiceManager.sendUnknownErrorMessage(param.getUserPageId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -996,7 +996,7 @@ public class SocketDevResponseService {
|
|||||||
CnSocketUtil.quitSend(param);
|
CnSocketUtil.quitSend(param);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CnSocketUtil.sendUnSocket(param.getUserPageId());
|
WebServiceManager.sendUnknownErrorMessage(param.getUserPageId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1206,7 +1206,7 @@ public class SocketDevResponseService {
|
|||||||
CnSocketUtil.quitSend(param);
|
CnSocketUtil.quitSend(param);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CnSocketUtil.sendUnSocket(param.getUserPageId());
|
WebServiceManager.sendUnknownErrorMessage(param.getUserPageId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1282,7 +1282,7 @@ public class SocketDevResponseService {
|
|||||||
resultList.add(devTem);
|
resultList.add(devTem);
|
||||||
});
|
});
|
||||||
allDevTestList.clear();
|
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())) {
|
if (FormalTestManager.stopFlag && CollUtil.isNotEmpty(SocketManager.getSourceList())) {
|
||||||
@@ -1300,7 +1300,7 @@ public class SocketDevResponseService {
|
|||||||
SourceIssue sourceIssues = SocketManager.getSourceList().get(0);
|
SourceIssue sourceIssues = SocketManager.getSourceList().get(0);
|
||||||
// 如果上一个大项检测完成,则检测下一个大项,并向前端推送消息
|
// 如果上一个大项检测完成,则检测下一个大项,并向前端推送消息
|
||||||
if (residueCount == 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:
|
case MESSAGE_PARSING_ERROR:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CnSocketUtil.sendUnSocket(param.getUserPageId());
|
WebServiceManager.sendUnknownErrorMessage(param.getUserPageId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1490,7 +1490,7 @@ public class SocketDevResponseService {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CnSocketUtil.sendUnSocket(param.getUserPageId());
|
WebServiceManager.sendUnknownErrorMessage(param.getUserPageId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ public class SocketSourceResponseService {
|
|||||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CnSocketUtil.sendUnSocket(param.getUserPageId());
|
WebServiceManager.sendUnknownErrorMessage(param.getUserPageId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -273,7 +273,7 @@ public class SocketSourceResponseService {
|
|||||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CnSocketUtil.sendUnSocket(param.getUserPageId());
|
WebServiceManager.sendUnknownErrorMessage(param.getUserPageId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
public enum DetectionResponseEnum {
|
public enum DetectionResponseEnum {
|
||||||
PLAN_PATTERN_NOT("A020001", "计划模式查询为空"),
|
PLAN_PATTERN_NOT("A020001", "计划模式查询为空"),
|
||||||
|
PLAN_NOT_EXIST("A020001", "计划信息缺失"),
|
||||||
SCRIPT_PATTERN_NOT("A020001", "检测脚本查询为空"),
|
SCRIPT_PATTERN_NOT("A020001", "检测脚本查询为空"),
|
||||||
SOURCE_INFO_NOT("A020002", "源表信息不存在"),
|
SOURCE_INFO_NOT("A020002", "源表信息不存在"),
|
||||||
PLAN_AND_SOURCE_NOT("A020003", "计划和源关系不存在"),
|
PLAN_AND_SOURCE_NOT("A020003", "计划和源关系不存在"),
|
||||||
|
|||||||
@@ -93,9 +93,9 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
//用于处理异常导致的socket通道未关闭,socket交互异常
|
//用于处理异常导致的socket通道未关闭,socket交互异常
|
||||||
DetectionCommunicateUtil.checkCommunicateChannel(param);
|
DetectionCommunicateUtil.checkCommunicateChannel(param);
|
||||||
/*
|
/*
|
||||||
先组装源通讯协议
|
* 先组装源通讯协议
|
||||||
查询计划什么模式的(除了对比式,其他都是一个计划对应一个源)
|
* 查询计划什么模式的(除了对比式,其他都是一个计划对应一个源)
|
||||||
*/
|
*/
|
||||||
AdPlan plan = iAdPlanService.getById(param.getPlanId());
|
AdPlan plan = iAdPlanService.getById(param.getPlanId());
|
||||||
param.setScriptId(plan.getScriptId());
|
param.setScriptId(plan.getScriptId());
|
||||||
param.setErrorSysId(plan.getErrorSysId());
|
param.setErrorSysId(plan.getErrorSysId());
|
||||||
@@ -103,19 +103,24 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
if (ObjectUtil.isNotNull(plan)) {
|
if (ObjectUtil.isNotNull(plan)) {
|
||||||
String code = dictDataService.getDictDataById(plan.getPattern()).getCode();
|
String code = dictDataService.getDictDataById(plan.getPattern()).getCode();
|
||||||
DictDataEnum dictDataEnumByCode = DictDataEnum.getDictDataEnumByCode(code);
|
DictDataEnum dictDataEnumByCode = DictDataEnum.getDictDataEnumByCode(code);
|
||||||
switch (dictDataEnumByCode) {
|
if (Objects.nonNull(dictDataEnumByCode)) {
|
||||||
case DIGITAL:
|
switch (dictDataEnumByCode) {
|
||||||
case SIMULATE:
|
case DIGITAL:
|
||||||
sendYtxSocket(param);
|
case SIMULATE:
|
||||||
break;
|
sendYtxSocket(param);
|
||||||
case CONTRAST:
|
break;
|
||||||
break;
|
case CONTRAST:
|
||||||
default:
|
break;
|
||||||
throw new BusinessException(DetectionResponseEnum.PLAN_PATTERN_NOT);
|
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
|
@Override
|
||||||
@@ -149,7 +154,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送源通信校验Socket连接(数字式和模拟式检测模式)
|
* 发送源通信校验Socket连接(数字式和模拟式检测模式)
|
||||||
*
|
*
|
||||||
* <p>该方法用于建立与程控源设备的Socket连接,进行源通信校验。主要流程:</p>
|
* <p>该方法用于建立与程控源设备的Socket连接,进行源通信校验。主要流程:</p>
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>1. 存储检测参数到全局管理器</li>
|
* <li>1. 存储检测参数到全局管理器</li>
|
||||||
@@ -159,18 +164,17 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
* <li>5. 组装Socket请求报文</li>
|
* <li>5. 组装Socket请求报文</li>
|
||||||
* <li>6. 建立Netty客户端连接</li>
|
* <li>6. 建立Netty客户端连接</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @param param 预检测参数,包含计划ID、用户ID等信息
|
* @param param 预检测参数,包含计划ID、用户ID等信息
|
||||||
* @throws BusinessException 当计划源信息不存在或源初始化参数为空时抛出
|
* @throws BusinessException 当计划源信息不存在或源初始化参数为空时抛出
|
||||||
*
|
|
||||||
* @see SourceOperateCodeEnum#YJC_YTXJY 源通信校验操作码
|
* @see SourceOperateCodeEnum#YJC_YTXJY 源通信校验操作码
|
||||||
* @see SourceOperateCodeEnum#INIT_GATHER 初始化采集操作码
|
* @see SourceOperateCodeEnum#INIT_GATHER 初始化采集操作码
|
||||||
*/
|
*/
|
||||||
private void sendYtxSocket(PreDetectionParam param) {
|
private void sendYtxSocket(PreDetectionParam param) {
|
||||||
String loginName = RequestUtil.getLoginNameByToken();
|
|
||||||
WebServiceManager.addPreDetectionParam(loginName, param);
|
|
||||||
AdPlanSource planSource = adPlanSourceService.getOne(new LambdaQueryWrapper<AdPlanSource>().eq(AdPlanSource::getPlanId, param.getPlanId()));
|
AdPlanSource planSource = adPlanSourceService.getOne(new LambdaQueryWrapper<AdPlanSource>().eq(AdPlanSource::getPlanId, param.getPlanId()));
|
||||||
param.setSourceId(planSource.getSourceId());
|
param.setSourceId(planSource.getSourceId());
|
||||||
|
String loginName = RequestUtil.getLoginNameByToken();
|
||||||
|
WebServiceManager.addPreDetectionParam(loginName, param);
|
||||||
if (ObjectUtil.isNotNull(planSource)) {
|
if (ObjectUtil.isNotNull(planSource)) {
|
||||||
//获取源初始化参数
|
//获取源初始化参数
|
||||||
SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(planSource.getSourceId());
|
SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(planSource.getSourceId());
|
||||||
@@ -183,7 +187,6 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
socketMsg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue());
|
socketMsg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue());
|
||||||
socketMsg.setData(JSON.toJSONString(sourceParam));
|
socketMsg.setData(JSON.toJSONString(sourceParam));
|
||||||
//建立与源控程序的socket连接,
|
//建立与源控程序的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));
|
NettyClient.socketClient(ip, port, param, JSON.toJSONString(socketMsg), new NettySourceClientHandler(param, socketSourceResponseService));
|
||||||
} else {
|
} else {
|
||||||
throw new BusinessException(DetectionResponseEnum.SOURCE_INFO_NOT);
|
throw new BusinessException(DetectionResponseEnum.SOURCE_INFO_NOT);
|
||||||
@@ -195,17 +198,16 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送源通信校验Socket连接(仿真模式)
|
* 发送源通信校验Socket连接(仿真模式)
|
||||||
*
|
*
|
||||||
* <p>该方法专门用于仿真检测模式下的源通信校验。与普通模式的区别:</p>
|
* <p>该方法专门用于仿真检测模式下的源通信校验。与普通模式的区别:</p>
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>直接使用传入的sourceId获取源初始化参数</li>
|
* <li>直接使用传入的sourceId获取源初始化参数</li>
|
||||||
* <li>不需要通过计划ID查询计划源信息</li>
|
* <li>不需要通过计划ID查询计划源信息</li>
|
||||||
* <li>适用于独立的源设备通信测试</li>
|
* <li>适用于独立的源设备通信测试</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @param param 预检测参数,必须包含sourceId和userPageId
|
* @param param 预检测参数,必须包含sourceId和userPageId
|
||||||
* @throws BusinessException 当源初始化参数为空时抛出
|
* @throws BusinessException 当源初始化参数为空时抛出
|
||||||
*
|
|
||||||
* @see #sendYtxSocket(PreDetectionParam) 普通检测模式的源通信校验
|
* @see #sendYtxSocket(PreDetectionParam) 普通检测模式的源通信校验
|
||||||
* @see SourceOperateCodeEnum#YJC_YTXJY 源通信校验操作码
|
* @see SourceOperateCodeEnum#YJC_YTXJY 源通信校验操作码
|
||||||
* @see SourceOperateCodeEnum#INIT_GATHER 初始化采集操作码
|
* @see SourceOperateCodeEnum#INIT_GATHER 初始化采集操作码
|
||||||
|
|||||||
@@ -28,29 +28,32 @@ public class DetectionCommunicateUtil {
|
|||||||
Channel channelSource = SocketManager.getChannelByUserId(param.getUserPageId() + DetectionCommunicateConstant.SOURCE);
|
Channel channelSource = SocketManager.getChannelByUserId(param.getUserPageId() + DetectionCommunicateConstant.SOURCE);
|
||||||
Channel channelDev = SocketManager.getChannelByUserId(param.getUserPageId() + DetectionCommunicateConstant.DEV);
|
Channel channelDev = SocketManager.getChannelByUserId(param.getUserPageId() + DetectionCommunicateConstant.DEV);
|
||||||
|
|
||||||
if (Objects.nonNull(channelSource) && channelSource.isActive()) {
|
boolean channelSourceActive = channelSource != null && channelSource.isActive();
|
||||||
System.out.println("发送关闭源指令。。。。。。。。");
|
boolean channelDevActive = channelDev != null && channelDev.isActive();
|
||||||
CnSocketUtil.quitSendSource(param);
|
if(channelSourceActive || channelDevActive){
|
||||||
}
|
if(channelSourceActive){
|
||||||
if (Objects.nonNull(channelDev) && channelDev.isActive()) {
|
System.out.println("发送关闭源指令。。。。。。。。");
|
||||||
System.out.println("发送关闭设备通讯指令。。。。。。。。");
|
CnSocketUtil.quitSendSource(param);
|
||||||
CnSocketUtil.quitSend(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 {
|
// SocketManager.removeUser(param.getUserPageId() + DetectionCommunicateConstant.SOURCE);
|
||||||
Thread.sleep(2000);
|
// SocketManager.removeUser(param.getUserPageId() + DetectionCommunicateConstant.DEV);
|
||||||
} catch (InterruptedException e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||||
import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
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;
|
import com.njcn.gather.detection.util.socket.websocket.WebServiceManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -35,6 +34,7 @@ public class CnSocketUtil {
|
|||||||
socketMsg.setRequestId(SourceOperateCodeEnum.QUITE.getValue());
|
socketMsg.setRequestId(SourceOperateCodeEnum.QUITE.getValue());
|
||||||
socketMsg.setOperateCode(SourceOperateCodeEnum.QUIT_INIT_03.getValue());
|
socketMsg.setOperateCode(SourceOperateCodeEnum.QUIT_INIT_03.getValue());
|
||||||
SocketManager.sendMsg(param.getUserPageId() + DEV_TAG, JSON.toJSONString(socketMsg));
|
SocketManager.sendMsg(param.getUserPageId() + DEV_TAG, JSON.toJSONString(socketMsg));
|
||||||
|
|
||||||
WebServiceManager.removePreDetectionParam();
|
WebServiceManager.removePreDetectionParam();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,29 +52,6 @@ public class CnSocketUtil {
|
|||||||
WebServiceManager.removePreDetectionParam();
|
WebServiceManager.removePreDetectionParam();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 推送webSocket数据
|
|
||||||
*/
|
|
||||||
public static void sendToWebSocket(String userId, String requestId, String operatorType, Object data, String desc) {
|
|
||||||
WebSocketVO<Object> 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<Object> 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ public class NettyClient {
|
|||||||
.addLast(handler);
|
.addLast(handler);
|
||||||
} else {
|
} else {
|
||||||
ch.pipeline()
|
ch.pipeline()
|
||||||
|
|
||||||
// 添加LineBasedFrameDecoder来按行分割数据
|
// 添加LineBasedFrameDecoder来按行分割数据
|
||||||
.addLast(new LineBasedFrameDecoder(10240))
|
.addLast(new LineBasedFrameDecoder(10240))
|
||||||
.addLast(new StringDecoder(CharsetUtil.UTF_8))
|
.addLast(new StringDecoder(CharsetUtil.UTF_8))
|
||||||
|
|||||||
@@ -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.pojo.param.PreDetectionParam;
|
||||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
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 com.njcn.gather.plan.pojo.enums.DataSourceEnum;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
@@ -155,7 +156,7 @@ public class NettyContrastClientHandler extends SimpleChannelInboundHandler<Stri
|
|||||||
System.out.println("连接socket服务端异常");
|
System.out.println("连接socket服务端异常");
|
||||||
} else if (cause instanceof IOException) {
|
} else if (cause instanceof IOException) {
|
||||||
System.out.println("IOException caught: There was an I/O error.");
|
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);
|
||||||
} else if (cause instanceof TimeoutException) {
|
} else if (cause instanceof TimeoutException) {
|
||||||
System.out.println("TimeoutException caught: Operation timed out.");
|
System.out.println("TimeoutException caught: Operation timed out.");
|
||||||
} else if (cause instanceof ProtocolException) {
|
} else if (cause instanceof ProtocolException) {
|
||||||
@@ -163,7 +164,7 @@ public class NettyContrastClientHandler extends SimpleChannelInboundHandler<Stri
|
|||||||
} else {
|
} else {
|
||||||
// 处理其他类型的异常
|
// 处理其他类型的异常
|
||||||
System.out.println("Unknown exception caught: " + cause.getMessage());
|
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);
|
CnSocketUtil.quitSend(param);
|
||||||
// socketContrastResponseService.backCheckState(param);
|
// socketContrastResponseService.backCheckState(param);
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
|||||||
fly = true;
|
fly = true;
|
||||||
//为空则认为是常规步骤,设定一分钟超时
|
//为空则认为是常规步骤,设定一分钟超时
|
||||||
CnSocketUtil.quitSend(param);
|
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) {
|
if (fly) {
|
||||||
socketResponseService.backCheckState(param);
|
socketResponseService.backCheckState(param);
|
||||||
@@ -152,7 +152,7 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
|||||||
System.out.println("当前进入暂停操作超时函数-----------------" + FormalTestManager.stopTime);
|
System.out.println("当前进入暂停操作超时函数-----------------" + FormalTestManager.stopTime);
|
||||||
if (FormalTestManager.stopTime > 600) {
|
if (FormalTestManager.stopTime > 600) {
|
||||||
CnSocketUtil.quitSend(param);
|
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<String> {
|
|||||||
} else if (cause instanceof IOException) {
|
} else if (cause instanceof IOException) {
|
||||||
// 处理I/O异常,例如读写错误
|
// 处理I/O异常,例如读写错误
|
||||||
System.out.println("IOException caught: There was an I/O error.");
|
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错误信息
|
// 例如,可以记录更详细的I/O错误信息
|
||||||
} else if (cause instanceof TimeoutException) {
|
} else if (cause instanceof TimeoutException) {
|
||||||
@@ -195,7 +195,7 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
|||||||
} else {
|
} else {
|
||||||
// 处理其他类型的异常
|
// 处理其他类型的异常
|
||||||
System.out.println("Unknown exception caught: " + cause.getMessage());
|
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);
|
CnSocketUtil.quitSend(param);
|
||||||
|
|||||||
@@ -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.pojo.param.PreDetectionParam;
|
||||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
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.ChannelHandlerContext;
|
||||||
import io.netty.channel.SimpleChannelInboundHandler;
|
import io.netty.channel.SimpleChannelInboundHandler;
|
||||||
import io.netty.handler.timeout.IdleState;
|
import io.netty.handler.timeout.IdleState;
|
||||||
@@ -118,7 +119,7 @@ public class NettySourceClientHandler extends SimpleChannelInboundHandler<String
|
|||||||
|
|
||||||
} else if (cause instanceof IOException) {
|
} else if (cause instanceof IOException) {
|
||||||
// 处理I/O异常,例如读写错误
|
// 处理I/O异常,例如读写错误
|
||||||
CnSocketUtil.sendToWebSocket(webUser.getUserPageId(), SourceOperateCodeEnum.SERVER_ERROR.getValue(), SourceOperateCodeEnum.SERVER_ERROR.getValue(), SourceOperateCodeEnum.SERVER_ERROR.getMsg(), null);
|
WebServiceManager.sendDetectionErrorMessage(webUser.getUserPageId(), SourceOperateCodeEnum.SERVER_ERROR);
|
||||||
|
|
||||||
// 例如,可以记录更详细的I/O错误信息
|
// 例如,可以记录更详细的I/O错误信息
|
||||||
} else if (cause instanceof TimeoutException) {
|
} else if (cause instanceof TimeoutException) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.njcn.gather.detection.util.socket.websocket;
|
|||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||||
import com.njcn.gather.detection.pojo.vo.WebSocketVO;
|
import com.njcn.gather.detection.pojo.vo.WebSocketVO;
|
||||||
|
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
|
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -257,5 +258,58 @@ public class WebServiceManager {
|
|||||||
public static java.util.Set<String> getOnlineUserIds() {
|
public static java.util.Set<String> getOnlineUserIds() {
|
||||||
return new java.util.HashSet<>(userSessions.keySet());
|
return new java.util.HashSet<>(userSessions.keySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ================================ 检测消息推送方法 ================================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送检测相关消息给指定用户
|
||||||
|
* <p>用于推送检测状态、进度、结果等结构化消息</p>
|
||||||
|
*
|
||||||
|
* @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<Object> webSocketVO = new WebSocketVO<>();
|
||||||
|
webSocketVO.setRequestId(requestId);
|
||||||
|
webSocketVO.setOperateCode(operateCode);
|
||||||
|
webSocketVO.setData(data);
|
||||||
|
webSocketVO.setDesc(desc);
|
||||||
|
sendMessage(userId, webSocketVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送未知错误消息给指定用户
|
||||||
|
* <p>用于处理系统无法识别的操作或未知异常情况</p>
|
||||||
|
*
|
||||||
|
* @param userId 目标用户ID
|
||||||
|
* @since v2.3.12 重构版本
|
||||||
|
*/
|
||||||
|
public static void sendUnknownErrorMessage(String userId) {
|
||||||
|
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
||||||
|
webSocketVO.setRequestId(SourceOperateCodeEnum.UNKNOWN_OPERATE.getValue());
|
||||||
|
webSocketVO.setData(SourceOperateCodeEnum.UNKNOWN_OPERATE.getMsg());
|
||||||
|
webSocketVO.setOperateCode(SourceOperateCodeEnum.UNKNOWN_OPERATE.getMsg());
|
||||||
|
sendMessage(userId, webSocketVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送检测错误消息给指定用户
|
||||||
|
* <p>用于推送特定类型的检测错误信息</p>
|
||||||
|
*
|
||||||
|
* @param userId 目标用户ID
|
||||||
|
* @param errorType 错误类型枚举
|
||||||
|
* @since v2.3.12 重构版本
|
||||||
|
*/
|
||||||
|
public static void sendDetectionErrorMessage(String userId, SourceOperateCodeEnum errorType) {
|
||||||
|
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
||||||
|
webSocketVO.setRequestId(errorType.getValue());
|
||||||
|
webSocketVO.setData(errorType.getMsg());
|
||||||
|
webSocketVO.setOperateCode(errorType.getValue());
|
||||||
|
sendMessage(userId, webSocketVO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,10 +49,10 @@ phaseAngle:
|
|||||||
|
|
||||||
socket:
|
socket:
|
||||||
source:
|
source:
|
||||||
ip: 127.0.0.1
|
ip: 192.168.1.124
|
||||||
port: 62000
|
port: 62000
|
||||||
device:
|
device:
|
||||||
ip: 127.0.0.1
|
ip: 192.168.1.124
|
||||||
port: 61000
|
port: 61000
|
||||||
# source:
|
# source:
|
||||||
# ip: 192.168.1.121
|
# ip: 192.168.1.121
|
||||||
|
|||||||
Reference in New Issue
Block a user