Pu Zhibing
2025-06-19 a05b419384e148fc950c77553816a2d05144f4ae
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/server/WarnMsgService.java
@@ -60,9 +60,17 @@
   @Resource
   private UPExgMsgRealLocationDao upExgMsgRealLocationDao;
   //走川标的公司
   private List<Integer> enterprise = Arrays.asList(17458936, 43984060, 13914394);
   //固定报警类型
   private List<Integer> warnType = Arrays.asList(0x0201, 0x0202, 0x0301, 0x000B, 0x0012, 0x0203, 0x0208, 0x0002, 0x0211, 0x0212, 0x0214, 0x0213, 0x0215, 0x0217, 0x0307);
   private List<Integer> enterprise = Arrays.asList(17458936,13914394,43984060,25439966);
   //富临报警类型
   private List<Integer> fl_warnType = Arrays.asList(0x0201, 0x0012, 0x0202, 0x0203, 0x0208, 0x0002, 0x0212, 0x0214, 0x0213, 0x0215, 0x0217);
   //均辉报警类型
   private List<Integer> jh_warnType = Arrays.asList(0x0201, 0x0012, 0x0202, 0x0203, 0x0208, 0x0002, 0x0212, 0x0214, 0x0213, 0x0215, 0x0217, 0x0307);
   //出租车报警类型
   private List<Integer> cz_warnType = Arrays.asList(0x0001, 0x0005);
   //公交报警类型
   private List<Integer> gj_warnType = Arrays.asList(0x0002, 0x0212, 0x0214, 0x0213, 0x0215, 0x0217, 0x0001);
   //平安报警类型
   private List<Integer> pa_warnType = Arrays.asList(0x0201, 0x0012, 0x0202, 0x0208, 0x0002, 0x0212, 0x0214, 0x0213, 0x0215, 0x0217, 0x0307);
   
   
   public void up_warn_msg(ChannelHandlerContext ctx, OuterPacket out) {
@@ -147,8 +155,31 @@
    */
   public void up_warn_msg_adpt_info(ChannelHandlerContext ctx, int inferiorPlatformId, WarnMsg warnMsg) {
      UPWarnMsgAdptInfo upWarnMsgAdptInfo = enterprise.contains(inferiorPlatformId) ? new UPWarnMsgAdptInfo().decode2(warnMsg) : new UPWarnMsgAdptInfo().decode1(warnMsg);
      if(!warnType.contains(upWarnMsgAdptInfo.getWarnType())){
         return;
      switch (inferiorPlatformId) {
         case 17458936:
            if(!fl_warnType.contains(upWarnMsgAdptInfo.getWarnType())){
               return;
            }
         case 43984060:
            if(!jh_warnType.contains(upWarnMsgAdptInfo.getWarnType())){
               return;
            }
         case 17235341:
            if(!cz_warnType.contains(upWarnMsgAdptInfo.getWarnType())){
               return;
            }
         case 82296583:
            if(!cz_warnType.contains(upWarnMsgAdptInfo.getWarnType())){
               return;
            }
         case 25439966:
            if(!gj_warnType.contains(upWarnMsgAdptInfo.getWarnType())){
               return;
            }
         case 13914394:
            if(!pa_warnType.contains(upWarnMsgAdptInfo.getWarnType())){
               return;
            }
      }
      upWarnMsgAdptInfo.setResult(0x00);
      upWarnMsgAdptInfo.setInferiorPlatformId(inferiorPlatformId);
@@ -197,8 +228,10 @@
      upWarnMsgOperationInfoDao.save(upWarnMsgOperationInfo);
      //修改报警处理结果
      UPWarnMsgAdptInfo upWarnMsgAdptInfo = upWarnMsgAdptInfoDao.findByInfoIdIs(upWarnMsgOperationInfo.getInfoId());
      upWarnMsgAdptInfo.setResult(upWarnMsgOperationInfo.getResult());
      upWarnMsgAdptInfoDao.save(upWarnMsgAdptInfo);
      if(null != upWarnMsgAdptInfo){
         upWarnMsgAdptInfo.setResult(upWarnMsgOperationInfo.getResult());
         upWarnMsgAdptInfoDao.save(upWarnMsgAdptInfo);
      }
   }
   
   
@@ -213,22 +246,26 @@
      upWarnMsgFileListAck.setInferiorPlatformId(inferiorPlatformId);
      upWarnMsgFileListAck.setCreateTime(LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8)));
      upWarnMsgFileListAckDao.save(upWarnMsgFileListAck);
      //修改报警处理结果
      //修改报警附件数据
      UPWarnMsgAdptInfo upWarnMsgAdptInfo = upWarnMsgAdptInfoDao.findByInfoIdIs(upWarnMsgFileListAck.getInfoId());
      StringJoiner joiner = new StringJoiner(",");
      upWarnMsgFileListAck.getFileList().forEach(file->{
         if(file.getFileType() == 0x00){
            joiner.add(file.getFileUrl());
         }
      });
      upWarnMsgAdptInfo.setPicUrl(joiner.toString());
      if(upWarnMsgFileListAck.getFileList().size() > 0){
         StringJoiner joiner = new StringJoiner(",");
         upWarnMsgFileListAck.getFileList().forEach(file->{
            if(file.getFileType() == 0x00){
               joiner.add(file.getFileUrl());
            }
         });
         upWarnMsgAdptInfo.setPicUrl(joiner.toString());
      }else{
         upWarnMsgAdptInfo.setPicUrl("*");
      }
      upWarnMsgAdptInfoDao.save(upWarnMsgAdptInfo);
   }
   
   
   
   /**
    * 定时任务督办报警请求
    * 定时任务督办报警请求和附件请求
    */
   public void taskUrgeTodo() {
      List<UPWarnMsgAdptInfo> list = upWarnMsgAdptInfoDao.findByResultIsAndLevelNotNullAndPushTimeBefore(0x00, LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8)));
