运营区边缘计算:基础支持-音频播放命令

This commit is contained in:
PC 2026-03-04 09:45:28 +08:00
parent 643ea38553
commit 1511e1f8f8
8 changed files with 70 additions and 3 deletions

View File

@ -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; // 超出运营区提醒
}

View File

@ -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);
}

View File

@ -65,4 +65,9 @@ public interface CommandType {
* 临时停车继续骑行
*/
String TEMP_LOCK_RESUME = "TEMP_LOCK_RESUME";
/**
* 播放音频
*/
String PLAY_AUDIO = "PLAY_AUDIO";
}

View File

@ -103,4 +103,12 @@ public interface CommandService{
* @return 执行结果
*/
boolean tempLockResume(EbikeEcuInfo ebikeEcuInfo);
/**
* 播放音频
* @param ebikeEcuInfo 中控信息
* @param idx 语音顺序
* @return 执行结果
*/
boolean playAudio(EbikeEcuInfo ebikeEcuInfo,Integer idx);
}

View File

@ -117,7 +117,7 @@ public interface EbikeEcuInfoService extends IService<EbikeEcuInfo> {
* @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);
/**
* 根据车辆编号获取中控信息

View File

@ -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("该品牌中控暂未接入");
}
}
/**
* 提交异步任务并等待布尔结果

View File

@ -247,6 +247,9 @@ public class EbikeEcuInfoServiceImpl extends ServiceImpl<EbikeEcuInfoMapper, Ebi
return commandService.tempLockResume(ebikeEcuInfo);
}
private boolean playAudio(EbikeEcuInfo ebikeEcuInfo,Integer idx) {
return commandService.playAudio(ebikeEcuInfo,idx);
}
public boolean upgradeAudio(EbikeEcuInfo ebikeEcuInfo, String url, Integer idx, Boolean fullUpgrade) {
return commandService.upgradeAudio(ebikeEcuInfo, url, idx, fullUpgrade);
@ -268,7 +271,7 @@ public class EbikeEcuInfoServiceImpl extends ServiceImpl<EbikeEcuInfoMapper, Ebi
}
@Override
public boolean executeCommand(String ecuSn, String bikeCode, String commandCode, String url) {
public boolean executeCommand(String ecuSn, String bikeCode, String commandCode, String url,Integer idx) {
check(ecuSn, bikeCode);
EbikeEcuInfo ebikeEcuInfo;
if (StringUtil.hasText(ecuSn)) {
@ -288,6 +291,7 @@ public class EbikeEcuInfoServiceImpl extends ServiceImpl<EbikeEcuInfoMapper, Ebi
case CommandType.UPGRADE -> 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("该命令不存在/未接入");
};
}

View File

@ -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("该命令暂未接入");