Commit 7c508a1f7e12e5c71ad8a88f275e6d88ef3775ea

Authored by guzijian
1 parent d266a714

feat: 解决部分协议冲突

Bsth-admin/src/main/java/com/ruoyi/common/cache/NowSchedulingCache.java
@@ -29,7 +29,7 @@ public class NowSchedulingCache { @@ -29,7 +29,7 @@ public class NowSchedulingCache {
29 this.schedulingMapper = driverSchedulingMapper; 29 this.schedulingMapper = driverSchedulingMapper;
30 this.errorJobcodeService = errorJobcodeService; 30 this.errorJobcodeService = errorJobcodeService;
31 log.info("项目启动加载中获取排班表并存入缓存-----"); 31 log.info("项目启动加载中获取排班表并存入缓存-----");
32 - cacheNowDaySchedulingInit(); 32 +// cacheNowDaySchedulingInit();
33 } 33 }
34 34
35 /** 35 /**
Bsth-admin/src/main/java/com/ruoyi/common/cache/SchedulingCache.java
@@ -36,7 +36,7 @@ public class SchedulingCache { @@ -36,7 +36,7 @@ public class SchedulingCache {
36 36
37 public SchedulingCache(SchedulerProperty property) { 37 public SchedulingCache(SchedulerProperty property) {
38 log.info("项目启动加载中获取实时班次并存入缓存-----"); 38 log.info("项目启动加载中获取实时班次并存入缓存-----");
39 - schedulingInit(property); 39 +// schedulingInit(property);
40 } 40 }
41 41
42 42
Bsth-admin/src/main/java/com/ruoyi/system/protocol/ThinkraceUtil.java
@@ -26,7 +26,7 @@ public class ThinkraceUtil { @@ -26,7 +26,7 @@ public class ThinkraceUtil {
26 private static final String COMMAND_SEND = "command:send:"; 26 private static final String COMMAND_SEND = "command:send:";
27 public static final Integer COMMAND_LABEL_SURE = 1; 27 public static final Integer COMMAND_LABEL_SURE = 1;
28 public static final Integer COMMAND_LABEL_INIT = 0; 28 public static final Integer COMMAND_LABEL_INIT = 0;
29 - private static final Long SN_LENGTH = 1000000L; 29 + public static final Long SN_LENGTH = 1000000L;
30 private static RedisCache REDIS_CACHE; 30 private static RedisCache REDIS_CACHE;
31 /** 31 /**
32 * 指令列表 32 * 指令列表
@@ -109,6 +109,7 @@ public class ThinkraceUtil { @@ -109,6 +109,7 @@ public class ThinkraceUtil {
109 public static final String ALARM_REQ = "IWAP10"; 109 public static final String ALARM_REQ = "IWAP10";
110 public static final String IMAGE_REQ = "IWAP42"; 110 public static final String IMAGE_REQ = "IWAP42";
111 public static final String HEART_REQ = "IWAP49"; 111 public static final String HEART_REQ = "IWAP49";
  112 + // 这两协议 在st2和智能手表标准协议中都有
112 public static final String TEMPERATURE_50_REQ = "IWAP50"; 113 public static final String TEMPERATURE_50_REQ = "IWAP50";
113 public static final String QUERY_BLUETOOTH_REQ = "IWAP51"; 114 public static final String QUERY_BLUETOOTH_REQ = "IWAP51";
114 public static final String CDMA_GPS_REQ = "IWAP91"; 115 public static final String CDMA_GPS_REQ = "IWAP91";
@@ -140,7 +141,7 @@ public class ThinkraceUtil { @@ -140,7 +141,7 @@ public class ThinkraceUtil {
140 public static final String SOS_REQ = "IWAP12"; 141 public static final String SOS_REQ = "IWAP12";
141 142
142 143
143 - public static final String UPLOAD_GPS_TIME_REQ = "IWAP15"; 144 + public static final String UPLOAD_GPS_TIME_REQ = "IWAP16";
144 145
145 public static final String RECOVERY_RESET_REQ = "IWAP17"; 146 public static final String RECOVERY_RESET_REQ = "IWAP17";
146 public static final String RESET_POWER_REQ = "IWAP18"; 147 public static final String RESET_POWER_REQ = "IWAP18";
Bsth-admin/src/main/java/com/ruoyi/system/protocol/adapter/callback/ICallbackHeartCheckPacketAdapter.java
1 package com.ruoyi.system.protocol.adapter.callback; 1 package com.ruoyi.system.protocol.adapter.callback;
2 2
  3 +import com.ruoyi.system.domain.command.HealthInfo;
3 import com.ruoyi.system.protocol.ThinkraceUtil; 4 import com.ruoyi.system.protocol.ThinkraceUtil;
4 import com.ruoyi.system.protocol.adapter.ICommandAdapter; 5 import com.ruoyi.system.protocol.adapter.ICommandAdapter;
  6 +import io.netty.buffer.Unpooled;
5 import io.netty.channel.ChannelHandlerContext; 7 import io.netty.channel.ChannelHandlerContext;
6 import io.netty.util.AttributeKey; 8 import io.netty.util.AttributeKey;
  9 +import io.netty.util.CharsetUtil;
7 import org.springframework.stereotype.Service; 10 import org.springframework.stereotype.Service;
8 11
9 @Service(ThinkraceUtil.REQ.HEART_CHECK_REQ) 12 @Service(ThinkraceUtil.REQ.HEART_CHECK_REQ)
10 public class ICallbackHeartCheckPacketAdapter extends ICommandAdapter { 13 public class ICallbackHeartCheckPacketAdapter extends ICommandAdapter {
11 @Override 14 @Override
12 public Object resolveCommand(String command, ChannelHandlerContext ctx) { 15 public Object resolveCommand(String command, ChannelHandlerContext ctx) {
13 - //终端响应格式:  
14 - //IWAP50,指令流水号,执行结果# 终端响应示例:  
15 - //IWAP50,080835,1#  
16 - //080835:指令流水号  
17 - //1:表示终端执行成功,0 表示终端执行失败  
18 - //心跳数据检测完成后,终端使用 AP49 上传心跳检测数据  
19 - String[] params = command.replace(ThinkraceUtil.END_SYMBOL, "").split(",");  
20 - String sn = params[1];  
21 - // TODO  
22 - String result = params[2];  
23 - String imei = ctx.channel().attr(AttributeKey.valueOf(ThinkraceUtil.IMEI)).toString();  
24 - return ThinkraceUtil.askCommand("下发心跳检测指令", imei, command, sn); 16 + // IWAP50,36.7,90#
  17 + String sub = command.substring(0, command.length() - 1);
  18 + String[] params = sub.split(",");
  19 + String param = params[1];
  20 + if (param.length() == ThinkraceUtil.SN_LENGTH.toString().length() - 1) {
  21 + //终端响应格式:
  22 + //IWAP50,指令流水号,执行结果# 终端响应示例:
  23 + //IWAP50,080835,1#
  24 + //080835:指令流水号
  25 + //1:表示终端执行成功,0 表示终端执行失败
  26 + //心跳数据检测完成后,终端使用 AP49 上传心跳检测数据
  27 + String sn = params[1];
  28 + // TODO
  29 + String result = params[2];
  30 + String imei = ctx.channel().attr(AttributeKey.valueOf(ThinkraceUtil.IMEI)).toString();
  31 + return ThinkraceUtil.askCommand("下发心跳检测指令", imei, command, sn);
  32 + }
  33 + HealthInfo hi = new HealthInfo();
  34 + hi.setImei(ctx.channel().attr(AttributeKey.valueOf(ThinkraceUtil.IMEI)).toString());
  35 + log.info("设备:{},温度数据上传命令:{}", hi.getImei(), command);
  36 + hi.setTemperature(Float.parseFloat(params[1]));
  37 + hi.setPower(params[2]);
  38 + // IWBP50#
  39 + String response = ThinkraceUtil.RES.TEMPERATURE_50_RES + ThinkraceUtil.END_SYMBOL;
  40 + ctx.channel().writeAndFlush(Unpooled.copiedBuffer(response, CharsetUtil.UTF_8));
  41 + responseLog(hi.getImei(), response);
  42 + return hi;
  43 +
  44 +
25 } 45 }
26 46
27 @Override 47 @Override
Bsth-admin/src/main/java/com/ruoyi/system/protocol/adapter/device/IQueryBluetoothPacketAdapter.java
1 -package com.ruoyi.system.protocol.adapter.device;  
2 -  
3 -import com.ruoyi.system.protocol.ThinkraceUtil;  
4 -import com.ruoyi.system.protocol.adapter.ICommandAdapter;  
5 -import io.netty.buffer.Unpooled;  
6 -import io.netty.channel.ChannelHandlerContext;  
7 -import io.netty.util.AttributeKey;  
8 -import io.netty.util.CharsetUtil;  
9 -import org.springframework.stereotype.Service;  
10 -  
11 -/**  
12 - * 10 查询手表对应的蓝牙温度计SN  
13 - *  
14 - * @author 20412  
15 - */  
16 -@Service(ThinkraceUtil.REQ.QUERY_BLUETOOTH_REQ)  
17 -public class IQueryBluetoothPacketAdapter extends ICommandAdapter {  
18 -  
19 - @Override  
20 - public Object resolveCommand(String command, ChannelHandlerContext ctx) {  
21 - String imei = ctx.channel().attr(AttributeKey.valueOf(ThinkraceUtil.IMEI)).toString();  
22 - log.info("设备:{},查询手表对应的蓝牙温度计SN命令:{}", imei, command);  
23 - // IWBP51,123456#  
24 - String response = ThinkraceUtil.RES.QUERY_BLUETOOTH_RES + "," + 123456 + ThinkraceUtil.END_SYMBOL;  
25 - ctx.channel().writeAndFlush(Unpooled.copiedBuffer(response, CharsetUtil.UTF_8));  
26 - responseLog(imei, response);  
27 - return null;  
28 - }  
29 -  
30 - @Override  
31 - public CommandListen sendCommand(Object params) {  
32 - return null;  
33 - }  
34 -} 1 +//package com.ruoyi.system.protocol.adapter.device;
  2 +//
  3 +//import com.ruoyi.system.protocol.ThinkraceUtil;
  4 +//import com.ruoyi.system.protocol.adapter.ICommandAdapter;
  5 +//import io.netty.buffer.Unpooled;
  6 +//import io.netty.channel.ChannelHandlerContext;
  7 +//import io.netty.util.AttributeKey;
  8 +//import io.netty.util.CharsetUtil;
  9 +//import org.springframework.stereotype.Service;
  10 +//
  11 +///**
  12 +// * 10 查询手表对应的蓝牙温度计SN
  13 +// *
  14 +// * @author 20412
  15 +// */
  16 +//@Service(ThinkraceUtil.REQ.QUERY_BLUETOOTH_REQ)
  17 +//public class IQueryBluetoothPacketAdapter extends ICommandAdapter {
  18 +//
  19 +// @Override
  20 +// public Object resolveCommand(String command, ChannelHandlerContext ctx) {
  21 +// String imei = ctx.channel().attr(AttributeKey.valueOf(ThinkraceUtil.IMEI)).toString();
  22 +// log.info("设备:{},查询手表对应的蓝牙温度计SN命令:{}", imei, command);
  23 +// // IWBP51,123456#
  24 +// String response = ThinkraceUtil.RES.QUERY_BLUETOOTH_RES + "," + 123456 + ThinkraceUtil.END_SYMBOL;
  25 +// ctx.channel().writeAndFlush(Unpooled.copiedBuffer(response, CharsetUtil.UTF_8));
  26 +// responseLog(imei, response);
  27 +// return null;
  28 +// }
  29 +//
  30 +// @Override
  31 +// public CommandListen sendCommand(Object params) {
  32 +// return null;
  33 +// }
  34 +//}
