From ca57feebb2a691db5264881cc465c6205f4f7628 Mon Sep 17 00:00:00 2001 From: Lemon Date: Wed, 24 Jan 2024 17:30:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E5=8D=8E=E4=B8=BA=20?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E5=90=AF=E5=8A=A8=E5=85=85=E7=94=B5=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pile/dto/huawei/QueryStartChargeDTO.java | 64 ++++++++++++++++++ .../huawei/requestEquipBusinessPolicyDTO.java | 29 ++++++++ .../pile/vo/huawei/QueryStartChargeVO.java | 44 ++++++++++++ .../thirdparty/huawei/HuaweiServiceV2.java | 67 ++++++++++++++++++- 4 files changed, 202 insertions(+), 2 deletions(-) create mode 100644 jsowell-pile/src/main/java/com/jsowell/pile/dto/huawei/QueryStartChargeDTO.java create mode 100644 jsowell-pile/src/main/java/com/jsowell/pile/dto/huawei/requestEquipBusinessPolicyDTO.java create mode 100644 jsowell-pile/src/main/java/com/jsowell/pile/vo/huawei/QueryStartChargeVO.java diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/dto/huawei/QueryStartChargeDTO.java b/jsowell-pile/src/main/java/com/jsowell/pile/dto/huawei/QueryStartChargeDTO.java new file mode 100644 index 000000000..6cecb0772 --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/pile/dto/huawei/QueryStartChargeDTO.java @@ -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; +} diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/dto/huawei/requestEquipBusinessPolicyDTO.java b/jsowell-pile/src/main/java/com/jsowell/pile/dto/huawei/requestEquipBusinessPolicyDTO.java new file mode 100644 index 000000000..579448578 --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/pile/dto/huawei/requestEquipBusinessPolicyDTO.java @@ -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; + +} diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/vo/huawei/QueryStartChargeVO.java b/jsowell-pile/src/main/java/com/jsowell/pile/vo/huawei/QueryStartChargeVO.java new file mode 100644 index 000000000..b5a2bb1c1 --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/pile/vo/huawei/QueryStartChargeVO.java @@ -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; +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/huawei/HuaweiServiceV2.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/huawei/HuaweiServiceV2.java index f34dd4580..7fde92458 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/huawei/HuaweiServiceV2.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/huawei/HuaweiServiceV2.java @@ -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 requestEquipBusinessPolicy(QueryStartChargeDTO dto) { + public Map 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() { + + } + /** * 获取华为配置信息