puzhibing
2025-06-03 f58d0913c810c68c550e5b12da64dbdeb0d0c1f0
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/server/WarnMsgService.java
@@ -193,39 +193,59 @@
   public void saveWarnMsgService(JSONObject jsonObject) {
      SubscriptionEvent subscriptionEvent = jsonObject.getObject("params", SubscriptionEvent.class);
      List<Event> events = subscriptionEvent.getEvents();
      events.forEach(event -> {
         //车牌号
         String srcName = event.getSrcName();
         Alarm data = JSONObject.parseObject(event.getData(), Alarm.class);
         if(!StringUtils.hasLength(data.getAlarmId())){
            return;
         }
         UPWarnMsgAdptInfo upWarnMsgAdptInfo = upWarnMsgAdptInfoDao.findByInfoIdIs(data.getAlarmId());
         if(null == upWarnMsgAdptInfo){
            upWarnMsgAdptInfo = new UPWarnMsgAdptInfo();
         }
         upWarnMsgAdptInfo.setVehicleNo(srcName);
         upWarnMsgAdptInfo.setVehicleColor(null == data.getVehicleLicenseColor() ? 0 : data.getVehicleLicenseColor());
         upWarnMsgAdptInfo.setWarnSrc(data.getSourceType() + 1);
         upWarnMsgAdptInfo.setWarnType(getAlarmType(data.getEventType()));
         upWarnMsgAdptInfo.setWarnTime(LocalDateTime.parse(data.getAlarmTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")).toEpochSecond(ZoneOffset.ofHours(8)));
         upWarnMsgAdptInfo.setInfoId(data.getAlarmId());
         upWarnMsgAdptInfo.setLevel(getLevel(data.getLevel()));
         upWarnMsgAdptInfo.setLongitude(data.getLatitude().intValue() * 10);
         upWarnMsgAdptInfo.setLatitude(data.getLongitude().intValue());
         upWarnMsgAdptInfo.setAltitude(data.getHeight().intValue() / 10);
         upWarnMsgAdptInfo.setSpeed(data.getSpeed().intValue() / 100000);
         upWarnMsgAdptInfo.setVec2(data.getSpeed().intValue() / 100000);
         upWarnMsgAdptInfo.setStatus(data.getStatus());
         upWarnMsgAdptInfo.setDirection(data.getDirection() / 100);
         upWarnMsgAdptInfo.setInfoContent(data.getAlarmInfo());
         upWarnMsgAdptInfo.setInferiorPlatformId(25439966);
         upWarnMsgAdptInfo.setCreateTime(LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8)));
         if(!warnType.contains(upWarnMsgAdptInfo.getWarnType())){
            return;
         }
         upWarnMsgAdptInfoDao.save(upWarnMsgAdptInfo);
      });
      if(null != events){
         events.forEach(event -> {
            try {
               //车牌号
               String srcName = event.getSrcName();
               Alarm data = JSONObject.parseObject(event.getData(), Alarm.class);
               if(!StringUtils.hasLength(data.getAlarmId())){
                  return;
               }
               UPWarnMsgAdptInfo upWarnMsgAdptInfo = upWarnMsgAdptInfoDao.findByInfoIdIs(data.getAlarmId());
               if(null == upWarnMsgAdptInfo){
                  upWarnMsgAdptInfo = new UPWarnMsgAdptInfo();
               }
               upWarnMsgAdptInfo.setVehicleNo(srcName);
               upWarnMsgAdptInfo.setVehicleColor(null == data.getVehicleLicenseColor() ? 0 : data.getVehicleLicenseColor());
               upWarnMsgAdptInfo.setWarnSrc(data.getSourceType() + 1);
               upWarnMsgAdptInfo.setWarnType(getAlarmType(data.getEventType()));
               if(null != data.getAlarmTime()){
                  upWarnMsgAdptInfo.setWarnTime(LocalDateTime.parse(data.getAlarmTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")).toEpochSecond(ZoneOffset.ofHours(8)));
               }
               upWarnMsgAdptInfo.setInfoId(data.getAlarmId());
               upWarnMsgAdptInfo.setLevel(getLevel(data.getLevel()));
               if(null != data.getLatitude()){
                  upWarnMsgAdptInfo.setLongitude(data.getLatitude().intValue() * 10);
               }
               if(null != data.getLongitude()){
                  upWarnMsgAdptInfo.setLatitude(data.getLongitude().intValue());
               }
               if(null != data.getHeight()){
                  upWarnMsgAdptInfo.setAltitude(data.getHeight().intValue() / 10);
               }
               if(null != data.getSpeed()){
                  upWarnMsgAdptInfo.setSpeed(data.getSpeed().intValue() / 100000);
               }
               if(null != data.getSpeed()){
                  upWarnMsgAdptInfo.setVec2(data.getSpeed().intValue() / 100000);
               }
               upWarnMsgAdptInfo.setStatus(data.getStatus());
               if(null != data.getDirection()){
                  upWarnMsgAdptInfo.setDirection(data.getDirection() / 100);
               }
               upWarnMsgAdptInfo.setInfoContent(data.getAlarmInfo());
               upWarnMsgAdptInfo.setInferiorPlatformId(25439966);
               upWarnMsgAdptInfo.setCreateTime(LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8)));
               if(!warnType.contains(upWarnMsgAdptInfo.getWarnType())){
                  return;
               }
               upWarnMsgAdptInfoDao.save(upWarnMsgAdptInfo);
            }catch (Exception e){
               e.printStackTrace();
            }
         });
      }
   }
   
   public int getAlarmType(long eventType){