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

@@ -22,7 +22,7 @@ public class HWStationInfo {
/**
* 充电站ID
*/
@JsonProperty(value = "StationId")
@JsonProperty(value = "StationID")
private String stationId;
/**

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);

View File

@@ -384,11 +384,10 @@ public class LianLianServiceImpl implements LianLianService {
public static void main(String[] args) throws UnsupportedEncodingException {
String dataSecret = "KnGhAb88GtUEPb0j"; // SPBNJ1Z5EQNmpK08 VTAEKDPVN9CUS7WO
String dataSecretIV = "XZ4wURhuo2y8s4ZS"; // peRoTcb2C7zqKeII 83UZFFRRZDYNF5CR
String dataSecret = "E6gnWuz0QzBW75CR"; // SPBNJ1Z5EQNmpK08 VTAEKDPVN9CUS7WO
String dataSecretIV = "SXejaSUx5yud8UHm"; // peRoTcb2C7zqKeII 83UZFFRRZDYNF5CR
String signSecret = "sRjCDeokckFGpYpA"; // sRjCDeokckFGpYpA
String dataString = "pZLkdIJdqGhgVcTEhSQXv3cbkBYiaI4Wk0SOKEaKbzMowLZ/Qvpy1ZeMZ+yEWhkHwn8oZwQhuIUMWxYmIXgnDNRcHU6sNW8LPbQOpB1qhfFS398c+sSU2rlv/I7kqsCJntM3Sn\n" +
"NV5SKdNtKX0gzFpsO0pl0ybHX3E6UyArdIqvhDmAbiw78/RwQRxGYsfk/cFW2PPhynTGc2ydZOb6TYFGgAh0RlHND17d3p5S4A3UJbM+mM4R4Nk2FeNJ7LESLfzDvt6RBUVOKlhl+yfzQypSSxj9X6GGAA4GZavmUUVXQwRe1fWsEqapYH2gL9mHPhg2+tNtVJlMju4iHhCftNFJBRsVpGfwJuvU0EUpo4cTm/YZ4bs5qAIC+SiLmKSmtPAL19GxPJ5hHGz2hNsCuL3rUc+cfYSfM0QKzZc6SwpikT2uwgPUy2Dq1T7POq95/4gsHu1ftW42MoG4exjtT/W74lUl3xibeLG+RqBSSWr8tDlRqQaTlz1GXYQcFG8vWREnBFuWz9NfNepN8ps0Xq7/Pzv7LHcTpAs0y1tWLo0GmYG6z32IOK9zqPd9DtAyBvW9bs5xhYVXkTzNN/g2RaGCpo3KDuq0uVRUIO0+1WVVdA6P/4jpTZ3Sc9GhtS4zYZ5YCTLbt0tEv8CUtodzmSdvbBMWUr0KGlS0lNq7ztAkJ+NprzC5Tvb4HG/pXVEwXz";
String dataString = "GZlmSIZOVzT+Yvpc2PmvNr2P2qkhe5aubvzxs/F8zMuiJdVOJZ8JkH8x1UbBloCETEcTrxb1F/VIeQqnMVE+9nDv5/mg3717jl9Tk6sHCBxfCH8lO9jisLF58YNcKzJB";
// 解密data
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());