1. 修改心跳协议以及控制器状态回复协议
This commit is contained in:
parent
28c904076a
commit
1faa9ff0ca
|
@ -1,20 +1,12 @@
|
||||||
package com.zjyr.beidouservice.adapter.impl.netty.decode;
|
package com.zjyr.beidouservice.adapter.impl.netty.decode;
|
||||||
|
|
||||||
import com.zjyr.beidouservice.common.CommonEnumHandler;
|
import com.zjyr.beidouservice.common.CommonEnumHandler;
|
||||||
import com.zjyr.beidouservice.common.impl.BeidouStatusName;
|
import com.zjyr.beidouservice.common.impl.ControlChannelStatus;
|
||||||
import com.zjyr.beidouservice.common.impl.ControlCommandName;
|
import com.zjyr.beidouservice.common.impl.ControlCommandName;
|
||||||
import com.zjyr.beidouservice.common.impl.SendStatusName;
|
import com.zjyr.beidouservice.common.impl.SendStatusName;
|
||||||
import com.zjyr.beidouservice.common.impl.SensorControlTunnelName;
|
import com.zjyr.beidouservice.common.impl.SensorControlTunnelName;
|
||||||
import com.zjyr.beidouservice.common.impl.SensorStatusName;
|
|
||||||
import com.zjyr.beidouservice.common.impl.TelphoneStatusName;
|
|
||||||
import com.zjyr.beidouservice.common.impl.WirelessStatusName;
|
|
||||||
import com.zjyr.beidouservice.misc.HelperUtils;
|
import com.zjyr.beidouservice.misc.HelperUtils;
|
||||||
import com.zjyr.beidouservice.pojo.vo.binary.BaseBinaryProtocol;
|
import com.zjyr.beidouservice.pojo.vo.binary.*;
|
||||||
import com.zjyr.beidouservice.pojo.vo.binary.ControllerStatus;
|
|
||||||
import com.zjyr.beidouservice.pojo.vo.binary.MessageContent;
|
|
||||||
import com.zjyr.beidouservice.pojo.vo.binary.SensorCotrolAck;
|
|
||||||
import com.zjyr.beidouservice.pojo.vo.binary.SensorStatusAck;
|
|
||||||
import com.zjyr.beidouservice.pojo.vo.binary.SensorStatusInfo;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.ByteBufUtil;
|
import io.netty.buffer.ByteBufUtil;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
|
@ -37,75 +29,83 @@ 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();
|
||||||
int commandId = buf.readInt();
|
int commandId = buf.readInt();
|
||||||
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());
|
||||||
|
ControlChannelStatus beidouStatus = CommonEnumHandler.codeOf(ControlChannelStatus.class, buf.readByte());
|
||||||
|
byte[] beidouCommFreq = new byte[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);
|
||||||
SensorStatusName wireStatus = CommonEnumHandler.codeOf(SensorStatusName.class, buf.readByte());
|
ControlChannelStatus wireStatus = CommonEnumHandler.codeOf(ControlChannelStatus.class, buf.readByte());
|
||||||
SensorStatusName phoneStatus = CommonEnumHandler.codeOf(SensorStatusName.class, buf.readByte());
|
ControlChannelStatus phoneStatus = CommonEnumHandler.codeOf(ControlChannelStatus.class, buf.readByte());
|
||||||
|
|
||||||
ControllerStatus status = ControllerStatus.builder()
|
ControllerStatus status = ControllerStatus.builder()
|
||||||
.beidouSignalStrength(beidouSignal)
|
.sendStatus(sendStatus)
|
||||||
.wirelessStatus(wireStatus)
|
.beidouStatus(beidouStatus)
|
||||||
.telphoneStatus(phoneStatus)
|
.beidouFreq(beidouCommFreq)
|
||||||
.build();
|
.beidouSignalStrength(beidouSignal)
|
||||||
|
.wirelessStatus(wireStatus)
|
||||||
|
.telphoneStatus(phoneStatus)
|
||||||
|
.build();
|
||||||
|
|
||||||
MessageContent<ControllerStatus> msgCtx = MessageContent.<ControllerStatus>builder().msgType(
|
MessageContent<ControllerStatus> msgCtx = MessageContent.<ControllerStatus>builder().msgType(
|
||||||
msgType).msgSize(msgSize).msgBody(status).build();
|
msgType).msgSize(msgSize).msgBody(status).build();
|
||||||
|
|
||||||
list.add(BaseBinaryProtocol.<ControllerStatus>builder()
|
list.add(BaseBinaryProtocol.<ControllerStatus>builder()
|
||||||
.msgLength(msgLength)
|
.msgLength(msgLength)
|
||||||
.version(version)
|
.version(version)
|
||||||
.commandId(commandId)
|
.commandId(commandId)
|
||||||
.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 -> {
|
||||||
SendStatusName sendStatus = CommonEnumHandler.codeOf(SendStatusName.class, buf.readByte());
|
// SendStatusName sendStatus = CommonEnumHandler.codeOf(SendStatusName.class, buf.readByte());
|
||||||
BeidouStatusName beidouStatus = CommonEnumHandler.codeOf(BeidouStatusName.class,
|
// BeidouStatusName beidouStatus = CommonEnumHandler.codeOf(BeidouStatusName.class,
|
||||||
buf.readByte());
|
// buf.readByte());
|
||||||
WirelessStatusName wireStatus = CommonEnumHandler.codeOf(WirelessStatusName.class,
|
// WirelessStatusName wireStatus = CommonEnumHandler.codeOf(WirelessStatusName.class,
|
||||||
buf.readByte());
|
// buf.readByte());
|
||||||
TelphoneStatusName phoneStatus = CommonEnumHandler.codeOf(TelphoneStatusName.class,
|
// TelphoneStatusName phoneStatus = CommonEnumHandler.codeOf(TelphoneStatusName.class,
|
||||||
buf.readByte());
|
// buf.readByte());
|
||||||
byte[] beidouSignle = new byte[3];
|
// byte[] beidouSignle = new byte[3];
|
||||||
buf.readBytes(beidouSignle, 0, 3);
|
// buf.readBytes(beidouSignle, 0, 3);
|
||||||
|
//
|
||||||
SensorCotrolAck ack = SensorCotrolAck.builder()
|
// SensorCotrolAck ack = SensorCotrolAck.builder()
|
||||||
.sendStatus(sendStatus)
|
// .sendStatus(sendStatus)
|
||||||
.beidouStatus(beidouStatus)
|
// .beidouStatus(beidouStatus)
|
||||||
.wirelessStatus(wireStatus)
|
// .wirelessStatus(wireStatus)
|
||||||
.telphoneStatus(phoneStatus)
|
// .telphoneStatus(phoneStatus)
|
||||||
.beidouFreq(beidouSignle)
|
// .beidouFreq(beidouSignle)
|
||||||
.build();
|
// .build();
|
||||||
|
//
|
||||||
MessageContent<SensorCotrolAck> msgCtx = MessageContent.<SensorCotrolAck>builder().msgType(
|
// MessageContent<SensorCotrolAck> msgCtx = MessageContent.<SensorCotrolAck>builder().msgType(
|
||||||
msgType).msgSize(msgSize).msgBody(ack).build();
|
// msgType).msgSize(msgSize).msgBody(ack).build();
|
||||||
list.add(BaseBinaryProtocol.<SensorCotrolAck>builder()
|
// list.add(BaseBinaryProtocol.<SensorCotrolAck>builder()
|
||||||
.msgLength(msgLength)
|
// .msgLength(msgLength)
|
||||||
.version(version)
|
// .version(version)
|
||||||
.commandId(commandId)
|
// .commandId(commandId)
|
||||||
.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(
|
||||||
|
@ -114,53 +114,53 @@ public class YuanRongProtocolDecode extends ByteToMessageDecoder {
|
||||||
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)
|
||||||
.commandId(commandId)
|
.commandId(commandId)
|
||||||
.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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class YuanRongProtocolEncode<T> extends MessageToByteEncoder<BaseBinaryPr
|
||||||
byteBuf.writeByte(msg.getNControlInfo());
|
byteBuf.writeByte(msg.getNControlInfo());
|
||||||
for (var c : msg.getControllContents()) {
|
for (var c : msg.getControllContents()) {
|
||||||
byteBuf.writeByte(c.getDistrictsCode());
|
byteBuf.writeByte(c.getDistrictsCode());
|
||||||
byteBuf.writeByte(c.getControlAction().getValue().byteValue());
|
//byteBuf.writeByte(c.getControlAction().getValue().byteValue());
|
||||||
byteBuf.writeShort(c.getSensorId());
|
byteBuf.writeShort(c.getSensorId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ public class YuanRongProtocolEncode<T> extends MessageToByteEncoder<BaseBinaryPr
|
||||||
byteBuf.writeByte(msg.getNControlInfo());
|
byteBuf.writeByte(msg.getNControlInfo());
|
||||||
for (var c : msg.getControllContents()) {
|
for (var c : msg.getControllContents()) {
|
||||||
byteBuf.writeByte(c.getDistrictsCode());
|
byteBuf.writeByte(c.getDistrictsCode());
|
||||||
byteBuf.writeByte(c.getControlAction().getValue().byteValue());
|
//byteBuf.writeByte(c.getControlAction().getValue().byteValue());
|
||||||
byteBuf.writeShort(c.getSensorId());
|
byteBuf.writeShort(c.getSensorId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,12 @@ package com.zjyr.beidouservice.common.impl;
|
||||||
|
|
||||||
import com.zjyr.beidouservice.common.EnumerationBase;
|
import com.zjyr.beidouservice.common.EnumerationBase;
|
||||||
|
|
||||||
public enum BeidouStatusName implements EnumerationBase {
|
public enum ControlChannelStatus implements EnumerationBase {
|
||||||
BEIDOU_NORMAL(0, "BEIDOU_NORMAL"),
|
CHANNEL_NORMAL(0, "CHANNEL_NORMAL"),
|
||||||
BEIDOU_MODULE_EXCEPTION(1, "BEIDOU_MODULE_EXCEPTION"),
|
CHANNEL_MODULE_UNEXISTS(1, "CHANNEL_MODULE_UNEXISTS"),
|
||||||
BEIDOU_SATELLITE_EXCEPTION(2, "BEIDOU_SATELLITE_EXCEPTION"),
|
CHANNEL_MODULE_EXCEPTION(2, "CHANNEL_MODULE_EXCEPTION"),
|
||||||
|
BEIDOU_MODULE_EXCEPTION(3, "BEIDOU_MODULE_EXCEPTION"),
|
||||||
|
BEIDOU_SATELLITE_EXCEPTION(4, "BEIDOU_SATELLITE_EXCEPTION"),
|
||||||
;
|
;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,7 +25,7 @@ public enum BeidouStatusName implements EnumerationBase {
|
||||||
* @param val the val
|
* @param val the val
|
||||||
* @param desc the desc
|
* @param desc the desc
|
||||||
*/
|
*/
|
||||||
BeidouStatusName(int val, String desc) {
|
ControlChannelStatus(int val, String desc) {
|
||||||
this.code = val;
|
this.code = val;
|
||||||
this.desc = desc;
|
this.desc = desc;
|
||||||
}
|
}
|
|
@ -1,54 +0,0 @@
|
||||||
package com.zjyr.beidouservice.common.impl;
|
|
||||||
|
|
||||||
import com.zjyr.beidouservice.common.EnumerationBase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The enum Sensor control action name.
|
|
||||||
*/
|
|
||||||
public enum SensorControlActionName implements EnumerationBase {
|
|
||||||
/**
|
|
||||||
* Action single point sensor control action name.
|
|
||||||
*/
|
|
||||||
ACTION_SINGLE_POINT(0, "ACTION_SINGLE_POINT"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Action city based sensor control action name.
|
|
||||||
*/
|
|
||||||
ACTION_CITY_BASED(1, "ACTION_CITY_BASED"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Action districts based sensor control action name.
|
|
||||||
*/
|
|
||||||
ACTION_DISTRICTS_BASED(2, "ACTION_DISTRICTS_BASED"),
|
|
||||||
;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Code.
|
|
||||||
*/
|
|
||||||
private final Integer code;
|
|
||||||
/**
|
|
||||||
* The Desc.
|
|
||||||
*/
|
|
||||||
private final String desc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiates a new Sensor control action name.
|
|
||||||
*
|
|
||||||
* @param val the val
|
|
||||||
* @param desc the desc
|
|
||||||
*/
|
|
||||||
SensorControlActionName(int val, String desc) {
|
|
||||||
this.code = val;
|
|
||||||
this.desc = desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer getValue() {
|
|
||||||
return this.code;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescription() {
|
|
||||||
return this.desc;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
package com.zjyr.beidouservice.common.impl;
|
|
||||||
|
|
||||||
import com.zjyr.beidouservice.common.EnumerationBase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The enum Sensor status name.
|
|
||||||
*/
|
|
||||||
public enum SensorStatusName implements EnumerationBase {
|
|
||||||
/**
|
|
||||||
* Wireless noexists sensor status name.
|
|
||||||
*/
|
|
||||||
WIRELESS_NOEXISTS(0, "WIRELESS_NOEXISTS"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wireless normal sensor status name.
|
|
||||||
*/
|
|
||||||
WIRELESS_NORMAL(1, "WIRELESS_NORMAL"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wireless exception sensor status name.
|
|
||||||
*/
|
|
||||||
WIRELESS_EXCEPTION(2, "WIRELESS_EXCEPTION"),
|
|
||||||
;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Code.
|
|
||||||
*/
|
|
||||||
private final Integer code;
|
|
||||||
/**
|
|
||||||
* The Desc.
|
|
||||||
*/
|
|
||||||
private final String desc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiates a new Sensor status name.
|
|
||||||
*
|
|
||||||
* @param val the val
|
|
||||||
* @param desc the desc
|
|
||||||
*/
|
|
||||||
SensorStatusName(int val, String desc) {
|
|
||||||
this.code = val;
|
|
||||||
this.desc = desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer getValue() {
|
|
||||||
return this.code;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescription() {
|
|
||||||
return this.desc;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
package com.zjyr.beidouservice.common.impl;
|
|
||||||
|
|
||||||
import com.zjyr.beidouservice.common.EnumerationBase;
|
|
||||||
|
|
||||||
public enum TelphoneStatusName implements EnumerationBase {
|
|
||||||
TELPHONE_NORMAL(0, "TELPHONE_NORMAL"),
|
|
||||||
TELPHONE_NOT_DETECTION(1, "TELPHONE_NOT_DETECTION"),
|
|
||||||
TELPHONE_BREAKDOWN(2, "TELPHONE_BREAKDOWN"),
|
|
||||||
;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Code.
|
|
||||||
*/
|
|
||||||
private final Integer code;
|
|
||||||
/**
|
|
||||||
* The Desc.
|
|
||||||
*/
|
|
||||||
private final String desc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiates a new Beidou adapter type name.
|
|
||||||
*
|
|
||||||
* @param val the val
|
|
||||||
* @param desc the desc
|
|
||||||
*/
|
|
||||||
TelphoneStatusName(int val, String desc) {
|
|
||||||
this.code = val;
|
|
||||||
this.desc = desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer getValue() {
|
|
||||||
return this.code;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescription() {
|
|
||||||
return this.desc;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
package com.zjyr.beidouservice.common.impl;
|
|
||||||
|
|
||||||
import com.zjyr.beidouservice.common.EnumerationBase;
|
|
||||||
|
|
||||||
public enum WirelessStatusName implements EnumerationBase {
|
|
||||||
|
|
||||||
WIRELESS_NORMAL(0, "WIRELESS_NORMAL"),
|
|
||||||
WIRELESS_BREAKDOWN(0, "WIRELESS_BREAKDOWN"),
|
|
||||||
;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Code.
|
|
||||||
*/
|
|
||||||
private final Integer code;
|
|
||||||
/**
|
|
||||||
* The Desc.
|
|
||||||
*/
|
|
||||||
private final String desc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiates a new Beidou adapter type name.
|
|
||||||
*
|
|
||||||
* @param val the val
|
|
||||||
* @param desc the desc
|
|
||||||
*/
|
|
||||||
WirelessStatusName(int val, String desc) {
|
|
||||||
this.code = val;
|
|
||||||
this.desc = desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer getValue() {
|
|
||||||
return this.code;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescription() {
|
|
||||||
return this.desc;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.zjyr.beidouservice.controller;
|
package com.zjyr.beidouservice.controller;
|
||||||
|
|
||||||
import com.zjyr.beidouservice.common.impl.SensorControlActionName;
|
|
||||||
import com.zjyr.beidouservice.common.impl.SensorControlModeName;
|
import com.zjyr.beidouservice.common.impl.SensorControlModeName;
|
||||||
import com.zjyr.beidouservice.common.impl.SensorControlTunnelName;
|
import com.zjyr.beidouservice.common.impl.SensorControlTunnelName;
|
||||||
import com.zjyr.beidouservice.pojo.dto.BaseProtocolDTO;
|
import com.zjyr.beidouservice.pojo.dto.BaseProtocolDTO;
|
||||||
|
@ -62,11 +61,11 @@ public class AuthUser {
|
||||||
List<BeidouAdapterControlContent> adapterInfo = new ArrayList<>();
|
List<BeidouAdapterControlContent> adapterInfo = new ArrayList<>();
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
adapterInfo.add(BeidouAdapterControlContent.builder()
|
// adapterInfo.add(BeidouAdapterControlContent.builder()
|
||||||
.districtsCode(0x10 + i)
|
// .districtsCode(0x10 + i)
|
||||||
.sensorId(0x3f00 + i)
|
// .sensorId(0x3f00 + i)
|
||||||
.controlAction(SensorControlActionName.ACTION_DISTRICTS_BASED)
|
// .controlAction(SensorControlActionName.ACTION_DISTRICTS_BASED)
|
||||||
.build());
|
// .build());
|
||||||
}
|
}
|
||||||
|
|
||||||
SensorControlProtocol sp =
|
SensorControlProtocol sp =
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class ControlDevice {
|
||||||
*/
|
*/
|
||||||
@Id
|
@Id
|
||||||
@KeySql(useGeneratedKeys = true)
|
@KeySql(useGeneratedKeys = true)
|
||||||
private Long id;
|
private Long id;
|
||||||
/**
|
/**
|
||||||
* The Device type.
|
* The Device type.
|
||||||
*/
|
*/
|
||||||
|
@ -39,12 +39,18 @@ public class ControlDevice {
|
||||||
/**
|
/**
|
||||||
* The Device addr.
|
* The Device addr.
|
||||||
*/
|
*/
|
||||||
private String deviceAddr;
|
private String deviceAddr;
|
||||||
|
|
||||||
|
private Integer sendEnabled;
|
||||||
|
|
||||||
|
private Integer beidouStatus;
|
||||||
|
|
||||||
|
private String beidouChannelStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Beidou signal strength.
|
* The Beidou signal strength.
|
||||||
*/
|
*/
|
||||||
private String beidouSignalStrength;
|
private String beidouSignalStrength;
|
||||||
/**
|
/**
|
||||||
* The Wireless status.
|
* The Wireless status.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.zjyr.beidouservice.pojo.po;
|
package com.zjyr.beidouservice.pojo.po;
|
||||||
|
|
||||||
import com.zjyr.beidouservice.common.impl.SensorControlActionName;
|
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
@ -14,7 +13,7 @@ public class BeidouAdapterControlContent {
|
||||||
/**
|
/**
|
||||||
* The Control action.
|
* The Control action.
|
||||||
*/
|
*/
|
||||||
private SensorControlActionName controlAction;
|
//private SensorControlActionName controlAction;
|
||||||
/**
|
/**
|
||||||
* The Sensor id.
|
* The Sensor id.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -13,7 +13,7 @@ public class BeidouAdapterDevice {
|
||||||
/**
|
/**
|
||||||
* The Id.
|
* The Id.
|
||||||
*/
|
*/
|
||||||
private Long id;
|
private long id;
|
||||||
/**
|
/**
|
||||||
* The Adapter type.
|
* The Adapter type.
|
||||||
*/
|
*/
|
||||||
|
@ -21,17 +21,20 @@ public class BeidouAdapterDevice {
|
||||||
/**
|
/**
|
||||||
* The Adapter addr.
|
* The Adapter addr.
|
||||||
*/
|
*/
|
||||||
private String adapterAddr;
|
private String adapterAddr;
|
||||||
|
private int sendEnabled;
|
||||||
|
private int beidouStatus;
|
||||||
|
private String beidouChannelStatus;
|
||||||
/**
|
/**
|
||||||
* The Beidou signal strength.
|
* The Beidou signal strength.
|
||||||
*/
|
*/
|
||||||
private String beidouSignalStrength;
|
private String beidouSignalStrength;
|
||||||
/**
|
/**
|
||||||
* The Wireless status.
|
* The Wireless status.
|
||||||
*/
|
*/
|
||||||
private Integer wirelessStatus;
|
private int wirelessStatus;
|
||||||
/**
|
/**
|
||||||
* The Telphone status.
|
* The Telphone status.
|
||||||
*/
|
*/
|
||||||
private Integer telphoneStatus;
|
private int telphoneStatus;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.zjyr.beidouservice.pojo.vo.binary;
|
package com.zjyr.beidouservice.pojo.vo.binary;
|
||||||
|
|
||||||
import com.zjyr.beidouservice.common.impl.SensorStatusName;
|
import com.zjyr.beidouservice.common.impl.*;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
@ -10,16 +10,14 @@ import lombok.Data;
|
||||||
@Data
|
@Data
|
||||||
@Builder
|
@Builder
|
||||||
public class ControllerStatus {
|
public class ControllerStatus {
|
||||||
|
private byte[] beidouFreq;
|
||||||
/**
|
/**
|
||||||
* The Beidou signal strength.
|
* The Beidou signal strength.
|
||||||
*/
|
*/
|
||||||
private byte[] beidouSignalStrength;
|
private byte[] beidouSignalStrength;
|
||||||
/**
|
private SendStatusName sendStatus;
|
||||||
* The Wireless status.
|
private ControlChannelStatus beidouStatus;
|
||||||
*/
|
private ControlChannelStatus wirelessStatus;
|
||||||
private SensorStatusName wirelessStatus;
|
private ControlChannelStatus telphoneStatus;
|
||||||
/**
|
|
||||||
* The Telphone status.
|
|
||||||
*/
|
|
||||||
private SensorStatusName telphoneStatus;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.zjyr.beidouservice.pojo.vo.binary;
|
package com.zjyr.beidouservice.pojo.vo.binary;
|
||||||
|
|
||||||
import com.zjyr.beidouservice.common.impl.SensorControlActionName;
|
//import com.zjyr.beidouservice.common.impl.SensorControlActionName;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ public class SensorControllContent {
|
||||||
/**
|
/**
|
||||||
* The Control action.
|
* The Control action.
|
||||||
*/
|
*/
|
||||||
private SensorControlActionName controlAction;
|
//private SensorControlActionName controlAction;
|
||||||
/**
|
/**
|
||||||
* The Sensor id.
|
* The Sensor id.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
package com.zjyr.beidouservice.pojo.vo.binary;
|
|
||||||
|
|
||||||
import com.zjyr.beidouservice.common.impl.BeidouStatusName;
|
|
||||||
import com.zjyr.beidouservice.common.impl.SendStatusName;
|
|
||||||
import com.zjyr.beidouservice.common.impl.TelphoneStatusName;
|
|
||||||
import com.zjyr.beidouservice.common.impl.WirelessStatusName;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
public class SensorCotrolAck {
|
|
||||||
private byte[] beidouFreq;
|
|
||||||
|
|
||||||
private SendStatusName sendStatus;
|
|
||||||
private BeidouStatusName beidouStatus;
|
|
||||||
private WirelessStatusName wirelessStatus;
|
|
||||||
private TelphoneStatusName telphoneStatus;
|
|
||||||
}
|
|
|
@ -9,7 +9,6 @@ import com.zjyr.beidouservice.pojo.entry.ControlDevice;
|
||||||
import com.zjyr.beidouservice.pojo.po.BeidouAdapterDevice;
|
import com.zjyr.beidouservice.pojo.po.BeidouAdapterDevice;
|
||||||
import com.zjyr.beidouservice.pojo.vo.ControlAdapterSocketCtx;
|
import com.zjyr.beidouservice.pojo.vo.ControlAdapterSocketCtx;
|
||||||
import com.zjyr.beidouservice.pojo.vo.binary.ControllerStatus;
|
import com.zjyr.beidouservice.pojo.vo.binary.ControllerStatus;
|
||||||
import com.zjyr.beidouservice.pojo.vo.binary.SensorCotrolAck;
|
|
||||||
import com.zjyr.beidouservice.pojo.vo.binary.SensorStatusAck;
|
import com.zjyr.beidouservice.pojo.vo.binary.SensorStatusAck;
|
||||||
import com.zjyr.beidouservice.service.AdapterProtocolService;
|
import com.zjyr.beidouservice.service.AdapterProtocolService;
|
||||||
import com.zjyr.beidouservice.service.BaidouAdapterService;
|
import com.zjyr.beidouservice.service.BaidouAdapterService;
|
||||||
|
@ -33,7 +32,7 @@ import static com.zjyr.beidouservice.common.impl.SocketEventName.SOCKET_EVT_CONN
|
||||||
@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,15 +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, SOCKET_EVT_IDLE_TIMEOUT -> {
|
case SOCKET_EVT_CONNECT -> {
|
||||||
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());
|
||||||
|
@ -90,6 +88,10 @@ 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()) {
|
||||||
|
@ -101,17 +103,28 @@ 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()));
|
||||||
} else if (event.getEvtMessage() instanceof SensorCotrolAck ack) {
|
BeidouAdapterDevice a = BeidouAdapterDevice.builder()
|
||||||
|
.adapterType(BeidouAdapterTypeName.ADAPTER_SOCKET_TCP)
|
||||||
|
.adapterAddr(sa.getAddress().getHostAddress())
|
||||||
|
.sendEnabled(status.getSendStatus().getValue())
|
||||||
|
.beidouStatus(status.getBeidouStatus().getValue())
|
||||||
|
.beidouChannelStatus(HelperUtils.bytesToHexString(status.getBeidouFreq()))
|
||||||
|
.beidouSignalStrength(HelperUtils.bytesToHexString(status.getBeidouSignalStrength()))
|
||||||
|
.wirelessStatus(status.getWirelessStatus().getValue())
|
||||||
|
.telphoneStatus(status.getTelphoneStatus().getValue())
|
||||||
|
.build();
|
||||||
|
addNewBeidouAdapter(a);
|
||||||
|
} /*else if (event.getEvtMessage() instanceof SensorCotrolAck ack) {
|
||||||
log.info("+++{}, {}, {}, {}, {}",
|
log.info("+++{}, {}, {}, {}, {}",
|
||||||
ack.getSendStatus(),
|
ack.getSendStatus(),
|
||||||
ack.getBeidouStatus(),
|
ack.getBeidouStatus(),
|
||||||
ack.getWirelessStatus(),
|
ack.getWirelessStatus(),
|
||||||
ack.getTelphoneStatus(),
|
ack.getTelphoneStatus(),
|
||||||
HelperUtils.bytesToHexString(ack.getBeidouFreq()));
|
HelperUtils.bytesToHexString(ack.getBeidouFreq()));
|
||||||
} else if (event.getEvtMessage() instanceof SensorStatusAck ack) {
|
}*/ else if (event.getEvtMessage() instanceof SensorStatusAck ack) {
|
||||||
log.info("+++Total Sensors: {}", ack.getSensorStatus().size());
|
log.info("+++Total Sensors: {}", ack.getSensorStatus().size());
|
||||||
sensorDataService.addNewSensor(ack.getSensorStatus());
|
sensorDataService.addNewSensor(ack.getSensorStatus());
|
||||||
}
|
}
|
||||||
|
@ -129,13 +142,13 @@ 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())
|
||||||
.beidouSignalStrength(c.getBeidouSignalStrength())
|
.beidouSignalStrength(c.getBeidouSignalStrength())
|
||||||
.wirelessStatus(c.getWirelessStatus())
|
.wirelessStatus(c.getWirelessStatus())
|
||||||
.telphoneStatus(c.getTelphoneStatus())
|
.telphoneStatus(c.getTelphoneStatus())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
return adapterDevices;
|
return adapterDevices;
|
||||||
|
@ -147,13 +160,16 @@ 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())
|
||||||
.beidouSignalStrength(adapter.getBeidouSignalStrength())
|
.beidouStatus(adapter.getBeidouStatus())
|
||||||
.wirelessStatus(adapter.getWirelessStatus())
|
.sendEnabled(adapter.getSendEnabled())
|
||||||
.telphoneStatus(adapter.getTelphoneStatus())
|
.beidouChannelStatus(adapter.getBeidouChannelStatus())
|
||||||
.build();
|
.beidouSignalStrength(adapter.getBeidouSignalStrength())
|
||||||
|
.wirelessStatus(adapter.getWirelessStatus())
|
||||||
|
.telphoneStatus(adapter.getTelphoneStatus())
|
||||||
|
.build();
|
||||||
BeidouAdapterDevice dev = getAdapterByAddr(adapter.getAdapterAddr());
|
BeidouAdapterDevice dev = getAdapterByAddr(adapter.getAdapterAddr());
|
||||||
if (dev == null) {
|
if (dev == null) {
|
||||||
controlDeviceMapper.addControlDevice(device);
|
controlDeviceMapper.addControlDevice(device);
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class BeidouSocketProtocolServiceImpl implements AdapterProtocolService {
|
||||||
for (BeidouAdapterControlContent v : ctxList) {
|
for (BeidouAdapterControlContent v : ctxList) {
|
||||||
list.add(SensorControllContent.builder()
|
list.add(SensorControllContent.builder()
|
||||||
.districtsCode(v.getDistrictsCode().byteValue())
|
.districtsCode(v.getDistrictsCode().byteValue())
|
||||||
.controlAction(v.getControlAction())
|
//.controlAction(v.getControlAction())
|
||||||
.sensorId(v.getSensorId().shortValue())
|
.sensorId(v.getSensorId().shortValue())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,29 +5,59 @@
|
||||||
<id column="id" property="id"/>
|
<id column="id" property="id"/>
|
||||||
<result column="deviceType" property="deviceType"/>
|
<result column="deviceType" property="deviceType"/>
|
||||||
<result column="deviceAddr" property="deviceAddr"/>
|
<result column="deviceAddr" property="deviceAddr"/>
|
||||||
|
<result column="sendEnabled" property="sendEnabled"/>
|
||||||
|
<result column="beidouStatus" property="beidouStatus"/>
|
||||||
|
<result column="beidouChannelStatus" property="beidouChannelStatus"/>
|
||||||
<result column="beidouSignalStrength" property="beidouSignalStrength"/>
|
<result column="beidouSignalStrength" property="beidouSignalStrength"/>
|
||||||
<result column="wirelessStatus" property="wirelessStatus"/>
|
<result column="wirelessStatus" property="wirelessStatus"/>
|
||||||
<result column="telphoneStatus" property="telphoneStatus"/>
|
<result column="telphoneStatus" property="telphoneStatus"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<select id="selectAll" resultMap="control_device">
|
<select id="selectAll" resultMap="control_device">
|
||||||
SELECT id, deviceAddr, deviceType, beidouSignalStrength, wirelessStatus, telphoneStatus
|
SELECT id,
|
||||||
|
deviceAddr,
|
||||||
|
deviceType,
|
||||||
|
sendEnabled,
|
||||||
|
beidouStatus,
|
||||||
|
beidouChannelStatus,
|
||||||
|
beidouSignalStrength,
|
||||||
|
wirelessStatus,
|
||||||
|
telphoneStatus
|
||||||
FROM control_device
|
FROM control_device
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<update id="upgradeControlDevice" parameterType="com.zjyr.beidouservice.pojo.entry.ControlDevice">
|
<update id="upgradeControlDevice" parameterType="com.zjyr.beidouservice.pojo.entry.ControlDevice">
|
||||||
UPDATE control_device
|
INSERT IGNORE INTO control_device(deviceAddr, deviceType, sendEnabled, beidouStatus, beidouChannelStatus,
|
||||||
SET beidouSignalStrength = #{dev.beidouSignalStrength},
|
beidouSignalStrength, wirelessStatus, telphoneStatus)
|
||||||
wirelessStatus = #{dev.wirelessStatus},
|
SELECT #{device.deviceAddr},
|
||||||
telphoneStatus = #{dev.telphoneStatus}
|
#{device.deviceType},
|
||||||
WHERE deviceAddr = #{dev.deviceAddr}
|
#{device.sendEnabled},
|
||||||
|
#{device.beidouStatus},
|
||||||
|
#{device.beidouChannelStatus},
|
||||||
|
#{device.beidouSignalStrength},
|
||||||
|
#{device.wirelessStatus},
|
||||||
|
#{device.telphoneStatus}
|
||||||
|
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"
|
||||||
parameterType="com.zjyr.beidouservice.pojo.entry.ControlDevice">
|
parameterType="com.zjyr.beidouservice.pojo.entry.ControlDevice">
|
||||||
INSERT IGNORE INTO control_device(deviceAddr, deviceType, beidouSignalStrength, wirelessStatus, telphoneStatus)
|
INSERT IGNORE INTO control_device(deviceAddr, deviceType, sendEnabled, beidouStatus, beidouChannelStatus,
|
||||||
SELECT #{device.deviceAddr}, #{device.deviceType}, #{device.beidouSignalStrength}, #{device.wirelessStatus},
|
beidouSignalStrength, wirelessStatus, telphoneStatus)
|
||||||
#{device.telphoneStatus} FROM DUAL WHERE NOT EXISTS (SELECT deviceAddr FROM control_device
|
SELECT #{device.deviceAddr},
|
||||||
WHERE deviceAddr = #{device.deviceAddr})
|
#{device.deviceType},
|
||||||
|
#{device.sendEnabled},
|
||||||
|
#{device.beidouStatus},
|
||||||
|
#{device.beidouChannelStatus},
|
||||||
|
#{device.beidouSignalStrength},
|
||||||
|
#{device.wirelessStatus},
|
||||||
|
#{device.telphoneStatus}
|
||||||
|
FROM DUAL
|
||||||
|
WHERE NOT EXISTS (SELECT deviceAddr
|
||||||
|
FROM control_device
|
||||||
|
WHERE deviceAddr = #{device.deviceAddr})
|
||||||
</insert>
|
</insert>
|
||||||
</mapper>
|
</mapper>
|
Loading…
Reference in New Issue