diff --git a/ebike-operations/src/main/java/com/cdzy/operations/enums/CommandType.java b/ebike-operations/src/main/java/com/cdzy/operations/enums/CommandType.java index 4af0b75..a83e5ab 100644 --- a/ebike-operations/src/main/java/com/cdzy/operations/enums/CommandType.java +++ b/ebike-operations/src/main/java/com/cdzy/operations/enums/CommandType.java @@ -15,4 +15,9 @@ public interface CommandType { * GPS */ String GPS = "GPS"; + + /** + * 打开电池所(3s复位 + */ + String OPEN_BATTERY_LOCK = "OPEN_BATTERY_LOCK"; } diff --git a/ebike-operations/src/main/java/com/cdzy/operations/service/CommandService.java b/ebike-operations/src/main/java/com/cdzy/operations/service/CommandService.java index cfc3d58..42f9161 100644 --- a/ebike-operations/src/main/java/com/cdzy/operations/service/CommandService.java +++ b/ebike-operations/src/main/java/com/cdzy/operations/service/CommandService.java @@ -24,6 +24,13 @@ public interface CommandService{ */ boolean gps(EbikeEcuInfo ebikeEcuInfo); + /** + * 打开电池仓锁 + * @param ebikeEcuInfo 中控信息 + * @return 执行结果 + */ + boolean openBatteryLock(EbikeEcuInfo ebikeEcuInfo); + /** * 回调事件 * @param taskId 任务ID diff --git a/ebike-operations/src/main/java/com/cdzy/operations/service/EbikeEcuInfoService.java b/ebike-operations/src/main/java/com/cdzy/operations/service/EbikeEcuInfoService.java index 7258fa2..6fc30ac 100644 --- a/ebike-operations/src/main/java/com/cdzy/operations/service/EbikeEcuInfoService.java +++ b/ebike-operations/src/main/java/com/cdzy/operations/service/EbikeEcuInfoService.java @@ -57,6 +57,13 @@ public interface EbikeEcuInfoService extends IService { */ boolean gps(EbikeEcuInfo ebikeEcuInfo); + /** + * 打开电池仓锁命令 + * @param ebikeEcuInfo 中控信息 + * @return 结果 + */ + boolean openBatteryLock(EbikeEcuInfo ebikeEcuInfo); + /** * 校验参数 * @param ecuSn 中控SN码 diff --git a/ebike-operations/src/main/java/com/cdzy/operations/service/impl/CommandServiceImpl.java b/ebike-operations/src/main/java/com/cdzy/operations/service/impl/CommandServiceImpl.java index 24f628b..7dd60af 100644 --- a/ebike-operations/src/main/java/com/cdzy/operations/service/impl/CommandServiceImpl.java +++ b/ebike-operations/src/main/java/com/cdzy/operations/service/impl/CommandServiceImpl.java @@ -68,6 +68,23 @@ public class CommandServiceImpl implements CommandService { } } + @Override + public boolean openBatteryLock(EbikeEcuInfo ebikeEcuInfo) { + String taskId = createTaskId(); + switch (ebikeEcuInfo.getEcuBrand()){ + case EcuBrand.GUANG_HE_TONG: + String command = null; + try { + command = CommandUtil.guang_he_tong(ebikeEcuInfo.getEcuSn(),taskId, CommandType.OPEN_BATTERY_LOCK); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + return submitTaskAndWait(topic, taskId,command); + default : + throw new EbikeException("该品牌中控暂未接入"); + } + } + @Override public void onComplete(String taskId, boolean success) { completeRequest(taskId,success); diff --git a/ebike-operations/src/main/java/com/cdzy/operations/service/impl/EbikeEcuInfoServiceImpl.java b/ebike-operations/src/main/java/com/cdzy/operations/service/impl/EbikeEcuInfoServiceImpl.java index d32e4e3..5255524 100644 --- a/ebike-operations/src/main/java/com/cdzy/operations/service/impl/EbikeEcuInfoServiceImpl.java +++ b/ebike-operations/src/main/java/com/cdzy/operations/service/impl/EbikeEcuInfoServiceImpl.java @@ -131,6 +131,11 @@ public class EbikeEcuInfoServiceImpl extends ServiceImpl findBike(ebikeEcuInfo); case CommandType.GPS -> gps(ebikeEcuInfo); + case CommandType.OPEN_BATTERY_LOCK -> openBatteryLock(ebikeEcuInfo); default -> throw new EbikeException("该命令不存在/未接入"); }; } diff --git a/ebike-operations/src/main/java/com/cdzy/operations/utils/CommandUtil.java b/ebike-operations/src/main/java/com/cdzy/operations/utils/CommandUtil.java index fad3884..ebce867 100644 --- a/ebike-operations/src/main/java/com/cdzy/operations/utils/CommandUtil.java +++ b/ebike-operations/src/main/java/com/cdzy/operations/utils/CommandUtil.java @@ -32,6 +32,11 @@ public class CommandUtil { ObjectNode objectNode_34 = mapper.readValue(command_34,ObjectNode.class); jsonNode.put("command",objectNode_34.toString()); break; + case CommandType.OPEN_BATTERY_LOCK: + String command_29 = "{\"c\":29,\"tid\":\""+ taskId+"\"}"; + ObjectNode objectNode_29 = mapper.readValue(command_29,ObjectNode.class); + jsonNode.put("command",objectNode_29.toString()); + break; default : throw new EbikeException("该命令暂未接入"); }