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 fbbeebccbf..50512fd6d6 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 @@ -75,6 +75,8 @@ public enum EpmetErrorCode { STAFF_ADD_FAILED(8403,"人员添加失败"), STAFF_EDIT_FAILED(8404,"人员编辑失败"), CANNOT_DISABLE_YOURSELF(8405,"您不能禁用自己"), + NO_SET_GRID_COUNT(8406,"您还未设置创建网格数量上限,请联系管理员设置"), + GRID_COUNT_UP(8407,"您的创建网格数量已到达上限,请联系管理员设置"), ALREADY_EVALUATE(8501,"您已评价"), ALREADY_VOTE(8502,"您已表态"), diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java index 09f71efd99..1d50d1453a 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java @@ -216,4 +216,12 @@ public interface CustomerGridDao extends BaseDao { * @Description 单客户-指定区时查询当前城市下除该区之外其余的网格 **/ List selectThirdRestGridWithoutGivenAreaCode(Map map); + + /** + * @Description 查询当前客户已有网格数量 + * @param customerId + * @author zxc + * @date 2020/8/12 5:10 下午 + */ + Integer selectGridCount(@Param("customerId")String customerId); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java index 8f023276a3..fd32b2a087 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java @@ -37,6 +37,7 @@ import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.entity.CustomerGridEntity; import com.epmet.feign.EpmetUserFeignClient; +import com.epmet.feign.OperCrmOpenFeignClient; import com.epmet.service.CustomerAgencyService; import com.epmet.service.CustomerGridService; import com.epmet.service.CustomerStaffGridService; @@ -69,11 +70,11 @@ public class CustomerGridServiceImpl extends BaseServiceImpl page(Map params) { @@ -206,15 +207,36 @@ public class CustomerGridServiceImpl extends BaseServiceImpl().ok(griddetail); } + /** + * @Desc 网格添加 + * @Author zxc + * @param tokenDto + * @param addGridFormDTO + * @return + */ @Override @Transactional(rollbackFor = Exception.class) public Result addGrid(TokenDto tokenDto, AddGridFormDTO addGridFormDTO) { - //查询是否重名 + CustomerAgencyDTO customerAgencyDTO=customerAgencyService.get(addGridFormDTO.getAgencyId()); + // 1. 查询该客户下可创建网格的最大数量 + GridCountFormDTO gridCount = new GridCountFormDTO(); + String customerId = customerAgencyDTO.getCustomerId(); + gridCount.setCustomerId(customerId); + GridCountResultDTO grid = operCrmOpenFeignClient.getGridCount(gridCount).getData(); + if (grid.getGridCount().equals(NumConstant.ZERO)){ + throw new RenException(EpmetErrorCode.GRID_COUNT_UP.getCode()); + } + // 2. 判断当前客户下存在的网格数量 + Integer gridCounts = customerGridDao.selectGridCount(customerId); + if (gridCounts >= grid.getGridCount()){ + throw new RenException(EpmetErrorCode.GRID_COUNT_UP.getCode()); + } + // 3. 查询网格名称是否重名 AddGridResultDTO gridResult = baseDao.selectGridIdByGridName(addGridFormDTO.getGridName(), addGridFormDTO.getAgencyId(), null); if (gridResult!=null){ return new Result().error(EpmetErrorCode.NOT_ADD_GRID.getCode()); } - CustomerAgencyDTO customerAgencyDTO=customerAgencyService.get(addGridFormDTO.getAgencyId()); + CustomerGridEntity customerGridEntity = new CustomerGridEntity(); BeanUtils.copyProperties(addGridFormDTO,customerGridEntity); customerGridEntity.setAreaCode(customerAgencyDTO.getAreaCode()); diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml index 802ec9f2f3..b9a98117e1 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml @@ -462,4 +462,15 @@ ) AS c LIMIT #{pageNo}, #{pageSize} + + + \ No newline at end of file diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/GridCountFormDTO.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/GridCountFormDTO.java new file mode 100644 index 0000000000..a4ebfedc5c --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/GridCountFormDTO.java @@ -0,0 +1,17 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2020/8/12 4:34 下午 + */ +@Data +public class GridCountFormDTO implements Serializable { + + private static final long serialVersionUID = 3121175488079594627L; + + private String customerId; +} diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/GridCountResultDTO.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/GridCountResultDTO.java new file mode 100644 index 0000000000..7264a71c72 --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/GridCountResultDTO.java @@ -0,0 +1,17 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2020/8/12 4:31 下午 + */ +@Data +public class GridCountResultDTO implements Serializable { + + private static final long serialVersionUID = -5523213918272649646L; + + private Integer gridCount; +} diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java index 7b426012b4..161d3e5f9e 100644 --- a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java @@ -6,6 +6,8 @@ import com.epmet.dto.CustomerAppDTO; import com.epmet.dto.CustomerDTO; import com.epmet.dto.form.CustomerAppSecretFormDTO; import com.epmet.dto.form.CustomerManagerFormDTO; +import com.epmet.dto.form.GridCountFormDTO; +import com.epmet.dto.result.GridCountResultDTO; import com.epmet.feign.fallback.OperCrmOpenFeignClientFallback; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; @@ -62,4 +64,13 @@ public interface OperCrmOpenFeignClient { */ @PostMapping("/oper/crm/customer/getalllist") Result> getAllCustomerList(); + + /** + * @Description 查询客户下可以创建网格的最大数 + * @param formDTO + * @author zxc + * @date 2020/8/12 4:37 下午 + */ + @PostMapping("/oper/crm/customer/getgridcount") + Result getGridCount(@RequestBody GridCountFormDTO formDTO); } diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java index b4f3947ed7..f4ad95f4ca 100644 --- a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java @@ -7,6 +7,8 @@ import com.epmet.dto.CustomerAppDTO; import com.epmet.dto.CustomerDTO; import com.epmet.dto.form.CustomerAppSecretFormDTO; import com.epmet.dto.form.CustomerManagerFormDTO; +import com.epmet.dto.form.GridCountFormDTO; +import com.epmet.dto.result.GridCountResultDTO; import com.epmet.feign.OperCrmOpenFeignClient; import org.springframework.stereotype.Component; @@ -50,4 +52,9 @@ public class OperCrmOpenFeignClientFallback implements OperCrmOpenFeignClient { public Result> getAllCustomerList() { return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "getAllCustomerList", null); } + + @Override + public Result getGridCount(GridCountFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "getGridCount", formDTO); + } } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java index 79c49245b6..dc26003a63 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java @@ -32,6 +32,7 @@ import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.CustomerDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.CustomerDetailResultDTO; +import com.epmet.dto.result.GridCountResultDTO; import com.epmet.dto.result.ValidCustomerResultDTO; import com.epmet.excel.CustomerExcel; import com.epmet.feign.GovOrgFeignClient; @@ -256,4 +257,14 @@ public class CustomerController { return new Result>().ok(customerService.getAllList()); } + /** + * @Description 查询客户下可以创建网格的最大数 + * @author zxc + * @date 2020/8/12 4:30 下午 + */ + @PostMapping("getgridcount") + public Result getGridCount(@RequestBody GridCountFormDTO formDTO){ + return new Result().ok(customerService.getGridCount(formDTO)); + } + } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerDao.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerDao.java index dea5f2f40b..40dd5394e6 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerDao.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerDao.java @@ -20,6 +20,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.CustomerDTO; import com.epmet.dto.result.CustomerResultDTO; +import com.epmet.dto.result.GridCountResultDTO; import com.epmet.dto.result.ValidCustomerResultDTO; import com.epmet.entity.CustomerEntity; import org.apache.ibatis.annotations.Mapper; @@ -74,4 +75,12 @@ public interface CustomerDao extends BaseDao { */ List getAllList(); + /** + * @Description 查询客户下可以创建网格的最大数 + * @param customerId + * @author zxc + * @date 2020/8/12 4:46 下午 + */ + GridCountResultDTO getGridCount(@Param("customerId")String customerId); + } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java index b815474688..08475a9f5b 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java @@ -21,11 +21,9 @@ 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.CustomerDTO; -import com.epmet.dto.form.CustomerFormDTO; -import com.epmet.dto.form.CustomerInitFormDTO; -import com.epmet.dto.form.CustomerManagerFormDTO; -import com.epmet.dto.form.PageQueryFormDTO; +import com.epmet.dto.form.*; import com.epmet.dto.result.CustomerDetailResultDTO; +import com.epmet.dto.result.GridCountResultDTO; import com.epmet.dto.result.ValidCustomerResultDTO; import com.epmet.entity.CustomerEntity; @@ -174,4 +172,11 @@ public interface CustomerService extends BaseService { * @return */ List getAllList(); + + /** + * @Description 查询客户下可以创建网格的最大数 + * @author zxc + * @date 2020/8/12 4:30 下午 + */ + GridCountResultDTO getGridCount( GridCountFormDTO formDTO); } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java index 6565160593..a408167145 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java @@ -76,6 +76,8 @@ public class CustomerServiceImpl extends BaseServiceImpl page(Map params) { @@ -545,4 +547,14 @@ public class CustomerServiceImpl extends BaseServiceImpl + + +