Browse Source

Merge remote-tracking branch 'origin/dev_issue_category' into dev_issue_category

master
wangchao 5 years ago
parent
commit
2dcdbd172a
  1. 13
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/CategoryDictFormDTO.java
  2. 6
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenProjectDataCollController.java
  3. 6
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/CustomerProjectCategoryDictService.java
  4. 14
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/CustomerProjectCategoryDictServiceImpl.java
  5. 47
      epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/FirstCategoryFormDTO.java
  6. 21
      epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/SecondCategoryFormDTO.java
  7. 48
      epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/result/CustomerCategoryResultDTO.java
  8. 76
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueProjectCategoryDictController.java
  9. 43
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueProjectCategoryDictDao.java
  10. 7
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueProjectTagDictDao.java
  11. 54
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueProjectCategoryDictService.java
  12. 175
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueProjectCategoryDictServiceImpl.java
  13. 4
      epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueCategoryDao.xml
  14. 66
      epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueProjectCategoryDictDao.xml
  15. 13
      epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueProjectTagDictDao.xml
  16. 5
      epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/DelCategoryFormDTO.java
  17. 13
      epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/IsDisableCategoryFormDTO.java
  18. 4
      epmet-module/gov-project/gov-project-server/src/main/resources/mapper/ProjectCategoryDao.xml

13
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/CategoryDictFormDTO.java

@ -1,11 +1,8 @@
package com.epmet.dto.screen.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 项目分类字典上报
@ -15,38 +12,31 @@ import java.math.BigDecimal;
@Data
public class CategoryDictFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
// public interface ExtractDailyForm extends CustomerClientShowGroup {}
private static final long serialVersionUID = 1245827825857891963L;
/**
* 客户内自己的分类编码
*/
// @NotBlank(message = "客户分类编码不能为空", groups = { ExtractDailyForm.class })
private String categoryCode;
/**
* 客户内自己的分类名称
*/
// @NotBlank(message = "客户分类名称不能为空", groups = { ExtractDailyForm.class })
private String categoryName;
/**
* 父类分类编码如果是一级分类此列赋值为0
*/
// @NotBlank(message = "父类分类编码不能为空", groups = { ExtractDailyForm.class })
private String parentCategoryCode;
/**
* 分类等级12....
*/
// @NotBlank(message = "分类等级不能为空", groups = { ExtractDailyForm.class })
private Integer level;
/**
* 排序
*/
// @NotBlank(message = "排序不能为空", groups = { ExtractDailyForm.class })
private Integer sort;
/**
@ -67,6 +57,5 @@ public class CategoryDictFormDTO implements Serializable {
/**
* 分类字典表主键
*/
// @NotBlank(message = "分类字典表主键不能为空", groups = { ExtractDailyForm.class })
private String categoryId;
}

6
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenProjectDataCollController.java

@ -163,8 +163,10 @@ public class ScreenProjectDataCollController {
* @Date 16:03 2021-03-22
**/
@PostMapping("uploadcategorydict")
public Result uploadcategorydict(@RequestHeader("CustomerId") String customerId, @RequestBody CategoryDictDataFormDTO formDTO) {
customerProjectCategoryDictService.uploadCategoryDict(customerId, formDTO);
public Result uploadcategorydict(@RequestHeader("CustomerId") String customerId, @RequestBody ScreenCollFormDTO<CategoryDictFormDTO> formDTO) {
formDTO.setCustomerId(customerId);
ValidatorUtils.validateEntity(formDTO, ScreenCollFormDTO.CustomerIdShowGroup.class, ScreenCollFormDTO.DataListShowGroup.class);
customerProjectCategoryDictService.uploadCategoryDict(formDTO);
return new Result();
}
}

6
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/CustomerProjectCategoryDictService.java

@ -18,7 +18,8 @@
package com.epmet.service.stats;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.dto.screen.CategoryDictDataFormDTO;
import com.epmet.dto.screen.form.CategoryDictFormDTO;
import com.epmet.dto.screencoll.ScreenCollFormDTO;
import com.epmet.entity.issue.IssueProjectCategoryDictEntity;
import com.epmet.entity.stats.CustomerProjectCategoryDictEntity;
@ -48,11 +49,10 @@ public interface CustomerProjectCategoryDictService extends BaseService<Customer
* 项目分类字典上报
* 目标表epmet_evaluation_index库的customer_project_category_dict
*
* @param customerId
* @param formDTO
* @return void
* @Author zhangyong
* @Date 16:03 2021-03-22
**/
void uploadCategoryDict(String customerId, CategoryDictDataFormDTO formDTO);
void uploadCategoryDict(ScreenCollFormDTO<CategoryDictFormDTO> formDTO);
}

