parent
5503523a0c
commit
d97abd5e16
|
@ -1,4 +1,4 @@
|
||||||
socket.server-host=localhost
|
socket.server-host=localhost
|
||||||
socket.server-port=10000
|
socket.server-port=10001
|
||||||
socket.server-mode=tcp
|
socket.server-mode=tcp
|
||||||
socket.heart-timeout=60
|
socket.heart-timeout=60
|
||||||
|
|
|
@ -30,10 +30,7 @@ public class MessageHandler<T> extends SimpleChannelInboundHandler<BaseBinaryPro
|
||||||
if (evt instanceof IdleStateEvent idleStateEvent) {
|
if (evt instanceof IdleStateEvent idleStateEvent) {
|
||||||
if (idleStateEvent.state() == IdleState.ALL_IDLE) {
|
if (idleStateEvent.state() == IdleState.ALL_IDLE) {
|
||||||
log.info("{}:: Trigger Heart Signe", ctx.channel().id());
|
log.info("{}:: Trigger Heart Signe", ctx.channel().id());
|
||||||
SocketNotifyEvent notify = new SocketNotifyEvent(this,
|
SocketNotifyEvent notify = new SocketNotifyEvent(this, ctx.channel(), SocketEventName.SOCKET_EVT_IDLE_TIMEOUT, null);
|
||||||
ctx.channel(),
|
|
||||||
SocketEventName.SOCKET_EVT_IDLE_TIMEOUT,
|
|
||||||
null);
|
|
||||||
applicationEventPublisher.publishEvent(notify);
|
applicationEventPublisher.publishEvent(notify);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -42,7 +39,7 @@ public class MessageHandler<T> extends SimpleChannelInboundHandler<BaseBinaryPro
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void channelRead0(ChannelHandlerContext ctx, BaseBinaryProtocol<T> message) throws Exception {
|
public void channelRead0(ChannelHandlerContext ctx, BaseBinaryProtocol<T> message) {
|
||||||
SocketNotifyEvent notify = new SocketNotifyEvent(this,
|
SocketNotifyEvent notify = new SocketNotifyEvent(this,
|
||||||
ctx.channel(),
|
ctx.channel(),
|
||||||
message.getTimeStamp(),
|
message.getTimeStamp(),
|
||||||
|
@ -68,10 +65,7 @@ public class MessageHandler<T> extends SimpleChannelInboundHandler<BaseBinaryPro
|
||||||
super.channelInactive(ctx);
|
super.channelInactive(ctx);
|
||||||
ctx.close();
|
ctx.close();
|
||||||
|
|
||||||
SocketNotifyEvent notify = new SocketNotifyEvent(this,
|
SocketNotifyEvent notify = new SocketNotifyEvent(this, ctx.channel(), SocketEventName.SOCKET_EVT_DISCONNECT, null);
|
||||||
ctx.channel(),
|
|
||||||
SocketEventName.SOCKET_EVT_DISCONNECT,
|
|
||||||
null);
|
|
||||||
applicationEventPublisher.publishEvent(notify);
|
applicationEventPublisher.publishEvent(notify);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,141 +33,141 @@ public class YuanRongProtocolDecode extends ByteToMessageDecoder {
|
||||||
protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf buf, List<Object> list) {
|
protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf buf, List<Object> list) {
|
||||||
log.info("\n{}", ByteBufUtil.prettyHexDump(buf));
|
log.info("\n{}", ByteBufUtil.prettyHexDump(buf));
|
||||||
try {
|
try {
|
||||||
short msgLength = buf.readShort();
|
short msgLength = buf.readShort();
|
||||||
byte version = buf.readByte();
|
byte version = buf.readByte();
|
||||||
byte cryptCytp = buf.readByte();
|
byte cryptCytp = buf.readByte();
|
||||||
int timeStamp = buf.readInt();
|
int timeStamp = buf.readInt();
|
||||||
int statusCode = buf.readInt();
|
int statusCode = buf.readInt();
|
||||||
byte msgType = buf.readByte();
|
byte msgType = buf.readByte();
|
||||||
short msgSize = buf.readShort();
|
short msgSize = buf.readShort();
|
||||||
|
|
||||||
ControlCommandName cmd = CommonEnumHandler.codeOf(ControlCommandName.class, msgType);
|
ControlCommandName cmd = CommonEnumHandler.codeOf(ControlCommandName.class, msgType);
|
||||||
if (cmd != null) {
|
if (cmd != null) {
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case COMMAND_REPORT_HEART -> {
|
case COMMAND_REPORT_HEART -> {
|
||||||
SendStatusName sendStatus = CommonEnumHandler.codeOf(SendStatusName.class, buf.readByte());
|
int heartSeq = buf.readInt();
|
||||||
ControlChannelStatus beidouStatus = CommonEnumHandler.codeOf(ControlChannelStatus.class,
|
SendStatusName sendStatus = CommonEnumHandler.codeOf(SendStatusName.class, buf.readByte());
|
||||||
buf.readByte());
|
ControlChannelStatus beidouStatus = CommonEnumHandler.codeOf(ControlChannelStatus.class, buf.readByte());
|
||||||
byte[] beidouCommFreq = new byte[3];
|
byte[] beidouCommFreq = new byte[3];
|
||||||
buf.readBytes(beidouCommFreq, 0, 3);
|
buf.readBytes(beidouCommFreq, 0, 3);
|
||||||
byte[] beidouSignal = new byte[10];
|
byte[] beidouSignal = new byte[10];
|
||||||
buf.readBytes(beidouSignal, 0, 10);
|
buf.readBytes(beidouSignal, 0, 10);
|
||||||
ControlChannelStatus wireStatus = CommonEnumHandler.codeOf(ControlChannelStatus.class,
|
ControlChannelStatus wireStatus = CommonEnumHandler.codeOf(ControlChannelStatus.class, buf.readByte());
|
||||||
buf.readByte());
|
ControlChannelStatus phoneStatus = CommonEnumHandler.codeOf(ControlChannelStatus.class, buf.readByte());
|
||||||
ControlChannelStatus phoneStatus = CommonEnumHandler.codeOf(ControlChannelStatus.class,
|
|
||||||
buf.readByte());
|
|
||||||
|
|
||||||
ControllerStatus status = ControllerStatus.builder()
|
ControllerStatus status = ControllerStatus.builder()
|
||||||
.sendStatus(sendStatus)
|
.heartSeq(heartSeq)
|
||||||
.beidouStatus(beidouStatus)
|
.sendStatus(sendStatus)
|
||||||
.beidouFreq(beidouCommFreq)
|
.beidouStatus(beidouStatus)
|
||||||
.beidouSignalStrength(beidouSignal)
|
.beidouFreq(beidouCommFreq)
|
||||||
.wirelessStatus(wireStatus)
|
.beidouSignalStrength(beidouSignal)
|
||||||
.telphoneStatus(phoneStatus)
|
.wirelessStatus(wireStatus)
|
||||||
.build();
|
.telphoneStatus(phoneStatus)
|
||||||
|
.build();
|
||||||
|
|
||||||
MessageContent<ControllerStatus> msgCtx = MessageContent.<ControllerStatus>builder().msgType(
|
MessageContent<ControllerStatus> msgCtx = MessageContent.<ControllerStatus>builder().msgType(msgType).msgSize(
|
||||||
msgType).msgSize(msgSize).msgBody(status).build();
|
msgSize).msgBody(status).build();
|
||||||
|
|
||||||
list.add(BaseBinaryProtocol.<ControllerStatus>builder()
|
list.add(BaseBinaryProtocol.<ControllerStatus>builder()
|
||||||
.msgLength(msgLength)
|
.msgLength(msgLength)
|
||||||
.version(version)
|
.version(version)
|
||||||
.cryptoType(cryptCytp)
|
.cryptoType(cryptCytp)
|
||||||
.timeStamp(timeStamp)
|
.timeStamp(timeStamp)
|
||||||
.statusCode(statusCode)
|
.statusCode(statusCode)
|
||||||
.msgContent(msgCtx)
|
.msgContent(msgCtx)
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
case COMMAND_REPORT_SENSOR -> {
|
case COMMAND_REPORT_SENSOR -> {
|
||||||
int taskId = buf.readInt();
|
int taskId = buf.readInt();
|
||||||
byte nItem = buf.readByte();
|
byte nItem = buf.readByte();
|
||||||
|
|
||||||
SensorTaskAck taskAck = SensorTaskAck.builder()
|
SensorTaskAck taskAck = SensorTaskAck.builder().taskId(taskId).ackTimestamp(timeStamp).sensorStatus(new ArrayList<>(
|
||||||
.taskId(taskId)
|
nItem)).build();
|
||||||
.ackTimestamp(timeStamp)
|
|
||||||
.sensorStatus(new ArrayList<>(nItem))
|
|
||||||
.build();
|
|
||||||
for (int i = 0; i < nItem; i++) {
|
for (int i = 0; i < nItem; i++) {
|
||||||
SensorTaskStatus taskStatus = SensorTaskStatus.builder()
|
SensorTaskStatus taskStatus = SensorTaskStatus.builder()
|
||||||
.sensorId(buf.readInt())
|
.sensorId(buf.readInt())
|
||||||
.taskResult(CommonEnumHandler.codeOf(TaskResultName.class, buf.readByte()))
|
.taskResult(CommonEnumHandler.codeOf(TaskResultName.class,
|
||||||
.tunnelName(CommonEnumHandler.codeOf(SensorControlTunnelName.class, buf.readByte()))
|
buf.readByte()))
|
||||||
.build();
|
.tunnelName(CommonEnumHandler.codeOf(SensorControlTunnelName.class,
|
||||||
|
buf.readByte()))
|
||||||
|
.build();
|
||||||
|
|
||||||
taskAck.getSensorStatus().add(taskStatus);
|
taskAck.getSensorStatus().add(taskStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageContent<SensorTaskAck> msgCtx = MessageContent.<SensorTaskAck>builder()
|
MessageContent<SensorTaskAck> msgCtx = MessageContent.<SensorTaskAck>builder()
|
||||||
.msgType(msgType)
|
.msgType(msgType)
|
||||||
.msgSize(msgSize)
|
.msgSize(msgSize)
|
||||||
.msgBody(taskAck)
|
.msgBody(taskAck)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
list.add(BaseBinaryProtocol.<SensorTaskAck>builder()
|
list.add(BaseBinaryProtocol.<SensorTaskAck>builder()
|
||||||
.msgLength(msgLength)
|
.msgLength(msgLength)
|
||||||
.version(version)
|
.version(version)
|
||||||
.cryptoType(cryptCytp)
|
.cryptoType(cryptCytp)
|
||||||
.timeStamp(timeStamp)
|
.timeStamp(timeStamp)
|
||||||
.statusCode(statusCode)
|
.statusCode(statusCode)
|
||||||
.msgContent(msgCtx)
|
.msgContent(msgCtx)
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
case COMMAND_REPORT_QUERY_SENSOR -> {
|
case COMMAND_REPORT_QUERY_SENSOR -> {
|
||||||
int nItems = buf.readByte();
|
int nItems = buf.readByte();
|
||||||
SensorStatusAck sensorAck = SensorStatusAck.builder().sensorStatus(new ArrayList<>()).build();
|
SensorStatusAck sensorAck = SensorStatusAck.builder().sensorStatus(new ArrayList<>()).build();
|
||||||
|
|
||||||
MessageContent<SensorStatusAck> msgCtx = MessageContent.<SensorStatusAck>builder().msgType(
|
MessageContent<SensorStatusAck> msgCtx = MessageContent.<SensorStatusAck>builder()
|
||||||
msgType).msgSize(msgSize).msgBody(sensorAck).build();
|
.msgType(msgType)
|
||||||
|
.msgSize(msgSize)
|
||||||
|
.msgBody(sensorAck)
|
||||||
|
.build();
|
||||||
|
|
||||||
for (int i = 0; i < nItems; i++) {
|
for (int i = 0; i < nItems; i++) {
|
||||||
short tmInfo = buf.readShort();
|
short tmInfo = buf.readShort();
|
||||||
SensorControlTunnelName tn = CommonEnumHandler.codeOf(SensorControlTunnelName.class,
|
SensorControlTunnelName tn = CommonEnumHandler.codeOf(SensorControlTunnelName.class, buf.readByte());
|
||||||
buf.readByte());
|
int cmdType = buf.readByte();
|
||||||
int cmdType = buf.readByte();
|
short sa = buf.readShort();
|
||||||
short sa = buf.readShort();
|
short sid = buf.readShort();
|
||||||
short sid = buf.readShort();
|
int warrStatus = buf.readByte();
|
||||||
int warrStatus = buf.readByte();
|
int emg0 = buf.readByte();
|
||||||
int emg0 = buf.readByte();
|
int emg1 = buf.readByte();
|
||||||
int emg1 = buf.readByte();
|
int emg2 = buf.readByte();
|
||||||
int emg2 = buf.readByte();
|
int spk0 = buf.readByte();
|
||||||
int spk0 = buf.readByte();
|
int spk1 = buf.readByte();
|
||||||
int spk1 = buf.readByte();
|
int spk2 = buf.readByte();
|
||||||
int spk2 = buf.readByte();
|
int runStatus = buf.readByte();
|
||||||
int runStatus = buf.readByte();
|
byte[] signale = new byte[5];
|
||||||
byte[] signale = new byte[5];
|
|
||||||
buf.readBytes(signale, 0, 5);
|
buf.readBytes(signale, 0, 5);
|
||||||
byte[] id = new byte[3];
|
byte[] id = new byte[3];
|
||||||
buf.readBytes(id, 0, 3);
|
buf.readBytes(id, 0, 3);
|
||||||
|
|
||||||
SensorStatusInfo si = SensorStatusInfo.builder()
|
SensorStatusInfo si = SensorStatusInfo.builder()
|
||||||
.dtInfo(tmInfo)
|
.dtInfo(tmInfo)
|
||||||
.tunnelName(tn)
|
.tunnelName(tn)
|
||||||
.command(cmdType)
|
.command(cmdType)
|
||||||
.startAddr(sa)
|
.startAddr(sa)
|
||||||
.sensorId(sid)
|
.sensorId(sid)
|
||||||
.warrningStatus(warrStatus)
|
.warrningStatus(warrStatus)
|
||||||
.emergenStatus0(emg0)
|
.emergenStatus0(emg0)
|
||||||
.emergenStatus1(emg1)
|
.emergenStatus1(emg1)
|
||||||
.emergenStatus2(emg2)
|
.emergenStatus2(emg2)
|
||||||
.speakerStatus0(spk0)
|
.speakerStatus0(spk0)
|
||||||
.speakerStatus1(spk1)
|
.speakerStatus1(spk1)
|
||||||
.speakerStatus2(spk2)
|
.speakerStatus2(spk2)
|
||||||
.runStatus(runStatus)
|
.runStatus(runStatus)
|
||||||
.signalStrength(HelperUtils.bytesToHexString(signale))
|
.signalStrength(HelperUtils.bytesToHexString(signale))
|
||||||
.beidouId(HelperUtils.bytesToHexString(id))
|
.beidouId(HelperUtils.bytesToHexString(id))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
sensorAck.getSensorStatus().add(si);
|
sensorAck.getSensorStatus().add(si);
|
||||||
}
|
}
|
||||||
|
|
||||||
list.add(BaseBinaryProtocol.<SensorStatusAck>builder()
|
list.add(BaseBinaryProtocol.<SensorStatusAck>builder()
|
||||||
.msgLength(msgLength)
|
.msgLength(msgLength)
|
||||||
.version(version)
|
.version(version)
|
||||||
.cryptoType(cryptCytp)
|
.cryptoType(cryptCytp)
|
||||||
.timeStamp(timeStamp)
|
.timeStamp(timeStamp)
|
||||||
.statusCode(statusCode)
|
.statusCode(statusCode)
|
||||||
.msgContent(msgCtx)
|
.msgContent(msgCtx)
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
default -> log.error("Unsupport Command: {}({})", cmd, msgType);
|
default -> log.error("Unsupport Command: {}({})", cmd, msgType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.zjyr.beidouservice.adapter.impl.netty.encode;
|
||||||
|
|
||||||
import com.zjyr.beidouservice.pojo.vo.binary.BaseBinaryProtocol;
|
import com.zjyr.beidouservice.pojo.vo.binary.BaseBinaryProtocol;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.ByteBufUtil;
|
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.handler.codec.LengthFieldPrepender;
|
import io.netty.handler.codec.LengthFieldPrepender;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.zjyr.beidouservice.adapter.impl.netty.encode;
|
package com.zjyr.beidouservice.adapter.impl.netty.encode;
|
||||||
|
|
||||||
import com.zjyr.beidouservice.common.impl.AlarmModeName;
|
|
||||||
import com.zjyr.beidouservice.common.impl.ControlCommandName;
|
import com.zjyr.beidouservice.common.impl.ControlCommandName;
|
||||||
import com.zjyr.beidouservice.pojo.vo.binary.BaseBinaryProtocol;
|
import com.zjyr.beidouservice.pojo.vo.binary.BaseBinaryProtocol;
|
||||||
import com.zjyr.beidouservice.pojo.vo.binary.HeartProtocol;
|
import com.zjyr.beidouservice.pojo.vo.binary.HeartProtocol;
|
||||||
|
@ -19,12 +18,10 @@ import org.springframework.stereotype.Component;
|
||||||
@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,
|
protected void encode(ChannelHandlerContext channelHandlerContext, BaseBinaryProtocol<T> baseBinaryProtocol, ByteBuf byteBuf) {
|
||||||
BaseBinaryProtocol<T> baseBinaryProtocol,
|
|
||||||
ByteBuf byteBuf) {
|
|
||||||
|
|
||||||
if (baseBinaryProtocol == null || baseBinaryProtocol.getMsgContent() == null ||
|
if (baseBinaryProtocol == null || baseBinaryProtocol.getMsgContent() == null ||
|
||||||
baseBinaryProtocol.getMsgContent().getMsgBody() == null) {
|
baseBinaryProtocol.getMsgContent().getMsgBody() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +44,7 @@ public class YuanRongProtocolEncode<T> extends MessageToByteEncoder<BaseBinaryPr
|
||||||
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().getValue().byteValue());
|
byteBuf.writeByte(msg.getControlTunnel().byteValue());
|
||||||
byteBuf.writeInt(msg.getTimeStamp());
|
byteBuf.writeInt(msg.getTimeStamp());
|
||||||
|
|
||||||
if (msg.getCityCode().isEmpty()) {
|
if (msg.getCityCode().isEmpty()) {
|
||||||
|
@ -71,7 +68,7 @@ public class YuanRongProtocolEncode<T> extends MessageToByteEncoder<BaseBinaryPr
|
||||||
if (msg.getSensorId().isEmpty()) {
|
if (msg.getSensorId().isEmpty()) {
|
||||||
byteBuf.writeByte(0);
|
byteBuf.writeByte(0);
|
||||||
} else {
|
} else {
|
||||||
byteBuf.writeByte(msg.getSensorId().size() * 4);
|
byteBuf.writeByte(msg.getSensorId().size());
|
||||||
for (var c : msg.getSensorId()) {
|
for (var c : msg.getSensorId()) {
|
||||||
byteBuf.writeInt(c);
|
byteBuf.writeInt(c);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,6 @@ public class SocketNotifyEvent extends ApplicationEvent {
|
||||||
this.socketEvent = evtType;
|
this.socketEvent = evtType;
|
||||||
this.evtMessage = evtMessage;
|
this.evtMessage = evtMessage;
|
||||||
this.ctxChannel = ctx;
|
this.ctxChannel = ctx;
|
||||||
this.timeStamp = (int)(System.currentTimeMillis() / 1000);
|
this.timeStamp = (int) (System.currentTimeMillis() / 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,10 +36,7 @@ public final class CommonEnumHandler<E extends EnumerationBase> extends BaseType
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setNonNullParameter(PreparedStatement preparedStatement,
|
public void setNonNullParameter(PreparedStatement preparedStatement, int i, E e, JdbcType jdbcType) throws SQLException {
|
||||||
int i,
|
|
||||||
E e,
|
|
||||||
JdbcType jdbcType) throws SQLException {
|
|
||||||
preparedStatement.setInt(i, e.getValue());
|
preparedStatement.setInt(i, e.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ public enum TaskResultName implements EnumerationBase {
|
||||||
TASK_RESULT_FAILED(1, "TASK_RESULT_FAILED"),
|
TASK_RESULT_FAILED(1, "TASK_RESULT_FAILED"),
|
||||||
;
|
;
|
||||||
private final Integer code;
|
private final Integer code;
|
||||||
private final String desc;
|
private final String desc;
|
||||||
|
|
||||||
TaskResultName(int val, String desc) {
|
TaskResultName(int val, String desc) {
|
||||||
this.code = val;
|
this.code = val;
|
||||||
|
|
|
@ -16,7 +16,7 @@ public enum AlarmTypeEnum {
|
||||||
|
|
||||||
|
|
||||||
private final Integer code;
|
private final Integer code;
|
||||||
private final String msg;
|
private final String msg;
|
||||||
|
|
||||||
public static String getByCode(Integer code) {
|
public static String getByCode(Integer code) {
|
||||||
AlarmTypeEnum[] values = AlarmTypeEnum.values();
|
AlarmTypeEnum[] values = AlarmTypeEnum.values();
|
||||||
|
@ -30,7 +30,7 @@ public enum AlarmTypeEnum {
|
||||||
|
|
||||||
public static List<Integer> getAllCodes() {
|
public static List<Integer> getAllCodes() {
|
||||||
AlarmTypeEnum[] values = AlarmTypeEnum.values();
|
AlarmTypeEnum[] values = AlarmTypeEnum.values();
|
||||||
List<Integer> codes = new ArrayList<>();
|
List<Integer> codes = new ArrayList<>();
|
||||||
for (AlarmTypeEnum v : values) {
|
for (AlarmTypeEnum v : values) {
|
||||||
codes.add(v.getCode());
|
codes.add(v.getCode());
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ public enum ManufacturerTypeEnum {
|
||||||
|
|
||||||
public static List<Integer> getAllCodes() {
|
public static List<Integer> getAllCodes() {
|
||||||
ManufacturerTypeEnum[] values = ManufacturerTypeEnum.values();
|
ManufacturerTypeEnum[] values = ManufacturerTypeEnum.values();
|
||||||
List<Integer> codes = new ArrayList<>();
|
List<Integer> codes = new ArrayList<>();
|
||||||
for (ManufacturerTypeEnum v : values) {
|
for (ManufacturerTypeEnum v : values) {
|
||||||
codes.add(v.getCode());
|
codes.add(v.getCode());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
package com.zjyr.beidouservice.controller;
|
package com.zjyr.beidouservice.controller;
|
||||||
|
|
||||||
|
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.common.impl.SensorControlTunnelName;
|
||||||
import com.zjyr.beidouservice.pojo.dto.BaseProtocolDTO;
|
import com.zjyr.beidouservice.pojo.dto.BaseProtocolDTO;
|
||||||
import com.zjyr.beidouservice.pojo.dto.GetUserConfig;
|
import com.zjyr.beidouservice.pojo.dto.GetUserConfig;
|
||||||
|
import com.zjyr.beidouservice.pojo.vo.binary.SensorControlProtocol;
|
||||||
import com.zjyr.beidouservice.service.AdapterProtocolService;
|
import com.zjyr.beidouservice.service.AdapterProtocolService;
|
||||||
import com.zjyr.beidouservice.service.BaidouAdapterService;
|
import com.zjyr.beidouservice.service.BaidouAdapterService;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
@ -14,8 +19,11 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import java.text.ParsePosition;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.Arrays;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
//@RequestMapping(value = "/auth")
|
//@RequestMapping(value = "/auth")
|
||||||
|
@ -37,33 +45,22 @@ public class AuthUser {
|
||||||
@PostMapping("/sensor/control")
|
@PostMapping("/sensor/control")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String getUserConfig(@RequestBody BaseProtocolDTO<GetUserConfig> mr, @RequestHeader HttpHeaders headers) {
|
public String getUserConfig(@RequestBody BaseProtocolDTO<GetUserConfig> mr, @RequestHeader HttpHeaders headers) {
|
||||||
// List<BeidouAdapterControlContent> adapterInfo = new ArrayList<>();
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
//
|
ParsePosition pos = new ParsePosition(0);
|
||||||
// for (int i = 0; i < 2; i++) {
|
Date strtodate = formatter.parse("2023-08-30 18:24:30", pos);
|
||||||
//// adapterInfo.add(BeidouAdapterControlContent.builder()
|
|
||||||
//// .districtsCode(0x10 + i)
|
SensorControlProtocol sensorPro = adapterProtocolService.createSensorControlProtocol(1024,
|
||||||
//// .sensorId(0x3f00 + i)
|
AlarmModeName.ALARM_MODE_MANUALLY,
|
||||||
//// .controlAction(SensorControlActionName.ACTION_DISTRICTS_BASED)
|
AlarmControlTypeName.ALARM_CONTROL_TYPE_TEST_QUITE,
|
||||||
//// .build());
|
AlarmTypeName.ALARM_TYPE_AIRATTACK,
|
||||||
// }
|
SensorControlTunnelName.TUNNEL_BEIDOU.getValue() |
|
||||||
//
|
SensorControlTunnelName.TUNNEL_WIRELESS.getValue(),
|
||||||
// SensorControlProtocol sp =
|
strtodate,
|
||||||
// adapterProtocolService.createSensorControlProtocol(SensorControlTunnelName.TUNNEL_BEIDOU,
|
new ArrayList<>(),
|
||||||
// new byte[]{0x01, 0x02, 0x03},
|
new ArrayList<>(),
|
||||||
// 8,
|
new ArrayList<>(Arrays.asList(0, 1, 2, 3)));
|
||||||
// 14,
|
Long id = baidouAdapterService.getAllAdapter().get(0).getId();
|
||||||
// 20,
|
baidouAdapterService.sendCommond(id, sensorPro);
|
||||||
// 35,
|
|
||||||
// 3,
|
|
||||||
// 5,
|
|
||||||
// SensorControlModeName.CONTROL_TYPE_QUIET,
|
|
||||||
// 0,
|
|
||||||
// adapterProtocolService.createSensorCtrlInfo(
|
|
||||||
// adapterInfo));
|
|
||||||
// Long id = baidouAdapterService.getAllAdapter().get(0).getId();
|
|
||||||
// if (id != null) {
|
|
||||||
// baidouAdapterService.sendCommond(id, sp);
|
|
||||||
// }
|
|
||||||
|
|
||||||
return "{\"result\": 0}";
|
return "{\"result\": 0}";
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,8 @@ import com.zjyr.beidouservice.pojo.MyResp;
|
||||||
import com.zjyr.beidouservice.pojo.dto.city.CityRespDTO;
|
import com.zjyr.beidouservice.pojo.dto.city.CityRespDTO;
|
||||||
import com.zjyr.beidouservice.pojo.dto.city.CitySearchDTO;
|
import com.zjyr.beidouservice.pojo.dto.city.CitySearchDTO;
|
||||||
import com.zjyr.beidouservice.pojo.dto.province.OnlyProvinceResp;
|
import com.zjyr.beidouservice.pojo.dto.province.OnlyProvinceResp;
|
||||||
import com.zjyr.beidouservice.pojo.dto.province.ProvinceSearchDTO;
|
|
||||||
import com.zjyr.beidouservice.pojo.dto.province.ProvinceRespDTO;
|
import com.zjyr.beidouservice.pojo.dto.province.ProvinceRespDTO;
|
||||||
|
import com.zjyr.beidouservice.pojo.dto.province.ProvinceSearchDTO;
|
||||||
import com.zjyr.beidouservice.service.LocationService;
|
import com.zjyr.beidouservice.service.LocationService;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
@ -30,6 +30,7 @@ public class LocationController {
|
||||||
OnlyProvinceResp onlyProvinceResp = locationService.getOnlyProvinces();
|
OnlyProvinceResp onlyProvinceResp = locationService.getOnlyProvinces();
|
||||||
return MyResp.success(onlyProvinceResp);
|
return MyResp.success(onlyProvinceResp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("provinces")
|
@PostMapping("provinces")
|
||||||
public MyResp<ProvinceRespDTO> getProvinces(@RequestBody ProvinceSearchDTO provinceSearchDTO) {
|
public MyResp<ProvinceRespDTO> getProvinces(@RequestBody ProvinceSearchDTO provinceSearchDTO) {
|
||||||
ProvinceRespDTO provinceResp = locationService.getProvinces(provinceSearchDTO);
|
ProvinceRespDTO provinceResp = locationService.getProvinces(provinceSearchDTO);
|
||||||
|
|
|
@ -10,8 +10,7 @@ import java.util.List;
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface DevAttributesMapper {
|
public interface DevAttributesMapper {
|
||||||
|
|
||||||
List<DevMaunDTO> selectManuByManufacturer(@Param("deviceId") Long deviceId,
|
List<DevMaunDTO> selectManuByManufacturer(@Param("deviceId") Long deviceId, @Param("manufacturer") String manufacturer);
|
||||||
@Param("manufacturer") String manufacturer);
|
|
||||||
|
|
||||||
|
|
||||||
List<DevAttributesDO> selectManuAll();
|
List<DevAttributesDO> selectManuAll();
|
||||||
|
|
|
@ -9,6 +9,5 @@ import java.util.List;
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface LocCountyMapper {
|
public interface LocCountyMapper {
|
||||||
|
|
||||||
List<LocCountyDO> selectCountyByCity(@Param("provinceCode") String provinceCode,
|
List<LocCountyDO> selectCountyByCity(@Param("provinceCode") String provinceCode, @Param("cityCode") String cityCode);
|
||||||
@Param("cityCode") String cityCode);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,5 +10,6 @@ import java.util.List;
|
||||||
public interface LocProvinceMapper {
|
public interface LocProvinceMapper {
|
||||||
|
|
||||||
List<LocProvinceDO> selectAllProvince();
|
List<LocProvinceDO> selectAllProvince();
|
||||||
|
|
||||||
List<LocProvinceDO> selectProvince(@Param("provinceCode") String provinceCode);
|
List<LocProvinceDO> selectProvince(@Param("provinceCode") String provinceCode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,33 +11,23 @@ import lombok.NoArgsConstructor;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class MyResp<T> {
|
public class MyResp<T> {
|
||||||
|
|
||||||
private int code = Resp.SUCCESS.getCede();
|
private int code = Resp.SUCCESS.getCede();
|
||||||
private String msg;
|
private String msg;
|
||||||
private T data;
|
private T data;
|
||||||
|
|
||||||
public static MyResp build() {
|
public static MyResp build() {
|
||||||
return new MyResp();
|
return new MyResp();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MyResp result(Resp resp) {
|
public static MyResp result(Resp resp) {
|
||||||
return MyResp.builder()
|
return MyResp.builder().code(resp.getCede()).msg(resp.getMsg()).build();
|
||||||
.code(resp.getCede())
|
|
||||||
.msg(resp.getMsg())
|
|
||||||
.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> MyResp success(T data) {
|
public static <T> MyResp success(T data) {
|
||||||
return MyResp.builder()
|
return MyResp.builder().code(Resp.SUCCESS.getCede()).msg(Resp.SUCCESS.getMsg()).data(data).build();
|
||||||
.code(Resp.SUCCESS.getCede())
|
|
||||||
.msg(Resp.SUCCESS.getMsg())
|
|
||||||
.data(data)
|
|
||||||
.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MyResp error(Resp respEnum) {
|
public static MyResp error(Resp respEnum) {
|
||||||
return MyResp.builder()
|
return MyResp.builder().code(respEnum.getCede()).msg(respEnum.getMsg()).build();
|
||||||
.code(respEnum.getCede())
|
|
||||||
.msg(respEnum.getMsg())
|
|
||||||
.build();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,29 +1,27 @@
|
||||||
package com.zjyr.beidouservice.pojo;
|
package com.zjyr.beidouservice.pojo;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
public enum Resp {
|
public enum Resp {
|
||||||
//成功返回码
|
//成功返回码
|
||||||
SUCCESS(200, "SUCCESS");
|
SUCCESS(200, "SUCCESS");
|
||||||
|
|
||||||
|
|
||||||
private int code;
|
private final int code;
|
||||||
|
|
||||||
private String msg;
|
@Getter
|
||||||
|
private final String msg;
|
||||||
|
|
||||||
Resp(int code, String msg) {
|
Resp(int code, String msg) {
|
||||||
this.code = code;
|
this.code = code;
|
||||||
this.msg = msg;
|
this.msg = msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCede() {
|
public int getCede() {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMsg() {
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class DevAttributesDO {
|
||||||
|
|
||||||
private Date alarmInstallTime;
|
private Date alarmInstallTime;
|
||||||
|
|
||||||
private String controlModel;
|
private String controlModel;
|
||||||
private Integer controlStatus;
|
private Integer controlStatus;
|
||||||
|
|
||||||
private Integer controlManufacturer;
|
private Integer controlManufacturer;
|
||||||
|
|
|
@ -27,6 +27,6 @@ public class DevTaskDO {
|
||||||
private String execCmd;
|
private String execCmd;
|
||||||
|
|
||||||
private Integer execState;
|
private Integer execState;
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import lombok.NoArgsConstructor;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class AlarmDevContentDTO {
|
public class AlarmDevContentDTO {
|
||||||
private String alarmType;
|
private String alarmType;
|
||||||
private Integer alarmNum;
|
private Integer alarmNum;
|
||||||
|
|
||||||
private Double alarmRatio;
|
private Double alarmRatio;
|
||||||
|
|
|
@ -18,7 +18,7 @@ public class DeviceTaskContentDTO {
|
||||||
private String deviceName;
|
private String deviceName;
|
||||||
|
|
||||||
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
private Date respTime;
|
private Date respTime;
|
||||||
|
|
||||||
private Integer execState;
|
private Integer execState;
|
||||||
|
|
|
@ -18,7 +18,7 @@ public class DeviceTaskRespDTO {
|
||||||
|
|
||||||
private String taskId;
|
private String taskId;
|
||||||
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
private Date recodeTime;
|
private Date recodeTime;
|
||||||
|
|
||||||
private Integer deviceNum;
|
private Integer deviceNum;
|
||||||
|
|
|
@ -25,9 +25,9 @@ import javax.persistence.Table;
|
||||||
public class ControlDevice {
|
public class ControlDevice {
|
||||||
@Id
|
@Id
|
||||||
@KeySql(useGeneratedKeys = true)
|
@KeySql(useGeneratedKeys = true)
|
||||||
private Long id;
|
private Long id;
|
||||||
private BeidouAdapterTypeName deviceType;
|
private BeidouAdapterTypeName deviceType;
|
||||||
private String deviceAddr;
|
private String deviceAddr;
|
||||||
|
|
||||||
private Integer sendEnabled;
|
private Integer sendEnabled;
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ public class ControlDevice {
|
||||||
|
|
||||||
private String beidouChannelStatus;
|
private String beidouChannelStatus;
|
||||||
|
|
||||||
private String beidouSignalStrength;
|
private String beidouSignalStrength;
|
||||||
private Integer wirelessStatus;
|
private Integer wirelessStatus;
|
||||||
private Integer telphoneStatus;
|
private Integer telphoneStatus;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,13 +7,13 @@ import lombok.Data;
|
||||||
@Builder
|
@Builder
|
||||||
@Data
|
@Data
|
||||||
public class BeidouAdapterDevice {
|
public class BeidouAdapterDevice {
|
||||||
private long id;
|
private long id;
|
||||||
private BeidouAdapterTypeName adapterType;
|
private BeidouAdapterTypeName adapterType;
|
||||||
private String adapterAddr;
|
private String adapterAddr;
|
||||||
private int sendEnabled;
|
private int sendEnabled;
|
||||||
private int beidouStatus;
|
private int beidouStatus;
|
||||||
private String beidouChannelStatus;
|
private String beidouChannelStatus;
|
||||||
private String beidouSignalStrength;
|
private String beidouSignalStrength;
|
||||||
private int wirelessStatus;
|
private int wirelessStatus;
|
||||||
private int telphoneStatus;
|
private int telphoneStatus;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
package com.zjyr.beidouservice.pojo.vo.binary;
|
package com.zjyr.beidouservice.pojo.vo.binary;
|
||||||
|
|
||||||
import com.zjyr.beidouservice.common.impl.*;
|
import com.zjyr.beidouservice.common.impl.ControlChannelStatus;
|
||||||
|
import com.zjyr.beidouservice.common.impl.SendStatusName;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Builder
|
@Builder
|
||||||
public class ControllerStatus {
|
public class ControllerStatus {
|
||||||
private byte[] beidouFreq;
|
private byte[] beidouFreq;
|
||||||
private byte[] beidouSignalStrength;
|
private byte[] beidouSignalStrength;
|
||||||
private SendStatusName sendStatus;
|
private int heartSeq;
|
||||||
|
private SendStatusName sendStatus;
|
||||||
private ControlChannelStatus beidouStatus;
|
private ControlChannelStatus beidouStatus;
|
||||||
private ControlChannelStatus wirelessStatus;
|
private ControlChannelStatus wirelessStatus;
|
||||||
private ControlChannelStatus telphoneStatus;
|
private ControlChannelStatus telphoneStatus;
|
||||||
|
|
|
@ -3,15 +3,13 @@ package com.zjyr.beidouservice.pojo.vo.binary;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Builder
|
@Builder
|
||||||
public class QuerySensorProtocol {
|
public class QuerySensorProtocol {
|
||||||
private byte province;
|
private byte province;
|
||||||
private byte city;
|
private byte city;
|
||||||
|
|
||||||
private byte nControlInfo;
|
private byte nControlInfo;
|
||||||
/**
|
/**
|
||||||
* The Controll contents.
|
* The Controll contents.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -3,7 +3,6 @@ package com.zjyr.beidouservice.pojo.vo.binary;
|
||||||
import com.zjyr.beidouservice.common.impl.AlarmControlTypeName;
|
import com.zjyr.beidouservice.common.impl.AlarmControlTypeName;
|
||||||
import com.zjyr.beidouservice.common.impl.AlarmModeName;
|
import com.zjyr.beidouservice.common.impl.AlarmModeName;
|
||||||
import com.zjyr.beidouservice.common.impl.AlarmTypeName;
|
import com.zjyr.beidouservice.common.impl.AlarmTypeName;
|
||||||
import com.zjyr.beidouservice.common.impl.SensorControlTunnelName;
|
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
@ -12,13 +11,13 @@ import java.util.List;
|
||||||
@Data
|
@Data
|
||||||
@Builder
|
@Builder
|
||||||
public class SensorControlProtocol {
|
public class SensorControlProtocol {
|
||||||
private int taskId;
|
private int taskId;
|
||||||
private AlarmModeName alarmMode;
|
private AlarmModeName alarmMode;
|
||||||
private AlarmControlTypeName alarmControlType;
|
private AlarmControlTypeName alarmControlType;
|
||||||
private AlarmTypeName alarmType;
|
private AlarmTypeName alarmType;
|
||||||
private SensorControlTunnelName controlTunnel;
|
private Integer controlTunnel;
|
||||||
private int timeStamp;
|
private Integer timeStamp;
|
||||||
private List<Integer> cityCode;
|
private List<Integer> cityCode;
|
||||||
private List<Integer> districtsCode;
|
private List<Integer> districtsCode;
|
||||||
private List<Integer> sensorId;
|
private List<Integer> sensorId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import java.util.List;
|
||||||
@Builder
|
@Builder
|
||||||
@Data
|
@Data
|
||||||
public class SensorTaskAck {
|
public class SensorTaskAck {
|
||||||
private int taskId;
|
private int taskId;
|
||||||
private int ackTimestamp;
|
private int ackTimestamp;
|
||||||
private List<SensorTaskStatus> sensorStatus;
|
private List<SensorTaskStatus> sensorStatus;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import lombok.Data;
|
||||||
@Builder
|
@Builder
|
||||||
@Data
|
@Data
|
||||||
public class SensorTaskStatus {
|
public class SensorTaskStatus {
|
||||||
private int sensorId;
|
private int sensorId;
|
||||||
private TaskResultName taskResult;
|
private TaskResultName taskResult;
|
||||||
|
|
||||||
private SensorControlTunnelName tunnelName;
|
private SensorControlTunnelName tunnelName;
|
||||||
|
|
|
@ -3,7 +3,6 @@ package com.zjyr.beidouservice.service;
|
||||||
import com.zjyr.beidouservice.common.impl.AlarmControlTypeName;
|
import com.zjyr.beidouservice.common.impl.AlarmControlTypeName;
|
||||||
import com.zjyr.beidouservice.common.impl.AlarmModeName;
|
import com.zjyr.beidouservice.common.impl.AlarmModeName;
|
||||||
import com.zjyr.beidouservice.common.impl.AlarmTypeName;
|
import com.zjyr.beidouservice.common.impl.AlarmTypeName;
|
||||||
import com.zjyr.beidouservice.common.impl.SensorControlTunnelName;
|
|
||||||
import com.zjyr.beidouservice.pojo.vo.binary.HeartProtocol;
|
import com.zjyr.beidouservice.pojo.vo.binary.HeartProtocol;
|
||||||
import com.zjyr.beidouservice.pojo.vo.binary.SensorControlProtocol;
|
import com.zjyr.beidouservice.pojo.vo.binary.SensorControlProtocol;
|
||||||
|
|
||||||
|
@ -13,11 +12,15 @@ import java.util.List;
|
||||||
public interface AdapterProtocolService {
|
public interface AdapterProtocolService {
|
||||||
HeartProtocol createHeartProtocol();
|
HeartProtocol createHeartProtocol();
|
||||||
|
|
||||||
SensorControlProtocol createSensorControlProtocol(AlarmModeName alarmMode, AlarmControlTypeName controlType,
|
SensorControlProtocol createSensorControlProtocol(int taskId,
|
||||||
AlarmTypeName alarmType, SensorControlTunnelName tunnelName,
|
AlarmModeName alarmMode,
|
||||||
|
AlarmControlTypeName controlType,
|
||||||
|
AlarmTypeName alarmType,
|
||||||
|
int tunnelName,
|
||||||
Date alarmDt,
|
Date alarmDt,
|
||||||
List<Integer> citys,
|
List<Integer> citys,
|
||||||
List<Integer> areas,
|
List<Integer> areas,
|
||||||
List<Integer> sensors);
|
List<Integer> sensors);
|
||||||
|
|
||||||
<T> Object createTransmissionProtocol(T proContent);
|
<T> Object createTransmissionProtocol(T proContent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
package com.zjyr.beidouservice.service;
|
package com.zjyr.beidouservice.service;
|
||||||
|
|
||||||
import com.zjyr.beidouservice.pojo.dto.AlarmDevRespDTO;
|
import com.zjyr.beidouservice.pojo.dto.AlarmDevRespDTO;
|
||||||
import com.zjyr.beidouservice.pojo.dto.DeviceReqDTO;
|
import com.zjyr.beidouservice.pojo.dto.DeviceReqDTO;
|
||||||
import com.zjyr.beidouservice.pojo.dto.DeviceRespDTO;
|
import com.zjyr.beidouservice.pojo.dto.DeviceRespDTO;
|
||||||
|
|
|
@ -4,13 +4,11 @@ import com.zjyr.beidouservice.pojo.dto.DevTaskExecRespDTO;
|
||||||
import com.zjyr.beidouservice.pojo.dto.DeviceTaskExecReqDTO;
|
import com.zjyr.beidouservice.pojo.dto.DeviceTaskExecReqDTO;
|
||||||
import com.zjyr.beidouservice.pojo.dto.DeviceTaskRespDTO;
|
import com.zjyr.beidouservice.pojo.dto.DeviceTaskRespDTO;
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface DeviceTaskService {
|
public interface DeviceTaskService {
|
||||||
List<DeviceTaskRespDTO> getDeviceTaskInfo();
|
List<DeviceTaskRespDTO> getDeviceTaskInfo();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DevTaskExecRespDTO deviceTaskExec(DeviceTaskExecReqDTO deviceTaskExecReqDTO);
|
DevTaskExecRespDTO deviceTaskExec(DeviceTaskExecReqDTO deviceTaskExecReqDTO);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,8 @@ package com.zjyr.beidouservice.service;
|
||||||
import com.zjyr.beidouservice.pojo.dto.city.CityRespDTO;
|
import com.zjyr.beidouservice.pojo.dto.city.CityRespDTO;
|
||||||
import com.zjyr.beidouservice.pojo.dto.city.CitySearchDTO;
|
import com.zjyr.beidouservice.pojo.dto.city.CitySearchDTO;
|
||||||
import com.zjyr.beidouservice.pojo.dto.province.OnlyProvinceResp;
|
import com.zjyr.beidouservice.pojo.dto.province.OnlyProvinceResp;
|
||||||
import com.zjyr.beidouservice.pojo.dto.province.ProvinceSearchDTO;
|
|
||||||
import com.zjyr.beidouservice.pojo.dto.province.ProvinceRespDTO;
|
import com.zjyr.beidouservice.pojo.dto.province.ProvinceRespDTO;
|
||||||
|
import com.zjyr.beidouservice.pojo.dto.province.ProvinceSearchDTO;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface LocationService {
|
public interface LocationService {
|
||||||
OnlyProvinceResp getOnlyProvinces();
|
OnlyProvinceResp getOnlyProvinces();
|
||||||
|
|
|
@ -32,8 +32,7 @@ import static com.zjyr.beidouservice.common.impl.SocketEventName.SOCKET_EVT_CONN
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
|
||||||
public class BaidouSocketAdapterServiceImpl<T extends ApplicationEvent> implements BaidouAdapterService,
|
public class BaidouSocketAdapterServiceImpl<T extends ApplicationEvent> implements BaidouAdapterService, ApplicationListener<T> {
|
||||||
ApplicationListener<T> {
|
|
||||||
|
|
||||||
private final ConcurrentHashMap<Long, ControlAdapterSocketCtx> ctxMap = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<Long, ControlAdapterSocketCtx> ctxMap = new ConcurrentHashMap<>();
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -74,14 +73,14 @@ public class BaidouSocketAdapterServiceImpl<T extends ApplicationEvent> implemen
|
||||||
if (evtContent instanceof SocketNotifyEvent event) {
|
if (evtContent instanceof SocketNotifyEvent event) {
|
||||||
InetSocketAddress sa = (InetSocketAddress) event.getCtxChannel().remoteAddress();
|
InetSocketAddress sa = (InetSocketAddress) event.getCtxChannel().remoteAddress();
|
||||||
switch (event.getSocketEvent()) {
|
switch (event.getSocketEvent()) {
|
||||||
case SOCKET_EVT_CONNECT -> {
|
case SOCKET_EVT_CONNECT, SOCKET_EVT_IDLE_TIMEOUT -> {
|
||||||
sendCommond(event.getCtxChannel(), adapterProtocolService.createHeartProtocol());
|
sendCommond(event.getCtxChannel(), adapterProtocolService.createHeartProtocol());
|
||||||
|
|
||||||
if (event.getSocketEvent() == SOCKET_EVT_CONNECT) {
|
if (event.getSocketEvent() == SOCKET_EVT_CONNECT) {
|
||||||
BeidouAdapterDevice a = BeidouAdapterDevice.builder()
|
BeidouAdapterDevice a = BeidouAdapterDevice.builder()
|
||||||
.adapterType(BeidouAdapterTypeName.ADAPTER_SOCKET_TCP)
|
.adapterType(BeidouAdapterTypeName.ADAPTER_SOCKET_TCP)
|
||||||
.adapterAddr(sa.getAddress().getHostAddress())
|
.adapterAddr(sa.getAddress().getHostAddress())
|
||||||
.build();
|
.build();
|
||||||
addNewBeidouAdapter(a);
|
addNewBeidouAdapter(a);
|
||||||
|
|
||||||
ControlAdapterSocketCtx sockCtx = new ControlAdapterSocketCtx(a.getId(), event.getCtxChannel());
|
ControlAdapterSocketCtx sockCtx = new ControlAdapterSocketCtx(a.getId(), event.getCtxChannel());
|
||||||
|
@ -89,10 +88,6 @@ public class BaidouSocketAdapterServiceImpl<T extends ApplicationEvent> implemen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case SOCKET_EVT_IDLE_TIMEOUT -> {
|
|
||||||
sendCommond(event.getCtxChannel(), adapterProtocolService.createHeartProtocol());
|
|
||||||
}
|
|
||||||
|
|
||||||
case SOCKET_EVT_DISCONNECT -> {
|
case SOCKET_EVT_DISCONNECT -> {
|
||||||
for (ConcurrentHashMap.Entry<Long, ControlAdapterSocketCtx> entry : ctxMap.entrySet()) {
|
for (ConcurrentHashMap.Entry<Long, ControlAdapterSocketCtx> entry : ctxMap.entrySet()) {
|
||||||
if (entry.getValue().getChannel().id() == event.getCtxChannel().id()) {
|
if (entry.getValue().getChannel().id() == event.getCtxChannel().id()) {
|
||||||
|
@ -104,19 +99,19 @@ public class BaidouSocketAdapterServiceImpl<T extends ApplicationEvent> implemen
|
||||||
case SOCKET_EVT_RECV -> {
|
case SOCKET_EVT_RECV -> {
|
||||||
if (event.getEvtMessage() instanceof ControllerStatus status) {
|
if (event.getEvtMessage() instanceof ControllerStatus status) {
|
||||||
log.info("+++{}, {}, {}",
|
log.info("+++{}, {}, {}",
|
||||||
status.getWirelessStatus(),
|
status.getWirelessStatus(),
|
||||||
status.getTelphoneStatus(),
|
status.getTelphoneStatus(),
|
||||||
HelperUtils.bytesToHexString(status.getBeidouSignalStrength()));
|
HelperUtils.bytesToHexString(status.getBeidouSignalStrength()));
|
||||||
BeidouAdapterDevice a = BeidouAdapterDevice.builder()
|
BeidouAdapterDevice a = BeidouAdapterDevice.builder()
|
||||||
.adapterType(BeidouAdapterTypeName.ADAPTER_SOCKET_TCP)
|
.adapterType(BeidouAdapterTypeName.ADAPTER_SOCKET_TCP)
|
||||||
.adapterAddr(sa.getAddress().getHostAddress())
|
.adapterAddr(sa.getAddress().getHostAddress())
|
||||||
.sendEnabled(status.getSendStatus().getValue())
|
.sendEnabled(status.getSendStatus().getValue())
|
||||||
.beidouStatus(status.getBeidouStatus().getValue())
|
.beidouStatus(status.getBeidouStatus().getValue())
|
||||||
.beidouChannelStatus(HelperUtils.bytesToHexString(status.getBeidouFreq()))
|
.beidouChannelStatus(HelperUtils.bytesToHexString(status.getBeidouFreq()))
|
||||||
.beidouSignalStrength(HelperUtils.bytesToHexString(status.getBeidouSignalStrength()))
|
.beidouSignalStrength(HelperUtils.bytesToHexString(status.getBeidouSignalStrength()))
|
||||||
.wirelessStatus(status.getWirelessStatus().getValue())
|
.wirelessStatus(status.getWirelessStatus().getValue())
|
||||||
.telphoneStatus(status.getTelphoneStatus().getValue())
|
.telphoneStatus(status.getTelphoneStatus().getValue())
|
||||||
.build();
|
.build();
|
||||||
addNewBeidouAdapter(a);
|
addNewBeidouAdapter(a);
|
||||||
} /*else if (event.getEvtMessage() instanceof SensorCotrolAck ack) {
|
} /*else if (event.getEvtMessage() instanceof SensorCotrolAck ack) {
|
||||||
log.info("+++{}, {}, {}, {}, {}",
|
log.info("+++{}, {}, {}, {}, {}",
|
||||||
|
@ -143,16 +138,16 @@ public class BaidouSocketAdapterServiceImpl<T extends ApplicationEvent> implemen
|
||||||
|
|
||||||
for (ControlDevice c : controlDevices) {
|
for (ControlDevice c : controlDevices) {
|
||||||
adapterDevices.add(BeidouAdapterDevice.builder()
|
adapterDevices.add(BeidouAdapterDevice.builder()
|
||||||
.id(c.getId())
|
.id(c.getId())
|
||||||
.adapterType(c.getDeviceType())
|
.adapterType(c.getDeviceType())
|
||||||
.adapterAddr(c.getDeviceAddr())
|
.adapterAddr(c.getDeviceAddr())
|
||||||
.sendEnabled(Optional.ofNullable(c.getSendEnabled()).orElse(0))
|
.sendEnabled(Optional.ofNullable(c.getSendEnabled()).orElse(0))
|
||||||
.beidouStatus(Optional.ofNullable(c.getBeidouStatus()).orElse(0))
|
.beidouStatus(Optional.ofNullable(c.getBeidouStatus()).orElse(0))
|
||||||
.beidouChannelStatus(Optional.ofNullable(c.getBeidouChannelStatus()).orElse(""))
|
.beidouChannelStatus(Optional.ofNullable(c.getBeidouChannelStatus()).orElse(""))
|
||||||
.beidouSignalStrength(Optional.ofNullable(c.getBeidouSignalStrength()).orElse(""))
|
.beidouSignalStrength(Optional.ofNullable(c.getBeidouSignalStrength()).orElse(""))
|
||||||
.wirelessStatus(Optional.ofNullable(c.getWirelessStatus()).orElse(0))
|
.wirelessStatus(Optional.ofNullable(c.getWirelessStatus()).orElse(0))
|
||||||
.telphoneStatus(Optional.ofNullable(c.getTelphoneStatus()).orElse(0))
|
.telphoneStatus(Optional.ofNullable(c.getTelphoneStatus()).orElse(0))
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
return adapterDevices;
|
return adapterDevices;
|
||||||
|
@ -164,20 +159,21 @@ public class BaidouSocketAdapterServiceImpl<T extends ApplicationEvent> implemen
|
||||||
@Override
|
@Override
|
||||||
public void addNewBeidouAdapter(BeidouAdapterDevice adapter) {
|
public void addNewBeidouAdapter(BeidouAdapterDevice adapter) {
|
||||||
ControlDevice device = ControlDevice.builder()
|
ControlDevice device = ControlDevice.builder()
|
||||||
.id(adapter.getId())
|
.id(adapter.getId())
|
||||||
.deviceType(adapter.getAdapterType())
|
.deviceType(adapter.getAdapterType())
|
||||||
.deviceAddr(adapter.getAdapterAddr())
|
.deviceAddr(adapter.getAdapterAddr())
|
||||||
.beidouStatus(adapter.getBeidouStatus())
|
.beidouStatus(adapter.getBeidouStatus())
|
||||||
.sendEnabled(adapter.getSendEnabled())
|
.sendEnabled(adapter.getSendEnabled())
|
||||||
.beidouChannelStatus(adapter.getBeidouChannelStatus())
|
.beidouChannelStatus(adapter.getBeidouChannelStatus())
|
||||||
.beidouSignalStrength(adapter.getBeidouSignalStrength())
|
.beidouSignalStrength(adapter.getBeidouSignalStrength())
|
||||||
.wirelessStatus(adapter.getWirelessStatus())
|
.wirelessStatus(adapter.getWirelessStatus())
|
||||||
.telphoneStatus(adapter.getTelphoneStatus())
|
.telphoneStatus(adapter.getTelphoneStatus())
|
||||||
.build();
|
.build();
|
||||||
BeidouAdapterDevice dev = getAdapterByAddr(adapter.getAdapterAddr());
|
BeidouAdapterDevice dev = getAdapterByAddr(adapter.getAdapterAddr());
|
||||||
if (dev == null) {
|
if (dev == null) {
|
||||||
controlDeviceMapper.addControlDevice(device);
|
controlDeviceMapper.addControlDevice(device);
|
||||||
} else {
|
} else {
|
||||||
|
device.setId(dev.getId());
|
||||||
adapter.setId(dev.getId());
|
adapter.setId(dev.getId());
|
||||||
controlDeviceMapper.upgradeControlDevice(device);
|
controlDeviceMapper.upgradeControlDevice(device);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package com.zjyr.beidouservice.service.impl;
|
||||||
import com.zjyr.beidouservice.common.impl.AlarmControlTypeName;
|
import com.zjyr.beidouservice.common.impl.AlarmControlTypeName;
|
||||||
import com.zjyr.beidouservice.common.impl.AlarmModeName;
|
import com.zjyr.beidouservice.common.impl.AlarmModeName;
|
||||||
import com.zjyr.beidouservice.common.impl.AlarmTypeName;
|
import com.zjyr.beidouservice.common.impl.AlarmTypeName;
|
||||||
import com.zjyr.beidouservice.common.impl.SensorControlTunnelName;
|
|
||||||
import com.zjyr.beidouservice.pojo.vo.binary.BaseBinaryProtocol;
|
import com.zjyr.beidouservice.pojo.vo.binary.BaseBinaryProtocol;
|
||||||
import com.zjyr.beidouservice.pojo.vo.binary.HeartProtocol;
|
import com.zjyr.beidouservice.pojo.vo.binary.HeartProtocol;
|
||||||
import com.zjyr.beidouservice.pojo.vo.binary.MessageContent;
|
import com.zjyr.beidouservice.pojo.vo.binary.MessageContent;
|
||||||
|
@ -27,23 +26,27 @@ public class BeidouSocketProtocolServiceImpl implements AdapterProtocolService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SensorControlProtocol createSensorControlProtocol(AlarmModeName alarmMode,
|
public SensorControlProtocol createSensorControlProtocol(int taskId,
|
||||||
|
AlarmModeName alarmMode,
|
||||||
AlarmControlTypeName controlType,
|
AlarmControlTypeName controlType,
|
||||||
AlarmTypeName alarmType,
|
AlarmTypeName alarmType,
|
||||||
SensorControlTunnelName tunnelName, Date alarmDt,
|
int tunnelName,
|
||||||
List<Integer> citys, List<Integer> areas,
|
Date alarmDt,
|
||||||
|
List<Integer> citys,
|
||||||
|
List<Integer> areas,
|
||||||
List<Integer> sensors) {
|
List<Integer> sensors) {
|
||||||
long timestamp = new Timestamp(alarmDt.getTime()).getTime();
|
long timestamp = new Timestamp(alarmDt.getTime()).getTime() / 1000;
|
||||||
return SensorControlProtocol.builder()
|
return SensorControlProtocol.builder()
|
||||||
.alarmMode(alarmMode)
|
.taskId(taskId)
|
||||||
.alarmControlType(controlType)
|
.alarmMode(alarmMode)
|
||||||
.alarmType(alarmType)
|
.alarmControlType(controlType)
|
||||||
.controlTunnel(tunnelName)
|
.alarmType(alarmType)
|
||||||
.timeStamp((int) timestamp)
|
.controlTunnel(tunnelName)
|
||||||
.cityCode(citys)
|
.timeStamp((int) timestamp)
|
||||||
.districtsCode(areas)
|
.cityCode(citys)
|
||||||
.sensorId(sensors)
|
.districtsCode(areas)
|
||||||
.build();
|
.sensorId(sensors)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -53,9 +53,9 @@ public class DeviceServiceImpl implements DeviceService {
|
||||||
}
|
}
|
||||||
|
|
||||||
devBasicInfoList.forEach(dev -> {
|
devBasicInfoList.forEach(dev -> {
|
||||||
Long deviceId = dev.getDeviceId();
|
Long deviceId = dev.getDeviceId();
|
||||||
String manufacturer = deviceReqDTO.getManufacturer();
|
String manufacturer = deviceReqDTO.getManufacturer();
|
||||||
List<DevMaunDTO> devMaunDTO = devAttributesMapper.selectManuByManufacturer(deviceId, manufacturer);
|
List<DevMaunDTO> devMaunDTO = devAttributesMapper.selectManuByManufacturer(deviceId, manufacturer);
|
||||||
//根据过滤过厂商的device查找device基本信息
|
//根据过滤过厂商的device查找device基本信息
|
||||||
devMaunDTO.forEach(v -> {
|
devMaunDTO.forEach(v -> {
|
||||||
DeviceRespDTO deviceResp = new DeviceRespDTO();
|
DeviceRespDTO deviceResp = new DeviceRespDTO();
|
||||||
|
@ -87,8 +87,8 @@ public class DeviceServiceImpl implements DeviceService {
|
||||||
ManufacturerRespDTO manufacturerResp = new ManufacturerRespDTO();
|
ManufacturerRespDTO manufacturerResp = new ManufacturerRespDTO();
|
||||||
//获取厂家名称和类型
|
//获取厂家名称和类型
|
||||||
List<ManufacturerContentDTO> contents = new ArrayList<>();
|
List<ManufacturerContentDTO> contents = new ArrayList<>();
|
||||||
List<Integer> codeList = ManufacturerTypeEnum.getAllCodes();
|
List<Integer> codeList = ManufacturerTypeEnum.getAllCodes();
|
||||||
codeList.forEach(v->{
|
codeList.forEach(v -> {
|
||||||
ManufacturerContentDTO content = new ManufacturerContentDTO();
|
ManufacturerContentDTO content = new ManufacturerContentDTO();
|
||||||
content.setManufacturerType(v);
|
content.setManufacturerType(v);
|
||||||
content.setManufacturerName(ManufacturerTypeEnum.getByCode(v));
|
content.setManufacturerName(ManufacturerTypeEnum.getByCode(v));
|
||||||
|
@ -102,7 +102,7 @@ public class DeviceServiceImpl implements DeviceService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AlarmDevRespDTO getAlarmDeviceInfo() {
|
public AlarmDevRespDTO getAlarmDeviceInfo() {
|
||||||
AlarmDevRespDTO respDTO = new AlarmDevRespDTO();
|
AlarmDevRespDTO respDTO = new AlarmDevRespDTO();
|
||||||
List<AlarmDevContentDTO> contents = new ArrayList<>();
|
List<AlarmDevContentDTO> contents = new ArrayList<>();
|
||||||
|
|
||||||
//获取所有的设备属性信息
|
//获取所有的设备属性信息
|
||||||
|
@ -118,7 +118,7 @@ public class DeviceServiceImpl implements DeviceService {
|
||||||
List<Integer> typeList = AlarmTypeEnum.getAllCodes();
|
List<Integer> typeList = AlarmTypeEnum.getAllCodes();
|
||||||
typeList.forEach(type -> {
|
typeList.forEach(type -> {
|
||||||
AlarmDevContentDTO content = new AlarmDevContentDTO();
|
AlarmDevContentDTO content = new AlarmDevContentDTO();
|
||||||
String typeMsg = AlarmTypeEnum.getByCode(type);
|
String typeMsg = AlarmTypeEnum.getByCode(type);
|
||||||
log.info("alarm type :[{}]", typeMsg);
|
log.info("alarm type :[{}]", typeMsg);
|
||||||
|
|
||||||
//过滤出不同类型的设备属性
|
//过滤出不同类型的设备属性
|
||||||
|
|
|
@ -48,9 +48,9 @@ public class DeviceTaskServiceImpl implements DeviceTaskService {
|
||||||
|
|
||||||
|
|
||||||
//告警任务回示率,收到响应信息的设备数量(执行成功、执行失败)/总设备数量
|
//告警任务回示率,收到响应信息的设备数量(执行成功、执行失败)/总设备数量
|
||||||
int respNum = task.getExecNormalNum() + task.getExecAbnormalNum();
|
int respNum = task.getExecNormalNum() + task.getExecAbnormalNum();
|
||||||
int deviceNum = task.getDeviceNum();
|
int deviceNum = task.getDeviceNum();
|
||||||
double respRate = (double) respNum / (double) deviceNum;
|
double respRate = (double) respNum / (double) deviceNum;
|
||||||
|
|
||||||
//告警任务执行设备数量、执行正常数量、执行异常数量、回示率
|
//告警任务执行设备数量、执行正常数量、执行异常数量、回示率
|
||||||
taskResp.setDeviceNum(deviceNum);
|
taskResp.setDeviceNum(deviceNum);
|
||||||
|
@ -60,7 +60,7 @@ public class DeviceTaskServiceImpl implements DeviceTaskService {
|
||||||
|
|
||||||
//获取任务id详细信息
|
//获取任务id详细信息
|
||||||
List<DeviceTaskContentDTO> devTaskContents = new ArrayList<>();
|
List<DeviceTaskContentDTO> devTaskContents = new ArrayList<>();
|
||||||
List<DevTaskDO> devTaskDOList = devTaskMapper.selectDevTaskByTaskId(task.getTaskId());
|
List<DevTaskDO> devTaskDOList = devTaskMapper.selectDevTaskByTaskId(task.getTaskId());
|
||||||
if (devTaskDOList.isEmpty()) {
|
if (devTaskDOList.isEmpty()) {
|
||||||
log.warn("根据任务Id: [{}] 获取不到告警任务详情信息", task.getTaskId());
|
log.warn("根据任务Id: [{}] 获取不到告警任务详情信息", task.getTaskId());
|
||||||
taskResp.setData(new ArrayList<>());
|
taskResp.setData(new ArrayList<>());
|
||||||
|
|
|
@ -14,8 +14,8 @@ import com.zjyr.beidouservice.pojo.dto.province.CityContentDTO;
|
||||||
import com.zjyr.beidouservice.pojo.dto.province.OnlyProvinceContentDTO;
|
import com.zjyr.beidouservice.pojo.dto.province.OnlyProvinceContentDTO;
|
||||||
import com.zjyr.beidouservice.pojo.dto.province.OnlyProvinceResp;
|
import com.zjyr.beidouservice.pojo.dto.province.OnlyProvinceResp;
|
||||||
import com.zjyr.beidouservice.pojo.dto.province.ProvinceContent;
|
import com.zjyr.beidouservice.pojo.dto.province.ProvinceContent;
|
||||||
import com.zjyr.beidouservice.pojo.dto.province.ProvinceSearchDTO;
|
|
||||||
import com.zjyr.beidouservice.pojo.dto.province.ProvinceRespDTO;
|
import com.zjyr.beidouservice.pojo.dto.province.ProvinceRespDTO;
|
||||||
|
import com.zjyr.beidouservice.pojo.dto.province.ProvinceSearchDTO;
|
||||||
import com.zjyr.beidouservice.service.LocationService;
|
import com.zjyr.beidouservice.service.LocationService;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
@ -38,7 +38,7 @@ public class LocationServiceImpl implements LocationService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OnlyProvinceResp getOnlyProvinces() {
|
public OnlyProvinceResp getOnlyProvinces() {
|
||||||
OnlyProvinceResp onlyProvinceResp = new OnlyProvinceResp();
|
OnlyProvinceResp onlyProvinceResp = new OnlyProvinceResp();
|
||||||
List<OnlyProvinceContentDTO> onlyProvinceList = new ArrayList<>();
|
List<OnlyProvinceContentDTO> onlyProvinceList = new ArrayList<>();
|
||||||
|
|
||||||
//获取省份信息
|
//获取省份信息
|
||||||
|
@ -48,7 +48,7 @@ public class LocationServiceImpl implements LocationService {
|
||||||
return new OnlyProvinceResp();
|
return new OnlyProvinceResp();
|
||||||
}
|
}
|
||||||
|
|
||||||
provinceDOS.forEach(province ->{
|
provinceDOS.forEach(province -> {
|
||||||
OnlyProvinceContentDTO onlyProvinceContent = new OnlyProvinceContentDTO();
|
OnlyProvinceContentDTO onlyProvinceContent = new OnlyProvinceContentDTO();
|
||||||
onlyProvinceContent.setProvinceName(province.getProvinceName());
|
onlyProvinceContent.setProvinceName(province.getProvinceName());
|
||||||
onlyProvinceContent.setProvinceCode(province.getProvinceCode());
|
onlyProvinceContent.setProvinceCode(province.getProvinceCode());
|
||||||
|
@ -61,12 +61,12 @@ public class LocationServiceImpl implements LocationService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProvinceRespDTO getProvinces(ProvinceSearchDTO provinceSearchDTO) {
|
public ProvinceRespDTO getProvinces(ProvinceSearchDTO provinceSearchDTO) {
|
||||||
ProvinceRespDTO provinceResp = new ProvinceRespDTO();
|
ProvinceRespDTO provinceResp = new ProvinceRespDTO();
|
||||||
List<ProvinceContent> provinceContents = new ArrayList<>();
|
List<ProvinceContent> provinceContents = new ArrayList<>();
|
||||||
|
|
||||||
//获取省份信息
|
//获取省份信息
|
||||||
String provinceCode = provinceSearchDTO.getProvinceCode();
|
String provinceCode = provinceSearchDTO.getProvinceCode();
|
||||||
List<LocProvinceDO> provinceDOS = locProvinceMapper.selectProvince(provinceCode);
|
List<LocProvinceDO> provinceDOS = locProvinceMapper.selectProvince(provinceCode);
|
||||||
if (provinceDOS.isEmpty()) {
|
if (provinceDOS.isEmpty()) {
|
||||||
log.warn("不存在省份信息");
|
log.warn("不存在省份信息");
|
||||||
return new ProvinceRespDTO();
|
return new ProvinceRespDTO();
|
||||||
|
@ -80,7 +80,7 @@ public class LocationServiceImpl implements LocationService {
|
||||||
|
|
||||||
//根据省份查询对应的地市信息
|
//根据省份查询对应的地市信息
|
||||||
List<CityContentDTO> cityContentDTOList = new ArrayList<>();
|
List<CityContentDTO> cityContentDTOList = new ArrayList<>();
|
||||||
List<LocCityDO> cityDOList = locCityMapper.selectCityByProvince(province.getProvinceCode());
|
List<LocCityDO> cityDOList = locCityMapper.selectCityByProvince(province.getProvinceCode());
|
||||||
cityDOList.forEach(city -> {
|
cityDOList.forEach(city -> {
|
||||||
CityContentDTO cityContent = new CityContentDTO();
|
CityContentDTO cityContent = new CityContentDTO();
|
||||||
cityContent.setCityName(city.getCityName());
|
cityContent.setCityName(city.getCityName());
|
||||||
|
@ -100,13 +100,13 @@ public class LocationServiceImpl implements LocationService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CityRespDTO getCity(CitySearchDTO citySearchDTO) {
|
public CityRespDTO getCity(CitySearchDTO citySearchDTO) {
|
||||||
CityRespDTO cityResp = new CityRespDTO();
|
CityRespDTO cityResp = new CityRespDTO();
|
||||||
List<CityCountyDTO> cityContents = new ArrayList<>();
|
List<CityCountyDTO> cityContents = new ArrayList<>();
|
||||||
|
|
||||||
//获取地市信息
|
//获取地市信息
|
||||||
String provinceCode = citySearchDTO.getProvinceCode();
|
String provinceCode = citySearchDTO.getProvinceCode();
|
||||||
String cityCode = citySearchDTO.getCityCode();
|
String cityCode = citySearchDTO.getCityCode();
|
||||||
List<LocCityDO> cityDOS = locCityMapper.selectCity(provinceCode, cityCode);
|
List<LocCityDO> cityDOS = locCityMapper.selectCity(provinceCode, cityCode);
|
||||||
if (cityDOS.isEmpty()) {
|
if (cityDOS.isEmpty()) {
|
||||||
log.warn("不存在地市信息");
|
log.warn("不存在地市信息");
|
||||||
return new CityRespDTO();
|
return new CityRespDTO();
|
||||||
|
@ -120,7 +120,7 @@ public class LocationServiceImpl implements LocationService {
|
||||||
|
|
||||||
//根据地市查询对应的区信息
|
//根据地市查询对应的区信息
|
||||||
List<CountyContent> countyContentList = new ArrayList<>();
|
List<CountyContent> countyContentList = new ArrayList<>();
|
||||||
List<LocCountyDO> countyDOList = locCountyMapper.selectCountyByCity(city.getProvinceCode(), city.getCityCode());
|
List<LocCountyDO> countyDOList = locCountyMapper.selectCountyByCity(city.getProvinceCode(), city.getCityCode());
|
||||||
countyDOList.forEach(county -> {
|
countyDOList.forEach(county -> {
|
||||||
CountyContent countyContent = new CountyContent();
|
CountyContent countyContent = new CountyContent();
|
||||||
countyContent.setCountyName(county.getCountyName());
|
countyContent.setCountyName(county.getCountyName());
|
||||||
|
|
|
@ -74,12 +74,8 @@ public class SensorDataServiceImpl implements SensorDataService {
|
||||||
.startAddr(v.getStartAddr().intValue())
|
.startAddr(v.getStartAddr().intValue())
|
||||||
.dtInfo(v.getDtInfo().intValue())
|
.dtInfo(v.getDtInfo().intValue())
|
||||||
.warrningStatus(v.getWarrningStatus())
|
.warrningStatus(v.getWarrningStatus())
|
||||||
.emergStatus(createStatusMapValue(v.getEmergenStatus0(),
|
.emergStatus(createStatusMapValue(v.getEmergenStatus0(), v.getEmergenStatus1(), v.getEmergenStatus2()))
|
||||||
v.getEmergenStatus1(),
|
.spearkStatus(createStatusMapValue(v.getSpeakerStatus0(), v.getSpeakerStatus1(), v.getSpeakerStatus2()))
|
||||||
v.getEmergenStatus2()))
|
|
||||||
.spearkStatus(createStatusMapValue(v.getSpeakerStatus0(),
|
|
||||||
v.getSpeakerStatus1(),
|
|
||||||
v.getSpeakerStatus2()))
|
|
||||||
.runStatus(v.getRunStatus())
|
.runStatus(v.getRunStatus())
|
||||||
.signalStrength(v.getSignalStrength())
|
.signalStrength(v.getSignalStrength())
|
||||||
.beidouId(v.getBeidouId())
|
.beidouId(v.getBeidouId())
|
||||||
|
|
|
@ -27,20 +27,16 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<update id="upgradeControlDevice" parameterType="com.zjyr.beidouservice.pojo.entry.ControlDevice">
|
<update id="upgradeControlDevice" parameterType="com.zjyr.beidouservice.pojo.entry.ControlDevice">
|
||||||
INSERT IGNORE INTO control_device(deviceAddr, deviceType, sendEnabled, beidouStatus, beidouChannelStatus,
|
UPDATE control_device
|
||||||
beidouSignalStrength, wirelessStatus, telphoneStatus)
|
SET deviceAddr = #{device.deviceAddr},
|
||||||
SELECT #{device.deviceAddr},
|
deviceType = #{device.deviceType},
|
||||||
#{device.deviceType},
|
sendEnabled = #{device.sendEnabled},
|
||||||
#{device.sendEnabled},
|
beidouStatus = #{device.beidouStatus},
|
||||||
#{device.beidouStatus},
|
beidouChannelStatus = #{device.beidouChannelStatus},
|
||||||
#{device.beidouChannelStatus},
|
beidouSignalStrength = #{device.beidouSignalStrength},
|
||||||
#{device.beidouSignalStrength},
|
wirelessStatus = #{device.wirelessStatus},
|
||||||
#{device.wirelessStatus},
|
telphoneStatus = #{device.telphoneStatus}
|
||||||
#{device.telphoneStatus}
|
WHERE deviceAddr = #{device.deviceAddr}
|
||||||
FROM DUAL
|
|
||||||
WHERE NOT EXISTS (SELECT deviceAddr
|
|
||||||
FROM control_device
|
|
||||||
WHERE deviceAddr = #{device.deviceAddr})
|
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<insert id="addControlDevice" useGeneratedKeys="true" keyProperty="id"
|
<insert id="addControlDevice" useGeneratedKeys="true" keyProperty="id"
|
||||||
|
|
Loading…
Reference in New Issue