diff --git a/jsowell-admin/src/test/java/SpringBootTestController.java b/jsowell-admin/src/test/java/SpringBootTestController.java index 114ad3bf9..94941d3a3 100644 --- a/jsowell-admin/src/test/java/SpringBootTestController.java +++ b/jsowell-admin/src/test/java/SpringBootTestController.java @@ -71,6 +71,7 @@ import com.jsowell.service.OrderService; import com.jsowell.service.PileService; import com.jsowell.service.TempService; import com.jsowell.thirdparty.amap.service.AMapService; +import com.jsowell.thirdparty.common.NotificationService; import com.jsowell.thirdparty.huawei.HuaWeiService; import com.jsowell.thirdparty.lianlian.service.LianLianService; import com.jsowell.thirdparty.lutongyunting.service.LTYTService; @@ -247,6 +248,15 @@ public class SpringBootTestController { @Autowired private HuaWeiService huaWeiService; + @Autowired + private NotificationService notificationService; + + @Test + public void notificationStationInfoTest() { + String stationId = "19"; + notificationService.notificationStationInfo(stationId); + } + @Test public void queryBillingPriceTest() { String stationId = "19"; diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/vo/ThirdPartySecretInfoVO.java b/jsowell-pile/src/main/java/com/jsowell/pile/vo/ThirdPartySecretInfoVO.java index 33e8e6ffe..09c68f02a 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/vo/ThirdPartySecretInfoVO.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/vo/ThirdPartySecretInfoVO.java @@ -9,36 +9,68 @@ import lombok.Setter; @Getter @Setter public class ThirdPartySecretInfoVO { - // 我方的组织机构代码 + /** + * 我方的组织机构代码 + */ private String ourOperatorId; - // 我方生成的唯一识别密钥 + /** + * 我方生成的唯一识别密钥 + */ private String ourOperatorSecret; - // 我方生成的消息密钥 + /** + * 我方生成的消息密钥 + */ private String ourDataSecret; - // 我方生成的初始化向量 + /** + * 我方生成的初始化向量 + */ private String ourDataSecretIv; - // 我方生成的签名密钥 + /** + * 我方生成的签名密钥 + */ private String ourSigSecret; - // 对接平台的组织机构代码 + /** + * 对接平台名称 + */ + private String platformName; + + /** + * 对接平台类型 {@link com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum} + */ + private String platformType; + + /** + * 对接平台的组织机构代码 + */ private String theirOperatorId; - // 对接平台生成的唯一识别密钥 + /** + * 对接平台生成的唯一识别密钥 + */ private String theirOperatorSecret; - // 对接平台生成的消息密钥 + /** + * 对接平台生成的消息密钥 + */ private String theirDataSecret; - // 对接平台的初始化向量 + /** + * 对接平台的初始化向量 + */ private String theirDataSecretIv; - // 对接平台生成的签名密钥 + /** + * 对接平台生成的签名密钥 + */ private String theirSigSecret; - // 对接平台接口前缀 + /** + * 对接平台接口前缀 + */ private String theirUrlPrefix; } 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 e984b5134..430746292 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 @@ -65,4 +65,6 @@ public interface ThirdpartySecretInfoMapper { ThirdPartySecretInfoVO queryByOperatorId(String theirOperatorId); ThirdPartySecretInfoVO queryByThirdPlatformType(String thirdPlatformType); + + List queryStationToPlatformList(String stationId); } diff --git a/jsowell-pile/src/main/java/com/jsowell/thirdparty/service/ThirdpartySecretInfoService.java b/jsowell-pile/src/main/java/com/jsowell/thirdparty/service/ThirdpartySecretInfoService.java index e12c6eb8a..4a50758fd 100644 --- a/jsowell-pile/src/main/java/com/jsowell/thirdparty/service/ThirdpartySecretInfoService.java +++ b/jsowell-pile/src/main/java/com/jsowell/thirdparty/service/ThirdpartySecretInfoService.java @@ -60,7 +60,24 @@ public interface ThirdpartySecretInfoService { */ public int deleteThirdpartySecretInfoById(Long id); + /** + * 通过组织结构代码,查询平台密钥配置信息 + * @param theirOperatorId 组织结构代码 + * @return + */ ThirdPartySecretInfoVO queryByOperatorId(String theirOperatorId); + /** + * 通过第三方平台类型,查询平台密钥配置信息 + * @param thirdPlatformType 第三方平台类型 {@link com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum} + * @return + */ ThirdPartySecretInfoVO queryByThirdPlatformType(String thirdPlatformType); + + /** + * 查询站点对接第三方平台信息列表 + * @param stationId 站点id + * @return + */ + List queryStationToPlatformList(String stationId); } diff --git a/jsowell-pile/src/main/java/com/jsowell/thirdparty/service/impl/ThirdpartySecretInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/thirdparty/service/impl/ThirdpartySecretInfoServiceImpl.java index 7bc2ea09b..bcf1978c6 100644 --- a/jsowell-pile/src/main/java/com/jsowell/thirdparty/service/impl/ThirdpartySecretInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/thirdparty/service/impl/ThirdpartySecretInfoServiceImpl.java @@ -127,4 +127,10 @@ public class ThirdpartySecretInfoServiceImpl implements ThirdpartySecretInfoServ } return result; } + + @Override + public List queryStationToPlatformList(String stationId) { + List list = thirdpartySecretInfoMapper.queryStationToPlatformList(stationId); + return list; + } } diff --git a/jsowell-pile/src/main/resources/mapper/thirdparty/ThirdpartySecretInfoMapper.xml b/jsowell-pile/src/main/resources/mapper/thirdparty/ThirdpartySecretInfoMapper.xml index 0ff1ad50a..b6e6ddf31 100644 --- a/jsowell-pile/src/main/resources/mapper/thirdparty/ThirdpartySecretInfoMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/thirdparty/ThirdpartySecretInfoMapper.xml @@ -138,6 +138,8 @@ + + \ No newline at end of file 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 new file mode 100644 index 000000000..4bb779a64 --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/NotificationService.java @@ -0,0 +1,85 @@ +package com.jsowell.thirdparty.common; + +import com.jsowell.pile.vo.ThirdPartySecretInfoVO; +import com.jsowell.thirdparty.platform.ThirdPartyPlatformService; +import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory; +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.util.List; + +/** + * 主动通知Service + * 说明:创建此接口目的是为了简化开发 + * 在需要通知第三方平台的地方,异步调用此类中对应的方法 + * 通知方法中应该根据对接平台,自动找到响应的平台处理逻辑 + */ +@Service +public class NotificationService { + + @Autowired + private ThirdpartySecretInfoService thirdpartySecretInfoService; + + /** + * 充电站信息变化推送 + * notification_stationInfo + */ + public void notificationStationInfo(String stationId) { + // 通过stationId 查询该站点需要对接的平台配置 + List secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId); + if (CollectionUtils.isEmpty(secretInfoVOS)) { + return; + } + // 调用相应平台的处理方法 + for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) { + ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType()); + // platformService.printServiceName(); + platformService.notificationStationInfo(stationId); + } + } + + /** + * 设备状态变化推送 + * notification_stationStatus + */ + public void notificationStationStatus(String stationId, String pileConnectorCode, String status) { + // 通过stationId 查询该站点需要对接的平台配置 + List secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId); + if (CollectionUtils.isEmpty(secretInfoVOS)) { + return; + } + // 调用相应平台的处理方法 + for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) { + // 根据平台类型获取Service + ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType()); + platformService.notificationStationStatus(stationId, pileConnectorCode, status, secretInfoVO); + } + } + + /** + * 设备充电中状态变化推送 + * notification_connector_charge_status + * notification_equip_charge_status + */ + public void notificationConnectorChargeStatus() { + + } + + /** + * 订单信息推送 + * notification_orderInfo/notification_charge_order_info + */ + public void notificationOrderInfo() { + + } + + /** + * 站点费率变化推送 + * notification_stationFee + */ + public void notificationStationFee() { + + } +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/ThirdPartyPlatformService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/ThirdPartyPlatformService.java index 11200b4e1..8948d6aef 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/ThirdPartyPlatformService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/ThirdPartyPlatformService.java @@ -10,11 +10,13 @@ import com.jsowell.common.util.StringUtils; import com.jsowell.pile.dto.*; import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryStationInfoDTO; import com.jsowell.pile.thirdparty.CommonParamsDTO; +import com.jsowell.pile.vo.ThirdPartySecretInfoVO; import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO; import com.jsowell.thirdparty.lianlian.vo.LianLianResultVO; import com.jsowell.thirdparty.platform.util.Cryptos; import com.jsowell.thirdparty.platform.util.Encodes; import com.jsowell.thirdparty.platform.util.GBSignUtils; +import org.springframework.beans.factory.InitializingBean; import java.nio.charset.StandardCharsets; import java.util.*; @@ -24,7 +26,10 @@ import java.util.*; * 说明:此接口中的方法可以选择性实现,具体看要对接的第三方平台需要什么方法 * 所有的方法默认抛出未实现异常,在三方平台实现类中未覆盖的话,掉用会抛异常,注意处理异常 */ -public interface ThirdPartyPlatformService { +public interface ThirdPartyPlatformService extends InitializingBean { + default void printServiceName() { + throw new UnsupportedOperationException("This method is not yet implemented"); + } /** * query_token 获取token,提供给第三方平台使用 @@ -210,8 +215,11 @@ public interface ThirdPartyPlatformService { } /** - * 设备状态变化推送 notification_stationStatus - * 推送充电设备接口状态信息 supervise_notification_station_status + * 设备状态变化推送 + * 概述:当设备状态发生变化时,推送最新的状态到合作方 + * 接口定义: + * 中电联平台 设备状态变化推送 notification_stationStatus + * 内蒙古平台 推送充电设备接口状态信息 supervise_notification_station_status * * @param dto * @throws UnsupportedOperationException 未实现异常 @@ -220,6 +228,21 @@ public interface ThirdPartyPlatformService { throw new UnsupportedOperationException("This method is not yet implemented"); } + /** + * 设备状态变化推送 + * 概述:当设备状态发生变化时,推送最新的状态到合作方 + * 接口定义: + * 中电联平台 设备状态变化推送 notification_stationStatus + * 内蒙古平台 推送充电设备接口状态信息 supervise_notification_station_status + * + * @param stationId 站点id + * @param pileConnectorCode 充电桩枪口编号 + * @throws UnsupportedOperationException 未实现异常 + */ + default String notificationStationStatus(String stationId, String pileConnectorCode, String status, ThirdPartySecretInfoVO secretInfoVO) { + throw new UnsupportedOperationException("This method is not yet implemented"); + } + /** * 设备充电中状态变化推送 notification_connector_charge_status * 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 new file mode 100644 index 000000000..6e718185a --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/factory/ThirdPartyPlatformFactory.java @@ -0,0 +1,38 @@ +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 java.util.Map; +import java.util.Objects; + +/** + * 工厂设计模式 + * 云快充操作 + */ +public class ThirdPartyPlatformFactory { + + private static Map serviceMap = Maps.newHashMap(); + + /** + * 注册 + * @param str + * @param service + */ + public static void register(String str, ThirdPartyPlatformService service) { + if (StringUtils.isBlank(str) || Objects.isNull(service)) { + return; + } + serviceMap.put(str, service); + } + + /** + * 获取 + * @param type + * @return + */ + public static ThirdPartyPlatformService getInvokeStrategy(String type) { + return serviceMap.get(type); + } +} 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/hainan/service/HaiNanPlatformServiceImpl.java index 11663dd11..321ac5bc0 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/hainan/service/HaiNanPlatformServiceImpl.java @@ -21,6 +21,7 @@ import com.jsowell.pile.domain.*; import com.jsowell.pile.domain.ykcCommond.StartChargingCommand; import com.jsowell.pile.dto.*; import com.jsowell.pile.service.*; +import com.jsowell.pile.thirdparty.ZDLEquipmentInfo; import com.jsowell.pile.vo.base.ConnectorInfoVO; import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO; import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO; @@ -29,24 +30,24 @@ import com.jsowell.pile.vo.uniapp.BillingPriceVO; import com.jsowell.pile.vo.web.BillingTemplateVO; import com.jsowell.pile.vo.web.EchoBillingTemplateVO; import com.jsowell.pile.vo.web.PileConnectorInfoVO; -import com.jsowell.pile.vo.web.PileStationVO; import com.jsowell.pile.vo.zdl.EquipBusinessPolicyVO; import com.jsowell.thirdparty.lianlian.domain.*; -import com.jsowell.thirdparty.platform.util.Cryptos; -import com.jsowell.thirdparty.platform.util.Encodes; -import com.jsowell.thirdparty.platform.util.GBSignUtils; -import com.jsowell.thirdparty.platform.util.HttpRequestUtil; 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.factory.ThirdPartyPlatformFactory; import com.jsowell.thirdparty.platform.hainan.domain.HNStationInfo; -import com.jsowell.pile.thirdparty.ZDLEquipmentInfo; +import com.jsowell.thirdparty.platform.util.Cryptos; +import com.jsowell.thirdparty.platform.util.Encodes; +import com.jsowell.thirdparty.platform.util.GBSignUtils; +import com.jsowell.thirdparty.platform.util.HttpRequestUtil; 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; @@ -70,7 +71,7 @@ import java.util.stream.Collectors; public class HaiNanPlatformServiceImpl implements ThirdPartyPlatformService { Logger logger = LoggerFactory.getLogger(HaiNanPlatformServiceImpl.class); // 平台类型 - private final String platformType = ThirdPlatformTypeEnum.HAI_NAN_1_PLATFORM.getTypeCode(); + private final String thirdPlatformType = ThirdPlatformTypeEnum.HAI_NAN_1_PLATFORM.getTypeCode(); @Autowired private PileMerchantInfoService pileMerchantInfoService; @@ -108,10 +109,24 @@ public class HaiNanPlatformServiceImpl implements ThirdPartyPlatformService { @Autowired private ZDLService zdlService; - // @Override - // public void afterPropertiesSet() throws Exception { - // InterfaceWithPlatformLogicFactory.register(platformType, this); - // } + /** + * Invoked by the containing {@code BeanFactory} after it has set all bean properties + * and satisfied {@link BeanFactoryAware}, {@code ApplicationContextAware} etc. + *

This method allows the bean instance to perform validation of its overall + * configuration and final initialization when all bean properties have been set. + * + * @throws Exception in the event of misconfiguration (such as failure to set an + * essential property) or if initialization fails for any other reason + */ + @Override + public void afterPropertiesSet() throws Exception { + ThirdPartyPlatformFactory.register(thirdPlatformType, this); + } + + @Override + public void printServiceName() { + System.out.println("当前类名:" + this.getClass().getSimpleName()); + } public String pushStationInfoV2(PushStationInfoDTO dto) { return zdlService.pushStationInfoV2(dto); @@ -994,4 +1009,5 @@ public class HaiNanPlatformServiceImpl implements ThirdPartyPlatformService { return result; } + } 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/lianlian/service/LianLianPlatformServiceImpl.java index 568087e3a..f328b0376 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/lianlian/service/LianLianPlatformServiceImpl.java @@ -41,6 +41,7 @@ import com.jsowell.thirdparty.platform.ThirdPartyPlatformService; import com.jsowell.thirdparty.platform.common.ChargeDetail; import com.jsowell.thirdparty.platform.common.OrderInfo; import com.jsowell.thirdparty.platform.common.StationInfo; +import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory; import com.jsowell.thirdparty.platform.util.*; import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -55,7 +56,7 @@ import java.util.stream.Collectors; @Service public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService { // 平台类型 - private final String platformType = ThirdPlatformTypeEnum.LIAN_LIAN_PLATFORM.getTypeCode(); + private final String thirdPlatformType = ThirdPlatformTypeEnum.LIAN_LIAN_PLATFORM.getTypeCode(); @Autowired private PileMerchantInfoService pileMerchantInfoService; @@ -84,11 +85,24 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService { @Resource private ThirdPartyStationRelationService thirdPartyStationRelationService; + /** + * Invoked by the containing {@code BeanFactory} after it has set all bean properties + * and satisfied {@link BeanFactoryAware}, {@code ApplicationContextAware} etc. + *

This method allows the bean instance to perform validation of its overall + * configuration and final initialization when all bean properties have been set. + * + * @throws Exception in the event of misconfiguration (such as failure to set an + * essential property) or if initialization fails for any other reason + */ + @Override + public void afterPropertiesSet() throws Exception { + ThirdPartyPlatformFactory.register(thirdPlatformType, this); + } - // @Override - // public void afterPropertiesSet() throws Exception { - // InterfaceWithPlatformLogicFactory.register(platformType, this); - // } + @Override + public void printServiceName() { + System.out.println("当前类名:" + this.getClass().getSimpleName()); + } // @Override public Map queryTokenOld(CommonParamsDTO dto) { @@ -469,7 +483,7 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService { PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(Long.parseLong(stationId)); // 通过第三方配置类型查询相关配置信息 ThirdPartySettingInfo settingInfo = new ThirdPartySettingInfo(); - settingInfo.setType(platformType); + settingInfo.setType(thirdPlatformType); ThirdPartySettingInfo thirdPartySettingInfo = thirdPartySettingInfoService.selectSettingInfo(settingInfo); String operatorId = thirdPartySettingInfo.getOperatorId(); @@ -519,7 +533,7 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService { info.setAreaCode(subAreaCode); // 截取运营商组织机构代码(去除最后一位后的最后九位) String organizationCode = ""; - if (StringUtils.equals(ThirdPlatformTypeEnum.LIAN_LIAN_PLATFORM.getTypeCode(), platformType)) { + if (StringUtils.equals(ThirdPlatformTypeEnum.LIAN_LIAN_PLATFORM.getTypeCode(), thirdPlatformType)) { // 联联平台先使用自己运营商的组织机构代码 organizationCode = Constants.OPERATORID_LIANLIAN; info.setEquipmentOwnerID(organizationCode); @@ -575,8 +589,8 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService { , dataSecretIv, operatorId, signSecret); // 新增数据库 - thirdPartyStationRelationService.insertInfo2DataBase(platformType, stationId); - return platformType + ":" + result; + thirdPartyStationRelationService.insertInfo2DataBase(thirdPlatformType, stationId); + return thirdPlatformType + ":" + result; } /** @@ -967,4 +981,5 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService { return resultMap; } + } 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/neimenggu/service/NeiMengGuPlatformServiceImpl.java index d41f4b7f9..708a856e0 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/neimenggu/service/NeiMengGuPlatformServiceImpl.java @@ -41,6 +41,7 @@ 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.factory.ThirdPartyPlatformFactory; import com.jsowell.thirdparty.platform.neimenggu.domain.ChargeOrderInfo; import com.jsowell.thirdparty.platform.neimenggu.domain.SupChargeDetails; import com.jsowell.thirdparty.platform.neimenggu.domain.SupOperatorInfo; @@ -97,6 +98,19 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { @Autowired private PileBillingTemplateService pileBillingTemplateService; + @Override + public void afterPropertiesSet() throws Exception { + ThirdPartyPlatformFactory.register(thirdPlatformType, this); + } + + /** + * @return + */ + @Override + public void printServiceName() { + System.out.println("当前类名:" + this.getClass().getSimpleName()); + } + /** * query_token 获取token,提供给第三方平台使用 * @@ -338,7 +352,6 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { */ @Override public String notificationStationStatus(PushRealTimeInfoDTO dto) { - String thirdPartyType = dto.getThirdPartyType(); String status = dto.getStatus(); String pileConnectorCode = dto.getPileConnectorCode(); @@ -372,6 +385,30 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { return result; } + @Override + public String notificationStationStatus(String stationId, String pileConnectorCode, String status, ThirdPartySecretInfoVO secretInfoVO) { + 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 + 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; + } + /** * 充电订单推送 notification_charge_order_info * @@ -651,4 +688,6 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { } return resultList; } + + } 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/qinghai/service/QingHaiPlatformServiceImpl.java index 91ac2370a..923e5d6f7 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/qinghai/service/QingHaiPlatformServiceImpl.java @@ -3,22 +3,22 @@ package com.jsowell.thirdparty.platform.qinghai.service; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; 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.OrderStatusEnum; -import com.jsowell.common.enums.ykc.PayModeEnum; import com.jsowell.common.enums.ykc.ReturnCodeEnum; import com.jsowell.common.exception.BusinessException; import com.jsowell.common.util.DateUtils; import com.jsowell.common.util.PageUtils; import com.jsowell.common.util.StringUtils; import com.jsowell.pile.domain.*; -import com.jsowell.pile.dto.*; +import com.jsowell.pile.dto.PushRealTimeInfoDTO; +import com.jsowell.pile.dto.QueryConnectorListDTO; +import com.jsowell.pile.dto.QueryStartChargeDTO; +import com.jsowell.pile.dto.QueryStationInfoDTO; import com.jsowell.pile.service.*; import com.jsowell.pile.thirdparty.ZDLEquipmentInfo; import com.jsowell.pile.thirdparty.ZDLStationInfo; @@ -28,15 +28,13 @@ import com.jsowell.pile.vo.uniapp.BillingPriceVO; import com.jsowell.pile.vo.uniapp.OrderVO; import com.jsowell.pile.vo.web.PileConnectorInfoVO; import com.jsowell.pile.vo.web.PileMerchantInfoVO; -import com.jsowell.pile.vo.web.PileStationVO; import com.jsowell.pile.vo.zdl.EquipBusinessPolicyVO; import com.jsowell.thirdparty.lianlian.domain.ConnectorStatusInfo; -import com.jsowell.thirdparty.lianlian.vo.QueryChargingStatusVO; import com.jsowell.thirdparty.platform.ThirdPartyPlatformService; import com.jsowell.thirdparty.platform.common.ChargeOrderInfo; import com.jsowell.thirdparty.platform.common.ConnectorChargeStatusInfo; import com.jsowell.thirdparty.platform.common.SupStationPowerInfo; -import com.jsowell.thirdparty.platform.hainan.domain.HNStationInfo; +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.GBSignUtils; @@ -44,14 +42,13 @@ import com.jsowell.thirdparty.platform.util.HttpRequestUtil; 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; import javax.annotation.Resource; import java.math.BigDecimal; -import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -92,9 +89,28 @@ public class QingHaiPlatformServiceImpl implements ThirdPartyPlatformService { Logger logger = LoggerFactory.getLogger(QingHaiPlatformServiceImpl.class); // 平台类型 - private final String platformType = ThirdPlatformTypeEnum.QING_HAI_PLATFORM.getTypeCode(); + private final String thirdPlatformType = ThirdPlatformTypeEnum.QING_HAI_PLATFORM.getTypeCode(); + /** + * Invoked by the containing {@code BeanFactory} after it has set all bean properties + * and satisfied {@link BeanFactoryAware}, {@code ApplicationContextAware} etc. + *

This method allows the bean instance to perform validation of its overall + * configuration and final initialization when all bean properties have been set. + * + * @throws Exception in the event of misconfiguration (such as failure to set an + * essential property) or if initialization fails for any other reason + */ + @Override + public void afterPropertiesSet() throws Exception { + ThirdPartyPlatformFactory.register(thirdPlatformType, this); + } + + @Override + public void printServiceName() { + System.out.println("当前类名:" + this.getClass().getSimpleName()); + } + /** * 查询站点信息 query_stations_info * @param dto 查询站点信息dto @@ -593,4 +609,5 @@ public class QingHaiPlatformServiceImpl implements ThirdPartyPlatformService { return resultMap; } + } 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/zhongdianlian/service/ZhongDianLianPlatformServiceImpl.java index 619d97275..2558376ef 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/zhongdianlian/service/ZhongDianLianPlatformServiceImpl.java @@ -1,6 +1,7 @@ package com.jsowell.thirdparty.platform.zhongdianlian.service; import com.alibaba.fastjson2.JSON; +import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; import com.jsowell.common.util.JWTUtils; import com.jsowell.common.util.StringUtils; import com.jsowell.pile.service.ThirdPartyPlatformConfigService; @@ -8,6 +9,7 @@ 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.factory.ThirdPartyPlatformFactory; import com.jsowell.thirdparty.platform.util.Cryptos; import com.jsowell.thirdparty.platform.util.ThirdPartyPlatformUtils; import com.jsowell.thirdparty.service.ThirdpartySecretInfoService; @@ -18,6 +20,8 @@ import java.util.Map; @Service public class ZhongDianLianPlatformServiceImpl implements ThirdPartyPlatformService { + // 平台类型 + private final String thirdPlatformType = ThirdPlatformTypeEnum.ZHONG_DIAN_LIAN_PLATFORM.getTypeCode(); @Autowired private ThirdPartyPlatformConfigService thirdPartyPlatformConfigService; @@ -25,6 +29,25 @@ public class ZhongDianLianPlatformServiceImpl implements ThirdPartyPlatformServi @Autowired private ThirdpartySecretInfoService thirdpartySecretInfoService; + /** + * Invoked by the containing {@code BeanFactory} after it has set all bean properties + * and satisfied {@link BeanFactoryAware}, {@code ApplicationContextAware} etc. + *

This method allows the bean instance to perform validation of its overall + * configuration and final initialization when all bean properties have been set. + * + * @throws Exception in the event of misconfiguration (such as failure to set an + * essential property) or if initialization fails for any other reason + */ + @Override + public void afterPropertiesSet() throws Exception { + ThirdPartyPlatformFactory.register(thirdPlatformType, this); + } + + @Override + public void printServiceName() { + System.out.println("当前类名:" + this.getClass().getSimpleName()); + } + /** * query_token 获取token,提供给第三方平台使用 * @@ -75,4 +98,5 @@ public class ZhongDianLianPlatformServiceImpl implements ThirdPartyPlatformServi Map resultMap = ThirdPartyPlatformUtils.generateResultMap(vo, thirdPartySecretInfoVO); return resultMap; } + }