|
@@ -139,28 +139,46 @@ public class HeartReportHandler extends SimpleChannelInboundHandler<HeartReportI
|
|
|
|
|
|
String deviceNo = ctx.channel().attr(LapiAttrKeys.DEVICE_NO).get();
|
|
String deviceNo = ctx.channel().attr(LapiAttrKeys.DEVICE_NO).get();
|
|
|
|
|
|
- if(StringUtils.isNotEmpty(deviceNo)){
|
|
|
|
- log.warn(deviceNo + "channelInactive");
|
|
|
|
-
|
|
|
|
- new Thread(()->{
|
|
|
|
- try {
|
|
|
|
- //防止channelRead0和channelInactive同时发生
|
|
|
|
- Thread.sleep(1000);
|
|
|
|
- } catch (InterruptedException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ final SysLog sysLog = new SysLog();
|
|
|
|
+ sysLog.setPointcut(deviceNo);
|
|
|
|
+ sysLog.setUrl("/LAPI/V1.0/PACS/Controller/HeartReportInfo");
|
|
|
|
+ SocketAddress remoteAddress = ctx.channel().remoteAddress();
|
|
|
|
+ sysLog.setRemoteIp(remoteAddress.toString());
|
|
|
|
+
|
|
|
|
+ sysLog.setCreateTime(new Date());
|
|
|
|
+
|
|
|
|
+ if(StringUtils.isNotEmpty(deviceNo)) {
|
|
|
|
+ log.warn(deviceNo + " channelInactive");
|
|
|
|
+
|
|
|
|
+ //增加判断remoteAddress是否相同,避免客户端离线后,延迟通知服务端,导致服务器将新连接删除
|
|
|
|
+ String remoteAddr1 = ctx.channel().remoteAddress().toString();
|
|
|
|
+
|
|
|
|
+ if (activeLapiChannelMap.containsKey(deviceNo)) {
|
|
|
|
+ String remoteAddr2 = activeLapiChannelMap.get(deviceNo).getChannel().remoteAddress().toString();
|
|
|
|
+ sysLog.setData("当前设备对应连接->" + remoteAddr2);
|
|
|
|
+
|
|
|
|
+ if (remoteAddr1.equals(remoteAddr2)) {
|
|
|
|
+ activeLapiChannelMap.remove(deviceNo);
|
|
|
|
+ sysLog.setRemark("设备离线,已从全局map中删除");
|
|
|
|
+
|
|
|
|
+ new Thread(() -> {
|
|
|
|
+ try {
|
|
|
|
+ //防止channelRead0和channelInactive同时发生
|
|
|
|
+ Thread.sleep(1000);
|
|
|
|
+ } catch (InterruptedException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ deviceInfoService.updateByDeviceNo(deviceNo, false);
|
|
|
|
+ }).start();
|
|
|
|
+ } else {
|
|
|
|
+ sysLog.setRemark("设备离线,但有新连接接入" + remoteAddr2);
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ sysLog.setRemark("设备离线," + "未加入全局map");
|
|
|
|
+ }
|
|
|
|
|
|
- SysLog sysLog = new SysLog();
|
|
|
|
- sysLog.setPointcut(deviceNo);
|
|
|
|
- sysLog.setUrl("/LAPI/V1.0/PACS/Controller/HeartReportInfo");
|
|
|
|
- sysLog.setRemark("设备离线");
|
|
|
|
- SocketAddress remoteAddress = ctx.channel().remoteAddress();
|
|
|
|
- sysLog.setRemoteIp(remoteAddress.toString());
|
|
|
|
- sysLog.setCreateTime(new Date());
|
|
|
|
- sysLogService.insert(sysLog);
|
|
|
|
-
|
|
|
|
- deviceInfoService.updateByDeviceNo(deviceNo,false);
|
|
|
|
- }).start();
|
|
|
|
|
|
+ sysLogService.insert(sysLog);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|