Pu Zhibing
2025-04-27 2e1766b31e889d9ee54d433476d031220dfda294
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/model/UPWarnMsgAdptInfo.java
@@ -50,6 +50,15 @@
   private int warnSrc;
   /**
    * 报警类型
    * 0x0001: 超速报警
    * 0x0002: 疲劳驾驶报警
    * 0x0003: 紧急报警
    * 0x0004: 进入指定区域报警
    * 0x0005: 离开指定区域报警
    * 0x0006: 路段堵塞报警
    * 0x0007: 危险路段报警
    * 0x0008: 越界报警
    * 0x0009: 盗警
    */
   @Field(type = FieldType.Integer)
   private int warnType;
@@ -74,6 +83,21 @@
   @Field(type = FieldType.Text)
   private String infoContent;
   /**
    * 速度
    */
   @Field(type = FieldType.Integer)
   private Integer speed;
   /**
    * 经度
    */
   @Field(type = FieldType.Integer)
   private Integer longitude;
   /**
    * 纬度
    */
   @Field(type = FieldType.Integer)
   private Integer latitude;
   /**
    * 报警处理结果
    * 0x00:处理中
    * 0x01:已处理完毕
@@ -82,34 +106,43 @@
    */
   @Field(type = FieldType.Integer)
   private int result;
   /**
    * 报警督办发起时间
    */
   @Field(type = FieldType.Long)
   private long pushTime;
   
   
   /**
    * 解析报文
    */
   public UPWarnMsgAdptInfo decode(WarnMsg warnMsg) {
      byte[] data = warnMsg.getData();
      ByteBuf byteBuf = Unpooled.wrappedBuffer(data);
      this.vehicleNo = warnMsg.getVehicleNo();
      this.vehicleColor = warnMsg.getVehicleColor();
      this.dataType = warnMsg.getDataType();
      this.dataLength = warnMsg.getDataLength();
      //报警信息来源
      this.warnSrc = byteBuf.readByte();
      //报警类型
      this.warnType = byteBuf.readShort();
      byte[] readableBytes = new byte[8];
      byteBuf.readBytes(readableBytes);
      String time = ByteArrayUtil.bytes2HexStr(readableBytes);
      //报警时间
      this.warnTime = Long.parseLong(time, 16);
      //信息ID
      this.infoId = byteBuf.readInt();
      //报警数据长度
      this.infoLength = byteBuf.readInt();
      //上报报警信息内容
      this.infoContent = Jtt809Util.readGBKString(byteBuf, this.infoLength);
      try {
         byte[] data = warnMsg.getData();
         ByteBuf byteBuf = Unpooled.wrappedBuffer(data);
         this.vehicleNo = warnMsg.getVehicleNo();
         this.vehicleColor = warnMsg.getVehicleColor();
         this.dataType = warnMsg.getDataType();
         this.dataLength = warnMsg.getDataLength();
         //报警信息来源
         this.warnSrc = byteBuf.readByte();
         //报警类型
         this.warnType = byteBuf.readShort();
         byte[] readableBytes = new byte[8];
         byteBuf.readBytes(readableBytes);
         String time = ByteArrayUtil.bytes2HexStr(readableBytes);
         //报警时间
         this.warnTime = Long.parseLong(time, 16);
         //信息ID
         this.infoId = byteBuf.readInt();
         //报警数据长度
         this.infoLength = byteBuf.readInt();
         //上报报警信息内容
         this.infoContent = Jtt809Util.readGBKString(byteBuf, this.infoLength);
      }catch (Exception e){
         e.printStackTrace();
      }
      return this;
   }
}