This commit is contained in:
2025-01-16 10:31:26 +08:00
parent bab07585a9
commit 4e0b16fad1
4 changed files with 34 additions and 26 deletions

View File

@@ -313,14 +313,14 @@ public class SocketDevResponseService {
//判断小电压是否系数超过大电压10% //判断小电压是否系数超过大电压10%
double limit = 0.1; double limit = 0.1;
XiNumberManager.smallDevXiNumDataMap.forEach((devIp, devXiNumDataBig) -> { XiNumberManager.smallDevXiNumDataMap.forEach((devIp, devXiNumDataSmall) -> {
//定义一个标识: false:表示小电流系数和大电流系数 //定义一个标识: false:表示小电流系数和大电流系数
boolean flag = true; boolean flag = true;
DevXiNumData devXiNumDataSmall = XiNumberManager.devXiNumDataMap.get(devIp); DevXiNumData devXiNumDataBig = XiNumberManager.devXiNumDataMap.get(devIp);
Map<Integer, DevXiNumData.GF> gfMap = devXiNumDataSmall.getGf().stream().collect(Collectors.toMap(DevXiNumData.GF::getUMonitorPoint, Function.identity())); Map<Integer, DevXiNumData.GF> gfMapSmall = devXiNumDataSmall.getGf().stream().collect(Collectors.toMap(DevXiNumData.GF::getUMonitorPoint, Function.identity()));
for (DevXiNumData.GF bigGf : devXiNumDataBig.getGf()) { for (DevXiNumData.GF bigGf : devXiNumDataBig.getGf()) {
DevXiNumData.F smallF = gfMap.get(bigGf.getUMonitorPoint()).getF(); DevXiNumData.F smallF = gfMapSmall.get(bigGf.getUMonitorPoint()).getF();
DevXiNumData.F bigF = bigGf.getF(); DevXiNumData.F bigF = bigGf.getF();
boolean ia = isWithinTenPercent(smallF.getIa_gain(), bigF.getIa_gain(), limit); boolean ia = isWithinTenPercent(smallF.getIa_gain(), bigF.getIa_gain(), limit);
@@ -908,6 +908,8 @@ public class SocketDevResponseService {
} }
Map<String,List<DevLineTestResult>> targetTestMap = new HashMap<>(); Map<String,List<DevLineTestResult>> targetTestMap = new HashMap<>();
/** /**
@@ -1197,8 +1199,8 @@ public class SocketDevResponseService {
.sorted(Comparator.comparing(SourceIssue.ChannelListDTO::getChannelType)) .sorted(Comparator.comparing(SourceIssue.ChannelListDTO::getChannelType))
.collect(Collectors.toList()); .collect(Collectors.toList());
Map<String, String> sourceMessageMap = sourceMessage(issue); Map<String, String> sourceMessageMap = sourceMessage(issue);
List<String> v = Arrays.asList("VRMS", "VA", "U", "V", "电压"); List<String> v = Arrays.asList("VRMS", "VA", "U", "V");
List<String> i = Arrays.asList("IRMS", "IA", "I", "I", "电流"); List<String> i = Arrays.asList("IRMS", "IA", "I", "I");
devMap.forEach((key, value) -> { devMap.forEach((key, value) -> {
List<DevData.SqlDataDTO> sqlData = value.stream().flatMap(x -> x.getSqlData().stream()).collect(Collectors.toList()); List<DevData.SqlDataDTO> sqlData = value.stream().flatMap(x -> x.getSqlData().stream()).collect(Collectors.toList());
getResult(key, sqlData, sourceMessageMap, sourceV, info, v); getResult(key, sqlData, sourceMessageMap, sourceV, info, v);
@@ -1253,7 +1255,7 @@ public class SocketDevResponseService {
Boolean b = getaBoolean(sourceMap.get(type + "b"), data.get(0).getList().getB(), dataPhase.get(0).getList().getB()); Boolean b = getaBoolean(sourceMap.get(type + "b"), data.get(0).getList().getB(), dataPhase.get(0).getList().getB());
Boolean c = getaBoolean(sourceMap.get(type + "c"), data.get(0).getList().getC(), dataPhase.get(0).getList().getC()); Boolean c = getaBoolean(sourceMap.get(type + "c"), data.get(0).getList().getC(), dataPhase.get(0).getList().getC());
compareDev.setIsQualified(a && b && c); compareDev.setIsQualified(a && b && c);
compareDev.setDesc(name + (compareDev.getIsQualified() ? "合格->" : "不合格->") + desc + stepTag + devMessage(type, data, dataPhase)); compareDev.setDesc(name + (compareDev.getIsQualified() ? "合格->" : "不合格->") +stepTag + desc + stepTag + devMessage(type, data, dataPhase));
return compareDev; return compareDev;
} }

View File

@@ -56,6 +56,7 @@ public enum SourceOperateCodeEnum {
UNKNOWN_OPERATE("unknown_operate","未知的操作返回,请联系管理员排查"), UNKNOWN_OPERATE("unknown_operate","未知的操作返回,请联系管理员排查"),
SOCKET_TIMEOUT("socket_timeout","与源或者装置通讯等待超时"), SOCKET_TIMEOUT("socket_timeout","与源或者装置通讯等待超时"),
STOP_TIMEOUT("stop_timeout","暂停时间超过十分钟"), STOP_TIMEOUT("stop_timeout","暂停时间超过十分钟"),
SERVER_ERROR("server_error","服务端主动关闭连接,请稍后再试"),

View File

@@ -85,7 +85,7 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
* @param ctx * @param ctx
*/ */
@Override @Override
public void channelInactive(ChannelHandlerContext ctx) { public void channelInactive(ChannelHandlerContext ctx) throws Exception {
System.out.println("设备通讯客户端断线"); System.out.println("设备通讯客户端断线");
ctx.close(); ctx.close();
SocketManager.removeUser(param.getUserPageId() + dev); SocketManager.removeUser(param.getUserPageId() + dev);
@@ -173,6 +173,7 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
@Override @Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
System.out.println("捕获到设备服务异常。。。。。。。");
// 处理异常,例如记录日志、关闭连接等 // 处理异常,例如记录日志、关闭连接等
cause.printStackTrace(); cause.printStackTrace();
// 根据异常类型进行不同的处理 // 根据异常类型进行不同的处理
@@ -183,6 +184,8 @@ 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.SERVER_ERROR.getValue(),SourceOperateCodeEnum.SERVER_ERROR.getValue(),SourceOperateCodeEnum.SERVER_ERROR.getMsg(),null );
// 例如可以记录更详细的I/O错误信息 // 例如可以记录更详细的I/O错误信息
} else if (cause instanceof TimeoutException) { } else if (cause instanceof TimeoutException) {
// 处理超时异常 // 处理超时异常

View File

@@ -6,6 +6,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.pojo.vo.SocketDataMsg; import com.njcn.gather.detection.pojo.vo.SocketDataMsg;
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.CnSocketUtil; import com.njcn.gather.detection.util.socket.CnSocketUtil;
import com.njcn.gather.detection.util.socket.MsgUtil; import com.njcn.gather.detection.util.socket.MsgUtil;
import com.njcn.gather.detection.util.socket.SocketManager; import com.njcn.gather.detection.util.socket.SocketManager;
@@ -115,6 +116,7 @@ public class NettySourceClientHandler extends SimpleChannelInboundHandler<String
@Override @Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
// 处理异常,例如记录日志、关闭连接等 // 处理异常,例如记录日志、关闭连接等
System.out.println("捕获到源异常。。。。。。。");
cause.printStackTrace(); cause.printStackTrace();
// 根据异常类型进行不同的处理 // 根据异常类型进行不同的处理
if (cause instanceof ConnectException) { if (cause instanceof ConnectException) {
@@ -123,7 +125,7 @@ public class NettySourceClientHandler 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."); CnSocketUtil.sendToWebSocket(webUser.getUserPageId(),SourceOperateCodeEnum.SERVER_ERROR.getValue(),SourceOperateCodeEnum.SERVER_ERROR.getValue(),SourceOperateCodeEnum.SERVER_ERROR.getMsg(),null );
// 例如可以记录更详细的I/O错误信息 // 例如可以记录更详细的I/O错误信息
} else if (cause instanceof TimeoutException) { } else if (cause instanceof TimeoutException) {
// 处理超时异常 // 处理超时异常