From d12d04f03be703c53e1b8528b2a669513dc0403c Mon Sep 17 00:00:00 2001 From: weizhiqiang <598748873@qq.com> Date: Fri, 7 Oct 2022 18:31:53 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E7=A0=81=E8=A7=84=E5=88=99=E7=9A=84?= =?UTF-8?q?=E6=B3=A8=E8=A7=A3=E4=BF=AE=E6=94=B9=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=88=86=E7=BB=84=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../coderule/SkyeyeClassCodeRuleMation.java | 7 ++++++ .../eve/service/impl/CodeRuleServiceImpl.java | 3 ++- .../impl/SkyeyeClassCodeRuleServiceImpl.java | 23 ++++++++++--------- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/skyeye-promote/skyeye-common/src/main/java/com/skyeye/eve/entity/coderule/SkyeyeClassCodeRuleMation.java b/skyeye-promote/skyeye-common/src/main/java/com/skyeye/eve/entity/coderule/SkyeyeClassCodeRuleMation.java index 4879b4a6..b2ab0f52 100644 --- a/skyeye-promote/skyeye-common/src/main/java/com/skyeye/eve/entity/coderule/SkyeyeClassCodeRuleMation.java +++ b/skyeye-promote/skyeye-common/src/main/java/com/skyeye/eve/entity/coderule/SkyeyeClassCodeRuleMation.java @@ -60,6 +60,13 @@ public class SkyeyeClassCodeRuleMation extends CommonOperatorUserInfo implements @ApiModelProperty(value = "className对应的服务名称", required = "required") private String serviceName; + /** + * className对应的服务名称 + */ + @TableField("group_name") + @ApiModelProperty(value = "className对应的分组名称", required = "required") + private String groupName; + /** * 编码规则id */ diff --git a/skyeye-promote/skyeye-common/src/main/java/com/skyeye/eve/service/impl/CodeRuleServiceImpl.java b/skyeye-promote/skyeye-common/src/main/java/com/skyeye/eve/service/impl/CodeRuleServiceImpl.java index 8a8eabb5..43973e3f 100644 --- a/skyeye-promote/skyeye-common/src/main/java/com/skyeye/eve/service/impl/CodeRuleServiceImpl.java +++ b/skyeye-promote/skyeye-common/src/main/java/com/skyeye/eve/service/impl/CodeRuleServiceImpl.java @@ -111,7 +111,8 @@ public class CodeRuleServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); queryWrapper.and(wrapper -> wrapper.eq(MybatisPlusUtil.toColumns(CodeRuleMation::getCodeNum), codeRule.getCodeNum()) - .or().eq(MybatisPlusUtil.toColumns(CodeRuleMation::getName), codeRule.getName())); + .or().eq(MybatisPlusUtil.toColumns(CodeRuleMation::getName), codeRule.getName()) + .or().eq(MybatisPlusUtil.toColumns(CodeRuleMation::getPattern), codeRule.getPattern())); if (StringUtils.isNotEmpty(codeRule.getId())) { queryWrapper.ne(CommonConstants.ID, codeRule.getId()); } diff --git a/skyeye-promote/skyeye-common/src/main/java/com/skyeye/eve/service/impl/SkyeyeClassCodeRuleServiceImpl.java b/skyeye-promote/skyeye-common/src/main/java/com/skyeye/eve/service/impl/SkyeyeClassCodeRuleServiceImpl.java index 26246c71..87ce57ba 100644 --- a/skyeye-promote/skyeye-common/src/main/java/com/skyeye/eve/service/impl/SkyeyeClassCodeRuleServiceImpl.java +++ b/skyeye-promote/skyeye-common/src/main/java/com/skyeye/eve/service/impl/SkyeyeClassCodeRuleServiceImpl.java @@ -57,7 +57,7 @@ public class SkyeyeClassCodeRuleServiceImpl extends ServiceImpl wrapper = new QueryWrapper<>(); wrapper.eq(MybatisPlusUtil.toColumns(SkyeyeClassCodeRuleMation::getAppId), skyeyeClassCodeRuleApiMation.getAppId()); List oldList = super.list(wrapper); - List oldKeys = oldList.stream().map(bean -> bean.getClassName() + bean.getServiceName()).collect(Collectors.toList()); + List oldKeys = oldList.stream().map(bean -> bean.getClassName() + bean.getGroupName() + bean.getServiceName()).collect(Collectors.toList()); // 获取入参的数据 List classNameList = skyeyeClassCodeRuleApiMation.getClassNameList(); @@ -66,18 +66,11 @@ public class SkyeyeClassCodeRuleServiceImpl extends ServiceImpl newKeys = classNameList.stream().map(bean -> bean.getClassName() + bean.getServiceName()).collect(Collectors.toList()); - - // (新数据 - 旧数据) 添加到数据库 - List addBeans = classNameList.stream() - .filter(item -> !oldKeys.contains(item.getClassName() + item.getServiceName())).collect(Collectors.toList()); - if (!CollectionUtils.isEmpty(addBeans)) { - saveBatch(addBeans); - } + List newKeys = classNameList.stream().map(bean -> bean.getClassName() + bean.getGroupName() + bean.getServiceName()).collect(Collectors.toList()); // (旧数据 - 新数据) 从数据库删除 List deleteBeans = oldList.stream() - .filter(item -> !newKeys.contains(item.getClassName() + item.getServiceName())).collect(Collectors.toList()); + .filter(item -> !newKeys.contains(item.getClassName() + item.getGroupName() + item.getServiceName())).collect(Collectors.toList()); if (!CollectionUtils.isEmpty(deleteBeans)) { List classNames = deleteBeans.stream().map(bean -> bean.getClassName()).collect(Collectors.toList()); QueryWrapper deleteWrapper = new QueryWrapper<>(); @@ -86,6 +79,13 @@ public class SkyeyeClassCodeRuleServiceImpl extends ServiceImpl addBeans = classNameList.stream() + .filter(item -> !oldKeys.contains(item.getClassName() + item.getGroupName() + item.getServiceName())).collect(Collectors.toList()); + if (!CollectionUtils.isEmpty(addBeans)) { + saveBatch(addBeans); + } + } /** @@ -131,7 +131,8 @@ public class SkyeyeClassCodeRuleServiceImpl extends ServiceImpl classCodeRuleMationList = super.list(); - Map> collect = classCodeRuleMationList.stream().collect(Collectors.groupingBy(SkyeyeClassCodeRuleMation::getAppName)); + Map>> collect = classCodeRuleMationList.stream() + .collect(Collectors.groupingBy(SkyeyeClassCodeRuleMation::getAppName, Collectors.groupingBy(SkyeyeClassCodeRuleMation::getGroupName))); outputObject.setBean(collect); outputObject.settotal(CommonNumConstants.NUM_ONE); }