14
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/CustomerProjectCategoryDictServiceImpl.java

@ -22,14 +22,15 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.constant.DataSourceConstant;
import com.epmet.dao.stats.CustomerProjectCategoryDictDao;
import com.epmet.dto.screen.CategoryDictDataFormDTO;
import com.epmet.dto.screen.form.CategoryDictFormDTO;
import com.epmet.dto.screencoll.ScreenCollFormDTO;
import com.epmet.entity.issue.IssueProjectCategoryDictEntity;
import com.epmet.entity.stats.CustomerProjectCategoryDictEntity;
import com.epmet.service.stats.CustomerProjectCategoryDictService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.apache.commons.collections4.CollectionUtils;
import java.util.List;
@ -97,18 +98,19 @@ public class CustomerProjectCategoryDictServiceImpl extends BaseServiceImpl<Cust
return baseDao.getLatestUpdatedEntity();
}
@DataSource(value = DataSourceConstant.EVALUATION_INDEX)
@DataSource(value = DataSourceConstant.EVALUATION_INDEX,datasourceNameFromArg = true)
@Override
@Transactional(rollbackFor = Exception.class)
public void uploadCategoryDict(String customerId, CategoryDictDataFormDTO formDTO) {
public void uploadCategoryDict(ScreenCollFormDTO<CategoryDictFormDTO> formDTO) {
if (formDTO.getIsFirst()) {
int deleteNum;
do {
deleteNum = baseDao.deleteCustomerProjectCategoryDict(customerId);
deleteNum = baseDao.deleteCustomerProjectCategoryDict(formDTO.getCustomerId());
} while (deleteNum > NumConstant.ZERO);
}
if (!CollectionUtils.isEmpty(formDTO.getDataList())) {
baseDao.batchInsertCustomerProjectCategoryDict(formDTO.getDataList(), customerId);
baseDao.batchInsertCustomerProjectCategoryDict(formDTO.getDataList(), formDTO.getCustomerId());
}
}
}

47
epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/FirstCategoryFormDTO.java

@ -0,0 +1,47 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.List;
/**
* @Description 一级分类 新增/修改
* @Auth zy
* @Date 2021-03-22 09:17
*/
@Data
public class FirstCategoryFormDTO implements Serializable {
private static final long serialVersionUID = 3188828578545996470L;
public interface AddCategoryInternalGroup {
}
/**
* 客户Id
**/
@NotBlank(message = "customerId不能为空", groups = AddCategoryInternalGroup.class)
private String customerId;
/**
* 分类Id
* issue_project_category_dict 表主键只有执行修改操作时才会传入
**/
private String categoryId;
/**
* 分类名称
**/
private String categoryName;
/**
* 排序
**/
private Integer sort;
/**
* 操作类型(add:新增 edit:编辑)
**/
@NotBlank(message = "操作类型不能为空", groups = AddCategoryInternalGroup.class)
private String type;
}

21
epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/SecondCategoryFormDTO.java