Bsth-admin/src/main/java/com/ruoyi/system/protocol/adapter/device/ITemperature50PacketAdapter.java
1 -package com.ruoyi.system.protocol.adapter.device;  
2 -  
3 -import com.ruoyi.system.domain.command.HealthInfo;  
4 -import com.ruoyi.system.protocol.ThinkraceUtil;  
5 -import com.ruoyi.system.protocol.adapter.ICommandAdapter;  
6 -import io.netty.buffer.Unpooled;  
7 -import io.netty.channel.ChannelHandlerContext;  
8 -import io.netty.util.AttributeKey;  
9 -import io.netty.util.CharsetUtil;  
10 -import org.springframework.stereotype.Service;  
11 -  
12 -/**  
13 - * 9 温度数据上传  
14 - *  
15 - * @author 20412  
16 - */  
17 -@Service(ThinkraceUtil.REQ.TEMPERATURE_50_REQ)  
18 -public class ITemperature50PacketAdapter extends ICommandAdapter {  
19 -  
20 - @Override  
21 - public Object resolveCommand(String command, ChannelHandlerContext ctx) {  
22 - // IWAP50,36.7,90#  
23 - String sub = command.substring(0, command.length() - 1);  
24 - String[] params = sub.split(",");  
25 - HealthInfo hi = new HealthInfo();  
26 - hi.setImei(ctx.channel().attr(AttributeKey.valueOf(ThinkraceUtil.IMEI)).toString());  
27 - log.info("设备:{},温度数据上传命令:{}", hi.getImei(), command);  
28 - hi.setTemperature(Float.parseFloat(params[1]));  
29 - hi.setPower(params[2]);  
30 - // IWBP50#  
31 - String response = ThinkraceUtil.RES.TEMPERATURE_50_RES + ThinkraceUtil.END_SYMBOL;  
32 - ctx.channel().writeAndFlush(Unpooled.copiedBuffer(response, CharsetUtil.UTF_8));  
33 - responseLog(hi.getImei(), response);  
34 - return hi;  
35 - }  
36 -  
37 - @Override  
38 - public CommandListen sendCommand(Object params) {  
39 - return null;  
40 - }  
41 -} 1 +//package com.ruoyi.system.protocol.adapter.device;
  2 +//
  3 +//import com.ruoyi.system.domain.command.HealthInfo;
  4 +//import com.ruoyi.system.protocol.ThinkraceUtil;
  5 +//import com.ruoyi.system.protocol.adapter.ICommandAdapter;
  6 +//import io.netty.buffer.Unpooled;
  7 +//import io.netty.channel.ChannelHandlerContext;
  8 +//import io.netty.util.AttributeKey;
  9 +//import io.netty.util.CharsetUtil;
  10 +//import org.springframework.stereotype.Service;
  11 +//
  12 +///**
  13 +// * 9 温度数据上传
  14 +// *
  15 +// * @author 20412
  16 +// */
  17 +//@Service(ThinkraceUtil.REQ.TEMPERATURE_50_REQ)
  18 +//public class ITemperature50PacketAdapter extends ICommandAdapter {
  19 +//
  20 +// @Override
  21 +// public Object resolveCommand(String command, ChannelHandlerContext ctx) {
  22 +// // IWAP50,36.7,90#
  23 +// String sub = command.substring(0, command.length() - 1);
  24 +// String[] params = sub.split(",");
  25 +// HealthInfo hi = new HealthInfo();
  26 +// hi.setImei(ctx.channel().attr(AttributeKey.valueOf(ThinkraceUtil.IMEI)).toString());
  27 +// log.info("设备:{},温度数据上传命令:{}", hi.getImei(), command);
  28 +// hi.setTemperature(Float.parseFloat(params[1]));
  29 +// hi.setPower(params[2]);
  30 +// // IWBP50#
  31 +// String response = ThinkraceUtil.RES.TEMPERATURE_50_RES + ThinkraceUtil.END_SYMBOL;
  32 +// ctx.channel().writeAndFlush(Unpooled.copiedBuffer(response, CharsetUtil.UTF_8));
  33 +// responseLog(hi.getImei(), response);
  34 +// return hi;
  35 +// }
  36 +//
  37 +// @Override
  38 +// public CommandListen sendCommand(Object params) {
  39 +// return null;
  40 +// }
  41 +//}
