1. 心跳协议响应获取设备信息入库

2. 创建警报任务协议
3. 格式化代码
This commit is contained in:
HuangXin 2023-08-21 20:58:34 +08:00
parent 5503523a0c
commit d97abd5e16
40 changed files with 281 additions and 320 deletions

View File

@ -1,4 +1,4 @@
socket.server-host=localhost
socket.server-port=10000
socket.server-port=10001
socket.server-mode=tcp
socket.heart-timeout=60

View File

@ -30,10 +30,7 @@ public class MessageHandler<T> extends SimpleChannelInboundHandler<BaseBinaryPro
if (evt instanceof IdleStateEvent idleStateEvent) {
if (idleStateEvent.state() == IdleState.ALL_IDLE) {
log.info("{}:: Trigger Heart Signe", ctx.channel().id());
SocketNotifyEvent notify = new SocketNotifyEvent(this,
ctx.channel(),
SocketEventName.SOCKET_EVT_IDLE_TIMEOUT,
null);
SocketNotifyEvent notify = new SocketNotifyEvent(this, ctx.channel(), SocketEventName.SOCKET_EVT_IDLE_TIMEOUT, null);
applicationEventPublisher.publishEvent(notify);
}
} else {
@ -42,7 +39,7 @@ public class MessageHandler<T> extends SimpleChannelInboundHandler<BaseBinaryPro
}
@Override
public void channelRead0(ChannelHandlerContext ctx, BaseBinaryProtocol<T> message) throws Exception {
public void channelRead0(ChannelHandlerContext ctx, BaseBinaryProtocol<T> message) {
SocketNotifyEvent notify = new SocketNotifyEvent(this,
ctx.channel(),
message.getTimeStamp(),
@ -68,10 +65,7 @@ public class MessageHandler<T> extends SimpleChannelInboundHandler<BaseBinaryPro
super.channelInactive(ctx);
ctx.close();
SocketNotifyEvent notify = new SocketNotifyEvent(this,
ctx.channel(),
SocketEventName.SOCKET_EVT_DISCONNECT,
null);
SocketNotifyEvent notify = new SocketNotifyEvent(this, ctx.channel(), SocketEventName.SOCKET_EVT_DISCONNECT, null);
applicationEventPublisher.publishEvent(notify);
}

View File

@ -45,19 +45,18 @@ public class YuanRongProtocolDecode extends ByteToMessageDecoder {
if (cmd != null) {
switch (cmd) {
case COMMAND_REPORT_HEART -> {
int heartSeq = buf.readInt();
SendStatusName sendStatus = CommonEnumHandler.codeOf(SendStatusName.class, buf.readByte());
ControlChannelStatus beidouStatus = CommonEnumHandler.codeOf(ControlChannelStatus.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];
buf.readBytes(beidouSignal, 0, 10);
ControlChannelStatus wireStatus = CommonEnumHandler.codeOf(ControlChannelStatus.class,
buf.readByte());
ControlChannelStatus phoneStatus = CommonEnumHandler.codeOf(ControlChannelStatus.class,
buf.readByte());
ControlChannelStatus wireStatus = CommonEnumHandler.codeOf(ControlChannelStatus.class, buf.readByte());
ControlChannelStatus phoneStatus = CommonEnumHandler.codeOf(ControlChannelStatus.class, buf.readByte());
ControllerStatus status = ControllerStatus.builder()
.heartSeq(heartSeq)
.sendStatus(sendStatus)
.beidouStatus(beidouStatus)
.beidouFreq(beidouCommFreq)
@ -66,8 +65,8 @@ public class YuanRongProtocolDecode extends ByteToMessageDecoder {
.telphoneStatus(phoneStatus)
.build();
MessageContent<ControllerStatus> msgCtx = MessageContent.<ControllerStatus>builder().msgType(
msgType).msgSize(msgSize).msgBody(status).build();
MessageContent<ControllerStatus> msgCtx = MessageContent.<ControllerStatus>builder().msgType(msgType).msgSize(
msgSize).msgBody(status).build();
list.add(BaseBinaryProtocol.<ControllerStatus>builder()
.msgLength(msgLength)
@ -82,16 +81,15 @@ public class YuanRongProtocolDecode extends ByteToMessageDecoder {
int taskId = buf.readInt();
byte nItem = buf.readByte();
SensorTaskAck taskAck = SensorTaskAck.builder()
.taskId(taskId)
.ackTimestamp(timeStamp)
.sensorStatus(new ArrayList<>(nItem))
.build();
SensorTaskAck taskAck = SensorTaskAck.builder().taskId(taskId).ackTimestamp(timeStamp).sensorStatus(new ArrayList<>(
nItem)).build();
for (int i = 0; i < nItem; i++) {
SensorTaskStatus taskStatus = SensorTaskStatus.builder()
.sensorId(buf.readInt())
.taskResult(CommonEnumHandler.codeOf(TaskResultName.class, buf.readByte()))
.tunnelName(CommonEnumHandler.codeOf(SensorControlTunnelName.class, buf.readByte()))
.taskResult(CommonEnumHandler.codeOf(TaskResultName.class,
buf.readByte()))
.tunnelName(CommonEnumHandler.codeOf(SensorControlTunnelName.class,
buf.readByte()))
.build();
taskAck.getSensorStatus().add(taskStatus);
@ -116,13 +114,15 @@ public class YuanRongProtocolDecode extends ByteToMessageDecoder {
int nItems = buf.readByte();
SensorStatusAck sensorAck = SensorStatusAck.builder().sensorStatus(new ArrayList<>()).build();
MessageContent<SensorStatusAck> msgCtx = MessageContent.<SensorStatusAck>builder().msgType(
msgType).msgSize(msgSize).msgBody(sensorAck).build();
MessageContent<SensorStatusAck> msgCtx = MessageContent.<SensorStatusAck>builder()
.msgType(msgType)
.msgSize(msgSize)
.msgBody(sensorAck)
.build();
for (int i = 0; i < nItems; i++) {
short tmInfo = buf.readShort();
SensorControlTunnelName tn = CommonEnumHandler.codeOf(SensorControlTunnelName.class,
buf.readByte());
SensorControlTunnelName tn = CommonEnumHandler.codeOf(SensorControlTunnelName.class, buf.readByte());
int cmdType = buf.readByte();
short sa = buf.readShort();
short sid = buf.readShort();

View File

@ -2,7 +2,6 @@ package com.zjyr.beidouservice.adapter.impl.netty.encode;
import com.zjyr.beidouservice.pojo.vo.binary.BaseBinaryProtocol;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.LengthFieldPrepender;
import lombok.extern.slf4j.Slf4j;

View File

@ -1,6 +1,5 @@
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.pojo.vo.binary.BaseBinaryProtocol;
import com.zjyr.beidouservice.pojo.vo.binary.HeartProtocol;
@ -19,9 +18,7 @@ import org.springframework.stereotype.Component;
@Slf4j
public class YuanRongProtocolEncode<T> extends MessageToByteEncoder<BaseBinaryProtocol<T>> {
@Override
protected void encode(ChannelHandlerContext channelHandlerContext,
BaseBinaryProtocol<T> baseBinaryProtocol,
ByteBuf byteBuf) {
protected void encode(ChannelHandlerContext channelHandlerContext, BaseBinaryProtocol<T> baseBinaryProtocol, ByteBuf byteBuf) {
if (baseBinaryProtocol == null || baseBinaryProtocol.getMsgContent() == null ||
baseBinaryProtocol.getMsgContent().getMsgBody() == null) {
@ -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.getAlarmType().getValue().byteValue());
byteBuf.writeByte(msg.getControlTunnel().getValue().byteValue());
byteBuf.writeByte(msg.getControlTunnel().byteValue());
byteBuf.writeInt(msg.getTimeStamp());
if (msg.getCityCode().isEmpty()) {
@ -71,7 +68,7 @@ public class YuanRongProtocolEncode<T> extends MessageToByteEncoder<BaseBinaryPr
if (msg.getSensorId().isEmpty()) {
byteBuf.writeByte(0);
} else {
byteBuf.writeByte(msg.getSensorId().size() * 4);
byteBuf.writeByte(msg.getSensorId().size());
for (var c : msg.getSensorId()) {
byteBuf.writeInt(c);
}

View File

@ -36,10 +36,7 @@ public final class CommonEnumHandler<E extends EnumerationBase> extends BaseType
}
@Override
public void setNonNullParameter(PreparedStatement preparedStatement,
int i,
E e,
JdbcType jdbcType) throws SQLException {
public void setNonNullParameter(PreparedStatement preparedStatement, int i, E e, JdbcType jdbcType) throws SQLException {
preparedStatement.setInt(i, e.getValue());
}

View File

@ -1,7 +1,12 @@
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.GetUserConfig;
import com.zjyr.beidouservice.pojo.vo.binary.SensorControlProtocol;
import com.zjyr.beidouservice.service.AdapterProtocolService;
import com.zjyr.beidouservice.service.BaidouAdapterService;
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.ResponseBody;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Arrays;
import java.util.Date;
@Controller
//@RequestMapping(value = "/auth")
@ -37,33 +45,22 @@ public class AuthUser {
@PostMapping("/sensor/control")
@ResponseBody
public String getUserConfig(@RequestBody BaseProtocolDTO<GetUserConfig> mr, @RequestHeader HttpHeaders headers) {
// List<BeidouAdapterControlContent> adapterInfo = new ArrayList<>();
//
// for (int i = 0; i < 2; i++) {
//// adapterInfo.add(BeidouAdapterControlContent.builder()
//// .districtsCode(0x10 + i)
//// .sensorId(0x3f00 + i)
//// .controlAction(SensorControlActionName.ACTION_DISTRICTS_BASED)
//// .build());
// }
//
// SensorControlProtocol sp =
// adapterProtocolService.createSensorControlProtocol(SensorControlTunnelName.TUNNEL_BEIDOU,
// new byte[]{0x01, 0x02, 0x03},
// 8,
// 14,
// 20,
// 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);
// }
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
ParsePosition pos = new ParsePosition(0);
Date strtodate = formatter.parse("2023-08-30 18:24:30", pos);
SensorControlProtocol sensorPro = adapterProtocolService.createSensorControlProtocol(1024,
AlarmModeName.ALARM_MODE_MANUALLY,
AlarmControlTypeName.ALARM_CONTROL_TYPE_TEST_QUITE,
AlarmTypeName.ALARM_TYPE_AIRATTACK,
SensorControlTunnelName.TUNNEL_BEIDOU.getValue() |
SensorControlTunnelName.TUNNEL_WIRELESS.getValue(),
strtodate,
new ArrayList<>(),
new ArrayList<>(),
new ArrayList<>(Arrays.asList(0, 1, 2, 3)));
Long id = baidouAdapterService.getAllAdapter().get(0).getId();
baidouAdapterService.sendCommond(id, sensorPro);
return "{\"result\": 0}";
}

View File

@ -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.CitySearchDTO;
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.ProvinceSearchDTO;
import com.zjyr.beidouservice.service.LocationService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
@ -30,6 +30,7 @@ public class LocationController {
OnlyProvinceResp onlyProvinceResp = locationService.getOnlyProvinces();
return MyResp.success(onlyProvinceResp);
}
@PostMapping("provinces")
public MyResp<ProvinceRespDTO> getProvinces(@RequestBody ProvinceSearchDTO provinceSearchDTO) {
ProvinceRespDTO provinceResp = locationService.getProvinces(provinceSearchDTO);

View File

@ -10,8 +10,7 @@ import java.util.List;
@Mapper
public interface DevAttributesMapper {
List<DevMaunDTO> selectManuByManufacturer(@Param("deviceId") Long deviceId,
@Param("manufacturer") String manufacturer);
List<DevMaunDTO> selectManuByManufacturer(@Param("deviceId") Long deviceId, @Param("manufacturer") String manufacturer);
List<DevAttributesDO> selectManuAll();

View File

@ -9,6 +9,5 @@ import java.util.List;
@Mapper
public interface LocCountyMapper {
List<LocCountyDO> selectCountyByCity(@Param("provinceCode") String provinceCode,
@Param("cityCode") String cityCode);
List<LocCountyDO> selectCountyByCity(@Param("provinceCode") String provinceCode, @Param("cityCode") String cityCode);
}

View File

@ -10,5 +10,6 @@ import java.util.List;
public interface LocProvinceMapper {
List<LocProvinceDO> selectAllProvince();
List<LocProvinceDO> selectProvince(@Param("provinceCode") String provinceCode);
}

View File

@ -20,24 +20,14 @@ public class MyResp<T> {
}
public static MyResp result(Resp resp) {
return MyResp.builder()
.code(resp.getCede())
.msg(resp.getMsg())
.build();
return MyResp.builder().code(resp.getCede()).msg(resp.getMsg()).build();
}
public static <T> MyResp success(T data) {
return MyResp.builder()
.code(Resp.SUCCESS.getCede())
.msg(Resp.SUCCESS.getMsg())
.data(data)
.build();
return MyResp.builder().code(Resp.SUCCESS.getCede()).msg(Resp.SUCCESS.getMsg()).data(data).build();
}
public static MyResp error(Resp respEnum) {
return MyResp.builder()
.code(respEnum.getCede())
.msg(respEnum.getMsg())
.build();
return MyResp.builder().code(respEnum.getCede()).msg(respEnum.getMsg()).build();
}
}

View File

@ -1,15 +1,17 @@
package com.zjyr.beidouservice.pojo;
import com.alibaba.fastjson.JSONObject;
import lombok.Getter;
public enum Resp {
//成功返回码
SUCCESS(200, "SUCCESS");
private int code;
private final int code;
private String msg;
@Getter
private final String msg;
Resp(int code, String msg) {
this.code = code;
@ -20,10 +22,6 @@ public enum Resp {
return code;
}
public String getMsg() {
return msg;
}
@Override
public String toString() {
JSONObject json = new JSONObject();

View File

@ -1,6 +1,7 @@
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.Data;
@ -9,6 +10,7 @@ import lombok.Data;
public class ControllerStatus {
private byte[] beidouFreq;
private byte[] beidouSignalStrength;
private int heartSeq;
private SendStatusName sendStatus;
private ControlChannelStatus beidouStatus;
private ControlChannelStatus wirelessStatus;

View File

@ -3,8 +3,6 @@ package com.zjyr.beidouservice.pojo.vo.binary;
import lombok.Builder;
import lombok.Data;
import java.util.List;
@Data
@Builder
public class QuerySensorProtocol {

View File

@ -3,7 +3,6 @@ package com.zjyr.beidouservice.pojo.vo.binary;
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 lombok.Builder;
import lombok.Data;
@ -16,8 +15,8 @@ public class SensorControlProtocol {
private AlarmModeName alarmMode;
private AlarmControlTypeName alarmControlType;
private AlarmTypeName alarmType;
private SensorControlTunnelName controlTunnel;
private int timeStamp;
private Integer controlTunnel;
private Integer timeStamp;
private List<Integer> cityCode;
private List<Integer> districtsCode;
private List<Integer> sensorId;

View File

@ -3,7 +3,6 @@ package com.zjyr.beidouservice.service;
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.vo.binary.HeartProtocol;
import com.zjyr.beidouservice.pojo.vo.binary.SensorControlProtocol;
@ -13,11 +12,15 @@ import java.util.List;
public interface AdapterProtocolService {
HeartProtocol createHeartProtocol();
SensorControlProtocol createSensorControlProtocol(AlarmModeName alarmMode, AlarmControlTypeName controlType,
AlarmTypeName alarmType, SensorControlTunnelName tunnelName,
SensorControlProtocol createSensorControlProtocol(int taskId,
AlarmModeName alarmMode,
AlarmControlTypeName controlType,
AlarmTypeName alarmType,
int tunnelName,
Date alarmDt,
List<Integer> citys,
List<Integer> areas,
List<Integer> sensors);
<T> Object createTransmissionProtocol(T proContent);
}

View File

@ -1,4 +1,5 @@
package com.zjyr.beidouservice.service;
import com.zjyr.beidouservice.pojo.dto.AlarmDevRespDTO;
import com.zjyr.beidouservice.pojo.dto.DeviceReqDTO;
import com.zjyr.beidouservice.pojo.dto.DeviceRespDTO;

View File

@ -4,13 +4,11 @@ import com.zjyr.beidouservice.pojo.dto.DevTaskExecRespDTO;
import com.zjyr.beidouservice.pojo.dto.DeviceTaskExecReqDTO;
import com.zjyr.beidouservice.pojo.dto.DeviceTaskRespDTO;
import java.util.List;
public interface DeviceTaskService {
List<DeviceTaskRespDTO> getDeviceTaskInfo();
DevTaskExecRespDTO deviceTaskExec(DeviceTaskExecReqDTO deviceTaskExecReqDTO);
}

View File

@ -3,11 +3,8 @@ package com.zjyr.beidouservice.service;
import com.zjyr.beidouservice.pojo.dto.city.CityRespDTO;
import com.zjyr.beidouservice.pojo.dto.city.CitySearchDTO;
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 java.util.List;
import com.zjyr.beidouservice.pojo.dto.province.ProvinceSearchDTO;
public interface LocationService {
OnlyProvinceResp getOnlyProvinces();

View File

@ -32,8 +32,7 @@ import static com.zjyr.beidouservice.common.impl.SocketEventName.SOCKET_EVT_CONN
@Service
@Slf4j
public class BaidouSocketAdapterServiceImpl<T extends ApplicationEvent> implements BaidouAdapterService,
ApplicationListener<T> {
public class BaidouSocketAdapterServiceImpl<T extends ApplicationEvent> implements BaidouAdapterService, ApplicationListener<T> {
private final ConcurrentHashMap<Long, ControlAdapterSocketCtx> ctxMap = new ConcurrentHashMap<>();
@Resource
@ -74,7 +73,7 @@ public class BaidouSocketAdapterServiceImpl<T extends ApplicationEvent> implemen
if (evtContent instanceof SocketNotifyEvent event) {
InetSocketAddress sa = (InetSocketAddress) event.getCtxChannel().remoteAddress();
switch (event.getSocketEvent()) {
case SOCKET_EVT_CONNECT -> {
case SOCKET_EVT_CONNECT, SOCKET_EVT_IDLE_TIMEOUT -> {
sendCommond(event.getCtxChannel(), adapterProtocolService.createHeartProtocol());
if (event.getSocketEvent() == SOCKET_EVT_CONNECT) {
@ -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 -> {
for (ConcurrentHashMap.Entry<Long, ControlAdapterSocketCtx> entry : ctxMap.entrySet()) {
if (entry.getValue().getChannel().id() == event.getCtxChannel().id()) {
@ -178,6 +173,7 @@ public class BaidouSocketAdapterServiceImpl<T extends ApplicationEvent> implemen
if (dev == null) {
controlDeviceMapper.addControlDevice(device);
} else {
device.setId(dev.getId());
adapter.setId(dev.getId());
controlDeviceMapper.upgradeControlDevice(device);
}

View File

@ -3,7 +3,6 @@ package com.zjyr.beidouservice.service.impl;
import com.zjyr.beidouservice.common.impl.AlarmControlTypeName;
import com.zjyr.beidouservice.common.impl.AlarmModeName;
import com.zjyr.beidouservice.common.impl.AlarmTypeName;
import com.zjyr.beidouservice.common.impl.SensorControlTunnelName;
import com.zjyr.beidouservice.pojo.vo.binary.BaseBinaryProtocol;
import com.zjyr.beidouservice.pojo.vo.binary.HeartProtocol;
import com.zjyr.beidouservice.pojo.vo.binary.MessageContent;
@ -27,14 +26,18 @@ public class BeidouSocketProtocolServiceImpl implements AdapterProtocolService {
}
@Override
public SensorControlProtocol createSensorControlProtocol(AlarmModeName alarmMode,
public SensorControlProtocol createSensorControlProtocol(int taskId,
AlarmModeName alarmMode,
AlarmControlTypeName controlType,
AlarmTypeName alarmType,
SensorControlTunnelName tunnelName, Date alarmDt,
List<Integer> citys, List<Integer> areas,
int tunnelName,
Date alarmDt,
List<Integer> citys,
List<Integer> areas,
List<Integer> sensors) {
long timestamp = new Timestamp(alarmDt.getTime()).getTime();
long timestamp = new Timestamp(alarmDt.getTime()).getTime() / 1000;
return SensorControlProtocol.builder()
.taskId(taskId)
.alarmMode(alarmMode)
.alarmControlType(controlType)
.alarmType(alarmType)

View File

@ -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.OnlyProvinceResp;
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.ProvinceSearchDTO;
import com.zjyr.beidouservice.service.LocationService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;

View File

@ -74,12 +74,8 @@ public class SensorDataServiceImpl implements SensorDataService {
.startAddr(v.getStartAddr().intValue())
.dtInfo(v.getDtInfo().intValue())
.warrningStatus(v.getWarrningStatus())
.emergStatus(createStatusMapValue(v.getEmergenStatus0(),
v.getEmergenStatus1(),
v.getEmergenStatus2()))
.spearkStatus(createStatusMapValue(v.getSpeakerStatus0(),
v.getSpeakerStatus1(),
v.getSpeakerStatus2()))
.emergStatus(createStatusMapValue(v.getEmergenStatus0(), v.getEmergenStatus1(), v.getEmergenStatus2()))
.spearkStatus(createStatusMapValue(v.getSpeakerStatus0(), v.getSpeakerStatus1(), v.getSpeakerStatus2()))
.runStatus(v.getRunStatus())
.signalStrength(v.getSignalStrength())
.beidouId(v.getBeidouId())

View File

@ -27,20 +27,16 @@
</select>
<update id="upgradeControlDevice" parameterType="com.zjyr.beidouservice.pojo.entry.ControlDevice">
INSERT IGNORE INTO control_device(deviceAddr, deviceType, sendEnabled, beidouStatus, beidouChannelStatus,
beidouSignalStrength, wirelessStatus, telphoneStatus)
SELECT #{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})
UPDATE control_device
SET deviceAddr = #{device.deviceAddr},
deviceType = #{device.deviceType},
sendEnabled = #{device.sendEnabled},
beidouStatus = #{device.beidouStatus},
beidouChannelStatus = #{device.beidouChannelStatus},
beidouSignalStrength = #{device.beidouSignalStrength},
wirelessStatus = #{device.wirelessStatus},
telphoneStatus = #{device.telphoneStatus}
WHERE deviceAddr = #{device.deviceAddr}
</update>
<insert id="addControlDevice" useGeneratedKeys="true" keyProperty="id"