|
@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.TimeInterval;
|
|
import cn.hutool.core.date.TimeInterval;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.TypeReference;
|
|
import com.alibaba.fastjson.TypeReference;
|
|
|
|
+import com.persagy.cache.AlarmInfoCache;
|
|
import com.persagy.entity.AlarmDefine;
|
|
import com.persagy.entity.AlarmDefine;
|
|
import com.persagy.entity.NettyMessage;
|
|
import com.persagy.entity.NettyMessage;
|
|
import com.persagy.entity.ZktAlarmRecordDO;
|
|
import com.persagy.entity.ZktAlarmRecordDO;
|
|
@@ -71,10 +72,10 @@ public class GroupNettyClientHandler extends ChannelInboundHandlerAdapter {
|
|
@Override
|
|
@Override
|
|
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
|
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
|
log.info("Connected to: " + ctx.channel().remoteAddress());
|
|
log.info("Connected to: " + ctx.channel().remoteAddress());
|
|
- ctx.channel().writeAndFlush(new NettyMessage<>(200, groupNettyClient.getProjectId()).toString());
|
|
|
|
|
|
+ ctx.channel().writeAndFlush(new NettyMessage<>(200, groupNettyClient.getProjectId(),groupNettyClient.getGroupCode()).toString());
|
|
//启动的时候发送消息,获取全部报警定义
|
|
//启动的时候发送消息,获取全部报警定义
|
|
//{"groupCode":"wd", "projectId":"Pj123"}
|
|
//{"groupCode":"wd", "projectId":"Pj123"}
|
|
- NettyMessage nettyMessage = new NettyMessage(4, groupNettyClient.getProjectId());
|
|
|
|
|
|
+ NettyMessage nettyMessage = new NettyMessage(4, groupNettyClient.getProjectId(),groupNettyClient.getGroupCode());
|
|
nettyMessage.setRemark("连接已经建立;");
|
|
nettyMessage.setRemark("连接已经建立;");
|
|
JSONObject content = new JSONObject();
|
|
JSONObject content = new JSONObject();
|
|
content.put("groupCode", groupNettyClient.getGroupCode());
|
|
content.put("groupCode", groupNettyClient.getGroupCode());
|
|
@@ -154,6 +155,14 @@ public class GroupNettyClientHandler extends ChannelInboundHandlerAdapter {
|
|
if (CollectionUtil.isNotEmpty(definesList)) {
|
|
if (CollectionUtil.isNotEmpty(definesList)) {
|
|
alarmDefineService.deleteAlarmDefine(definesList);
|
|
alarmDefineService.deleteAlarmDefine(definesList);
|
|
}
|
|
}
|
|
|
|
+ } else if (message.getOpCode() == 11) {
|
|
|
|
+ //更新隔离的系统对象
|
|
|
|
+ NettyMessage<String> AlarmDefineMessage = JSONObject.parseObject(String.valueOf(msg), new TypeReference<NettyMessage<String>>() {
|
|
|
|
+ });
|
|
|
|
+ List<String> isolationSystemList = AlarmDefineMessage.getContent();
|
|
|
|
+ if (CollectionUtil.isNotEmpty(isolationSystemList)) {
|
|
|
|
+ AlarmInfoCache.isolationSystemList = isolationSystemList;
|
|
|
|
+ }
|
|
} else if (message.getOpCode() == 8) {
|
|
} else if (message.getOpCode() == 8) {
|
|
log.info("-----报警记录id推送----[{}]", message);
|
|
log.info("-----报警记录id推送----[{}]", message);
|
|
//{"id":"","objId":"","itemCode":""} id为报警记录ID
|
|
//{"id":"","objId":"","itemCode":""} id为报警记录ID
|
|
@@ -170,7 +179,7 @@ public class GroupNettyClientHandler extends ChannelInboundHandlerAdapter {
|
|
alarmRecordRepository.save(zktAlarmRecordDO);
|
|
alarmRecordRepository.save(zktAlarmRecordDO);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- NettyMessage response = new NettyMessage(3, groupNettyClient.getProjectId());
|
|
|
|
|
|
+ NettyMessage response = new NettyMessage(3, groupNettyClient.getProjectId(),groupNettyClient.getGroupCode());
|
|
response.setRemark("已经收到消息");
|
|
response.setRemark("已经收到消息");
|
|
channelHandlerContext.write(response.toString());
|
|
channelHandlerContext.write(response.toString());
|
|
}
|
|
}
|