|
|
@ -30,12 +30,10 @@ import com.epmet.commons.tools.utils.Result; |
|
|
|
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.form.*; |
|
|
|
import com.epmet.dto.result.CustomerCategoryListResultDTO; |
|
|
|
import com.epmet.dto.result.ProjectCategoryDTOResultDTO; |
|
|
|
import com.epmet.dto.result.ProjectIssueCategoryResultDTO; |
|
|
|
import com.epmet.dto.result.ProjectIssueDTOResultDTO; |
|
|
|
import com.epmet.dto.result.*; |
|
|
|
import com.epmet.entity.IssueProjectCategoryDictEntity; |
|
|
|
import com.epmet.entity.IssueProjectTagDictEntity; |
|
|
|
import com.epmet.feign.GovProjectOpenFeignClient; |
|
|
@ -80,6 +78,8 @@ public class IssueProjectCategoryDictServiceImpl extends BaseServiceImpl<IssuePr |
|
|
|
private GovProjectOpenFeignClient govProjectOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private OperCrmOpenFeignClient operCrmOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private IssueProjectTagDictDao issueProjectTagDictDao; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<IssueProjectCategoryDictDTO> page(Map<String, Object> params) { |
|
|
@ -246,25 +246,32 @@ public class IssueProjectCategoryDictServiceImpl extends BaseServiceImpl<IssuePr |
|
|
|
List<String> categoryList = new ArrayList<>(); |
|
|
|
//待修改的二级分类Id汇总
|
|
|
|
List<String> secondList = new ArrayList<>(); |
|
|
|
if("1".equals(dto.getCategoryType())){ |
|
|
|
if ("1".equals(dto.getCategoryType())) { |
|
|
|
//2-1.查询子类信息
|
|
|
|
List<ProjectCategoryDictResultDTO> subList = baseDao.selectSubCustomerCategoryDict(formDTO.getCustomerId(),formDTO.getCategoryId()); |
|
|
|
secondList = subList.stream().map(sub->sub.getId()).collect(Collectors.toList()); |
|
|
|
List<ProjectCategoryDictResultDTO> subList = baseDao.selectSubCustomerCategoryDict(formDTO.getCustomerId(), formDTO.getCategoryId()); |
|
|
|
secondList = subList.stream().map(sub -> sub.getId()).collect(Collectors.toList()); |
|
|
|
categoryList.add(formDTO.getCategoryId()); |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
secondList.add(formDTO.getCategoryId()); |
|
|
|
} |
|
|
|
categoryList.addAll(secondList); |
|
|
|
formDTO.setCategoryList(categoryList); |
|
|
|
formDTO.setSecondCategorylist(secondList); |
|
|
|
|
|
|
|
//3.修改标签、分类表数据状态
|
|
|
|
if(baseDao.updateCustomerCategory(formDTO)<NumConstant.ONE){ |
|
|
|
//修改分类数据
|
|
|
|
if (baseDao.updateCustomerCategory(formDTO) < NumConstant.ONE) { |
|
|
|
logger.error(String.format("修改分类信息状态失败,客户Id->%s,分类Id->%s", formDTO.getCustomerId(), formDTO.getCategoryId())); |
|
|
|
throw new RuntimeException("分类信息修改失败!"); |
|
|
|
} |
|
|
|
//修改吧二级分类下默认的标签数据
|
|
|
|
if (issueProjectTagDictDao.updateCustomerTag(formDTO) < NumConstant.ONE) { |
|
|
|
logger.error(String.format("修改标签信息状态失败,客户Id->%s,分类Id->%s", formDTO.getCustomerId(), formDTO.getCategoryId())); |
|
|
|
throw new RuntimeException("分类、标签信息修改失败!"); |
|
|
|
} |
|
|
|
//4.修改缓存中标签状态 todo
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 分类删除 |
|
|
@ -284,7 +291,7 @@ public class IssueProjectCategoryDictServiceImpl extends BaseServiceImpl<IssuePr |
|
|
|
//2-1.判断议题有无使用
|
|
|
|
List<IssueCategoryDTO> issueList = issueCategoryDao.selectIssueList(formDTO); |
|
|
|
//已使用,不允许删除
|
|
|
|
if (null != issueList || issueList.size() > NumConstant.ZERO) { |
|
|
|
if (null != issueList && issueList.size() > NumConstant.ZERO) { |
|
|
|
throw new RenException(EpmetErrorCode.CUSTOMER_CATEGORY.getCode(), EpmetErrorCode.CUSTOMER_CATEGORY.getMsg()); |
|
|
|
} |
|
|
|
//2-2.判断项目有无使用
|
|
|
@ -292,7 +299,7 @@ public class IssueProjectCategoryDictServiceImpl extends BaseServiceImpl<IssuePr |
|
|
|
if (!resultList.success()) { |
|
|
|
throw new RenException(resultList.getCode(), resultList.getMsg()); |
|
|
|
} |
|
|
|
if (null != resultList.getData() || resultList.getData().size() > NumConstant.ZERO) { |
|
|
|
if (null != resultList.getData() && resultList.getData().size() > NumConstant.ZERO) { |
|
|
|
throw new RenException(EpmetErrorCode.CUSTOMER_CATEGORY.getCode(), EpmetErrorCode.CUSTOMER_CATEGORY.getMsg()); |
|
|
|
} |
|
|
|
|
|
|
@ -307,5 +314,149 @@ public class IssueProjectCategoryDictServiceImpl extends BaseServiceImpl<IssuePr |
|
|
|
@Override |
|
|
|
public List<ProjectCategoryDictResultDTO> listCategoryDict(String customerId, String pid) { |
|
|
|
return baseDao.selectListCategoryDict(customerId, pid); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<String> saveFirstCategory(SecondCategoryFormDTO formDTO) { |
|
|
|
// 分类名称在同一个客户下有效数据中不允许重复
|
|
|
|
Integer numCategoryName = baseDao.isCategoryName(formDTO.getCustomerId(), formDTO.getCategoryName(), null,null); |
|
|
|
if (NumConstant.ZERO < numCategoryName) { |
|
|
|
throw new RenException("现添加的一级分类名称 重复"); |
|
|
|
} |
|
|
|
IssueProjectCategoryDictEntity entity = this.packageFirstCategoryDictEntity(formDTO); |
|
|
|
baseDao.insert(entity); |
|
|
|
return new Result<String>().ok(entity.getId()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 一级分类 组装字段 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @return com.epmet.entity.IssueProjectCategoryDictEntity |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 10:46 2021-03-23 |
|
|
|
**/ |
|
|
|
private IssueProjectCategoryDictEntity packageFirstCategoryDictEntity(SecondCategoryFormDTO formDTO) { |
|
|
|
IssueProjectCategoryDictEntity entity = new IssueProjectCategoryDictEntity(); |
|
|
|
entity.setCustomerId(formDTO.getCustomerId()); |
|
|
|
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; |
|
|
|
} else { |
|
|
|
maxCategoryCode++; |
|
|
|
} |
|
|
|
entity.setCategoryCode(String.valueOf(maxCategoryCode)); |
|
|
|
|
|
|
|
entity.setCategoryName(formDTO.getCategoryName()); |
|
|
|
entity.setCategoryType(NumConstant.ONE_STR); |
|
|
|
entity.setSort(formDTO.getSort()); |
|
|
|
entity.setIsDisable("enable"); |
|
|
|
return entity; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<String> editFirstCategory(SecondCategoryFormDTO formDTO) { |
|
|
|
if (StringUtils.isBlank(formDTO.getCategoryId())) { |
|
|
|
throw new RenException("分类Id 不能为空"); |
|
|
|
} |
|
|
|
// 分类名称在同一个客户下有效数据中不允许重复
|
|
|
|
Integer numCategoryName = baseDao.isCategoryName(formDTO.getCustomerId(), formDTO.getCategoryName(), null, formDTO.getCategoryId()); |
|
|
|
if (NumConstant.ZERO < numCategoryName) { |
|
|
|
throw new RenException("现添加的一级分类名称 重复"); |
|
|
|
} |
|
|
|
IssueProjectCategoryDictEntity entity = new IssueProjectCategoryDictEntity(); |
|
|
|
entity.setCategoryName(formDTO.getCategoryName()); |
|
|
|
entity.setSort(formDTO.getSort()); |
|
|
|
entity.setId(formDTO.getCategoryId()); |
|
|
|
baseDao.updateById(entity); |
|
|
|
return new Result<>(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<String> saveSecondCategory(SecondCategoryFormDTO formDTO) { |
|
|
|
// 分类名称在同一个客户下同一 一级分类下有效数据中不允许重复
|
|
|
|
Integer numCategoryName = baseDao.isCategoryName(formDTO.getCustomerId(), formDTO.getCategoryName(), formDTO.getParentCategoryId(), null); |
|
|
|
if (NumConstant.ZERO < numCategoryName) { |
|
|
|
throw new RenException("现添加的二级分类名称 重复"); |
|
|
|
} |
|
|
|
IssueProjectCategoryDictEntity entity = this.packageSecondCategoryDictEntity(formDTO); |
|
|
|
baseDao.insert(entity); |
|
|
|
return new Result<String>().ok(entity.getId()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 二级分类 组装字段 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @return com.epmet.entity.IssueProjectCategoryDictEntity |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 10:46 2021-03-23 |
|
|
|
**/ |
|
|
|
private IssueProjectCategoryDictEntity packageSecondCategoryDictEntity(SecondCategoryFormDTO formDTO) { |
|
|
|
IssueProjectCategoryDictEntity entity = new IssueProjectCategoryDictEntity(); |
|
|
|
entity.setCustomerId(formDTO.getCustomerId()); |
|
|
|
entity.setPid(formDTO.getParentCategoryId()); |
|
|
|
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"); |
|
|
|
} else { |
|
|
|
maxCategoryCode++; |
|
|
|
} |
|
|
|
entity.setCategoryCode(String.valueOf(maxCategoryCode)); |
|
|
|
|
|
|
|
entity.setCategoryName(formDTO.getCategoryName()); |
|
|
|
entity.setCategoryType(NumConstant.TWO_STR); |
|
|
|
entity.setSort(formDTO.getSort()); |
|
|
|
entity.setIsDisable("enable"); |
|
|
|
return entity; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<String> editSecondCategory(SecondCategoryFormDTO formDTO) { |
|
|
|
if (StringUtils.isBlank(formDTO.getCategoryId())) { |
|
|
|
throw new RenException("分类Id 不能为空"); |
|
|
|
} |
|
|
|
// 分类名称在同一个客户下同一 一级分类下有效数据中不允许重复
|
|
|
|
Integer numCategoryName = baseDao.isCategoryName(formDTO.getCustomerId(), formDTO.getCategoryName(), formDTO.getParentCategoryId(), formDTO.getCategoryId()); |
|
|
|
if (NumConstant.ZERO < numCategoryName) { |
|
|
|
throw new RenException("现添加的二级分类名称 重复"); |
|
|
|
} |
|
|
|
IssueProjectCategoryDictEntity entity = new IssueProjectCategoryDictEntity(); |
|
|
|
entity.setCategoryName(formDTO.getCategoryName()); |
|
|
|
entity.setSort(formDTO.getSort()); |
|
|
|
entity.setId(formDTO.getCategoryId()); |
|
|
|
baseDao.updateById(entity); |
|
|
|
return new Result<>(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<CustomerCategoryResultDTO> customerCategoryList(String customerId) { |
|
|
|
List<CustomerCategoryResultDTO> parentCategoryDict = baseDao.selectListAllCategoryDict(customerId, NumConstant.ZERO_STR); |
|
|
|
List<CustomerCategoryResultDTO> childrenCategoryDict = baseDao.selectListAllCategoryDict(customerId, NumConstant.ONE_STR); |
|
|
|
|
|
|
|
for (CustomerCategoryResultDTO p : parentCategoryDict) { |
|
|
|
List<CustomerCategoryResultDTO> children = new ArrayList<>(); |
|
|
|
for (CustomerCategoryResultDTO c : childrenCategoryDict) { |
|
|
|
if (p.getCategoryId().equals(c.getPid())) { |
|
|
|
CustomerCategoryResultDTO dto = new CustomerCategoryResultDTO(); |
|
|
|
dto.setCategoryId(c.getCategoryId()); |
|
|
|
dto.setCategoryName(c.getCategoryName()); |
|
|
|
dto.setSort(c.getSort()); |
|
|
|
dto.setIsDisable(c.getIsDisable()); |
|
|
|
dto.setPid(c.getPid()); |
|
|
|
children.add(dto); |
|
|
|
} |
|
|
|
} |
|
|
|
p.setChildren(children); |
|
|
|
} |
|
|
|
return parentCategoryDict; |
|
|
|
} |
|
|
|
} |
|
|
|