From f4e872c3579aa07c90141dd68af554e7adb53699 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Fri, 19 Nov 2021 11:00:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B1=85=E6=B0=91=E9=9C=80=E6=B1=82=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/exception/EpmetErrorCode.java | 1 + .../dto/form/demand/AddCategoryFormDTO.java | 31 ++++ .../form/demand/AddFirstCategoryFormDTO.java | 26 +++ .../form/demand/DemandDictPageFormDTO.java | 17 ++ .../epmet/dto/form/demand/StatusFormDTO.java | 20 +++ .../epmet/dto/form/demand/SubCodeFormDTO.java | 15 ++ .../epmet/dto/form/demand/UpdateFormDTO.java | 42 +++++ .../demand/UserDemandNameQueryFormDTO.java | 2 +- .../dto/result/demand/DemandPageResDTO.java | 21 +++ .../epmet/dto/result/demand/OptionDTO.java | 12 ++ .../IcResiDemandDictController.java | 121 +++++++++++--- .../com/epmet/dao/IcResiDemandDictDao.java | 22 +++ .../epmet/entity/IcResiDemandDictEntity.java | 11 +- .../service/IcResiDemandDictService.java | 51 +++--- .../impl/IcResiDemandDictServiceImpl.java | 154 +++++++++++++++--- .../resources/mapper/IcResiDemandDictDao.xml | 120 ++++++++++++++ 16 files changed, 595 insertions(+), 71 deletions(-) create mode 100644 epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/AddCategoryFormDTO.java create mode 100644 epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/AddFirstCategoryFormDTO.java create mode 100644 epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/DemandDictPageFormDTO.java create mode 100644 epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/StatusFormDTO.java create mode 100644 epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/SubCodeFormDTO.java create mode 100644 epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/UpdateFormDTO.java create mode 100644 epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/DemandPageResDTO.java create mode 100644 epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/OptionDTO.java diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index b57a5c8584..ac0d07f7be 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -82,6 +82,7 @@ public enum EpmetErrorCode { BUILDING_NAME_EXITED(8215,"楼栋名称已存在"), DOOR_NAME_EXITED(8216,"门牌号已存在"), NEIGHBOOR_NAME_EXITED(8217,"小区名称已存在"), + DEMAND_NAME_EXITED(8218, "分类名称已存在"), REQUIRE_PERMISSION(8301, "您没有足够的操作权限"), THIRD_PLAT_REQUEST_ERROR(8302, "请求第三方平台错误"), diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/AddCategoryFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/AddCategoryFormDTO.java new file mode 100644 index 0000000000..866a20bc6d --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/AddCategoryFormDTO.java @@ -0,0 +1,31 @@ +package com.epmet.dto.form.demand; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +@Data +public class AddCategoryFormDTO implements Serializable { + public interface AddUserInternalGroup { + } + + public interface AddUserShowGroup extends CustomerClientShowGroup { + } + + @NotBlank(message = "客户id不能为空", groups = AddUserInternalGroup.class) + private String customerId; + + @NotBlank(message = "分类名称不能为空", groups = AddUserShowGroup.class) + @Length(max = 100, message = "分类名称最多输入100字", groups = AddUserShowGroup.class) + private String categoryName; + + @NotBlank(message = "请先选择一级分类", groups = AddUserShowGroup.class) + private String parentCategoryCode; + + @NotNull(message = "奖励积分不能为空", groups = AddUserShowGroup.class) + private Integer awardPoint; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/AddFirstCategoryFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/AddFirstCategoryFormDTO.java new file mode 100644 index 0000000000..b0a610d278 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/AddFirstCategoryFormDTO.java @@ -0,0 +1,26 @@ +package com.epmet.dto.form.demand; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +@Data +public class AddFirstCategoryFormDTO implements Serializable { + private static final long serialVersionUID = -9011014064624688518L; + + public interface AddUserInternalGroup { + } + + public interface AddUserShowGroup extends CustomerClientShowGroup { + } + + @NotBlank(message = "客户id不能为空", groups = AddUserInternalGroup.class) + private String customerId; + + @NotBlank(message = "分类名称不能为空", groups = AddUserShowGroup.class) + @Length(max = 20, message = "一级分类名称最多输入20字", groups = AddUserShowGroup.class) + private String categoryName; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/DemandDictPageFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/DemandDictPageFormDTO.java new file mode 100644 index 0000000000..3ff7d63c0b --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/DemandDictPageFormDTO.java @@ -0,0 +1,17 @@ +package com.epmet.dto.form.demand; + +import com.epmet.commons.tools.dto.form.PageFormDTO; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +@Data +public class DemandDictPageFormDTO extends PageFormDTO implements Serializable { + public interface AddUserInternalGroup {} + + @NotBlank(message = "客户id不能为空",groups = AddUserInternalGroup.class) + private String customerId; + + private String firstCategoryCode; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/StatusFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/StatusFormDTO.java new file mode 100644 index 0000000000..879d632cc7 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/StatusFormDTO.java @@ -0,0 +1,20 @@ +package com.epmet.dto.form.demand; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +@Data +public class StatusFormDTO implements Serializable { + + public interface AddUserInternalGroup { + } + + @NotBlank(message = "categoryId不能为空", groups = AddUserInternalGroup.class) + private String categoryId; + + @NotNull(message = "usableFlag不能为空", groups = AddUserInternalGroup.class) + private Boolean usableFlag; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/SubCodeFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/SubCodeFormDTO.java new file mode 100644 index 0000000000..5fecd09258 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/SubCodeFormDTO.java @@ -0,0 +1,15 @@ +package com.epmet.dto.form.demand; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +@Data +public class SubCodeFormDTO implements Serializable { + public interface AddUserInternalGroup {} + @NotBlank(message = "客户id不能为空",groups = AddUserInternalGroup.class) + private String customerId; + @NotBlank(message = "parentCategoryCode不能为空",groups = AddUserInternalGroup.class) + private String parentCategoryCode; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/UpdateFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/UpdateFormDTO.java new file mode 100644 index 0000000000..4929228f29 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/UpdateFormDTO.java @@ -0,0 +1,42 @@ +package com.epmet.dto.form.demand; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +@Data +public class UpdateFormDTO implements Serializable { + + public interface AddUserInternalGroup { + } + + public interface AddUserShowGroup extends CustomerClientShowGroup { + } + + public interface First extends CustomerClientShowGroup { + } + + public interface Two extends CustomerClientShowGroup { + } + @NotBlank(message = "客户id不能为空", groups = AddUserInternalGroup.class) + private String customerId; + + @NotBlank(message = "categoryId不能为空", groups = AddUserInternalGroup.class) + private String categoryId; + + @NotNull(message = "等级不能为空", groups = AddUserInternalGroup.class) + private Integer level; + + + @NotBlank(message = "分类名称不能为空", groups = AddUserShowGroup.class) + @Length(max = 100, message = "分类名称最多输入100字", groups = First.class) + @Length(max = 20, message = "分类名称最多输入20字", groups = Two.class) + private String categoryName; + + @NotNull(message = "奖励积分不能为空", groups = Two.class) + private Integer awardPoint; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/UserDemandNameQueryFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/UserDemandNameQueryFormDTO.java index 3247482054..2a0141713f 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/UserDemandNameQueryFormDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/UserDemandNameQueryFormDTO.java @@ -13,7 +13,7 @@ public class UserDemandNameQueryFormDTO implements Serializable { public interface AddUserInternalGroup {} - @NotBlank(message = "客户idbu不能为空",groups =AddUserInternalGroup.class) + @NotBlank(message = "客户id不能为空",groups =AddUserInternalGroup.class) private String customerId; @NotEmpty(message = "分类编码不能为空",groups =AddUserInternalGroup.class) diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/DemandPageResDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/DemandPageResDTO.java new file mode 100644 index 0000000000..5b2a12c529 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/DemandPageResDTO.java @@ -0,0 +1,21 @@ +package com.epmet.dto.result.demand; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.List; + +@Data +public class DemandPageResDTO implements Serializable { + private String customerId; + private String categoryId; + private String categoryCode; + private String parentCategoryCode; + private String categoryName; + private Integer level; + private Integer sort; + private BigDecimal awardPoint; + private Boolean usableFlag; + private List children; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/OptionDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/OptionDTO.java new file mode 100644 index 0000000000..c0cfd3b48d --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/OptionDTO.java @@ -0,0 +1,12 @@ +package com.epmet.dto.result.demand; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class OptionDTO implements Serializable { + private static final long serialVersionUID = -6722370308097497466L; + private String label; + private String value; +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcResiDemandDictController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcResiDemandDictController.java index 13779cfe13..2b225c73dc 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcResiDemandDictController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcResiDemandDictController.java @@ -18,23 +18,22 @@ package com.epmet.controller; import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.dto.form.PageFormDTO; import com.epmet.commons.tools.dto.result.OptionResultDTO; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; 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.DefaultGroup; -import com.epmet.commons.tools.validator.group.UpdateGroup; -import com.epmet.dto.IcResiDemandDictDTO; -import com.epmet.dto.form.demand.UserDemandNameQueryFormDTO; +import com.epmet.dto.form.demand.*; +import com.epmet.dto.result.demand.DemandPageResDTO; +import com.epmet.dto.result.demand.OptionDTO; import com.epmet.service.IcResiDemandDictService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; -import java.util.Map; /** @@ -50,31 +49,73 @@ public class IcResiDemandDictController { @Autowired private IcResiDemandDictService icResiDemandDictService; - @GetMapping("page") - public Result> page(@RequestParam Map params){ - PageData page = icResiDemandDictService.page(params); - return new Result>().ok(page); + /** + * 分页列表查询 + * + * @param formDTO + * @return + */ + @PostMapping("pagelist") + public Result> page(@RequestBody DemandDictPageFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO,DemandDictPageFormDTO.AddUserInternalGroup.class, PageFormDTO.AddUserInternalGroup.class); + PageData page = icResiDemandDictService.page(formDTO); + return new Result>().ok(page); } - @GetMapping("{id}") - public Result get(@PathVariable("id") String id){ - IcResiDemandDictDTO data = icResiDemandDictService.get(id); - return new Result().ok(data); + /** + * 添加一级分类 + * @param formDTO + * @return + */ + @PostMapping("addfirst") + public Result addFirstCategory(@RequestBody AddFirstCategoryFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO,AddFirstCategoryFormDTO.AddUserShowGroup.class,AddFirstCategoryFormDTO.AddUserInternalGroup.class); + icResiDemandDictService.addFirstCategory(formDTO); + return new Result(); } - @PostMapping - public Result save(@RequestBody IcResiDemandDictDTO dto){ - //效验数据 - ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); - icResiDemandDictService.save(dto); + /** + * 新增二级分类 + * @param formDTO + * @return + */ + @PostMapping("addchild") + public Result addChild(@RequestBody AddCategoryFormDTO formDTO ){ + ValidatorUtils.validateEntity(formDTO,AddCategoryFormDTO.AddUserShowGroup.class,AddCategoryFormDTO.AddUserInternalGroup.class); + icResiDemandDictService.addChild(formDTO); return new Result(); } - @PutMapping - public Result update(@RequestBody IcResiDemandDictDTO dto){ + /** + * 修改分类 + * + * + * @param formDTO + * @return + */ + @PostMapping("update") + public Result update(@RequestBody UpdateFormDTO formDTO) { //效验数据 - ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); - icResiDemandDictService.update(dto); + ValidatorUtils.validateEntity(formDTO, UpdateFormDTO.AddUserInternalGroup.class, UpdateFormDTO.AddUserShowGroup.class); + if (NumConstant.ONE == formDTO.getLevel()) { + ValidatorUtils.validateEntity(formDTO, UpdateFormDTO.First.class); + } else if (NumConstant.TWO == formDTO.getLevel()) { + ValidatorUtils.validateEntity(formDTO, UpdateFormDTO.Two.class); + } + icResiDemandDictService.update(formDTO); + return new Result(); + } + + /** + * 启用或禁用 + * + * @param formDTO + * @return + */ + @PostMapping("updatestatus") + public Result updateStatus(@RequestBody StatusFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO,StatusFormDTO.AddUserInternalGroup.class); + icResiDemandDictService.updateStatus(formDTO); return new Result(); } @@ -102,4 +143,38 @@ public class IcResiDemandDictController { ValidatorUtils.validateEntity(formDTO,UserDemandNameQueryFormDTO.AddUserInternalGroup.class); return icResiDemandDictService.queryDemandNames(formDTO); } + + /** + * 居民需求查询条件:一级分类列表 0 + * 区域化党建单位:服务事项下拉框 1010 + * + * @param tokenDto + * @param formDTO + * @return + */ + @PostMapping("subcodelist") + public Result> querySubCodeList(@LoginUser TokenDto tokenDto, @RequestBody SubCodeFormDTO formDTO){ + formDTO.setCustomerId(tokenDto.getCustomerId()); + ValidatorUtils.validateEntity(formDTO,SubCodeFormDTO.AddUserInternalGroup.class); + return new Result>().ok(icResiDemandDictService.querySubCodeList(formDTO)); + } + + + + + + + + + + + + + + + + + + + } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcResiDemandDictDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcResiDemandDictDao.java index 94fd335929..d58dce2d8a 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcResiDemandDictDao.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcResiDemandDictDao.java @@ -19,6 +19,8 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.commons.tools.dto.result.OptionResultDTO; +import com.epmet.dto.result.demand.DemandPageResDTO; +import com.epmet.dto.result.demand.OptionDTO; import com.epmet.entity.IcResiDemandDictEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -38,4 +40,24 @@ public interface IcResiDemandDictDao extends BaseDao { List selectChildDemands(@Param("customerId")String customerId, @Param("parentCode") String parentCode); String selectCategoryNames(@Param("customerId") String customerId,@Param("codeSet") Set codeSet); + + List selectByPCode(@Param("pcode") String pcode, @Param("customerId") String customerId); + + List pageSelect(@Param("customerId") String customerId, @Param("firstCategoryCode")String firstCategoryCode); + + List selectChild(@Param("customerId") String customerId, @Param("parentCode")String parentCode); + + int selectCountName(@Param("customerId") String customerId, + @Param("categoryName")String categoryName, + @Param("level")int level, + @Param("parentCode")String parentCode, + @Param("id")String id); + + Integer selectMaxCategoryCode(@Param("customerId") String customerId, + @Param("level") Integer level, + @Param("parentCode") String parentCode); + + Integer selectMaxSort(@Param("customerId") String customerId, + @Param("level") int level, + @Param("parentCode") String parentCode); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcResiDemandDictEntity.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcResiDemandDictEntity.java index 5e01dd2b14..1b9a30b755 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcResiDemandDictEntity.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcResiDemandDictEntity.java @@ -58,7 +58,7 @@ public class IcResiDemandDictEntity extends BaseEpmetEntity { /** * 级别 */ - private String level; + private Integer level; /** * 备注 @@ -70,4 +70,13 @@ public class IcResiDemandDictEntity extends BaseEpmetEntity { */ private Integer sort; + /** + * 奖励积分:只有二级分类才会配置,一级默认为0。11.17 + */ + private Integer awardPoint; + + /** + * 1可用,0不可用,11.17 + */ + private Boolean usableFlag; } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcResiDemandDictService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcResiDemandDictService.java index d41c4303ba..1df5be75af 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcResiDemandDictService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcResiDemandDictService.java @@ -22,7 +22,9 @@ import com.epmet.commons.tools.dto.result.OptionResultDTO; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.IcResiDemandDictDTO; -import com.epmet.dto.form.demand.UserDemandNameQueryFormDTO; +import com.epmet.dto.form.demand.*; +import com.epmet.dto.result.demand.DemandPageResDTO; +import com.epmet.dto.result.demand.OptionDTO; import com.epmet.entity.IcResiDemandDictEntity; import java.util.List; @@ -39,52 +41,46 @@ public interface IcResiDemandDictService extends BaseService * @author generator * @date 2021-10-27 */ - PageData page(Map params); + PageData page(DemandDictPageFormDTO formDTO); /** - * 默认查询 - * - * @param params - * @return java.util.List - * @author generator - * @date 2021-10-27 + * 新增一级分类 + * @param formDTO */ - List list(Map params); + void addFirstCategory(AddFirstCategoryFormDTO formDTO); /** - * 单条查询 - * - * @param id - * @return IcResiDemandDictDTO - * @author generator - * @date 2021-10-27 + * 新增二级分类 + * @param formDTO */ - IcResiDemandDictDTO get(String id); + void addChild(AddCategoryFormDTO formDTO); + /** - * 默认保存 + * 默认查询 * - * @param dto - * @return void + * @param params + * @return java.util.List * @author generator * @date 2021-10-27 */ - void save(IcResiDemandDictDTO dto); + List list(Map params); + /** * 默认更新 * - * @param dto + * @param formDTO * @return void * @author generator * @date 2021-10-27 */ - void update(IcResiDemandDictDTO dto); + void update(UpdateFormDTO formDTO); /** * 批量删除 @@ -111,4 +107,13 @@ public interface IcResiDemandDictService extends BaseService queryDemandNames(UserDemandNameQueryFormDTO formDTO); + + List querySubCodeList(SubCodeFormDTO formDTO); + + /** + * 启用或禁用 + * + * @param formDTO + */ + void updateStatus(StatusFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcResiDemandDictServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcResiDemandDictServiceImpl.java index fb23a85fe8..fd30b41bd3 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcResiDemandDictServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcResiDemandDictServiceImpl.java @@ -18,18 +18,25 @@ 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.constant.NumConstant; import com.epmet.commons.tools.dto.result.OptionResultDTO; +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.IcResiDemandDictDao; import com.epmet.dto.IcResiDemandDictDTO; -import com.epmet.dto.form.demand.UserDemandNameQueryFormDTO; +import com.epmet.dto.form.demand.*; +import com.epmet.dto.result.demand.DemandPageResDTO; +import com.epmet.dto.result.demand.OptionDTO; import com.epmet.entity.IcResiDemandDictEntity; import com.epmet.service.IcResiDemandDictService; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -44,18 +51,90 @@ import java.util.Map; * @author generator generator@elink-cn.com * @since v1.0.0 2021-10-27 */ +@Slf4j @Service public class IcResiDemandDictServiceImpl extends BaseServiceImpl implements IcResiDemandDictService { + /** + * 分页查询 + * + * @param formDTO + * @return + */ @Override - public PageData page(Map params) { - IPage page = baseDao.selectPage( - getPage(params, FieldConstant.CREATED_TIME, false), - getWrapper(params) - ); - return getPageData(page, IcResiDemandDictDTO.class); + public PageData page(DemandDictPageFormDTO formDTO) { + PageInfo pageInfo= PageHelper.startPage(formDTO.getPageNo(), + formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.pageSelect(formDTO.getCustomerId(),formDTO.getFirstCategoryCode())); + return new PageData<>(pageInfo.getList(), pageInfo.getTotal()); } + /** + * 新增一级分类 + * @param formDTO + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void addFirstCategory(AddFirstCategoryFormDTO formDTO) { + if (checkCategoryName(formDTO.getCustomerId(), formDTO.getCategoryName(), NumConstant.ONE, NumConstant.ZERO_STR,null) > NumConstant.ZERO) { + // 名称唯一 + throw new RenException(EpmetErrorCode.DEMAND_NAME_EXITED.getCode(), EpmetErrorCode.DEMAND_NAME_EXITED.getMsg()); + } + + IcResiDemandDictEntity entity = new IcResiDemandDictEntity(); + entity.setCustomerId(formDTO.getCustomerId()); + entity.setCategoryName(formDTO.getCategoryName()); + entity.setLevel(NumConstant.ONE); + entity.setParentCode(NumConstant.ZERO_STR); + entity.setAwardPoint(NumConstant.ZERO); + entity.setUsableFlag(true); + // 获取当前最大的排序号 + Integer maxSort = baseDao.selectMaxSort(formDTO.getCustomerId(), NumConstant.ONE,NumConstant.ZERO_STR); + entity.setSort(null == maxSort ? NumConstant.ZERO : maxSort + 1); + // 一级分类,直接获取最大的,然后+1 + Integer maxFirstCategoryCode = baseDao.selectMaxCategoryCode(formDTO.getCustomerId(),NumConstant.ONE,NumConstant.ZERO_STR); + entity.setCategoryCode(null == maxFirstCategoryCode ? "1001" : String.valueOf(maxFirstCategoryCode + 1)); + baseDao.insert(entity); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void addChild(AddCategoryFormDTO formDTO) { + if (checkCategoryName(formDTO.getCustomerId(), formDTO.getCategoryName(), NumConstant.TWO, formDTO.getParentCategoryCode(),null) > NumConstant.ZERO) { + // 名称唯一 + throw new RenException(EpmetErrorCode.DEMAND_NAME_EXITED.getCode(), EpmetErrorCode.DEMAND_NAME_EXITED.getMsg()); + } + + IcResiDemandDictEntity entity = new IcResiDemandDictEntity(); + entity.setCustomerId(formDTO.getCustomerId()); + entity.setCategoryName(formDTO.getCategoryName()); + entity.setLevel(NumConstant.TWO); + entity.setParentCode(formDTO.getParentCategoryCode()); + entity.setAwardPoint(formDTO.getAwardPoint()); + entity.setUsableFlag(true); + // 获取当前最大的排序号 + Integer maxSort = baseDao.selectMaxSort(formDTO.getCustomerId(), NumConstant.TWO,formDTO.getParentCategoryCode()); + entity.setSort(null == maxSort ? NumConstant.ZERO : maxSort + 1); + // 二级分类,直接获取最大的,然后+1 + Integer maxCategoryCode = baseDao.selectMaxCategoryCode(formDTO.getCustomerId(),NumConstant.TWO,formDTO.getParentCategoryCode()); + entity.setCategoryCode(null == maxCategoryCode ? formDTO.getParentCategoryCode().concat("0001") : String.valueOf(maxCategoryCode + 1)); + baseDao.insert(entity); + } + + /** + * 校验名字是否存在 + * @param customerId + * @param categoryName + * @param level + * @param id + * @return + */ + public int checkCategoryName(String customerId,String categoryName,int level,String parentCategoryCode,String id){ + return baseDao.selectCountName(customerId,categoryName,level,parentCategoryCode,id); + } + + + + @Override public List list(Map params) { List entityList = baseDao.selectList(getWrapper(params)); @@ -72,24 +151,26 @@ public class IcResiDemandDictServiceImpl extends BaseServiceImpl NumConstant.ZERO) { + // 名称唯一 + throw new RenException(EpmetErrorCode.DEMAND_NAME_EXITED.getCode(), EpmetErrorCode.DEMAND_NAME_EXITED.getMsg()); + } + origin.setCategoryName(formDTO.getCategoryName()); + if (NumConstant.TWO == origin.getLevel()) { + origin.setAwardPoint(formDTO.getAwardPoint()); + } + updateById(origin); } @Override @@ -117,4 +198,31 @@ public class IcResiDemandDictServiceImpl extends BaseServiceImpl().ok(baseDao.selectCategoryNames(formDTO.getCustomerId(),formDTO.getCodeSet())); } + @Override + public List querySubCodeList(SubCodeFormDTO formDTO) { + return baseDao.selectByPCode(formDTO.getParentCategoryCode(),formDTO.getCustomerId()); + } + + @Override + public void updateStatus(StatusFormDTO formDTO) { + IcResiDemandDictEntity origin = baseDao.selectById(formDTO.getCategoryId()); + if (null == origin) { + log.error("category_id=" + formDTO.getCategoryId() + " 没有找到记录"); + return; + } + origin.setUsableFlag(formDTO.getUsableFlag()); + updateById(origin); + // 如果修改的是一级分类, 同步到二级 + if (NumConstant.ONE == origin.getLevel()) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(origin.getCategoryCode()), "PARENT_CODE", origin.getCategoryCode()); + List entityList = baseDao.selectList(wrapper); + for (IcResiDemandDictEntity sub : entityList) { + sub.setUsableFlag(formDTO.getUsableFlag()); + updateById(sub); + } + } + } + + } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcResiDemandDictDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcResiDemandDictDao.xml index ae0c5a1e7f..d9b7adb0ac 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcResiDemandDictDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcResiDemandDictDao.xml @@ -74,4 +74,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file