|
|
@ -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<IssuePr |
|
|
|
@Override |
|
|
|
public List<CustomerCategoryListResultDTO> categoryList(String customerId) { |
|
|
|
List<CustomerCategoryListResultDTO> 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<IssuePr |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void init(CategoryTagInitFormDTO formDTO) { |
|
|
|
//2021.3.23 sun 不传客户Id时默认查询所有有效客户列表 循环添加
|
|
|
|
List<String> customerIdList = new ArrayList<>(); |
|
|
|
if(StringUtils.isBlank(formDTO.getCustomerId())){ |
|
|
|
Result<List<CustomerDTO>> 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<IssueProjectCategoryDictEntity> list = baseDao.selectCategoryListByCustomer(formDTO.getCustomerId()); |
|
|
|
if (CollectionUtils.isEmpty(list)) { |
|
|
|
//分类初始化
|
|
|
|
List<IssueProjectCategoryDictEntity> categoryList = baseDao.selectCategoryListByCustomer("default"); |
|
|
|
categoryList.forEach(item -> { |
|
|
|
item.setCustomerId(formDTO.getCustomerId()); |
|
|
|
}); |
|
|
|
this.insertBatch(categoryList); |
|
|
|
//标签初始化
|
|
|
|
List<IssueProjectTagDictEntity> tagList = issueProjectTagDictService.getTagListByCustomer("default"); |
|
|
|
tagList.forEach(item -> { |
|
|
|
item.setCustomerId(formDTO.getCustomerId()); |
|
|
|
}); |
|
|
|
issueProjectTagDictService.insertBatch(tagList); |
|
|
|
} |
|
|
|
//end sun
|
|
|
|
customerIdList.forEach(cu->{ |
|
|
|
List<IssueProjectCategoryDictEntity> list = baseDao.selectCategoryListByCustomer(cu); |
|
|
|
if (CollectionUtils.isEmpty(list)) { |
|
|
|
//分类初始化
|
|
|
|
List<IssueProjectCategoryDictEntity> categoryList = baseDao.selectCategoryListByCustomer("default"); |
|
|
|
categoryList.forEach(item -> { |
|
|
|
item.setCustomerId(cu); |
|
|
|
}); |
|
|
|
this.insertBatch(categoryList); |
|
|
|
//标签初始化
|
|
|
|
List<IssueProjectTagDictEntity> tagList = issueProjectTagDictService.getTagListByCustomer("default"); |
|
|
|
tagList.forEach(item -> { |
|
|
|
item.setCustomerId(cu); |
|
|
|
}); |
|
|
|
issueProjectTagDictService.insertBatch(tagList); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -345,7 +346,7 @@ public class IssueProjectCategoryDictServiceImpl extends BaseServiceImpl<IssuePr |
|
|
|
entity.setPid(NumConstant.ZERO_STR ); |
|
|
|
entity.setPids(NumConstant.ZERO_STR ); |
|
|
|
entity.setParentCategoryCode(NumConstant.ZERO_STR); |
|
|
|
// 查询 当前客户下,+1 后最大的一级分类数。从1开始
|
|
|
|
// 查询 当前客户下最大的一级分类数。
|
|
|
|
Integer maxCategoryCode = baseDao.getMaxCategoryCode(formDTO.getCustomerId(), NumConstant.ZERO_STR); |
|
|
|
if (NumConstant.ZERO == maxCategoryCode) { |
|
|
|
maxCategoryCode = 1001; |
|
|
@ -406,7 +407,7 @@ public class IssueProjectCategoryDictServiceImpl extends BaseServiceImpl<IssuePr |
|
|
|
entity.setPids(formDTO.getParentCategoryId()); |
|
|
|
IssueProjectCategoryDictEntity parentCategoryCode = baseDao.selectById(formDTO.getParentCategoryId()); |
|
|
|
entity.setParentCategoryCode(parentCategoryCode.getCategoryCode()); |
|
|
|
// 查询 当前客户下,+1 后最大的一级分类数
|
|
|
|
// 查询 当前客户下最大的一级分类数。
|
|
|
|
Integer maxCategoryCode = baseDao.getMaxCategoryCode(formDTO.getCustomerId(), parentCategoryCode.getCategoryCode()); |
|
|
|
if (NumConstant.ZERO == maxCategoryCode) { |
|
|
|
maxCategoryCode = Integer.valueOf(parentCategoryCode.getCategoryCode() + "1001"); |
|
|
|