1.微调相序校验
This commit is contained in:
@@ -235,7 +235,7 @@ public class SocketDevResponseService {
|
||||
System.out.println("开始相序校验++++++++++");
|
||||
PqScriptIssueParam issueParam=new PqScriptIssueParam();
|
||||
issueParam.setPlanId(param.getPlanId());
|
||||
issueParam.setSourceId(param.getScriptId());
|
||||
issueParam.setSourceId(param.getSourceId());
|
||||
issueParam.setIsPhaseSequence(true);
|
||||
issueParam.setDevIds(param.getDevIds());
|
||||
List<SourceIssue> sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
|
||||
@@ -300,6 +300,7 @@ public class SocketDevResponseService {
|
||||
sourceParam.setPlanId(param.getPlanId());
|
||||
sourceParam.setDevIds(param.getDevIds());
|
||||
sourceParam.setIsPhaseSequence(true);
|
||||
sourceParam.setSourceId(param.getSourceId());
|
||||
List<SourceIssue> sourceIssues = scriptDtlsService.listSourceIssue(sourceParam);
|
||||
List<SourceCompareDev> info = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(sourceIssues)) {
|
||||
@@ -308,6 +309,15 @@ public class SocketDevResponseService {
|
||||
}
|
||||
}
|
||||
xuClear();
|
||||
String s = param.getUserPageId() + "_Source";
|
||||
SocketMsg msg= new SocketMsg();
|
||||
msg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
|
||||
msg.setOperateCode(SourceOperateCodeEnum.CLOSE_GATHER.getValue());
|
||||
Map<String,String> map=new HashMap<>(1);
|
||||
map.put("sourceId",sourceIssues.get(0).getSourceId());
|
||||
msg.setData(JSON.toJSONString(map));
|
||||
SocketManager.sendMsg(s, JSON.toJSONString(msg));
|
||||
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_XUJY.getValue());
|
||||
socketMsg.setOperateCode(socketDataMsg.getOperateCode());
|
||||
socketMsg.setData(JSON.toJSONString(info));
|
||||
|
||||
@@ -133,7 +133,7 @@ public class SocketSourceResponseService {
|
||||
phaseSequenceParam.setMoniterIdList(moniterIdList);
|
||||
phaseSequenceParam.setDataType(Arrays.asList("实时数据/电压有效值","实时数据/电流有效值"));
|
||||
phaseSequenceParam.setReadCount(1);
|
||||
phaseSequenceParam.setIgnoreCount(1);
|
||||
phaseSequenceParam.setIgnoreCount(10);
|
||||
socketMsg.setData(JSON.toJSONString(phaseSequenceParam));
|
||||
SocketManager.sendMsg(s,JSON.toJSONString(socketMsg));
|
||||
break;
|
||||
|
||||
@@ -32,4 +32,8 @@ public class PreDetectionParam {
|
||||
*/
|
||||
private String scriptId;
|
||||
|
||||
/**
|
||||
* 检测脚本Id
|
||||
*/
|
||||
private String sourceId;
|
||||
}
|
||||
|
||||
@@ -103,20 +103,6 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
socketDevResponseService.initList(param);
|
||||
if(channel==null || !channel.isActive()){
|
||||
NettyClient.socketClient(ip, port, param.getUserPageId(), new NettySourceClientHandler(param, sourceResponseService));
|
||||
}else{
|
||||
//关闭源
|
||||
msg= new SocketMsg();
|
||||
msg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
|
||||
msg.setOperateCode(SourceOperateCodeEnum.CLOSE_GATHER.getValue());
|
||||
Map<String,String> map=new HashMap<>(1);
|
||||
map.put("sourceId",sourceParam.getSourceId());
|
||||
msg.setData(JSON.toJSONString(map));
|
||||
SocketManager.sendMsg(s, JSON.toJSONString(msg));
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
msg= new SocketMsg();
|
||||
msg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
|
||||
|
||||
@@ -39,7 +39,7 @@ import java.util.concurrent.TimeUnit;
|
||||
@Getter
|
||||
public class NettyClient {
|
||||
|
||||
public static void socketClient(String ip, Integer port,String userPageId,SimpleChannelInboundHandler<String> handler) {
|
||||
public static void socketClient(String ip, Integer port, String userPageId, SimpleChannelInboundHandler<String> handler) {
|
||||
NioEventLoopGroup group = new NioEventLoopGroup();
|
||||
Bootstrap bootstrap = new Bootstrap();
|
||||
try {
|
||||
@@ -48,16 +48,16 @@ public class NettyClient {
|
||||
.handler(new ChannelInitializer<NioSocketChannel>() {
|
||||
@Override
|
||||
protected void initChannel(NioSocketChannel ch) {
|
||||
if(handler instanceof NettySourceClientHandler){
|
||||
if (handler instanceof NettySourceClientHandler) {
|
||||
ch.pipeline()
|
||||
//空闲状态的handler
|
||||
// 添加LineBasedFrameDecoder来按行分割数据
|
||||
// .addLast(new LineBasedFrameDecoder(10240))
|
||||
.addLast(new IdleStateHandler(0, 5, 0, TimeUnit.SECONDS))
|
||||
.addLast(new IdleStateHandler(20, 0, 0, TimeUnit.SECONDS))
|
||||
.addLast(new StringDecoder(CharsetUtil.UTF_8))
|
||||
.addLast(new StringEncoder(CharsetUtil.UTF_8))
|
||||
.addLast(handler);
|
||||
}else{
|
||||
} else {
|
||||
ch.pipeline()
|
||||
//空闲状态的handler
|
||||
// 添加LineBasedFrameDecoder来按行分割数据
|
||||
@@ -78,14 +78,14 @@ public class NettyClient {
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
System.out.println("连接socker服务端发送异常............"+e.getMessage());
|
||||
System.out.println("连接socker服务端发送异常............" + e.getMessage());
|
||||
group.shutdownGracefully();
|
||||
//TODO 通知页面
|
||||
WebSocketVO webSocketVO = new WebSocketVO();
|
||||
webSocketVO.setCode(SourceResponseCodeEnum.SOCKET_ERROR.getCode());
|
||||
webSocketVO.setMessage(SourceResponseCodeEnum.SOCKET_ERROR.getMessage());
|
||||
WebServiceManager.sendMsg(userPageId, JSON.toJSONString(webSocketVO));
|
||||
}finally {
|
||||
} finally {
|
||||
// System.out.println("进入clientSocket最后步骤---------------------");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class NettySourceClientHandler extends SimpleChannelInboundHandler<Strin
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
|
||||
//如果是空闲状态事件
|
||||
if (evt instanceof IdleStateEvent) {
|
||||
if (((IdleStateEvent) evt).state() == IdleState.WRITER_IDLE) {
|
||||
if (((IdleStateEvent) evt).state() == IdleState.READER_IDLE) {
|
||||
//发送ping 保持心跳链接
|
||||
SocketMsg msg=new SocketMsg();
|
||||
msg.setRequestId("yxt");
|
||||
|
||||
Reference in New Issue
Block a user