临时停车与临时停车继续骑行
This commit is contained in:
parent
d68b914b92
commit
1a08cca193
@ -233,4 +233,28 @@ public class EbikeBikeInfoController {
|
|||||||
List<EbikeSite> ebikeSites = ebikeBikeInfoService.getAllSiteByBikeCode(bikeCode);
|
List<EbikeSite> ebikeSites = ebikeBikeInfoService.getAllSiteByBikeCode(bikeCode);
|
||||||
return JsonResult.success(ebikeSites);
|
return JsonResult.success(ebikeSites);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户临时停车
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@GetMapping("/api/tempLock")
|
||||||
|
public JsonResult<?> tempLock(@RequestParam("bikeCode") String bikeCode) {
|
||||||
|
ebikeBikeInfoService.tempLock(bikeCode);
|
||||||
|
return JsonResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户临时停车继续骑行
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@GetMapping("/api/tempLockResume")
|
||||||
|
public JsonResult<?> tempLockResume(@RequestParam("bikeCode") String bikeCode) {
|
||||||
|
ebikeBikeInfoService.tempLockResume(bikeCode);
|
||||||
|
return JsonResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,4 +55,14 @@ public interface CommandType {
|
|||||||
* 更新语音播报
|
* 更新语音播报
|
||||||
*/
|
*/
|
||||||
String UPGRADE_AUDIO = "UPGRADE_AUDIO";
|
String UPGRADE_AUDIO = "UPGRADE_AUDIO";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 临时停车
|
||||||
|
*/
|
||||||
|
String TEMP_LOCK = "TEMP_LOCK";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 临时停车继续骑行
|
||||||
|
*/
|
||||||
|
String TEMP_LOCK_RESUME = "TEMP_LOCK_RESUME";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -89,4 +89,18 @@ public interface CommandService{
|
|||||||
* @return 执行结果
|
* @return 执行结果
|
||||||
*/
|
*/
|
||||||
boolean upgradeAudio(EbikeEcuInfo ebikeEcuInfo, String url, Integer idx,Boolean fullUpgrade);
|
boolean upgradeAudio(EbikeEcuInfo ebikeEcuInfo, String url, Integer idx,Boolean fullUpgrade);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 临时停车
|
||||||
|
* @param ebikeEcuInfo 中控信息
|
||||||
|
* @return 执行结果
|
||||||
|
*/
|
||||||
|
boolean tempLock(EbikeEcuInfo ebikeEcuInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 临时停车继续骑行
|
||||||
|
* @param ebikeEcuInfo 中控信息
|
||||||
|
* @return 执行结果
|
||||||
|
*/
|
||||||
|
boolean tempLockResume(EbikeEcuInfo ebikeEcuInfo);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -112,4 +112,16 @@ public interface EbikeBikeInfoService extends IService<EbikeBikeInfo> {
|
|||||||
* @return 所有站点
|
* @return 所有站点
|
||||||
*/
|
*/
|
||||||
List<EbikeSite> getAllSiteByBikeCode(String bikeCode);
|
List<EbikeSite> getAllSiteByBikeCode(String bikeCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 临时停车
|
||||||
|
* @param bikeCode 车辆编号
|
||||||
|
*/
|
||||||
|
void tempLock(String bikeCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 临时停车继续骑行
|
||||||
|
* @param bikeCode 车辆编号
|
||||||
|
*/
|
||||||
|
void tempLockResume(String bikeCode);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -152,4 +152,18 @@ public interface EbikeEcuInfoService extends IService<EbikeEcuInfo> {
|
|||||||
* @param bikeCode 车辆编号
|
* @param bikeCode 车辆编号
|
||||||
*/
|
*/
|
||||||
boolean findBikeByBikeCode(String bikeCode);
|
boolean findBikeByBikeCode(String bikeCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 临时停车
|
||||||
|
* @param ebikeEcuInfo 中控信息
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
boolean tempLock(EbikeEcuInfo ebikeEcuInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 临时停车继续骑行
|
||||||
|
* @param ebikeEcuInfo 中控信息
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
boolean tempLockResume(EbikeEcuInfo ebikeEcuInfo);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -212,6 +212,40 @@ public class CommandServiceImpl implements CommandService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean tempLock(EbikeEcuInfo ebikeEcuInfo) {
|
||||||
|
String taskId = createTaskId();
|
||||||
|
switch (ebikeEcuInfo.getEcuBrand()) {
|
||||||
|
case EcuBrand.GUANG_HE_TONG:
|
||||||
|
String command;
|
||||||
|
try {
|
||||||
|
command = CommandUtil.guang_he_tong(ebikeEcuInfo.getEcuSn(), taskId, CommandType.TEMP_LOCK,null,null,false);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return submitTaskAndWait(topic, taskId, command);
|
||||||
|
default:
|
||||||
|
throw new EbikeException("该品牌中控暂未接入");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean tempLockResume(EbikeEcuInfo ebikeEcuInfo) {
|
||||||
|
String taskId = createTaskId();
|
||||||
|
switch (ebikeEcuInfo.getEcuBrand()) {
|
||||||
|
case EcuBrand.GUANG_HE_TONG:
|
||||||
|
String command;
|
||||||
|
try {
|
||||||
|
command = CommandUtil.guang_he_tong(ebikeEcuInfo.getEcuSn(), taskId, CommandType.TEMP_LOCK_RESUME,null,null,false);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return submitTaskAndWait(topic, taskId, command);
|
||||||
|
default:
|
||||||
|
throw new EbikeException("该品牌中控暂未接入");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提交异步任务并等待布尔结果
|
* 提交异步任务并等待布尔结果
|
||||||
|
|||||||
@ -643,6 +643,36 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
|
|||||||
return siteMapper.selectListByQuery(queryWrapper);
|
return siteMapper.selectListByQuery(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tempLock(String bikeCode) {
|
||||||
|
// 获取车辆中控信息
|
||||||
|
EbikeEcuInfo ebikeEcuInfo = ebikeEcuInfoService.getEcu(bikeCode);
|
||||||
|
if (Objects.isNull(ebikeEcuInfo)) {
|
||||||
|
throw new EbikeException("未找到该车辆编号的中控信息");
|
||||||
|
}
|
||||||
|
boolean result = ebikeEcuInfoService.tempLock(ebikeEcuInfo);
|
||||||
|
if (result) {
|
||||||
|
log.info("车辆编号:{} 临时停车成功", bikeCode);
|
||||||
|
} else {
|
||||||
|
log.warn("车辆编号:{} 临时停车执行返回失败", bikeCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tempLockResume(String bikeCode) {
|
||||||
|
// 获取车辆中控信息
|
||||||
|
EbikeEcuInfo ebikeEcuInfo = ebikeEcuInfoService.getEcu(bikeCode);
|
||||||
|
if (Objects.isNull(ebikeEcuInfo)) {
|
||||||
|
throw new EbikeException("未找到该车辆编号的中控信息");
|
||||||
|
}
|
||||||
|
boolean result = ebikeEcuInfoService.tempLockResume(ebikeEcuInfo);
|
||||||
|
if (result) {
|
||||||
|
log.info("车辆编号:{} 恢复骑行成功", bikeCode);
|
||||||
|
} else {
|
||||||
|
log.warn("车辆编号:{} 恢复骑行执行返回失败", bikeCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static EbikeSpecialDay getEbikeSpecialDay(List<EbikeSpecialDay> ebikeSpecialDays) {
|
static EbikeSpecialDay getEbikeSpecialDay(List<EbikeSpecialDay> ebikeSpecialDays) {
|
||||||
LocalDate today = LocalDate.now();
|
LocalDate today = LocalDate.now();
|
||||||
|
|||||||
@ -237,6 +237,17 @@ public class EbikeEcuInfoServiceImpl extends ServiceImpl<EbikeEcuInfoMapper, Ebi
|
|||||||
return commandService.findBike(ebikeEcuInfo);
|
return commandService.findBike(ebikeEcuInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean tempLock(EbikeEcuInfo ebikeEcuInfo) {
|
||||||
|
return commandService.tempLock(ebikeEcuInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean tempLockResume(EbikeEcuInfo ebikeEcuInfo) {
|
||||||
|
return commandService.tempLockResume(ebikeEcuInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
@ -275,6 +286,8 @@ public class EbikeEcuInfoServiceImpl extends ServiceImpl<EbikeEcuInfoMapper, Ebi
|
|||||||
case CommandType.OPEN_HELMET -> openHelmet(ebikeEcuInfo);
|
case CommandType.OPEN_HELMET -> openHelmet(ebikeEcuInfo);
|
||||||
case CommandType.POWER_OFF -> powerOff(ebikeEcuInfo);
|
case CommandType.POWER_OFF -> powerOff(ebikeEcuInfo);
|
||||||
case CommandType.UPGRADE -> upgradeFile(ebikeEcuInfo, url, false);
|
case CommandType.UPGRADE -> upgradeFile(ebikeEcuInfo, url, false);
|
||||||
|
case CommandType.TEMP_LOCK -> tempLock(ebikeEcuInfo);
|
||||||
|
case CommandType.TEMP_LOCK_RESUME -> tempLockResume(ebikeEcuInfo);
|
||||||
default -> throw new EbikeException("该命令不存在/未接入");
|
default -> throw new EbikeException("该命令不存在/未接入");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -83,6 +83,17 @@ public class CommandUtil {
|
|||||||
ObjectNode objectNode_30 = mapper.readValue(command_30, ObjectNode.class);
|
ObjectNode objectNode_30 = mapper.readValue(command_30, ObjectNode.class);
|
||||||
jsonNode.put("command", objectNode_30.toString());
|
jsonNode.put("command", objectNode_30.toString());
|
||||||
break;
|
break;
|
||||||
|
case CommandType.TEMP_LOCK:
|
||||||
|
String command_84 = "{\"c\":84,\"tid\":\"" + taskId + "\",\"param\":{\"idx\":8}}";
|
||||||
|
ObjectNode objectNode_84 = mapper.readValue(command_84, ObjectNode.class);
|
||||||
|
jsonNode.put("command", objectNode_84.toString());
|
||||||
|
break;
|
||||||
|
case CommandType.TEMP_LOCK_RESUME:
|
||||||
|
String command_85 = "{\"c\":85,\"tid\":\"" + taskId + "\",\"param\":{\"idx\":8}}";
|
||||||
|
ObjectNode objectNode_85 = mapper.readValue(command_85, ObjectNode.class);
|
||||||
|
jsonNode.put("command", objectNode_85.toString());
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new EbikeException("该命令暂未接入");
|
throw new EbikeException("该命令暂未接入");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user