From f08de6dd546d77ecd73552efa99f3f7d4c9b81b0 Mon Sep 17 00:00:00 2001 From: Lemon Date: Thu, 30 May 2024 09:38:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=20=20=E5=AE=81=E5=A4=8F?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0controller?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/thirdparty/NingXiaController.java | 60 +++++++++++++++++-- .../api/thirdparty/QingHaiController.java | 6 +- .../thirdparty/common/CommonService.java | 19 ++++++ .../service/ThirdPartyPlatformService.java | 9 +++ .../impl/ShenZhenPlatformServiceImpl.java | 59 ++++++++++++++++++ 5 files changed, 148 insertions(+), 5 deletions(-) diff --git a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/NingXiaController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/NingXiaController.java index 19cb2bb1b..064b210da 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/NingXiaController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/NingXiaController.java @@ -4,6 +4,8 @@ import com.alibaba.fastjson2.JSON; import com.jsowell.common.annotation.Anonymous; import com.jsowell.common.enums.thirdparty.ThirdPartyReturnCodeEnum; import com.jsowell.common.exception.BusinessException; +import com.jsowell.common.response.RestApiResponse; +import com.jsowell.pile.dto.PushRealTimeInfoDTO; import com.jsowell.pile.dto.QueryOperatorInfoDTO; import com.jsowell.pile.dto.QueryStationInfoDTO; import com.jsowell.pile.thirdparty.CommonParamsDTO; @@ -11,10 +13,7 @@ import com.jsowell.thirdparty.lianlian.common.CommonResult; import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import java.util.Map; @@ -156,4 +155,57 @@ public class NingXiaController extends ThirdPartyBaseController { } + /** + * 推送充电设备接口状态信息 + * @param dto + * @return + */ + @PostMapping("/v1/supervise_notification_station_status") + public RestApiResponse superviseNotificationStationStatus(@RequestBody PushRealTimeInfoDTO dto) { + RestApiResponse response = null; + try { + String result = platformLogic.notificationStationStatus(dto); + response = new RestApiResponse<>(result); + } catch (Exception e) { + logger.error("宁夏平台推送充电设备接口状态信息 error", e); + return new RestApiResponse<>(e); + } + return response; + } + + /** + * 推送充电状态信息 + * @param dto + * @return + */ + @GetMapping("/v1/supervise_notification_equip_charge_status/{orderCode}") + public RestApiResponse superviseNotificationEquipChargeStatus(@PathVariable("orderCode") String orderCode) { + RestApiResponse response = null; + try { + String result = platformLogic.notificationEquipChargeStatus(orderCode); + response = new RestApiResponse<>(result); + } catch (Exception e) { + logger.error("宁夏平台推送充电状态信息 error", e); + return new RestApiResponse<>(e); + } + return response; + } + + /** + * 推送充电站历史充电订单信息 + * @param orderCode + * @return + */ + @GetMapping("/v1/supervise_notification_equip_charge_status/{orderCode}") + public RestApiResponse notificationChargeOrderInfoHistory(@PathVariable("orderCode") String orderCode) { + RestApiResponse response = null; + try { + String result = platformLogic.notificationChargeOrderInfoHistory(orderCode); + response = new RestApiResponse<>(result); + } catch (Exception e) { + logger.error("宁夏平台推送充电站历史充电订单信息 error", e); + return new RestApiResponse<>(e); + } + return response; + } } diff --git a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/QingHaiController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/QingHaiController.java index fa77ee125..2e868342e 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/QingHaiController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/QingHaiController.java @@ -5,6 +5,7 @@ import com.alibaba.fastjson2.JSONObject; import com.jsowell.common.annotation.Anonymous; import com.jsowell.common.core.controller.BaseController; import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; +import com.jsowell.common.exception.BusinessException; import com.jsowell.common.response.RestApiResponse; import com.jsowell.common.util.JWTUtils; import com.jsowell.pile.domain.ThirdPartyPlatformConfig; @@ -56,8 +57,11 @@ public class QingHaiController extends BaseController { Map map = qingHaiPlatformServiceImpl.queryToken(dto); logger.info("青海平台请求令牌 result:{}", JSON.toJSONString(map)); return CommonResult.success(Integer.parseInt(map.get("Ret")), map.get("Msg"), map.get("Data"), map.get("Sig")); + }catch (BusinessException e) { + logger.error("青海平台请求令牌 error:{}, {}", e.getCode(), e.getMessage()); + return CommonResult.failed("获取token发生异常"); } catch (Exception e) { - logger.error("获取token接口 异常"); + logger.error("青海平台请求令牌接口 异常"); return CommonResult.failed("获取token发生异常"); } } 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 9de4ed5ee..0635cd483 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 @@ -35,6 +35,7 @@ import com.jsowell.thirdparty.huawei.HuaweiServiceV2; import com.jsowell.thirdparty.platform.service.impl.HaiNanPlatformServiceImpl; import com.jsowell.thirdparty.huawei.HuaWeiService; import com.jsowell.thirdparty.lianlian.service.LianLianService; +import com.jsowell.thirdparty.platform.service.impl.NinaXiaPlatformServiceImpl; import com.jsowell.thirdparty.platform.service.impl.QingHaiPlatformServiceImpl; import com.jsowell.thirdparty.platform.util.HttpRequestUtil; import com.jsowell.thirdparty.lutongyunting.service.LTYTService; @@ -116,6 +117,9 @@ public class CommonService { @Autowired private QingHaiPlatformServiceImpl qingHaiPlatformService; + @Autowired + private NinaXiaPlatformServiceImpl ninaXiaPlatformService; + @Autowired private RedisCache redisCache; @@ -366,6 +370,21 @@ public class CommonService { } } } + if (StringUtils.equals(ThirdPlatformTypeEnum.NING_XIA_PLATFORM.getTypeCode(), thirdPartyType)) { + // 宁夏平台 + dto.setThirdPartyType(ThirdPlatformTypeEnum.NING_XIA_PLATFORM.getTypeCode()); + String result = ninaXiaPlatformService.notificationStationStatus(dto); + log.info("宁夏平台推送充电设备接口状态信息 result:{}", result); + if (StringUtils.equals(connectorStatus, "03")) { + // 充电状态, 查出订单信息 + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByTransactionCode(transactionCode); + if (orderInfo == null) { + return; + } + String result2 = ninaXiaPlatformService.notificationEquipChargeStatus(orderInfo.getOrderCode()); + log.info("宁夏平台推送充电状态信息 result:{}", result2); + } + } } } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/ThirdPartyPlatformService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/ThirdPartyPlatformService.java index 5d93fe826..377a4479c 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/ThirdPartyPlatformService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/ThirdPartyPlatformService.java @@ -171,6 +171,15 @@ public interface ThirdPartyPlatformService extends InitializingBean { throw new UnsupportedOperationException("This method is not yet implemented"); } + /** + * 过程信息查询 query_bms_info + * @param pileConnectorCode + * @return + */ + default Map queryBmsInfo(String pileConnectorCode) { + throw new UnsupportedOperationException("This method is not yet implemented"); + } + /** * 查询业务策略信息结果 * 请求计费策略 request_equip_business_policy diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ShenZhenPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ShenZhenPlatformServiceImpl.java index 3cde69c7c..92470e090 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ShenZhenPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ShenZhenPlatformServiceImpl.java @@ -552,6 +552,65 @@ public class ShenZhenPlatformServiceImpl implements ThirdPartyPlatformService { return result; } + + @Override + public Map queryBmsInfo(String pileConnectorCode) { + JSONObject jsonObject = new JSONObject(); + // 根据枪口编号查询枪口信息 + PileConnectorInfoVO connectorInfoVO = pileConnectorInfoService.getPileConnectorInfoByConnectorCode(pileConnectorCode); + if (!StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_CHARGING.getValue(), String.valueOf(connectorInfoVO.getStatus()))) { + // 不为充电中, BmsInfo 为空 + jsonObject.put("BmsInfo", null); + }else { + // 充电中状态时,获取充电电池信息 + // 获取正在充电的订单信息 + List orderListVOS = orderBasicInfoService.selectChargingOrder(connectorInfoVO.getPileSn()); + if (CollectionUtils.isEmpty(orderListVOS)) { + return null; + } + OrderListVO orderVO = orderListVOS.get(0); + // 获取充电电池信息 + List chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(orderVO.getTransactionCode()); + if (CollectionUtils.isEmpty(chargingRealTimeData)) { + return null; + } + RealTimeMonitorData data = chargingRealTimeData.get(0); + BMSInfo bmsInfo = BMSInfo.builder() + .vinCode(orderVO.getVinCode()) + .bmsCode("") + .bmsVer("") + .connectorID(orderVO.getPileConnectorCode()) + .maxChargeCurrent(new BigDecimal("")) + .maxChargeCellVoltage(new BigDecimal("")) + .maxTemp(0) + .ratedCapacity(0) + .tatalVoltage(new BigDecimal(data.getOutputVoltage())) + .totalCurrent(new BigDecimal(data.getOutputCurrent())) + .soc(Integer.parseInt(data.getSOC())) + .voltageH(new BigDecimal("")) + .voltageHNumIndex(0) + .temptureH(0) + .temptureHNumIndex(0) + .temptureL(0) + .temptureLNumIndex(0) + .currentCapacity(new BigDecimal("")) + .freshTime(DateUtils.getDateTime()) + .startChargingTime(orderVO.getChargeStartTime()) + .chargingSessionMin(Integer.parseInt(data.getSumChargingTime()) * 60) + + .build(); + + jsonObject.put("BmsInfo", bmsInfo); + } + jsonObject.put("ConnectorID", pileConnectorCode); + jsonObject.put("Status", connectorInfoVO.getStatus()); + + ThirdPartySecretInfoVO shenZhenSecretInfo = getShenZhenSecretInfo(); + + Map map = ThirdPartyPlatformUtils.generateResultMap(jsonObject, shenZhenSecretInfo); + return map; + } + /** * 获取深圳平台相关密钥信息 * @return