update 并充逻辑

This commit is contained in:
Lemon
2025-08-06 15:49:23 +08:00
parent 68c65d42c3
commit 8404790238
2 changed files with 53 additions and 34 deletions

View File

@@ -35,6 +35,7 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@@ -141,30 +142,39 @@ public class PileRemoteService {
* @param transactionCode * @param transactionCode
* @param chargeAmount * @param chargeAmount
*/ */
public void remoteStartMergeCharging(String pileSn, String transactionCode, public void remoteStartMergeCharging(String pileSn, String connectorCode, String transactionCode,
BigDecimal chargeAmount, String mergeChargeCode) { BigDecimal chargeAmount, String mergeChargeCode) {
if (StringUtils.isEmpty(pileSn)) { if (StringUtils.isEmpty(pileSn) || StringUtils.isEmpty(connectorCode)) {
log.warn("远程启动并充充电, 充电桩编号不能为空"); log.warn("远程启动并充充电, 充电桩编号、枪口号不能为空");
return; return;
} }
// 确定主枪
String mainPileConnectorCode = pileSn + connectorCode;
// 查询该桩下所有的枪口列表
List<PileConnectorInfo> pileConnectorInfos = pileConnectorInfoService.selectPileConnectorInfoList(pileSn); List<PileConnectorInfo> pileConnectorInfos = pileConnectorInfoService.selectPileConnectorInfoList(pileSn);
log.info("【=====平台下发指令=====】: 远程启动并充充电, 桩号:{}", pileSn); log.info("【=====平台下发指令=====】: 远程启动并充充电, 桩号:{}, 枪口号:{}", pileSn, connectorCode);
if (CollectionUtils.isEmpty(pileConnectorInfos)) { if (CollectionUtils.isEmpty(pileConnectorInfos)) {
log.info("远程启动并充充电, 枪口列表为空"); log.info("远程启动并充充电, 枪口列表为空");
return; return;
} }
// 筛选出枪口号
// 筛选出枪口号,与传来的枪口号对比,将传来的枪口号作为主枪排在首位
List<String> connectorCodeList = pileConnectorInfos.stream() List<String> connectorCodeList = pileConnectorInfos.stream()
.map(PileConnectorInfo::getPileConnectorCode) .map(PileConnectorInfo::getPileConnectorCode)
.collect(Collectors.toList())
.stream()
.sorted(Comparator.comparing(x -> !x.equals(mainPileConnectorCode)))
.collect(Collectors.toList()); .collect(Collectors.toList());
for (String pileConnectorCode : connectorCodeList) { for (String pileConnectorCode : connectorCodeList) {
// 获取枪口号 // 获取枪口号
String connectorCode = YKCUtils.getConnectorCode(pileConnectorCode); String gunCode = YKCUtils.getConnectorCode(pileConnectorCode);
// 两把枪都要下发启动充电指令 // 两把枪都要下发启动充电指令
StartMergeChargeCommand command = StartMergeChargeCommand.builder() StartMergeChargeCommand command = StartMergeChargeCommand.builder()
.pileSn(pileSn) .pileSn(pileSn)
.connectorCode(connectorCode) .connectorCode(gunCode)
// .logicCardCode() // .logicCardCode()
.transactionCode(transactionCode) .transactionCode(transactionCode)
// .physicsCardCode() // .physicsCardCode()
@@ -444,29 +454,38 @@ public class PileRemoteService {
} }
public static void main(String[] args) { public static void main(String[] args) {
//获取百度IP地址 // //获取百度IP地址
try { // try {
System.out.println("www.baidu.com的地址: "+InetAddress.getByName("www.baidu.com").getHostAddress()); // System.out.println("www.baidu.com的地址: "+InetAddress.getByName("www.baidu.com").getHostAddress());
} catch (UnknownHostException e) { // } catch (UnknownHostException e) {
throw new RuntimeException(e); // throw new RuntimeException(e);
} // }
//
// //获取百度IP地址
// try {
// System.out.println("jsowell的地址: "+InetAddress.getByName("apitest.jsowellcloud.com").getHostAddress());
// } catch (UnknownHostException e) {
// throw new RuntimeException(e);
// }
//
// String serverAddress = "http://apitest.jsowellcloud.com";
// String ip;
// try {
// String server = StringUtils.removeHttp(serverAddress);;
// ip = InetAddress.getByName(server).getHostAddress();
// } catch (UnknownHostException e) {
// throw new BusinessException("", "无法解析出IP");
// }
// System.out.println("=====" + ip);
//获取百度IP地址 List<String> list = Lists.newArrayList("123", "321", "666", "789");
try { String a = "789";
System.out.println("jsowell的地址: "+InetAddress.getByName("apitest.jsowellcloud.com").getHostAddress());
} catch (UnknownHostException e) {
throw new RuntimeException(e);
}
String serverAddress = "http://apitest.jsowellcloud.com"; System.out.println("排序前 list: " + list);
String ip; List<String> connectorCodeList = list.stream()
try { .sorted(Comparator.comparing(x -> !x.equals(a)))
String server = StringUtils.removeHttp(serverAddress);; .collect(Collectors.toList());
ip = InetAddress.getByName(server).getHostAddress(); System.out.println("排序后 list: " + connectorCodeList);
} catch (UnknownHostException e) {
throw new BusinessException("", "无法解析出IP");
}
System.out.println("=====" + ip);
} }
/** /**

View File

@@ -662,11 +662,11 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
orderInfo.setMainConnectorCode(pileConnectorCode); orderInfo.setMainConnectorCode(pileConnectorCode);
} }
updateOrderBasicInfo(orderInfo); updateOrderBasicInfo(orderInfo);
// 判断是否要向小程序发送通知 // // 判断是否要向小程序发送通知
if (StringUtils.isNotEmpty(orderInfo.getMemberId())){ // if (StringUtils.isNotEmpty(orderInfo.getMemberId())){
// 发送小程序通知 // // 发送小程序通知
wxAppletRemoteService.startChargingSendMsg(orderInfo); // wxAppletRemoteService.startChargingSendMsg(orderInfo);
} // }
} }
/** /**
@@ -4283,7 +4283,7 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
String orderType = orderInfo.getOrderType(); String orderType = orderInfo.getOrderType();
if (StringUtils.equals(OrderTypeEnum.MERGE_CHARGE_ORDER.getValue(), orderType)) { if (StringUtils.equals(OrderTypeEnum.MERGE_CHARGE_ORDER.getValue(), orderType)) {
// 并充订单,调用并充启动充电 // 并充订单,调用并充启动充电
pileRemoteService.remoteStartMergeCharging(pileSn, orderInfo.getTransactionCode(), chargeAmount, orderInfo.getMergeChargeNumber()); pileRemoteService.remoteStartMergeCharging(pileSn, orderInfo.getConnectorCode(), orderInfo.getTransactionCode(), chargeAmount, orderInfo.getMergeChargeNumber());
}else { }else {
// 普通订单启动充电 // 普通订单启动充电
pileRemoteService.remoteStartCharging(pileSn, orderInfo.getConnectorCode(), orderInfo.getTransactionCode(), chargeAmount); pileRemoteService.remoteStartCharging(pileSn, orderInfo.getConnectorCode(), orderInfo.getTransactionCode(), chargeAmount);