From 04c5082fdc9909f37a2016c2707dffd567f503a7 Mon Sep 17 00:00:00 2001 From: Lemon Date: Wed, 20 Mar 2024 08:18:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=20=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E5=90=AF=E5=8A=A8=E5=85=85=E7=94=B5=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../thirdparty/common/CommonService.java | 61 +++++++++++++++++++ .../thirdparty/huawei/HuaweiServiceV2.java | 7 ++- 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/CommonService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/CommonService.java index a5ebcb9d2..565fda5c1 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/CommonService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/CommonService.java @@ -8,21 +8,28 @@ import com.jsowell.common.core.redis.RedisCache; import com.jsowell.common.enums.parkplatform.ParkingEnum; import com.jsowell.common.enums.thirdparty.BusinessInformationExchangeEnum; import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; +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.pile.domain.OrderBasicInfo; import com.jsowell.pile.domain.PileBasicInfo; import com.jsowell.pile.domain.ThirdPartyStationRelation; import com.jsowell.pile.domain.ThirdpartyParkingConfig; import com.jsowell.pile.dto.PushStationInfoDTO; +import com.jsowell.pile.dto.huawei.HWQueryStartChargeDTO; import com.jsowell.pile.dto.lutongyunting.BindCouponDTO; import com.jsowell.pile.dto.ruanjie.UseCouponDTO; import com.jsowell.pile.service.*; import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO; +import com.jsowell.pile.vo.huawei.QueryChargeStatusVO; +import com.jsowell.pile.vo.huawei.QueryEquipAuthVO; +import com.jsowell.pile.vo.huawei.QueryStartChargeVO; import com.jsowell.pile.vo.web.PileStationVO; +import com.jsowell.thirdparty.huawei.HuaweiServiceV2; import com.jsowell.thirdparty.platform.hainan.service.HaiNanPlatformLogic; import com.jsowell.thirdparty.huawei.HuaWeiService; import com.jsowell.thirdparty.lianlian.service.LianLianService; @@ -40,8 +47,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.io.UnsupportedEncodingException; +import java.math.BigDecimal; import java.text.ParseException; import java.util.List; +import java.util.Map; import java.util.concurrent.TimeUnit; /** @@ -93,6 +102,9 @@ public class CommonService { @Autowired private HuaWeiService huaWeiService; + @Autowired + private HuaweiServiceV2 huaweiServiceV2; + @Autowired private HaiNanPlatformLogic haiNanChargeService; @@ -486,6 +498,55 @@ public class CommonService { return null; } + /** + * 统一请求启动充电,目前给华为平台用 + * @param thirdPartyType + * @param stationIds + * @param pileConnectorCode + * @return + */ + public String commonQueryStartCharge(String thirdPartyType, List stationIds, String pileConnectorCode, BigDecimal chargeAmount) { + // 判断平台类型 + if (StringUtils.equals(ThirdPlatformTypeEnum.HUA_WEI.getCode(), thirdPartyType)) { + // 华为平台 + // query_station_status 查询站点枪口详情 + Map map = huaweiServiceV2.queryStationStatus(stationIds); + String status = map.get(pileConnectorCode); + // 判断枪口状态 + if (!StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_NOT_CHARGED.getValue(), status)) { + log.error(thirdPartyType + "判断枪口状态 error, 枪口状态为:{}", status); + } + // query_equip_auth 请求设备认证 + QueryEquipAuthVO vo = huaweiServiceV2.queryEquipAuth(pileConnectorCode); + Integer succStat = vo.getSuccStat(); + if (succStat != Constants.zero) { + log.error(thirdPartyType + "请求设备认证 error, {}", vo.getFailReason()); + } + // query_start_charge 请求启动充电 + HWQueryStartChargeDTO dto = new HWQueryStartChargeDTO(); + dto.setConnectorID(pileConnectorCode); + dto.setMoneyLimit(chargeAmount); + QueryStartChargeVO startChargeVO = huaweiServiceV2.queryStartCharge(dto); + if (startChargeVO.getSuccStat() != Constants.zero) { + log.error(thirdPartyType + "请求启动充电 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(); + } + } + + return null; + } + + + /** * 转换枪口状态 * @param connectorStatus 有电充平台枪口状态 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 6e8d4a6ba..6fdfae060 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 @@ -232,7 +232,8 @@ public class HuaweiServiceV2 { * @param stationIds * @return */ - public String queryStationStatus(List stationIds) { + public Map queryStationStatus(List stationIds) { + Map resultMap = new LinkedHashMap<>(); String requestName = "query_station_status"; // 拼装参数 @@ -263,9 +264,11 @@ public class HuaweiServiceV2 { String status = connectorStatusInfo.getStatus(); // 修改对应枪口状态 pileConnectorInfoService.updateConnectorStatus(connectorId, status); + // 将对应枪口的订单存入map + resultMap.put(connectorId, status); } } - return jsonStationStatus.toJSONString(); + return resultMap; }