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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,19 +45,18 @@ public class YuanRongProtocolDecode extends ByteToMessageDecoder {
|
||||||
if (cmd != null) {
|
if (cmd != null) {
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case COMMAND_REPORT_HEART -> {
|
case COMMAND_REPORT_HEART -> {
|
||||||
|
int heartSeq = buf.readInt();
|
||||||
SendStatusName sendStatus = CommonEnumHandler.codeOf(SendStatusName.class, buf.readByte());
|
SendStatusName sendStatus = CommonEnumHandler.codeOf(SendStatusName.class, buf.readByte());
|
||||||
ControlChannelStatus beidouStatus = CommonEnumHandler.codeOf(ControlChannelStatus.class,
|
ControlChannelStatus beidouStatus = CommonEnumHandler.codeOf(ControlChannelStatus.class, buf.readByte());
|
||||||
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()
|
||||||
|
.heartSeq(heartSeq)
|
||||||
.sendStatus(sendStatus)
|
.sendStatus(sendStatus)
|
||||||
.beidouStatus(beidouStatus)
|
.beidouStatus(beidouStatus)
|
||||||
.beidouFreq(beidouCommFreq)
|
.beidouFreq(beidouCommFreq)
|
||||||
|
@ -66,8 +65,8 @@ public class YuanRongProtocolDecode extends ByteToMessageDecoder {
|
||||||
.telphoneStatus(phoneStatus)
|
.telphoneStatus(phoneStatus)
|
||||||
.build();
|
.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)
|
||||||
|
@ -82,16 +81,15 @@ public class YuanRongProtocolDecode extends ByteToMessageDecoder {
|
||||||
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()))
|
||||||
|
.tunnelName(CommonEnumHandler.codeOf(SensorControlTunnelName.class,
|
||||||
|
buf.readByte()))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
taskAck.getSensorStatus().add(taskStatus);
|
taskAck.getSensorStatus().add(taskStatus);
|
||||||
|
@ -116,13 +114,15 @@ public class YuanRongProtocolDecode extends ByteToMessageDecoder {
|
||||||
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();
|
||||||
|
|
|
@ -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,9 +18,7 @@ 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) {
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,24 +20,14 @@ public class MyResp<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
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,15 +1,17 @@
|
||||||
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;
|
||||||
|
@ -20,10 +22,6 @@ public enum Resp {
|
||||||
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();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
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;
|
||||||
|
|
||||||
|
@ -9,6 +10,7 @@ import lombok.Data;
|
||||||
public class ControllerStatus {
|
public class ControllerStatus {
|
||||||
private byte[] beidouFreq;
|
private byte[] beidouFreq;
|
||||||
private byte[] beidouSignalStrength;
|
private byte[] beidouSignalStrength;
|
||||||
|
private int heartSeq;
|
||||||
private SendStatusName sendStatus;
|
private SendStatusName sendStatus;
|
||||||
private ControlChannelStatus beidouStatus;
|
private ControlChannelStatus beidouStatus;
|
||||||
private ControlChannelStatus wirelessStatus;
|
private ControlChannelStatus wirelessStatus;
|
||||||
|
|
|
@ -3,8 +3,6 @@ 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 {
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
@ -16,8 +15,8 @@ public class SensorControlProtocol {
|
||||||
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;
|
||||||
|
|
|
@ -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,7 +73,7 @@ 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) {
|
||||||
|
@ -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()) {
|
||||||
|
@ -178,6 +173,7 @@ public class BaidouSocketAdapterServiceImpl<T extends ApplicationEvent> implemen
|
||||||
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,14 +26,18 @@ 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()
|
||||||
|
.taskId(taskId)
|
||||||
.alarmMode(alarmMode)
|
.alarmMode(alarmMode)
|
||||||
.alarmControlType(controlType)
|
.alarmControlType(controlType)
|
||||||
.alarmType(alarmType)
|
.alarmType(alarmType)
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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