Browse Source

议题、项目:保存/修改分类

master
sunyuchao 5 years ago
parent
commit
54c03c1dbd
  1. 28
      epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/IssueSaveCategoryFormDTO.java
  2. 27
      epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/SaveIssueCategoryFormDTO.java
  3. 7
      epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/feign/GovIssueOpenFeignClient.java
  4. 9
      epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/feign/fallback/GovIssueOpenFeignClientFallBack.java
  5. 31
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueCategoryController.java
  6. 28
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueProjectCategoryDictController.java
  7. 7
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueCategoryDao.java
  8. 9
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueProjectCategoryDictDao.java
  9. 6
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueProjectRelationDao.java
  10. 11
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueCategoryService.java
  11. 18
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueProjectCategoryDictService.java
  12. 61
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueCategoryServiceImpl.java
  13. 48
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueProjectCategoryDictServiceImpl.java
  14. 9
      epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueCategoryDao.xml
  15. 16
      epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueProjectCategoryDictDao.xml
  16. 12
      epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueProjectRelationDao.xml
  17. 6
      epmet-module/gov-project/gov-project-client/pom.xml
  18. 28
      epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/ProjectSaveCategoryFormDTO.java
  19. 26
      epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/SaveIssueCategoryFormDTO.java
  20. 27
      epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/result/ProjectIssueCategoryResultDTO.java
  21. 19
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/controller/ProjectCategoryController.java
  22. 5
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/dao/ProjectCategoryDao.java
  23. 9
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/ProjectCategoryService.java
  24. 49
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectCategoryServiceImpl.java
  25. 14
      epmet-module/gov-project/gov-project-server/src/main/resources/mapper/ProjectCategoryDao.xml

28
epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/IssueSaveCategoryFormDTO.java

@ -0,0 +1,28 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.List;
/**
* 议题保存/修改分类-接口入参
* @Author sun
*/
@Data
public class IssueSaveCategoryFormDTO implements Serializable {
private static final long serialVersionUID = 2599592072265715951L;
/**
* 议题Id
*/
@NotBlank(message = "议题ID不能为空",groups = {ProjectSaveCategoryFormDTO.SaveCategory.class})
private String issueId;
/**
* 议题分类集合
*/
private List<SaveIssueCategoryFormDTO> categoryList;
public interface SaveCategory{}
}

27
epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/SaveIssueCategoryFormDTO.java

@ -0,0 +1,27 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 议题保存/修改分类-接口入参
*
* @Author sun
*/
@Data
public class SaveIssueCategoryFormDTO implements Serializable {
private static final long serialVersionUID = 2599592072265715951L;
/**
* 分类Id
*/
private String id;
/**
* 分类名称
*/
private String name;
}

7
epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/feign/GovIssueOpenFeignClient.java

@ -216,4 +216,11 @@ public interface GovIssueOpenFeignClient {
**/
@PostMapping(value = "/gov/issue/issuecategory/projectcategorylist")
Result<List<ProjectCategoryTagResultDTO>> projectCategoryList(@RequestBody List<String> categoryIdList);
/**
* @description 查询项目所属客户和所属网格信息以及分类对应的分类信息
* @author sun
**/
@PostMapping(value = "/gov/issue/issueprojectcategorydict/getprojectandcategoryinfo")
Result<ProjectIssueCategoryResultDTO> getProjectAndCategoryInfo(ProjectSaveCategoryFormDTO formDTO);
}

9
epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/feign/fallback/GovIssueOpenFeignClientFallBack.java

@ -202,4 +202,13 @@ public class GovIssueOpenFeignClientFallBack implements GovIssueOpenFeignClient
public Result<List<ProjectCategoryTagResultDTO>> projectCategoryList(List<String> categoryIdList) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ISSUE_SERVER, "projectCategoryList", categoryIdList);
}
/**
* @description 查询项目所属客户和所属网格信息以及分类对应的分类信息
* @author sun
**/
@Override
public Result<ProjectIssueCategoryResultDTO> getProjectAndCategoryInfo(ProjectSaveCategoryFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ISSUE_SERVER, "getProjectAndCategoryInfo", formDTO);
}
}

31
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueCategoryController.java

