|
|
@ -22,26 +22,35 @@ 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.RenException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.dao.IssueCategoryDao; |
|
|
|
import com.epmet.dao.IssueTagsDao; |
|
|
|
import com.epmet.dto.IssueCategoryDTO; |
|
|
|
import com.epmet.dto.IssueProjectCategoryDictDTO; |
|
|
|
import com.epmet.dto.form.IssueCategoryTagListFormDTO; |
|
|
|
import com.epmet.dto.form.IssueSaveCategoryFormDTO; |
|
|
|
import com.epmet.dto.form.SaveIssueCategoryFormDTO; |
|
|
|
import com.epmet.dto.result.IssueCategoryTagListResultDTO; |
|
|
|
import com.epmet.dto.result.IssueCategoryTagResultDTO; |
|
|
|
import com.epmet.dto.result.ProjectCategoryTagResultDTO; |
|
|
|
import com.epmet.entity.IssueCategoryEntity; |
|
|
|
import com.epmet.entity.IssueEntity; |
|
|
|
import com.epmet.redis.IssueCategoryRedis; |
|
|
|
import com.epmet.service.IssueCategoryService; |
|
|
|
import com.epmet.service.IssueProjectCategoryDictService; |
|
|
|
import com.epmet.service.IssueService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
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; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 议题所属分类表 |
|
|
@ -56,6 +65,10 @@ public class IssueCategoryServiceImpl extends BaseServiceImpl<IssueCategoryDao, |
|
|
|
private IssueCategoryRedis issueCategoryRedis; |
|
|
|
@Autowired |
|
|
|
private IssueTagsDao issueTagsDao; |
|
|
|
@Autowired |
|
|
|
private IssueService issueService; |
|
|
|
@Autowired |
|
|
|
private IssueProjectCategoryDictService issueProjectCategoryDictService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<IssueCategoryDTO> page(Map<String, Object> params) { |
|
|
@ -155,4 +168,52 @@ public class IssueCategoryServiceImpl extends BaseServiceImpl<IssueCategoryDao, |
|
|
|
return baseDao.selectCategoryByIssue(issueId); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param formDTO |
|
|
|
* @return |
|
|
|
* @Description 议题:保存/修改分类 |
|
|
|
* @Author sun |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public void saveCategory(IssueSaveCategoryFormDTO formDTO) { |
|
|
|
|
|
|
|
//1.查询议题所属客户和所属网格信息
|
|
|
|
IssueEntity issue = issueService.selectById(formDTO.getIssueId()); |
|
|
|
if (null == issue) { |
|
|
|
throw new RenException(String.format("根据议题Id获取议题信息失败,issueId->%s", formDTO.getIssueId())); |
|
|
|
} |
|
|
|
|
|
|
|
//2.批量查询分类信息
|
|
|
|
List<String> categoryIdList = formDTO.getCategoryList().stream().map(SaveIssueCategoryFormDTO::getId).collect(Collectors.toList()); |
|
|
|
List<IssueProjectCategoryDictDTO> categoryList = issueProjectCategoryDictService.getCategoryList(categoryIdList); |
|
|
|
if (null == categoryList) { |
|
|
|
throw new RenException(String.format("议题分类信息保存,根据分类Id获取分类信息失败")); |
|
|
|
} |
|
|
|
|
|
|
|
//3.汇总批量新增数据
|
|
|
|
List<IssueCategoryEntity> entityList = new ArrayList<>(); |
|
|
|
formDTO.getCategoryList().forEach(ca -> { |
|
|
|
IssueCategoryEntity entity = new IssueCategoryEntity(); |
|
|
|
entity.setCustomerId(issue.getCustomerId()); |
|
|
|
entity.setGridId(issue.getGridId()); |
|
|
|
entity.setIssueId(formDTO.getIssueId()); |
|
|
|
entity.setCategoryId(ca.getId()); |
|
|
|
categoryList.forEach(cl -> { |
|
|
|
if (ca.getId().equals(cl.getId())) { |
|
|
|
entity.setCategoryPids(cl.getPids()); |
|
|
|
} |
|
|
|
}); |
|
|
|
entityList.add(entity); |
|
|
|
}); |
|
|
|
|
|
|
|
//4.根据议题Id删除可能存在的分类信息
|
|
|
|
baseDao.delByIssueId(formDTO.getIssueId()); |
|
|
|
|
|
|
|
//5.批量保存议题分类信息
|
|
|
|
if (!insertBatch(entityList)) { |
|
|
|
throw new RenException(String.format("议题分类信息保存失败")); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |