package com.ruoyi.dataInterchange.model;
|
|
import com.ruoyi.common.core.utils.DateUtils;
|
import com.ruoyi.dataInterchange.pojo.BaseModel;
|
import com.ruoyi.dataInterchange.util.jtt809.common.Jtt809Util;
|
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.Unpooled;
|
import lombok.Data;
|
import org.springframework.data.elasticsearch.annotations.Document;
|
import org.springframework.data.elasticsearch.annotations.Field;
|
import org.springframework.data.elasticsearch.annotations.FieldType;
|
|
import java.text.ParseException;
|
|
/**
|
* 上报报警信息
|
*
|
* @author zhibing.pu
|
* @Date 2025/3/3 14:50
|
*/
|
@Data
|
@Document(indexName = "up_warn_msg_adpt_info")
|
public class UPWarnMsgAdptInfo extends BaseModel {
|
/**
|
* 车牌号
|
*/
|
@Field(type = FieldType.Text)
|
private String vehicleNo;
|
/**
|
* 车牌颜色
|
*/
|
@Field(type = FieldType.Integer)
|
private int vehicleColor;
|
/**
|
* 子业务类型标识
|
*/
|
@Field(type = FieldType.Integer)
|
private int dataType;
|
/**
|
* 后续数据长度
|
*/
|
@Field(type = FieldType.Integer)
|
private int dataLength;
|
/**
|
* 报警信息来源
|
* 0x01: 车载终端
|
* 0x02: 企业监控平台
|
* 0x03: 政府监管平台
|
* 0x09: 其他
|
*/
|
@Field(type = FieldType.Integer)
|
private int warnSrc;
|
/**
|
* 报警类型
|
*/
|
@Field(type = FieldType.Integer)
|
private int warnType;
|
/**
|
* 报警时间
|
*/
|
@Field(type = FieldType.Integer)
|
private long warnTime;
|
/**
|
* 信息ID
|
*/
|
@Field(type = FieldType.Integer)
|
private int infoId;
|
/**
|
* 报警数据长度
|
*/
|
@Field(type = FieldType.Integer)
|
private int infoLength;
|
/**
|
* 上报报警信息内容
|
*/
|
@Field(type = FieldType.Text)
|
private String infoContent;
|
|
|
/**
|
* 解析报文
|
*/
|
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();
|
String date = byteBuf.readByte() + "-" + byteBuf.readByte() + "-" + byteBuf.readShort() + " " +
|
byteBuf.readByte() + ":" + byteBuf.readByte() + ":" + byteBuf.readByte();
|
long time = 0;
|
try {
|
time = DateUtils.parseDate(date, "dd-MM-yyyy HH:mm:ss").getTime();
|
} catch (ParseException e) {
|
e.printStackTrace();
|
}
|
//报警时间
|
this.warnTime = time;
|
//信息ID
|
this.infoId = byteBuf.readInt();
|
//报警数据长度
|
this.infoLength = byteBuf.readInt();
|
//上报报警信息内容
|
this.infoContent = Jtt809Util.readGBKString(byteBuf, this.infoLength);
|
return this;
|
}
|
}
|