@ -17,6 +17,8 @@
package com.epmet.controller;
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.ExcelUtils;
import com.epmet.commons.tools.utils.Result;
@ -27,6 +29,7 @@ import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.IssueCategoryDTO;
import com.epmet.dto.form.IssueCategoryTagListFormDTO;
import com.epmet.dto.form.IssueSaveCategoryFormDTO;
import com.epmet.dto.result.IssueCategoryTagListResultDTO;
import com.epmet.dto.result.ProjectCategoryTagResultDTO;
import com.epmet.excel.IssueCategoryExcel;
@ -48,24 +51,24 @@ import java.util.Map;
@RestController
@RequestMapping("issuecategory")
public class IssueCategoryController {
@Autowired
private IssueCategoryService issueCategoryService;
@GetMapping("page")
public Result<PageData<IssueCategoryDTO>> page(@RequestParam Map<String, Object> params){
public Result<PageData<IssueCategoryDTO>> page(@RequestParam Map<String, Object> params) {
PageData<IssueCategoryDTO> page = issueCategoryService.page(params);
return new Result<PageData<IssueCategoryDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<IssueCategoryDTO> get(@PathVariable("id") String id){
public Result<IssueCategoryDTO> get(@PathVariable("id") String id) {
IssueCategoryDTO data = issueCategoryService.get(id);
return new Result<IssueCategoryDTO>().ok(data);
}
@PostMapping
public Result save(@RequestBody IssueCategoryDTO dto){
public Result save(@RequestBody IssueCategoryDTO dto) {
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
issueCategoryService.save(dto);
@ -73,7 +76,7 @@ public class IssueCategoryController {
}
@PutMapping
public Result update(@RequestBody IssueCategoryDTO dto){
public Result update(@RequestBody IssueCategoryDTO dto) {
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
issueCategoryService.update(dto);
@ -81,7 +84,7 @@ public class IssueCategoryController {
}
@DeleteMapping
public Result delete(@RequestBody String[] ids){
public Result delete(@RequestBody String[] ids) {
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
issueCategoryService.delete(ids);
@ -117,4 +120,20 @@ public class IssueCategoryController {
return new Result<List<ProjectCategoryTagResultDTO>>().ok(issueCategoryService.projectCategoryList(categoryIdList));
}
/**
* @param formDTO
* @return
* @Description 议题保存/修改分类
* @Author sun
**/
@PostMapping("save")
public Result saveCategory(@RequestBody IssueSaveCategoryFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, IssueSaveCategoryFormDTO.SaveCategory.class);
if(formDTO.getCategoryList().size()< NumConstant.ONE){
throw new RenException("请至少选择一个分类保存");
}
issueCategoryService.saveCategory(formDTO);
return new Result();
}
}

28
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueProjectCategoryDictController.java

@ -23,13 +23,13 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.AssertUtils;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.IssueProjectCategoryDictDTO;
import com.epmet.dto.form.CustomerCategoryListFormDTO;
import com.epmet.dto.form.IssueCategoryTagListFormDTO;
import com.epmet.dto.form.ProjectSaveCategoryFormDTO;
import com.epmet.dto.result.CustomerCategoryListResultDTO;
import com.epmet.dto.result.ProjectCategoryTagResultDTO;
import com.epmet.dto.result.ProjectIssueCategoryResultDTO;
import com.epmet.excel.IssueProjectCategoryDictExcel;
import com.epmet.service.IssueProjectCategoryDictService;
import org.springframework.beans.factory.annotation.Autowired;
@ -107,4 +107,26 @@ public class IssueProjectCategoryDictController {
return new Result<List<CustomerCategoryListResultDTO>>().ok(issueProjectCategoryDictService.categoryList(formDTO));
}
/**
* @param cstegoryIdList
* @return
* @Description 批量查询分类信息
* @Author sun
**/
@PostMapping("getcategorylist")
public Result<List<IssueProjectCategoryDictDTO>> getCategoryList(@RequestBody List<String> cstegoryIdList) {
return new Result<List<IssueProjectCategoryDictDTO>>().ok(issueProjectCategoryDictService.getCategoryList(cstegoryIdList));
}
/**
* @param formDTO
* @return
* @Description 查询项目所属客户和所属网格信息以及分类对应的分类信息
* @Author sun
**/
@PostMapping("getprojectandcategoryinfo")
public Result<ProjectIssueCategoryResultDTO> getProjectAndCategoryInfo(@RequestBody ProjectSaveCategoryFormDTO formDTO) {
return new Result<ProjectIssueCategoryResultDTO>().ok(issueProjectCategoryDictService.getProjectAndCategoryInfo(formDTO));
}
}

7
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueCategoryDao.java

@ -49,7 +49,6 @@ public interface IssueCategoryDao extends BaseDao<IssueCategoryEntity> {
* @Author sun
**/
List<ProjectCategoryTagResultDTO> selectProjectCategoryList(@Param("categoryIdList") List<String> categoryIdList);
List<ProjectCategoryTagResultDTO> selectProjectCategoryList(List<String> categoryIdList);
/**
* 获取议题分类
@ -59,4 +58,10 @@ public interface IssueCategoryDao extends BaseDao<IssueCategoryEntity> {
* @return java.util.List<com.epmet.dto.IssueCategoryDTO>
*/
List<IssueCategoryDTO> selectCategoryByIssue(@Param("issueId") String issueId);
/**
* @Description 删除议题的分类信息
* @Author sun
**/
void delByIssueId(@Param("issueId") String issueId);
}

9
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueProjectCategoryDictDao.java

@ -18,6 +18,7 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.IssueProjectCategoryDictDTO;
import com.epmet.dto.result.CustomerCategoryListResultDTO;
import com.epmet.entity.IssueProjectCategoryDictEntity;
import org.apache.ibatis.annotations.Mapper;
@ -44,4 +45,12 @@ public interface IssueProjectCategoryDictDao extends BaseDao<IssueProjectCategor
* @Author sun
**/
List<CustomerCategoryListResultDTO> subCategoryList(@Param("id") String categoryId);
/**
* @param cstegoryIdList
* @return
* @Description 批量查询分类信息
* @Author sun
**/
List<IssueProjectCategoryDictDTO> selectCategoryList(@Param("cstegoryIdList") List<String> cstegoryIdList);
}

6
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueProjectRelationDao.java

@ -18,6 +18,7 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.IssueDTO;
import com.epmet.entity.IssueProjectRelationEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -50,4 +51,9 @@ public interface IssueProjectRelationDao extends BaseDao<IssueProjectRelationEnt
**/
List<IssueProjectRelationEntity> selectRelationList(@Param("projectIdList") List<String> projectIdList);
/**
* @Author sun
* @Description 根据项目id查询对应的议题基本信息
**/
IssueDTO selectProjectToIssue(@Param("issueId") String issueId);
}

11
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueCategoryService.java

@ -21,6 +21,7 @@ import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.IssueCategoryDTO;
import com.epmet.dto.form.IssueCategoryTagListFormDTO;
import com.epmet.dto.form.IssueSaveCategoryFormDTO;
import com.epmet.dto.result.IssueCategoryTagListResultDTO;
import com.epmet.dto.result.ProjectCategoryTagResultDTO;
import com.epmet.entity.IssueCategoryEntity;
@ -120,4 +121,14 @@ public interface IssueCategoryService extends BaseService<IssueCategoryEntity> {
* @return java.util.List<com.epmet.dto.IssueCategoryDTO>
*/
List<IssueCategoryDTO> getCategoryByIssue(String issueId);
/**
* @param formDTO
* @return
* @Description 议题保存/修改分类
* @Author sun
**/
void saveCategory(IssueSaveCategoryFormDTO formDTO);
}

18
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueProjectCategoryDictService.java

@ -21,7 +21,9 @@ import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.IssueProjectCategoryDictDTO;
import com.epmet.dto.form.CustomerCategoryListFormDTO;
import com.epmet.dto.form.ProjectSaveCategoryFormDTO;
import com.epmet.dto.result.CustomerCategoryListResultDTO;
import com.epmet.dto.result.ProjectIssueCategoryResultDTO;
import com.epmet.entity.IssueProjectCategoryDictEntity;
import java.util.List;
@ -102,4 +104,20 @@ public interface IssueProjectCategoryDictService extends BaseService<IssueProjec
* @Author sun
**/
List<CustomerCategoryListResultDTO> categoryList(CustomerCategoryListFormDTO formDTO);
/**
* @param cstegoryIdList
* @return
* @Description 批量查询分类信息
* @Author sun
**/
List<IssueProjectCategoryDictDTO> getCategoryList(List<String> cstegoryIdList);
/**
* @param formDTO
* @return
* @Description 查询项目所属客户和所属网格信息以及分类对应的分类信息
* @Author sun
**/
ProjectIssueCategoryResultDTO getProjectAndCategoryInfo(ProjectSaveCategoryFormDTO formDTO);
}

61
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueCategoryServiceImpl.java

@ -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("议题分类信息保存失败"));
}
}
}

