| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -37,13 +37,19 @@ import com.epmet.commons.tools.utils.Result; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.constant.CustomerGridConstant; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dao.CustomerGridDao; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dao.IcNeighborHoodDao; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dao.IcPropertyManagementDao; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dto.IcNeighborHoodDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dto.NeighborHoodAndManagementDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dto.form.ImportInfoFormDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dto.result.InfoByNamesResultDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.entity.IcNeighborHoodEntity; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.entity.IcNeighborHoodPropertyEntity; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.entity.IcPropertyManagementEntity; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.excel.IcBuildingExcel; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.excel.IcNeighborHoodExcel; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.service.IcNeighborHoodPropertyService; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.service.IcNeighborHoodService; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.service.IcPropertyManagementService; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.util.ExcelPoiUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import lombok.extern.slf4j.Slf4j; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.apache.commons.collections4.CollectionUtils; | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -70,6 +76,12 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @Autowired | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private CustomerGridDao customerGridDao; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @Autowired | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private IcPropertyManagementDao propertyManagementDao; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @Autowired | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private IcPropertyManagementService propertyManagementService; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @Autowired | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private IcNeighborHoodPropertyService neighborHoodPropertyService; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @Override | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public PageData<IcNeighborHoodDTO> page(Map<String, Object> params) { | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -217,7 +229,7 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            return new Result().error(9999,"excel表格内没有数据"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<Integer> nums = new ArrayList<>(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<String> gridNames = result.stream().map(m -> m.getGridName()).collect(Collectors.toList()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<String> gridNames = result.stream().map(m -> m.getGridName()).distinct().collect(Collectors.toList()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        // 1. 查询数据网格是否存在
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<InfoByNamesResultDTO> gridInfos = customerGridDao.selectGridInfoByNames(gridNames, formDTO.getCustomerId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (CollectionUtils.isEmpty(gridInfos)){ | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -241,7 +253,7 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        // 只获取能查询到的网格
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<IcNeighborHoodExcel> neighborHoods = groupStatus.get(true); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        // 2. 查询组织选中组织下存在的小区
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<String> existNames = baseDao.selectNeighborhoodNameByNames(neighborHoods.stream().map(m -> m.getNeighborHoodName()).collect(Collectors.toList()), formDTO.getCustomerId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<String> existNames = baseDao.selectNeighborhoodNameByNames(neighborHoods.stream().map(m -> m.getNeighborHoodName()).distinct().collect(Collectors.toList()), formDTO.getCustomerId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        // 为了显示多少行插入成功,未成功
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        result.forEach(r -> { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            for (String s : existNames) { | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -324,8 +336,31 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        // 物业表插入
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<String> propertyNames = finalNeedInsert.stream().map(m -> m.getPropertyName()).distinct().collect(Collectors.toList()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<String> disposePropertyNames = finalNeedInsert.stream().map(m -> m.getPropertyName()).distinct().collect(Collectors.toList()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<String> existPropertyNames = propertyManagementDao.selectExistNames(propertyNames); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        disposePropertyNames.removeAll(existPropertyNames); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<IcPropertyManagementEntity> propertyManagementEntities = new ArrayList<>(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (CollectionUtils.isNotEmpty(disposePropertyNames)){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            disposePropertyNames.forEach(name -> { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                IcPropertyManagementEntity e = new IcPropertyManagementEntity(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                e.setName(name); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                propertyManagementEntities.add(e); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        importInsert(entities,propertyManagementEntities); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        // 小区物业关系表插入
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<NeighborHoodAndManagementDTO> neighborHoodAndManagementDTOS = ConvertUtils.sourceToTarget(entities, NeighborHoodAndManagementDTO.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<IcPropertyManagementEntity> propertyManagementInfos = propertyManagementDao.selectIdByName(propertyNames); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        neighborHoodAndManagementDTOS.forEach(n -> propertyManagementInfos.stream().filter(p -> p.getName().equals(n.getPropertyName())) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                .forEach(p -> { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    n.setPropertyId(p.getId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    n.setNeighborHoodId(n.getId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                })); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<IcNeighborHoodPropertyEntity> icNeighborHoodPropertyEntities = ConvertUtils.sourceToTarget(neighborHoodAndManagementDTOS, IcNeighborHoodPropertyEntity.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        neighborHoodPropertyInsert(icNeighborHoodPropertyEntities); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        importInsert(entities); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        for (int i = NumConstant.ZERO; i < result.size(); i++) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (result.get(i).getStatus() == false || result.get(i).getExistNameStatus() == true || result.get(i).getAgencyNameStatus() == false || result.get(i).getReStatus() == true){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                nums.add(i + NumConstant.ONE); | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -338,12 +373,37 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return new Result().ok(str); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    /** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @Description  小区插入,物业插入 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param entities | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param propertyManagementEntities | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @author zxc | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @date 2022/2/13 10:09 上午 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @Transactional(rollbackFor = Exception.class) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public void importInsert(List<IcNeighborHoodEntity> entities){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public void importInsert(List<IcNeighborHoodEntity> entities,List<IcPropertyManagementEntity> propertyManagementEntities){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<List<IcNeighborHoodEntity>> partition = ListUtils.partition(entities, NumConstant.ONE_HUNDRED); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        partition.forEach(p -> { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            insertBatch(p); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<List<IcPropertyManagementEntity>> partition1 = ListUtils.partition(propertyManagementEntities, NumConstant.ONE_HUNDRED); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        partition1.forEach(p -> { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            propertyManagementService.insertBatch(p); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    /** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @Description 小区物业关系表插入 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param entities | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @author zxc | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @date 2022/2/13 10:09 上午 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @Transactional(rollbackFor = Exception.class) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public void neighborHoodPropertyInsert(List<IcNeighborHoodPropertyEntity> entities){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<List<IcNeighborHoodPropertyEntity>> partition = ListUtils.partition(entities, NumConstant.ONE_HUNDRED); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        partition.forEach(p -> { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            neighborHoodPropertyService.insertBatch(p); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} |