|
|
@ -21,33 +21,40 @@ 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.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
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.dto.IssueCategoryDTO; |
|
|
|
import com.epmet.dto.IssueDTO; |
|
|
|
import com.epmet.dto.IssueProjectCategoryDictDTO; |
|
|
|
import com.epmet.dto.form.CategoryTagInitFormDTO; |
|
|
|
import com.epmet.dto.form.IssueProjectCategoryDictListFormDTO; |
|
|
|
import com.epmet.dto.form.ProjectSaveCategoryFormDTO; |
|
|
|
import com.epmet.dto.form.SaveIssueCategoryFormDTO; |
|
|
|
import com.epmet.dto.ProjectCategoryDTO; |
|
|
|
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.entity.IssueProjectCategoryDictEntity; |
|
|
|
import com.epmet.entity.IssueProjectTagDictEntity; |
|
|
|
import com.epmet.feign.GovProjectOpenFeignClient; |
|
|
|
import com.epmet.project.dto.result.ProjectCategoryDictResultDTO; |
|
|
|
import com.epmet.redis.IssueProjectCategoryDictRedis; |
|
|
|
import com.epmet.service.IssueProjectCategoryDictService; |
|
|
|
import com.epmet.service.IssueProjectTagDictService; |
|
|
|
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; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
@ -62,6 +69,7 @@ import java.util.stream.Collectors; |
|
|
|
@Service |
|
|
|
public class IssueProjectCategoryDictServiceImpl extends BaseServiceImpl<IssueProjectCategoryDictDao, IssueProjectCategoryDictEntity> implements IssueProjectCategoryDictService { |
|
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(IssueProjectCategoryDictServiceImpl.class); |
|
|
|
@Autowired |
|
|
|
private IssueProjectCategoryDictRedis issueProjectCategoryDictRedis; |
|
|
|
@Autowired |
|
|
@ -69,6 +77,11 @@ public class IssueProjectCategoryDictServiceImpl extends BaseServiceImpl<IssuePr |
|
|
|
@Autowired |
|
|
|
private IssueProjectTagDictService issueProjectTagDictService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IssueCategoryDao issueCategoryDao; |
|
|
|
@Autowired |
|
|
|
private GovProjectOpenFeignClient govProjectOpenFeignClient; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<IssueProjectCategoryDictDTO> page(Map<String, Object> params) { |
|
|
|
IPage<IssueProjectCategoryDictEntity> page = baseDao.selectPage( |
|
|
@ -208,18 +221,74 @@ public class IssueProjectCategoryDictServiceImpl extends BaseServiceImpl<IssuePr |
|
|
|
* @Author sun |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public ProjectIssueCategoryResultDTO isDisableCategory(ProjectSaveCategoryFormDTO formDTO) { |
|
|
|
return null; |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void isDisableCategory(IsDisableCategoryFormDTO formDTO) { |
|
|
|
//1.查询客户分类信息
|
|
|
|
IssueProjectCategoryDictDTO dto = baseDao.selectByCustomerId(formDTO.getCustomerId(), formDTO.getCategoryId()); |
|
|
|
if (null == dto) { |
|
|
|
throw new RuntimeException("未查询到客户分类信息!"); |
|
|
|
} |
|
|
|
//2.汇总二级分类Id集合
|
|
|
|
//待修改的分类Id汇总
|
|
|
|
List<String> categoryList = new ArrayList<>(); |
|
|
|
//待修改的二级分类Id汇总
|
|
|
|
List<String> secondList = new ArrayList<>(); |
|
|
|
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()); |
|
|
|
categoryList.add(formDTO.getCategoryId()); |
|
|
|
}else { |
|
|
|
secondList.add(formDTO.getCategoryId()); |
|
|
|
} |
|
|
|
categoryList.addAll(secondList); |
|
|
|
formDTO.setCategoryList(categoryList); |
|
|
|
|
|
|
|
//3.修改标签、分类表数据状态
|
|
|
|
if(baseDao.updateCustomerCategory(formDTO)<NumConstant.ONE){ |
|
|
|
logger.error(String.format("修改分类信息状态失败,客户Id->%s,分类Id->%s", formDTO.getCustomerId(), formDTO.getCategoryId())); |
|
|
|
throw new RuntimeException("分类信息修改失败!"); |
|
|
|
} |
|
|
|
//4.修改缓存中标签状态 todo
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 分类删除 |
|
|
|
* 分类客户没有使用过的可以直接删除 包括子类删除,只要客户用过 不管什么状态都不能再删除,允许删除的也跟标签没关系,不删标签 |
|
|
|
* @Author sun |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public ProjectIssueCategoryResultDTO delCategory(ProjectSaveCategoryFormDTO formDTO) { |
|
|
|
return null; |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void delCategory(DelCategoryFormDTO formDTO) { |
|
|
|
//1.查询分类信息
|
|
|
|
IssueProjectCategoryDictDTO dto = baseDao.selectByCustomerId(formDTO.getCustomerId(), formDTO.getCategoryId()); |
|
|
|
if (null == dto) { |
|
|
|
throw new RuntimeException("未查询到客户分类信息!"); |
|
|
|
} |
|
|
|
//2.判断分类有没有被客户的议题、项目使用过
|
|
|
|
formDTO.setLevel(dto.getCategoryType()); |
|
|
|
//2-1.判断议题有无使用
|
|
|
|
List<IssueCategoryDTO> issueList = issueCategoryDao.selectIssueList(formDTO); |
|
|
|
//已使用,不允许删除
|
|
|
|
if (null != issueList || issueList.size() > NumConstant.ZERO) { |
|
|
|
throw new RenException(EpmetErrorCode.CUSTOMER_CATEGORY.getCode(), EpmetErrorCode.CUSTOMER_CATEGORY.getMsg()); |
|
|
|
} |
|
|
|
//2-2.判断项目有无使用
|
|
|
|
Result<List<ProjectCategoryDTO>> resultList = govProjectOpenFeignClient.getProjectCategoryList(formDTO); |
|
|
|
if (!resultList.success()) { |
|
|
|
throw new RenException(resultList.getCode(), resultList.getMsg()); |
|
|
|
} |
|
|
|
if (null != resultList.getData() || resultList.getData().size() > NumConstant.ZERO) { |
|
|
|
throw new RenException(EpmetErrorCode.CUSTOMER_CATEGORY.getCode(), EpmetErrorCode.CUSTOMER_CATEGORY.getMsg()); |
|
|
|
} |
|
|
|
|
|
|
|
//3.分类未被使用,则删除一级、二级分类,二级分类下默认有的标签不作处理
|
|
|
|
if (baseDao.delCategory(formDTO) < NumConstant.ONE) { |
|
|
|
logger.error(String.format("分类删除失败,客户Id->%s,分类Id->%s", formDTO.getCustomerId(), formDTO.getCategoryId())); |
|
|
|
throw new RuntimeException("分类删除失败!"); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|