From af6daf48afb6b1f22d77324950956a36313c2b3d Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Mon, 29 Mar 2021 13:32:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=BF=90=E8=90=A5=E7=AB=AF?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=88=86=E7=B1=BB=20=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E6=9F=A5=E8=AF=A2=E4=B8=8D=E5=88=B0=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/redis/IssueProjectTagDictRedis.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/redis/IssueProjectTagDictRedis.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/redis/IssueProjectTagDictRedis.java index 3eeefd9afe..5cfb9a1c5c 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/redis/IssueProjectTagDictRedis.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/redis/IssueProjectTagDictRedis.java @@ -100,7 +100,9 @@ public class IssueProjectTagDictRedis { throw new RenException("customerId can not be null when obtain govern tags."); } + //查询客户的“其他"分类的Id IssueProjectCategoryDictEntity otherCategory = categoryDictDao.selectSingleByCustomerIdAndCategoryNameAndCategoryType(customerId, ModuleConstants.CATEGORY_NAME_OTHERS, null); + //判断入参是否是只有一个分类Id并且是"其他"的Id boolean ifOtherOnly = null == otherCategory ? false : (!CollectionUtils.isEmpty(category) && category.size() == NumConstant.ONE && category.contains(otherCategory.getId()) ? true : false); Map> result = new HashMap<>(); @@ -348,13 +350,22 @@ public class IssueProjectTagDictRedis { //result.put(ModuleConstants.DEFAULT_TAG_CATEGORY_NAME,CollectionUtils.isEmpty(db) ? null : db.stream().filter(o -> !StringUtils.equals(ModuleConstants.CUSTOMIZED_TAG_CATEGORY_NAME,o.getCategoryId())).map(entity -> { // IssueCategoryTagResultDTO tag = ConvertUtils.sourceToTarget(entity,IssueCategoryTagResultDTO.class); // tag.setName(entity.getTagName()); return tag;}).collect(Collectors.toList())); - result.put(ModuleConstants.DEFAULT_TAG_CATEGORY_NAME,poolDao.selectDefault(customerId,ifOtherOnly ? null : category)); - + if (!CollectionUtils.isEmpty(preResult) && !CollectionUtils.isEmpty(preResult.get(ModuleConstants.DEFAULT_TAG_CATEGORY_NAME))) { + result.put(ModuleConstants.DEFAULT_TAG_CATEGORY_NAME, preResult.get(ModuleConstants.DEFAULT_TAG_CATEGORY_NAME)); + } else { + result.put(ModuleConstants.DEFAULT_TAG_CATEGORY_NAME, poolDao.selectDefault(customerId, ifOtherOnly ? null : category)); + } //自定义标签:按照热度排序 sorted(Comparator.comparing(IssueProjectTagDictEntity :: getIssueUseCount).reversed()) - result.put(ModuleConstants.CUSTOMIZED_TAG_CATEGORY_NAME,CollectionUtils.isEmpty(db) ? null : db.stream().filter(o -> StringUtils.equals(ModuleConstants.CUSTOMIZED_TAG_CATEGORY_NAME,o.getCategoryId())).sorted(Comparator.comparing(IssueProjectTagDictEntity :: getIssueUseCount).reversed()).map(entity -> { - IssueCategoryTagResultDTO tag = ConvertUtils.sourceToTarget(entity,IssueCategoryTagResultDTO.class); - tag.setName(entity.getTagName());return tag;}).collect(Collectors.toList())); + if (!CollectionUtils.isEmpty(preResult) && !CollectionUtils.isEmpty(preResult.get(ModuleConstants.CUSTOMIZED_TAG_CATEGORY_NAME))) { + result.put(ModuleConstants.CUSTOMIZED_TAG_CATEGORY_NAME, preResult.get(ModuleConstants.CUSTOMIZED_TAG_CATEGORY_NAME)); + } else { + result.put(ModuleConstants.CUSTOMIZED_TAG_CATEGORY_NAME, CollectionUtils.isEmpty(db) ? null : db.stream().filter(o -> StringUtils.equals(ModuleConstants.CUSTOMIZED_TAG_CATEGORY_NAME, o.getCategoryId())).sorted(Comparator.comparing(IssueProjectTagDictEntity::getIssueUseCount).reversed()).map(entity -> { + IssueCategoryTagResultDTO tag = ConvertUtils.sourceToTarget(entity, IssueCategoryTagResultDTO.class); + tag.setName(entity.getTagName()); + return tag; + }).collect(Collectors.toList())); + } return result; }