From 1511e1f8f8ff4ae8bf36c16f20f6c496f1216ceac00d42994b1498dd73a1d1c7 Mon Sep 17 00:00:00 2001 From: PC <2413103649@qq.com> Date: Wed, 4 Mar 2026 09:45:28 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=90=E8=90=A5=E5=8C=BA=E8=BE=B9=E7=BC=98?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=EF=BC=9A=E5=9F=BA=E7=A1=80=E6=94=AF=E6=8C=81?= =?UTF-8?q?-=E9=9F=B3=E9=A2=91=E6=92=AD=E6=94=BE=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/cdzy/common/enums/AudioType.java | 16 ++++++++++++++++ .../controller/EbikeEcuInfoController.java | 14 +++++++++++++- .../com/cdzy/operations/enums/CommandType.java | 5 +++++ .../cdzy/operations/service/CommandService.java | 8 ++++++++ .../operations/service/EbikeEcuInfoService.java | 2 +- .../service/impl/CommandServiceImpl.java | 17 +++++++++++++++++ .../service/impl/EbikeEcuInfoServiceImpl.java | 6 +++++- .../com/cdzy/operations/utils/CommandUtil.java | 5 +++++ 8 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 ebike-common/src/main/java/com/cdzy/common/enums/AudioType.java diff --git a/ebike-common/src/main/java/com/cdzy/common/enums/AudioType.java b/ebike-common/src/main/java/com/cdzy/common/enums/AudioType.java new file mode 100644 index 0000000..ecc26f8 --- /dev/null +++ b/ebike-common/src/main/java/com/cdzy/common/enums/AudioType.java @@ -0,0 +1,16 @@ +package com.cdzy.common.enums; + +public interface AudioType { + Integer UN_LOCK = 1; // 开锁指令 + Integer LOCK = 2; // 关锁指令 + Integer OPEN_BATTERY_LOCK = 3; // 开电池仓锁指令 + Integer CLOSE_BATTERY_LOCK = 4; // 关电池仓锁指令 + Integer OPEN_HELMET_LOCK = 5; // 开头盔锁指令 + Integer CLOSE_HELMET_LOCK = 6; // 关头盔锁指令 + Integer ANTI_THEFT = 7; // 防盗指令 + Integer FIND_BIKE = 8; // 寻车铃指令 + Integer LOW_BATTERY_ALERT = 9; // 低电量提醒 + Integer EDGE_ALERT = 10; // 运营区边缘提醒 + Integer TEMP_LOCK = 11; // 临时锁车 + Integer OUT_OF_AREA_ALERT = 12; // 超出运营区提醒 +} diff --git a/ebike-operations/src/main/java/com/cdzy/operations/controller/EbikeEcuInfoController.java b/ebike-operations/src/main/java/com/cdzy/operations/controller/EbikeEcuInfoController.java index b20b8cf..d6394d8 100644 --- a/ebike-operations/src/main/java/com/cdzy/operations/controller/EbikeEcuInfoController.java +++ b/ebike-operations/src/main/java/com/cdzy/operations/controller/EbikeEcuInfoController.java @@ -3,6 +3,7 @@ package com.cdzy.operations.controller; import com.cdzy.common.enums.Message; import com.cdzy.common.model.request.PageParam; import com.cdzy.common.model.response.JsonResult; +import com.cdzy.operations.enums.CommandType; import com.cdzy.operations.model.dto.EbikeEcuInOverview; import com.cdzy.operations.model.entity.EbikeEcuInfo; import com.cdzy.operations.model.vo.EbikeEcuInfoBatchVo; @@ -166,7 +167,18 @@ public class EbikeEcuInfoController { */ @GetMapping("executeCommand") public JsonResult executeCommand(String ecuSn, String bikeCode, @NotNull(message = "命令编码不能为空") String commandCode) { - boolean result = ebikeEcuInfoService.executeCommand(ecuSn, bikeCode, commandCode, null); + boolean result = ebikeEcuInfoService.executeCommand(ecuSn, bikeCode, commandCode, null,null); + return JsonResult.success(result); + } + + /** + * 播放音频 + * + * @return 执行结构 + */ + @GetMapping("playAudio") + public JsonResult playAudio(String ecuSn,Integer idx) { + boolean result = ebikeEcuInfoService.executeCommand(ecuSn, null, CommandType.PLAY_AUDIO, null,idx); return JsonResult.success(result); } 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 8584a28..2fac736 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 @@ -65,4 +65,9 @@ public interface CommandType { * 临时停车继续骑行 */ String TEMP_LOCK_RESUME = "TEMP_LOCK_RESUME"; + + /** + * 播放音频 + */ + String PLAY_AUDIO = "PLAY_AUDIO"; } 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 bc3542b..0717362 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 @@ -103,4 +103,12 @@ public interface CommandService{ * @return 执行结果 */ boolean tempLockResume(EbikeEcuInfo ebikeEcuInfo); + + /** + * 播放音频 + * @param ebikeEcuInfo 中控信息 + * @param idx 语音顺序 + * @return 执行结果 + */ + boolean playAudio(EbikeEcuInfo ebikeEcuInfo,Integer idx); } 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 193e19f..bfcc8a3 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 @@ -117,7 +117,7 @@ public interface EbikeEcuInfoService extends IService { * @param commandCode 命令编码 * @return 执行结果 */ - boolean executeCommand(String ecuSn, String bikeCode, String commandCode,String url); + boolean executeCommand(String ecuSn, String bikeCode, String commandCode,String url,Integer idx); /** * 根据车辆编号获取中控信息 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 335aa78..65da540 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 @@ -246,6 +246,23 @@ public class CommandServiceImpl implements CommandService { } } + @Override + public boolean playAudio(EbikeEcuInfo ebikeEcuInfo,Integer idx) { + String taskId = createTaskId(); + switch (ebikeEcuInfo.getEcuBrand()) { + case EcuBrand.GUANG_HE_TONG: + String command; + try { + command = CommandUtil.guang_he_tong(ebikeEcuInfo.getEcuSn(), taskId, CommandType.PLAY_AUDIO,null,idx,false); + } catch (Exception e) { + throw new RuntimeException(e); + } + return submitTaskAndWait(topic, taskId, command); + default: + throw new EbikeException("该品牌中控暂未接入"); + } + } + /** * 提交异步任务并等待布尔结果 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 f3805ed..e6290c4 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 @@ -247,6 +247,9 @@ public class EbikeEcuInfoServiceImpl extends ServiceImpl upgradeFile(ebikeEcuInfo, url, false); case CommandType.TEMP_LOCK -> tempLock(ebikeEcuInfo); case CommandType.TEMP_LOCK_RESUME -> tempLockResume(ebikeEcuInfo); + case CommandType.PLAY_AUDIO -> playAudio(ebikeEcuInfo,idx); 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 fec3b5c..d59c90d 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 @@ -93,6 +93,11 @@ public class CommandUtil { ObjectNode objectNode_85 = mapper.readValue(command_85, ObjectNode.class); jsonNode.put("command", objectNode_85.toString()); break; + case CommandType.PLAY_AUDIO: + String command_14_all = "{\"c\":14,\"tid\":\"" + taskId + "\",\"param\":{\"volume\":50,\"idx\":"+idx+"}}"; + ObjectNode objectNode_14_all = mapper.readValue(command_14_all, ObjectNode.class); + jsonNode.put("command", objectNode_14_all.toString()); + break; default: throw new EbikeException("该命令暂未接入");