From 9badf1c7fe71c081ff418ae43c1b950d4db2e584 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Mon, 8 Apr 2024 18:15:02 +0800 Subject: [PATCH] =?UTF-8?q?1078-=E6=B7=BB=E5=8A=A0=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E9=99=84=E5=8A=A0=E4=BF=A1=E6=81=AF=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jt1078/bean/JTPositionAdditionalInfo.java | 25 +++ .../vmp/jt1078/bean/JTPositionBaseInfo.java | 147 ++++++++++++++++++ .../iot/vmp/jt1078/bean/JTPositionInfo.java | 140 ++--------------- .../iot/vmp/jt1078/proc/request/J0200.java | 25 +-- 4 files changed, 200 insertions(+), 137 deletions(-) create mode 100644 src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTPositionAdditionalInfo.java create mode 100644 src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTPositionBaseInfo.java diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTPositionAdditionalInfo.java b/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTPositionAdditionalInfo.java new file mode 100644 index 000000000..6319b9228 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTPositionAdditionalInfo.java @@ -0,0 +1,25 @@ +package com.genersoft.iot.vmp.jt1078.bean; + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema(description = "位置附加信息") +public class JTPositionAdditionalInfo { + + @Schema(description = "里程, 单位为1/10km, 对应车上里程表读数") + private int mileage; + + @Schema(description = "油量, 单位为1/10L, 对应车上油量表读数") + private int oil; + + @Schema(description = "行驶记录功能获取的速度,单位为1/10km/h") + private int speed; + + @Schema(description = "报警事件的 ID") + private int alarmId; + // TODO 暂不支持胎压 + + @Schema(description = "车厢温度 ,单位为摄氏度") + private int carriageTemperature; + // TODO 暂不支持胎压 + +} diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTPositionBaseInfo.java b/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTPositionBaseInfo.java new file mode 100644 index 000000000..1edac47f3 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTPositionBaseInfo.java @@ -0,0 +1,147 @@ +package com.genersoft.iot.vmp.jt1078.bean; + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema(description = "位置基本信息") +public class JTPositionBaseInfo { + + /** + * 报警标志 + */ + @Schema(description = "报警标志") + private JTAlarmSign alarmSign; + + /** + * 状态 + */ + @Schema(description = "状态") + private JTStatus status; + + /** + * 经度 + */ + @Schema(description = "经度") + private Double longitude; + + /** + * 纬度 + */ + @Schema(description = "纬度") + private Double latitude; + + /** + * 高程 + */ + @Schema(description = "高程") + private Integer altitude; + + /** + * 速度 + */ + @Schema(description = "速度") + private Integer speed; + + /** + * 方向 + */ + @Schema(description = "方向") + private Integer direction; + + /** + * 时间 + */ + @Schema(description = "时间") + private String time; + + /** + * 视频报警 + */ + @Schema(description = "视频报警") + private JTVideoAlarm videoAlarm; + + public JTAlarmSign getAlarmSign() { + return alarmSign; + } + + public void setAlarmSign(JTAlarmSign alarmSign) { + this.alarmSign = alarmSign; + } + + public JTStatus getStatus() { + return status; + } + + public void setStatus(JTStatus status) { + this.status = status; + } + + public Double getLongitude() { + return longitude; + } + + public void setLongitude(Double longitude) { + this.longitude = longitude; + } + + public Double getLatitude() { + return latitude; + } + + public void setLatitude(Double latitude) { + this.latitude = latitude; + } + + public Integer getAltitude() { + return altitude; + } + + public void setAltitude(Integer altitude) { + this.altitude = altitude; + } + + public Integer getSpeed() { + return speed; + } + + public void setSpeed(Integer speed) { + this.speed = speed; + } + + public Integer getDirection() { + return direction; + } + + public void setDirection(Integer direction) { + this.direction = direction; + } + + public String getTime() { + return time; + } + + public void setTime(String time) { + this.time = time; + } + + public JTVideoAlarm getVideoAlarm() { + return videoAlarm; + } + + public void setVideoAlarm(JTVideoAlarm videoAlarm) { + this.videoAlarm = videoAlarm; + } + + @Override + public String toString() { + return "位置汇报信息: " + + " \n 报警标志:" + alarmSign.toString() + + " \n 状态:" + status.toString() + + " \n 经度:" + longitude + + " \n 纬度:" + latitude + + " \n 高程: " + altitude + + " \n 速度: " + speed + + " \n 方向: " + direction + + " \n 时间: " + time + + " \n"; + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTPositionInfo.java b/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTPositionInfo.java index d0bf18f8a..853c4f213 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTPositionInfo.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTPositionInfo.java @@ -6,142 +6,30 @@ import io.swagger.v3.oas.annotations.media.Schema; public class JTPositionInfo { /** - * 报警标志 + * 位置基本信息 */ - @Schema(description = "报警标志") - private JTAlarmSign alarmSign; + @Schema(description = "位置基本信息") + private JTPositionBaseInfo base; /** - * 状态 + * 位置基本信息 */ - @Schema(description = "状态") - private JTStatus status; + @Schema(description = "位置附加信息") + private JTPositionAdditionalInfo additional; - /** - * 经度 - */ - @Schema(description = "经度") - private Double longitude; - - /** - * 纬度 - */ - @Schema(description = "纬度") - private Double latitude; - - /** - * 高程 - */ - @Schema(description = "高程") - private Integer altitude; - - /** - * 速度 - */ - @Schema(description = "速度") - private Integer speed; - - /** - * 方向 - */ - @Schema(description = "方向") - private Integer direction; - - /** - * 时间 - */ - @Schema(description = "时间") - private String time; - - /** - * 视频报警 - */ - @Schema(description = "视频报警") - private JTVideoAlarm videoAlarm; - - public JTAlarmSign getAlarmSign() { - return alarmSign; + public JTPositionBaseInfo getBase() { + return base; } - public void setAlarmSign(JTAlarmSign alarmSign) { - this.alarmSign = alarmSign; + public void setBase(JTPositionBaseInfo base) { + this.base = base; } - public JTStatus getStatus() { - return status; + public JTPositionAdditionalInfo getAdditional() { + return additional; } - public void setStatus(JTStatus status) { - this.status = status; - } - - public Double getLongitude() { - return longitude; - } - - public void setLongitude(Double longitude) { - this.longitude = longitude; - } - - public Double getLatitude() { - return latitude; - } - - public void setLatitude(Double latitude) { - this.latitude = latitude; - } - - public Integer getAltitude() { - return altitude; - } - - public void setAltitude(Integer altitude) { - this.altitude = altitude; - } - - public Integer getSpeed() { - return speed; - } - - public void setSpeed(Integer speed) { - this.speed = speed; - } - - public Integer getDirection() { - return direction; - } - - public void setDirection(Integer direction) { - this.direction = direction; - } - - public String getTime() { - return time; - } - - public void setTime(String time) { - this.time = time; - } - - public JTVideoAlarm getVideoAlarm() { - return videoAlarm; - } - - public void setVideoAlarm(JTVideoAlarm videoAlarm) { - this.videoAlarm = videoAlarm; - } - - @Override - public String toString() { - return "位置汇报信息: " + - " \n 报警标志:" + alarmSign.toString() + - " \n 状态:" + status.toString() + - " \n 经度:" + longitude + - " \n 纬度:" + latitude + - " \n 高程: " + altitude + - " \n 速度: " + speed + - " \n 方向: " + direction + - " \n 时间: " + time + - " \n"; + public void setAdditional(JTPositionAdditionalInfo additional) { + this.additional = additional; } } diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/request/J0200.java b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/request/J0200.java index 6e79e0cba..6347ce07a 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/request/J0200.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/request/J0200.java @@ -24,11 +24,11 @@ import org.springframework.context.ApplicationEvent; public class J0200 extends Re { private final static Logger log = LoggerFactory.getLogger(J0100.class); - private JTPositionInfo positionInfo; + private JTPositionBaseInfo positionInfo; @Override protected Rs decode0(ByteBuf buf, Header header, Session session) { - positionInfo = new JTPositionInfo(); + positionInfo = new JTPositionBaseInfo(); int alarmSignInt = buf.readInt(); positionInfo.setAlarmSign(new JTAlarmSign(alarmSignInt)); @@ -43,15 +43,18 @@ public class J0200 extends Re { byte[] timeBytes = new byte[6]; buf.readBytes(timeBytes); positionInfo.setTime(BCDUtil.transform(timeBytes)); - - // 支持1078的视频报警上报 - int alarm = buf.readInt(); - int loss = buf.readInt(); - int occlusion = buf.readInt(); - short storageFault = buf.readShort(); - short driving = buf.readShort(); - JTVideoAlarm videoAlarm = JTVideoAlarm.getInstance(alarm, loss, occlusion, storageFault, driving); - positionInfo.setVideoAlarm(videoAlarm); + boolean readable = buf.isReadable(); + // 读取附加信息 + if (buf.isReadable()) { + // 支持1078的视频报警上报 + int alarm = buf.readInt(); + int loss = buf.readInt(); + int occlusion = buf.readInt(); + short storageFault = buf.readShort(); + short driving = buf.readShort(); + JTVideoAlarm videoAlarm = JTVideoAlarm.getInstance(alarm, loss, occlusion, storageFault, driving); + positionInfo.setVideoAlarm(videoAlarm); + } log.info("[JT-位置汇报]: {}", positionInfo.toString()); return null; }