diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/PileBasicInfoMapper.java b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/PileBasicInfoMapper.java index d114728c6..34cef148b 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/PileBasicInfoMapper.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/PileBasicInfoMapper.java @@ -112,6 +112,12 @@ public interface PileBasicInfoMapper { */ PileDetailVO selectBasicInfoById(Long id); + /** + * 通过桩sn查询basic信息 + * @param pileSn 桩sn + */ + PileDetailVO selectPileDetailByPileSn(String pileSn); + /** * 通过idList批量查询 * diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/EBikeSendCommandService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/EBikeSendCommandService.java index 65696ede6..9c108e96f 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/EBikeSendCommandService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/EBikeSendCommandService.java @@ -19,7 +19,7 @@ public interface EBikeSendCommandService { * 停止充电 * @param command */ - ChargingOperationResponse sendStopChargingCommand(StopChargingCommand command) throws Exception; + ChargingOperationResponse sendStopChargingCommand(StopChargingCommand command); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/PileBasicInfoService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/PileBasicInfoService.java index 463697708..5c92c803f 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/PileBasicInfoService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/PileBasicInfoService.java @@ -105,6 +105,14 @@ public interface PileBasicInfoService { */ PileDetailVO selectBasicInfoById(Long id); + /** + * 通过桩sn查询basic信息 + * + * @param id 桩id + * @return 结果集合 + */ + PileDetailVO selectPileDetailByPileSn(String pileSn); + PileInfoVO selectPileInfoBySn(String pileSn); /** @@ -125,20 +133,6 @@ public interface PileBasicInfoService { */ void firstUnplugCharger(String pileConnectorCode); - /** - * 通过桩编号查询站点id - * @param sn 桩编号 - * @return 站点id - */ - // String selectStationIdBySn(String sn); - - /** - * uniApp通过桩号查询桩详情 - * @param pileSn 桩号 - * @return - */ - // PileDetailVO uniAppGetPileDetailByPileSn(String pileSn); - /** * 修改状态 * @param frameType diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/PileRemoteService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/PileRemoteService.java index 7afbe07ce..589a89b11 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/PileRemoteService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/PileRemoteService.java @@ -3,6 +3,7 @@ package com.jsowell.pile.service; import com.alibaba.fastjson2.JSON; import com.google.common.collect.Lists; import com.jsowell.common.constant.CacheConstants; +import com.jsowell.common.constant.Constants; import com.jsowell.common.core.domain.ykc.YKCDataProtocol; import com.jsowell.common.core.redis.RedisCache; import com.jsowell.common.enums.ebike.EBikeChargeResponseEnum; @@ -162,14 +163,44 @@ public class PileRemoteService { log.info("发送远程停止充电指令-充电桩枪口编号:{}, 获取到正在充电中的交易流水号:{}, 与入参交易流水号:{}不一致, function return", pileSn + connectorCode, redisResult, transactionCode); return; } + + // 查询桩信息 + PileDetailVO pileDetailVO = pileBasicInfoService.selectPileDetailByPileSn(pileSn); + if (pileDetailVO == null) { + return; + } + StopChargingCommand command = StopChargingCommand.builder() .pileSn(pileSn) .connectorCode(connectorCode) + .transactionCode(transactionCode) .build(); - ykcPushCommandService.pushStopChargingCommand(command); + + String chargePortType = pileDetailVO.getChargePortType(); + if (StringUtils.equals(chargePortType, Constants.THREE)) { + // 发送电动自行车桩停止充电指令 + eBikeSendCommandService.sendStopChargingCommand(command); + } else { + // 发送电动汽车桩停止充电指令 + ykcPushCommandService.pushStopChargingCommand(command); + } log.info("remoteStopCharging success, pileConnectorCode:{}, transactionCode:{}", pileSn + connectorCode, transactionCode); } + public void remoteStopChargingForEBike(String pileSn, String connectorCode, String transactionCode) { + StopChargingCommand command = StopChargingCommand.builder() + .pileSn(pileSn) + .connectorCode(connectorCode) + .transactionCode(transactionCode) + .build(); + try { + eBikeSendCommandService.sendStopChargingCommand(command); + } catch (Exception e) { + log.error("remoteStopChargingForEBike error, pileSn:{}, connectorCode:{}, transactionCode:{}" + ,pileSn, connectorCode, transactionCode, e); + } + } + /** * 下发充电桩二维码 * diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/EBikeSendCommandServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/EBikeSendCommandServiceImpl.java index 9913360f1..466ba3f1f 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/EBikeSendCommandServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/EBikeSendCommandServiceImpl.java @@ -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; } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java index 37690f650..152b213f2 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java @@ -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 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 diff --git a/jsowell-pile/src/main/resources/mapper/pile/PileBasicInfoMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/PileBasicInfoMapper.xml index 6c5e24dba..7dbde1765 100644 --- a/jsowell-pile/src/main/resources/mapper/pile/PileBasicInfoMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/pile/PileBasicInfoMapper.xml @@ -419,4 +419,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" id desc limit 1 + + \ No newline at end of file