@@ -237,11 +274,12 @@
         //海康威视直接走接口
         if(25439966 == inferiorPlatformId){
            try {
               if("***".equals(upWarnMsgAdptInfo.getPicUrl())){
               if(!StringUtils.hasLength(upWarnMsgAdptInfo.getPicUrl())){
                  FindPicturesByAlarmIdRequest findPicturesByAlarmIdRequest = new FindPicturesByAlarmIdRequest();
                  findPicturesByAlarmIdRequest.setAlarmId(upWarnMsgAdptInfo.getInfoId());
                  long warnTime = upWarnMsgAdptInfo.getWarnTime();
                  String format = LocalDateTime.ofEpochSecond(warnTime, 0, ZoneOffset.ofHours(8)).format(DateTimeFormatter.ofPattern("yyyy-MM-ddTHH:mm:ss.SSS+08:00"));
                  String format = LocalDateTime.ofEpochSecond(warnTime, 0, ZoneOffset.ofHours(8)).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
                  format = format.replace(" ", "T") + "+08:00";
                  findPicturesByAlarmIdRequest.setAlarmTime(format);
                  String pictures = Artemis.findPicturesByAlarmId(findPicturesByAlarmIdRequest);
                  JSONObject jsonObject = JSONObject.parseObject(pictures);
@@ -254,22 +292,33 @@
                        String url = jsonObject1.getString("url");
                        joiner.add(url);
                     }
                     upWarnMsgAdptInfo.setPicUrl(joiner.toString());
                     upWarnMsgAdptInfo.setPicUrl(joiner.length() > 0 ? joiner.toString() : "*");
                     upWarnMsgAdptInfoDao.save(upWarnMsgAdptInfo);
                  }
               }
            }catch (Exception e){
               e.printStackTrace();
            }
         }
         //请求报警附件(川标协议)
         if(enterprise.contains(inferiorPlatformId) && !StringUtils.hasLength(upWarnMsgAdptInfo.getPicUrl())){
            DOWNWarnMsgFileListReq downWarnMsgFileListReq = new DOWNWarnMsgFileListReq();
            downWarnMsgFileListReq.setVehicleNo(upWarnMsgAdptInfo.getVehicleNo());
            downWarnMsgFileListReq.setVehicleColor(upWarnMsgAdptInfo.getVehicleColor());
            downWarnMsgFileListReq.setDataType(DataType.DOWN_WARN_MSG_FILELIST_REQ.getCode());
            downWarnMsgFileListReq.setDataLength(32);
            downWarnMsgFileListReq.setInfoId(upWarnMsgAdptInfo.getInfoId());
            byte[] body = downWarnMsgFileListReq.encode();
            OuterPacket out = new OuterPacket(DataType.DOWN_WARN_MSG.getCode(), inferiorPlatformId, body);
            //获取从链路通道
            Channel channel = ChannelMap.getClientChannel(inferiorPlatformId);
            if (null != channel && channel.isActive()) {
               channel.writeAndFlush(out);
               log.info("报警附件目录请求({}):{}", DataType.DOWN_WARN_MSG_FILELIST_REQ.getCode(), JSON.toJSONString(downWarnMsgFileListReq));
            }
         }
         
         down_warn_msg_urge_todo_req(upWarnMsgAdptInfo);
