mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
新增 华为 请求启动充电接口
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
package com.jsowell.pile.dto.huawei;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 华为请求启动充电DTO
|
||||
*
|
||||
* @author Lemon
|
||||
* @Date 2024/1/23 14:34:58
|
||||
*/
|
||||
@Data
|
||||
public class QueryStartChargeDTO {
|
||||
/**
|
||||
* 充电订单号 Y
|
||||
* 格式“运营商ID+唯一编号”(<=27字符)。
|
||||
*/
|
||||
@JsonProperty(value = "StartChargeSeq")
|
||||
private String startChargeSeq;
|
||||
|
||||
/**
|
||||
* 充电设备接口编码 Y
|
||||
*/
|
||||
@JsonProperty(value = "ConnectorID")
|
||||
private String connectorID;
|
||||
|
||||
/**
|
||||
* 二维码其他信息
|
||||
*/
|
||||
@JsonProperty(value = "QRCode")
|
||||
private String qrCode;
|
||||
|
||||
/**
|
||||
* 启动方式
|
||||
*
|
||||
* 0:扫码启动
|
||||
* 1:即插即充
|
||||
*/
|
||||
@JsonProperty(value = "Startmode")
|
||||
private Integer startMode;
|
||||
|
||||
/**
|
||||
* 预充电量限制
|
||||
* 单次可充电最大电量,达到充电电量后,自动停止充电,单位:度,小数点后2位;不填则不限制。
|
||||
*/
|
||||
@JsonProperty(value = "PowerLimit")
|
||||
private BigDecimal powerLimit;
|
||||
|
||||
/**
|
||||
* 预充电费限制
|
||||
* 单次可充电最大电费,达到充电费用后,自动停止充电,单位:元,小数点后2位;不填则不限制
|
||||
*/
|
||||
@JsonProperty(value = "MoneyLimit")
|
||||
private BigDecimal moneyLimit;
|
||||
|
||||
/**
|
||||
* 预充SOC限制
|
||||
* 单次可充电最大SOC,达到限制SOC后,自动停止充电;小数点后1位,不填则不限制。
|
||||
*/
|
||||
@JsonProperty(value = "SOCLimit")
|
||||
private BigDecimal socLimit;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.jsowell.pile.dto.huawei;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* @author Lemon
|
||||
* @Date 2024/1/23 15:32:25
|
||||
*/
|
||||
@Data
|
||||
public class requestEquipBusinessPolicyDTO {
|
||||
/**
|
||||
* 业务策略查询流水号
|
||||
*/
|
||||
@JsonProperty(value = "EquipBizSeq")
|
||||
private String equipBizSeq;
|
||||
|
||||
/**
|
||||
* 充电设备接口编码
|
||||
*/
|
||||
@JsonProperty(value = "ConnectorID")
|
||||
private String connectorID;
|
||||
|
||||
@JsonProperty(value = "OperatorID")
|
||||
private String operatorId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.jsowell.pile.vo.huawei;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 请求启动充电VO
|
||||
*
|
||||
* @author Lemon
|
||||
* @Date 2024/1/24 9:21:03
|
||||
*/
|
||||
@Data
|
||||
public class QueryStartChargeVO {
|
||||
|
||||
/**
|
||||
* 充电订单号
|
||||
*/
|
||||
@JsonProperty(value = "StartChargeSeq")
|
||||
private String startChargeSeq;
|
||||
|
||||
/**
|
||||
* 充电订单状态
|
||||
*/
|
||||
@JsonProperty(value = "StartChargeSeqStat")
|
||||
private Integer startChargeSeqStat;
|
||||
|
||||
/**
|
||||
* 充电设备接口编码
|
||||
*/
|
||||
@JsonProperty(value = "ConnectorID")
|
||||
private String connectorID;
|
||||
|
||||
/**
|
||||
* 操作结果
|
||||
*/
|
||||
@JsonProperty(value = "SuccStat")
|
||||
private Integer succStat;
|
||||
|
||||
/**
|
||||
* 失败原因
|
||||
*/
|
||||
@JsonProperty(value = "FailReason")
|
||||
private Integer failReason;
|
||||
}
|
||||
@@ -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() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取华为配置信息
|
||||
|
||||
Reference in New Issue
Block a user