From 5ba2f8dc2dc7b908a9d12d8619a5caca521a97fa Mon Sep 17 00:00:00 2001 From: weijing <> Date: Fri, 16 Dec 2022 16:02:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E7=B1=BB=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/SkyeyeClassServiceBeanServiceImpl.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/skyeye-promote/skyeye-common/src/main/java/com/skyeye/clazz/service/impl/SkyeyeClassServiceBeanServiceImpl.java b/skyeye-promote/skyeye-common/src/main/java/com/skyeye/clazz/service/impl/SkyeyeClassServiceBeanServiceImpl.java index e33afbc3..0989eeec 100644 --- a/skyeye-promote/skyeye-common/src/main/java/com/skyeye/clazz/service/impl/SkyeyeClassServiceBeanServiceImpl.java +++ b/skyeye-promote/skyeye-common/src/main/java/com/skyeye/clazz/service/impl/SkyeyeClassServiceBeanServiceImpl.java @@ -71,7 +71,7 @@ public class SkyeyeClassServiceBeanServiceImpl extends SkyeyeBusinessServiceImpl QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq(MybatisPlusUtil.toColumns(SkyeyeClassServiceBean::getSpringApplicationName), skyeyeClassServiceBeanApi.getSpringApplicationName()); List oldList = super.list(wrapper); - List oldKeys = oldList.stream().map(bean -> bean.getClassName()).collect(Collectors.toList()); + List oldKeys = oldList.stream().map(bean -> getKey(bean)).collect(Collectors.toList()); // 获取入参的数据 List classNameList = skyeyeClassServiceBeanApi.getClassNameList(); @@ -80,10 +80,10 @@ public class SkyeyeClassServiceBeanServiceImpl extends SkyeyeBusinessServiceImpl className.setSpringApplicationName(skyeyeClassServiceBeanApi.getSpringApplicationName()); }); - List newKeys = classNameList.stream().map(bean -> bean.getClassName()).collect(Collectors.toList()); + List newKeys = classNameList.stream().map(bean -> getKey(bean)).collect(Collectors.toList()); // (旧数据 - 新数据) 从数据库删除 - List deleteBeans = oldList.stream().filter(item -> !newKeys.contains(item.getClassName())).collect(Collectors.toList()); + List deleteBeans = oldList.stream().filter(item -> !newKeys.contains(getKey(item))).collect(Collectors.toList()); if (!CollectionUtils.isEmpty(deleteBeans)) { List classNames = deleteBeans.stream().map(bean -> bean.getClassName()).collect(Collectors.toList()); QueryWrapper deleteWrapper = new QueryWrapper<>(); @@ -93,7 +93,7 @@ public class SkyeyeClassServiceBeanServiceImpl extends SkyeyeBusinessServiceImpl } // (新数据 - 旧数据) 添加到数据库 - List addBeans = classNameList.stream().filter(item -> !oldKeys.contains(item.getClassName())).collect(Collectors.toList()); + List addBeans = classNameList.stream().filter(item -> !oldKeys.contains(getKey(item))).collect(Collectors.toList()); if (!CollectionUtils.isEmpty(addBeans)) { createEntity(addBeans, StringUtils.EMPTY); } @@ -102,6 +102,10 @@ public class SkyeyeClassServiceBeanServiceImpl extends SkyeyeBusinessServiceImpl saveAttrDefinition(skyeyeClassServiceBeanApi.getAppId(), classNameList); } + private String getKey(SkyeyeClassServiceBean bean) { + return String.format(Locale.ROOT, "%s_%s_%s", bean.getClassName(), bean.getManageShow(), bean.getTenant()); + } + private void saveAttrDefinition(String appId, List classNameList) { List attrDefinitionList = classNameList.stream() .filter(className -> CollectionUtil.isNotEmpty(className.getAttrDefinitionList()))