48
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueProjectCategoryDictServiceImpl.java

@ -20,13 +20,19 @@ 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.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.dao.IssueProjectCategoryDictDao;
import com.epmet.dao.IssueProjectRelationDao;
import com.epmet.dto.IssueDTO;
import com.epmet.dto.IssueProjectCategoryDictDTO;
import com.epmet.dto.form.CustomerCategoryListFormDTO;
import com.epmet.dto.form.ProjectSaveCategoryFormDTO;
import com.epmet.dto.form.SaveIssueCategoryFormDTO;
import com.epmet.dto.result.CustomerCategoryListResultDTO;
import com.epmet.dto.result.ProjectIssueCategoryResultDTO;
import com.epmet.entity.IssueProjectCategoryDictEntity;
import com.epmet.redis.IssueProjectCategoryDictRedis;
import com.epmet.service.IssueProjectCategoryDictService;
@ -38,6 +44,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 议题项目分类字典
@ -50,6 +57,8 @@ public class IssueProjectCategoryDictServiceImpl extends BaseServiceImpl<IssuePr
@Autowired
private IssueProjectCategoryDictRedis issueProjectCategoryDictRedis;
@Autowired
private IssueProjectRelationDao issueProjectRelationDao;
@Override
public PageData<IssueProjectCategoryDictDTO> page(Map<String, Object> params) {
@ -115,4 +124,41 @@ public class IssueProjectCategoryDictServiceImpl extends BaseServiceImpl<IssuePr
return resultList;
}
/**
* @param cstegoryIdList
* @return
* @Description 批量查询分类信息
* @Author sun
**/
@Override
public List<IssueProjectCategoryDictDTO> getCategoryList(List<String> cstegoryIdList) {
return baseDao.selectCategoryList(cstegoryIdList);
}
/**
* @param formDTO
* @return
* @Description 查询项目所属客户和所属网格信息以及分类对应的分类信息
* @Author sun
**/
@Override
public ProjectIssueCategoryResultDTO getProjectAndCategoryInfo(ProjectSaveCategoryFormDTO formDTO) {
ProjectIssueCategoryResultDTO resultDTO = new ProjectIssueCategoryResultDTO();
//1.根据项目id查询对应的议题基本信息
IssueDTO dto = issueProjectRelationDao.selectProjectToIssue(formDTO.getProjectId());
if (null == dto) {
throw new RenException(String.format("保存项目分类信息,获取项目对应的议题基本信息失败,projectId->%s", formDTO.getProjectId()));
}
resultDTO.setIssueDTO(dto);
//2.批量查询分类信息
List<String> categoryIdList = formDTO.getCategoryList().stream().map(SaveIssueCategoryFormDTO::getId).collect(Collectors.toList());
List<IssueProjectCategoryDictDTO> categoryList = getCategoryList(categoryIdList);
if (null == categoryList) {
throw new RenException(String.format("保存项目分类信息,根据分类Id获取分类信息失败"));
}
resultDTO.setCategoryList(categoryList);
return resultDTO;
}
}

