diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/CategoryDictFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/CategoryDictFormDTO.java index f60c33faa4..364c497eb1 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/CategoryDictFormDTO.java +++ b/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; /** * 分类等级:1、2....; */ -// @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; } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenProjectDataCollController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenProjectDataCollController.java index d51ca41f31..db45cca198 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenProjectDataCollController.java +++ b/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 formDTO) { + formDTO.setCustomerId(customerId); + ValidatorUtils.validateEntity(formDTO, ScreenCollFormDTO.CustomerIdShowGroup.class, ScreenCollFormDTO.DataListShowGroup.class); + customerProjectCategoryDictService.uploadCategoryDict(formDTO); return new Result(); } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/CustomerProjectCategoryDictService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/CustomerProjectCategoryDictService.java index 1b37c9448a..ef8440c594 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/CustomerProjectCategoryDictService.java +++ b/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 formDTO); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/CustomerProjectCategoryDictServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/CustomerProjectCategoryDictServiceImpl.java index 455039a2a9..b610fa9c6c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/CustomerProjectCategoryDictServiceImpl.java +++ b/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 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()); } } } diff --git a/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/FirstCategoryFormDTO.java b/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/FirstCategoryFormDTO.java new file mode 100644 index 0000000000..cb50e8dbe2 --- /dev/null +++ b/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; +} diff --git a/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/SecondCategoryFormDTO.java b/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/SecondCategoryFormDTO.java new file mode 100644 index 0000000000..7b3d389462 --- /dev/null +++ b/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; +} diff --git a/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/result/CustomerCategoryResultDTO.java b/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/result/CustomerCategoryResultDTO.java new file mode 100644 index 0000000000..5121a13471 --- /dev/null +++ b/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 children; + + /** + * pid + */ + private String pid; +} diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueProjectCategoryDictController.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueProjectCategoryDictController.java index bc6a3607c6..df85854df5 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueProjectCategoryDictController.java +++ b/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>().ok(issueProjectCategoryDictService.listCategoryDict(dto.getCustomerId(), dto.getPid())); } + + /** + * 新增或修改一级分类信息,分类名称在同一个客户下有效数据中不允许重复 + * + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author zhangyong + * @Date 10:27 2021-03-23 + **/ + @PostMapping("savefirstcategory") + public Result 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 + * @Author zhangyong + * @Date 10:27 2021-03-23 + **/ + @PostMapping("savesecondcategory") + public Result 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> + * @Author zhangyong + * @Date 16:30 2021-03-23 + **/ + @PostMapping("customercategorylist") + public Result> customerCategoryList(@RequestBody Map map) { + if (StringUtils.isBlank(map.get(FieldConstant.CUSTOMER_ID_HUMP))) { + throw new RenException("客户id 不能为空"); + } + return new Result>().ok(issueProjectCategoryDictService.customerCategoryList(map.get(FieldConstant.CUSTOMER_ID_HUMP))); + } } + diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueProjectCategoryDictDao.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueProjectCategoryDictDao.java index 6698b28722..d85eaa3295 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueProjectCategoryDictDao.java +++ b/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 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 + * @Author zhangyong + * @Date 14:10 2021-03-22 + **/ + List selectListAllCategoryDict(@Param("customerId") String customerId, @Param("pid") String pid); } diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueProjectTagDictDao.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueProjectTagDictDao.java index 2d14833f4a..9fa8ef840d 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueProjectTagDictDao.java +++ b/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 selectTagsByCustomerIdAndTagIds(@Param("customerId") String customerId,@Param("tagIds")List tagIds); + + /** + * 批量修改标签的启用、禁用状态 + * @author sun + */ + int updateCustomerTag(IsDisableCategoryFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueProjectCategoryDictService.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueProjectCategoryDictService.java index 55fc4871c3..639888bc23 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueProjectCategoryDictService.java +++ b/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 listCategoryDict(String customerId, String pid); + + /** + * 新增一级分类信息,分类名称在同一个客户下有效数据中不允许重复 + * + * @param formDTO + * @return com.epmet.commons.tools.utils.Result 新增后的主键 + * @Author zhangyong + * @Date 10:27 2021-03-23 + **/ + Result saveFirstCategory(SecondCategoryFormDTO formDTO); + + /** + * 修改一级分类信息,分类名称在同一个客户下有效数据中不允许重复 + * + * @param formDTO + * @return com.epmet.commons.tools.utils.Result 新增后的主键 + * @Author zhangyong + * @Date 10:27 2021-03-23 + **/ + Result editFirstCategory(SecondCategoryFormDTO formDTO); + + /** + * 新增二级分类信息,分类名称在同一个客户下同一 一级分类下有效数据中不允许重复 + * + * @param formDTO + * @return com.epmet.commons.tools.utils.Result 新增后的主键 + * @Author zhangyong + * @Date 10:27 2021-03-23 + **/ + Result saveSecondCategory(SecondCategoryFormDTO formDTO); + + /** + * 修改二级分类信息,分类名称在同一个客户下有效数据中不允许重复 + * + * @param formDTO + * @return com.epmet.commons.tools.utils.Result 新增后的主键 + * @Author zhangyong + * @Date 10:27 2021-03-23 + **/ + Result editSecondCategory(SecondCategoryFormDTO formDTO); + + /** + * 客户分类列表 + * 按客户查询已有一级二级分类列表,升序排列,全部查询,不涉及分页 + * + * @param customerId + * @return java.util.List + * @Author zhangyong + * @Date 16:30 2021-03-23 + **/ + List customerCategoryList(String customerId); } diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueProjectCategoryDictServiceImpl.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueProjectCategoryDictServiceImpl.java index c4faa05e5d..006568d0e2 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueProjectCategoryDictServiceImpl.java +++ b/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 page(Map params) { @@ -246,25 +246,32 @@ public class IssueProjectCategoryDictServiceImpl extends BaseServiceImpl categoryList = new ArrayList<>(); //待修改的二级分类Id汇总 List secondList = new ArrayList<>(); - if("1".equals(dto.getCategoryType())){ + if ("1".equals(dto.getCategoryType())) { //2-1.查询子类信息 - List subList = baseDao.selectSubCustomerCategoryDict(formDTO.getCustomerId(),formDTO.getCategoryId()); - secondList = subList.stream().map(sub->sub.getId()).collect(Collectors.toList()); + List 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)%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 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 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 listCategoryDict(String customerId, String pid) { return baseDao.selectListCategoryDict(customerId, pid); + } + + @Override + public Result 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().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 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 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().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 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 customerCategoryList(String customerId) { + List parentCategoryDict = baseDao.selectListAllCategoryDict(customerId, NumConstant.ZERO_STR); + List childrenCategoryDict = baseDao.selectListAllCategoryDict(customerId, NumConstant.ONE_STR); + + for (CustomerCategoryResultDTO p : parentCategoryDict) { + List 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; } } diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueCategoryDao.xml b/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueCategoryDao.xml index d5fc89045e..159debdd32 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueCategoryDao.xml +++ b/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} - + AND category_pids = #{categoryId} - + AND category_id = #{categoryId} diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueProjectCategoryDictDao.xml b/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueProjectCategoryDictDao.xml index 20f8c5cfdd..6cfbb5f164 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueProjectCategoryDictDao.xml +++ b/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} UPDATE issue_project_category_dict - SET del_flag = '1' + SET del_flag = '1', + updated_by = #{userId}, + updated_time = NOW() WHERE customer_id = #{customerId} - - AND id = #{categoryId} + + AND id = #{categoryId} OR pid = #{categoryId} - - AND pid = #{categoryId} + + AND id = #{categoryId} UPDATE issue_project_category_dict - SET is_disable = #{type} + SET is_disable = #{type}, + updated_by = #{userId}, + updated_time = NOW() WHERE customer_id = #{customerId} @@ -161,4 +165,52 @@ + + + + + + diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueProjectTagDictDao.xml b/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueProjectTagDictDao.xml index 5988ddbbbd..e141bba4b1 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueProjectTagDictDao.xml +++ b/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueProjectTagDictDao.xml @@ -136,4 +136,17 @@ + + + UPDATE issue_project_tag_dict + SET is_disable = #{type}, + updated_by = #{userId}, + updated_time = NOW() + WHERE + customer_id = #{customerId} + + category_id = #{ids} + + + \ No newline at end of file diff --git a/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/DelCategoryFormDTO.java b/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/DelCategoryFormDTO.java index c1fa3252c6..48ac7e6404 100644 --- a/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/DelCategoryFormDTO.java +++ b/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; + } diff --git a/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/IsDisableCategoryFormDTO.java b/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/IsDisableCategoryFormDTO.java index e259fd81a9..ccd91a49c5 100644 --- a/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/IsDisableCategoryFormDTO.java +++ b/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 categoryList; + /** + * 二类分类Id集合 + */ + private List secondCategorylist; + + /** + * token中用户 + */ + private String userId; + } diff --git a/epmet-module/gov-project/gov-project-server/src/main/resources/mapper/ProjectCategoryDao.xml b/epmet-module/gov-project/gov-project-server/src/main/resources/mapper/ProjectCategoryDao.xml index bb6a148e90..30033c620e 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/resources/mapper/ProjectCategoryDao.xml +++ b/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} - + AND category_pids = #{categoryId} - + AND category_id = #{categoryId}