Browse Source

网格添加修改

dev
zxc 5 years ago
parent
commit
7bcedf2ac2
  1. 2
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  2. 8
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java
  3. 32
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java
  4. 11
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml
  5. 17
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/GridCountFormDTO.java
  6. 17
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/GridCountResultDTO.java
  7. 11
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java
  8. 7
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java
  9. 11
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java
  10. 9
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerDao.java
  11. 13
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java
  12. 12
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java
  13. 11
      epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerDao.xml

2
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,"您已表态"),

8
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java

@ -216,4 +216,12 @@ public interface CustomerGridDao extends BaseDao<CustomerGridEntity> {
* @Description 单客户-指定区时查询当前城市下除该区之外其余的网格
**/
List<PublicCustomerGridForStrangerResultDTO> selectThirdRestGridWithoutGivenAreaCode(Map<String, Object> map);
/**
* @Description 查询当前客户已有网格数量
* @param customerId
* @author zxc
* @date 2020/8/12 5:10 下午
*/
Integer selectGridCount(@Param("customerId")String customerId);
}

32
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<CustomerGridDao, Cu
@Autowired
private EpmetUserFeignClient epmetUserFeignClient;
@Autowired
private CustomerStaffGridService customerStaffGridService;
@Autowired
private CustomerStaffGridDao customerStaffGridDao;
@Autowired
private CustomerAgencyDao customerAgencyDao;
private OperCrmOpenFeignClient operCrmOpenFeignClient;
@Autowired
private CustomerGridDao customerGridDao;
@Override
public PageData<CustomerGridDTO> page(Map<String, Object> params) {
@ -206,15 +207,36 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu
return new Result<GridDetailResultDTO>().ok(griddetail);
}
/**
* @Desc 网格添加
* @Author zxc
* @param tokenDto
* @param addGridFormDTO
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result<AddGridResultDTO> 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());

11
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml

@ -462,4 +462,15 @@
) AS c
LIMIT #{pageNo}, #{pageSize}
</select>
<!-- 查询当前客户已有网格数量 -->
<select id="selectGridCount" resultType="java.lang.Integer">
SELECT
COUNT( id ) AS gridCount
FROM
customer_grid
WHERE
del_flag = '0'
AND customer_id = #{customerId}
</select>
</mapper>

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

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

11
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<List<CustomerDTO>> getAllCustomerList();
/**
* @Description 查询客户下可以创建网格的最大数
* @param formDTO
* @author zxc
* @date 2020/8/12 4:37 下午
*/
@PostMapping("/oper/crm/customer/getgridcount")
Result<GridCountResultDTO> getGridCount(@RequestBody GridCountFormDTO formDTO);
}

7
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<List<CustomerDTO>> getAllCustomerList() {
return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "getAllCustomerList", null);
}
@Override
public Result<GridCountResultDTO> getGridCount(GridCountFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "getGridCount", formDTO);
}
}

11
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<List<CustomerDTO>>().ok(customerService.getAllList());
}
/**
* @Description 查询客户下可以创建网格的最大数
* @author zxc
* @date 2020/8/12 4:30 下午
*/
@PostMapping("getgridcount")
public Result<GridCountResultDTO> getGridCount(@RequestBody GridCountFormDTO formDTO){
return new Result<GridCountResultDTO>().ok(customerService.getGridCount(formDTO));
}
}

9
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<CustomerEntity> {
*/
List<CustomerEntity> getAllList();
/**
* @Description 查询客户下可以创建网格的最大数
* @param customerId
* @author zxc
* @date 2020/8/12 4:46 下午
*/
GridCountResultDTO getGridCount(@Param("customerId")String customerId);
}

13
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<CustomerEntity> {
* @return
*/
List<CustomerDTO> getAllList();
/**
* @Description 查询客户下可以创建网格的最大数
* @author zxc
* @date 2020/8/12 4:30 下午
*/
GridCountResultDTO getGridCount( GridCountFormDTO formDTO);
}

12
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<CustomerDao, CustomerEn
private OperCustomizeFeignClient operCustomizeFeignClient;
@Autowired
private GovOrgOpenFeignClient govOrgOpenFeignClient;
@Autowired
private CustomerDao customerDao;
@Override
public PageData<CustomerDTO> page(Map<String, Object> params) {
@ -545,4 +547,14 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerDao, CustomerEn
return ConvertUtils.sourceToTarget(list,CustomerDTO.class);
}
/**
* @Description 查询客户下可以创建网格的最大数
* @author zxc
* @date 2020/8/12 4:30 下午
*/
@Override
public GridCountResultDTO getGridCount(GridCountFormDTO formDTO) {
return customerDao.getGridCount(formDTO.getCustomerId());
}
}

11
epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerDao.xml

@ -78,4 +78,15 @@
WHERE
del_flag = '0'
</select>
<!-- 查询客户下可以创建网格的最大数 -->
<select id="getGridCount" resultType="com.epmet.dto.result.GridCountResultDTO">
SELECT
IFNULL( grid_number, 0 ) AS gridCount
FROM
customer
WHERE
del_flag = 0
AND id = #{customerId}
</select>
</mapper>

Loading…
Cancel
Save