| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -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()); | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |