mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
update 华为Service
This commit is contained in:
@@ -2,6 +2,7 @@ package com.jsowell.thirdparty.common;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
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.RealTimeMonitorData;
|
||||
@@ -508,47 +509,16 @@ public class CommonService {
|
||||
*/
|
||||
public String commonQueryStartCharge(ThirdPartyCommonStartChargeDTO dto) {
|
||||
String thirdPartyType = dto.getThirdPartyType();
|
||||
List<String> stationIds = dto.getStationIds();
|
||||
String pileConnectorCode = dto.getPileConnectorCode();
|
||||
BigDecimal chargeAmount = dto.getChargeAmount();
|
||||
String payMode = dto.getPayMode();
|
||||
// List<String> stationIds = dto.getStationIds();
|
||||
// String pileConnectorCode = dto.getPileConnectorCode();
|
||||
// BigDecimal chargeAmount = dto.getChargeAmount();
|
||||
// String payMode = dto.getPayMode();
|
||||
|
||||
// 判断平台类型
|
||||
if (StringUtils.equals(ThirdPlatformTypeEnum.HUA_WEI.getTypeCode(), thirdPartyType)) {
|
||||
// 华为平台
|
||||
String label = ThirdPlatformTypeEnum.getTypeLabelByTypeCode(thirdPartyType);
|
||||
// query_station_status 查询站点枪口详情
|
||||
Map<String, String> map = huaweiServiceV2.queryStationStatus(stationIds);
|
||||
String status = map.get(pileConnectorCode);
|
||||
// 判断枪口状态
|
||||
if (!StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_NOT_CHARGED.getValue(), status)) {
|
||||
log.error(label + "判断枪口状态 error, 枪口状态为:{}", status);
|
||||
}
|
||||
// query_equip_auth 请求设备认证
|
||||
QueryEquipAuthVO vo = huaweiServiceV2.queryEquipAuth(pileConnectorCode);
|
||||
Integer succStat = vo.getSuccStat();
|
||||
if (succStat != Constants.zero) {
|
||||
log.error(label + "请求设备认证 error, {}", vo.getFailReason());
|
||||
}
|
||||
// query_start_charge 请求启动充电
|
||||
HWQueryStartChargeDTO chargeDTO = new HWQueryStartChargeDTO();
|
||||
chargeDTO.setConnectorID(pileConnectorCode);
|
||||
chargeDTO.setMoneyLimit(chargeAmount);
|
||||
chargeDTO.setPayMode(payMode);
|
||||
QueryStartChargeVO startChargeVO = huaweiServiceV2.queryStartCharge(chargeDTO);
|
||||
if (startChargeVO.getSuccStat() != Constants.zero) {
|
||||
log.error(label + "请求启动充电 error, {}", startChargeVO.getFailReason());
|
||||
}
|
||||
String startChargeSeq = startChargeVO.getStartChargeSeq(); // 充电订单号
|
||||
|
||||
// 延时2s,查询充电状态
|
||||
Threads.sleep(2000);
|
||||
// query_equip_charge_status 查询设备充电状态
|
||||
QueryChargeStatusVO chargeStatusVO = huaweiServiceV2.queryChargeStatus(startChargeSeq);
|
||||
if (chargeStatusVO.getConnectorStatus() == 3) {
|
||||
// 充电中, 返回充电订单号
|
||||
return chargeStatusVO.getStartChargeSeq();
|
||||
}
|
||||
String result = huaweiServiceV2.startChargeFlow(dto);
|
||||
log.info("华为统一请求启动充电 result:{}", result);
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -595,4 +565,13 @@ public class CommonService {
|
||||
return connectorStatus;
|
||||
}
|
||||
}
|
||||
|
||||
public void commonQueryStationStatus(String stationId, String thirdPartyType) {
|
||||
if (StringUtils.equals(ThirdPlatformTypeEnum.HUA_WEI.getTypeCode(), thirdPartyType)) {
|
||||
// 华为平台
|
||||
Map<String, String> map = huaweiServiceV2.queryStationStatus(Lists.newArrayList(stationId));
|
||||
// key: pileConnectorCode,
|
||||
// value: status
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,17 +16,20 @@ import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
|
||||
import com.jsowell.common.enums.thirdparty.huawei.StartFailedReasonEnum;
|
||||
import com.jsowell.common.enums.thirdparty.huawei.StopFailedReasonEnum;
|
||||
import com.jsowell.common.enums.ykc.OrderStatusEnum;
|
||||
import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.enums.ykc.StartModeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.Threads;
|
||||
import com.jsowell.common.util.id.IdUtils;
|
||||
import com.jsowell.pile.domain.*;
|
||||
import com.jsowell.pile.domain.huawei.HWStationInfo;
|
||||
import com.jsowell.pile.domain.huawei.HWStationStatusInfo;
|
||||
import com.jsowell.pile.dto.GenerateOrderDTO;
|
||||
import com.jsowell.pile.dto.QueryStartChargeDTO;
|
||||
import com.jsowell.pile.dto.ThirdPartyCommonStartChargeDTO;
|
||||
import com.jsowell.pile.dto.huawei.*;
|
||||
import com.jsowell.pile.service.*;
|
||||
import com.jsowell.pile.service.programlogic.AbstractProgramLogic;
|
||||
@@ -654,6 +657,12 @@ public class HuaweiServiceV2 {
|
||||
if (orderBasicInfo == null) {
|
||||
return null;
|
||||
}
|
||||
String orderStatus = orderBasicInfo.getOrderStatus();
|
||||
if (!StringUtils.equals(OrderStatusEnum.IN_THE_CHARGING.getValue(), orderStatus)) {
|
||||
// 如果查出订单状态不为充电中,将订单改状态改为充电中
|
||||
orderBasicInfo.setOrderStatus(OrderStatusEnum.IN_THE_CHARGING.getValue());
|
||||
orderBasicInfoService.updateOrderBasicInfo(orderBasicInfo);
|
||||
}
|
||||
// 将源数据存储至缓存
|
||||
String redisKey = CacheConstants.HUA_WEI_REAL_TIME_INFO_BY_ORDER_CODE + startChargeSeq;
|
||||
String jsonMsg = JSON.toJSONString(dto);
|
||||
@@ -928,6 +937,65 @@ public class HuaweiServiceV2 {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 华为启动充电流程(用于 CommonService)
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public String startChargeFlow(ThirdPartyCommonStartChargeDTO dto) {
|
||||
String thirdPartyType = dto.getThirdPartyType();
|
||||
List<String> stationIds = dto.getStationIds();
|
||||
String pileConnectorCode = dto.getPileConnectorCode();
|
||||
BigDecimal chargeAmount = dto.getChargeAmount();
|
||||
String payMode = dto.getPayMode();
|
||||
|
||||
String label = ThirdPlatformTypeEnum.getTypeLabelByTypeCode(thirdPartyType);
|
||||
// query_station_status 查询站点枪口详情
|
||||
Map<String, String> map = queryStationStatus(stationIds);
|
||||
String status = map.get(pileConnectorCode);
|
||||
// 判断枪口状态
|
||||
if (!StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_NOT_CHARGED.getValue(), status)) {
|
||||
log.error(label + "判断枪口状态 error, 枪口状态为:{}", status);
|
||||
}
|
||||
// query_equip_auth 请求设备认证
|
||||
QueryEquipAuthVO vo = queryEquipAuth(pileConnectorCode);
|
||||
Integer succStat = vo.getSuccStat();
|
||||
if (succStat != Constants.zero) {
|
||||
log.error(label + "请求设备认证 error, {}", vo.getFailReason());
|
||||
}
|
||||
// query_start_charge 请求启动充电
|
||||
HWQueryStartChargeDTO chargeDTO = new HWQueryStartChargeDTO();
|
||||
chargeDTO.setConnectorID(pileConnectorCode);
|
||||
chargeDTO.setMoneyLimit(chargeAmount);
|
||||
chargeDTO.setPayMode(payMode);
|
||||
QueryStartChargeVO startChargeVO = queryStartCharge(chargeDTO);
|
||||
if (startChargeVO.getSuccStat() != Constants.zero) {
|
||||
log.error(label + "请求启动充电 error, {}", startChargeVO.getFailReason());
|
||||
}
|
||||
String startChargeSeq = startChargeVO.getStartChargeSeq(); // 充电订单号
|
||||
|
||||
// Threads.sleep(5000);
|
||||
// query_equip_charge_status 查询设备充电状态
|
||||
QueryChargeStatusVO chargeStatusVO = new QueryChargeStatusVO();
|
||||
for (int i = 1; i <= 3; i ++) {
|
||||
// 循环 3 次,每次延时5s,查询充电状态
|
||||
Threads.sleep(5000);
|
||||
chargeStatusVO = queryChargeStatus(startChargeSeq);
|
||||
if (chargeStatusVO != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (chargeStatusVO == null) {
|
||||
return null;
|
||||
}
|
||||
if (chargeStatusVO.getConnectorStatus() == 3) {
|
||||
// 充电中, 返回充电订单号
|
||||
return chargeStatusVO.getStartChargeSeq();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取华为配置信息
|
||||
* @return
|
||||
|
||||
@@ -379,10 +379,10 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
|
||||
|
||||
public static void main(String[] args) throws UnsupportedEncodingException {
|
||||
String dataSecret = "pJahbxk8wG79CMDB"; // SPBNJ1Z5EQNmpK08 VTAEKDPVN9CUS7WO huawei: zd4NrLWJ38XCTaqP E6gnWuz0QzBW75CR 正式:NHsBDtTanA60vTIu pJahbxk8wG79CMDB
|
||||
String dataSecretIV = "y259VRq7h8RyFXmT"; // peRoTcb2C7zqKeII 83UZFFRRZDYNF5CR huawei: RJJecvNTJ48SGMG7 SXejaSUx5yud8UHm 正式:2uyE2Cgu4nVf6egc y259VRq7h8RyFXmT
|
||||
String dataSecret = "E6gnWuz0QzBW75CR"; // SPBNJ1Z5EQNmpK08 VTAEKDPVN9CUS7WO huawei: zd4NrLWJ38XCTaqP E6gnWuz0QzBW75CR 正式:NHsBDtTanA60vTIu pJahbxk8wG79CMDB
|
||||
String dataSecretIV = "SXejaSUx5yud8UHm"; // peRoTcb2C7zqKeII 83UZFFRRZDYNF5CR huawei: RJJecvNTJ48SGMG7 SXejaSUx5yud8UHm 正式:2uyE2Cgu4nVf6egc y259VRq7h8RyFXmT
|
||||
String signSecret = "sRjCDeokckFGpYpA"; // sRjCDeokckFGpYpA
|
||||
String dataString = "ESOi5BHD3GIr3bEN8VTQsvSyj6P8nICQF0+sk8pqaGJ/z9Y4bJK+UPLBYNZze7De5GKDsVcM/V8rfx3DG+yDqLkpq4vSNm6LFzpk/U6WQF1Z7n+8NrqTDCEtFTYmiF7qhZPng550UpLg3rU6G9CXQw==";
|
||||
String dataString = "iW1cm5Ktq70YeNayo1+R3UVzsqFK2AN9C7xDbKmdhrLQivIVtbR30Ct6VxpBrXSkDbgtyX7jxPxsnhrE+X2uxw==";
|
||||
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||
|
||||
Reference in New Issue
Block a user