1. 修正无法发送协议问题
This commit is contained in:
parent
6fb4cce34d
commit
14665dc896
2
pom.xml
2
pom.xml
|
@ -10,7 +10,7 @@
|
|||
</parent>
|
||||
<groupId>com.cmhi</groupId>
|
||||
<artifactId>BeiDouPlatform</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.2</version>
|
||||
<name>BeiDouPlatform</name>
|
||||
<description>BeiDouPlatform</description>
|
||||
<properties>
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.zjyr.beidouservice.adapter.impl.netty.encode;
|
||||
|
||||
import com.zjyr.beidouservice.common.impl.ControlCommandName;
|
||||
import com.zjyr.beidouservice.config.CommonConfigure;
|
||||
import com.zjyr.beidouservice.misc.HelperUtils;
|
||||
import com.zjyr.beidouservice.pojo.vo.binary.BaseBinaryProtocol;
|
||||
import com.zjyr.beidouservice.pojo.vo.binary.HeartProtocol;
|
||||
|
@ -24,9 +23,6 @@ import java.io.UnsupportedEncodingException;
|
|||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class YuanRongProtocolEncode<T> extends MessageToByteEncoder<BaseBinaryProtocol<T>> {
|
||||
@Resource
|
||||
CommonConfigure commonConfigure;
|
||||
|
||||
@Resource
|
||||
DeviceService deviceService;
|
||||
|
||||
|
@ -91,9 +87,9 @@ public class YuanRongProtocolEncode<T> extends MessageToByteEncoder<BaseBinaryPr
|
|||
// 警报重复次数, 当前长度 13
|
||||
byteBuf.writeByte(msg.getRepeatTimes().byteValue());
|
||||
// 北斗ID, 当前长度 21
|
||||
byteBuf.writeLong(commonConfigure.getBeidouId());
|
||||
byteBuf.writeLong(msg.getBeidouCommunicationId());
|
||||
// 省ID, 当前长度 22(不含可变内容长度)
|
||||
byteBuf.writeByte(commonConfigure.getProviceCode().byteValue());
|
||||
byteBuf.writeByte(msg.getProviceCode().byteValue());
|
||||
// TTS 内容长度, 当前长度 24
|
||||
byteBuf.writeShort((short) ttsSize);
|
||||
if (ttsSize > 0) {
|
||||
|
|
|
@ -19,6 +19,8 @@ public class SensorControlProtocol {
|
|||
private Integer timeStamp;
|
||||
private Integer repeatTimes;
|
||||
private String ttsContent;
|
||||
private Integer proviceCode;
|
||||
private Long beidouCommunicationId;
|
||||
private List<Integer> cityCode;
|
||||
private List<Integer> districtsCode;
|
||||
private List<Integer> sensorId;
|
||||
|
|
|
@ -35,6 +35,7 @@ import com.zjyr.beidouservice.service.AdapterProtocolService;
|
|||
import com.zjyr.beidouservice.service.AlarmTaskService;
|
||||
import com.zjyr.beidouservice.service.BaidouAdapterService;
|
||||
import com.zjyr.beidouservice.service.DeviceService;
|
||||
import jakarta.annotation.Nullable;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -48,6 +49,7 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
|
@ -88,6 +90,8 @@ public class AlarmTaskServiceImpl implements AlarmTaskService {
|
|||
public MyResp alarmTaskExec(AlarmTaskReqDTO alarmTaskReqDTO) {
|
||||
//根据选择的省份、地市、区域或指定设备信息,获取执行任务的deviceId,provinceCode默认为null
|
||||
DeviceInfoDTO deviceInfo = getExecDeviceInfo(alarmTaskReqDTO);
|
||||
int ctrlChannel = Optional.ofNullable(alarmTaskReqDTO.getControlChannel())
|
||||
.orElse(SensorControlTunnelName.TUNNEL_ALL.getValue());
|
||||
|
||||
//生成规则为"JL"+"当前年月日"+"4位自增ID"
|
||||
String taskId = generateRecordNumber();
|
||||
|
@ -99,7 +103,7 @@ public class AlarmTaskServiceImpl implements AlarmTaskService {
|
|||
.alarmCounty(deviceInfo.getCountyCodes() == null ? " " : ListToString(deviceInfo.getCountyCodes()))
|
||||
.deviceIds(ListToString(deviceInfo.getDeviceIds()))
|
||||
.alarmMode(alarmTaskReqDTO.getAlarmMode())
|
||||
.controlChannel(alarmTaskReqDTO.getControlChannel())
|
||||
.controlChannel(ctrlChannel)
|
||||
.sender(alarmTaskReqDTO.getSender())
|
||||
.sendTime(alarmTaskReqDTO.getSendTime())
|
||||
.approvalStatus(ApprovalStatusEnum.APPROVAL_SUCCESS.getCode()).build();
|
||||
|
@ -119,7 +123,7 @@ public class AlarmTaskServiceImpl implements AlarmTaskService {
|
|||
CommonEnumHandler.codeOf(AlarmModeName.class, alarmTaskReqDTO.getAlarmMode()),
|
||||
CommonEnumHandler.codeOf(AlarmControlTypeName.class, alarmTaskReqDTO.getAlarmType()),
|
||||
CommonEnumHandler.codeOf(AlarmTypeName.class, alarmTaskReqDTO.getAlarmKind()),
|
||||
alarmTaskReqDTO.getControlChannel(),
|
||||
ctrlChannel,
|
||||
alarmTaskReqDTO.getSendTime(),
|
||||
0, null,
|
||||
deviceInfo.getCityCodes(),
|
||||
|
@ -267,37 +271,49 @@ public class AlarmTaskServiceImpl implements AlarmTaskService {
|
|||
List<AlarmDeviceTaskDO> alarmDeviceTaskDOS = new ArrayList<>();
|
||||
List<Integer> deviceIds = deviceInfo.getDeviceIds();
|
||||
|
||||
if (alarmTaskReqDTO.getControlChannel().equals(SensorControlTunnelName.TUNNEL_ALL.getValue())) {
|
||||
List<Integer> controlTunnel = new ArrayList<>();
|
||||
controlTunnel.add(SensorControlTunnelName.TUNNEL_BEIDOU.getValue());
|
||||
controlTunnel.add(SensorControlTunnelName.TUNNEL_WIRELESS.getValue());
|
||||
controlTunnel.add(SensorControlTunnelName.TUNNEL_TEL.getValue());
|
||||
deviceIds.forEach(dev -> {
|
||||
AlarmDeviceTaskDO task = new AlarmDeviceTaskDO();
|
||||
task.setTaskId(taskId);
|
||||
task.setDeviceId(dev);
|
||||
task.setControlChannel(SensorControlTunnelName.TUNNEL_ALL.getValue());
|
||||
task.setSendTime(alarmTaskReqDTO.getSendTime());
|
||||
task.setStatus(TaskStatusName.TASK_EXECUTING.getValue());
|
||||
|
||||
controlTunnel.forEach(v ->
|
||||
deviceIds.forEach(k -> {
|
||||
AlarmDeviceTaskDO task = new AlarmDeviceTaskDO();
|
||||
task.setTaskId(taskId);
|
||||
task.setDeviceId(k);
|
||||
task.setControlChannel(alarmTaskReqDTO.getControlChannel());
|
||||
task.setSendTime(alarmTaskReqDTO.getSendTime());
|
||||
task.setStatus(TaskStatusName.TASK_EXECUTING.getValue());
|
||||
alarmDeviceTaskDOS.add(task);
|
||||
});
|
||||
|
||||
alarmDeviceTaskDOS.add(task);
|
||||
}));
|
||||
// if (alarmTaskReqDTO.getControlChannel().equals(SensorControlTunnelName.TUNNEL_ALL.getValue())) {
|
||||
// List<Integer> controlTunnel = new ArrayList<>();
|
||||
// controlTunnel.add(SensorControlTunnelName.TUNNEL_BEIDOU.getValue());
|
||||
// controlTunnel.add(SensorControlTunnelName.TUNNEL_WIRELESS.getValue());
|
||||
// controlTunnel.add(SensorControlTunnelName.TUNNEL_TEL.getValue());
|
||||
//
|
||||
// controlTunnel.forEach(v ->
|
||||
// deviceIds.forEach(k -> {
|
||||
// AlarmDeviceTaskDO task = new AlarmDeviceTaskDO();
|
||||
// task.setTaskId(taskId);
|
||||
// task.setDeviceId(k);
|
||||
// task.setControlChannel(alarmTaskReqDTO.getControlChannel());
|
||||
// task.setSendTime(alarmTaskReqDTO.getSendTime());
|
||||
// task.setStatus(TaskStatusName.TASK_EXECUTING.getValue());
|
||||
//
|
||||
// alarmDeviceTaskDOS.add(task);
|
||||
// }));
|
||||
//
|
||||
// } else {
|
||||
// deviceIds.forEach(dev -> {
|
||||
// AlarmDeviceTaskDO task = new AlarmDeviceTaskDO();
|
||||
// task.setTaskId(taskId);
|
||||
// task.setDeviceId(dev);
|
||||
// task.setControlChannel(alarmTaskReqDTO.getControlChannel());
|
||||
// task.setSendTime(alarmTaskReqDTO.getSendTime());
|
||||
// task.setStatus(TaskStatusName.TASK_EXECUTING.getValue());
|
||||
//
|
||||
// alarmDeviceTaskDOS.add(task);
|
||||
// });
|
||||
//
|
||||
// }
|
||||
|
||||
} else {
|
||||
deviceIds.forEach(dev -> {
|
||||
AlarmDeviceTaskDO task = new AlarmDeviceTaskDO();
|
||||
task.setTaskId(taskId);
|
||||
task.setDeviceId(dev);
|
||||
task.setControlChannel(alarmTaskReqDTO.getControlChannel());
|
||||
task.setSendTime(alarmTaskReqDTO.getSendTime());
|
||||
task.setStatus(TaskStatusName.TASK_EXECUTING.getValue());
|
||||
|
||||
alarmDeviceTaskDOS.add(task);
|
||||
});
|
||||
|
||||
}
|
||||
return alarmDeviceTaskDOS;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,11 +3,13 @@ package com.zjyr.beidouservice.service.impl;
|
|||
import com.zjyr.beidouservice.common.impl.AlarmControlTypeName;
|
||||
import com.zjyr.beidouservice.common.impl.AlarmModeName;
|
||||
import com.zjyr.beidouservice.common.impl.AlarmTypeName;
|
||||
import com.zjyr.beidouservice.config.CommonConfigure;
|
||||
import com.zjyr.beidouservice.pojo.vo.binary.BaseBinaryProtocol;
|
||||
import com.zjyr.beidouservice.pojo.vo.binary.HeartProtocol;
|
||||
import com.zjyr.beidouservice.pojo.vo.binary.MessageContent;
|
||||
import com.zjyr.beidouservice.pojo.vo.binary.SensorControlProtocol;
|
||||
import com.zjyr.beidouservice.service.AdapterProtocolService;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -19,6 +21,9 @@ import java.util.List;
|
|||
@Service
|
||||
@Slf4j
|
||||
public class BeidouSocketProtocolServiceImpl implements AdapterProtocolService {
|
||||
@Resource
|
||||
CommonConfigure commonConfigure;
|
||||
|
||||
private int currentSeqId = 0;
|
||||
|
||||
@Override
|
||||
|
@ -39,6 +44,9 @@ public class BeidouSocketProtocolServiceImpl implements AdapterProtocolService {
|
|||
List<Integer> areas,
|
||||
List<Integer> sensors) {
|
||||
long timestamp = new Timestamp(alarmDt.getTime()).getTime() / 1000;
|
||||
|
||||
log.info("Current: proviceCode = {}, beidouId = {}", commonConfigure.getProviceCode(), commonConfigure.getBeidouId());
|
||||
|
||||
return SensorControlProtocol.builder()
|
||||
.taskId(taskId)
|
||||
.alarmMode(alarmMode)
|
||||
|
@ -48,6 +56,8 @@ public class BeidouSocketProtocolServiceImpl implements AdapterProtocolService {
|
|||
.timeStamp((int) timestamp)
|
||||
.repeatTimes(repeatTimes)
|
||||
.ttsContent(ttsText)
|
||||
.proviceCode(commonConfigure.getProviceCode())
|
||||
.beidouCommunicationId(commonConfigure.getBeidouId())
|
||||
.cityCode(citys == null ? new ArrayList<>() : citys)
|
||||
.districtsCode(areas == null ? new ArrayList<>() : citys)
|
||||
.sensorId(sensors == null ? new ArrayList<>() : citys)
|
||||
|
|
Loading…
Reference in New Issue