9
epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueCategoryDao.xml

@ -34,6 +34,7 @@
ORDER BY
sort ASC
</select>
<select id="selectCategoryByIssue" resultType="com.epmet.dto.IssueCategoryDTO">
SELECT
CUSTOMER_ID,
@ -45,4 +46,12 @@
AND ISSUE_ID = #{issueId}
</select>
<delete id="delByIssueId">
DELETE
FROM
issue_category
WHERE
issue_id = #{issueId}
</delete>
</mapper>

16
epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueProjectCategoryDictDao.xml

@ -36,4 +36,20 @@
</select>
<!-- sql递归 查询客户议题项目的分类信息以及递归查询二级分类信息 end-->
<select id="selectCategoryList" resultType="com.epmet.dto.IssueProjectCategoryDictDTO">
SELECT
*
FROM
issue_project_category_dict
WHERE
del_flag = '0'
<if test="cstegoryIdList != null and cstegoryIdList.size() > 0">
<foreach collection="cstegoryIdList" item="id" open="AND( " separator=" OR " index="index" close=")">
id = #{id}
</foreach>
</if>
ORDER BY
sort ASC
</select>
</mapper>

12
epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueProjectRelationDao.xml

@ -46,4 +46,16 @@
)
</select>
<select id="selectProjectToIssue" resultType="com.epmet.dto.IssueDTO">
SELECT
i.*
FROM
issue_project_relation ipr
INNER JOIN issue i ON ipr.ISSUE_ID = i.ID
WHERE
ipr.DEL_FLAG = '0'
AND i.DEL_FLAG = '0'
AND ipr.PROJECT_ID = #{issueId}
</select>
</mapper>