@ -0,0 +1,21 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* @Description 二级分类 新增/修改
* @ClassName CommonGridIdListFormDTO
* @Auth zy
* @Date 2021-03-22 09:17
*/
@Data
public class SecondCategoryFormDTO extends FirstCategoryFormDTO implements Serializable{
private static final long serialVersionUID = 3188828578545996470L;
/**
* 一级分类Id
**/
private String parentCategoryId;
}

48
epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/result/CustomerCategoryResultDTO.java

@ -0,0 +1,48 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 客户分类列表
*
* @Author ZY
* @DateTime 2021/03/23
*/
@Data
public class CustomerCategoryResultDTO implements Serializable {
private static final long serialVersionUID = 4769136806332933579L;
/**
* 分类Id
*/
private String categoryId;
/**
* 分类名称
*/
private String categoryName;
/**
* 排序
*/
private Integer sort;
/**
* 是否禁用(enable:启用 disable:禁用)
*/
private String isDisable;
/**
* 二级分类
*/
private List<CustomerCategoryResultDTO> children;
/**
* pid
*/
private String pid;
}

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

@ -18,6 +18,9 @@
package com.epmet.controller;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.enums.CommonOperateTypeEnum;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ExcelUtils;
@ -30,12 +33,15 @@ import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.IssueProjectCategoryDictDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.CustomerCategoryListResultDTO;
import com.epmet.dto.result.CustomerCategoryResultDTO;
import com.epmet.dto.result.ProjectIssueCategoryResultDTO;
import com.epmet.entity.IssueProjectCategoryDictEntity;
import com.epmet.excel.IssueProjectCategoryDictExcel;
import com.epmet.project.dto.CustomerCategoryDTO;
import com.epmet.project.dto.result.ProjectCategoryDictResultDTO;
import com.epmet.service.IssueProjectCategoryDictService;
import com.epmet.utils.ModuleConstants;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -152,8 +158,9 @@ public class IssueProjectCategoryDictController {
* @Author sun
**/
@PostMapping("isdisablecategory")
public Result isDisableCategory(@RequestBody IsDisableCategoryFormDTO formDTO) {
public Result isDisableCategory(@LoginUser TokenDto tokenDto, @RequestBody IsDisableCategoryFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, IsDisableCategoryFormDTO.IsDisableCategory.class);
formDTO.setUserId(tokenDto.getUserId());
if(!ModuleConstants.ID_ENABLE.equals(formDTO.getType())&&!ModuleConstants.IS_DISABLE.equals(formDTO.getType())){
throw new RuntimeException("参数错误,操作类型值错误!");
}
@ -168,8 +175,9 @@ public class IssueProjectCategoryDictController {
* @Author sun
**/
@PostMapping("delcategory")
public Result delCategory(@RequestBody DelCategoryFormDTO formDTO) {
public Result delCategory(@LoginUser TokenDto tokenDto, @RequestBody DelCategoryFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, DelCategoryFormDTO.DelCategory.class);
formDTO.setUserId(tokenDto.getUserId());
issueProjectCategoryDictService.delCategory(formDTO);
return new Result();
}
@ -189,4 +197,68 @@ public class IssueProjectCategoryDictController {
return new Result<List<ProjectCategoryDictResultDTO>>().ok(issueProjectCategoryDictService.listCategoryDict(dto.getCustomerId(),
dto.getPid()));
}
/**
* 新增或修改一级分类信息分类名称在同一个客户下有效数据中不允许重复
*
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<java.lang.String>
* @Author zhangyong
* @Date 10:27 2021-03-23
**/
@PostMapping("savefirstcategory")
public Result<String> saveFirstCategory(@RequestBody SecondCategoryFormDTO formDTO) {
if (StringUtils.isBlank(formDTO.getCustomerId())) {
throw new RenException("客户id 不能为空");
}
if (CommonOperateTypeEnum.ADD.getCode().equals(formDTO.getType())) {
return issueProjectCategoryDictService.saveFirstCategory(formDTO);
} else if (CommonOperateTypeEnum.EDIT.getCode().equals(formDTO.getType())){
return issueProjectCategoryDictService.editFirstCategory(formDTO);
}
throw new RenException("操作类型为空,或错误。type:" + formDTO.getType());
}
/**
* 新增或修改二级分类信息分类名称在同一个客户下同一 一级分类下有效数据中不允许重复
*
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<java.lang.String>
* @Author zhangyong
* @Date 10:27 2021-03-23
**/
@PostMapping("savesecondcategory")
public Result<String> saveSecondCategory(@RequestBody SecondCategoryFormDTO formDTO) {
if (StringUtils.isBlank(formDTO.getCustomerId())) {
throw new RenException("客户id 不能为空");
}
if (StringUtils.isBlank(formDTO.getParentCategoryId())) {
throw new RenException("一级分类Id 不能为空");
}
if (CommonOperateTypeEnum.ADD.getCode().equals(formDTO.getType())) {
return issueProjectCategoryDictService.saveSecondCategory(formDTO);
} else if (CommonOperateTypeEnum.EDIT.getCode().equals(formDTO.getType())){
return issueProjectCategoryDictService.editSecondCategory(formDTO);
}
throw new RenException("操作类型为空,或错误。type:" + formDTO.getType());
}
/**
* 客户分类列表
* 按客户查询已有一级二级分类列表升序排列全部查询不涉及分页
*
* @param map
* customerId
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.result.CustomerCategoryResultDTO>>
* @Author zhangyong
* @Date 16:30 2021-03-23
**/
@PostMapping("customercategorylist")
public Result<List<CustomerCategoryResultDTO>> customerCategoryList(@RequestBody Map<String, String> map) {
if (StringUtils.isBlank(map.get(FieldConstant.CUSTOMER_ID_HUMP))) {
throw new RenException("客户id 不能为空");
}
return new Result<List<CustomerCategoryResultDTO>>().ok(issueProjectCategoryDictService.customerCategoryList(map.get(FieldConstant.CUSTOMER_ID_HUMP)));
}
}

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

@ -23,6 +23,7 @@ import com.epmet.dto.form.DelCategoryFormDTO;
import com.epmet.dto.form.IsDisableCategoryFormDTO;
import com.epmet.dto.form.IssueProjectCategoryDictListFormDTO;
import com.epmet.dto.result.CustomerCategoryListResultDTO;
import com.epmet.dto.result.CustomerCategoryResultDTO;
import com.epmet.entity.IssueProjectCategoryDictEntity;
import com.epmet.project.dto.result.ProjectCategoryDictResultDTO;
import org.apache.ibatis.annotations.Mapper;
@ -113,4 +114,46 @@ public interface IssueProjectCategoryDictDao extends BaseDao<IssueProjectCategor
* @author sun
*/
int updateCustomerCategory(IsDisableCategoryFormDTO formDTO);
/**
* 获取客户下 最大的分类编码
*
* @param customerId
* @param parentCategoryCode
* = 0 查询一级分类的最大分类编码
* = 10xx 根据上级分类编码查询某个子级的最大分类编码
* @return java.lang.Integer
* @Author zhangyong
* @Date 13:35 2021-03-23
**/
Integer getMaxCategoryCode(@Param("customerId") String customerId, @Param("parentCategoryCode") String parentCategoryCode);
/**
* 判断同一个客户下有效数据中 分类名称是否重复
* > 0 则为重复
*
*
* @param customerId
* @param categoryName
* @param pid != null 表示 将查询范围限制在某一个一级分类 一级分类下的有效数据
* @param id 修改时不一定会修改分类名称所以需通过id 过滤自己
* @return java.lang.Boolean
* @Author zhangyong
* @Date 14:11 2021-03-23
**/
Integer isCategoryName(@Param("customerId") String customerId, @Param("categoryName") String categoryName,
@Param("pid") String pid, @Param("id") String id);
/**
* 获取客户所有的 分类字典 信息(包含已被禁用的)
*
* @param customerId
* @param pid pid = 0 查询一级分类
* pid != 0 查询二级分类
*
* @return java.util.List<com.epmet.project.dto.result.ProjectCategoryDictResultDTO>
* @Author zhangyong
* @Date 14:10 2021-03-22
**/
List<CustomerCategoryResultDTO> selectListAllCategoryDict(@Param("customerId") String customerId, @Param("pid") String pid);
}

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

@ -18,6 +18,7 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.form.IsDisableCategoryFormDTO;
import com.epmet.dto.form.IssueTagFormDTO;
import com.epmet.dto.result.IssueCategoryTagResultDTO;
import com.epmet.entity.IssueProjectTagDictEntity;
@ -102,4 +103,10 @@ public interface IssueProjectTagDictDao extends BaseDao<IssueProjectTagDictEntit
* @date 2020.12.13 14:23
*/
List<IssueProjectTagDictEntity> selectTagsByCustomerIdAndTagIds(@Param("customerId") String customerId,@Param("tagIds")List<String> tagIds);
/**
* 批量修改标签的启用禁用状态
* @author sun
*/
int updateCustomerTag(IsDisableCategoryFormDTO formDTO);
}

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

