|  |  | @ -10,11 +10,9 @@ import com.epmet.dto.stats.form.FactUserHouseFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.stats.result.FactUserHouseResultDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.entity.stats.FactAgencyUserHouseDailyEntity; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.entity.stats.FactGridUserHouseDailyEntity; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.entity.stats.FactNeighborhoodUserHouseDailyEntity; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.org.HouseService; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.stats.DimGridService; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.stats.FactAgencyUserHouseDailyService; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.stats.FactGridUserHouseDailyService; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.stats.FactUserHouseService; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.stats.*; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.user.IcResiUserService; | 
			
		
	
		
			
				
					|  |  |  | import org.apache.commons.lang3.StringUtils; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
			
		
	
	
		
			
				
					|  |  | @ -37,6 +35,9 @@ public class FactUserHouseServiceImpl implements FactUserHouseService { | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private FactGridUserHouseDailyService factGridUserHouseDailyService; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private FactNeighborhoodUserHouseDailyService factNeighborhoodUserHouseDailyService; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private HouseService houseService; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | @ -59,7 +60,10 @@ public class FactUserHouseServiceImpl implements FactUserHouseService { | 
			
		
	
		
			
				
					|  |  |  |             params.put("dateId", DateUtils.getBeforeNDay(NumConstant.ONE)); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         if (params.containsKey("level")) { | 
			
		
	
		
			
				
					|  |  |  |             if (OrgLevelEnum.GRID.getCode().equals(params.get("level").toString()) || OrgLevelEnum.COMMUNITY.getCode().equals(params.get("level").toString())) { | 
			
		
	
		
			
				
					|  |  |  |             if("neighborhoodCode".equals(params.get("level").toString())){ | 
			
		
	
		
			
				
					|  |  |  |                 page = factNeighborhoodUserHouseDailyService.page(params); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             }else if (OrgLevelEnum.COMMUNITY.getCode().equals(params.get("level").toString())) { | 
			
		
	
		
			
				
					|  |  |  |                 page = factGridUserHouseDailyService.page(params); | 
			
		
	
		
			
				
					|  |  |  |             } else { | 
			
		
	
		
			
				
					|  |  |  |                 page = factAgencyUserHouseDailyService.page(params); | 
			
		
	
	
		
			
				
					|  |  | @ -83,7 +87,9 @@ public class FactUserHouseServiceImpl implements FactUserHouseService { | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         // 网格纬度查询网格统计表,其余纬度查询组织统计表
 | 
			
		
	
		
			
				
					|  |  |  |         if (params.containsKey("level")) { | 
			
		
	
		
			
				
					|  |  |  |             if (OrgLevelEnum.GRID.getCode().equals(params.get("level").toString())) { | 
			
		
	
		
			
				
					|  |  |  |             if("neighborhoodCode".equals(params.get("level").toString())){ | 
			
		
	
		
			
				
					|  |  |  |                 dto = factNeighborhoodUserHouseDailyService.getTotal(params); | 
			
		
	
		
			
				
					|  |  |  |             }else if (OrgLevelEnum.GRID.getCode().equals(params.get("level").toString())) { | 
			
		
	
		
			
				
					|  |  |  |                 dto = factGridUserHouseDailyService.getTotal(params); | 
			
		
	
		
			
				
					|  |  |  |             } else { | 
			
		
	
		
			
				
					|  |  |  |                 dto = factAgencyUserHouseDailyService.getTotal(params); | 
			
		
	
	
		
			
				
					|  |  | @ -96,7 +102,9 @@ public class FactUserHouseServiceImpl implements FactUserHouseService { | 
			
		
	
		
			
				
					|  |  |  |     public List<FactUserHouseResultDTO> list(Map<String, Object> params) { | 
			
		
	
		
			
				
					|  |  |  |         List<FactUserHouseResultDTO> list = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |         if (params.containsKey("level")) { | 
			
		
	
		
			
				
					|  |  |  |             if (OrgLevelEnum.GRID.getCode().equals(params.get("level").toString()) || OrgLevelEnum.COMMUNITY.getCode().equals(params.get("level").toString())) { | 
			
		
	
		
			
				
					|  |  |  |             if("neighborhoodCode".equals(params.get("level").toString())){ | 
			
		
	
		
			
				
					|  |  |  |                 list = factNeighborhoodUserHouseDailyService.listExport(params); | 
			
		
	
		
			
				
					|  |  |  |             }else if (OrgLevelEnum.COMMUNITY.getCode().equals(params.get("level").toString())) { | 
			
		
	
		
			
				
					|  |  |  |                 list = factGridUserHouseDailyService.listExport(params); | 
			
		
	
		
			
				
					|  |  |  |             } else { | 
			
		
	
		
			
				
					|  |  |  |                 list = factAgencyUserHouseDailyService.listExport(params); | 
			
		
	
	
		
			
				
					|  |  | @ -168,6 +176,71 @@ public class FactUserHouseServiceImpl implements FactUserHouseService { | 
			
		
	
		
			
				
					|  |  |  |         factGridUserHouseDailyService.insertBatch(entityList); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * 小区 | 
			
		
	
		
			
				
					|  |  |  |      * @author wgf | 
			
		
	
		
			
				
					|  |  |  |      * @param formDTO | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public void statNeighborhood(FactUserHouseFormDTO formDTO) { | 
			
		
	
		
			
				
					|  |  |  |         if (StringUtils.isBlank(formDTO.getDateId())) { | 
			
		
	
		
			
				
					|  |  |  |             formDTO.setDateId(DateUtils.getBeforeNDay(NumConstant.ONE)); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         String dateId = formDTO.getDateId(); | 
			
		
	
		
			
				
					|  |  |  |         String customerId = formDTO.getCustomerId(); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         // 先删除历史
 | 
			
		
	
		
			
				
					|  |  |  |         factNeighborhoodUserHouseDailyService.deleteByDateId(formDTO); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         // 保证小区是全部网格后,其余数据进行循环匹配
 | 
			
		
	
		
			
				
					|  |  |  |         List<FactUserHouseResultDTO> neiList = houseService.neighborhoodStatNew(formDTO); | 
			
		
	
		
			
				
					|  |  |  |         List<FactUserHouseResultDTO> houseList = houseService.houseStatNew(formDTO); | 
			
		
	
		
			
				
					|  |  |  |         List<FactUserHouseResultDTO> userList = icResiUserService.userStatNew(formDTO); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         List<FactUserHouseResultDTO> addList = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         neiList.forEach(item -> { | 
			
		
	
		
			
				
					|  |  |  |             String gridId = item.getGridId(); | 
			
		
	
		
			
				
					|  |  |  |             String neighborHoodsId = item.getNeighbourhoodsId(); | 
			
		
	
		
			
				
					|  |  |  |             FactUserHouseResultDTO dto = new FactUserHouseResultDTO(); | 
			
		
	
		
			
				
					|  |  |  |             dto.setCustomerId(formDTO.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |             dto.setDateId(dateId); | 
			
		
	
		
			
				
					|  |  |  |             dto.setGridId(gridId); | 
			
		
	
		
			
				
					|  |  |  |             dto.setPid(item.getPid()); | 
			
		
	
		
			
				
					|  |  |  |             dto.setPids(item.getPids()); | 
			
		
	
		
			
				
					|  |  |  |             dto.setNeighbourhoodsCount(item.getNeighbourhoodsCount()); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             Optional<FactUserHouseResultDTO> houseOptional = houseList.stream().filter(house -> neighborHoodsId.equals(house.getNeighbourhoodsId()) && customerId.equals(house.getCustomerId())).findFirst(); | 
			
		
	
		
			
				
					|  |  |  |             if (houseOptional.isPresent()) { | 
			
		
	
		
			
				
					|  |  |  |                 dto.setHouseCount(houseOptional.get().getHouseCount()); | 
			
		
	
		
			
				
					|  |  |  |                 dto.setHouseSelfCount(houseOptional.get().getHouseSelfCount()); | 
			
		
	
		
			
				
					|  |  |  |                 dto.setHouseLeaseCount(houseOptional.get().getHouseLeaseCount()); | 
			
		
	
		
			
				
					|  |  |  |                 dto.setHouseIdleCount(houseOptional.get().getHouseIdleCount()); | 
			
		
	
		
			
				
					|  |  |  |             } else { | 
			
		
	
		
			
				
					|  |  |  |                 dto.setHouseCount(NumConstant.ZERO); | 
			
		
	
		
			
				
					|  |  |  |                 dto.setHouseSelfCount(NumConstant.ZERO); | 
			
		
	
		
			
				
					|  |  |  |                 dto.setHouseLeaseCount(NumConstant.ZERO); | 
			
		
	
		
			
				
					|  |  |  |                 dto.setHouseIdleCount(NumConstant.ZERO); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             Optional<FactUserHouseResultDTO> userOptional = userList.stream().filter(user -> neighborHoodsId.equals(user.getNeighbourhoodsId()) && customerId.equals(user.getCustomerId())).findFirst(); | 
			
		
	
		
			
				
					|  |  |  |             if (userOptional.isPresent()) { | 
			
		
	
		
			
				
					|  |  |  |                 dto.setUserCount(userOptional.get().getUserCount()); | 
			
		
	
		
			
				
					|  |  |  |                 dto.setUserResiCount(userOptional.get().getUserResiCount()); | 
			
		
	
		
			
				
					|  |  |  |                 dto.setUserFloatCount(userOptional.get().getUserFloatCount()); | 
			
		
	
		
			
				
					|  |  |  |             } else { | 
			
		
	
		
			
				
					|  |  |  |                 dto.setUserCount(NumConstant.ZERO); | 
			
		
	
		
			
				
					|  |  |  |                 dto.setUserResiCount(NumConstant.ZERO); | 
			
		
	
		
			
				
					|  |  |  |                 dto.setUserFloatCount(NumConstant.ZERO); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |             addList.add(dto); | 
			
		
	
		
			
				
					|  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         List<FactNeighborhoodUserHouseDailyEntity> entityList = ConvertUtils.sourceToTarget(addList, FactNeighborhoodUserHouseDailyEntity.class); | 
			
		
	
		
			
				
					|  |  |  |         factNeighborhoodUserHouseDailyService.insertBatch(entityList); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public void statAgency(FactUserHouseFormDTO formDTO) { | 
			
		
	
		
			
				
					|  |  |  |         if (StringUtils.isBlank(formDTO.getDateId())) { | 
			
		
	
	
		
			
				
					|  |  | @ -218,4 +291,4 @@ public class FactUserHouseServiceImpl implements FactUserHouseService { | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
	
		
			
				
					|  |  | 
 |