南昌市物联网技防平台-后台
blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/equipment/service/impl/EquipmentServiceImpl.java
@@ -233,6 +233,66 @@
   public Map<String, Object> selEqTypeSum() {
      //查詢之前先更新设备状态
      //查询所有的设备,不包含故障和警情状态
//      List<Equipment> equipment = baseMapper.selAllEq();
//      long time = new Date().getTime();
//      long hearbeat = 0;
//      List<Long> equipmentListz = new ArrayList<>();
//      List<Long> equipmentListl = new ArrayList<>();
//      for (Equipment e:equipment) {
//         try {
//            if(null!=e.getHeartbeat()) {
//               hearbeat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(e.getHeartbeat()).getTime();
//            }
//         } catch (ParseException parseException) {
//            parseException.printStackTrace();
//         }
//         //对比心跳时间,在线
//         if (time-hearbeat<TIME_DIFFERENCE){
//            if (null==e.getDtype() || e.getDtype()!="1"){
//               equipmentListz.add(e.getId());
//            }
//         }
//         if (time-hearbeat>=TIME_DIFFERENCE){
//            if (null==e.getDtype() || e.getDtype()!="0"){
//               equipmentListl.add(e.getId());
//            }
//         }
//      }
//
//      System.out.println("equipmentListl = " + equipmentListl);
//      System.out.println("equipmentListz = " + equipmentListz);
//      //批量更新数据
//      if (equipmentListz.size()>0){
//         baseMapper.updateEqListz(equipmentListz);
//      }
//      if (equipmentListl.size()>0){
//         baseMapper.updateEqListl(equipmentListl);
//      }
      //设备在线数量
      Integer integerz = baseMapper.selectEqCz();
      //设备掉线数量
      Integer integerd = baseMapper.selectEqCd();
      //设备预警数量
      Integer alarmSum = baseMapper.selectEqCys();
      //设备故障数量
      Integer integerg = baseMapper.selectEqCg();
      //封装数据
      Map<String, Object> map = new HashMap<String, Object>();
      map.put("zx", integerz);
      map.put("dx", integerd);
      map.put("yj", alarmSum);
      map.put("gz", integerg);
      //返回数据
      return map;
   }
   /**
    * 更新设备状态
    */
   @Override
   public void updateEquipmentDtype() {
      //查询所有的设备,不包含故障和警情状态
      List<Equipment> equipment = baseMapper.selAllEq();
      long time = new Date().getTime();
      long hearbeat = 0;
@@ -268,21 +328,5 @@
      if (equipmentListl.size()>0){
         baseMapper.updateEqListl(equipmentListl);
      }
      //设备在线数量
      Integer integerz = baseMapper.selectEqCz();
      //设备掉线数量
      Integer integerd = baseMapper.selectEqCd();
      //设备预警数量
      Integer alarmSum = baseMapper.selectEqCys();
      //设备故障数量
      Integer integerg = baseMapper.selectEqCg();
      //封装数据
      Map<String, Object> map = new HashMap<String, Object>();
      map.put("zx", integerz);
      map.put("dx", integerd);
      map.put("yj", alarmSum);
      map.put("gz", integerg);
      //返回数据
      return map;
   }
}