@ -19,12 +19,15 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.IssueProjectCategoryDictDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.CustomerCategoryListResultDTO;
import com.epmet.dto.result.CustomerCategoryResultDTO;
import com.epmet.dto.result.ProjectIssueCategoryResultDTO;
import com.epmet.entity.IssueProjectCategoryDictEntity;
import com.epmet.project.dto.result.ProjectCategoryDictResultDTO;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
import java.util.Map;
@ -154,4 +157,55 @@ public interface IssueProjectCategoryDictService extends BaseService<IssueProjec
* @Date 14:10 2021-03-22
**/
List<ProjectCategoryDictResultDTO> listCategoryDict(String customerId, String pid);
/**
* 新增一级分类信息分类名称在同一个客户下有效数据中不允许重复
*
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<java.lang.String> 新增后的主键
* @Author zhangyong
* @Date 10:27 2021-03-23
**/
Result<String> saveFirstCategory(SecondCategoryFormDTO formDTO);
/**
* 修改一级分类信息分类名称在同一个客户下有效数据中不允许重复
*
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<java.lang.String> 新增后的主键
* @Author zhangyong
* @Date 10:27 2021-03-23
**/
Result<String> editFirstCategory(SecondCategoryFormDTO formDTO);
/**
* 新增二级分类信息分类名称在同一个客户下同一 一级分类下有效数据中不允许重复
*
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<java.lang.String> 新增后的主键
* @Author zhangyong
* @Date 10:27 2021-03-23
**/
Result<String> saveSecondCategory(SecondCategoryFormDTO formDTO);
/**
* 修改二级分类信息分类名称在同一个客户下有效数据中不允许重复
*
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<java.lang.String> 新增后的主键
* @Author zhangyong
* @Date 10:27 2021-03-23
**/
Result<String> editSecondCategory(SecondCategoryFormDTO formDTO);
/**
* 客户分类列表
* 按客户查询已有一级二级分类列表升序排列全部查询不涉及分页
*
* @param customerId
* @return java.util.List<com.epmet.dto.result.CustomerCategoryResultDTO>
* @Author zhangyong
* @Date 16:30 2021-03-23
**/
List<CustomerCategoryResultDTO> customerCategoryList(String customerId);
}

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

