update 电单车协议

This commit is contained in:
Guoqs
2024-09-20 09:00:45 +08:00
parent 9a2af549d8
commit d08ee877f6
7 changed files with 112 additions and 28 deletions

View File

@@ -84,7 +84,7 @@ public class EBikeSendCommandServiceImpl implements EBikeSendCommandService {
* @param command
*/
@Override
public ChargingOperationResponse sendStopChargingCommand(StopChargingCommand command) throws Exception {
public ChargingOperationResponse sendStopChargingCommand(StopChargingCommand command) {
String pileSn = command.getPileSn();
String connectorCode = command.getConnectorCode();
String transactionCode = command.getTransactionCode();
@@ -131,10 +131,10 @@ public class EBikeSendCommandServiceImpl implements EBikeSendCommandService {
* 公共方法, 发送指令
* @param msg
*/
private byte[] send(AbsEBikeMessage2 msg) throws Exception {
private byte[] send(AbsEBikeMessage2 msg) {
return this.send(msg, 5, TimeUnit.SECONDS);
}
private byte[] send(AbsEBikeMessage2 msg, long timeout, TimeUnit unit) throws Exception {
private byte[] send(AbsEBikeMessage2 msg, long timeout, TimeUnit unit) {
String pileSn = msg.getPhysicalId() + "";
byte[] messageBytes = msg.getMessageBytes();
String command = YKCUtils.frameType2Str(msg.getCommand());
@@ -172,17 +172,23 @@ public class EBikeSendCommandServiceImpl implements EBikeSendCommandService {
});
// 等待获取结果
byte[] rpcResponse = syncPromise.get(timeout, unit);
if(rpcResponse == null) {
if(syncPromise.isTimeout()) {
// throw new TimeoutException("等待响应结果超时");
log.error("发送[{}]指令后, 等待响应结果超时", command);
} else{
log.error("发送[{}]指令后, 发生其他异常", command);
byte[] rpcResponse;
try {
rpcResponse = syncPromise.get(timeout, unit);
if(rpcResponse == null) {
if(syncPromise.isTimeout()) {
// throw new TimeoutException("等待响应结果超时");
log.error("发送[{}]指令后, 等待响应结果超时", command);
} else{
log.error("发送[{}]指令后, 发生其他异常", command);
}
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
} finally {
// 移除容器
RpcUtil.getSyncPromiseMap().remove(msgId);
}
// 移除容器
RpcUtil.getSyncPromiseMap().remove(msgId);
return rpcResponse;
}

View File

@@ -417,6 +417,25 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService {
return pileInfoVO;
}
@Override
public PileDetailVO selectPileDetailByPileSn(String pileSn) {
PileDetailVO pileInfoVO = pileBasicInfoMapper.selectPileDetailByPileSn(pileSn);
if (pileInfoVO == null) {
return null;
}
// 获取桩状态
Map<String, String> pileStatusMap = pileConnectorInfoService.getPileStatus(Lists.newArrayList(pileInfoVO.getPileSn()));
pileInfoVO.setStatus(pileStatusMap.get(pileInfoVO.getPileSn()));
String pileQrCodeUrl = getPileQrCodeUrl(pileInfoVO.getPileSn());
pileInfoVO.setQrCodeURL(pileQrCodeUrl);
// 设备型号
PileModelInfo pileModelInfo = pileModelInfoService.selectPileModelInfoById(Long.parseLong(pileInfoVO.getModelId()));
if (pileModelInfo != null) {
pileInfoVO.setModelName(pileModelInfo.getModelName());
}
return pileInfoVO;
}
/**
* 根据桩编号查询桩信息
* @param pileSn