|  | @ -40,10 +40,13 @@ | 
			
		
	
		
		
			
				
					|  |  |  import com.epmet.dataaggre.entity.datastats.DimAgencyEntity; |  |  |  import com.epmet.dataaggre.entity.datastats.DimAgencyEntity; | 
			
		
	
		
		
			
				
					|  |  |  import com.epmet.dataaggre.entity.datastats.FactAgencyGovernDailyEntity; |  |  |  import com.epmet.dataaggre.entity.datastats.FactAgencyGovernDailyEntity; | 
			
		
	
		
		
			
				
					|  |  |  import com.epmet.dataaggre.excel.CustomerDataManageExcel; |  |  |  import com.epmet.dataaggre.excel.CustomerDataManageExcel; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |  import com.epmet.dataaggre.service.PartymemberService; | 
			
		
	
		
		
			
				
					|  |  |  import com.epmet.dataaggre.service.datastats.DataStatsService; |  |  |  import com.epmet.dataaggre.service.datastats.DataStatsService; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |  import com.epmet.dataaggre.service.epmetuser.EpmetUserService; | 
			
		
	
		
		
			
				
					|  |  |  import com.epmet.dataaggre.service.epmetuser.StatsStaffPatrolRecordDailyService; |  |  |  import com.epmet.dataaggre.service.epmetuser.StatsStaffPatrolRecordDailyService; | 
			
		
	
		
		
			
				
					|  |  |  import com.epmet.dataaggre.service.evaluationindex.EvaluationIndexService; |  |  |  import com.epmet.dataaggre.service.evaluationindex.EvaluationIndexService; | 
			
		
	
		
		
			
				
					|  |  |  import com.epmet.dataaggre.service.govorg.GovOrgService; |  |  |  import com.epmet.dataaggre.service.govorg.GovOrgService; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |  import com.epmet.dataaggre.service.govproject.GovProjectService; | 
			
		
	
		
		
			
				
					|  |  |  import com.epmet.dataaggre.service.opercrm.CustomerRelation; |  |  |  import com.epmet.dataaggre.service.opercrm.CustomerRelation; | 
			
		
	
		
		
			
				
					|  |  |  import com.github.pagehelper.PageHelper; |  |  |  import com.github.pagehelper.PageHelper; | 
			
		
	
		
		
			
				
					|  |  |  import com.github.pagehelper.PageInfo; |  |  |  import com.github.pagehelper.PageInfo; | 
			
		
	
	
		
		
			
				
					|  | @ -86,6 +89,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve | 
			
		
	
		
		
			
				
					|  |  |     private StatsStaffPatrolRecordDailyService statsStaffPatrolRecordDailyService; |  |  |     private StatsStaffPatrolRecordDailyService statsStaffPatrolRecordDailyService; | 
			
		
	
		
		
			
				
					|  |  |     @Autowired |  |  |     @Autowired | 
			
		
	
		
		
			
				
					|  |  |     private GovOrgService govOrgService; |  |  |     private GovOrgService govOrgService; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     @Autowired | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     private EpmetUserService epmetUserService; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     @Autowired | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     private GovProjectService govProjectService; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     @Autowired | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     private PartymemberService partymemberService; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     /** |  |  |     /** | 
			
		
	
		
		
			
				
					|  |  |      * @Param formDTO |  |  |      * @Param formDTO | 
			
		
	
	
		
		
			
				
					|  | @ -2310,4 +2319,112 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve | 
			
		
	
		
		
			
				
					|  |  |         PageInfo<MemberProjectInfoResultDTO> pageInfo = new PageInfo<>(list); |  |  |         PageInfo<MemberProjectInfoResultDTO> pageInfo = new PageInfo<>(list); | 
			
		
	
		
		
			
				
					|  |  |         return new PageData<>(list, pageInfo.getTotal()); |  |  |         return new PageData<>(list, pageInfo.getTotal()); | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     @Override | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     public List<NowStatsDataResultDTO> nowStatsData(NowStatsDataFormDTO formDTO) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //1.必要参数校验及处理
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         String startTimeForm = formDTO.getStartTime(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if ("Interval".equals(formDTO.getType()) && StringUtils.isEmpty(startTimeForm)) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             throw new RenException("请选择开始时间或查询累计值"); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //2.查询组织信息,判断要查询下级是组织还是网格数据
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         ScreenAgencyOrGridListDTO agencyGrid = govOrgService.getSubAgencyOrGridList(formDTO.getCustomerId(), formDTO.getAgencyId()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if (null == agencyGrid) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             return new ArrayList<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //组织或网格Id集合
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<String> idList = agencyGrid.getAgencyGridList().stream().map(ScreenAgencyOrGridListDTO.AgencyGrid::getOrgId).collect(Collectors.toList()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         formDTO.setDataType(!OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) ? OrgTypeEnum.AGENCY.getCode() : OrgTypeEnum.GRID.getCode()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         formDTO.setIdList(idList); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //3.按条件分别查询统计各业务实时数据
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //3-1.注册居民、注册党员数
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<NowStatsDataResultDTO> user = epmetUserService.getNowResiUser(formDTO); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<NowStatsDataResultDTO> party = partymemberService.getNowPart(formDTO); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //3-2.事件总数、居民上报事件数、平台录入事件数
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<NowStatsDataResultDTO> event = govProjectService.getNowIcEvent(formDTO); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //3-3.项目总数、议题转项目数、事件立项数、组织立项数
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<NowStatsDataResultDTO> project = govProjectService.getNowProject(formDTO); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         Map<String, NowStatsDataResultDTO> userMap = new HashMap<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         Map<String, NowStatsDataResultDTO> partyMap = new HashMap<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         Map<String, NowStatsDataResultDTO> eventMap = new HashMap<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         Map<String, NowStatsDataResultDTO> projectMap = new HashMap<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if ("grid".equals(formDTO.getDataType())) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             userMap = CollectionUtils.isEmpty(user) ? new HashMap<>() : user.stream().collect(Collectors.toMap(NowStatsDataResultDTO::getOrgId, m -> m, (k1, k2) -> k1)); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             partyMap = CollectionUtils.isEmpty(party) ? new HashMap<>() : party.stream().collect(Collectors.toMap(NowStatsDataResultDTO::getOrgId, m -> m, (k1, k2) -> k1)); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             eventMap = CollectionUtils.isEmpty(event) ? new HashMap<>() : event.stream().collect(Collectors.toMap(NowStatsDataResultDTO::getOrgId, m -> m, (k1, k2) -> k1)); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             projectMap = CollectionUtils.isEmpty(project) ? new HashMap<>() : project.stream().collect(Collectors.toMap(NowStatsDataResultDTO::getOrgId, m -> m, (k1, k2) -> k1)); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //4.封装数据
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<NowStatsDataResultDTO> resultDTOList = new ArrayList<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         NowStatsDataResultDTO export = new NowStatsDataResultDTO(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         export.setOrgName("合计"); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         for (ScreenAgencyOrGridListDTO.AgencyGrid org : agencyGrid.getAgencyGridList()) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             NowStatsDataResultDTO dto = new NowStatsDataResultDTO(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             dto.setOrgId(org.getOrgId()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             dto.setOrgName(org.getOrgName()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             //网格数据sql已统计好
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             if ("grid".equals(formDTO.getDataType())) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 if (userMap.containsKey(org.getOrgId())) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     dto.setResiUserCount(userMap.get(org.getOrgId()).getResiUserCount()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 if (partyMap.containsKey(org.getOrgId())) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     dto.setPartyMemberCount(partyMap.get(org.getOrgId()).getPartyMemberCount()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 if (eventMap.containsKey(org.getOrgId())) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     dto.setIcEventCount(eventMap.get(org.getOrgId()).getIcEventCount()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     dto.setResiEventCount(eventMap.get(org.getOrgId()).getResiEventCount()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     dto.setPcEventCount(eventMap.get(org.getOrgId()).getPcEventCount()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 if (projectMap.containsKey(org.getOrgId())) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     dto.setProjectCount(projectMap.get(org.getOrgId()).getProjectCount()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     dto.setIssueProjectCount(projectMap.get(org.getOrgId()).getIssueProjectCount()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     dto.setIcEventProjectCount(projectMap.get(org.getOrgId()).getIcEventProjectCount()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     dto.setAgencyProjectCount(projectMap.get(org.getOrgId()).getAgencyProjectCount()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             } else { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 //组织数据 需要java计算结果
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 int resiUserCount = (int) user.stream().filter(u -> u.getPids().contains(org.getOrgId())).count(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 dto.setResiUserCount(resiUserCount); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 int partyMemberCount = (int) party.stream().filter(p -> p.getPids().contains(org.getOrgId())).count(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 dto.setPartyMemberCount(partyMemberCount); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 int resiEventCount = (int) event.stream().filter(e -> e.getPids().contains(org.getOrgId()) && "0".equals(e.getSourceType())).count(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 int pcEventCount = (int) event.stream().filter(e -> e.getPids().contains(org.getOrgId()) && !"0".equals(e.getSourceType())).count(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 int icEventCount = resiEventCount + pcEventCount; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 dto.setIcEventCount(icEventCount); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 dto.setResiEventCount(resiEventCount); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 dto.setPcEventCount(pcEventCount); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 int issueProjectCount = (int) project.stream().filter(p -> p.getPids().contains(org.getOrgId()) && "issue".equals(p.getOrigin())).count(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 int icEventProjectCount = (int) project.stream().filter(p -> p.getPids().contains(org.getOrgId()) && "ic_event".equals(p.getOrigin())).count(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 int agencyProjectCount = (int) project.stream().filter(p -> p.getPids().contains(org.getOrgId()) && "agency".equals(p.getOrigin())).count(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 int projectCount = issueProjectCount + icEventProjectCount + agencyProjectCount; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 dto.setProjectCount(projectCount); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 dto.setIssueProjectCount(issueProjectCount); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 dto.setIcEventProjectCount(icEventProjectCount); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 dto.setAgencyProjectCount(agencyProjectCount); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             resultDTOList.add(dto); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             if (formDTO.isExport()) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 export.setResiUserCount(export.getResiUserCount() + dto.getResiUserCount()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 export.setPartyMemberCount(export.getPartyMemberCount() + dto.getPartyMemberCount()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 export.setIcEventCount(export.getIcEventCount() + dto.getIcEventCount()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 export.setResiEventCount(export.getResiEventCount() + dto.getResiEventCount()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 export.setPcEventCount(export.getPcEventCount() + dto.getPcEventCount()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 export.setProjectCount(export.getProjectCount() + dto.getProjectCount()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 export.setIssueProjectCount(export.getIssueProjectCount() + dto.getIssueProjectCount()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 export.setIcEventProjectCount(export.getIcEventProjectCount() + dto.getIcEventProjectCount()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 export.setAgencyProjectCount(export.getAgencyProjectCount() + dto.getAgencyProjectCount()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if (formDTO.isExport()) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             resultDTOList.add(export); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         return resultDTOList; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | } |  |  | } | 
			
		
	
	
		
		
			
				
					|  | 
 |