@ -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;
}
}

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

@ -63,10 +63,10 @@
FROM issue_category
WHERE del_flag = '0'
AND customer_id = #{customerId}
<if test="level != null and '' != level and '1' == level ">
<if test="1 == level ">
AND category_pids = #{categoryId}
</if>
<if test="level != null and '' != level and '2' == level ">
<if test="2 == level ">
AND category_id = #{categoryId}
</if>
</select>

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

@ -135,25 +135,29 @@
WHERE
del_flag = '0'
AND customer_id = #{customerId}
AND pid = #{categoryId}
AND pid = #{pid}
</select>
<update id="delCategory">
UPDATE issue_project_category_dict
SET del_flag = '1'
SET del_flag = '1',
updated_by = #{userId},
updated_time = NOW()
WHERE
customer_id = #{customerId}
<if test="level != null and '' != level and '1' == level ">
AND id = #{categoryId}
<if test="1 == level ">
AND id = #{categoryId} OR pid = #{categoryId}
</if>
<if test="level != null and '' != level and '2' == level ">
AND pid = #{categoryId}
<if test="2 == level ">
AND id = #{categoryId}
</if>
</update>
<update id="updateCustomerCategory">
UPDATE issue_project_category_dict
SET is_disable = #{type}
SET is_disable = #{type},
updated_by = #{userId},
updated_time = NOW()
WHERE
customer_id = #{customerId}
<foreach item="ids" collection="categoryList" separator="OR" open="AND (" close=")" index="">
@ -161,4 +165,52 @@
</foreach>
</update>
<select id="getMaxCategoryCode" resultType="Integer">
SELECT
IFNULL( MAX(CATEGORY_CODE), 0)
FROM
`issue_project_category_dict`
WHERE
PARENT_CATEGORY_CODE = #{parentCategoryCode}
AND CUSTOMER_ID = #{customerId}
AND DEL_FLAG = '0'
</select>
<select id="isCategoryName" resultType="Integer">
SELECT
COUNT(1)
FROM
`issue_project_category_dict`
WHERE
CATEGORY_NAME = #{categoryName}
AND CUSTOMER_ID = #{customerId}
AND DEL_FLAG = '0'
<if test="pid != null and pid != '' ">
AND (ID = #{pid} OR PID = #{pid})
</if>
<if test="id != null">
AND id != #{id}
</if>
</select>
<select id="selectListAllCategoryDict" resultType="com.epmet.dto.result.CustomerCategoryResultDTO">
SELECT
CATEGORY_CODE categoryCode,
CATEGORY_NAME categoryName,
IS_DISABLE isDisable,
SORT,
PID,
ID categoryId
FROM issue_project_category_dict d
WHERE d.CUSTOMER_ID = #{customerId}
AND d.DEL_FLAG ='0'
<if test="pid != null and pid == 0">
AND d.PID = '0'
</if>
<if test="pid != null and pid != 0">
AND d.PID != '0'
</if>
ORDER BY CATEGORY_CODE ASC
</select>
</mapper>

13
epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueProjectTagDictDao.xml

@ -136,4 +136,17 @@
</foreach>
</if>
</select>
<update id="updateCustomerTag">
UPDATE issue_project_tag_dict
SET is_disable = #{type},
updated_by = #{userId},
updated_time = NOW()
WHERE
customer_id = #{customerId}
<foreach item="ids" collection="secondCategorylist" separator="OR" open="AND (" close=")" index="">
category_id = #{ids}
</foreach>
</update>
</mapper>

5
epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/DelCategoryFormDTO.java

@ -31,5 +31,10 @@ public class DelCategoryFormDTO implements Serializable {
*/
private String level;
/**
* token中用户
*/
private String userId;
}

13
epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/IsDisableCategoryFormDTO.java

@ -31,6 +31,19 @@ public class IsDisableCategoryFormDTO implements Serializable {
@NotBlank(message = "是否启用类型不能为空",groups = {IsDisableCategory.class})
private String type;
/**
* 一类二类分类Id集合
*/
private List<String> categoryList;
/**
* 二类分类Id集合
*/
private List<String> secondCategorylist;
/**
* token中用户
*/
private String userId;
}

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

@ -19,10 +19,10 @@
FROM project_category
WHERE del_flag = '0'
AND customer_id = #{customerId}
<if test="level != null and '' != level and '1' == level ">
<if test="1 == level ">
AND category_pids = #{categoryId}
</if>
<if test="level != null and '' != level and '2' == level ">
<if test="2 == level ">
AND category_id = #{categoryId}
</if>
</select>

Loading…
Cancel
Save