1.微调
This commit is contained in:
@@ -17,6 +17,7 @@ public enum SourceOperateCodeEnum {
|
||||
INIT_GATHER("INIT_GATHER", "源初始化"),
|
||||
OPER_GATHER("OPER_GATHER", "源输出"),
|
||||
CLOSE_GATHER("CLOSE_GATHER", "源停止"),
|
||||
HEARTBEAT("HeartBeat", "心跳报文"),
|
||||
|
||||
/**
|
||||
* 终端 INIT_GATHER$01 INIT_GATHER采集初始化,01 统计采集、02 暂态采集、03 实时采集
|
||||
@@ -30,6 +31,8 @@ public enum SourceOperateCodeEnum {
|
||||
DEV_DATA_REQUEST_03("DATA_REQUEST$03", "暂态采集申请"),
|
||||
|
||||
|
||||
|
||||
|
||||
YJC_YTXJY("yjc_ytxjy", "预检测_源通讯检测"),
|
||||
YJC_SBTXJY("yjc_sbtxjy", "预检测_设备通讯检测"),
|
||||
YJC_XYJY("yjc_xyjy", "预检测_协议校验"),
|
||||
|
||||
@@ -48,7 +48,7 @@ public class NettyClient {
|
||||
.handler(new ChannelInitializer<NioSocketChannel>() {
|
||||
@Override
|
||||
protected void initChannel(NioSocketChannel ch) {
|
||||
if(port==10086){
|
||||
if(handler instanceof NettySourceClientHandler){
|
||||
ch.pipeline()
|
||||
//空闲状态的handler
|
||||
// 添加LineBasedFrameDecoder来按行分割数据
|
||||
|
||||
@@ -3,11 +3,8 @@ package com.njcn.gather.detection.util.socket.cilent;
|
||||
import com.njcn.gather.detection.handler.SocketDevResponseService;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||
import com.njcn.gather.detection.util.socket.WebServiceManager;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import io.netty.handler.timeout.IdleState;
|
||||
import io.netty.handler.timeout.IdleStateEvent;
|
||||
import io.netty.handler.timeout.TimeoutException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
@@ -5,8 +5,12 @@ import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import io.netty.handler.timeout.TimeoutException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.ConnectException;
|
||||
import java.net.ProtocolException;
|
||||
|
||||
|
||||
/**
|
||||
@@ -85,7 +89,30 @@ public class NettySourceClientHandler extends SimpleChannelInboundHandler<Strin
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
||||
// 处理异常,例如记录日志、关闭连接等
|
||||
cause.printStackTrace();
|
||||
// 根据异常类型进行不同的处理
|
||||
if (cause instanceof ConnectException) {
|
||||
// 处理连接异常,例如重试连接或记录特定的连接错误信息
|
||||
System.out.println("连接socket服务端异常");
|
||||
|
||||
} else if (cause instanceof IOException) {
|
||||
// 处理I/O异常,例如读写错误
|
||||
System.out.println("IOException caught: There was an I/O error.");
|
||||
// 例如,可以记录更详细的I/O错误信息
|
||||
} else if (cause instanceof TimeoutException) {
|
||||
// 处理超时异常
|
||||
System.out.println("TimeoutException caught: Operation timed out.");
|
||||
// 可以根据业务逻辑决定是否重试或记录超时信息
|
||||
} else if (cause instanceof ProtocolException) {
|
||||
// 处理协议异常,例如消息格式不正确
|
||||
System.out.println("ProtocolException caught: Invalid protocol message.");
|
||||
// 可以记录协议错误信息或向客户端发送错误响应
|
||||
} else {
|
||||
// 处理其他类型的异常
|
||||
System.out.println("Unknown exception caught: " + cause.getMessage());
|
||||
// 可以记录未知异常信息
|
||||
}
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +90,18 @@ public class PreDetection {
|
||||
*/
|
||||
@JSONField(name = "line")
|
||||
private Integer line;
|
||||
|
||||
/**
|
||||
* 监测点线路号
|
||||
*/
|
||||
@JSONField(name = "pt")
|
||||
private Integer pt;
|
||||
|
||||
/**
|
||||
* 监测点线路号
|
||||
*/
|
||||
@JSONField(name = "pt")
|
||||
private Integer ct;
|
||||
}
|
||||
|
||||
public String getDevKey() {
|
||||
|
||||
@@ -413,6 +413,8 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
monitorListDTO=new PreDetection.MonitorListDTO();
|
||||
monitorListDTO.setLineId(preDetection.getDevIP()+"_"+i);
|
||||
monitorListDTO.setLine(i);
|
||||
monitorListDTO.setPt(1);
|
||||
monitorListDTO.setPt(1);
|
||||
monitorList.add(monitorListDTO);
|
||||
}
|
||||
preDetection.setMonitorList(monitorList);
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
resultType="com.njcn.gather.device.device.pojo.vo.PreDetection$MonitorListDTO">
|
||||
SELECT
|
||||
Id as lineId,
|
||||
Num as line
|
||||
Num as line,
|
||||
pt as pt,
|
||||
ct as ct
|
||||
FROM
|
||||
pq_monitor
|
||||
WHERE
|
||||
|
||||
Reference in New Issue
Block a user