Commit 7c508a1f7e12e5c71ad8a88f275e6d88ef3775ea
1 parent
d266a714
feat: 解决部分协议冲突
Showing
8 changed files
with
116 additions
and
95 deletions
Bsth-admin/src/main/java/com/ruoyi/common/cache/NowSchedulingCache.java
| ... | ... | @@ -29,7 +29,7 @@ public class NowSchedulingCache { |
| 29 | 29 | this.schedulingMapper = driverSchedulingMapper; |
| 30 | 30 | this.errorJobcodeService = errorJobcodeService; |
| 31 | 31 | log.info("项目启动加载中获取排班表并存入缓存-----"); |
| 32 | - cacheNowDaySchedulingInit(); | |
| 32 | +// cacheNowDaySchedulingInit(); | |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/common/cache/SchedulingCache.java
Bsth-admin/src/main/java/com/ruoyi/system/protocol/ThinkraceUtil.java
| ... | ... | @@ -26,7 +26,7 @@ public class ThinkraceUtil { |
| 26 | 26 | private static final String COMMAND_SEND = "command:send:"; |
| 27 | 27 | public static final Integer COMMAND_LABEL_SURE = 1; |
| 28 | 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 | 30 | private static RedisCache REDIS_CACHE; |
| 31 | 31 | /** |
| 32 | 32 | * 指令列表 |
| ... | ... | @@ -109,6 +109,7 @@ public class ThinkraceUtil { |
| 109 | 109 | public static final String ALARM_REQ = "IWAP10"; |
| 110 | 110 | public static final String IMAGE_REQ = "IWAP42"; |
| 111 | 111 | public static final String HEART_REQ = "IWAP49"; |
| 112 | + // 这两协议 在st2和智能手表标准协议中都有 | |
| 112 | 113 | public static final String TEMPERATURE_50_REQ = "IWAP50"; |
| 113 | 114 | public static final String QUERY_BLUETOOTH_REQ = "IWAP51"; |
| 114 | 115 | public static final String CDMA_GPS_REQ = "IWAP91"; |
| ... | ... | @@ -140,7 +141,7 @@ public class ThinkraceUtil { |
| 140 | 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 | 146 | public static final String RECOVERY_RESET_REQ = "IWAP17"; |
| 146 | 147 | public static final String RESET_POWER_REQ = "IWAP18"; | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/system/protocol/adapter/callback/ICallbackHeartCheckPacketAdapter.java
| 1 | 1 | package com.ruoyi.system.protocol.adapter.callback; |
| 2 | 2 | |
| 3 | +import com.ruoyi.system.domain.command.HealthInfo; | |
| 3 | 4 | import com.ruoyi.system.protocol.ThinkraceUtil; |
| 4 | 5 | import com.ruoyi.system.protocol.adapter.ICommandAdapter; |
| 6 | +import io.netty.buffer.Unpooled; | |
| 5 | 7 | import io.netty.channel.ChannelHandlerContext; |
| 6 | 8 | import io.netty.util.AttributeKey; |
| 9 | +import io.netty.util.CharsetUtil; | |
| 7 | 10 | import org.springframework.stereotype.Service; |
| 8 | 11 | |
| 9 | 12 | @Service(ThinkraceUtil.REQ.HEART_CHECK_REQ) |
| 10 | 13 | public class ICallbackHeartCheckPacketAdapter extends ICommandAdapter { |
| 11 | 14 | @Override |
| 12 | 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 | 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
Bsth-admin/src/main/resources/application-druid-uat.yml
| ... | ... | @@ -133,7 +133,7 @@ ruoyi: |
| 133 | 133 | # 实例演示开关 |
| 134 | 134 | demoEnabled: true |
| 135 | 135 | # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) |
| 136 | - profile: /home/sign/uploadPath | |
| 136 | + profile: /home/health/uploadPath | |
| 137 | 137 | # 获取ip地址开关 |
| 138 | 138 | addressEnabled: false |
| 139 | 139 | # 验证码类型 math 数字计算 char 字符验证 |
| ... | ... | @@ -198,10 +198,10 @@ api: |
| 198 | 198 | people: |
| 199 | 199 | url: https://api.dingtalk.com/v1.0/yida/forms/instances/search |
| 200 | 200 | log: |
| 201 | - path: /home/sign/logs | |
| 201 | + path: /home/health/logs | |
| 202 | 202 | netty: |
| 203 | 203 | # 是否开启netty服务 |
| 204 | - enabled: false | |
| 204 | + enabled: true | |
| 205 | 205 | socket: |
| 206 | 206 | # 相对路径 classpath |
| 207 | 207 | catalogue: | ... | ... |