1. 增加指定警报播放重复次数

2. 增加支持下发TTS文本
This commit is contained in:
HuangXin 2023-09-01 17:53:34 +08:00
parent 0df845132d
commit d29ed06a94
6 changed files with 34 additions and 2 deletions

View File

@ -13,12 +13,17 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
@Component @Component
@RequiredArgsConstructor @RequiredArgsConstructor
@Slf4j @Slf4j
public class YuanRongProtocolEncode<T> extends MessageToByteEncoder<BaseBinaryProtocol<T>> { public class YuanRongProtocolEncode<T> extends MessageToByteEncoder<BaseBinaryProtocol<T>> {
@Override @Override
protected void encode(ChannelHandlerContext channelHandlerContext, BaseBinaryProtocol<T> baseBinaryProtocol, ByteBuf byteBuf) { protected void encode(ChannelHandlerContext channelHandlerContext,
BaseBinaryProtocol<T> baseBinaryProtocol,
ByteBuf byteBuf) throws UnsupportedEncodingException {
if (baseBinaryProtocol == null || baseBinaryProtocol.getMsgContent() == null || if (baseBinaryProtocol == null || baseBinaryProtocol.getMsgContent() == null ||
baseBinaryProtocol.getMsgContent().getMsgBody() == null) { baseBinaryProtocol.getMsgContent().getMsgBody() == null) {
@ -37,15 +42,31 @@ public class YuanRongProtocolEncode<T> extends MessageToByteEncoder<BaseBinaryPr
byteBuf.writeShort(4); // 消息内容长度 byteBuf.writeShort(4); // 消息内容长度
byteBuf.writeInt(heartProtocol.getSeqId()); byteBuf.writeInt(heartProtocol.getSeqId());
} else if (msgBody instanceof SensorControlProtocol msg) { } else if (msgBody instanceof SensorControlProtocol msg) {
int ttsSize;
byte[] ttsArray = new byte[0];
if (msg.getTtsContent() != null && !msg.getTtsContent().isEmpty()) {
ttsArray = msg.getTtsContent().getBytes(StandardCharsets.UTF_16BE);
ttsSize = ttsArray.length;
} else {
ttsSize = 0;
}
byteBuf.writeByte(ControlCommandName.COMMAND_SENSOR.getValue().byteValue()); // 消息类型 byteBuf.writeByte(ControlCommandName.COMMAND_SENSOR.getValue().byteValue()); // 消息类型
// 消息内容长度 // 消息内容长度
byteBuf.writeShort(10 + 3 + msg.getCityCode().size() + msg.getDistrictsCode().size() + msg.getSensorId().size() * 4); byteBuf.writeShort(10 + 4 + ttsSize + msg.getCityCode().size() + msg.getDistrictsCode().size() + msg.getSensorId().size() * 4);
byteBuf.writeInt(msg.getTaskId()); byteBuf.writeInt(msg.getTaskId());
byteBuf.writeByte(msg.getAlarmMode().getValue().byteValue()); byteBuf.writeByte(msg.getAlarmMode().getValue().byteValue());
byteBuf.writeByte(msg.getAlarmMode().getValue().byteValue()); byteBuf.writeByte(msg.getAlarmMode().getValue().byteValue());
byteBuf.writeByte(msg.getAlarmType().getValue().byteValue()); byteBuf.writeByte(msg.getAlarmType().getValue().byteValue());
byteBuf.writeByte(msg.getControlTunnel().byteValue()); byteBuf.writeByte(msg.getControlTunnel().byteValue());
byteBuf.writeInt(msg.getTimeStamp()); byteBuf.writeInt(msg.getTimeStamp());
byteBuf.writeByte(msg.getRepeatTimes().byteValue());
byteBuf.writeShort((short) ttsSize);
if(ttsSize > 0) {
byteBuf.writeBytes(ttsArray);
}
if (msg.getCityCode().isEmpty()) { if (msg.getCityCode().isEmpty()) {
byteBuf.writeByte(0); byteBuf.writeByte(0);

View File

@ -56,6 +56,8 @@ public class AuthUser {
SensorControlTunnelName.TUNNEL_BEIDOU.getValue() | SensorControlTunnelName.TUNNEL_BEIDOU.getValue() |
SensorControlTunnelName.TUNNEL_WIRELESS.getValue(), SensorControlTunnelName.TUNNEL_WIRELESS.getValue(),
strtodate, strtodate,
0,
null,
new ArrayList<>(), new ArrayList<>(),
new ArrayList<>(), new ArrayList<>(),
new ArrayList<>(Arrays.asList(0, 1, 2, 3))); new ArrayList<>(Arrays.asList(0, 1, 2, 3)));

View File

@ -17,6 +17,8 @@ public class SensorControlProtocol {
private AlarmTypeName alarmType; private AlarmTypeName alarmType;
private Integer controlTunnel; private Integer controlTunnel;
private Integer timeStamp; private Integer timeStamp;
private Integer repeatTimes;
private String ttsContent;
private List<Integer> cityCode; private List<Integer> cityCode;
private List<Integer> districtsCode; private List<Integer> districtsCode;
private List<Integer> sensorId; private List<Integer> sensorId;

View File

@ -18,6 +18,8 @@ public interface AdapterProtocolService {
AlarmTypeName alarmType, AlarmTypeName alarmType,
int tunnelName, int tunnelName,
Date alarmDt, Date alarmDt,
int repeatTimes,
String ttsText,
List<Integer> citys, List<Integer> citys,
List<Integer> areas, List<Integer> areas,
List<Integer> sensors); List<Integer> sensors);

View File

@ -121,6 +121,7 @@ public class AlarmTaskServiceImpl implements AlarmTaskService {
CommonEnumHandler.codeOf(AlarmTypeName.class, alarmTaskReqDTO.getAlarmKind()), CommonEnumHandler.codeOf(AlarmTypeName.class, alarmTaskReqDTO.getAlarmKind()),
alarmTaskReqDTO.getControlChannel(), alarmTaskReqDTO.getControlChannel(),
alarmTaskReqDTO.getSendTime(), alarmTaskReqDTO.getSendTime(),
0, null,
deviceInfo.getCityCodes(), deviceInfo.getCityCodes(),
deviceInfo.getCountyCodes(), deviceInfo.getCountyCodes(),
deviceInfo.getBeidouIds() deviceInfo.getBeidouIds()

View File

@ -33,6 +33,8 @@ public class BeidouSocketProtocolServiceImpl implements AdapterProtocolService {
AlarmTypeName alarmType, AlarmTypeName alarmType,
int tunnelName, int tunnelName,
Date alarmDt, Date alarmDt,
int repeatTimes,
String ttsText,
List<Integer> citys, List<Integer> citys,
List<Integer> areas, List<Integer> areas,
List<Integer> sensors) { List<Integer> sensors) {
@ -44,6 +46,8 @@ public class BeidouSocketProtocolServiceImpl implements AdapterProtocolService {
.alarmType(alarmType) .alarmType(alarmType)
.controlTunnel(tunnelName) .controlTunnel(tunnelName)
.timeStamp((int) timestamp) .timeStamp((int) timestamp)
.repeatTimes(repeatTimes)
.ttsContent(ttsText)
.cityCode(citys == null ? new ArrayList<>() : citys) .cityCode(citys == null ? new ArrayList<>() : citys)
.districtsCode(areas == null ? new ArrayList<>() : citys) .districtsCode(areas == null ? new ArrayList<>() : citys)
.sensorId(sensors == null ? new ArrayList<>() : citys) .sensorId(sensors == null ? new ArrayList<>() : citys)