运营区边缘计算:基础支持-音频播放命令
This commit is contained in:
parent
643ea38553
commit
1511e1f8f8
@ -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; // 超出运营区提醒
|
||||||
|
}
|
||||||
@ -3,6 +3,7 @@ package com.cdzy.operations.controller;
|
|||||||
import com.cdzy.common.enums.Message;
|
import com.cdzy.common.enums.Message;
|
||||||
import com.cdzy.common.model.request.PageParam;
|
import com.cdzy.common.model.request.PageParam;
|
||||||
import com.cdzy.common.model.response.JsonResult;
|
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.dto.EbikeEcuInOverview;
|
||||||
import com.cdzy.operations.model.entity.EbikeEcuInfo;
|
import com.cdzy.operations.model.entity.EbikeEcuInfo;
|
||||||
import com.cdzy.operations.model.vo.EbikeEcuInfoBatchVo;
|
import com.cdzy.operations.model.vo.EbikeEcuInfoBatchVo;
|
||||||
@ -166,7 +167,18 @@ public class EbikeEcuInfoController {
|
|||||||
*/
|
*/
|
||||||
@GetMapping("executeCommand")
|
@GetMapping("executeCommand")
|
||||||
public JsonResult<?> executeCommand(String ecuSn, String bikeCode, @NotNull(message = "命令编码不能为空") String commandCode) {
|
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);
|
return JsonResult.success(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -65,4 +65,9 @@ public interface CommandType {
|
|||||||
* 临时停车继续骑行
|
* 临时停车继续骑行
|
||||||
*/
|
*/
|
||||||
String TEMP_LOCK_RESUME = "TEMP_LOCK_RESUME";
|
String TEMP_LOCK_RESUME = "TEMP_LOCK_RESUME";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 播放音频
|
||||||
|
*/
|
||||||
|
String PLAY_AUDIO = "PLAY_AUDIO";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -103,4 +103,12 @@ public interface CommandService{
|
|||||||
* @return 执行结果
|
* @return 执行结果
|
||||||
*/
|
*/
|
||||||
boolean tempLockResume(EbikeEcuInfo ebikeEcuInfo);
|
boolean tempLockResume(EbikeEcuInfo ebikeEcuInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 播放音频
|
||||||
|
* @param ebikeEcuInfo 中控信息
|
||||||
|
* @param idx 语音顺序
|
||||||
|
* @return 执行结果
|
||||||
|
*/
|
||||||
|
boolean playAudio(EbikeEcuInfo ebikeEcuInfo,Integer idx);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -117,7 +117,7 @@ public interface EbikeEcuInfoService extends IService<EbikeEcuInfo> {
|
|||||||
* @param commandCode 命令编码
|
* @param commandCode 命令编码
|
||||||
* @return 执行结果
|
* @return 执行结果
|
||||||
*/
|
*/
|
||||||
boolean executeCommand(String ecuSn, String bikeCode, String commandCode,String url);
|
boolean executeCommand(String ecuSn, String bikeCode, String commandCode,String url,Integer idx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据车辆编号获取中控信息
|
* 根据车辆编号获取中控信息
|
||||||
|
|||||||
@ -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("该品牌中控暂未接入");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提交异步任务并等待布尔结果
|
* 提交异步任务并等待布尔结果
|
||||||
|
|||||||
@ -247,6 +247,9 @@ public class EbikeEcuInfoServiceImpl extends ServiceImpl<EbikeEcuInfoMapper, Ebi
|
|||||||
return commandService.tempLockResume(ebikeEcuInfo);
|
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) {
|
public boolean upgradeAudio(EbikeEcuInfo ebikeEcuInfo, String url, Integer idx, Boolean fullUpgrade) {
|
||||||
return commandService.upgradeAudio(ebikeEcuInfo, url, idx, fullUpgrade);
|
return commandService.upgradeAudio(ebikeEcuInfo, url, idx, fullUpgrade);
|
||||||
@ -268,7 +271,7 @@ public class EbikeEcuInfoServiceImpl extends ServiceImpl<EbikeEcuInfoMapper, Ebi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
check(ecuSn, bikeCode);
|
||||||
EbikeEcuInfo ebikeEcuInfo;
|
EbikeEcuInfo ebikeEcuInfo;
|
||||||
if (StringUtil.hasText(ecuSn)) {
|
if (StringUtil.hasText(ecuSn)) {
|
||||||
@ -288,6 +291,7 @@ public class EbikeEcuInfoServiceImpl extends ServiceImpl<EbikeEcuInfoMapper, Ebi
|
|||||||
case CommandType.UPGRADE -> upgradeFile(ebikeEcuInfo, url, false);
|
case CommandType.UPGRADE -> upgradeFile(ebikeEcuInfo, url, false);
|
||||||
case CommandType.TEMP_LOCK -> tempLock(ebikeEcuInfo);
|
case CommandType.TEMP_LOCK -> tempLock(ebikeEcuInfo);
|
||||||
case CommandType.TEMP_LOCK_RESUME -> tempLockResume(ebikeEcuInfo);
|
case CommandType.TEMP_LOCK_RESUME -> tempLockResume(ebikeEcuInfo);
|
||||||
|
case CommandType.PLAY_AUDIO -> playAudio(ebikeEcuInfo,idx);
|
||||||
default -> throw new EbikeException("该命令不存在/未接入");
|
default -> throw new EbikeException("该命令不存在/未接入");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -93,6 +93,11 @@ public class CommandUtil {
|
|||||||
ObjectNode objectNode_85 = mapper.readValue(command_85, ObjectNode.class);
|
ObjectNode objectNode_85 = mapper.readValue(command_85, ObjectNode.class);
|
||||||
jsonNode.put("command", objectNode_85.toString());
|
jsonNode.put("command", objectNode_85.toString());
|
||||||
break;
|
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:
|
default:
|
||||||
throw new EbikeException("该命令暂未接入");
|
throw new EbikeException("该命令暂未接入");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user