mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 03:25:12 +08:00
update 并充逻辑
This commit is contained in:
@@ -35,6 +35,7 @@ import org.springframework.stereotype.Service;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -141,30 +142,39 @@ public class PileRemoteService {
|
||||
* @param transactionCode
|
||||
* @param chargeAmount
|
||||
*/
|
||||
public void remoteStartMergeCharging(String pileSn, String transactionCode,
|
||||
public void remoteStartMergeCharging(String pileSn, String connectorCode, String transactionCode,
|
||||
BigDecimal chargeAmount, String mergeChargeCode) {
|
||||
if (StringUtils.isEmpty(pileSn)) {
|
||||
log.warn("远程启动并充充电, 充电桩编号不能为空");
|
||||
if (StringUtils.isEmpty(pileSn) || StringUtils.isEmpty(connectorCode)) {
|
||||
log.warn("远程启动并充充电, 充电桩编号、枪口号不能为空");
|
||||
return;
|
||||
}
|
||||
// 确定主枪
|
||||
String mainPileConnectorCode = pileSn + connectorCode;
|
||||
|
||||
// 查询该桩下所有的枪口列表
|
||||
List<PileConnectorInfo> pileConnectorInfos = pileConnectorInfoService.selectPileConnectorInfoList(pileSn);
|
||||
log.info("【=====平台下发指令=====】: 远程启动并充充电, 桩号:{}", pileSn);
|
||||
log.info("【=====平台下发指令=====】: 远程启动并充充电, 桩号:{}, 枪口号:{}", pileSn, connectorCode);
|
||||
|
||||
if (CollectionUtils.isEmpty(pileConnectorInfos)) {
|
||||
log.info("远程启动并充充电, 枪口列表为空");
|
||||
return;
|
||||
}
|
||||
// 筛选出枪口号
|
||||
|
||||
// 筛选出枪口号,与传来的枪口号对比,将传来的枪口号作为主枪排在首位
|
||||
List<String> connectorCodeList = pileConnectorInfos.stream()
|
||||
.map(PileConnectorInfo::getPileConnectorCode)
|
||||
.collect(Collectors.toList())
|
||||
.stream()
|
||||
.sorted(Comparator.comparing(x -> !x.equals(mainPileConnectorCode)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for (String pileConnectorCode : connectorCodeList) {
|
||||
// 获取枪口号
|
||||
String connectorCode = YKCUtils.getConnectorCode(pileConnectorCode);
|
||||
String gunCode = YKCUtils.getConnectorCode(pileConnectorCode);
|
||||
// 两把枪都要下发启动充电指令
|
||||
StartMergeChargeCommand command = StartMergeChargeCommand.builder()
|
||||
.pileSn(pileSn)
|
||||
.connectorCode(connectorCode)
|
||||
.connectorCode(gunCode)
|
||||
// .logicCardCode()
|
||||
.transactionCode(transactionCode)
|
||||
// .physicsCardCode()
|
||||
@@ -444,29 +454,38 @@ public class PileRemoteService {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
//获取百度IP地址
|
||||
try {
|
||||
System.out.println("www.baidu.com的地址: "+InetAddress.getByName("www.baidu.com").getHostAddress());
|
||||
} catch (UnknownHostException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
// //获取百度IP地址
|
||||
// try {
|
||||
// System.out.println("www.baidu.com的地址: "+InetAddress.getByName("www.baidu.com").getHostAddress());
|
||||
// } catch (UnknownHostException 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地址
|
||||
try {
|
||||
System.out.println("jsowell的地址: "+InetAddress.getByName("apitest.jsowellcloud.com").getHostAddress());
|
||||
} catch (UnknownHostException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
List<String> list = Lists.newArrayList("123", "321", "666", "789");
|
||||
String a = "789";
|
||||
|
||||
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);
|
||||
System.out.println("排序前 list: " + list);
|
||||
List<String> connectorCodeList = list.stream()
|
||||
.sorted(Comparator.comparing(x -> !x.equals(a)))
|
||||
.collect(Collectors.toList());
|
||||
System.out.println("排序后 list: " + connectorCodeList);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -662,11 +662,11 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
||||
orderInfo.setMainConnectorCode(pileConnectorCode);
|
||||
}
|
||||
updateOrderBasicInfo(orderInfo);
|
||||
// 判断是否要向小程序发送通知
|
||||
if (StringUtils.isNotEmpty(orderInfo.getMemberId())){
|
||||
// 发送小程序通知
|
||||
wxAppletRemoteService.startChargingSendMsg(orderInfo);
|
||||
}
|
||||
// // 判断是否要向小程序发送通知
|
||||
// if (StringUtils.isNotEmpty(orderInfo.getMemberId())){
|
||||
// // 发送小程序通知
|
||||
// wxAppletRemoteService.startChargingSendMsg(orderInfo);
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4283,7 +4283,7 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
||||
String orderType = orderInfo.getOrderType();
|
||||
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 {
|
||||
// 普通订单启动充电
|
||||
pileRemoteService.remoteStartCharging(pileSn, orderInfo.getConnectorCode(), orderInfo.getTransactionCode(), chargeAmount);
|
||||
|
||||
Reference in New Issue
Block a user