From 4a1b1df21b0b3549d00c49ff6772b5896523862a Mon Sep 17 00:00:00 2001 From: Guoqs <123@jsowell.com> Date: Fri, 10 May 2024 15:46:01 +0800 Subject: [PATCH 1/7] =?UTF-8?q?update=20=E6=8E=A5=E5=8F=A3=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DianXingPlatformController.java | 2 +- .../thirdparty/HaiNanPlatformController.java | 2 +- .../api/thirdparty/LianLianController.java | 2 +- .../jsowell/api/thirdparty/NMGController.java | 2 +- .../api/thirdparty/NingXiaController.java | 22 +++++++++++++++++++ .../api/thirdparty/QingHaiController.java | 2 +- .../thirdparty/ThirdPlatformTypeEnum.java | 1 + .../thirdparty/common/CommonService.java | 4 ++-- .../common/NotificationService.java | 2 +- .../domain/ChargeOrderInfo.java | 2 +- .../{hainan => }/domain/HNStationInfo.java | 2 +- .../domain/SupChargeDetails.java | 2 +- .../domain/SupConnectorStatusInfo.java | 2 +- .../domain/SupOperatorInfo.java | 2 +- .../domain/SupStationInfo.java | 2 +- .../domain/SupStationStatusInfo.java | 2 +- .../factory/ThirdPartyPlatformFactory.java | 2 +- .../ThirdPartyPlatformService.java | 2 +- .../impl}/DianXingPlatformServiceImpl.java | 6 ++--- .../impl}/HaiNanPlatformServiceImpl.java | 7 +++--- .../impl}/LianLianPlatformServiceImpl.java | 4 ++-- .../impl}/NeiMengGuPlatformServiceImpl.java | 7 +++--- .../impl/NinaXiaPlatformServiceImpl.java | 17 ++++++++++++++ .../impl}/QingHaiPlatformServiceImpl.java | 6 ++--- .../ZhongDianLianPlatformServiceImpl.java | 4 ++-- 25 files changed, 72 insertions(+), 36 deletions(-) create mode 100644 jsowell-admin/src/main/java/com/jsowell/api/thirdparty/NingXiaController.java rename jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/{neimenggu => }/domain/ChargeOrderInfo.java (99%) rename jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/{hainan => }/domain/HNStationInfo.java (91%) rename jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/{neimenggu => }/domain/SupChargeDetails.java (97%) rename jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/{neimenggu => }/domain/SupConnectorStatusInfo.java (97%) rename jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/{neimenggu => }/domain/SupOperatorInfo.java (96%) rename jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/{neimenggu => }/domain/SupStationInfo.java (94%) rename jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/{neimenggu => }/domain/SupStationStatusInfo.java (94%) rename jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/{ => service}/ThirdPartyPlatformService.java (99%) rename jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/{ningbodianxing/service => service/impl}/DianXingPlatformServiceImpl.java (94%) rename jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/{hainan/service => service/impl}/HaiNanPlatformServiceImpl.java (99%) rename jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/{lianlian/service => service/impl}/LianLianPlatformServiceImpl.java (99%) rename jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/{neimenggu/service => service/impl}/NeiMengGuPlatformServiceImpl.java (99%) create mode 100644 jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NinaXiaPlatformServiceImpl.java rename jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/{qinghai/service => service/impl}/QingHaiPlatformServiceImpl.java (99%) rename jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/{zhongdianlian/service => service/impl}/ZhongDianLianPlatformServiceImpl.java (96%) diff --git a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/DianXingPlatformController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/DianXingPlatformController.java index 8ecef2458..2c765664d 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/DianXingPlatformController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/DianXingPlatformController.java @@ -4,7 +4,7 @@ import com.jsowell.common.annotation.Anonymous; import com.jsowell.common.core.controller.BaseController; import com.jsowell.common.exception.BusinessException; import com.jsowell.common.response.RestApiResponse; -import com.jsowell.thirdparty.platform.ThirdPartyPlatformService; +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.*; diff --git a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/HaiNanPlatformController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/HaiNanPlatformController.java index dc1bc5747..6d51aa757 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/HaiNanPlatformController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/HaiNanPlatformController.java @@ -18,7 +18,7 @@ import com.jsowell.pile.thirdparty.CommonParamsDTO; import com.jsowell.thirdparty.lianlian.common.CommonResult; import com.jsowell.thirdparty.platform.util.Cryptos; import com.jsowell.thirdparty.platform.util.Encodes; -import com.jsowell.thirdparty.platform.ThirdPartyPlatformService; +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.*; diff --git a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/LianLianController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/LianLianController.java index 160c538d8..32abf31a8 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/LianLianController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/LianLianController.java @@ -11,7 +11,7 @@ import com.jsowell.common.util.StringUtils; import com.jsowell.pile.dto.*; import com.jsowell.pile.thirdparty.CommonParamsDTO; import com.jsowell.thirdparty.lianlian.common.CommonResult; -import com.jsowell.thirdparty.platform.ThirdPartyPlatformService; +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.*; diff --git a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/NMGController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/NMGController.java index dbf2414d3..a63567cb2 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/NMGController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/NMGController.java @@ -8,7 +8,7 @@ import com.jsowell.pile.dto.QueryOperatorInfoDTO; import com.jsowell.pile.dto.QueryStationInfoDTO; import com.jsowell.pile.thirdparty.CommonParamsDTO; import com.jsowell.thirdparty.lianlian.common.CommonResult; -import com.jsowell.thirdparty.platform.ThirdPartyPlatformService; +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; 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 new file mode 100644 index 000000000..464479ece --- /dev/null +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/NingXiaController.java @@ -0,0 +1,22 @@ +package com.jsowell.api.thirdparty; + +import com.jsowell.common.annotation.Anonymous; +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.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 宁夏平台Controller + */ +@Anonymous +@RestController +@RequestMapping("/ningxia") +public class NingXiaController extends ThirdPartyBaseController { + @Autowired + @Qualifier("ninaXiaPlatformServiceImpl") + private ThirdPartyPlatformService lianLianService; + + +} 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 bbc623ca9..fa77ee125 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 @@ -14,7 +14,7 @@ import com.jsowell.pile.dto.QueryStationInfoDTO; import com.jsowell.pile.service.ThirdPartyPlatformConfigService; import com.jsowell.pile.thirdparty.CommonParamsDTO; import com.jsowell.thirdparty.lianlian.common.CommonResult; -import com.jsowell.thirdparty.platform.ThirdPartyPlatformService; +import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; import com.jsowell.thirdparty.platform.util.Cryptos; import com.jsowell.thirdparty.platform.util.Encodes; import org.springframework.beans.factory.annotation.Autowired; diff --git a/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java b/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java index 08830269b..47a996818 100644 --- a/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java +++ b/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java @@ -21,6 +21,7 @@ public enum ThirdPlatformTypeEnum { NEI_MENG_GU_PLATFORM("10", "内蒙古平台", ""), QING_HAI_PLATFORM("11", "青海平台", "630000000"), DIAN_XING_PLATFORM("12", "宁波点行停车平台", ""), + NING_XIA_PLATFORM("13", "宁夏平台", ""), ; private String typeCode; 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 39ae0e712..19661b09b 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 @@ -31,10 +31,10 @@ import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO; 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.HaiNanPlatformServiceImpl; +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.qinghai.service.QingHaiPlatformServiceImpl; +import com.jsowell.thirdparty.platform.service.impl.QingHaiPlatformServiceImpl; import com.jsowell.thirdparty.platform.util.HttpRequestUtil; import com.jsowell.thirdparty.lutongyunting.service.LTYTService; import com.jsowell.thirdparty.nanrui.service.NRService; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/NotificationService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/NotificationService.java index fa45af6f3..91a6e9b17 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/NotificationService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/NotificationService.java @@ -4,7 +4,7 @@ import com.jsowell.common.enums.ykc.ReturnCodeEnum; import com.jsowell.common.exception.BusinessException; import com.jsowell.common.util.StringUtils; import com.jsowell.pile.vo.ThirdPartySecretInfoVO; -import com.jsowell.thirdparty.platform.ThirdPartyPlatformService; +import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory; import com.jsowell.thirdparty.service.ThirdpartySecretInfoService; import org.apache.commons.collections4.CollectionUtils; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/domain/ChargeOrderInfo.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/ChargeOrderInfo.java similarity index 99% rename from jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/domain/ChargeOrderInfo.java rename to jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/ChargeOrderInfo.java index 110db629b..19bad914e 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/domain/ChargeOrderInfo.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/ChargeOrderInfo.java @@ -1,4 +1,4 @@ -package com.jsowell.thirdparty.platform.neimenggu.domain; +package com.jsowell.thirdparty.platform.domain; import com.alibaba.fastjson2.annotation.JSONField; import lombok.*; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/hainan/domain/HNStationInfo.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/HNStationInfo.java similarity index 91% rename from jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/hainan/domain/HNStationInfo.java rename to jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/HNStationInfo.java index 08972d399..c56fcce34 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/hainan/domain/HNStationInfo.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/HNStationInfo.java @@ -1,4 +1,4 @@ -package com.jsowell.thirdparty.platform.hainan.domain; +package com.jsowell.thirdparty.platform.domain; import com.alibaba.fastjson2.annotation.JSONField; import com.jsowell.pile.thirdparty.ZDLStationInfo; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/domain/SupChargeDetails.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupChargeDetails.java similarity index 97% rename from jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/domain/SupChargeDetails.java rename to jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupChargeDetails.java index ae0460750..cbaed5c53 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/domain/SupChargeDetails.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupChargeDetails.java @@ -1,4 +1,4 @@ -package com.jsowell.thirdparty.platform.neimenggu.domain; +package com.jsowell.thirdparty.platform.domain; import com.alibaba.fastjson2.annotation.JSONField; import lombok.Getter; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/domain/SupConnectorStatusInfo.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupConnectorStatusInfo.java similarity index 97% rename from jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/domain/SupConnectorStatusInfo.java rename to jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupConnectorStatusInfo.java index ae39121c5..cd194aa0f 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/domain/SupConnectorStatusInfo.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupConnectorStatusInfo.java @@ -1,4 +1,4 @@ -package com.jsowell.thirdparty.platform.neimenggu.domain; +package com.jsowell.thirdparty.platform.domain; import com.alibaba.fastjson2.annotation.JSONField; import lombok.*; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/domain/SupOperatorInfo.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupOperatorInfo.java similarity index 96% rename from jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/domain/SupOperatorInfo.java rename to jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupOperatorInfo.java index ffd7dc30e..73899db93 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/domain/SupOperatorInfo.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupOperatorInfo.java @@ -1,4 +1,4 @@ -package com.jsowell.thirdparty.platform.neimenggu.domain; +package com.jsowell.thirdparty.platform.domain; import com.alibaba.fastjson2.annotation.JSONField; import lombok.*; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/domain/SupStationInfo.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupStationInfo.java similarity index 94% rename from jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/domain/SupStationInfo.java rename to jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupStationInfo.java index 42d447217..73711e08b 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/domain/SupStationInfo.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupStationInfo.java @@ -1,4 +1,4 @@ -package com.jsowell.thirdparty.platform.neimenggu.domain; +package com.jsowell.thirdparty.platform.domain; import com.alibaba.fastjson2.annotation.JSONField; import com.jsowell.thirdparty.platform.common.StationInfo; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/domain/SupStationStatusInfo.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupStationStatusInfo.java similarity index 94% rename from jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/domain/SupStationStatusInfo.java rename to jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupStationStatusInfo.java index a8f50fa2d..3eb65bc3d 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/domain/SupStationStatusInfo.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupStationStatusInfo.java @@ -1,4 +1,4 @@ -package com.jsowell.thirdparty.platform.neimenggu.domain; +package com.jsowell.thirdparty.platform.domain; import com.alibaba.fastjson2.annotation.JSONField; import lombok.*; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/factory/ThirdPartyPlatformFactory.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/factory/ThirdPartyPlatformFactory.java index 6e718185a..54051eca2 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/factory/ThirdPartyPlatformFactory.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/factory/ThirdPartyPlatformFactory.java @@ -2,7 +2,7 @@ package com.jsowell.thirdparty.platform.factory; import com.google.common.collect.Maps; import com.jsowell.common.util.StringUtils; -import com.jsowell.thirdparty.platform.ThirdPartyPlatformService; +import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; import java.util.Map; import java.util.Objects; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/ThirdPartyPlatformService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/ThirdPartyPlatformService.java similarity index 99% rename from jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/ThirdPartyPlatformService.java rename to jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/ThirdPartyPlatformService.java index 664f23c09..497f816f3 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/ThirdPartyPlatformService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/ThirdPartyPlatformService.java @@ -1,4 +1,4 @@ -package com.jsowell.thirdparty.platform; +package com.jsowell.thirdparty.platform.service; import cn.hutool.http.HttpUtil; import cn.hutool.json.JSONUtil; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/ningbodianxing/service/DianXingPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/DianXingPlatformServiceImpl.java similarity index 94% rename from jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/ningbodianxing/service/DianXingPlatformServiceImpl.java rename to jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/DianXingPlatformServiceImpl.java index d796e235f..b33efba1d 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/ningbodianxing/service/DianXingPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/DianXingPlatformServiceImpl.java @@ -1,8 +1,6 @@ -package com.jsowell.thirdparty.platform.ningbodianxing.service; +package com.jsowell.thirdparty.platform.service.impl; -import cn.hutool.http.HttpUtil; import com.alibaba.fastjson2.JSONObject; -import com.jsowell.common.enums.thirdparty.BusinessInformationExchangeEnum; import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; import com.jsowell.common.exception.BusinessException; import com.jsowell.common.util.DateUtils; @@ -11,7 +9,7 @@ import com.jsowell.common.util.http.HttpUtils; import com.jsowell.pile.domain.OrderBasicInfo; import com.jsowell.pile.service.OrderBasicInfoService; import com.jsowell.pile.vo.ThirdPartySecretInfoVO; -import com.jsowell.thirdparty.platform.ThirdPartyPlatformService; +import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory; import com.jsowell.thirdparty.service.ThirdpartySecretInfoService; import org.bouncycastle.crypto.CryptoException; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/hainan/service/HaiNanPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/HaiNanPlatformServiceImpl.java similarity index 99% rename from jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/hainan/service/HaiNanPlatformServiceImpl.java rename to jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/HaiNanPlatformServiceImpl.java index 59f526988..7b82d36a9 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/hainan/service/HaiNanPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/HaiNanPlatformServiceImpl.java @@ -1,4 +1,4 @@ -package com.jsowell.thirdparty.platform.hainan.service; +package com.jsowell.thirdparty.platform.service.impl; import cn.hutool.core.util.PageUtil; import com.alibaba.fastjson2.JSON; @@ -37,9 +37,9 @@ import com.jsowell.thirdparty.lianlian.vo.EquipmentAuthVO; import com.jsowell.thirdparty.lianlian.vo.QueryChargingStatusVO; import com.jsowell.thirdparty.lianlian.vo.QueryStartChargeVO; import com.jsowell.thirdparty.lianlian.vo.QueryStopChargeVO; -import com.jsowell.thirdparty.platform.ThirdPartyPlatformService; +import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory; -import com.jsowell.thirdparty.platform.hainan.domain.HNStationInfo; +import com.jsowell.thirdparty.platform.domain.HNStationInfo; import com.jsowell.thirdparty.platform.util.Cryptos; import com.jsowell.thirdparty.platform.util.Encodes; import com.jsowell.thirdparty.platform.util.GBSignUtils; @@ -48,7 +48,6 @@ import com.jsowell.thirdparty.zhongdianlian.service.ZDLService; import org.apache.commons.collections4.CollectionUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/lianlian/service/LianLianPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/LianLianPlatformServiceImpl.java similarity index 99% rename from jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/lianlian/service/LianLianPlatformServiceImpl.java rename to jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/LianLianPlatformServiceImpl.java index 58886eba8..f1df0fb4b 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/lianlian/service/LianLianPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/LianLianPlatformServiceImpl.java @@ -1,4 +1,4 @@ -package com.jsowell.thirdparty.platform.lianlian.service; +package com.jsowell.thirdparty.platform.service.impl; import cn.hutool.core.util.PageUtil; import com.alibaba.fastjson2.JSON; @@ -37,7 +37,7 @@ import com.jsowell.pile.vo.web.PileConnectorInfoVO; import com.jsowell.pile.vo.web.PileStationVO; import com.jsowell.thirdparty.lianlian.domain.*; import com.jsowell.thirdparty.lianlian.vo.*; -import com.jsowell.thirdparty.platform.ThirdPartyPlatformService; +import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; import com.jsowell.thirdparty.platform.common.ChargeDetail; import com.jsowell.thirdparty.platform.common.OrderInfo; import com.jsowell.thirdparty.platform.common.StationInfo; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/service/NeiMengGuPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NeiMengGuPlatformServiceImpl.java similarity index 99% rename from jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/service/NeiMengGuPlatformServiceImpl.java rename to jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NeiMengGuPlatformServiceImpl.java index 00e748a74..69bea368a 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/service/NeiMengGuPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NeiMengGuPlatformServiceImpl.java @@ -1,4 +1,4 @@ -package com.jsowell.thirdparty.platform.neimenggu.service; +package com.jsowell.thirdparty.platform.service.impl; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; @@ -44,9 +44,10 @@ import com.jsowell.thirdparty.lianlian.domain.ConnectorStatusInfo; import com.jsowell.thirdparty.lianlian.domain.StationStatusInfo; import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO; import com.jsowell.thirdparty.lianlian.vo.QueryChargingStatusVO; -import com.jsowell.thirdparty.platform.ThirdPartyPlatformService; +import com.jsowell.thirdparty.platform.domain.*; +import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory; -import com.jsowell.thirdparty.platform.neimenggu.domain.*; + import com.jsowell.thirdparty.platform.util.Cryptos; import com.jsowell.thirdparty.platform.util.Encodes; import com.jsowell.thirdparty.platform.util.HttpRequestUtil; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NinaXiaPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NinaXiaPlatformServiceImpl.java new file mode 100644 index 000000000..0ee6af557 --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NinaXiaPlatformServiceImpl.java @@ -0,0 +1,17 @@ +package com.jsowell.thirdparty.platform.service.impl; + +import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; +import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; +import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory; +import org.springframework.stereotype.Service; + +@Service +public class NinaXiaPlatformServiceImpl implements ThirdPartyPlatformService { + // 平台类型 + private final String thirdPlatformType = ThirdPlatformTypeEnum.NING_XIA_PLATFORM.getTypeCode(); + + @Override + public void afterPropertiesSet() throws Exception { + ThirdPartyPlatformFactory.register(thirdPlatformType, this); + } +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/qinghai/service/QingHaiPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/QingHaiPlatformServiceImpl.java similarity index 99% rename from jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/qinghai/service/QingHaiPlatformServiceImpl.java rename to jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/QingHaiPlatformServiceImpl.java index 5098b9b6e..f25f53203 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/qinghai/service/QingHaiPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/QingHaiPlatformServiceImpl.java @@ -1,4 +1,4 @@ -package com.jsowell.thirdparty.platform.qinghai.service; +package com.jsowell.thirdparty.platform.service.impl; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; @@ -24,7 +24,6 @@ import com.jsowell.pile.service.*; import com.jsowell.pile.thirdparty.CommonParamsDTO; import com.jsowell.pile.thirdparty.ZDLEquipmentInfo; import com.jsowell.pile.thirdparty.ZDLStationInfo; -import com.jsowell.pile.vo.ThirdPartySecretInfoVO; import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO; import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO; import com.jsowell.pile.vo.uniapp.BillingPriceVO; @@ -34,7 +33,7 @@ import com.jsowell.pile.vo.web.PileMerchantInfoVO; import com.jsowell.pile.vo.zdl.EquipBusinessPolicyVO; import com.jsowell.thirdparty.lianlian.domain.ConnectorStatusInfo; import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO; -import com.jsowell.thirdparty.platform.ThirdPartyPlatformService; +import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; import com.jsowell.thirdparty.platform.common.ChargeOrderInfo; import com.jsowell.thirdparty.platform.common.ConnectorChargeStatusInfo; import com.jsowell.thirdparty.platform.common.SupStationPowerInfo; @@ -51,7 +50,6 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; -import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; import java.util.Map; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/zhongdianlian/service/ZhongDianLianPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ZhongDianLianPlatformServiceImpl.java similarity index 96% rename from jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/zhongdianlian/service/ZhongDianLianPlatformServiceImpl.java rename to jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ZhongDianLianPlatformServiceImpl.java index acbe61dc3..f7a000daa 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/zhongdianlian/service/ZhongDianLianPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ZhongDianLianPlatformServiceImpl.java @@ -1,4 +1,4 @@ -package com.jsowell.thirdparty.platform.zhongdianlian.service; +package com.jsowell.thirdparty.platform.service.impl; import com.alibaba.fastjson2.JSON; import com.google.common.collect.Lists; @@ -9,7 +9,7 @@ import com.jsowell.pile.service.ThirdPartyPlatformConfigService; import com.jsowell.pile.thirdparty.CommonParamsDTO; import com.jsowell.pile.vo.ThirdPartySecretInfoVO; import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO; -import com.jsowell.thirdparty.platform.ThirdPartyPlatformService; +import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory; import com.jsowell.thirdparty.platform.util.Cryptos; import com.jsowell.thirdparty.platform.util.ThirdPartyPlatformUtils; From bfd25e28b649e739fdc8628ff84f5affda3ebf38 Mon Sep 17 00:00:00 2001 From: Guoqs <123@jsowell.com> Date: Fri, 10 May 2024 16:05:35 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/thirdparty/LianLianController.java | 154 ++-- ...ntroller.java => NeiMengGuController.java} | 31 +- .../api/thirdparty/NingXiaController.java | 139 +++- .../impl/NeiMengGuPlatformServiceImpl.java | 1 - .../impl/NinaXiaPlatformServiceImpl.java | 766 ++++++++++++++++++ 5 files changed, 1000 insertions(+), 91 deletions(-) rename jsowell-admin/src/main/java/com/jsowell/api/thirdparty/{NMGController.java => NeiMengGuController.java} (82%) diff --git a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/LianLianController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/LianLianController.java index 32abf31a8..83fe442ba 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/LianLianController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/LianLianController.java @@ -30,9 +30,11 @@ import java.util.Map; @RequestMapping("/LianLian") public class LianLianController extends ThirdPartyBaseController { + private final String platformName = "联联平台"; + @Autowired @Qualifier("lianLianPlatformServiceImpl") - private ThirdPartyPlatformService lianLianService; + private ThirdPartyPlatformService platformLogic; /** * 获取token接口 @@ -40,13 +42,13 @@ public class LianLianController extends ThirdPartyBaseController { */ @PostMapping("/v1/query_token") public CommonResult queryToken(@RequestBody CommonParamsDTO dto) { - logger.info("联联平台请求令牌 params:{}", JSON.toJSONString(dto)); + logger.info("{}-获取token接口params:{}", platformName, JSON.toJSONString(dto)); try { - Map map = lianLianService.queryToken(dto); - logger.info("联联平台请求令牌 result:{}", JSON.toJSONString(map)); + Map map = platformLogic.queryToken(dto); + logger.info("{}-获取token接口result:{}", platformName, JSON.toJSONString(map)); return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig")); } catch (Exception e) { - logger.error("获取token接口 异常"); + logger.error("{}-获取token接口异常", platformName); return CommonResult.failed("获取token发生异常"); } } @@ -54,12 +56,13 @@ public class LianLianController extends ThirdPartyBaseController { /** * 联联平台查询充电站信息 * http://localhost:8080/LianLian/v1/query_stations_info + * * @param dto * @return */ @PostMapping("/v1/query_stations_info") public CommonResult query_stations_info(HttpServletRequest request, @RequestBody CommonParamsDTO dto) { - logger.info("联联平台查询充电站信息 params:{}", JSON.toJSONString(dto)); + logger.info("{}-查询充电站信息 params:{}", platformName, JSON.toJSONString(dto)); try { // 校验令牌 if (!verifyToken(request.getHeader("Authorization"))) { @@ -77,12 +80,11 @@ public class LianLianController extends ThirdPartyBaseController { QueryStationInfoDTO queryStationInfoDTO = parseParamsDTO(dto, QueryStationInfoDTO.class); // 执行逻辑 - Map map = lianLianService.queryStationsInfo(queryStationInfoDTO); + Map map = platformLogic.queryStationsInfo(queryStationInfoDTO); return CommonResult.success(0, "查询充电站信息成功!", map.get("Data"), map.get("Sig")); } catch (Exception e) { - logger.info("联联平台查询充电站信息 error:", e); - e.printStackTrace(); + logger.info("{}-查询充电站信息 error:", platformName, e); } return CommonResult.failed("查询充电站信息发生异常"); } @@ -90,12 +92,13 @@ public class LianLianController extends ThirdPartyBaseController { /** * 联联平台查询充电站状态信息 * http://localhost:8080/LianLian/v1/query_station_status + * * @param dto * @return */ @PostMapping("/v1/query_station_status") public CommonResult query_station_status(HttpServletRequest request, @RequestBody CommonParamsDTO dto) { - logger.info("联联平台查询充电站状态信息 params:{}", JSON.toJSONString(dto)); + logger.info("{}-查询充电站状态信息 params:{}", platformName, JSON.toJSONString(dto)); try { // 校验令牌 if (!verifyToken(request.getHeader("Authorization"))) { @@ -113,12 +116,11 @@ public class LianLianController extends ThirdPartyBaseController { QueryStationInfoDTO queryStationInfoDTO = parseParamsDTO(dto, QueryStationInfoDTO.class); // 执行逻辑 - Map map = lianLianService.queryStationStatus(queryStationInfoDTO); + Map map = platformLogic.queryStationStatus(queryStationInfoDTO); return CommonResult.success(0, "查询充电站状态信息成功!", map.get("Data"), map.get("Sig")); } catch (Exception e) { - logger.info("联联平台查询充电站状态信息 error:", e); - e.printStackTrace(); + logger.error("{}-查询充电站状态信息 error:", platformName, e); } return CommonResult.failed("查询充电站状态信息发生异常"); } @@ -132,7 +134,7 @@ public class LianLianController extends ThirdPartyBaseController { */ @PostMapping("/v1/query_station_stats") public CommonResult query_station_stats(HttpServletRequest request, @RequestBody CommonParamsDTO dto) { - logger.info("联联平台查询统计信息 params:{}", JSON.toJSONString(dto)); + logger.info("{}-查询统计信息 params:{}", platformName, JSON.toJSONString(dto)); try { // 校验令牌 if (!verifyToken(request.getHeader("Authorization"))) { @@ -150,11 +152,10 @@ public class LianLianController extends ThirdPartyBaseController { QueryStationInfoDTO queryStationInfoDTO = parseParamsDTO(dto, QueryStationInfoDTO.class); // 执行逻辑 - Map map = lianLianService.queryStationStats(queryStationInfoDTO); + Map map = platformLogic.queryStationStats(queryStationInfoDTO); return CommonResult.success(0, "查询统计信息成功!", map.get("Data"), map.get("Sig")); } catch (Exception e) { - logger.info("联联平台查询统计信息 error:", e); - e.printStackTrace(); + logger.info("{}-查询统计信息 error:", platformName, e); } return CommonResult.failed("查询统计信息发生异常"); } @@ -165,34 +166,35 @@ public class LianLianController extends ThirdPartyBaseController { */ @PostMapping("/notificationStationInfo") public RestApiResponse notificationStationInfo(@RequestBody PushInfoParamDTO dto) { - logger.info("联联平台充电站信息变化推送 params:{}", JSON.toJSONString(dto)); + logger.info("{}-充电站信息变化推送 params:{}", platformName, JSON.toJSONString(dto)); RestApiResponse response = null; try { if (StringUtils.isBlank(String.valueOf(dto.getStationId()))) { throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); } - String result = lianLianService.notificationStationInfo(dto.getStationId()); + String result = platformLogic.notificationStationInfo(dto.getStationId()); response = new RestApiResponse<>(result); - }catch (BusinessException e) { - logger.error("联联平台充电站信息变化推送 error",e); + } catch (BusinessException e) { + logger.error("{}-充电站信息变化推送 error", platformName, e); response = new RestApiResponse<>(e.getCode(), e.getMessage()); - }catch (Exception e) { - logger.error("联联平台充电站信息变化推送 error", e); + } catch (Exception e) { + logger.error("{}-充电站信息变化推送 error", platformName, e); response = new RestApiResponse<>(e); } - logger.info("联联平台充电站信息变化推送 result:{}", response); + logger.info("{}-充电站信息变化推送 result:{}", platformName, response); return response; } /** * 联联平台设备状态变化推送 notification_stationStatus * http://localhost:8080/LianLian/notificationStationStatus + * * @param dto * @return */ @PostMapping("/notificationStationStatus") public RestApiResponse notificationStationStatus(@RequestBody PushInfoParamDTO dto) { - logger.info("联联平台设备状态变化推送 params:{}", JSON.toJSONString(dto)); + logger.info("{}-设备状态变化推送 params:{}", platformName, JSON.toJSONString(dto)); RestApiResponse response = null; try { if (StringUtils.isBlank(String.valueOf(dto.getPileConnectorCode())) || @@ -203,16 +205,16 @@ public class LianLianController extends ThirdPartyBaseController { pushRealTimeInfoDTO.setStatus(dto.getStatus()); pushRealTimeInfoDTO.setPileConnectorCode(dto.getPileConnectorCode()); pushRealTimeInfoDTO.setThirdPartyType(ThirdPlatformTypeEnum.LIAN_LIAN_PLATFORM.getTypeCode()); - String result = lianLianService.notificationStationStatus(pushRealTimeInfoDTO); + String result = platformLogic.notificationStationStatus(pushRealTimeInfoDTO); response = new RestApiResponse<>(result); - }catch (BusinessException e) { - logger.error("联联平台设备状态变化推送 error",e); + } catch (BusinessException e) { + logger.error("{}-设备状态变化推送 error", platformName, e); response = new RestApiResponse<>(e.getCode(), e.getMessage()); - }catch (Exception e) { - logger.error("联联平台设备状态变化推送 error", e); + } catch (Exception e) { + logger.error("{}-设备状态变化推送 error", platformName, e); response = new RestApiResponse<>(e); } - logger.info("联联平台设备状态变化推送 result:{}", response); + logger.info("{}-设备状态变化推送 result:{}", platformName, response); return response; } @@ -222,89 +224,92 @@ public class LianLianController extends ThirdPartyBaseController { */ @PostMapping("/notificationStationFee") public RestApiResponse notificationStationFee(@RequestBody PushInfoParamDTO dto) { - logger.info("联联平台站点费率变化推送 params:{}", JSON.toJSONString(dto)); + logger.info("{}-站点费率变化推送 params:{}", platformName, JSON.toJSONString(dto)); RestApiResponse response = null; try { if (StringUtils.isBlank(String.valueOf(dto.getStationId()))) { throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); } - String result = lianLianService.notificationStationFee(dto.getStationId()); + String result = platformLogic.notificationStationFee(dto.getStationId()); response = new RestApiResponse<>(result); - }catch (BusinessException e) { - logger.error("联联平台站点费率变化推送 error",e); + } catch (BusinessException e) { + logger.error("{}-站点费率变化推送 error", platformName, e); response = new RestApiResponse<>(e.getCode(), e.getMessage()); - }catch (Exception e) { - logger.error("联联平台站点费率变化推送 error", e); + } catch (Exception e) { + logger.error("{}-站点费率变化推送 error", platformName, e); response = new RestApiResponse<>(e); } - logger.info("联联平台站点费率变化推送 result:{}", response); + logger.info("{}-站点费率变化推送 result:{}", platformName, response); return response; } /** * 设备充电中状态变化推送 notification_connector_charge_status * http://localhost:8080/LianLian/notificationConnectorChargeStatus + * * @return */ @GetMapping("/notificationConnectorChargeStatus/{orderCode}") - public RestApiResponse notificationConnectorChargeStatus(@PathVariable("orderCode")String orderCode) { - logger.info("联联平台设备充电中状态变化推送 params:{}", orderCode); + public RestApiResponse notificationConnectorChargeStatus(@PathVariable("orderCode") String orderCode) { + logger.info("{}-设备充电中状态变化推送 params:{}", platformName, orderCode); RestApiResponse response = null; try { if (StringUtils.isBlank(orderCode)) { throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); } // String result = lianLianService.pushPileChargeStatusChange(orderCode); - String result = lianLianService.notificationConnectorChargeStatus(orderCode); + String result = platformLogic.notificationConnectorChargeStatus(orderCode); response = new RestApiResponse<>(result); - }catch (BusinessException e) { - logger.error("联联平台设备充电中状态变化推送 error",e); + } catch (BusinessException e) { + logger.error("{}-设备充电中状态变化推送 error", platformName, e); response = new RestApiResponse<>(e.getCode(), e.getMessage()); - }catch (Exception e) { - logger.error("联联平台设备充电中状态变化推送 error", e); + } catch (Exception e) { + logger.error("{}-设备充电中状态变化推送 error", platformName, e); response = new RestApiResponse<>(e); } - logger.info("联联平台设备充电中状态变化推送 result:{}", response); + logger.info("{}-设备充电中状态变化推送 result:{}", platformName, response); return response; } /** * 推送订单信息 notification_orderInfo * http://localhost:8080/LianLian/notificationOrderInfo/ + * * @param orderCode * @return */ @GetMapping("/notificationOrderInfo/{orderCode}") - public RestApiResponse notificationOrderInfo(@PathVariable("orderCode")String orderCode) { - logger.info("联联平台推送订单信息 params:{}", orderCode); + public RestApiResponse notificationOrderInfo(@PathVariable("orderCode") String orderCode) { + logger.info("{}-推送订单信息 params:{}", platformName, orderCode); RestApiResponse response = null; try { if (StringUtils.isBlank(orderCode)) { throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); } - String result = lianLianService.notificationChargeOrderInfo(orderCode); + String result = platformLogic.notificationChargeOrderInfo(orderCode); response = new RestApiResponse<>(result); - }catch (BusinessException e) { - logger.error("联联平台推送订单信息 error",e); + } catch (BusinessException e) { + logger.error("{}-推送订单信息 error", platformName, e); response = new RestApiResponse<>(e.getCode(), e.getMessage()); - }catch (Exception e) { - logger.error("联联平台推送订单信息 error", e); + } catch (Exception e) { + logger.error("{}-推送订单信息 error", platformName, e); response = new RestApiResponse<>(e); } - logger.info("联联平台推送订单信息 result:{}", response); + logger.info("{}-推送订单信息 result:{}", platformName, response); return response; } /** * 请求设备认证 * http://localhost:8080/LianLian/v1/query_equip_auth + * * @param request * @param dto * @return */ @PostMapping("/v1/query_equip_auth") public CommonResult query_equip_auth(HttpServletRequest request, @RequestBody CommonParamsDTO dto) { - logger.info("联联平台请求设备认证 param:{}", JSON.toJSONString(dto)); + logger.info("{}-请求设备认证 param:{}", platformName, JSON.toJSONString(dto)); try { // 校验令牌 if (!verifyToken(request.getHeader("Authorization"))) { @@ -322,23 +327,24 @@ public class LianLianController extends ThirdPartyBaseController { QueryEquipmentDTO queryEquipmentDTO = parseParamsDTO(dto, QueryEquipmentDTO.class); // 执行逻辑 - Map map = lianLianService.queryEquipAuth(queryEquipmentDTO); + Map map = platformLogic.queryEquipAuth(queryEquipmentDTO); return CommonResult.success(0, "请求设备认证成功!", map.get("Data"), map.get("Sig")); } catch (Exception e) { - logger.error("联联平台请求设备认证 error:", e); + logger.error("{}-请求设备认证 error:", platformName, e); } return CommonResult.failed("请求设备认证发生异常"); } /** * 请求启动充电 + * * @param request * @param dto * @return */ @PostMapping("/v1/query_start_charge") public CommonResult query_start_charge(HttpServletRequest request, @RequestBody CommonParamsDTO dto) { - logger.info("联联平台请求启动充电 params :{}", JSON.toJSONString(dto)); + logger.info("{}-请求启动充电 params :{}", platformName, JSON.toJSONString(dto)); try { // 校验令牌 if (!verifyToken(request.getHeader("Authorization"))) { @@ -356,11 +362,11 @@ public class LianLianController extends ThirdPartyBaseController { QueryStartChargeDTO queryStartChargeDTO = parseParamsDTO(dto, QueryStartChargeDTO.class); // 执行逻辑 - Map map = lianLianService.queryStartCharge(queryStartChargeDTO); + Map map = platformLogic.queryStartCharge(queryStartChargeDTO); return CommonResult.success(0, "请求启动充电成功!", map.get("Data"), map.get("Sig")); } catch (Exception e) { - logger.error("联联平台请求启动充电 error", e); + logger.error("{}-请求启动充电 error", platformName, e); } return CommonResult.failed("请求启动充电发生异常"); } @@ -368,12 +374,13 @@ public class LianLianController extends ThirdPartyBaseController { /** * 查询充电状态 * http://localhost:8080/LianLian/query_equip_charge_status/{startChargeSeq} + * * @param dto * @return */ @PostMapping("/v1/query_equip_charge_status") public CommonResult query_equip_charge_status(HttpServletRequest request, @RequestBody CommonParamsDTO dto) { - logger.info("联联平台查询充电状态 params :{}", JSON.toJSONString(dto)); + logger.info("{}-查询充电状态 params :{}", platformName, JSON.toJSONString(dto)); try { // 校验令牌 if (!verifyToken(request.getHeader("Authorization"))) { @@ -391,24 +398,25 @@ public class LianLianController extends ThirdPartyBaseController { QueryEquipChargeStatusDTO queryEquipChargeStatusDTO = parseParamsDTO(dto, QueryEquipChargeStatusDTO.class); // 执行逻辑 - Map map = lianLianService.queryEquipChargeStatus(queryEquipChargeStatusDTO); + Map map = platformLogic.queryEquipChargeStatus(queryEquipChargeStatusDTO); return CommonResult.success(0, "查询充电状态成功!", map.get("Data"), map.get("Sig")); } catch (Exception e) { - logger.error("联联平台查询充电状态 error", e); + logger.error("{}-查询充电状态 error", platformName, e); } - return CommonResult.failed("联联平台查询充电状态发生异常"); + return CommonResult.failed("{}-查询充电状态发生异常"); } /** * 请求停止充电 + * * @param request * @param dto * @return */ @PostMapping("/v1/query_stop_charge") public CommonResult query_stop_charge(HttpServletRequest request, @RequestBody CommonParamsDTO dto) { - logger.info("联联平台请求停止充电 params :{}", JSON.toJSONString(dto)); + logger.info("{}-请求停止充电 params :{}", platformName, JSON.toJSONString(dto)); try { // 校验令牌 if (!verifyToken(request.getHeader("Authorization"))) { @@ -426,26 +434,26 @@ public class LianLianController extends ThirdPartyBaseController { QueryStartChargeDTO queryStartChargeDTO = parseParamsDTO(dto, QueryStartChargeDTO.class); // 执行逻辑 - Map map = lianLianService.queryStopCharge(queryStartChargeDTO); + Map map = platformLogic.queryStopCharge(queryStartChargeDTO); return CommonResult.success(0, "请求停止充电成功!", map.get("Data"), map.get("Sig")); } catch (Exception e) { - logger.error("联联平台请求停止充电 error", e); + logger.error("{}-请求停止充电 error", platformName, e); } - return CommonResult.failed("联联平台请求停止充电发生异常"); + return CommonResult.failed("{}-请求停止充电发生异常"); } - /** * 推送订单结算信息 (联联推给我们) + * * @param request * @param dto * @return */ @PostMapping("/v1/notification_order_settlement_info") public CommonResult notification_order_settlement_info(HttpServletRequest request, @RequestBody CommonParamsDTO dto) { - logger.info("联联平台推送订单结算信息 params:{}", JSON.toJSONString(dto)); + logger.info("{}-推送订单结算信息 params:{}", platformName, JSON.toJSONString(dto)); try { // 校验令牌 if (!verifyToken(request.getHeader("Authorization"))) { @@ -463,11 +471,11 @@ public class LianLianController extends ThirdPartyBaseController { PushOrderSettlementDTO pushOrderSettlementDTO = parseParamsDTO(dto, PushOrderSettlementDTO.class); // 执行逻辑 - Map map = lianLianService.notificationOrderSettlementInfo(pushOrderSettlementDTO); + Map map = platformLogic.notificationOrderSettlementInfo(pushOrderSettlementDTO); return CommonResult.success(0, "推送订单结算信息成功!", map.get("Data"), map.get("Sig")); } catch (Exception e) { - logger.info("联联平台推送订单结算信息 error:", e); + logger.info("{}-推送订单结算信息 error:", platformName, e); e.printStackTrace(); } return CommonResult.failed("推送订单结算信息发生异常"); @@ -478,7 +486,7 @@ public class LianLianController extends ThirdPartyBaseController { RestApiResponse response = null; try { // String result = lianLianService.pushStationFee(stationId); - String result = lianLianService.notificationStationFee(stationId); + String result = platformLogic.notificationStationFee(stationId); response = new RestApiResponse<>(result); } catch (Exception e) { e.printStackTrace(); diff --git a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/NMGController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/NeiMengGuController.java similarity index 82% rename from jsowell-admin/src/main/java/com/jsowell/api/thirdparty/NMGController.java rename to jsowell-admin/src/main/java/com/jsowell/api/thirdparty/NeiMengGuController.java index a63567cb2..c38855a14 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/NMGController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/NeiMengGuController.java @@ -25,27 +25,26 @@ import java.util.Map; @Anonymous @RestController @RequestMapping("/evcs") -public class NMGController extends ThirdPartyBaseController { +public class NeiMengGuController extends ThirdPartyBaseController { + private final String platformName = "内蒙古平台"; + @Autowired @Qualifier("neiMengGuPlatformServiceImpl") private ThirdPartyPlatformService platformLogic; - // @Autowired - // private ThirdpartySecretInfoService thirdpartySecretInfoService; - /** * 获取token接口 * http://localhost:8080/evcs/v1/query_token */ @PostMapping("/v1/query_token") public CommonResult queryToken(@RequestBody CommonParamsDTO dto) { - logger.info("内蒙古平台请求令牌 params:{}", JSON.toJSONString(dto)); + logger.info("{}-请求令牌 params:{}", platformName, JSON.toJSONString(dto)); try { Map map = platformLogic.queryToken(dto); - logger.info("内蒙古平台请求令牌 result:{}", JSON.toJSONString(map)); + logger.info("{}-请求令牌 result:{}", platformName, JSON.toJSONString(map)); return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig")); } catch (Exception e) { - logger.error("内蒙古平台 请求令牌接口 异常", e); + logger.error("{}-请求令牌接口 异常", platformName, e); return CommonResult.failed("获取token发生异常"); } } @@ -59,7 +58,7 @@ public class NMGController extends ThirdPartyBaseController { */ @PostMapping("/v1/supervise_query_operator_info") public CommonResult queryOperatorInfo(HttpServletRequest request, @RequestBody CommonParamsDTO dto) { - logger.info("内蒙古平台查询运营商信息 params:{}", JSON.toJSONString(dto)); + logger.info("{}-查询运营商信息 params:{}", platformName, JSON.toJSONString(dto)); try { // 校验令牌 boolean verifyToken = verifyToken(request.getHeader("Authorization")); @@ -79,12 +78,12 @@ public class NMGController extends ThirdPartyBaseController { // 执行逻辑 Map map = platformLogic.queryOperatorInfo(paramDTO); - logger.info("内蒙古平台查询运营商信息 result:{}", JSON.toJSONString(map)); + logger.info("{}-查询运营商信息 result:{}", platformName, JSON.toJSONString(map)); return CommonResult.success(0, "操作成功!", map.get("Data"), map.get("Sig")); } catch (BusinessException e) { return CommonResult.failed(Integer.parseInt(e.getCode()), e.getMessage()); } catch (Exception e) { - logger.error("内蒙古平台查询运营商信息 异常", e); + logger.error("{}-查询运营商信息 异常", platformName, e); return CommonResult.failed("查询运营商信息发生异常"); } } @@ -98,7 +97,7 @@ public class NMGController extends ThirdPartyBaseController { */ @PostMapping("/v1/supervise_query_stations_info") public CommonResult queryStationsInfo(HttpServletRequest request, @RequestBody CommonParamsDTO dto) { - logger.info("内蒙古平台查询运营商信息 params:{}", JSON.toJSONString(dto)); + logger.info("{}-查询运营商信息 params:{}", platformName, JSON.toJSONString(dto)); try { // 校验令牌 boolean verifyToken = verifyToken(request.getHeader("Authorization")); @@ -114,10 +113,10 @@ public class NMGController extends ThirdPartyBaseController { } QueryStationInfoDTO paramDTO = parseParamsDTO(dto, QueryStationInfoDTO.class); Map map = platformLogic.queryStationsInfo(paramDTO); - logger.info("内蒙古平台查询运营商信息 result:{}", JSON.toJSONString(map)); + logger.info("{}-查询运营商信息 result:{}", platformName, JSON.toJSONString(map)); return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig")); } catch (Exception e) { - logger.error("内蒙古平台查询运营商信息 异常", e); + logger.error("{}-查询运营商信息 异常", platformName, e); return CommonResult.failed("查询运营商信息发生异常"); } } @@ -128,7 +127,7 @@ public class NMGController extends ThirdPartyBaseController { */ @PostMapping("/v1/supervise_query_station_status") public CommonResult queryStationStatus(HttpServletRequest request, @RequestBody CommonParamsDTO dto) { - logger.info("内蒙古平台查询充换电站状态信息 params:{}", JSON.toJSONString(dto)); + logger.info("{}-查询充换电站状态信息 params:{}", platformName, JSON.toJSONString(dto)); try { // 校验令牌 if (!verifyToken(request.getHeader("Authorization"))) { @@ -147,10 +146,10 @@ public class NMGController extends ThirdPartyBaseController { // 执行逻辑 Map map = platformLogic.queryStationStatus(paramDTO); - logger.info("内蒙古平台查询充换电站状态信息 result:{}", JSON.toJSONString(map)); + logger.info("{}-查询充换电站状态信息 result:{}", platformName, JSON.toJSONString(map)); return CommonResult.success(0, "查询充换电站状态信息成功!", map.get("Data"), map.get("Sig")); } catch (Exception e) { - logger.error("内蒙古平台查询充换电站状态信息异常", e); + logger.error("{}-查询充换电站状态信息异常", platformName, e); return CommonResult.failed("查询充换电站状态信息发生异常"); } } 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 464479ece..b49e411af 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 @@ -1,12 +1,24 @@ package com.jsowell.api.thirdparty; +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.pile.dto.QueryOperatorInfoDTO; +import com.jsowell.pile.dto.QueryStationInfoDTO; +import com.jsowell.pile.thirdparty.CommonParamsDTO; +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 javax.servlet.http.HttpServletRequest; +import java.util.Map; + /** * 宁夏平台Controller */ @@ -14,9 +26,134 @@ import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/ningxia") public class NingXiaController extends ThirdPartyBaseController { + + private final String platformName = "内蒙古平台"; + @Autowired @Qualifier("ninaXiaPlatformServiceImpl") - private ThirdPartyPlatformService lianLianService; + private ThirdPartyPlatformService platformLogic; + + /** + * 获取token接口 + * http://localhost:8080/evcs/v1/query_token + */ + @PostMapping("/v1/query_token") + public CommonResult queryToken(@RequestBody CommonParamsDTO dto) { + logger.info("{}-请求令牌 params:{}", platformName, JSON.toJSONString(dto)); + try { + Map map = platformLogic.queryToken(dto); + logger.info("{}-请求令牌 result:{}", platformName, JSON.toJSONString(map)); + return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig")); + } catch (Exception e) { + logger.error("{}- 请求令牌接口 异常", platformName, e); + return CommonResult.failed("获取token发生异常"); + } + } + + /** + * 查询运营商信息 + * 接口名称:supervise_query_operator_info + * 使用方法:由数据提供方实现此接口,数据需求方调用 + * 接口频率:每天一次或多次 + * 超时时间:120秒 + */ + @PostMapping("/v1/supervise_query_operator_info") + public CommonResult queryOperatorInfo(HttpServletRequest request, @RequestBody CommonParamsDTO dto) { + logger.info("{}-查询运营商信息 params:{}", platformName, JSON.toJSONString(dto)); + try { + // 校验令牌 + boolean verifyToken = verifyToken(request.getHeader("Authorization")); + if (!verifyToken) { + // 校验失败 + return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR); + } + + // 校验签名 + if (!verifySignature(dto)) { + // 签名错误 + return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR); + } + + // 解析入参 + QueryOperatorInfoDTO paramDTO = parseParamsDTO(dto, QueryOperatorInfoDTO.class); + + // 执行逻辑 + Map map = platformLogic.queryOperatorInfo(paramDTO); + logger.info("{}-查询运营商信息 result:{}", platformName, JSON.toJSONString(map)); + return CommonResult.success(0, "操作成功!", map.get("Data"), map.get("Sig")); + } catch (BusinessException e) { + return CommonResult.failed(Integer.parseInt(e.getCode()), e.getMessage()); + } catch (Exception e) { + logger.error("{}-查询运营商信息 异常", platformName, e); + return CommonResult.failed("查询运营商信息发生异常"); + } + } + + /** + * 查询充换电站信息 + * 接口名称: supervise_query_stations_info + * 使用方法:由数据提供方实现此接口,数据需求方调用 + * 接口频率:每天一次或多次 + * 超时时间:120秒 + */ + @PostMapping("/v1/supervise_query_stations_info") + public CommonResult queryStationsInfo(HttpServletRequest request, @RequestBody CommonParamsDTO dto) { + logger.info("{}-查询运营商信息 params:{}", platformName, JSON.toJSONString(dto)); + try { + // 校验令牌 + boolean verifyToken = verifyToken(request.getHeader("Authorization")); + if (!verifyToken) { + // 校验失败 + return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR); + } + + // 校验签名 + if (!verifySignature(dto)) { + // 签名错误 + return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR); + } + QueryStationInfoDTO paramDTO = parseParamsDTO(dto, QueryStationInfoDTO.class); + Map map = platformLogic.queryStationsInfo(paramDTO); + logger.info("{}-查询运营商信息 result:{}", platformName, JSON.toJSONString(map)); + return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig")); + } catch (Exception e) { + logger.error("{}-查询运营商信息 异常", platformName, e); + return CommonResult.failed("查询运营商信息发生异常"); + } + } + + /** + * 查询充换电站状态信息 + * supervise_query_station_status + */ + @PostMapping("/v1/supervise_query_station_status") + public CommonResult queryStationStatus(HttpServletRequest request, @RequestBody CommonParamsDTO dto) { + logger.info("{}-查询充换电站状态信息 params:{}", platformName, JSON.toJSONString(dto)); + try { + // 校验令牌 + if (!verifyToken(request.getHeader("Authorization"))) { + // 校验失败 + return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR); + } + + // 校验签名 + if (!verifySignature(dto)) { + // 签名错误 + return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR); + } + + // 解析入参 + QueryStationInfoDTO paramDTO = parseParamsDTO(dto, QueryStationInfoDTO.class); + + // 执行逻辑 + Map map = platformLogic.queryStationStatus(paramDTO); + logger.info("{}-查询充换电站状态信息 result:{}", platformName, JSON.toJSONString(map)); + return CommonResult.success(0, "查询充换电站状态信息成功!", map.get("Data"), map.get("Sig")); + } catch (Exception e) { + logger.error("{}-查询充换电站状态信息异常", platformName, e); + return CommonResult.failed("查询充换电站状态信息发生异常"); + } + } } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NeiMengGuPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NeiMengGuPlatformServiceImpl.java index 69bea368a..f8ed182c9 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NeiMengGuPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NeiMengGuPlatformServiceImpl.java @@ -126,7 +126,6 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { String operatorId = dto.getPlatformID(); // 通过operatorId 查出 operatorSecret - ThirdPartyPlatformConfig platformConfig = thirdPartyPlatformConfigService.getInfoByOperatorId(operatorId); ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByOperatorId(operatorId); if (thirdPartySecretInfoVO == null) { failReason = 1; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NinaXiaPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NinaXiaPlatformServiceImpl.java index 0ee6af557..4240d34aa 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NinaXiaPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NinaXiaPlatformServiceImpl.java @@ -1,10 +1,66 @@ package com.jsowell.thirdparty.platform.service.impl; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.jsowell.common.constant.Constants; +import com.jsowell.common.core.domain.ykc.RealTimeMonitorData; +import com.jsowell.common.enums.thirdparty.BusinessInformationExchangeEnum; +import com.jsowell.common.enums.thirdparty.ThirdPartyOperatorIdEnum; import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; +import com.jsowell.common.enums.ykc.BillingTimeTypeEnum; +import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum; +import com.jsowell.common.enums.ykc.ReturnCodeEnum; +import com.jsowell.common.exception.BusinessException; +import com.jsowell.common.util.DateUtils; +import com.jsowell.common.util.JWTUtils; +import com.jsowell.common.util.PageUtils; +import com.jsowell.common.util.StringUtils; +import com.jsowell.pile.domain.OrderBasicInfo; +import com.jsowell.pile.domain.OrderDetail; +import com.jsowell.pile.domain.ThirdPartyPlatformConfig; +import com.jsowell.pile.domain.ThirdPartyStationRelation; +import com.jsowell.pile.dto.PushRealTimeInfoDTO; +import com.jsowell.pile.dto.QueryEquipChargeStatusDTO; +import com.jsowell.pile.dto.QueryOperatorInfoDTO; +import com.jsowell.pile.dto.QueryStationInfoDTO; +import com.jsowell.pile.service.*; +import com.jsowell.pile.thirdparty.CommonParamsDTO; +import com.jsowell.pile.thirdparty.EquipmentInfo; +import com.jsowell.pile.util.MerchantUtils; +import com.jsowell.pile.vo.ThirdPartySecretInfoVO; +import com.jsowell.pile.vo.base.ConnectorInfoVO; +import com.jsowell.pile.vo.base.MerchantInfoVO; +import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO; +import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO; +import com.jsowell.pile.vo.uniapp.BillingPriceVO; +import com.jsowell.pile.vo.web.PileConnectorInfoVO; +import com.jsowell.pile.vo.web.PileStationVO; +import com.jsowell.thirdparty.lianlian.domain.ConnectorChargeStatusInfo; +import com.jsowell.thirdparty.lianlian.domain.ConnectorStatusInfo; +import com.jsowell.thirdparty.lianlian.domain.StationStatusInfo; +import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO; +import com.jsowell.thirdparty.lianlian.vo.QueryChargingStatusVO; +import com.jsowell.thirdparty.platform.domain.*; import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory; +import com.jsowell.thirdparty.platform.util.Cryptos; +import com.jsowell.thirdparty.platform.util.Encodes; +import com.jsowell.thirdparty.platform.util.HttpRequestUtil; +import com.jsowell.thirdparty.platform.util.ThirdPartyPlatformUtils; +import com.jsowell.thirdparty.service.ThirdpartySecretInfoService; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.math.BigDecimal; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.stream.Collectors; + @Service public class NinaXiaPlatformServiceImpl implements ThirdPartyPlatformService { // 平台类型 @@ -14,4 +70,714 @@ public class NinaXiaPlatformServiceImpl implements ThirdPartyPlatformService { public void afterPropertiesSet() throws Exception { ThirdPartyPlatformFactory.register(thirdPlatformType, this); } + + @Autowired + private ThirdPartyPlatformConfigService thirdPartyPlatformConfigService; + + @Autowired + private ThirdPartyStationRelationService thirdPartyStationRelationService; + + @Autowired + private ThirdpartySecretInfoService thirdpartySecretInfoService; + + @Autowired + private PileBasicInfoService pileBasicInfoService; + + @Autowired + private PileStationInfoService pileStationInfoService; + + @Autowired + private PileMerchantInfoService pileMerchantInfoService; + + @Autowired + private PileConnectorInfoService pileConnectorInfoService; + + @Autowired + private OrderBasicInfoService orderBasicInfoService; + + @Autowired + private PileBillingTemplateService pileBillingTemplateService; + + /** + * @return + */ + @Override + public void printServiceName() { + System.out.println("当前类名:" + this.getClass().getSimpleName()); + } + + /** + * query_token 获取token,提供给第三方平台使用 + * + * @param dto + * @return + */ + @Override + public Map queryToken(CommonParamsDTO dto) { + AccessTokenVO vo = new AccessTokenVO(); + // 0:成功;1:失败 + int succStat = 0; + // 0:无;1:无此对接平台;2:密钥错误; 3~99:自定义 + int failReason = 0; + + String operatorId = dto.getOperatorID(); + // 通过operatorId 查出 operatorSecret + ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByOperatorId(operatorId); + if (thirdPartySecretInfoVO == null) { + failReason = 1; + succStat = 1; + } else { + String theirOperatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); + String dataSecret = thirdPartySecretInfoVO.getOurDataSecret(); + String dataSecretIv = thirdPartySecretInfoVO.getOurDataSecretIv(); + // 解密data 获取参数中的OperatorSecret + String decrypt = Cryptos.decrypt(dto.getData(), dataSecret, dataSecretIv); + String inputOperatorSecret = null; + if (StringUtils.isNotBlank(decrypt)) { + inputOperatorSecret = JSON.parseObject(decrypt).getString("OperatorSecret"); + } + // 对比密钥 + if (!StringUtils.equals(theirOperatorSecret, inputOperatorSecret)) { + failReason = 1; + succStat = 1; + } else { + // 生成token + String token = JWTUtils.createToken(operatorId, theirOperatorSecret, JWTUtils.ttlMillis); + vo.setAccessToken(token); + vo.setTokenAvailableTime((int) (JWTUtils.ttlMillis / 1000)); + } + } + // 组装返回参数 + vo.setPlatformId(operatorId); + vo.setFailReason(failReason); + vo.setSuccStat(succStat); + + Map resultMap = ThirdPartyPlatformUtils.generateResultMap(vo, thirdPartySecretInfoVO); + return resultMap; + } + + /** + * 查询运营商信息 query_operator_info + * supervise_query_operator_info + * + * @param dto 查询运营商信息DTO + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public Map queryOperatorInfo(QueryOperatorInfoDTO dto) { + PageHelper.startPage(dto.getPageNo(), dto.getPageSize()); + List merchantList = thirdPartyStationRelationService.selectMerchantList(thirdPlatformType); + PageInfo pageInfo = new PageInfo<>(merchantList); + List operatorInfos = Lists.newArrayList(); + if (CollectionUtils.isNotEmpty(pageInfo.getList())) { + SupOperatorInfo supOperatorInfo; + for (MerchantInfoVO merchantInfoVO : pageInfo.getList()) { + supOperatorInfo = new SupOperatorInfo(); + supOperatorInfo.setOperatorID(MerchantUtils.getOperatorID(merchantInfoVO.getOrganizationCode())); + supOperatorInfo.setOperatorUSCID(merchantInfoVO.getOrganizationCode()); + supOperatorInfo.setOperatorName(merchantInfoVO.getMerchantName()); + supOperatorInfo.setOperatorTel1(merchantInfoVO.getMerchantTel()); + supOperatorInfo.setOperatorRegAddress(merchantInfoVO.getMerchantAddress()); + operatorInfos.add(supOperatorInfo); + } + } + ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(thirdPlatformType); + + // 组装结果集 + Map map = Maps.newHashMap(); + map.put("PageNo", pageInfo.getPageNum()); + map.put("PageCount", pageInfo.getPages()); + map.put("ItemSize", pageInfo.getTotal()); + map.put("OperatorInfos", operatorInfos); + + Map resultMap = ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); + return resultMap; + } + + /** + * 查询充电站信息 query_stations_info + * 此接口用于查询对接平台的充电站的信息 + * + * @param dto 查询站点信息dto + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public Map queryStationsInfo(QueryStationInfoDTO dto) { + int pageNo = dto.getPageNo() == null ? 1 : dto.getPageNo(); + int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize(); + + PageUtils.startPage(pageNo, pageSize); + List stationInfos = pileStationInfoService.getStationInfosByThirdParty(dto); + if (CollectionUtils.isEmpty(stationInfos)) { + // 未查到数据 + return null; + } + // ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorId()); + ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(thirdPlatformType); + if (thirdPartySecretInfoVO == null) { + return null; + } + PageInfo pageInfo = new PageInfo<>(stationInfos); + List resultList = new ArrayList<>(); + for (ThirdPartyStationInfoVO pileStationInfo : pageInfo.getList()) { + SupStationInfo stationInfo = new SupStationInfo(); + String stationId = String.valueOf(pileStationInfo.getId()); + stationInfo.setStationID(stationId); + // MerchantInfoVO merchantInfo = pileMerchantInfoService.getMerchantInfo(String.valueOf(pileStationInfo.getMerchantId())); + stationInfo.setOperatorID(Constants.OPERATORID_LIANLIAN); // 组织机构代码 + stationInfo.setEquipmentOwnerID(String.valueOf(pileStationInfo.getMerchantId())); + stationInfo.setStationName(pileStationInfo.getStationName()); + stationInfo.setIsAloneApply(Integer.valueOf(pileStationInfo.getAloneApply())); + stationInfo.setIsPublicParkingLot(Integer.valueOf(pileStationInfo.getPublicParking())); + stationInfo.setCountryCode(pileStationInfo.getCountryCode()); + stationInfo.setAreaCode(pileStationInfo.getAreaCode()); + stationInfo.setAddress(pileStationInfo.getAddress()); + stationInfo.setServiceTel(pileStationInfo.getStationTel()); + stationInfo.setStationType(Integer.valueOf(pileStationInfo.getStationType())); + stationInfo.setParkNums(Integer.valueOf(pileStationInfo.getParkNums())); + stationInfo.setStationLng(new BigDecimal(pileStationInfo.getStationLng())); + stationInfo.setStationLat(new BigDecimal(pileStationInfo.getStationLat())); + stationInfo.setConstruction(Integer.valueOf(pileStationInfo.getConstruction())); + stationInfo.setOpenAllDay(Integer.valueOf(pileStationInfo.getOpenAllDay())); + // stationInfo.setMinElectricityPrice(pileStationInfo); // 最低充电电费率 + // stationInfo.setElectricityFee(); // 电费 xx元/度 + // stationInfo.setServiceFee(); // 服务费 xx元/度 + stationInfo.setParkFree(Integer.valueOf(pileStationInfo.getParkFree())); + stationInfo.setPayment(pileStationInfo.getPayment()); + stationInfo.setSupportOrder(Integer.valueOf(pileStationInfo.getSupportOrder())); + // stationInfo.setParkFeeType(pileStationInfo); // 停车收费类型 + stationInfo.setToiletFlag(Integer.valueOf(pileStationInfo.getToiletFlag())); + stationInfo.setStoreFlag(Integer.valueOf(pileStationInfo.getStoreFlag())); + stationInfo.setRestaurantFlag(Integer.valueOf(pileStationInfo.getRestaurantFlag())); + stationInfo.setLoungeFlag(Integer.valueOf(pileStationInfo.getLoungeFlag())); + stationInfo.setCanopyFlag(Integer.valueOf(pileStationInfo.getCanopyFlag())); + stationInfo.setPrinterFlag(Integer.valueOf(pileStationInfo.getPrinterFlag())); + stationInfo.setBarrierFlag(Integer.valueOf(pileStationInfo.getBarrierFlag())); + stationInfo.setParkingLockFlag(Integer.valueOf(pileStationInfo.getParkingLockFlag())); + List pileList = pileBasicInfoService.getPileListForLianLian(stationId); + if (CollectionUtils.isNotEmpty(pileList)) { + stationInfo.setEquipmentInfos(pileList); // 充电设备信息列表 + } + resultList.add(stationInfo); + } + Map map = new LinkedHashMap<>(); + map.put("PageNo", pageInfo.getPageNum()); + map.put("PageCount", pageInfo.getPages()); + map.put("ItemSize", pageInfo.getTotal()); + map.put("StationInfos", resultList); + Map resultMap = ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); + return resultMap; + } + + /** + * 设备接口状态查询 query_station_status + * + * @param dto 查询站点信息dto + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public Map queryStationStatus(QueryStationInfoDTO dto) { + List stationIds = dto.getStationIds(); + List StationStatusInfos = new ArrayList<>(); + List connectorStatusInfos = new ArrayList<>(); + // ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorId()); + ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(thirdPlatformType); + if (thirdPartySecretInfoVO == null) { + return null; + } + ConnectorStatusInfo connectorStatusInfo; + for (String stationId : stationIds) { + StationStatusInfo stationStatusInfo = new StationStatusInfo(); + stationStatusInfo.setStationId(stationId); + // 根据站点id查询 + List list = pileConnectorInfoService.getConnectorListForLianLian(Long.parseLong(stationId)); + for (ConnectorInfoVO connectorInfoVO : list) { + + String connectorStatus = connectorInfoVO.getConnectorStatus(); + if (StringUtils.equals(connectorStatus, PileConnectorDataBaseStatusEnum.OCCUPIED_CHARGING.getValue())) { + // 充电中 + ConnectorChargeStatusInfo info = new ConnectorChargeStatusInfo(); + OrderBasicInfo orderBasicInfo = orderBasicInfoService.queryChargingByPileConnectorCode(connectorInfoVO.getPileConnectorCode()); + if (orderBasicInfo == null) { + continue; + } + List chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(orderBasicInfo.getTransactionCode()); + if (CollectionUtils.isNotEmpty(chargingRealTimeData)) { + RealTimeMonitorData realTimeMonitorData = chargingRealTimeData.get(0); + info.setStartChargeSeq(orderBasicInfo.getOrderCode()); + info.setConnectorID(orderBasicInfo.getPileConnectorCode()); + info.setConnectorStatus(Integer.valueOf(connectorInfoVO.getConnectorStatus())); + info.setCurrentA(new BigDecimal(realTimeMonitorData.getOutputCurrent())); + info.setVoltageA(new BigDecimal(realTimeMonitorData.getOutputVoltage())); + info.setSoc(new BigDecimal(realTimeMonitorData.getSOC())); + info.setStartTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeStartTime())); + info.setEndTime(DateUtils.getDateTime()); // 本次采样时间 + info.setTotalPower(new BigDecimal(realTimeMonitorData.getChargingDegree())); // 累计充电量 + // info.setElecMoney(); // 累计电费 + // info.setSeviceMoney(); // 累计服务费 + info.setTotalMoney(new BigDecimal(realTimeMonitorData.getChargingAmount())); + connectorStatusInfos.add(info); + } + } else { + // 其他 + connectorStatusInfo = new ConnectorStatusInfo(); + connectorStatusInfo.setConnectorID(connectorInfoVO.getPileConnectorCode()); + connectorStatusInfo.setStatus(Integer.parseInt(connectorInfoVO.getConnectorStatus())); + connectorStatusInfos.add(connectorStatusInfo); + } + } + stationStatusInfo.setConnectorStatusInfos(connectorStatusInfos); + StationStatusInfos.add(stationStatusInfo); + } + // 将 StationStatusInfos 分页 + int pageNum = 1; + int pageSize = 10; + List collect = StationStatusInfos.stream() + .skip((pageNum - 1) * pageSize) + .limit(pageSize) + .collect(Collectors.toList()); + + // int total = StationStatusInfos.size(); + // int pages = PageUtil.totalPage(total, pageSize); + + Map map = new LinkedHashMap<>(); + // map.put("Total", total); + map.put("StationStatusInfos", collect); + + Map resultMap = ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); + return resultMap; + } + + /** + * 设备状态变化推送 notification_stationStatus + * 推送充电设备接口状态信息 supervise_notification_station_status + * + * @param dto + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public String notificationStationStatus(PushRealTimeInfoDTO dto) { + String status = dto.getStatus(); + String pileConnectorCode = dto.getPileConnectorCode(); + + // 查出该桩所属哪个站点 + String pileSn = StringUtils.substring(pileConnectorCode, 0, 14); + PileStationVO stationVO = pileStationInfoService.getStationInfoByPileSn(pileSn); + // 通过站点id查询相关配置信息 + ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(stationVO.getId()); + if (relationInfo == null) { + return null; + } + String operatorId = relationInfo.getOperatorId(); + String operatorSecret = relationInfo.getOperatorSecret(); + String signSecret = relationInfo.getSignSecret(); + String dataSecret = relationInfo.getDataSecret(); + String dataSecretIv = relationInfo.getDataSecretIv(); + String urlAddress = relationInfo.getUrlAddress(); + + String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_STATION_STATUS.getValue(); + ConnectorStatusInfo info = ConnectorStatusInfo.builder() + .connectorID(pileConnectorCode) + .status(Integer.parseInt(status)) + .build(); + // 调用联联平台接口 + JSONObject json = new JSONObject(); + json.put("ConnectorStatusInfo", info); + String jsonString = JSON.toJSONString(json); + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + + @Override + public String notificationStationStatus(String stationId, String pileConnectorCode, String status, ThirdPartySecretInfoVO secretInfoVO) { + // 查询充电枪口状态 + PileConnectorInfoVO connectorInfo = pileConnectorInfoService.getPileConnectorInfoByConnectorCode(pileConnectorCode); + if (Objects.isNull(connectorInfo)) { + throw new BusinessException(ReturnCodeEnum.CODE_CONNECTOR_INFO_NULL_ERROR); + } + + String merchantId = connectorInfo.getMerchantId(); + MerchantInfoVO merchantInfoVO = pileMerchantInfoService.getMerchantInfoVO(merchantId); + if (Objects.isNull(merchantInfoVO)) { + throw new BusinessException(ReturnCodeEnum.CODE_CONNECTOR_INFO_NULL_ERROR); + } + + SupConnectorStatusInfo info = SupConnectorStatusInfo.builder() + .operatorID(Constants.JSOWELL_OPERATORID) + .equipmentOwnerID(MerchantUtils.getOperatorID(merchantInfoVO.getOrganizationCode())) + .stationID(connectorInfo.getStationId()) + .equipmentID(connectorInfo.getPileSn()) + .connectorID(pileConnectorCode) + .equipmentClassification(Constants.ONE) + .status(Integer.parseInt(status)) + .statusDesc(PileConnectorDataBaseStatusEnum.getStatusDescription(status)) + .parkStatus(Constants.ZERO) + .lockStatus(Constants.ZERO) + .batteryStatus(Constants.ZERO) + .batteryPackID("") + .lastChangeTime(DateUtils.getDateTime()) + .build(); + + // 调用联联平台接口 + String operatorId = secretInfoVO.getTheirOperatorId(); + String operatorSecret = secretInfoVO.getTheirOperatorSecret(); + String signSecret = secretInfoVO.getTheirSigSecret(); + String dataSecret = secretInfoVO.getTheirDataSecret(); + String dataSecretIv = secretInfoVO.getTheirDataSecretIv(); + String urlAddress = secretInfoVO.getTheirUrlPrefix(); + String url = urlAddress + "supervise_notification_station_status"; + + // JSONObject json = new JSONObject(); + // json.put("ConnectorStatusInfo", info); + String jsonString = JSON.toJSONString(info); + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + + /** + * 充电订单推送 notification_charge_order_info + * + * @param orderCode 订单编号 + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public String notificationChargeOrderInfo(String orderCode) { + // 根据订单号查询出信息 + OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + if (orderBasicInfo == null) { + return null; + } + + // 通过站点id查询相关配置信息 + ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(orderBasicInfo.getStationId()); + if (relationInfo == null) { + return null; + } + + String operatorId = relationInfo.getOperatorId(); + String operatorSecret = relationInfo.getOperatorSecret(); + String signSecret = relationInfo.getSignSecret(); + String dataSecret = relationInfo.getDataSecret(); + String dataSecretIv = relationInfo.getDataSecretIv(); + String urlAddress = relationInfo.getUrlAddress(); + + // 根据订单号查询订单详情 + OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode); + if (orderDetail == null) { + return null; + } + + // 推送地址 + String url = urlAddress + "notification_orderInfo"; + + // 拼装成内蒙古平台所需格式对象 + ChargeOrderInfo orderInfo = transformChargeOrderInfo(orderBasicInfo, orderDetail); + orderInfo.setOperatorID(operatorId); + String equipmentOwnerID; + if (MerchantUtils.isXiXiaoMerchant(orderBasicInfo.getMerchantId())) { + equipmentOwnerID = Constants.OPERATORID_XI_XIAO; + } else { + equipmentOwnerID = Constants.OPERATORID_LIANLIAN; + } + orderInfo.setEquipmentOwnerID(equipmentOwnerID); + + List billingList = pileBillingTemplateService.queryBillingPrice(orderBasicInfo.getStationId()); + // 先将list按照 尖、峰、平、谷 时段排序 + // List collect = billingList.stream().sorted(Comparator.comparing(BillingPriceVO::getTimeType)).collect(Collectors.toList()); + // 再循环该list,拼装对应的充电价格、费率 + List chargeDetails = transformSupChargeDetails(orderDetail, billingList); + orderInfo.setChargeDetails(chargeDetails); + + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + if (StringUtils.isBlank(token)) { + return null; + } + // 调用联联平台接口 + JSONObject json = new JSONObject(); + json.put("ChargeOrderInfo", orderInfo); + String jsonString = JSON.toJSONString(json); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + + @Override + public String notificationChargeOrderInfo(String orderCode, ThirdPartySecretInfoVO secretInfoVO) { + // 根据订单号查询出信息 + OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + if (orderBasicInfo == null) { + return null; + } + + // 通过站点id查询相关配置信息 + // ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(orderBasicInfo.getStationId()); + // if (relationInfo == null) { + // return null; + // } + + String operatorId = secretInfoVO.getTheirOperatorId(); + String operatorSecret = secretInfoVO.getTheirOperatorSecret(); + String signSecret = secretInfoVO.getTheirSigSecret(); + String dataSecret = secretInfoVO.getTheirDataSecret(); + String dataSecretIv = secretInfoVO.getTheirDataSecretIv(); + String urlAddress = secretInfoVO.getTheirUrlPrefix(); + + // 根据订单号查询订单详情 + OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode); + if (orderDetail == null) { + return null; + } + + // 推送地址 + String url = urlAddress + "notification_orderInfo"; + + // 拼装成内蒙古平台所需格式对象 + ChargeOrderInfo orderInfo = transformChargeOrderInfo(orderBasicInfo, orderDetail); + orderInfo.setOperatorID(operatorId); + String equipmentOwnerID; + if (MerchantUtils.isXiXiaoMerchant(orderBasicInfo.getMerchantId())) { + equipmentOwnerID = Constants.OPERATORID_XI_XIAO; + } else { + equipmentOwnerID = Constants.OPERATORID_LIANLIAN; + } + orderInfo.setEquipmentOwnerID(equipmentOwnerID); + + List billingList = pileBillingTemplateService.queryBillingPrice(orderBasicInfo.getStationId()); + // 先将list按照 尖、峰、平、谷 时段排序 + // List collect = billingList.stream().sorted(Comparator.comparing(BillingPriceVO::getTimeType)).collect(Collectors.toList()); + // 再循环该list,拼装对应的充电价格、费率 + List chargeDetails = transformSupChargeDetails(orderDetail, billingList); + orderInfo.setChargeDetails(chargeDetails); + + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + if (StringUtils.isBlank(token)) { + return null; + } + // 调用联联平台接口 + JSONObject json = new JSONObject(); + json.put("ChargeOrderInfo", orderInfo); + String jsonString = JSON.toJSONString(json); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + + /** + * 推送充电状态 notification_equip_charge_status + * 推送充电状态信息 supervise_notification_equip_charge_status + * + * @param orderCode 订单编号 + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public String notificationEquipChargeStatus(String orderCode) { + // 根据订单号查询订单信息 + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + // 通过第三方平台类型查询相关配置信息 + ThirdPartyStationRelation relation = new ThirdPartyStationRelation(); + relation.setThirdPartyType(orderInfo.getThirdPartyType()); + ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(relation); + // ThirdPartySettingInfo settingInfo = thirdPartySettingInfoService.getInfoByStationId(Long.parseLong(orderInfo.getStationId())); + if (relationInfo == null) { + return null; + } + String operatorId = relationInfo.getOperatorId(); + String operatorSecret = relationInfo.getOperatorSecret(); + String signSecret = relationInfo.getSignSecret(); + String dataSecret = relationInfo.getDataSecret(); + String dataSecretIv = relationInfo.getDataSecretIv(); + String urlAddress = relationInfo.getUrlAddress(); + String thirdPartyType = relationInfo.getThirdPartyType(); + + // 调用 查询充电状态方法 + QueryEquipChargeStatusDTO dto = new QueryEquipChargeStatusDTO(); + dto.setStartChargeSeq(orderCode); + // 根据type获取operatorId + String operatorIdByType = ThirdPartyOperatorIdEnum.getOperatorIdByType(thirdPartyType); + dto.setOperatorID(operatorIdByType); + Map map = queryEquipChargeStatus(dto); + if (map == null) { + return null; + } + String data = map.get("Data"); + // 解密data (此处解密需用 thirdparty_platform_config 的密钥配置) + ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(operatorIdByType); + ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(thirdPlatformType); + byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(data), + configInfo.getDataSecret().getBytes(), configInfo.getDataSecretIv().getBytes()); + String dataStr = new String(plainText, StandardCharsets.UTF_8); + // 转成对应的对象 + QueryChargingStatusVO vo = JSONObject.parseObject(dataStr, QueryChargingStatusVO.class); + + String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_EQUIP_CHARGE_STATUS.getValue(); + // 调用联联平台接口 + String jsonString = JSON.toJSONString(vo); + + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + + /** + * 推送充换电站用能统计信息 supervise_notification_operation_stats_info + * + * @param stationId + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public String notificationOperationStatsInfo(String stationId) { + return ThirdPartyPlatformService.super.notificationOperationStatsInfo(stationId); + } + + /** + * 推送充电站历史充电订单信息 supervise_notification_charge_order_info_history + * + * @param orderCode + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public String notificationChargeOrderInfoHistory(String orderCode) { + // 根据订单号查询出信息 + OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + + // 通过站点id查询相关配置信息 + ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(orderBasicInfo.getStationId()); + if (relationInfo == null) { + return null; + } + OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode); + + String operatorId = relationInfo.getOperatorId(); + String operatorSecret = relationInfo.getOperatorSecret(); + String signSecret = relationInfo.getSignSecret(); + String dataSecret = relationInfo.getDataSecret(); + String dataSecretIv = relationInfo.getDataSecretIv(); + String urlAddress = relationInfo.getUrlAddress(); + + String url = urlAddress + "supervise_notification_charge_order_info_history"; + + // 拼装成内蒙古平台所需格式对象 + ChargeOrderInfo orderInfo = transformChargeOrderInfo(orderBasicInfo, orderDetail); + orderInfo.setOperatorID(operatorId); + String equipmentOwnerID; + if (MerchantUtils.isXiXiaoMerchant(orderBasicInfo.getMerchantId())) { + equipmentOwnerID = Constants.OPERATORID_XI_XIAO; + } else { + equipmentOwnerID = Constants.OPERATORID_LIANLIAN; + } + orderInfo.setEquipmentOwnerID(equipmentOwnerID); + + List billingList = pileBillingTemplateService.queryBillingPrice(orderBasicInfo.getStationId()); + // 先将list按照 尖、峰、平、谷 时段排序 + // List collect = billingList.stream().sorted(Comparator.comparing(BillingPriceVO::getTimeType)).collect(Collectors.toList()); + // 再循环该list,拼装对应的充电价格、费率 + List chargeDetails = transformSupChargeDetails(orderDetail, billingList); + orderInfo.setChargeDetails(chargeDetails); + + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + if (StringUtils.isBlank(token)) { + return null; + } + // 调用联联平台接口 + JSONObject json = new JSONObject(); + json.put("ChargeOrderInfo", orderInfo); + String jsonString = JSON.toJSONString(json); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + + /** + * 转换充电站充电订单信息 + * @param orderBasicInfo + * @param orderDetail + * @return + */ + private ChargeOrderInfo transformChargeOrderInfo(OrderBasicInfo orderBasicInfo, OrderDetail orderDetail) { + ChargeOrderInfo chargeOrderInfo = ChargeOrderInfo.builder() + .stationID(orderBasicInfo.getStationId()) + .equipmentID(orderBasicInfo.getPileSn()) + .orderNo(orderBasicInfo.getOrderCode()) + .connectorID(orderBasicInfo.getPileConnectorCode()) + .licensePlate(orderBasicInfo.getPlateNumber()) + .vin(orderBasicInfo.getVinCode()) + .startSOC(orderBasicInfo.getStartSoc()) + .endSOC(orderBasicInfo.getEndSoc()) + .startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeStartTime())) + .endTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeEndTime())) + .totalPower(orderDetail.getTotalUsedElectricity()) + .cuspElect(orderDetail.getSharpUsedElectricity()) + .peakElect(orderDetail.getSharpUsedElectricity()) + .flatElect(orderDetail.getFlatUsedElectricity()) + .valleyElect(orderDetail.getValleyUsedElectricity()) + .pushTimeStamp(DateUtils.getDateTime()) + .totalElecMoney(orderDetail.getTotalElectricityAmount()) + .totalSeviceMoney(orderDetail.getTotalServiceAmount()) + .totalMoney(orderDetail.getTotalOrderAmount()) + .stopReason(0) + .stopDesc(orderBasicInfo.getReason()) // TODO 停止原因 + .sumPeriod(0) + .build(); + return chargeOrderInfo; + } + + /** + * 转换时段充电明细 + * @param orderDetail + * @param billingList + * @return + */ + private List transformSupChargeDetails(OrderDetail orderDetail, List billingList) { + List resultList = Lists.newArrayList(); + SupChargeDetails detail; + for (BillingPriceVO billingPriceVO : billingList) { + detail = new SupChargeDetails(); + if (StringUtils.equals(billingPriceVO.getTimeType(), BillingTimeTypeEnum.SHARP.getValue())) { + // 尖时段 + detail.setDetailStartTime(billingPriceVO.getStartTime()); + detail.setDetailEndTime(billingPriceVO.getEndTime()); + detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setDetailPower(orderDetail.getSharpUsedElectricity()); + detail.setDetailElecMoney(orderDetail.getSharpElectricityPrice()); + detail.setDetailSeviceMoney(orderDetail.getSharpServicePrice()); + } else if (StringUtils.equals(billingPriceVO.getTimeType(), BillingTimeTypeEnum.PEAK.getValue())) { + // 峰时段 + detail.setDetailStartTime(billingPriceVO.getStartTime()); + detail.setDetailEndTime(billingPriceVO.getEndTime()); + detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setDetailPower(orderDetail.getPeakUsedElectricity()); + detail.setDetailElecMoney(orderDetail.getPeakElectricityPrice()); + detail.setDetailSeviceMoney(orderDetail.getPeakServicePrice()); + } else if (StringUtils.equals(billingPriceVO.getTimeType(), BillingTimeTypeEnum.FLAT.getValue())) { + // 平时段 + detail.setDetailStartTime(billingPriceVO.getStartTime()); + detail.setDetailEndTime(billingPriceVO.getEndTime()); + detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setDetailPower(orderDetail.getFlatUsedElectricity()); + detail.setDetailElecMoney(orderDetail.getFlatElectricityPrice()); + detail.setDetailSeviceMoney(orderDetail.getFlatServicePrice()); + } else if (StringUtils.equals(billingPriceVO.getTimeType(), BillingTimeTypeEnum.VALLEY.getValue())) { + // 谷时段 + detail.setDetailStartTime(billingPriceVO.getStartTime()); + detail.setDetailEndTime(billingPriceVO.getEndTime()); + detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setDetailPower(orderDetail.getValleyUsedElectricity()); + detail.setDetailElecMoney(orderDetail.getValleyElectricityPrice()); + detail.setDetailSeviceMoney(orderDetail.getValleyServicePrice()); + } + resultList.add(detail); + } + return resultList; + } + + } From 6cecaf50e2175d1c583dfa2f904214465a1458f9 Mon Sep 17 00:00:00 2001 From: Guoqs <123@jsowell.com> Date: Fri, 10 May 2024 17:00:27 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handler/UploadRealTimeMonitorHandler.java | 13 ++++- .../mapper/ThirdpartySecretInfoMapper.java | 5 ++ .../thirdparty/common/CommonService.java | 53 +++++++++++++++++++ 3 files changed, 69 insertions(+), 2 deletions(-) diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/handler/UploadRealTimeMonitorHandler.java b/jsowell-netty/src/main/java/com/jsowell/netty/handler/UploadRealTimeMonitorHandler.java index 37d050de4..6c03c31de 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/handler/UploadRealTimeMonitorHandler.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/handler/UploadRealTimeMonitorHandler.java @@ -16,6 +16,8 @@ import com.jsowell.pile.domain.OrderBasicInfo; import com.jsowell.pile.service.PileBasicInfoService; import com.jsowell.pile.service.OrderBasicInfoService; import com.jsowell.thirdparty.common.CommonService; +import com.jsowell.thirdparty.common.NotificationDTO; +import com.jsowell.thirdparty.common.NotificationService; import io.netty.channel.Channel; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -297,13 +299,20 @@ public class UploadRealTimeMonitorHandler extends AbstractHandler { } // 异步推送第三方平台实时数据 - // pushToThirdPartyPlatforms(pileSn, connectorCode, connectorStatus, realTimeMonitorData, transactionCode); CompletableFuture.runAsync(() -> { try { commonService.pushRealTimeInfo(pileSn, connectorCode, connectorStatus, realTimeMonitorData, transactionCode); } catch (Exception e) { log.error("统一推送第三方平台实时数据 error, ", e); - e.printStackTrace(); + } + }); + + // 异步推送第三方平台实时数据V2 + CompletableFuture.runAsync(() -> { + try { + commonService.pushRealTimeInfoV2(pileSn, connectorCode, connectorStatus, realTimeMonitorData, transactionCode); + } catch (Exception e) { + log.error("统一推送第三方平台实时数据V2 error, ", e); } }); diff --git a/jsowell-pile/src/main/java/com/jsowell/thirdparty/mapper/ThirdpartySecretInfoMapper.java b/jsowell-pile/src/main/java/com/jsowell/thirdparty/mapper/ThirdpartySecretInfoMapper.java index 430746292..55caadbbe 100644 --- a/jsowell-pile/src/main/java/com/jsowell/thirdparty/mapper/ThirdpartySecretInfoMapper.java +++ b/jsowell-pile/src/main/java/com/jsowell/thirdparty/mapper/ThirdpartySecretInfoMapper.java @@ -66,5 +66,10 @@ public interface ThirdpartySecretInfoMapper { ThirdPartySecretInfoVO queryByThirdPlatformType(String thirdPlatformType); + /** + * 根据站点id查询对接的第三方平台列表 + * @param stationId 站点id + * @return + */ List queryStationToPlatformList(String stationId); } 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 19661b09b..c3e7b6597 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 @@ -27,6 +27,7 @@ import com.jsowell.pile.dto.ThirdPartyCommonStopChargeDTO; import com.jsowell.pile.dto.lutongyunting.BindCouponDTO; import com.jsowell.pile.dto.ruanjie.UseCouponDTO; import com.jsowell.pile.service.*; +import com.jsowell.pile.vo.ThirdPartySecretInfoVO; import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO; import com.jsowell.pile.vo.huawei.QueryStartChargeVO; import com.jsowell.pile.vo.web.PileStationVO; @@ -39,11 +40,13 @@ import com.jsowell.thirdparty.platform.util.HttpRequestUtil; import com.jsowell.thirdparty.lutongyunting.service.LTYTService; import com.jsowell.thirdparty.nanrui.service.NRService; import com.jsowell.thirdparty.ruanjie.service.RJService; +import com.jsowell.thirdparty.service.ThirdpartySecretInfoService; import com.jsowell.thirdparty.xindiantu.service.XDTService; import com.jsowell.thirdparty.yongchengboche.dto.YCBCGetTokenDTO; import com.jsowell.thirdparty.yongchengboche.service.YCBCService; import com.jsowell.thirdparty.zhongdianlian.service.ZDLService; import lombok.extern.slf4j.Slf4j; +import lombok.val; import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -52,6 +55,7 @@ import java.io.UnsupportedEncodingException; import java.text.ParseException; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.concurrent.TimeUnit; /** @@ -115,6 +119,12 @@ public class CommonService { @Autowired private RedisCache redisCache; + @Autowired + private ThirdpartySecretInfoService thirdpartySecretInfoService; + + @Autowired + private NotificationService notificationService; + /** * 将站点--第三方平台类型对应关系存入关系表 * @param dto @@ -355,6 +365,49 @@ public class CommonService { } } + /** + * 推送实时数据到第三方平台 + * @param pileSn + * @param connectorCode + * @param connectorStatus + * @param realTimeMonitorData + * @param transactionCode + * @throws UnsupportedEncodingException + */ + public void pushRealTimeInfoV2(String pileSn, String connectorCode, String connectorStatus, + RealTimeMonitorData realTimeMonitorData, String transactionCode) throws UnsupportedEncodingException { + // 推送第三方平台,先通过桩编号查出站点信息 pushToThirdPartyPlatforms + PileBasicInfo pileBasicInfo = pileBasicInfoService.selectPileBasicInfoBySN(pileSn); + + String pileConnectorCode = pileSn + connectorCode; + // 将枪口状态转换成对接平台的状态 + String changedStatus = changeConnectorStatus(connectorStatus, realTimeMonitorData.getPutGunType()); + + String stationId = String.valueOf(pileBasicInfo.getStationId()); + // 查询该站点是否推送第三方平台 + List thirdPartySecretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId); + if (CollectionUtils.isEmpty(thirdPartySecretInfoVOS)) { + return; + } + + // 查询订单信息 + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByTransactionCode(transactionCode); + + // 推送 + for (ThirdPartySecretInfoVO thirdPartySecretInfoVO : thirdPartySecretInfoVOS) { + NotificationDTO dto = new NotificationDTO(); + dto.setStationId(stationId); + dto.setPileConnectorCode(pileConnectorCode); + dto.setStatus(changedStatus); + dto.setPlatformType(thirdPartySecretInfoVO.getPlatformType()); + if (Objects.nonNull(orderInfo)) { + dto.setOrderCode(orderInfo.getOrderCode()); + } + notificationService.notificationConnectorChargeStatus(dto); + } + + } + /** * 统一方法推送订单信息 From 63a65b4e727703a7a53ab9175b01bfbb08490c0d Mon Sep 17 00:00:00 2001 From: Guoqs <123@jsowell.com> Date: Fri, 10 May 2024 17:15:47 +0800 Subject: [PATCH 4/7] =?UTF-8?q?update=20=E6=8E=A8=E9=80=81=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../thirdparty/common/CommonService.java | 24 +++++++-- .../common/NotificationService.java | 49 +++++++++++-------- 2 files changed, 49 insertions(+), 24 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 c3e7b6597..856cd183c 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 @@ -392,6 +392,9 @@ public class CommonService { // 查询订单信息 OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByTransactionCode(transactionCode); + if (Objects.isNull(orderInfo)) { + return; + } // 推送 for (ThirdPartySecretInfoVO thirdPartySecretInfoVO : thirdPartySecretInfoVOS) { @@ -400,9 +403,7 @@ public class CommonService { dto.setPileConnectorCode(pileConnectorCode); dto.setStatus(changedStatus); dto.setPlatformType(thirdPartySecretInfoVO.getPlatformType()); - if (Objects.nonNull(orderInfo)) { - dto.setOrderCode(orderInfo.getOrderCode()); - } + dto.setOrderCode(orderInfo.getOrderCode()); notificationService.notificationConnectorChargeStatus(dto); } @@ -483,6 +484,23 @@ public class CommonService { } } + public void commonPushOrderInfoV2(OrderBasicInfo orderBasicInfo) { + String stationId = orderBasicInfo.getStationId(); + // 查询该站点是否推送第三方平台 + List relationInfoList = thirdpartySecretInfoService.queryStationToPlatformList(stationId); + // ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(relation); + if (CollectionUtils.isEmpty(relationInfoList)) { + return; + } + for (ThirdPartySecretInfoVO relationVO : relationInfoList) { + NotificationDTO dto = new NotificationDTO(); + dto.setStationId(stationId); + dto.setPlatformType(relationVO.getPlatformType()); + dto.setOrderCode(orderBasicInfo.getOrderCode()); + notificationService.notificationChargeOrderInfo(dto); + } + } + /** * 统一推送启动充电结果 diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/NotificationService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/NotificationService.java index 91a6e9b17..90f9251a5 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/NotificationService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/NotificationService.java @@ -33,10 +33,12 @@ public class NotificationService { * notification_stationInfo */ public void notificationStationInfo(NotificationDTO dto) { - if (StringUtils.isBlank(dto.getStationId())) { + String stationId = dto.getStationId(); + String platformType = dto.getPlatformType(); + + if (StringUtils.isBlank(stationId)) { throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); } - String stationId = dto.getStationId(); // 通过stationId 查询该站点需要对接的平台配置 List secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId); if (CollectionUtils.isEmpty(secretInfoVOS)) { @@ -44,13 +46,12 @@ public class NotificationService { } // 调用相应平台的处理方法 for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) { - if (StringUtils.isNotBlank(dto.getPlatformType()) && !StringUtils.equals(dto.getPlatformType(), secretInfoVO.getPlatformType())) { + if (StringUtils.isNotBlank(platformType) && !StringUtils.equals(platformType, secretInfoVO.getPlatformType())) { // 如果dto中的platformType不为空,并且不等于secretInfoVO.getPlatformType(),continue continue; } try { ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType()); - // platformService.printServiceName(); platformService.notificationStationInfo(stationId); } catch (Exception e) { logger.error("充电站信息变化推送error", e); @@ -63,12 +64,14 @@ public class NotificationService { * notification_stationStatus */ public void notificationStationStatus(NotificationDTO dto) { - if (StringUtils.isBlank(dto.getStationId()) || StringUtils.isBlank(dto.getPileConnectorCode()) || StringUtils.isBlank(dto.getStatus())) { - throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); - } String stationId = dto.getStationId(); String pileConnectorCode = dto.getPileConnectorCode(); String status = dto.getStatus(); + String platformType = dto.getPlatformType(); + + if (StringUtils.isBlank(stationId) || StringUtils.isBlank(pileConnectorCode) || StringUtils.isBlank(status)) { + throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); + } // 通过stationId 查询该站点需要对接的平台配置 List secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId); if (CollectionUtils.isEmpty(secretInfoVOS)) { @@ -76,7 +79,7 @@ public class NotificationService { } // 调用相应平台的处理方法 for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) { - if (StringUtils.isNotBlank(dto.getPlatformType()) && !StringUtils.equals(dto.getPlatformType(), secretInfoVO.getPlatformType())) { + if (StringUtils.isNotBlank(platformType) && !StringUtils.equals(platformType, secretInfoVO.getPlatformType())) { // 如果dto中的platformType不为空,并且不等于secretInfoVO.getPlatformType(),continue continue; } @@ -96,11 +99,12 @@ public class NotificationService { * notification_equip_charge_status */ public void notificationConnectorChargeStatus(NotificationDTO dto) { - if (StringUtils.isBlank(dto.getStationId()) || StringUtils.isBlank(dto.getOrderCode())) { - throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); - } String stationId = dto.getStationId(); String orderCode = dto.getOrderCode(); + String platformType = dto.getPlatformType(); + if (StringUtils.isBlank(stationId) || StringUtils.isBlank(orderCode)) { + throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); + } // 通过stationId 查询该站点需要对接的平台配置 List secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId); if (CollectionUtils.isEmpty(secretInfoVOS)) { @@ -108,7 +112,7 @@ public class NotificationService { } // 调用相应平台的处理方法 for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) { - if (StringUtils.isNotBlank(dto.getPlatformType()) && !StringUtils.equals(dto.getPlatformType(), secretInfoVO.getPlatformType())) { + if (StringUtils.isNotBlank(platformType) && !StringUtils.equals(platformType, secretInfoVO.getPlatformType())) { // 如果dto中的platformType不为空,并且不等于secretInfoVO.getPlatformType(),continue continue; } @@ -127,11 +131,12 @@ public class NotificationService { * notification_orderInfo/notification_charge_order_info */ public void notificationChargeOrderInfo(NotificationDTO dto) { - if (StringUtils.isBlank(dto.getStationId()) || StringUtils.isBlank(dto.getOrderCode())) { - throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); - } String stationId = dto.getStationId(); String orderCode = dto.getOrderCode(); + String platformType = dto.getPlatformType(); + if (StringUtils.isBlank(stationId) || StringUtils.isBlank(orderCode)) { + throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); + } // 通过stationId 查询该站点需要对接的平台配置 List secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId); if (CollectionUtils.isEmpty(secretInfoVOS)) { @@ -139,7 +144,7 @@ public class NotificationService { } // 调用相应平台的处理方法 for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) { - if (StringUtils.isNotBlank(dto.getPlatformType()) && !StringUtils.equals(dto.getPlatformType(), secretInfoVO.getPlatformType())) { + if (StringUtils.isNotBlank(platformType) && !StringUtils.equals(platformType, secretInfoVO.getPlatformType())) { // 如果dto中的platformType不为空,并且不等于secretInfoVO.getPlatformType(),continue continue; } @@ -148,7 +153,7 @@ public class NotificationService { ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType()); platformService.notificationChargeOrderInfo(orderCode, secretInfoVO); } catch (Exception e) { - logger.error("设备充电中状态变化推送error", e); + logger.error("充电订单信息推送error", e); } } } @@ -158,10 +163,12 @@ public class NotificationService { * notification_stationFee */ public void notificationStationFee(NotificationDTO dto) { - if (StringUtils.isBlank(dto.getStationId())) { + String stationId = dto.getStationId(); + String platformType = dto.getPlatformType(); + + if (StringUtils.isBlank(stationId)) { throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); } - String stationId = dto.getStationId(); // 通过stationId 查询该站点需要对接的平台配置 List secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId); if (CollectionUtils.isEmpty(secretInfoVOS)) { @@ -169,7 +176,7 @@ public class NotificationService { } // 调用相应平台的处理方法 for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) { - if (StringUtils.isNotBlank(dto.getPlatformType()) && !StringUtils.equals(dto.getPlatformType(), secretInfoVO.getPlatformType())) { + if (StringUtils.isNotBlank(platformType) && !StringUtils.equals(platformType, secretInfoVO.getPlatformType())) { // 如果dto中的platformType不为空,并且不等于secretInfoVO.getPlatformType(),continue continue; } @@ -178,7 +185,7 @@ public class NotificationService { ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType()); platformService.notificationStationFee(stationId, secretInfoVO); } catch (Exception e) { - logger.error("设备充电中状态变化推送error", e); + logger.error("站点费率变化推送error", e); } } } From 2221f6ae62e2f2dd1fa18162568038417cf35b76 Mon Sep 17 00:00:00 2001 From: Guoqs <123@jsowell.com> Date: Fri, 10 May 2024 17:17:55 +0800 Subject: [PATCH 5/7] =?UTF-8?q?update=20=E6=8E=A8=E9=80=81=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../thirdparty/ThirdPartyPlatformConfigController.java | 2 +- .../controller/thirdparty/ThirdPartySettingInfoController.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/ThirdPartyPlatformConfigController.java b/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/ThirdPartyPlatformConfigController.java index e52661d01..2e749befa 100644 --- a/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/ThirdPartyPlatformConfigController.java +++ b/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/ThirdPartyPlatformConfigController.java @@ -24,7 +24,7 @@ import com.jsowell.common.core.page.TableDataInfo; /** * 对接平台配置信息Controller - * + * @deprecated 平台密钥信息整合到Thirdparty_Secret_Info * @author jsowell * @date 2023-05-27 */ diff --git a/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/ThirdPartySettingInfoController.java b/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/ThirdPartySettingInfoController.java index 1df4ccbf8..185e390c9 100644 --- a/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/ThirdPartySettingInfoController.java +++ b/jsowell-admin/src/main/java/com/jsowell/web/controller/thirdparty/ThirdPartySettingInfoController.java @@ -24,7 +24,7 @@ import com.jsowell.common.core.page.TableDataInfo; /** * 第三方平台配置Controller - * + * @deprecated 平台密钥信息整合到Thirdparty_Secret_Info * @author jsowell * @date 2023-11-29 */ From 3c4a87a1c26d62ca709dca3e3968293b0e3adce6 Mon Sep 17 00:00:00 2001 From: Guoqs <123@jsowell.com> Date: Sat, 11 May 2024 16:20:20 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=85=85=E7=94=B5=E7=AB=99=E4=BF=A1=E6=81=AF=E5=88=97=E8=A1=A8?= =?UTF-8?q?(=E4=B8=BB=E9=A1=B5)=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/PileStationInfoServiceImpl.java | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java index 21d7119b6..fd079d0b8 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java @@ -1,6 +1,8 @@ package com.jsowell.pile.service.impl; import cn.hutool.core.util.PageUtil; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import com.google.common.collect.Lists; import com.jsowell.common.constant.CacheConstants; import com.jsowell.common.constant.Constants; @@ -450,20 +452,22 @@ public class PileStationInfoServiceImpl implements PileStationInfoService { */ @Override public PageResponse uniAppQueryStationInfoList(QueryStationDTO dto) { - long pageNum = dto.getPageNum() == 0 ? 1L : dto.getPageNum(); - long pageSize = dto.getPageSize() == 0 ? 10L : dto.getPageSize(); + int pageNum = dto.getPageNum() == 0 ? 1 : dto.getPageNum(); + int pageSize = dto.getPageSize() == 0 ? 10 : dto.getPageSize(); // 小程序站点列表页只展示对外开放的站点 dto.setPublicFlag(Constants.ONE); // 根据前台参数分页 + PageHelper.startPage(pageNum, pageSize); List list = pileStationInfoMapper.queryStationInfos(dto); + PageInfo pageInfo = new PageInfo<>(list); List stationVOList = Lists.newArrayList(); - StationInfoVO stationVO = null; + StationInfoVO stationVO; String stationLng = dto.getStationLng(); String stationLat = dto.getStationLat(); double distance = 0d; - for (PileStationVO pileStationVO : list) { + for (PileStationVO pileStationVO : pageInfo.getList()) { stationVO = new StationInfoVO(); if (StringUtils.isNotEmpty(stationLng) && StringUtils.isNotEmpty(stationLat)) { try{ @@ -491,11 +495,10 @@ public class PileStationInfoServiceImpl implements PileStationInfoService { stationVO.setStationImgList(Lists.newArrayList(pileStationVO.getPictures().split(","))); } + // 查询快慢充数量 Map map = pileConnectorInfoService.getPileTypeNum(Long.parseLong(pileStationVO.getId())); - Integer fastFree = map.get("fastFree"); Integer slowFree = map.get("slowFree"); - stationVO.setFastTotal(map.get("fastTotal")); stationVO.setFastFree(fastFree); stationVO.setSlowTotal(map.get("slowTotal")); @@ -526,21 +529,16 @@ public class PileStationInfoServiceImpl implements PileStationInfoService { return a.compareTo(b); }); } - List collect = stationVOList.stream() - .skip((pageNum - 1) * pageSize) - .limit(pageSize) - .collect(Collectors.toList()); - int total = stationVOList.size(); - int pages = PageUtil.totalPage(total, dto.getPageSize()); // 返回结果集 - return PageResponse.builder() - .pageNum(Integer.parseInt(String.valueOf(pageNum))) - .pageSize(Integer.parseInt(String.valueOf(pageSize))) - .list(collect) - .pages(pages) - .total(total) + PageResponse pageResponse = PageResponse.builder() + .pageNum(pageInfo.getPageNum()) + .pageSize(pageInfo.getPageSize()) + .list(stationVOList) + .pages(pageInfo.getPages()) + .total(pageInfo.getTotal()) .build(); + return pageResponse; } /** From 6ed6c63748c639802282a815df37c0d5495b03fe Mon Sep 17 00:00:00 2001 From: Guoqs <123@jsowell.com> Date: Mon, 13 May 2024 10:57:37 +0800 Subject: [PATCH 7/7] update --- .../com/jsowell/netty/handler/ChargeEndHandler.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/handler/ChargeEndHandler.java b/jsowell-netty/src/main/java/com/jsowell/netty/handler/ChargeEndHandler.java index 997312fde..50ca92a3f 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/handler/ChargeEndHandler.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/handler/ChargeEndHandler.java @@ -101,18 +101,10 @@ public class ChargeEndHandler extends AbstractHandler{ length = 4; byte[] pileChargedCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); - // 查询订单,改为待结算 将结束soc传入 + // 查询订单 将结束soc传入 OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByTransactionCode(transactionCode); if (Objects.nonNull(orderInfo)) { Date nowDate = DateUtils.getNowDate(); // 当前时间 - // if (StringUtils.equals(OrderStatusEnum.IN_THE_CHARGING.getValue(), orderInfo.getOrderStatus())) { - // orderInfo.setOrderStatus(OrderStatusEnum.STAY_SETTLEMENT.getValue()); - // } - // orderInfo.setEndSoc(stopSoc); - // if (orderInfo.getChargeEndTime() == null) { - // orderInfo.setChargeEndTime(nowDate); // 结束充电时间 - // } - // orderBasicInfoService.updateOrderBasicInfo(orderInfo); // 只更新个别字段 OrderBasicInfo updateOrder = new OrderBasicInfo();