From c1142f711d24b05daa1d88eeaada5941ab3433256d91f17c1c0e56516743b007 Mon Sep 17 00:00:00 2001 From: attiya <2413103649@qq.com> Date: Fri, 31 Oct 2025 10:23:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=BC=80=E7=94=B5=E6=B1=A0=E4=BB=93?= =?UTF-8?q?=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/cdzy/operations/enums/CommandType.java | 5 +++++ .../cdzy/operations/service/CommandService.java | 7 +++++++ .../operations/service/EbikeEcuInfoService.java | 7 +++++++ .../service/impl/CommandServiceImpl.java | 17 +++++++++++++++++ .../service/impl/EbikeEcuInfoServiceImpl.java | 8 +++++++- .../com/cdzy/operations/utils/CommandUtil.java | 5 +++++ 6 files changed, 48 insertions(+), 1 deletion(-) 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("该命令暂未接入"); }