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 7c83ffb0a..6b4ebe8d0 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 @@ -16,6 +16,7 @@ public enum ThirdPlatformTypeEnum { NING_XIA_JIAO_TOU("5", "宁夏交投"), XIN_DIAN_TU("6", "新电途平台"), HUA_WEI("7", "华为平台"), + HAI_NAN("8", "海南平台"), ; private String code; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/hainan/service/HaiNanChargeService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/hainan/service/HaiNanChargeService.java index 48e3e1914..4c1643ce5 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/hainan/service/HaiNanChargeService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/hainan/service/HaiNanChargeService.java @@ -3,6 +3,7 @@ package com.jsowell.thirdparty.hainan.service; import com.github.pagehelper.PageInfo; import com.google.common.collect.Lists; import com.jsowell.common.constant.Constants; +import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; import com.jsowell.common.util.PageUtils; import com.jsowell.common.util.StringUtils; import com.jsowell.pile.domain.ThirdPartyPlatformConfig; @@ -10,7 +11,8 @@ import com.jsowell.pile.dto.QueryStationInfoDTO; import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO; import com.jsowell.pile.vo.uniapp.BillingPriceVO; import com.jsowell.thirdparty.hainan.domain.HNStationInfo; -import com.jsowell.thirdparty.platform.AbsInterfaceWithPlatformService; +import com.jsowell.thirdparty.platform.AbsInterfaceWithPlatformLogic; +import com.jsowell.thirdparty.platform.InterfaceWithPlatformLogicFactory; import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; @@ -26,7 +28,11 @@ import java.util.Map; * @Date 2024/1/18 10:05:23 */ @Service -public class HaiNanChargeService extends AbsInterfaceWithPlatformService { +public class HaiNanChargeService extends AbsInterfaceWithPlatformLogic { + @Override + public void afterPropertiesSet() throws Exception { + InterfaceWithPlatformLogicFactory.register(ThirdPlatformTypeEnum.HAI_NAN.getCode(), this); + } /** * 6.2 查询充电站信息 @@ -148,6 +154,8 @@ public class HaiNanChargeService extends AbsInterfaceWithPlatformService { return null; } + + /** * 身份认证 * diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/AbsInterfaceWithPlatformService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/AbsInterfaceWithPlatformLogic.java similarity index 97% rename from jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/AbsInterfaceWithPlatformService.java rename to jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/AbsInterfaceWithPlatformLogic.java index 2da9f59e4..a8849923b 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/AbsInterfaceWithPlatformService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/AbsInterfaceWithPlatformLogic.java @@ -16,6 +16,7 @@ import com.jsowell.thirdparty.lianlian.util.Encodes; import com.jsowell.thirdparty.lianlian.util.GBSignUtils; import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO; import com.jsowell.thirdparty.zhongdianlian.service.ZDLService; +import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import java.nio.charset.StandardCharsets; @@ -25,7 +26,7 @@ import java.util.Map; /** * 对接第三方平台抽象类 */ -public abstract class AbsInterfaceWithPlatformService { +public abstract class AbsInterfaceWithPlatformLogic implements InitializingBean { @Autowired protected PileStationInfoService pileStationInfoService; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/InterfaceWithPlatformLogicFactory.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/InterfaceWithPlatformLogicFactory.java new file mode 100644 index 000000000..66e0e1b46 --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/InterfaceWithPlatformLogicFactory.java @@ -0,0 +1,37 @@ +package com.jsowell.thirdparty.platform; + +import com.google.common.collect.Maps; +import com.jsowell.common.util.StringUtils; + +import java.util.Map; +import java.util.Objects; + +/** + * 工厂设计模式 + * 对接第三方平台逻辑工厂类 + */ +public class InterfaceWithPlatformLogicFactory { + + private static final Map platformMap = Maps.newHashMap(); + + /** + * 注册 + * @param str + * @param handler + */ + public static void register(String str, AbsInterfaceWithPlatformLogic handler) { + if (StringUtils.isBlank(str) || Objects.isNull(handler)) { + return; + } + platformMap.put(str, handler); + } + + /** + * 获取 + * @param name + * @return + */ + public static AbsInterfaceWithPlatformLogic getPlatformLogic(String name) { + return platformMap.get(name); + } +}