From e5acf7f1e45a787514e7a8a3f634e09032958a31 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 1 May 2024 10:05:33 +0800 Subject: [PATCH] =?UTF-8?q?1078-=E4=BA=BA=E5=B7=A5=E7=A1=AE=E8=AE=A4?= =?UTF-8?q?=E6=8A=A5=E8=AD=A6=E6=B6=88=E6=81=AF+=E9=93=BE=E8=B7=AF?= =?UTF-8?q?=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bean/JConfirmationAlarmMessageType.java | 41 +++++++++++++++- .../iot/vmp/jt1078/cmd/JT1078Template.java | 24 +++++++++ .../jt1078/controller/JT1078Controller.java | 20 +++++++- .../bean/ConfirmationAlarmMessageParam.java | 21 +++++++- .../iot/vmp/jt1078/proc/request/J0001.java | 3 ++ .../iot/vmp/jt1078/proc/response/J8203.java | 49 +++++++++++++++++++ .../iot/vmp/jt1078/proc/response/J8204.java | 19 +++++++ .../vmp/jt1078/service/Ijt1078Service.java | 5 ++ .../service/impl/jt1078ServiceImpl.java | 14 ++++++ 9 files changed, 192 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8203.java create mode 100644 src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8204.java diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JConfirmationAlarmMessageType.java b/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JConfirmationAlarmMessageType.java index 804c718e8..d85b3cd4c 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JConfirmationAlarmMessageType.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JConfirmationAlarmMessageType.java @@ -2,8 +2,9 @@ package com.genersoft.iot.vmp.jt1078.bean; import io.swagger.v3.oas.annotations.media.Schema; +@Schema(description = "人工确认报警类型") public class JConfirmationAlarmMessageType { - @Schema(description = "确认紧急报警 ;") + @Schema(description = "确认紧急报警") private boolean urgent; @Schema(description = "确认危险预警") private boolean alarmDangerous; @@ -18,6 +19,31 @@ public class JConfirmationAlarmMessageType { @Schema(description = "确认车辆非法位移报警") private boolean alarmIllegalDisplacement; + public long encode(){ + long result = 0L; + if (urgent) { + result |= 0x01; + } + if (alarmDangerous) { + result |= (0x01 << 3); + } + if (alarmRegion) { + result |= (0x01 << 20); + } + if (alarmRoute) { + result |= (0x01 << 21); + } + if (alarmTravelTime) { + result |= (0x01 << 22); + } + if (alarmIllegalIgnition) { + result |= (0x01 << 27); + } + if (alarmIllegalDisplacement) { + result |= (0x01 << 28); + } + return result; + } public boolean isUrgent() { @@ -75,4 +101,17 @@ public class JConfirmationAlarmMessageType { public void setAlarmIllegalDisplacement(boolean alarmIllegalDisplacement) { this.alarmIllegalDisplacement = alarmIllegalDisplacement; } + + @Override + public String toString() { + return "JConfirmationAlarmMessageType{" + + "urgent=" + urgent + + ", alarmDangerous=" + alarmDangerous + + ", alarmRegion=" + alarmRegion + + ", alarmRoute=" + alarmRoute + + ", alarmTravelTime=" + alarmTravelTime + + ", alarmIllegalIgnition=" + alarmIllegalIgnition + + ", alarmIllegalDisplacement=" + alarmIllegalDisplacement + + '}'; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/cmd/JT1078Template.java b/src/main/java/com/genersoft/iot/vmp/jt1078/cmd/JT1078Template.java index 9830350af..cd4dc978c 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/cmd/JT1078Template.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/cmd/JT1078Template.java @@ -24,6 +24,8 @@ public class JT1078Template { private static final String H8107 = "8107"; private static final String H8201 = "8201"; private static final String H8202 = "8202"; + private static final String H8203 = "8203"; + private static final String H8204 = "8204"; private static final String H9101 = "9101"; private static final String H9102 = "9102"; private static final String H9201 = "9201"; @@ -372,4 +374,26 @@ public class JT1078Template { .build(); return SessionManager.INSTANCE.request(cmd, timeOut); } + + public Object confirmationAlarmMessage(String devId, J8203 j8203, int timeOut) { + Cmd cmd = new Cmd.Builder() + .setDevId(devId) + .setPackageNo(randomInt()) + .setMsgId(H8203) + .setRespId(H0001) + .setRs(j8203) + .build(); + return SessionManager.INSTANCE.request(cmd, timeOut); + } + + public Object linkDetection(String devId, J8204 j8204, int timeOut) { + Cmd cmd = new Cmd.Builder() + .setDevId(devId) + .setPackageNo(randomInt()) + .setMsgId(H8204) + .setRespId(H0001) + .setRs(j8204) + .build(); + return SessionManager.INSTANCE.request(cmd, timeOut); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/controller/JT1078Controller.java b/src/main/java/com/genersoft/iot/vmp/jt1078/controller/JT1078Controller.java index 6b3daddab..ea06a6cf5 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/controller/JT1078Controller.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/controller/JT1078Controller.java @@ -394,8 +394,24 @@ public class JT1078Controller { @PostMapping("/confirmation-alarm-message") public void confirmationAlarmMessage(@RequestBody ConfirmationAlarmMessageParam param){ - logger.info("[1078-人工确认报警消息] deviceId: {}, 时间间隔 {}秒, 位置跟踪有效期 {}秒", deviceId, timeInterval, validityPeriod); - service.confirmationAlarmMessage(param.getDeviceId(), param.getAlarmMessageType()); + logger.info("[1078-人工确认报警消息] 参数: {}", param); + service.confirmationAlarmMessage(param.getDeviceId(), param.getAlarmPackageNo(), param.getAlarmMessageType()); + } + + @Operation(summary = "链路检测", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "deviceId", description = "设备编号", required = true) + @GetMapping("/link-detection") + public WVPResult linkDetection(String deviceId){ + + logger.info("[1078-链路检测] deviceId: {}", deviceId); + int result = service.linkDetection(deviceId); + if (result == 0) { + return WVPResult.success(result); + }else { + WVPResult fail = WVPResult.fail(ErrorCode.ERROR100); + fail.setData(result); + return fail; + } } } diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/controller/bean/ConfirmationAlarmMessageParam.java b/src/main/java/com/genersoft/iot/vmp/jt1078/controller/bean/ConfirmationAlarmMessageParam.java index 1329fe8e7..8f3ad35f8 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/controller/bean/ConfirmationAlarmMessageParam.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/controller/bean/ConfirmationAlarmMessageParam.java @@ -8,10 +8,12 @@ import io.swagger.v3.oas.annotations.media.Schema; */ @Schema(description = "人工确认报警消息参数") public class ConfirmationAlarmMessageParam { + @Schema(description = "设备") private String deviceId; @Schema(description = "报警消息流水号") - private int deviceId; + private int alarmPackageNo; + @Schema(description = "人工确认报警类型") private JConfirmationAlarmMessageType alarmMessageType; public String getDeviceId() { @@ -29,4 +31,21 @@ public class ConfirmationAlarmMessageParam { public void setAlarmMessageType(JConfirmationAlarmMessageType alarmMessageType) { this.alarmMessageType = alarmMessageType; } + + public int getAlarmPackageNo() { + return alarmPackageNo; + } + + public void setAlarmPackageNo(int alarmPackageNo) { + this.alarmPackageNo = alarmPackageNo; + } + + @Override + public String toString() { + return "ConfirmationAlarmMessageParam{" + + "deviceId='" + deviceId + '\'' + + ", alarmPackageNo=" + alarmPackageNo + + ", alarmMessageType=" + alarmMessageType + + '}'; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/request/J0001.java b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/request/J0001.java index b7a3c6cf9..2036c444c 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/request/J0001.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/request/J0001.java @@ -22,6 +22,9 @@ import org.springframework.context.ApplicationEvent; public class J0001 extends Re { int respNo; String respId; + /** + * 0:成功/确认;1:失败;2:消息有误;3:不支持 + */ int result; @Override diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8203.java b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8203.java new file mode 100644 index 000000000..71ebc4346 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8203.java @@ -0,0 +1,49 @@ +package com.genersoft.iot.vmp.jt1078.proc.response; + +import com.genersoft.iot.vmp.jt1078.annotation.MsgId; +import com.genersoft.iot.vmp.jt1078.bean.JConfirmationAlarmMessageType; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * 人工确认报警消息 + */ +@MsgId(id = "8203") +public class J8203 extends Rs { + + /** + * 报警消息流水号 + */ + private int alarmPackageNo; + /** + * 人工确认报警类型 + */ + private JConfirmationAlarmMessageType alarmMessageType; + + @Override + public ByteBuf encode() { + ByteBuf buffer = Unpooled.buffer(); + buffer.writeShort((short)(alarmPackageNo & 0xffff)); + if (alarmMessageType != null) { + buffer.writeInt((int) (alarmMessageType.encode() & 0xffffffffL)); + } + return buffer; + } + + public int getAlarmPackageNo() { + return alarmPackageNo; + } + + public void setAlarmPackageNo(int alarmPackageNo) { + this.alarmPackageNo = alarmPackageNo; + } + + public JConfirmationAlarmMessageType getAlarmMessageType() { + return alarmMessageType; + } + + public void setAlarmMessageType(JConfirmationAlarmMessageType alarmMessageType) { + this.alarmMessageType = alarmMessageType; + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8204.java b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8204.java new file mode 100644 index 000000000..51eb73f2d --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8204.java @@ -0,0 +1,19 @@ +package com.genersoft.iot.vmp.jt1078.proc.response; + +import com.genersoft.iot.vmp.jt1078.annotation.MsgId; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; + +/** + * 链路检测 + */ +@MsgId(id = "8204") +public class J8204 extends Rs { + + @Override + public ByteBuf encode() { + ByteBuf buffer = Unpooled.buffer(); + return buffer; + } + +} diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/service/Ijt1078Service.java b/src/main/java/com/genersoft/iot/vmp/jt1078/service/Ijt1078Service.java index f1f314879..a219edaf9 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/service/Ijt1078Service.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/service/Ijt1078Service.java @@ -4,6 +4,7 @@ import com.genersoft.iot.vmp.common.GeneralCallback; import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.jt1078.bean.*; import com.genersoft.iot.vmp.jt1078.proc.request.J1205; +import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import com.github.pagehelper.PageInfo; import java.util.List; @@ -56,4 +57,8 @@ public interface Ijt1078Service { JTPositionBaseInfo queryPositionInfo(String deviceId); void tempPositionTrackingControl(String deviceId, Integer timeInterval, Long validityPeriod); + + void confirmationAlarmMessage(String deviceId, int alarmPackageNo, JConfirmationAlarmMessageType alarmMessageType); + + int linkDetection(String deviceId); } diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/service/impl/jt1078ServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/jt1078/service/impl/jt1078ServiceImpl.java index b0b3ac9cc..dd9c0e72b 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/service/impl/jt1078ServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/service/impl/jt1078ServiceImpl.java @@ -559,4 +559,18 @@ public class jt1078ServiceImpl implements Ijt1078Service { j8202.setValidityPeriod(validityPeriod); jt1078Template.tempPositionTrackingControl(deviceId, j8202, 20); } + + @Override + public void confirmationAlarmMessage(String deviceId, int alarmPackageNo, JConfirmationAlarmMessageType alarmMessageType) { + J8203 j8203 = new J8203(); + j8203.setAlarmMessageType(alarmMessageType); + j8203.setAlarmPackageNo(alarmPackageNo); + jt1078Template.confirmationAlarmMessage(deviceId, j8203, 6); + } + + @Override + public int linkDetection(String deviceId) { + J8204 j8204 = new J8204(); + return (int)jt1078Template.linkDetection(deviceId, j8204, 6); + } }