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 6a21d19c46..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); - } - }); } /** diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueProjectTagDictServiceImpl.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueProjectTagDictServiceImpl.java index 5919990477..ee06f971d3 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueProjectTagDictServiceImpl.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueProjectTagDictServiceImpl.java @@ -20,25 +20,28 @@ package com.epmet.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.constant.GovIssueRedisKeys; import com.epmet.dao.IssueProjectTagDictDao; import com.epmet.dto.IssueProjectTagDictDTO; +import com.epmet.dto.form.CategoryTagInitFormDTO; import com.epmet.dto.form.TagDifferentSetFormDTO; import com.epmet.dto.form.TagListFormDTO; import com.epmet.dto.result.IssueCategoryTagResultDTO; -import com.epmet.dto.result.IssueProjectTagsResultDTO; import com.epmet.dto.result.TagListResultDTO; import com.epmet.entity.IssueProjectTagDictEntity; import com.epmet.redis.IssueProjectTagDictRedis; +import com.epmet.service.IssueProjectCategoryDictService; import com.epmet.service.IssueProjectTagDictService; import com.epmet.utils.ModuleConstants; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -55,8 +58,11 @@ import java.util.stream.Collectors; @Service public class IssueProjectTagDictServiceImpl 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()));