6
epmet-module/gov-project/gov-project-client/pom.xml

@ -23,5 +23,11 @@
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>gov-issue-client</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

28
epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/ProjectSaveCategoryFormDTO.java

@ -0,0 +1,28 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.List;
/**
* 议题保存/修改分类-接口入参
* @Author sun
*/
@Data
public class ProjectSaveCategoryFormDTO implements Serializable {
private static final long serialVersionUID = 2599592072265715951L;
/**
* 议题Id
*/
@NotBlank(message = "项目ID不能为空",groups = {SaveCategory.class})
private String projectId;
/**
* 议题分类集合
*/
private List<SaveIssueCategoryFormDTO> categoryList;
public interface SaveCategory{}
}

26
epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/SaveIssueCategoryFormDTO.java

@ -0,0 +1,26 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* 议题保存/修改分类-接口入参
*
* @Author sun
*/
@Data
public class SaveIssueCategoryFormDTO implements Serializable {
private static final long serialVersionUID = 2599592072265715951L;
/**
* 分类Id
*/
private String id;
/**
* 分类名称
*/
private String name;
}

27
epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/result/ProjectIssueCategoryResultDTO.java

@ -0,0 +1,27 @@
package com.epmet.dto.result;
import com.epmet.dto.IssueDTO;
import com.epmet.dto.IssueProjectCategoryDictDTO;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @dscription 项目所属网格分类基本信息-接口返参
* @author sun
*/
@Data
public class ProjectIssueCategoryResultDTO implements Serializable {
private static final long serialVersionUID = 5957826616179876849L;
/**
* 项目Id
*/
private IssueDTO issueDTO;
/**
* 项目标题
*/
private List<IssueProjectCategoryDictDTO> categoryList;
}

19
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/controller/ProjectCategoryController.java

@ -17,6 +17,8 @@
package com.epmet.controller;
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.ExcelUtils;
import com.epmet.commons.tools.utils.Result;
@ -27,6 +29,7 @@ import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.ProjectCategoryDTO;
import com.epmet.dto.form.ProjectCategoryTagListFormDTO;
import com.epmet.dto.form.ProjectSaveCategoryFormDTO;
import com.epmet.dto.result.ProjectCategoryTagListResultDTO;
import com.epmet.excel.ProjectCategoryExcel;
import com.epmet.service.ProjectCategoryService;
@ -105,4 +108,20 @@ public class ProjectCategoryController {
return new Result<ProjectCategoryTagListResultDTO>().ok(projectCategoryService.categoryTagList(formDTO));
}
/**
* @param formDTO
* @return
* @Description 项目保存/修改分类
* @Author sun
**/
@PostMapping("save")
public Result saveCategory(@RequestBody ProjectSaveCategoryFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, ProjectSaveCategoryFormDTO.SaveCategory.class);
if(formDTO.getCategoryList().size()< NumConstant.ONE){
throw new RenException("请至少选择一个分类保存");
}
projectCategoryService.saveCategory(formDTO);
return new Result();
}
}

5
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/dao/ProjectCategoryDao.java

@ -39,4 +39,9 @@ public interface ProjectCategoryDao extends BaseDao<ProjectCategoryEntity> {
**/
List<String> selectProjectCategoryIdList(@Param("projectId") String projectId);
/**
* @Description 删除项目的分类信息
* @Author sun
**/
void delByProjectId(@Param("projectId") String projectId);
}

