打开电池仓锁
This commit is contained in:
parent
38aa18053e
commit
c1142f711d
@ -15,4 +15,9 @@ public interface CommandType {
|
||||
* GPS
|
||||
*/
|
||||
String GPS = "GPS";
|
||||
|
||||
/**
|
||||
* 打开电池所(3s复位
|
||||
*/
|
||||
String OPEN_BATTERY_LOCK = "OPEN_BATTERY_LOCK";
|
||||
}
|
||||
|
||||
@ -24,6 +24,13 @@ public interface CommandService{
|
||||
*/
|
||||
boolean gps(EbikeEcuInfo ebikeEcuInfo);
|
||||
|
||||
/**
|
||||
* 打开电池仓锁
|
||||
* @param ebikeEcuInfo 中控信息
|
||||
* @return 执行结果
|
||||
*/
|
||||
boolean openBatteryLock(EbikeEcuInfo ebikeEcuInfo);
|
||||
|
||||
/**
|
||||
* 回调事件
|
||||
* @param taskId 任务ID
|
||||
|
||||
@ -57,6 +57,13 @@ public interface EbikeEcuInfoService extends IService<EbikeEcuInfo> {
|
||||
*/
|
||||
boolean gps(EbikeEcuInfo ebikeEcuInfo);
|
||||
|
||||
/**
|
||||
* 打开电池仓锁命令
|
||||
* @param ebikeEcuInfo 中控信息
|
||||
* @return 结果
|
||||
*/
|
||||
boolean openBatteryLock(EbikeEcuInfo ebikeEcuInfo);
|
||||
|
||||
/**
|
||||
* 校验参数
|
||||
* @param ecuSn 中控SN码
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -131,6 +131,11 @@ public class EbikeEcuInfoServiceImpl extends ServiceImpl<EbikeEcuInfoMapper, Ebi
|
||||
return commandService.gps(ebikeEcuInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean openBatteryLock(EbikeEcuInfo ebikeEcuInfo) {
|
||||
return commandService.openBatteryLock(ebikeEcuInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkSnOrBikeCode(String ecuSn, String bikeCode) {
|
||||
try {
|
||||
@ -149,7 +154,7 @@ public class EbikeEcuInfoServiceImpl extends ServiceImpl<EbikeEcuInfoMapper, Ebi
|
||||
@Override
|
||||
public boolean executeCommand(String ecuSn, String bikeCode, String commandCode) {
|
||||
check(ecuSn, bikeCode);
|
||||
EbikeEcuInfo ebikeEcuInfo = null;
|
||||
EbikeEcuInfo ebikeEcuInfo;
|
||||
if (StringUtil.hasText(ecuSn)) {
|
||||
ebikeEcuInfo = checkEcuSn(ecuSn);
|
||||
} else {
|
||||
@ -158,6 +163,7 @@ public class EbikeEcuInfoServiceImpl extends ServiceImpl<EbikeEcuInfoMapper, Ebi
|
||||
return switch (commandCode) {
|
||||
case CommandType.FIND_BIKE -> findBike(ebikeEcuInfo);
|
||||
case CommandType.GPS -> gps(ebikeEcuInfo);
|
||||
case CommandType.OPEN_BATTERY_LOCK -> openBatteryLock(ebikeEcuInfo);
|
||||
default -> throw new EbikeException("该命令不存在/未接入");
|
||||
};
|
||||
}
|
||||
|
||||
@ -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("该命令暂未接入");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user