diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueProjectCategoryDictServiceImpl.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueProjectCategoryDictServiceImpl.java index 5bdf0a58fe..d78c3a3458 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueProjectCategoryDictServiceImpl.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueProjectCategoryDictServiceImpl.java @@ -31,7 +31,10 @@ import com.epmet.dao.IssueCategoryDao; import com.epmet.dao.IssueProjectCategoryDictDao; import com.epmet.dao.IssueProjectRelationDao; import com.epmet.dao.IssueProjectTagDictDao; -import com.epmet.dto.*; +import com.epmet.dto.IssueCategoryDTO; +import com.epmet.dto.IssueDTO; +import com.epmet.dto.IssueProjectCategoryDictDTO; +import com.epmet.dto.ProjectCategoryDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.entity.IssueProjectCategoryDictEntity; @@ -145,6 +148,18 @@ public class IssueProjectCategoryDictServiceImpl extends BaseServiceImpl categoryList(String customerId) { List resultList = baseDao.selectCustomerCategoryList(customerId); + //2021.3.24 sun 客户初始化分类标签的接口不想加到新客户创建的程序里,因此加到这里 在标签列表的查询方法中也有关于初始化分类标签的逻辑 + try { + if(CollectionUtils.isEmpty(resultList)){ + CategoryTagInitFormDTO dto = new CategoryTagInitFormDTO(); + dto.setCustomerId(customerId); + init(dto); + resultList = baseDao.selectCustomerCategoryList(customerId); + } + } catch (Exception e) { + logger.error("客户初始化分类、标签失败,客户Id->"+customerId, e); + } + //end return resultList; } @@ -201,35 +216,21 @@ public class IssueProjectCategoryDictServiceImpl extends BaseServiceImpl customerIdList = new ArrayList<>(); - if(StringUtils.isBlank(formDTO.getCustomerId())){ - Result> resultList = operCrmOpenFeignClient.getAllCustomerList(); - if(!resultList.success()){ - throw new RuntimeException("crm库获取有效客户列表失败!"); - } - customerIdList = resultList.getData().stream().map(cu->cu.getId()).collect(Collectors.toList()); - }else { - customerIdList.add(formDTO.getCustomerId()); + List list = baseDao.selectCategoryListByCustomer(formDTO.getCustomerId()); + if (CollectionUtils.isEmpty(list)) { + //分类初始化 + List categoryList = baseDao.selectCategoryListByCustomer("default"); + categoryList.forEach(item -> { + item.setCustomerId(formDTO.getCustomerId()); + }); + this.insertBatch(categoryList); + //标签初始化 + List tagList = issueProjectTagDictService.getTagListByCustomer("default"); + tagList.forEach(item -> { + item.setCustomerId(formDTO.getCustomerId()); + }); + issueProjectTagDictService.insertBatch(tagList); } - //end sun - customerIdList.forEach(cu->{ - List list = baseDao.selectCategoryListByCustomer(cu); - if (CollectionUtils.isEmpty(list)) { - //分类初始化 - List categoryList = baseDao.selectCategoryListByCustomer("default"); - categoryList.forEach(item -> { - item.setCustomerId(cu); - }); - this.insertBatch(categoryList); - //标签初始化 - List tagList = issueProjectTagDictService.getTagListByCustomer("default"); - tagList.forEach(item -> { - item.setCustomerId(cu); - }); - issueProjectTagDictService.insertBatch(tagList); - } - }); } /** @@ -345,7 +346,7 @@ public class IssueProjectCategoryDictServiceImpl extends BaseServiceImpl implements IssueProjectTagDictService { + private static Logger logger = LoggerFactory.getLogger(IssueProjectTagDictServiceImpl.class); @Autowired private IssueProjectTagDictRedis issueProjectTagDictRedis; + @Autowired + private IssueProjectCategoryDictService issueProjectCategoryDictService; @Override public PageData page(Map params) { @@ -125,6 +131,20 @@ public class IssueProjectTagDictServiceImpl extends BaseServiceImpl> map = issueProjectTagDictRedis.getDefaultTagsSortedByCategoryAndCustomizedTagsOrderByRank(tokenDto.getCustomerId(), formDTO.getCategoryIdList()); result.setDefaulted(map.get(ModuleConstants.DEFAULT_TAG_CATEGORY_NAME)); + //2021.3.24 sun 客户初始化分类标签的接口不想加到新客户创建的程序里,因此加到这里 在分类列表的查询方法中也有关于初始化分类标签的逻辑 + try { + if(CollectionUtils.isEmpty(result.getDefaulted())){ + CategoryTagInitFormDTO dto = new CategoryTagInitFormDTO(); + dto.setCustomerId(tokenDto.getCustomerId()); + issueProjectCategoryDictService.init(dto); + Map> map1 = issueProjectTagDictRedis.getDefaultTagsSortedByCategoryAndCustomizedTagsOrderByRank(tokenDto.getCustomerId(), + formDTO.getCategoryIdList()); + result.setDefaulted(map1.get(ModuleConstants.DEFAULT_TAG_CATEGORY_NAME)); + } + } catch (Exception e) { + logger.error("客户初始化分类、标签失败,客户Id->"+tokenDto.getCustomerId(), e); + } + //end List list = map.get(ModuleConstants.CUSTOMIZED_TAG_CATEGORY_NAME); if (CollectionUtils.isNotEmpty(list)) { result.setCustomized(list.stream().limit(NumConstant.TEN).collect(Collectors.toList()));