| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -45,6 +45,7 @@ import lombok.extern.slf4j.Slf4j; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.apache.commons.lang3.StringUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.slf4j.Logger; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.slf4j.LoggerFactory; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.springframework.beans.BeanUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.springframework.beans.factory.annotation.Autowired; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.springframework.stereotype.Service; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.springframework.transaction.annotation.Transactional; | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -200,19 +201,17 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @Transactional(rollbackFor = Exception.class) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public Result<AddGridResultDTO> addGrid(TokenDto tokenDto, AddGridFormDTO addGridFormDTO) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //查询是否重名
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String checkGridName = baseDao.selectGridIdByGridName(addGridFormDTO.getGridName(),addGridFormDTO.getAgencyId(),null); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (checkGridName!=null){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        AddGridResultDTO gridResult = baseDao.selectGridIdByGridName(addGridFormDTO.getGridName(), addGridFormDTO.getAgencyId(), null); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (gridResult!=null){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            return new Result().error(EpmetErrorCode.NOT_ADD_GRID.getCode()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //查询地区编码
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String areaCode = customerAgencyDao.selectAreaCodeByAgencyId(addGridFormDTO.getAgencyId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        CustomerGridEntity customerGridEntity = new CustomerGridEntity(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        customerGridEntity.setAreaCode(areaCode); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        CustomerAgencyDTO customerAgencyDTO=customerAgencyService.get(addGridFormDTO.getAgencyId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        customerGridEntity.setCustomerId(customerAgencyDTO.getCustomerId());//查询customerId
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        customerGridEntity.setGridName(addGridFormDTO.getGridName()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        customerGridEntity.setManageDistrict(addGridFormDTO.getManageDistrict()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        CustomerGridEntity customerGridEntity = new CustomerGridEntity(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        BeanUtils.copyProperties(addGridFormDTO,customerGridEntity); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        customerGridEntity.setAreaCode(customerAgencyDTO.getAreaCode()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        customerGridEntity.setCustomerId(customerAgencyDTO.getCustomerId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        customerGridEntity.setPid(addGridFormDTO.getAgencyId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //所有上级机构id,必须包括当前机构id (放在所有上级机构id后)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if(StringUtils.isBlank(customerAgencyDTO.getPids())){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            customerGridEntity.setPids(addGridFormDTO.getAgencyId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        }else{ | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -222,12 +221,9 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                customerGridEntity.setPids(customerAgencyDTO.getPids().concat(":").concat(addGridFormDTO.getAgencyId())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					       //查询所有上级组织id
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        baseDao.insert(customerGridEntity); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //查询刚刚添加的gridId
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String gridId = baseDao.selectGridIdByGridName(addGridFormDTO.getGridName(),addGridFormDTO.getAgencyId(),null); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        AddGridResultDTO addGridResultDTO = new AddGridResultDTO(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        addGridResultDTO.setGridId(gridId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        AddGridResultDTO addGridResultDTO = baseDao.selectGridIdByGridName(addGridFormDTO.getGridName(), addGridFormDTO.getAgencyId(), null); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return new Result<AddGridResultDTO>().ok(addGridResultDTO); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -239,8 +235,8 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @Override | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @Transactional(rollbackFor = Exception.class) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public Result editGrid(TokenDto tokenDto, EditGridFormDTO editGridFormDTO) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String checkGridName = baseDao.selectGridIdByGridName(editGridFormDTO.getGridName(),editGridFormDTO.getAgencyId(),editGridFormDTO.getGridId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (checkGridName!=null){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        AddGridResultDTO gridId = baseDao.selectGridIdByGridName(editGridFormDTO.getGridName(), editGridFormDTO.getAgencyId(), editGridFormDTO.getGridId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (gridId!=null){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            return new Result().error(EpmetErrorCode.NOT_ADD_GRID.getCode()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        CustomerGridDTO customerGridDTO = new CustomerGridDTO(); | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |