diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java index 098dd1c14d..220d621195 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java @@ -370,4 +370,13 @@ public class RedisKeys { public static String getCustomerApiServiceKey(String customerId) { return rootPrefix.concat("customer:thirdplat:apiservice:").concat(customerId); } + + /** + * 一个客户对应多个第三方平台,多个ApiService的key + * @param customerId + * @return + */ + public static String listCustomerApiServiceListKey(String customerId) { + return rootPrefix.concat("customer:thirdplat:apiservicelist:").concat(customerId); + } } diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/constant/ApiServiceActions.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/constant/ApiServiceActions.java new file mode 100644 index 0000000000..e754e8f31e --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/constant/ApiServiceActions.java @@ -0,0 +1,11 @@ +package com.epmet.constant; + +/** + * api service 常量列表 + */ +public interface ApiServiceActions { + + // 测试动作 + String DEMO_ACTION = "demoAction"; + +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/ProjectAssistFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/ProjectAssistFormDTO.java new file mode 100644 index 0000000000..543524f1b1 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/ProjectAssistFormDTO.java @@ -0,0 +1,15 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +@Data +public class ProjectAssistFormDTO { + + private String customerId; + + @NotBlank(message = "平台ID不能为空") + private String platformId; + +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/TPFDemoFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/TPFDemoFormDTO.java new file mode 100644 index 0000000000..c790a4a529 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/TPFDemoFormDTO.java @@ -0,0 +1,20 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * 第三方平台-demo form dto + */ +@Data +public class TPFDemoFormDTO { + + private String demoString; + + @NotBlank(message = "客户ID不能为空") + private String customerId; + + @NotBlank(message = "平台ID不能为空") + private String platformId; +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/ApiService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/ApiService.java new file mode 100644 index 0000000000..da169d165a --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/ApiService.java @@ -0,0 +1,63 @@ +package com.epmet.apiservice; + +import com.epmet.apiservice.result.ProjectAssistResult; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.utils.SpringContextUtils; +import com.epmet.dao.ThirdplatformCustomerRegisterDao; +import com.epmet.dto.form.ProjectAssistFormDTO; +import com.epmet.dto.form.TPFDemoFormDTO; +import com.epmet.entity.ThirdplatformCustomerRegisterEntity; + +/** + * ApiService,对接第三方平台的抽象类 + * 每一个具体平台的ApiService都是该抽象类的子类,选择性实现抽象类中的某些方法,提供具体业务逻辑 + */ +public abstract class ApiService { + + /** + * @Description 判断该客户是否注册了该平台 + * @return true:已注册该平台,可以使用;false:未注册,无法使用 + * @author wxz + * @date 2021.03.15 11:09 + */ + public boolean isRegistered(String customerId, String platformId) { + ThirdplatformCustomerRegisterDao tpcRegDao = SpringContextUtils.getBean(ThirdplatformCustomerRegisterDao.class); + ThirdplatformCustomerRegisterEntity tpcReg = tpcRegDao.getByCustomerIdAndPlatformId(customerId, platformId); + if (tpcReg == null) { + return false; + } + return true; + } + + /** + * @Description 判断客户是否注册了指定的平台,如果没有注册,则抛出异常 + * @return + * @author wxz + * @date 2021.03.15 21:39 + */ + public void judgeRegistered(String customerId, String platformId) { + if (!isRegistered(customerId, platformId)) { + throw new RenException(String.format("客户:%s没有配置第三方平台:%s", customerId, platformId)); + } + } + + /** + * @Description demo示例方法 + * @return + * @author wxz + * @date 2021.03.15 10:46 + */ + public String demoAction(TPFDemoFormDTO tpfDemoFormDTO) { + return "do success !!"; + } + + /** + * @Description 项目协同处理 + * @return 项目协同处理的Result。具体的平台返回的结果最终都要转化为这个ProjectAssistResult返回 + * @author wxz + * @date 2021.03.16 09:28 + */ + public ProjectAssistResult projectAssist(ProjectAssistFormDTO formDTO) { + return null; + } +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/DemoApiService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/DemoApiService.java new file mode 100644 index 0000000000..6c1aca3917 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/DemoApiService.java @@ -0,0 +1,31 @@ +package com.epmet.apiservice.impl; + +import com.epmet.apiservice.ApiService; +import com.epmet.apiservice.result.ProjectAssistResult; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.constant.ApiServiceActions; +import com.epmet.dto.form.ProjectAssistFormDTO; +import com.epmet.dto.form.TPFDemoFormDTO; +import com.epmet.feign.OperCrmOpenFeignClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * demo api service + */ +@Component(value = "demoApiService") +public class DemoApiService extends ApiService { + + Logger logger = LoggerFactory.getLogger(DemoApiService.class); + + @Autowired + private OperCrmOpenFeignClient operCrmOpenFeignClient; + + @Override + public ProjectAssistResult projectAssist(ProjectAssistFormDTO formDTO) { + logger.info("DemoApiService发送项目协助到第三方平台成功"); + return null; + } +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/LuzhouGridPlatformApiService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/LuzhouGridPlatformApiService.java new file mode 100644 index 0000000000..4081bfad61 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/LuzhouGridPlatformApiService.java @@ -0,0 +1,19 @@ +package com.epmet.apiservice.impl; + +import com.epmet.apiservice.ApiService; +import com.epmet.apiservice.result.ProjectAssistResult; +import com.epmet.dto.form.ProjectAssistFormDTO; +import org.springframework.stereotype.Component; + +/** + * 泸州网格化平台ApiService + */ +@Component("luzhouGridPlatformApiService") +public class LuzhouGridPlatformApiService extends ApiService { + + @Override + public ProjectAssistResult projectAssist(ProjectAssistFormDTO formDTO) { + System.out.println("泸州网格化平台项目协助发送成功"); + return null; + } +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/result/LZGridPlatformProjectAssistResult.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/result/LZGridPlatformProjectAssistResult.java new file mode 100644 index 0000000000..ef74410885 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/result/LZGridPlatformProjectAssistResult.java @@ -0,0 +1,4 @@ +package com.epmet.apiservice.result; + +public class LZGridPlatformProjectAssistResult { +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/result/ProjectAssistResult.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/result/ProjectAssistResult.java new file mode 100644 index 0000000000..2da96d1e17 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/result/ProjectAssistResult.java @@ -0,0 +1,8 @@ +package com.epmet.apiservice.result; + +import lombok.Data; + +@Data +public class ProjectAssistResult { + +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/BizController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/BizController.java new file mode 100644 index 0000000000..ed83a196bf --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/BizController.java @@ -0,0 +1,54 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.form.ProjectAssistFormDTO; +import com.epmet.dto.form.TPFDemoFormDTO; +import com.epmet.service.ProjectService; +import org.springframework.beans.factory.annotation.Autowired; +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 java.lang.management.MemoryManagerMXBean; + +/** + * 对接第三方平台业务相关的controller + * 我们系统当中每一个需要发送到第三方平台的操作,只对应这里的一个方法,根据参数传入platformId,内部根据配置获取指定的APiService进行具体平台的调用 + * 每一个平台都有自己的ApiSerivce + */ +@RestController +@RequestMapping("biz") +public class BizController { + + @Autowired + private ProjectService projectService; + + /** + * @Description demo方法 + * @return + * @author wxz + * @date 2021.03.15 21:11 + */ + @PostMapping("demo-action") + public Result demoAction(@RequestBody TPFDemoFormDTO tpfDemoFormDTO) { + ValidatorUtils.validateEntity(tpfDemoFormDTO); + String r = projectService.demoAction(tpfDemoFormDTO); + return new Result().ok(r); + } + + /** + * @Description 发送项目协同处理方法 + * @return + * @author wxz + * @date 2021.03.15 21:13 + */ + @PostMapping("project-assist") + public Result projectAssist(@RequestBody ProjectAssistFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + projectService.projectAssist(formDTO); + return new Result(); + } + +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformActionDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformActionDao.java new file mode 100644 index 0000000000..9b309c15fc --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformActionDao.java @@ -0,0 +1,33 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *
+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *
+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see > getAllSubCustomerIds(@PathVariable("customerId") String customerId);
+
+ /**
+ * @Description 根据客户id列出该客户所有的apiService
+ * @return
+ * @author wxz
+ * @date 2021.03.15 15:13
+ */
+ @PostMapping("list-apiservice-by-customerid")
+ Result
> listApiServiceByCustomerId(@RequestBody ApiServiceFormDTO form);
}
diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java
index 5de09ce167..134ffcb242 100644
--- a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java
+++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java
@@ -95,4 +95,9 @@ public class OperCrmOpenFeignClientFallback implements OperCrmOpenFeignClient {
public Result
> getAllSubCustomerIds(String customerId) {
return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "getAllSubCustomerIds", customerId);
}
+
+ @Override
+ public Result
> listApiServiceByCustomerId(ApiServiceFormDTO form) {
+ return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "listApiServiceByCustomerId", form);
+ }
}
diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java
index c5330a9abd..461c06f3f6 100644
--- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java
+++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java
@@ -376,4 +376,17 @@ public class CustomerController {
}
return new Result<>();
}
+
+ /**
+ * @Description 根据客户id列出该客户所有的apiService
+ * @return
+ * @author wxz
+ * @date 2021.03.15 15:13
+ */
+ @PostMapping("list-apiservice-by-customerid")
+ public Result
> listApiServiceByCustomerId(@RequestBody ApiServiceFormDTO form) {
+ ValidatorUtils.validateEntity(form, ApiServiceFormDTO.GetByCustomerId.class);
+ String customerId = form.getCustomerId();
+ return new Result
>().ok(customerThirdplatApiServiceService.listByCustomerId(customerId));
+ }
}
diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerThirdplatApiserviceDao.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerThirdplatApiserviceDao.java
index 52f05556b1..a879264c54 100644
--- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerThirdplatApiserviceDao.java
+++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerThirdplatApiserviceDao.java
@@ -23,6 +23,8 @@ import com.epmet.entity.CustomerThirdplatApiserviceEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
+import java.util.List;
+
/**
* 客户所属的第三方平台的apiService列表
*
@@ -33,4 +35,12 @@ import org.apache.ibatis.annotations.Param;
public interface CustomerThirdplatApiserviceDao extends BaseDao