1078-人工确认报警消息+链路检测

This commit is contained in:
648540858
2024-05-01 10:05:33 +08:00
parent eb43ffd98f
commit e5acf7f1e4
9 changed files with 192 additions and 4 deletions

View File

@@ -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 +
'}';
}
}

View File

@@ -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);
}
}

View File

@@ -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<Integer> linkDetection(String deviceId){
logger.info("[1078-链路检测] deviceId: {}", deviceId);
int result = service.linkDetection(deviceId);
if (result == 0) {
return WVPResult.success(result);
}else {
WVPResult<Integer> fail = WVPResult.fail(ErrorCode.ERROR100);
fail.setData(result);
return fail;
}
}
}

View File

@@ -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 +
'}';
}
}

View File

@@ -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

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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);
}

View File

@@ -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);
}
}