From 7b3c63a2e2d981545c8860b86a5ba9b984c3950a Mon Sep 17 00:00:00 2001 From: wxz Date: Fri, 19 Mar 2021 16:49:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E6=AC=A1=E6=80=A7?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E5=AE=A2=E6=88=B7-=E7=AC=AC=E4=B8=89?= =?UTF-8?q?=E6=96=B9=E5=B9=B3=E5=8F=B0-action=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/dto/form/ThirdPlatformFormDTO.java | 17 ++++-- .../com/epmet/feign/ThirdOpenFeignClient.java | 26 +++++++++ .../ThirdOpenFeignClientFallback.java | 18 ++++++ .../controller/ThirdPlatformController.java | 12 ++++ .../dao/ThirdplatformCustomerActionDao.java | 2 + .../epmet/service/ThirdPlatformService.java | 2 + .../impl/ThirdPlatformServiceImpl.java | 52 +++++++++++++++++ .../mapper/ThirdplatformCustomerActionDao.xml | 7 +++ .../com/epmet/dto/form/ParameterFormDTO.java | 7 +++ .../dto/form/ThirdPlatformConfigFormDTO.java | 30 ++++++++++ .../gov-project/gov-project-server/pom.xml | 5 ++ .../epmet/constant/ParameterKeyConstant.java | 6 ++ .../CustomerProjectParameterController.java | 26 +++++++++ .../CustomerProjectParameterService.java | 7 +++ .../CustomerProjectParameterServiceImpl.java | 56 +++++++++++++++++-- 15 files changed, 262 insertions(+), 11 deletions(-) create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/ThirdOpenFeignClient.java create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/ThirdOpenFeignClientFallback.java create mode 100644 epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/ThirdPlatformConfigFormDTO.java diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/ThirdPlatformFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/ThirdPlatformFormDTO.java index f1793c1fb3..185eb5cab9 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/ThirdPlatformFormDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/ThirdPlatformFormDTO.java @@ -21,26 +21,33 @@ public class ThirdPlatformFormDTO { // 更新客户自定义的平台信息 public interface UpdateCustomizePlatformInfo {} + public interface SaveOrUpdateSelectedPlatformInfo {} + @NotBlank(message = "客户ID不能为空", groups = { ListAvailableByCustomerAndActionGroup.class, ListSelectableByCustomerAndActionGroup.class, SaveCustomerSelectedPlatformGroup.class, ListSelectedPlatforms.class, - UpdateCustomizePlatformInfo.class }) + UpdateCustomizePlatformInfo.class, + SaveOrUpdateSelectedPlatformInfo.class }) private String customerId; @NotBlank(message = "动作不能为空", groups = { ListAvailableByCustomerAndActionGroup.class, ListSelectableByCustomerAndActionGroup.class, - SaveCustomerSelectedPlatformGroup.class }) + SaveCustomerSelectedPlatformGroup.class, + SaveOrUpdateSelectedPlatformInfo.class }) private String actionKey; @NotBlank(message = "平台ID不能为空", groups = { SaveCustomerSelectedPlatformGroup.class, - UpdateCustomizePlatformInfo.class }) + UpdateCustomizePlatformInfo.class, + SaveOrUpdateSelectedPlatformInfo.class }) private String platformId; - @NotBlank(message = "平台名称不能为空", groups = { UpdateCustomizePlatformInfo.class }) + @NotBlank(message = "平台名称不能为空", groups = { UpdateCustomizePlatformInfo.class, + SaveOrUpdateSelectedPlatformInfo.class }) private String platformName; - @NotBlank(message = "平台图标不能为空", groups = { UpdateCustomizePlatformInfo.class }) + @NotBlank(message = "平台图标不能为空", groups = { UpdateCustomizePlatformInfo.class, + SaveOrUpdateSelectedPlatformInfo.class }) private String icon; } diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/ThirdOpenFeignClient.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/ThirdOpenFeignClient.java new file mode 100644 index 0000000000..f81e1b0db7 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/ThirdOpenFeignClient.java @@ -0,0 +1,26 @@ +package com.epmet.feign; + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.ThirdPlatformFormDTO; +import com.epmet.feign.fallback.ThirdOpenFeignClientFallback; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.List; + +//@FeignClient(name = ServiceConstant.EPMET_THIRD_SERVER, fallback = ThirdOpenFeignClientFallback.class) +@FeignClient(name = ServiceConstant.EPMET_THIRD_SERVER, fallback = ThirdOpenFeignClientFallback.class, url = "http://localhost:8110") +public interface ThirdOpenFeignClient { + + /** + * @Description 保存或修改客户选中的第三方平台信息 + * @return + * @author wxz + * @date 2021.03.19 15:25 + */ + @PostMapping("/third/thirdplatform/customer/saveorupdate-selected-platforms") + Result saveOrUpdateSelectedPlatformsInfo(@RequestBody List input); + +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/ThirdOpenFeignClientFallback.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/ThirdOpenFeignClientFallback.java new file mode 100644 index 0000000000..abd22929ee --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/ThirdOpenFeignClientFallback.java @@ -0,0 +1,18 @@ +package com.epmet.feign.fallback; + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.ModuleUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.ThirdPlatformFormDTO; +import com.epmet.feign.ThirdOpenFeignClient; +import org.springframework.stereotype.Component; + +import java.util.List; + +@Component +public class ThirdOpenFeignClientFallback implements ThirdOpenFeignClient { + @Override + public Result saveOrUpdateSelectedPlatformsInfo(List input) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "saveOrUpdateSelectedPlatformsInfo", input); + } +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/ThirdPlatformController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/ThirdPlatformController.java index e3f1998793..9288625bee 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/ThirdPlatformController.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/ThirdPlatformController.java @@ -76,4 +76,16 @@ public class ThirdPlatformController { return new Result(); } + /** + * @Description 保存或修改客户选中的第三方平台信息 + * @return + * @author wxz + * @date 2021.03.19 15:25 + */ + @PostMapping("customer/saveorupdate-selected-platforms") + public Result saveOrUpdateSelectedPlatformsInfo(@RequestBody List input) { + input.stream().forEach(i -> ValidatorUtils.validateEntity(i, ThirdPlatformFormDTO.SaveOrUpdateSelectedPlatformInfo.class)); + thirdPlatformService.saveOrUpdateSelectedPlatformInfo(input); + return new Result(); + } } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformCustomerActionDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformCustomerActionDao.java index 49ac3a5431..cf4640fcc8 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformCustomerActionDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformCustomerActionDao.java @@ -33,4 +33,6 @@ public interface ThirdplatformCustomerActionDao extends BaseDao platforms); void updateCustomizePlatformInfo(ThirdPlatformFormDTO input); + + void saveOrUpdateSelectedPlatformInfo(List platforms); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ThirdPlatformServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ThirdPlatformServiceImpl.java index ad4e81254e..39d3e33cae 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ThirdPlatformServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ThirdPlatformServiceImpl.java @@ -1,18 +1,25 @@ package com.epmet.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.epmet.dao.ThirdplatformCustomerActionDao; import com.epmet.dao.ThirdplatformCustomerRegisterDao; import com.epmet.dao.ThirdplatformDao; import com.epmet.dto.form.ThirdPlatformFormDTO; import com.epmet.dto.result.ThirdplatformResultDTO; +import com.epmet.entity.ThirdplatformActionEntity; import com.epmet.entity.ThirdplatformCustomerActionEntity; import com.epmet.entity.ThirdplatformCustomerRegisterEntity; import com.epmet.service.ThirdPlatformService; +import jodd.util.CollectionUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; +import javax.validation.constraints.NotBlank; import java.util.List; +import java.util.stream.Collectors; @Service public class ThirdPlatformServiceImpl implements ThirdPlatformService { @@ -60,4 +67,49 @@ public class ThirdPlatformServiceImpl implements ThirdPlatformService { thirdplatformCustomerRegisterDao.updateById(exist); } } + + @Transactional(rollbackFor = Exception.class) + @Override + public void saveOrUpdateSelectedPlatformInfo(List platforms) { + if (CollectionUtils.isEmpty(platforms)) { + return; + } + + // 1.物理删除客户-action所有对应关系 + int deletedCount = thirdplatformCustomerActionDao.deleteByCustomerIdAndActionKey(platforms.get(0).getCustomerId(), platforms.get(0).getActionKey()); + + platforms.stream().forEach(pt -> { + String customerId = pt.getCustomerId(); + String platformId = pt.getPlatformId(); + + // 2.更新用户自定义的平台信息 + updateThirdPlatformCustomerRegInfo(pt); + + // 3.重新建立customer-platform-action对应关系 + ThirdplatformCustomerActionEntity tpcaEntity = new ThirdplatformCustomerActionEntity(); + tpcaEntity.setPlatformId(platformId); + tpcaEntity.setCustomerId(customerId); + tpcaEntity.setActionKey(pt.getActionKey()); + thirdplatformCustomerActionDao.insert(tpcaEntity); + }); + + } + + /** + * @Description 更新第三方品台客户对应关系 + * @return + * @author wxz + * @date 2021.03.19 15:22 + */ + private void updateThirdPlatformCustomerRegInfo(ThirdPlatformFormDTO platformFormDTO) { + LambdaQueryWrapper conditions = new QueryWrapper() + .lambda() + .eq(ThirdplatformCustomerRegisterEntity::getCustomerId, platformFormDTO.getCustomerId()) + .eq(ThirdplatformCustomerRegisterEntity::getPlatformId, platformFormDTO.getPlatformId()); + + ThirdplatformCustomerRegisterEntity entity = new ThirdplatformCustomerRegisterEntity(); + entity.setCustomizedPlatformName(platformFormDTO.getPlatformName()); + entity.setCustomizedPlatformIcon(platformFormDTO.getIcon()); + thirdplatformCustomerRegisterDao.update(entity, conditions); + } } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformCustomerActionDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformCustomerActionDao.xml index 4decbb7c0f..f23ff18cc3 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformCustomerActionDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformCustomerActionDao.xml @@ -16,6 +16,13 @@ + + delete + from thirdplatform_customer_action + where CUSTOMER_ID = #{customerId} + and ACTION_KEY = #{actionKey} + +