Bsth-admin/src/main/resources/application-druid-dev.yml
@@ -184,7 +184,7 @@ server: @@ -184,7 +184,7 @@ server:
184 port: 8100 184 port: 8100
185 netty: 185 netty:
186 # 是否开启netty服务 186 # 是否开启netty服务
187 - enabled: false 187 + enabled: true
188 socket: 188 socket:
189 # 相对路径 classpath 189 # 相对路径 classpath
190 catalogue: 190 catalogue:
Bsth-admin/src/main/resources/application-druid-uat.yml
@@ -133,7 +133,7 @@ ruoyi: @@ -133,7 +133,7 @@ ruoyi:
133 # 实例演示开关 133 # 实例演示开关
134 demoEnabled: true 134 demoEnabled: true
135 # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) 135 # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
136 - profile: /home/sign/uploadPath 136 + profile: /home/health/uploadPath
137 # 获取ip地址开关 137 # 获取ip地址开关
138 addressEnabled: false 138 addressEnabled: false
139 # 验证码类型 math 数字计算 char 字符验证 139 # 验证码类型 math 数字计算 char 字符验证
@@ -198,10 +198,10 @@ api: @@ -198,10 +198,10 @@ api:
198 people: 198 people:
199 url: https://api.dingtalk.com/v1.0/yida/forms/instances/search 199 url: https://api.dingtalk.com/v1.0/yida/forms/instances/search
200 log: 200 log:
201 - path: /home/sign/logs 201 + path: /home/health/logs
202 netty: 202 netty:
203 # 是否开启netty服务 203 # 是否开启netty服务
204 - enabled: false 204 + enabled: true
205 socket: 205 socket:
206 # 相对路径 classpath 206 # 相对路径 classpath
207 catalogue: 207 catalogue: