新增 华为 请求启动充电接口

This commit is contained in:
Lemon
2024-01-24 17:30:27 +08:00
parent 0ba0fa3c43
commit ca57feebb2
4 changed files with 202 additions and 2 deletions

View File

@@ -13,11 +13,13 @@ import com.jsowell.common.util.id.IdUtils;
import com.jsowell.pile.domain.*;
import com.jsowell.pile.domain.huawei.HWStationInfo;
import com.jsowell.pile.dto.PushStationInfoDTO;
import com.jsowell.pile.dto.QueryStartChargeDTO;
import com.jsowell.pile.dto.huawei.DeliverEquipBusinessDTO;
import com.jsowell.pile.dto.huawei.QueryStartChargeDTO;
import com.jsowell.pile.dto.huawei.requestEquipBusinessPolicyDTO;
import com.jsowell.pile.service.*;
import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO;
import com.jsowell.pile.vo.huawei.QueryEquipAuthVO;
import com.jsowell.pile.vo.huawei.QueryStartChargeVO;
import com.jsowell.pile.vo.uniapp.BillingPriceVO;
import com.jsowell.pile.vo.web.PileStationVO;
import com.jsowell.thirdparty.lianlian.common.CommonResult;
@@ -325,7 +327,7 @@ public class HuaweiServiceV2 {
* @param dto
* @return
*/
public Map<String, String> requestEquipBusinessPolicy(QueryStartChargeDTO dto) {
public Map<String, String> requestEquipBusinessPolicy(requestEquipBusinessPolicyDTO dto) {
String pileConnectorCode = dto.getConnectorID();
String equipBizSeq = dto.getEquipBizSeq();
// 根据枪口号查询计费模板,并返回信息
@@ -490,6 +492,67 @@ public class HuaweiServiceV2 {
return result;
}
/**
* 请求启动充电
* 只需传枪口号、充电金额即可
* @param dto
* @return QueryStartChargeVO
*/
public QueryStartChargeVO queryStartCharge(QueryStartChargeDTO dto) {
String pileConnectorCode = dto.getConnectorID();
BigDecimal chargeAmount = dto.getMoneyLimit();
// 获取华为配置参数
ThirdPartySettingInfo settingInfo = getHuaWeiSettingInfo();
if (settingInfo == null) {
return null;
}
String operatorSecret = settingInfo.getOperatorSecret();
String dataSecret = settingInfo.getDataSecret();
String dataSecretIv = settingInfo.getDataSecretIv();
String signSecret = settingInfo.getSignSecret();
String urlAddress = settingInfo.getUrlAddress();
String requestUrl = urlAddress + "query_start_charge";
// 生成订单号
String orderCode = IdUtils.getOrderCode();
// 拼装参数
JSONObject jsonObject = new JSONObject();
jsonObject.put("StartChargeSeq", Constants.OPERATORID_JIANG_SU + "_C" + orderCode);
jsonObject.put("ConnectorID", pileConnectorCode);
jsonObject.put("MoneyLimit", chargeAmount);
// 加密
byte[] encryptText = Cryptos.aesEncrypt(jsonObject.toJSONString().getBytes(StandardCharsets.UTF_8),
dataSecret.getBytes(), dataSecretIv.getBytes());
String strData = Encodes.encodeBase64(encryptText);
// 向华为发送请求
String response = sendRequest2HuaWei(strData, signSecret, requestUrl);
CommonResult<?> commonResult = JSONObject.parseObject(response, CommonResult.class);
if (commonResult.getRet() != 0) {
log.error("解析华为请求启动充电接口result error:{}, ", commonResult.getMsg());
return null;
}
// 解密data
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64((String) commonResult.getData()),
dataSecret.getBytes(), dataSecretIv.getBytes());
String dataStr = new String(plainText, StandardCharsets.UTF_8);
// 转换成 QueryStartChargeVO 对象
QueryStartChargeVO vo = JSON.parseObject(dataStr, QueryStartChargeVO.class);
return vo;
}
/**
* 接收启动充电结果
*/
public void receiveStartChargeResult() {
}
/**
* 获取华为配置信息