| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -193,66 +193,71 @@ public class PublicPartExtractServiceImpl implements PublicPartExtractService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<FactIssueAgencyMonthlyEntity> issueTotal = factIssueAgencyMonthlyService.getIssueIncCountAndTotalByMonthId(formDTO.getCustomerId(), formDTO.getMonthId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<GridUserCountResultDTO> userCountList = factRegUserAgencyMonthlyService.selectAgencyUserCount(formDTO.getCustomerId(), formDTO.getMonthId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (CollectionUtils.isEmpty(issueTotal)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            log.error("抽取【公众参与-人均议题】,获取注册用户数为空"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            return; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Map<String, GridUserCountResultDTO> userCountMap = userCountList.stream().collect(Collectors.toMap(GridUserCountResultDTO::getOrgId, o -> o)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Set<String> agencyIdSet = new HashSet<>(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        issueTotal.forEach(issue -> { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            String agencyId = issue.getAgencyId(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            agencyIdSet.add(agencyId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            ScreenUserJoinEntity entity = insertMap.get(agencyId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            entity.setJoinTotal(issue.getIssueIncr()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            GridUserCountResultDTO user = userCountMap.get(agencyId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //百人人均议题:统计周期内总的议题数/(注册用户数/100)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (!user.getRegTotal().equals(0)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                BigDecimal avgIssueCount = new BigDecimal(issue.getIssueIncr()).divide(new BigDecimal(user.getRegTotal()) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        .divide(new BigDecimal(NumConstant.ONE_HUNDRED)), 4, BigDecimal.ROUND_HALF_UP); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                entity.setAvgIssue(avgIssueCount); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<List<String>> partition = ListUtils.partition(new ArrayList<>(agencyIdSet), NumConstant.THIRTY); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        partition.forEach(list -> { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //获取该月 表决的人数
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            List<IssueVoteUserCountResultDTO> voteCountList = factOriginIssueLogDailyService.getVoteCount(formDTO.getCustomerId(), formDTO.getMonthId(), ProjectConstant.AGENCY_ID); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Map<String, Integer> orgMemberCount = new HashMap<>(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (!CollectionUtils.isEmpty(issueTotal)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                //获取每个网格的应表决人数
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                List<GridGroupUserCountResultDTO> memberCountList = factOriginGroupMainDailyService.selectDistinctGroupMemberCount(formDTO.getCustomerId(), ProjectConstant.AGENCY_ID); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if (CollectionUtils.isEmpty(memberCountList)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    log.warn("抽取【公众参与-人均议题】,获取应表决人数为空"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    return; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (!CollectionUtils.isEmpty(issueTotal)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            log.error("抽取【公众参与-人均议题】,获取注册用户数为空"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            issueTotal.forEach(issue -> { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                String agencyId = issue.getAgencyId(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                agencyIdSet.add(agencyId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                ScreenUserJoinEntity entity = insertMap.get(agencyId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                entity.setJoinTotal(issue.getIssueIncr()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                GridUserCountResultDTO user = userCountMap.get(agencyId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                //百人人均议题:统计周期内总的议题数/(注册用户数/100)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if (!user.getRegTotal().equals(0)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    BigDecimal avgIssueCount = new BigDecimal(issue.getIssueIncr()).divide(new BigDecimal(user.getRegTotal()) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                            .divide(new BigDecimal(NumConstant.ONE_HUNDRED)), 4, BigDecimal.ROUND_HALF_UP); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    entity.setAvgIssue(avgIssueCount); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                orgMemberCount = memberCountList.stream().collect(Collectors.toMap(GridGroupUserCountResultDTO::getOrgId, o -> o.getMemberCount())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            List<List<String>> partition = ListUtils.partition(new ArrayList<>(agencyIdSet), NumConstant.THIRTY); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            partition.forEach(list -> { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                //获取该月 表决的人数
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                List<IssueVoteUserCountResultDTO> voteCountList = factOriginIssueLogDailyService.getVoteCount(formDTO.getCustomerId(), formDTO.getMonthId(), ProjectConstant.AGENCY_ID); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                Map<String, Integer> orgMemberCount = new HashMap<>(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if (!CollectionUtils.isEmpty(issueTotal)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    //获取每个网格的应表决人数
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    List<GridGroupUserCountResultDTO> memberCountList = factOriginGroupMainDailyService.selectDistinctGroupMemberCount(formDTO.getCustomerId(), ProjectConstant.AGENCY_ID); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    if (CollectionUtils.isEmpty(memberCountList)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        log.warn("抽取【公众参与-人均议题】,获取应表决人数为空"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        return; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    orgMemberCount = memberCountList.stream().collect(Collectors.toMap(GridGroupUserCountResultDTO::getOrgId, o -> o.getMemberCount())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                //百人平均参与度:每个议题的实际参与数/应参与数 的平均值:(每个议题的实际参与数/应参与数)的和)/被表决的议题数
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //百人平均参与度:每个议题的实际参与数/应参与数 的平均值:(每个议题的实际参与数/应参与数)的和)/被表决的议题数
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                //遍历实际参与人数
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                Map<String, List<IssueVoteUserCountResultDTO>> voteMap = voteCountList.stream().collect(Collectors.groupingBy(IssueVoteUserCountResultDTO::getOrgId)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                for (Map.Entry<String, List<IssueVoteUserCountResultDTO>> entry : voteMap.entrySet()) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    String orgId = entry.getKey(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    ScreenUserJoinEntity entity = insertMap.get(orgId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    List<IssueVoteUserCountResultDTO> issueList = entry.getValue(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    BigDecimal bigDecimal = new BigDecimal(0); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    BigDecimal votedByIssueCount = new BigDecimal(issueList.get(0).getIssueCount()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    for (IssueVoteUserCountResultDTO vote : issueList) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        Integer memberCount = orgMemberCount.get(orgId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        if (memberCount == null) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                            //memberCount = 0;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                            continue; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //遍历实际参与人数
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Map<String, List<IssueVoteUserCountResultDTO>> voteMap = voteCountList.stream().collect(Collectors.groupingBy(IssueVoteUserCountResultDTO::getOrgId)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            for (Map.Entry<String, List<IssueVoteUserCountResultDTO>> entry : voteMap.entrySet()) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                String orgId = entry.getKey(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                ScreenUserJoinEntity entity = insertMap.get(orgId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                List<IssueVoteUserCountResultDTO> issueList = entry.getValue(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                BigDecimal bigDecimal = new BigDecimal(0); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                BigDecimal votedByIssueCount = new BigDecimal(issueList.get(0).getIssueCount()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                for (IssueVoteUserCountResultDTO vote : issueList) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    Integer memberCount = orgMemberCount.get(orgId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    if (memberCount == null) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        memberCount = 0; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        bigDecimal = bigDecimal.add(new BigDecimal(vote.getVoteCount() / (memberCount * 1.0))); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    if (votedByIssueCount.intValue() != 0) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        entity.setAvgJoin(bigDecimal.divide(votedByIssueCount, 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(NumConstant.ONE_HUNDRED))); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    bigDecimal = bigDecimal.add(new BigDecimal(vote.getVoteCount() / (memberCount * 1.0))); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if (votedByIssueCount.intValue() != 0) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    entity.setAvgJoin(bigDecimal.divide(votedByIssueCount, 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(NumConstant.ONE_HUNDRED))); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        screenUserJoinService.deleteAndInsertBatch(formDTO, new ArrayList<>(insertMap.values())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public static void main(String[] args) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        BigDecimal bigDecimal = new BigDecimal(0); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        bigDecimal = bigDecimal.add(new BigDecimal(0 / (1 * 1.0))); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private void buildUserJoinEntity(ExtractScreenFormDTO formDTO, Object org, Map<String, ScreenUserJoinEntity> result) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        DimIdGenerator.DimIdBean dimIdBean = DimIdGenerator.getDimIdBean(DateUtils.stringToDate(formDTO.getMonthId(), DateUtils.DATE_PATTERN_YYYYMM)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        ScreenUserJoinEntity entity = ConvertUtils.sourceToTarget(dimIdBean, ScreenUserJoinEntity.class); | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |