Browse Source

居民需求分类管理

master
yinzuomei 4 years ago
parent
commit
f4e872c357
  1. 1
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  2. 31
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/AddCategoryFormDTO.java
  3. 26
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/AddFirstCategoryFormDTO.java
  4. 17
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/DemandDictPageFormDTO.java
  5. 20
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/StatusFormDTO.java
  6. 15
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/SubCodeFormDTO.java
  7. 42
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/UpdateFormDTO.java
  8. 2
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/UserDemandNameQueryFormDTO.java
  9. 21
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/DemandPageResDTO.java
  10. 12
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/OptionDTO.java
  11. 121
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcResiDemandDictController.java
  12. 22
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcResiDemandDictDao.java
  13. 11
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcResiDemandDictEntity.java
  14. 51
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcResiDemandDictService.java
  15. 154
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcResiDemandDictServiceImpl.java
  16. 120
      epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcResiDemandDictDao.xml

1
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, "请求第三方平台错误"),

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

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

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

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

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

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

2
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)

21
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<DemandPageResDTO> children;
}

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

121
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<PageData<IcResiDemandDictDTO>> page(@RequestParam Map<String, Object> params){
PageData<IcResiDemandDictDTO> page = icResiDemandDictService.page(params);
return new Result<PageData<IcResiDemandDictDTO>>().ok(page);
/**
* 分页列表查询
*
* @param formDTO
* @return
*/
@PostMapping("pagelist")
public Result<PageData<DemandPageResDTO>> page(@RequestBody DemandDictPageFormDTO formDTO){
ValidatorUtils.validateEntity(formDTO,DemandDictPageFormDTO.AddUserInternalGroup.class, PageFormDTO.AddUserInternalGroup.class);
PageData<DemandPageResDTO> page = icResiDemandDictService.page(formDTO);
return new Result<PageData<DemandPageResDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<IcResiDemandDictDTO> get(@PathVariable("id") String id){
IcResiDemandDictDTO data = icResiDemandDictService.get(id);
return new Result<IcResiDemandDictDTO>().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<List<OptionDTO>> querySubCodeList(@LoginUser TokenDto tokenDto, @RequestBody SubCodeFormDTO formDTO){
formDTO.setCustomerId(tokenDto.getCustomerId());
ValidatorUtils.validateEntity(formDTO,SubCodeFormDTO.AddUserInternalGroup.class);
return new Result<List<OptionDTO>>().ok(icResiDemandDictService.querySubCodeList(formDTO));
}
}

22
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<IcResiDemandDictEntity> {
List<OptionResultDTO> selectChildDemands(@Param("customerId")String customerId, @Param("parentCode") String parentCode);
String selectCategoryNames(@Param("customerId") String customerId,@Param("codeSet") Set<String> codeSet);
List<OptionDTO> selectByPCode(@Param("pcode") String pcode, @Param("customerId") String customerId);
List<DemandPageResDTO> pageSelect(@Param("customerId") String customerId, @Param("firstCategoryCode")String firstCategoryCode);
List<DemandPageResDTO> 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);
}

11
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;
/**
* 奖励积分只有二级分类才会配置一级默认为011.17
*/
private Integer awardPoint;
/**
* 1可用0不可用,11.17
*/
private Boolean usableFlag;
}

51
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<IcResiDemandDictEnt
/**
* 默认分页
*
* @param params
* @param formDTO
* @return PageData<IcResiDemandDictDTO>
* @author generator
* @date 2021-10-27
*/
PageData<IcResiDemandDictDTO> page(Map<String, Object> params);
PageData<DemandPageResDTO> page(DemandDictPageFormDTO formDTO);
/**
* 默认查询
*
* @param params
* @return java.util.List<IcResiDemandDictDTO>
* @author generator
* @date 2021-10-27
* 新增一级分类
* @param formDTO
*/
List<IcResiDemandDictDTO> list(Map<String, Object> 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<IcResiDemandDictDTO>
* @author generator
* @date 2021-10-27
*/
void save(IcResiDemandDictDTO dto);
List<IcResiDemandDictDTO> list(Map<String, Object> 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<IcResiDemandDictEnt
* @return
*/
Result<String> queryDemandNames(UserDemandNameQueryFormDTO formDTO);
List<OptionDTO> querySubCodeList(SubCodeFormDTO formDTO);
/**
* 启用或禁用
*
* @param formDTO
*/
void updateStatus(StatusFormDTO formDTO);
}

154
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<IcResiDemandDictDao, IcResiDemandDictEntity> implements IcResiDemandDictService {
/**
* 分页查询
*
* @param formDTO
* @return
*/
@Override
public PageData<IcResiDemandDictDTO> page(Map<String, Object> params) {
IPage<IcResiDemandDictEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, IcResiDemandDictDTO.class);
public PageData<DemandPageResDTO> page(DemandDictPageFormDTO formDTO) {
PageInfo<DemandPageResDTO> 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<IcResiDemandDictDTO> list(Map<String, Object> params) {
List<IcResiDemandDictEntity> entityList = baseDao.selectList(getWrapper(params));
@ -72,24 +151,26 @@ public class IcResiDemandDictServiceImpl extends BaseServiceImpl<IcResiDemandDic
return wrapper;
}
@Override
public IcResiDemandDictDTO get(String id) {
IcResiDemandDictEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, IcResiDemandDictDTO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(IcResiDemandDictDTO dto) {
IcResiDemandDictEntity entity = ConvertUtils.sourceToTarget(dto, IcResiDemandDictEntity.class);
insert(entity);
}
/**
* 修改分类
*
*
* @param formDTO
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void update(IcResiDemandDictDTO dto) {
IcResiDemandDictEntity entity = ConvertUtils.sourceToTarget(dto, IcResiDemandDictEntity.class);
updateById(entity);
public void update(UpdateFormDTO formDTO) {
IcResiDemandDictEntity origin = baseDao.selectById(formDTO.getCategoryId());
if (checkCategoryName(formDTO.getCustomerId(), formDTO.getCategoryName(), NumConstant.TWO, origin.getParentCode(), formDTO.getCategoryId()) > 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<IcResiDemandDic
return new Result<String>().ok(baseDao.selectCategoryNames(formDTO.getCustomerId(),formDTO.getCodeSet()));
}
@Override
public List<OptionDTO> 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<IcResiDemandDictEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(origin.getCategoryCode()), "PARENT_CODE", origin.getCategoryCode());
List<IcResiDemandDictEntity> entityList = baseDao.selectList(wrapper);
for (IcResiDemandDictEntity sub : entityList) {
sub.setUsableFlag(formDTO.getUsableFlag());
updateById(sub);
}
}
}
}

120
epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcResiDemandDictDao.xml

@ -74,4 +74,124 @@
</if>
</select>
<select id="selectByPCode" parameterType="map" resultType="com.epmet.dto.result.demand.OptionDTO">
SELECT
m.CATEGORY_NAME as label,
m.CATEGORY_CODE as `value`
FROM
ic_resi_demand_dict m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID = #{customerId}
and m.PARENT_CODE = #{pcode}
order by m.sort asc
</select>
<resultMap id="DemandPageResDTOMap" type="com.epmet.dto.result.demand.DemandPageResDTO">
<id property="categoryId" column="ID"></id>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="categoryCode" column="CATEGORY_CODE"/>
<result property="parentCategoryCode" column="PARENT_CODE"/>
<result property="categoryName" column="CATEGORY_NAME"/>
<result property="level" column="LEVEL"/>
<result property="sort" column="SORT"/>
<result property="usableFlag" column="USABLE_FLAG"/>
<result property="awardPoint" column="AWARD_POINT"/>
<collection property="children" ofType="com.epmet.dto.result.demand.DemandPageResDTO"
select="selectChild" column="customerId=CUSTOMER_ID,parentCode=CATEGORY_CODE">
</collection>
</resultMap>
<select id="pageSelect" resultMap="DemandPageResDTOMap" parameterType="map">
SELECT
m.CUSTOMER_ID,
m.ID,
m.CATEGORY_CODE,
m.PARENT_CODE,
m.CATEGORY_NAME,
m.`LEVEL`,
m.SORT,
m.USABLE_FLAG,
m.AWARD_POINT
FROM
ic_resi_demand_dict m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID = #{customerId}
AND m.PARENT_CODE = '0'
<if test="null!=firstCategoryCode and firstCategoryCode!=''">
AND m.CATEGORY_CODE =#{firstCategoryCode}
</if>
ORDER BY
m.CREATED_TIME DESC
</select>
<select id="selectChild" resultMap="DemandPageResDTOMap" parameterType="map">
SELECT
m.CUSTOMER_ID,
m.ID,
m.CATEGORY_CODE,
m.PARENT_CODE,
m.CATEGORY_NAME,
m.`LEVEL`,
m.SORT,
m.USABLE_FLAG,
m.AWARD_POINT
FROM
ic_resi_demand_dict m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID = #{customerId}
AND m.PARENT_CODE = #{parentCode}
ORDER BY
m.CREATED_TIME DESC
</select>
<select id="selectCountName" parameterType="map" resultType="int">
select
count(1)
FROM
ic_resi_demand_dict m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID = #{customerId}
and m.level=#{level}
and m.CATEGORY_NAME=#{categoryName}
<if test="null!=parentCode and parentCode!=''">
and m.parent_code=#{parentCode}
</if>
<if test="null!=id and id!=''">
and m.id !=#{id}
</if>
</select>
<select id="selectMaxCategoryCode" parameterType="map" resultType="java.lang.Integer">
SELECT
MAX(
CONVERT ( m.CATEGORY_CODE, UNSIGNED )) AS maxFirstCategoryCode
FROM
ic_resi_demand_dict m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID = #{customerId}
AND m.`LEVEL` = #{level}
and m.parent_code=#{parentCode}
</select>
<select id="selectMaxSort" parameterType="map" resultType="java.lang.Integer">
SELECT
max( m.SORT ) AS maxSort
FROM
ic_resi_demand_dict m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID = #{customerId}
AND m.`LEVEL` = #{level}
<if test="null!=parentCode and parentCode!=''">
and m.parent_code=#{parentCode}
</if>
</select>
</mapper>
Loading…
Cancel
Save