//         down_warn_msg_urge_todo_req(upWarnMsgAdptInfo);
      }
   }
   
@@ -327,11 +376,21 @@
               }
               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.getLatitude()){
//                  upWarnMsgAdptInfo.setLongitude(data.getLatitude().intValue() * 10);
//               }
//               if(null != data.getLongitude()){
//                  upWarnMsgAdptInfo.setLatitude(data.getLongitude().intValue());
//               }
               //调用获取实时定位数据
               UPExgMsgRealLocation upExgMsgRealLocation = upExgMsgRealLocationDao.findByVehicleNoOrderByCreateTimeDesc(upWarnMsgAdptInfo.getVehicleNo());
               if (null != upExgMsgRealLocation) {
                  GnssData gnssData = upExgMsgRealLocation.getGnssData();
                  upWarnMsgAdptInfo.setSpeed(gnssData.getVec1());
                  upWarnMsgAdptInfo.setLongitude(gnssData.getLon());
                  upWarnMsgAdptInfo.setLatitude(gnssData.getLat());
               }else{
                  return;
               }
               if(null != data.getHeight()){
                  upWarnMsgAdptInfo.setAltitude(data.getHeight().intValue() / 10);
@@ -349,18 +408,18 @@
               upWarnMsgAdptInfo.setInfoContent(data.getAlarmInfo());
               upWarnMsgAdptInfo.setInferiorPlatformId(25439966);
               upWarnMsgAdptInfo.setCreateTime(LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8)));
               if(!warnType.contains(upWarnMsgAdptInfo.getWarnType())){
               if(!gj_warnType.contains(upWarnMsgAdptInfo.getWarnType())){
                  return;
               }
               upWarnMsgAdptInfo.setResult(0x00);
               
               //获取报警抓拍图片
               if(data.getPicNum() > 0){
                  upWarnMsgAdptInfo.setPicUrl("***");
                  FindPicturesByAlarmIdRequest findPicturesByAlarmIdRequest = new FindPicturesByAlarmIdRequest();
                  findPicturesByAlarmIdRequest.setAlarmId(data.getAlarmId());
                  long warnTime = upWarnMsgAdptInfo.getWarnTime();
                  String format = LocalDateTime.ofEpochSecond(warnTime, 0, ZoneOffset.ofHours(8)).format(DateTimeFormatter.ofPattern("yyyy-MM-ddTHH:mm:ss.SSS+08:00"));
                  String format = LocalDateTime.ofEpochSecond(warnTime, 0, ZoneOffset.ofHours(8)).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
                  format = format.replace(" ", "T") + "+08:00";
                  findPicturesByAlarmIdRequest.setAlarmTime(format);
                  String pictures = Artemis.findPicturesByAlarmId(findPicturesByAlarmIdRequest);
                  JSONObject jsonObject1 = JSONObject.parseObject(pictures);
@@ -375,6 +434,8 @@
                     }
                     upWarnMsgAdptInfo.setPicUrl(joiner.toString());
                  }
               }else{
                  upWarnMsgAdptInfo.setPicUrl("*");
               }
               upWarnMsgAdptInfoDao.save(upWarnMsgAdptInfo);