From 271e73422444e7898b81c1160cc8724634092702 Mon Sep 17 00:00:00 2001 From: jianjun Date: Sat, 19 Dec 2020 20:57:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=82=E4=B8=8E=E5=BA=A6=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/PublicPartExtractServiceImpl.java | 105 +++++++++--------- 1 file changed, 55 insertions(+), 50 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PublicPartExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PublicPartExtractServiceImpl.java index f26101c3dd..8e9dbd77be 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PublicPartExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PublicPartExtractServiceImpl.java @@ -193,66 +193,71 @@ public class PublicPartExtractServiceImpl implements PublicPartExtractService { List issueTotal = factIssueAgencyMonthlyService.getIssueIncCountAndTotalByMonthId(formDTO.getCustomerId(), formDTO.getMonthId()); List userCountList = factRegUserAgencyMonthlyService.selectAgencyUserCount(formDTO.getCustomerId(), formDTO.getMonthId()); - if (CollectionUtils.isEmpty(issueTotal)) { - log.error("抽取【公众参与-人均议题】,获取注册用户数为空"); - return; - } Map userCountMap = userCountList.stream().collect(Collectors.toMap(GridUserCountResultDTO::getOrgId, o -> o)); Set 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> partition = ListUtils.partition(new ArrayList<>(agencyIdSet), NumConstant.THIRTY); - partition.forEach(list -> { - //获取该月 表决的人数 - List voteCountList = factOriginIssueLogDailyService.getVoteCount(formDTO.getCustomerId(), formDTO.getMonthId(), ProjectConstant.AGENCY_ID); - Map orgMemberCount = new HashMap<>(); - if (!CollectionUtils.isEmpty(issueTotal)) { - //获取每个网格的应表决人数 - List 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> partition = ListUtils.partition(new ArrayList<>(agencyIdSet), NumConstant.THIRTY); + partition.forEach(list -> { + //获取该月 表决的人数 + List voteCountList = factOriginIssueLogDailyService.getVoteCount(formDTO.getCustomerId(), formDTO.getMonthId(), ProjectConstant.AGENCY_ID); + Map orgMemberCount = new HashMap<>(); + if (!CollectionUtils.isEmpty(issueTotal)) { + //获取每个网格的应表决人数 + List 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> voteMap = voteCountList.stream().collect(Collectors.groupingBy(IssueVoteUserCountResultDTO::getOrgId)); + for (Map.Entry> entry : voteMap.entrySet()) { + String orgId = entry.getKey(); + ScreenUserJoinEntity entity = insertMap.get(orgId); + List 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> voteMap = voteCountList.stream().collect(Collectors.groupingBy(IssueVoteUserCountResultDTO::getOrgId)); - for (Map.Entry> entry : voteMap.entrySet()) { - String orgId = entry.getKey(); - ScreenUserJoinEntity entity = insertMap.get(orgId); - List 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 result) { DimIdGenerator.DimIdBean dimIdBean = DimIdGenerator.getDimIdBean(DateUtils.stringToDate(formDTO.getMonthId(), DateUtils.DATE_PATTERN_YYYYMM)); ScreenUserJoinEntity entity = ConvertUtils.sourceToTarget(dimIdBean, ScreenUserJoinEntity.class);