From 7c833f3d129e7f5741a5654566da76f0d278a697 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 1 May 2024 15:07:38 +0800 Subject: [PATCH] =?UTF-8?q?1078-=E6=96=87=E6=9C=AC=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E4=B8=8B=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/jt1078/bean/JTTextSign.java | 69 +++++++++++++++++++ .../iot/vmp/jt1078/cmd/JT1078Template.java | 12 ++++ .../jt1078/controller/JT1078Controller.java | 17 +++++ .../controller/bean/TextMessageParam.java | 63 +++++++++++++++++ .../iot/vmp/jt1078/proc/response/J8300.java | 63 +++++++++++++++++ .../vmp/jt1078/service/Ijt1078Service.java | 2 + .../service/impl/jt1078ServiceImpl.java | 10 +++ 7 files changed, 236 insertions(+) create mode 100644 src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTTextSign.java create mode 100644 src/main/java/com/genersoft/iot/vmp/jt1078/controller/bean/TextMessageParam.java create mode 100644 src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8300.java diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTTextSign.java b/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTTextSign.java new file mode 100644 index 000000000..ca3dfac6a --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTTextSign.java @@ -0,0 +1,69 @@ +package com.genersoft.iot.vmp.jt1078.bean; + +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * 文本信息标志 + */ +@Schema(description = "文本信息标志") +public class JTTextSign { + + @Schema(description = "01服务,2紧急,3通知") + private int type; + + @Schema(description = "1终端显示器显示") + private boolean terminalDisplay; + + @Schema(description = "1终端 TTS 播读") + private boolean tts; + + @Schema(description = "false: 中心导航信息 true CAN故障码信息") + private boolean source; + + public byte encode(){ + byte bytes = 0; + bytes |= (byte) type; + if (terminalDisplay) { + bytes |= (0x1 << 2); + } + if (tts) { + bytes |= (0x1 << 3); + } + if (source) { + bytes |= (0x1 << 5); + } + return bytes; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public boolean isTerminalDisplay() { + return terminalDisplay; + } + + public void setTerminalDisplay(boolean terminalDisplay) { + this.terminalDisplay = terminalDisplay; + } + + public boolean isTts() { + return tts; + } + + public void setTts(boolean tts) { + this.tts = tts; + } + + public boolean isSource() { + return source; + } + + public void setSource(boolean source) { + this.source = source; + } +} 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 cd4dc978c..1053d4a73 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 @@ -26,6 +26,7 @@ public class JT1078Template { private static final String H8202 = "8202"; private static final String H8203 = "8203"; private static final String H8204 = "8204"; + private static final String H8300 = "8300"; private static final String H9101 = "9101"; private static final String H9102 = "9102"; private static final String H9201 = "9201"; @@ -396,4 +397,15 @@ public class JT1078Template { .build(); return SessionManager.INSTANCE.request(cmd, timeOut); } + + public Object textMessage(String devId, J8300 j8300, int timeOut) { + Cmd cmd = new Cmd.Builder() + .setDevId(devId) + .setPackageNo(randomInt()) + .setMsgId(H8300) + .setRespId(H0001) + .setRs(j8300) + .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 ea06a6cf5..fbeb053f6 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 @@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.conf.security.JwtUtils; import com.genersoft.iot.vmp.jt1078.bean.*; import com.genersoft.iot.vmp.jt1078.controller.bean.ConfirmationAlarmMessageParam; import com.genersoft.iot.vmp.jt1078.controller.bean.ConnectionControlParam; +import com.genersoft.iot.vmp.jt1078.controller.bean.TextMessageParam; import com.genersoft.iot.vmp.jt1078.proc.request.J1205; import com.genersoft.iot.vmp.jt1078.service.Ijt1078Service; import com.genersoft.iot.vmp.service.bean.InviteErrorCode; @@ -414,5 +415,21 @@ public class JT1078Controller { } } + @Operation(summary = "文本信息下发", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "textMessageParam", description = "文本信息下发参数", required = true) + @PostMapping("/text-msg") + public WVPResult textMessage(@RequestBody TextMessageParam textMessageParam){ + + logger.info("[1078-文本信息下发] textMessageParam: {}", textMessageParam); + int result = service.textMessage(textMessageParam.getDeviceId(), textMessageParam.getSign(), textMessageParam.getTextType(), textMessageParam.getContent()); + 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/TextMessageParam.java b/src/main/java/com/genersoft/iot/vmp/jt1078/controller/bean/TextMessageParam.java new file mode 100644 index 000000000..f155c8c3a --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/controller/bean/TextMessageParam.java @@ -0,0 +1,63 @@ +package com.genersoft.iot.vmp.jt1078.controller.bean; + +import com.genersoft.iot.vmp.jt1078.bean.JConfirmationAlarmMessageType; +import com.genersoft.iot.vmp.jt1078.bean.JTTextSign; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * 文本信息下发参数 + */ +@Schema(description = "人工确认报警消息参数") +public class TextMessageParam { + + @Schema(description = "设备") + private String deviceId; + @Schema(description = "标志") + private JTTextSign sign; + @Schema(description = "文本类型,1 = 通知 ,2 = 服务") + private int textType; + @Schema(description = "消息内容,最长为1024字节") + private String content; + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + public int getTextType() { + return textType; + } + + public void setTextType(int textType) { + this.textType = textType; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public JTTextSign getSign() { + return sign; + } + + public void setSign(JTTextSign sign) { + this.sign = sign; + } + + @Override + public String toString() { + return "TextMessageParam{" + + "deviceId='" + deviceId + '\'' + + ", sign=" + sign + + ", textType=" + textType + + ", content='" + content + '\'' + + '}'; + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8300.java b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8300.java new file mode 100644 index 000000000..1994c2bdf --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8300.java @@ -0,0 +1,63 @@ +package com.genersoft.iot.vmp.jt1078.proc.response; + +import com.genersoft.iot.vmp.jt1078.annotation.MsgId; +import com.genersoft.iot.vmp.jt1078.bean.JTTextSign; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; + +import java.nio.charset.Charset; + +/** + * 文本信息下发 + */ +@MsgId(id = "8300") +public class J8300 extends Rs { + + /** + * 标志 + */ + private JTTextSign sign; + + /** + * 文本类型1 = 通知 ,2 = 服务 + */ + private int textType; + + /** + * 文本信息 + */ + private String content; + + @Override + public ByteBuf encode() { + ByteBuf buffer = Unpooled.buffer(); + buffer.writeByte(sign.encode()); + buffer.writeByte(textType); + buffer.writeCharSequence(content, Charset.forName("GBK")); + return buffer; + } + + public JTTextSign getSign() { + return sign; + } + + public void setSign(JTTextSign sign) { + this.sign = sign; + } + + public int getTextType() { + return textType; + } + + public void setTextType(int textType) { + this.textType = textType; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } +} 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 a219edaf9..b5f90f296 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 @@ -61,4 +61,6 @@ public interface Ijt1078Service { void confirmationAlarmMessage(String deviceId, int alarmPackageNo, JConfirmationAlarmMessageType alarmMessageType); int linkDetection(String deviceId); + + int textMessage(String deviceId,JTTextSign sign, int textType, String content); } 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 dd9c0e72b..aa55ce947 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 @@ -573,4 +573,14 @@ public class jt1078ServiceImpl implements Ijt1078Service { J8204 j8204 = new J8204(); return (int)jt1078Template.linkDetection(deviceId, j8204, 6); } + + @Override + public int textMessage(String deviceId, JTTextSign sign, int textType, String content) { + J8300 j8300 = new J8300(); + j8300.setSign(sign); + j8300.setTextType(textType); + j8300.setContent(content); + return (int)jt1078Template.textMessage(deviceId, j8300, 6); + } + }