南昌市物联网技防平台-后台
zengh
2021-04-25 6972afbf3b2cab802671a80aa2e858a329b5f55f
blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/nettyServer/ServerHandler.java
@@ -12,8 +12,11 @@
import org.springblade.jfpt.animalheat.service.AnimalHeatService;
import org.springblade.jfpt.catalog.service.catalogService;
import org.springblade.jfpt.equipment.service.IEquipmentService;
import org.springblade.jfpt.message.entity.Message;
import org.springblade.jfpt.message.service.IMessageService;
import org.springblade.jfpt.operation.service.IOperationService;
import org.springblade.jfpt.operation.vo.OperationVO;
import org.springblade.jfpt.webscoket.service.IPushMsgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -41,6 +44,8 @@
   @Autowired
   private org.springblade.jfpt.Netty.service.nettyService nettyService;
   @Autowired
   private  IMessageService messageService;
   @Autowired
   private IEquipmentService equipmentService;
@@ -50,6 +55,9 @@
   @Autowired
   private IAlarmService alarmService;
   @Autowired
   private IPushMsgService pushMsgService;
   @Autowired
   private IOperationService operationService;
@@ -106,6 +114,8 @@
   @Override
   public void channelRead(ChannelHandlerContext channelHandlerContext, Object info) throws Exception {
      long startTime1 = System.currentTimeMillis();
      Date day = new Date();
      SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      System.out.println("接收到了:" + info);
      ByteBuf buf = (ByteBuf) info;
      byte[] req = new byte[buf.readableBytes()];
@@ -126,6 +136,12 @@
         }
      } else {
         String ChannelName = content.substring(10, 22);//设备编码
         //报文内容保存
         Message message = new Message();
         message.setEnumber(ChannelName);
         message.setContent(body);
         message.setTime(df.format(day));
         serverHandler.messageService.save(message);
         String sub = content.substring(23, 27);
         ConcurrentHashMap<String, Channel> channelHashMap = ChannelMap.getChannelHashMap();
         if (channelHashMap == null) {
@@ -157,8 +173,6 @@
               Alarm alarm = new Alarm();
               alarm.setAlarmType("一键报警");
               alarm.setGalarmPeople("报警主机");
               Date day = new Date();
               SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
               alarm.setAlarmTime(df.format(day));
               alarm.setPlace((String) list.get(0).get("streeName"));//事发地址
               alarm.setDeviceNumber((String) list.get(0).get("deviceNumber"));//设备编号
@@ -1720,9 +1734,11 @@
                  //查询所有闲置的接警员
                  List<Map<String, Object>> policeList = serverHandler.alarmService.queryPolice();
                  List<Map<String, Object>> online_police = new ArrayList<>();
                  List<Map<String, Object>> zx_police = new ArrayList<>();
                  for (int i = 0; i < policeList.size(); i++) {
                     //System.out.println(policeList.get(i).get("real_name"));
                     if(policeList.get(i).get("online_status").equals(1)){
                           zx_police.add(policeList.get(i));
                        if (policeList.get(i).get("work_status").equals(0)){
                           online_police.add(policeList.get(i));
                        }
@@ -1730,8 +1746,18 @@
                  }
                  //如果无在线闲置人员
                  if (online_police.size() == 0){
                     online_police = policeList;
                     //判断是否有在线人员
                     if (zx_police.size() == 0){
                        //无在线人员,选取所有接警员
                        online_police = policeList;
                     }else{
                        //有在线人员
                        online_police = zx_police;
                     }
                  }
                  List policeIdArr = new ArrayList();
@@ -1774,6 +1800,9 @@
                  operation.setZc("接警");
                  operation.setZctime(alarm.getJjTime());
                  serverHandler.operationService.save(operation);
                  //通过websocket给前端接警员发送信息
                  serverHandler.pushMsgService.pushMsg(alarm.getAlarmId(), alarm.getId().toString());
               }
               outData.add("LEOK#@");