update 华为平台充电设备编码同步接口

This commit is contained in:
Lemon
2024-03-11 09:18:40 +08:00
parent 86b45362d8
commit 3983438371
3 changed files with 54 additions and 12 deletions

View File

@@ -95,6 +95,9 @@ public class HuaweiServiceV2 {
@Autowired
private MemberPlateNumberRelationService memberPlateNumberRelationService;
@Autowired
private IThirdpartySnRelationService thirdpartySnRelationService;
@Resource
private TransactionService transactionService;
@@ -157,13 +160,14 @@ public class HuaweiServiceV2 {
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64((String) commonResult.getData()),
dataSecret.getBytes(), dataSecretIv.getBytes());
String dataStr = new String(plainText, StandardCharsets.UTF_8);
Map<String, String> resultMap = (Map<String, String>) JSON.parse(dataStr);
int succStat = Integer.parseInt(resultMap.get("SuccStat"));
// Map<String, Object> resultMap = (Map<String, Object>) JSON.parse(dataStr);
JSONObject resultJson = JSONObject.parseObject(dataStr);
int succStat = resultJson.getInteger("SuccStat");
if (succStat != 0) {
return resultMap.get("FailReason");
return resultJson.getString("FailReason");
}
String token = resultMap.get("AccessToken");
int tokenAvailableTime = Integer.parseInt(resultMap.get("TokenAvailableTime")); // 凭证有效期,单位秒
String token = resultJson.getString("AccessToken");
int tokenAvailableTime = resultJson.getInteger("TokenAvailableTime"); // 凭证有效期,单位秒
// 存入缓存
redisCache.setCacheObject(redisKey, token, tokenAvailableTime, TimeUnit.SECONDS);
return token;
@@ -202,7 +206,7 @@ public class HuaweiServiceV2 {
.build();
// 查询桩列表
equipmentLogicInfos = getPileList(stationId);
equipmentLogicInfos = getPileListV2(stationId);
hwStationInfo.setEquipmentInfoNum(equipmentLogicInfos.size());
hwStationInfo.setEquipmentLogicInfos(equipmentLogicInfos);
@@ -924,6 +928,42 @@ public class HuaweiServiceV2 {
return resultMap;
}
private List<HWStationInfo.EquipmentLogicInfo> getPileListV2(String stationId) {
List<HWStationInfo
.EquipmentLogicInfo> equipmentLogicInfos = new ArrayList<>();
HWStationInfo
.EquipmentLogicInfo equipmentLogicInfo = null;
// 根据站点 id 查询第三方平台对应 sn 关系表
ThirdpartySnRelation snRelation = ThirdpartySnRelation.builder()
.stationId(stationId)
.build();
List<ThirdpartySnRelation> snRelations = thirdpartySnRelationService.selectThirdpartySnRelationList(snRelation);
if (CollectionUtils.isEmpty(snRelations)) {
return new ArrayList<>();
}
for (ThirdpartySnRelation relation : snRelations) {
String pileSn = relation.getPileSn();
equipmentLogicInfo = HWStationInfo.EquipmentLogicInfo.builder()
.equipmentId(pileSn)
// .equipmentType()
.chargeHostESN(relation.getThirdpartyPileSn())
.build();
// 获取枪口信息
List<HWStationInfo.EquipmentLogicInfo
.ConnectorInfo> connectorInfoList = getConnectorInfoList(pileSn);
if (CollectionUtils.isEmpty(connectorInfoList)) {
continue;
}
equipmentLogicInfo.setConnectorInfoNum(connectorInfoList.size());
equipmentLogicInfo.setConnectorInfos(connectorInfoList);
equipmentLogicInfos.add(equipmentLogicInfo);
}
return equipmentLogicInfos;
}
/**
* 获取桩列表
* @param stationId
@@ -941,6 +981,7 @@ public class HuaweiServiceV2 {
}
for (PileBasicInfo pileBasicInfo : pileBasicInfos) {
String pileSn = pileBasicInfo.getSn();
equipmentLogicInfo = HWStationInfo.EquipmentLogicInfo.builder()
.equipmentId(pileSn)
// .equipmentType()
@@ -975,10 +1016,12 @@ public class HuaweiServiceV2 {
if (CollectionUtils.isEmpty(pileConnectorInfos)) {
return new ArrayList<>();
}
int connectorNumber = 0;
for (PileConnectorInfo pileConnectorInfo : pileConnectorInfos) {
connectorNumber += 1;
connectorInfo = HWStationInfo.EquipmentLogicInfo.ConnectorInfo.builder()
.connectorID(pileConnectorInfo.getPileConnectorCode())
.connectorNumber(pileConnectorInfo.getId())
.connectorNumber(connectorNumber)
.build();
connectorInfoList.add(connectorInfo);