程控源功能

This commit is contained in:
caozehui
2025-03-07 09:16:18 +08:00
parent 1d7440b4f7
commit 08be6c15fb
9 changed files with 314 additions and 57 deletions

View File

@@ -7,19 +7,15 @@ import com.njcn.common.pojo.response.HttpResult;
import com.njcn.gather.detection.handler.SocketDevResponseService; import com.njcn.gather.detection.handler.SocketDevResponseService;
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.param.SimulateDetectionParam;
import com.njcn.gather.detection.pojo.vo.SocketMsg; import com.njcn.gather.detection.pojo.vo.SocketMsg;
import com.njcn.gather.detection.service.PreDetectionService; import com.njcn.gather.detection.service.PreDetectionService;
import com.njcn.gather.detection.service.impl.DetectionServiceImpl; import com.njcn.gather.detection.service.impl.DetectionServiceImpl;
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.XiNumberManager;
import com.njcn.gather.detection.util.socket.cilent.NettyClient; import com.njcn.gather.detection.util.socket.cilent.NettyClient;
import com.njcn.gather.detection.util.socket.cilent.NettyDevClientHandler; import com.njcn.gather.detection.util.socket.cilent.NettyDevClientHandler;
import com.njcn.gather.detection.util.socket.cilent.NettySourceClientHandler;
import com.njcn.gather.device.pojo.vo.PreDetection; import com.njcn.gather.device.pojo.vo.PreDetection;
import com.njcn.gather.device.service.IPqDevService; import com.njcn.gather.device.service.IPqDevService;
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
import com.njcn.gather.script.pojo.po.SourceIssue;
import com.njcn.gather.script.service.IPqScriptDtlsService; import com.njcn.gather.script.service.IPqScriptDtlsService;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
import com.njcn.web.utils.HttpResultUtil; import com.njcn.web.utils.HttpResultUtil;
@@ -54,9 +50,6 @@ public class PreDetectionController extends BaseController {
private final SocketDevResponseService socketDevResponseService; private final SocketDevResponseService socketDevResponseService;
/** /**
* 开始检测 * 开始检测
*/ */
@@ -70,6 +63,42 @@ public class PreDetectionController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} }
@PostMapping("/ytxCheckSimulate")
@OperateInfo
@ApiOperation("模拟检测-通讯校验")
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
public HttpResult<String> ytxCheckSimulate(@RequestBody @Validated SimulateDetectionParam param) {
String methodDescribe = getMethodDescribe("ytxCheckSimulate");
preDetectionService.ytxCheckSimulate(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
/**
* 模拟检测
*/
@PostMapping("/startSimulateTest")
@OperateInfo
@ApiOperation("模拟检测")
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
public HttpResult<String> startTestSimulate(@RequestBody @Validated SimulateDetectionParam param) {
String methodDescribe = getMethodDescribe("startTestSimulate");
preDetectionService.sendScript(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
/**
* 关闭检测
*/
@PostMapping("/closeSimulateTest")
@OperateInfo
@ApiOperation("停止模拟检测")
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
public HttpResult<String> closeSimulateTest(@RequestBody @Validated SimulateDetectionParam param) {
String methodDescribe = getMethodDescribe("closeSimulateTest");
preDetectionService.closeTestSimulate(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
/** /**
* 关闭检测 * 关闭检测
*/ */
@@ -138,7 +167,6 @@ public class PreDetectionController extends BaseController {
} }
/** /**
* 测试 * 测试
*/ */
@@ -151,8 +179,6 @@ public class PreDetectionController extends BaseController {
//preDetectionService.startTest(param); //preDetectionService.startTest(param);
List<PreDetection> pqDevList = iPqDevService.getDevInfo(param.getDevIds()); List<PreDetection> pqDevList = iPqDevService.getDevInfo(param.getDevIds());
XiNumberManager.xiDevList = pqDevList; XiNumberManager.xiDevList = pqDevList;
String s = param.getUserPageId() + "_Dev"; String s = param.getUserPageId() + "_Dev";
@@ -172,5 +198,4 @@ public class PreDetectionController extends BaseController {
} }
} }

View File

@@ -61,7 +61,11 @@ public class SocketSourceResponseService {
switch (enumByCode) { switch (enumByCode) {
//源初始化 //源初始化
case YJC_YTXJY: case YJC_YTXJY:
if (ObjectUtil.isNotNull(param.getPlanId())) {
detectionDev(param, socketDataMsg); detectionDev(param, socketDataMsg);
} else {
System.out.println("模拟检测-源初始化成功");
}
break; break;
//相序检测 //相序检测
case YJC_XUJY: case YJC_XUJY:
@@ -69,7 +73,11 @@ public class SocketSourceResponseService {
break; break;
//正式检测 //正式检测
case FORMAL_REAL: case FORMAL_REAL:
if (ObjectUtil.isNotNull(param.getPlanId())) {
senParamToDev(param, socketDataMsg); senParamToDev(param, socketDataMsg);
} else {
handleSimulateTest(param, socketDataMsg);
}
break; break;
//系数校验 //系数校验
case Coefficient_Check: case Coefficient_Check:
@@ -84,8 +92,34 @@ public class SocketSourceResponseService {
} else { } else {
System.out.println("fggggggggggggggggggggg" + enumByCode); System.out.println("fggggggggggggggggggggg" + enumByCode);
} }
}
/**
* 处理模拟检测时,通信模块返回报文
*
* @param param
* @param socketDataMsg
*/
private void handleSimulateTest(PreDetectionParam param, SocketDataMsg socketDataMsg) {
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
if (ObjectUtil.isNotNull(dictDataEnumByCode)) {
switch (dictDataEnumByCode) {
case SUCCESS:
System.out.println("模拟检测-源成功执行脚本");
break;
case UNPROCESSED_BUSINESS:
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
default:
CnSocketUtil.quitSendSource(param);
SocketMsg<String> socketMsg = new SocketMsg<>();
socketMsg.setRequestId(socketDataMsg.getRequestId());
socketMsg.setOperateCode(socketDataMsg.getOperateCode());
socketMsg.setData(dictDataEnumByCode.getMessage());
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketMsg));
break;
}
}
} }

View File

@@ -47,6 +47,7 @@ public enum SourceOperateCodeEnum {
YJC_XYJY("yjc_xyjy", "协议校验"), YJC_XYJY("yjc_xyjy", "协议校验"),
YJC_XUJY("YJC_xujy", "相序校验"), YJC_XUJY("YJC_xujy", "相序校验"),
FORMAL_REAL("formal_real","正式检测"), FORMAL_REAL("formal_real","正式检测"),
// SIMULATE_REAL("simulate_real","模拟检测"),
Coefficient_Check("Coefficient_Check","系数校验"), Coefficient_Check("Coefficient_Check","系数校验"),
QUITE("quit","关闭设备通讯初始化"), QUITE("quit","关闭设备通讯初始化"),
QUITE_SOURCE("close_source","关闭源通讯"), QUITE_SOURCE("close_source","关闭源通讯"),
@@ -74,6 +75,7 @@ public enum SourceOperateCodeEnum {
TEST_TEM_START("6","继续检测"), TEST_TEM_START("6","继续检测"),
TEST_STOP("7","停止检测"), TEST_STOP("7","停止检测"),
RE_ERROR_TEST("8","不合格项复检"), RE_ERROR_TEST("8","不合格项复检"),
SIMULATE_TEST("9","模拟检测"),
/** /**

View File

@@ -0,0 +1,40 @@
package com.njcn.gather.detection.pojo.param;
import lombok.Data;
/**
* @author caozehui
* @data 2025-03-06
*/
@Data
public class SimulateDetectionParam {
/**
* 操作类型 9.模拟检测
*/
private String operateType = "9";
/**
* 数字、模拟、比对
*/
private String pattern;
/**
* 用户功能组成唯一标识 zhangsan_test
*/
private String userPageId;
/**
* 检测脚本Id
*/
private String scriptId;
private Integer scriptIndex;
/**
* 源id
*/
private String sourceId;
}

View File

@@ -1,7 +1,7 @@
package com.njcn.gather.detection.service; package com.njcn.gather.detection.service;
import com.njcn.gather.detection.pojo.param.PreDetectionParam; import com.njcn.gather.detection.pojo.param.PreDetectionParam;
import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
/** /**
@@ -13,6 +13,7 @@ public interface PreDetectionService {
/** /**
* 源通讯校验socket入参拼接 * 源通讯校验socket入参拼接
*
* @param param * @param param
* @Author: wr * @Author: wr
* @Date: 2024/12/11 13:26 * @Date: 2024/12/11 13:26
@@ -35,4 +36,24 @@ public interface PreDetectionService {
void nextScript(PreDetectionParam param); void nextScript(PreDetectionParam param);
/**
* 模拟测试-源通讯校验
*
* @param param
*/
void ytxCheckSimulate(SimulateDetectionParam param);
/**
* 模拟测试-向源发送脚本
*
* @param param
*/
void sendScript(SimulateDetectionParam param);
/**
* 模拟测试-停止
*
* @param param
*/
void closeTestSimulate(SimulateDetectionParam param);
} }

View File

@@ -11,29 +11,28 @@ import com.njcn.gather.detection.handler.SocketSourceResponseService;
import com.njcn.gather.detection.pojo.enums.DetectionResponseEnum; import com.njcn.gather.detection.pojo.enums.DetectionResponseEnum;
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.param.SimulateDetectionParam;
import com.njcn.gather.detection.pojo.vo.SocketMsg; import com.njcn.gather.detection.pojo.vo.SocketMsg;
import com.njcn.gather.detection.service.PreDetectionService; import com.njcn.gather.detection.service.PreDetectionService;
import com.njcn.gather.detection.util.socket.CnSocketUtil; import com.njcn.gather.detection.util.socket.CnSocketUtil;
import com.njcn.gather.detection.util.socket.FormalTestManager; import com.njcn.gather.detection.util.socket.FormalTestManager;
import com.njcn.gather.detection.util.socket.SocketManager; import com.njcn.gather.detection.util.socket.SocketManager;
import com.njcn.gather.detection.util.socket.WebServiceManager;
import com.njcn.gather.detection.util.socket.cilent.NettyClient; import com.njcn.gather.detection.util.socket.cilent.NettyClient;
import com.njcn.gather.detection.util.socket.cilent.NettyDevClientHandler;
import com.njcn.gather.detection.util.socket.cilent.NettySourceClientHandler; import com.njcn.gather.detection.util.socket.cilent.NettySourceClientHandler;
import com.njcn.gather.device.pojo.enums.DevResponseEnum;
import com.njcn.gather.device.pojo.po.PqDev; import com.njcn.gather.device.pojo.po.PqDev;
import com.njcn.gather.device.pojo.vo.PreDetection;
import com.njcn.gather.device.service.IPqDevService; import com.njcn.gather.device.service.IPqDevService;
import com.njcn.gather.plan.pojo.po.AdPlan;
import com.njcn.gather.plan.pojo.po.AdPlanSource;
import com.njcn.gather.plan.service.IAdPlanService;
import com.njcn.gather.plan.service.IAdPlanSourceService;
import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam; import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam;
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
import com.njcn.gather.script.pojo.po.SourceIssue; import com.njcn.gather.script.pojo.po.SourceIssue;
import com.njcn.gather.script.service.IPqScriptCheckDataService; import com.njcn.gather.script.service.IPqScriptCheckDataService;
import com.njcn.gather.script.service.IPqScriptDtlsService; import com.njcn.gather.script.service.IPqScriptDtlsService;
import com.njcn.gather.source.pojo.po.SourceInitialize; import com.njcn.gather.source.pojo.po.SourceInitialize;
import com.njcn.gather.source.service.IPqSourceService; import com.njcn.gather.source.service.IPqSourceService;
import com.njcn.gather.plan.pojo.po.AdPlan;
import com.njcn.gather.plan.pojo.po.AdPlanSource;
import com.njcn.gather.plan.service.IAdPlanService;
import com.njcn.gather.plan.service.IAdPlanSourceService;
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum; import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
import com.njcn.gather.system.dictionary.service.IDictDataService; import com.njcn.gather.system.dictionary.service.IDictDataService;
import io.netty.channel.Channel; import io.netty.channel.Channel;
@@ -42,7 +41,10 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -53,6 +55,8 @@ public class PreDetectionServiceImpl implements PreDetectionService {
private final String source = "_Source"; private final String source = "_Source";
private final String dev = "_Dev"; private final String dev = "_Dev";
private final String stepTag = "&&";
private final String handlerSourceStr = "_Source";
private final IPqDevService iPqDevService; private final IPqDevService iPqDevService;
private final IDictDataService dictDataService; private final IDictDataService dictDataService;
@@ -154,6 +158,30 @@ public class PreDetectionServiceImpl implements PreDetectionService {
} }
} }
private void sendYtxSocketSimulate(PreDetectionParam param) {
//AdPlan plan = iAdPlanService.getById(param.getPlanId());
//AdPlanSource planSource = adPlanSourceService.getOne(new LambdaQueryWrapper<AdPlanSource>().eq(AdPlanSource::getPlanId, param.getPlanId()));
//param.setSourceId(planSource.getSourceId());
//param.setScriptId(plan.getScriptId());
//param.setErrorSysId(plan.getErrorSysId());
//param.setCode(String.valueOf(plan.getCode()));
SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(param.getSourceId());
param.setSourceId(sourceParam.getSourceId());
WebServiceManager.addPreDetectionParam(param);
if (ObjectUtil.isNotNull(sourceParam)) {
//开始组装socket报文请求头
//socketDevResponseService.initList(param);
//socketSourceResponseService.initList(param);
SocketMsg<String> socketMsg = new SocketMsg<>();
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
socketMsg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue());
socketMsg.setData(JSON.toJSONString(sourceParam));
NettyClient.socketClient(ip, port, param, JSON.toJSONString(socketMsg), new NettySourceClientHandler(param, sourceResponseService));
} else {
throw new BusinessException(DetectionResponseEnum.SOURCE_INFO_NOT);
}
}
@Override @Override
public boolean startTest(PreDetectionParam param) { public boolean startTest(PreDetectionParam param) {
@@ -229,8 +257,78 @@ public class PreDetectionServiceImpl implements PreDetectionService {
} }
@Override
public void ytxCheckSimulate(SimulateDetectionParam param) {
PreDetectionParam preDetectionParam = new PreDetectionParam();
preDetectionParam.setSourceId(param.getSourceId());
preDetectionParam.setUserPageId(param.getUserPageId());
specialDealSimulate(preDetectionParam);
// String code = dictDataService.getDictDataById(param.getPattern()).getCode();
// DictDataEnum dictDataEnumByCode = DictDataEnum.getDictDataEnumByCode(code);
// switch (dictDataEnumByCode) {
// case DIGITAL:
// case SIMULATE:
// sendYtxSocketSimulate(preDetectionParam);
// break;
// case CONTRAST:
// break;
// default:
// throw new BusinessException(DetectionResponseEnum.PLAN_PATTERN_NOT);
// }
sendYtxSocketSimulate(preDetectionParam);
}
@Override
public void sendScript(SimulateDetectionParam param) {
// Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + source);
// if (Objects.isNull(channel) || !channel.isActive()) {
// // 进行源通信连接
// PreDetectionParam preDetectionParam = new PreDetectionParam();
// preDetectionParam.setSourceId(param.getSourceId());
// preDetectionParam.setUserPageId(param.getUserPageId());
// this.sendYtxSocketSimulate(preDetectionParam);
// }
//组装源控制脚本
PqScriptIssueParam issueParam = new PqScriptIssueParam();
//issueParam.setPlanId(param.getPlanId());
issueParam.setSourceId(param.getSourceId());
//issueParam.setDevIds(param.getDevIds());
issueParam.setScriptId(param.getScriptId());
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.SIMULATE_TEST.getValue());
List<SourceIssue> sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
sourceIssues = sourceIssues.stream()
.filter(s -> s.getIndex().equals(param.getScriptIndex()))
.sorted(Comparator.comparing(SourceIssue::getIndex))
.collect(Collectors.toList());
SourceIssue sourceIssue = sourceIssues.get(0);
List<String> comm = sourceIssue.getDevValueTypeList();
System.out.println("向装置下发的参数ddd>>>>>>>>" + comm);
SocketMsg<String> socketMsg = new SocketMsg<>();
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + stepTag + sourceIssue.getType());
socketMsg.setData(JSON.toJSONString(sourceIssues.get(0)));
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(socketMsg));
}
@Override
public void closeTestSimulate(SimulateDetectionParam param) {
SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(param.getSourceId());
PreDetectionParam preDetectionParam = new PreDetectionParam();
preDetectionParam.setSourceId(sourceParam.getSourceId());
preDetectionParam.setUserPageId(param.getUserPageId());
CnSocketUtil.quitSendSource(preDetectionParam);
WebServiceManager.removePreDetectionParam();
SocketManager.removeUser(param.getUserPageId() + source);
}
/** /**
* 对重复发起或者异常发起的检测进行关闭源操作 * 对重复发起或者异常发起的检测进行关闭源操作
*
* @param param * @param param
*/ */
private void specialDeal(PreDetectionParam param) { private void specialDeal(PreDetectionParam param) {
@@ -261,6 +359,30 @@ public class PreDetectionServiceImpl implements PreDetectionService {
} }
} }
/**
* 对重复发起或者异常发起的检测进行关闭源操作-模拟检测
*
* @param param
*/
private void specialDealSimulate(PreDetectionParam param) {
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + source);
if (Objects.nonNull(channel) && channel.isActive()) {
System.out.println("发送关闭源指令。。。。。。。。");
CnSocketUtil.quitSendSource(param);
}
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
log.error(e.getMessage());
}
SocketManager.removeUser(param.getUserPageId() + source);
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
log.error(e.getMessage());
}
}
/** /**
* 校验 * 校验

View File

@@ -1,6 +1,7 @@
package com.njcn.gather.detection.util.socket; package com.njcn.gather.detection.util.socket;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
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 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;
@@ -24,6 +25,8 @@ public class WebServiceManager {
//key:页面 value:channel //key:页面 value:channel
private static final Map<String, Channel> userSessions = new ConcurrentHashMap<>(); private static final Map<String, Channel> userSessions = new ConcurrentHashMap<>();
// 检测参数。key固定为preDetectionParam, value:检测参数
private static final Map<String, PreDetectionParam> preDetectionParamMap = new ConcurrentHashMap<>();
public static void addUser(String userId, Channel channel) { public static void addUser(String userId, Channel channel) {
userSessions.put(userId, channel); userSessions.put(userId, channel);
@@ -66,5 +69,15 @@ public class WebServiceManager {
} }
} }
public static void addPreDetectionParam(PreDetectionParam preDetectionParam) {
preDetectionParamMap.put("preDetectionParam", preDetectionParam);
}
public static PreDetectionParam getPreDetectionParam() {
return preDetectionParamMap.get("preDetectionParam");
}
public static void removePreDetectionParam() {
preDetectionParamMap.clear();
}
} }

View File

@@ -1,21 +1,15 @@
package com.njcn.gather.detection.util.socket.web; package com.njcn.gather.detection.util.socket.web;
import cn.hutool.core.util.ObjectUtil;
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.WebServiceManager; import com.njcn.gather.detection.util.socket.WebServiceManager;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler; import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.codec.http.FullHttpRequest; import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import io.netty.handler.timeout.IdleStateEvent; import io.netty.handler.timeout.IdleStateEvent;
import io.netty.util.CharsetUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
/** /**
@@ -73,6 +67,7 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<TextWebSocketF
/** /**
* 根据用户地址获取用户名 ws://127.0.0.1:7777/hello?name=aa * 根据用户地址获取用户名 ws://127.0.0.1:7777/hello?name=aa
*
* @param url * @param url
* @return * @return
*/ */
@@ -124,9 +119,14 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<TextWebSocketF
System.out.println("weoSocket断线" + ctx.channel().id()); System.out.println("weoSocket断线" + ctx.channel().id());
ctx.close(); ctx.close();
PreDetectionParam param = new PreDetectionParam(); PreDetectionParam preDetectionParam = WebServiceManager.getPreDetectionParam();
param.setUserPageId("cdf"); if (ObjectUtil.isNotNull(preDetectionParam)) {
CnSocketUtil.quitSend(param); CnSocketUtil.quitSendSource(preDetectionParam); // 能否在这里关闭源socket连接
} else {
preDetectionParam = new PreDetectionParam();
preDetectionParam.setUserPageId("cdf");
CnSocketUtil.quitSend(preDetectionParam);
}
} }

View File

@@ -133,7 +133,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
if (devFly) { if (devFly) {
//校验终端额定电压电流是否相同 //校验终端额定电压电流是否相同
List<PqDev> list = pqDevService.list(new LambdaQueryWrapper<PqDev>() List<PqDev> list = pqDevService.list(new LambdaQueryWrapper<PqDev>()
.eq(PqDev::getPlanId, param.getPlanId()) .eq(StrUtil.isNotBlank(param.getPlanId()), PqDev::getPlanId, param.getPlanId())
.in(PqDev::getId, param.getDevIds()) .in(PqDev::getId, param.getDevIds())
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode()) .eq(PqDev::getState, DataStateEnum.ENABLE.getCode())
); );