9
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/ProjectCategoryService.java

@ -21,6 +21,7 @@ import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.ProjectCategoryDTO;
import com.epmet.dto.form.ProjectCategoryTagListFormDTO;
import com.epmet.dto.form.ProjectSaveCategoryFormDTO;
import com.epmet.dto.result.ProjectCategoryTagListResultDTO;
import com.epmet.entity.ProjectCategoryEntity;
@ -102,4 +103,12 @@ public interface ProjectCategoryService extends BaseService<ProjectCategoryEntit
* @Author sun
**/
ProjectCategoryTagListResultDTO categoryTagList(ProjectCategoryTagListFormDTO formDTO);
/**
* @param formDTO
* @return
* @Description 项目保存/修改分类
* @Author sun
**/
void saveCategory(ProjectSaveCategoryFormDTO formDTO);
}

49
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectCategoryServiceImpl.java

@ -22,17 +22,20 @@ 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.ProjectCategoryDao;
import com.epmet.dao.ProjectTagsDao;
import com.epmet.dto.IssueDTO;
import com.epmet.dto.IssueProjectCategoryDictDTO;
import com.epmet.dto.ProjectCategoryDTO;
import com.epmet.dto.form.ProjectCategoryTagListFormDTO;
import com.epmet.dto.form.ProjectSaveCategoryFormDTO;
import com.epmet.dto.result.ProjectCategoryTagListResultDTO;
import com.epmet.dto.result.ProjectCategoryTagResultDTO;
import com.epmet.dto.result.ProjectIssueCategoryResultDTO;
import com.epmet.entity.ProjectCategoryEntity;
import com.epmet.feign.GovIssueOpenFeignClient;
import com.epmet.redis.ProjectCategoryRedis;
@ -42,6 +45,7 @@ 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;
@ -141,4 +145,47 @@ public class ProjectCategoryServiceImpl extends BaseServiceImpl<ProjectCategoryD
return resultDTO;
}
/**
* @param formDTO
* @return
* @Description 项目保存/修改分类
* @Author sun
**/
@Override
public void saveCategory(ProjectSaveCategoryFormDTO formDTO) {
//1.查询项目所属客户和所属网格信息以及分类对应的分类信息
Result<ProjectIssueCategoryResultDTO> result = govIssueOpenFeignClient.getProjectAndCategoryInfo(formDTO);
if (!result.success()) {
throw new RenException(String.format("保存项目分类,获取项目对应的议题信息以及分类信息失败,projiectId->%s", formDTO.getProjectId()));
}
IssueDTO issue = result.getData().getIssueDTO();
List<IssueProjectCategoryDictDTO> categoryList = result.getData().getCategoryList();
//2.汇总批量新增数据
List<ProjectCategoryEntity> entityList = new ArrayList<>();
formDTO.getCategoryList().forEach(ca -> {
ProjectCategoryEntity entity = new ProjectCategoryEntity();
entity.setCustomerId(issue.getCustomerId());
entity.setGridId(issue.getGridId());
entity.setProjectId(formDTO.getProjectId());
entity.setCategoryId(ca.getId());
categoryList.forEach(cl -> {
if (ca.getId().equals(cl.getId())) {
entity.setCategoryPids(cl.getPids());
}
});
entityList.add(entity);
});
//3.根据议题Id删除可能存在的分类信息
baseDao.delByProjectId(formDTO.getProjectId());
//4.批量保存议题分类信息
if (!insertBatch(entityList)) {
throw new RenException(String.format("项目分类信息保存失败"));
}
}
}

14
epmet-module/gov-project/gov-project-server/src/main/resources/mapper/ProjectCategoryDao.xml

@ -5,12 +5,20 @@
<select id="selectProjectCategoryIdList" resultType="java.lang.String">
SELECT
CATEGORY_ID
category_id
FROM
project_category
WHERE
DEL_FLAG = '0'
AND PROJECT_ID = #{projectId}
del_flag = '0'
AND project_id = #{projectId}
</select>
<delete id="delByProjectId">
DELETE
FROM
project_category
WHERE
project_id = #{projectId}
</delete>
</mapper>
Loading…
Cancel
Save