1078-文本信息下发

This commit is contained in:
648540858
2024-05-01 15:07:38 +08:00
parent e5acf7f1e4
commit 7c833f3d12
7 changed files with 236 additions and 0 deletions

View File

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

View File

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

View File

@@ -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<Integer> 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<Integer> fail = WVPResult.fail(ErrorCode.ERROR100);
fail.setData(result);
return fail;
}
}
}

View File

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

View File

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

View File

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

View File

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