|
|
@ -6,6 +6,7 @@ import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
|
import com.epmet.constant.OrgTypeConstant; |
|
|
|
import com.epmet.constant.ProjectConstant; |
|
|
|
import com.epmet.dto.extract.form.ExtractScreenFormDTO; |
|
|
|
import com.epmet.dto.extract.result.GridGroupUserCountResultDTO; |
|
|
|
import com.epmet.dto.extract.result.GridUserCountResultDTO; |
|
|
@ -13,25 +14,28 @@ import com.epmet.dto.extract.result.IssueVoteUserCountResultDTO; |
|
|
|
import com.epmet.entity.evaluationindex.screen.ScreenUserJoinEntity; |
|
|
|
import com.epmet.entity.stats.DimAgencyEntity; |
|
|
|
import com.epmet.entity.stats.DimGridEntity; |
|
|
|
import com.epmet.entity.stats.FactIssueAgencyMonthlyEntity; |
|
|
|
import com.epmet.entity.stats.FactIssueGridMonthlyEntity; |
|
|
|
import com.epmet.service.evaluationindex.extract.todata.FactOriginGroupMainDailyService; |
|
|
|
import com.epmet.service.evaluationindex.extract.todata.FactOriginIssueLogDailyService; |
|
|
|
import com.epmet.service.evaluationindex.extract.toscreen.PublicPartExtractService; |
|
|
|
import com.epmet.service.evaluationindex.screen.ScreenUserJoinService; |
|
|
|
import com.epmet.service.stats.DimAgencyService; |
|
|
|
import com.epmet.service.stats.DimGridService; |
|
|
|
import com.epmet.service.stats.FactIssueAgencyMonthlyService; |
|
|
|
import com.epmet.service.stats.FactIssueGridMonthlyService; |
|
|
|
import com.epmet.service.stats.user.FactRegUserAgencyMonthlyService; |
|
|
|
import com.epmet.service.stats.user.FactRegUserGridMonthlyService; |
|
|
|
import com.epmet.util.DimIdGenerator; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.ListUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
@ -53,9 +57,15 @@ public class PublicPartExtractServiceImpl implements PublicPartExtractService { |
|
|
|
@Autowired |
|
|
|
private FactRegUserGridMonthlyService factRegUserGridMonthlyService; |
|
|
|
@Autowired |
|
|
|
private FactIssueAgencyMonthlyService factIssueAgencyMonthlyService; |
|
|
|
@Autowired |
|
|
|
private FactRegUserAgencyMonthlyService factRegUserAgencyMonthlyService; |
|
|
|
@Autowired |
|
|
|
private FactOriginIssueLogDailyService factOriginIssueLogDailyService; |
|
|
|
@Autowired |
|
|
|
private FactOriginGroupMainDailyService factOriginGroupMainDailyService; |
|
|
|
@Autowired |
|
|
|
private ScreenUserJoinService screenUserJoinService; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
@ -64,9 +74,7 @@ public class PublicPartExtractServiceImpl implements PublicPartExtractService { |
|
|
|
* 总参与:统计周期内议题表决(虽然可以评价 但是只有表决的人可以评价 所以按表决人数算)的人数 |
|
|
|
* 百人人均议题:统计周期内总的议题数/(注册用户数/100) |
|
|
|
* 百人平均参与度:每个议题的实际参与数/应参与数 的平均值:(每个议题的实际参与数/应参与数)的和)/被表决的议题数 来源 获取issue_vote_statistical_daily中 monthId的数据 |
|
|
|
* <p> |
|
|
|
* <p> |
|
|
|
* <p> |
|
|
|
* |
|
|
|
* 不考虑市北:人均议题:统计周期内议题总数/发过议题的人数 参与度:各个行为(表决)的总数/发生行为的人数 |
|
|
|
* |
|
|
|
* @return java.lang.Boolean |
|
|
@ -94,7 +102,7 @@ public class PublicPartExtractServiceImpl implements PublicPartExtractService { |
|
|
|
Map<String, ScreenUserJoinEntity> insertMap = new HashMap<>(); |
|
|
|
orgList.forEach(org -> buildUserJoinEntity(formDTO, org, insertMap)); |
|
|
|
//获取议题月份增量
|
|
|
|
List<FactIssueGridMonthlyEntity> issueTotal = factIssueGridMonthlyService.getIssueCount(formDTO.getCustomerId(), formDTO.getMonthId()); |
|
|
|
List<FactIssueGridMonthlyEntity> issueTotal = factIssueGridMonthlyService.getIssueIncCountAndTotalByMonthId(formDTO.getCustomerId(), formDTO.getMonthId()); |
|
|
|
if (CollectionUtils.isEmpty(issueTotal)) { |
|
|
|
log.error("抽取【公众参与-人均议题】,获取议题增量为空"); |
|
|
|
return; |
|
|
@ -111,28 +119,28 @@ public class PublicPartExtractServiceImpl implements PublicPartExtractService { |
|
|
|
entity.setJoinTotal(issue.getIssueIncr()); |
|
|
|
GridUserCountResultDTO user = userCountMap.get(gridId); |
|
|
|
//百人人均议题:统计周期内总的议题数/(注册用户数/100)
|
|
|
|
BigDecimal avgIssueCount = new BigDecimal(issue.getIssueIncr()).divide(new BigDecimal(user.getUserCount()).divide(new BigDecimal(NumConstant.ONE_HUNDRED))); |
|
|
|
BigDecimal avgIssueCount = new BigDecimal(issue.getIssueIncr()).divide(new BigDecimal(user.getRegTotal()).divide(new BigDecimal(NumConstant.ONE_HUNDRED))); |
|
|
|
entity.setAvgIssue(avgIssueCount); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
//获取该月 表决的人数
|
|
|
|
List<IssueVoteUserCountResultDTO> voteCountList = factOriginIssueLogDailyService.getVoteCount(formDTO.getCustomerId(), formDTO.getMonthId()); |
|
|
|
List<IssueVoteUserCountResultDTO> voteCountList = factOriginIssueLogDailyService.getVoteCount(formDTO.getCustomerId(), formDTO.getMonthId(), ProjectConstant.GRID_ID); |
|
|
|
Map<String, Integer> gridMemberCount = new HashMap<>(); |
|
|
|
if (!CollectionUtils.isEmpty(issueTotal)) { |
|
|
|
//获取每个网格的应表决人数
|
|
|
|
List<GridGroupUserCountResultDTO> memberCountList = factOriginGroupMainDailyService.selectDistinctGroupMemberCount(formDTO.getCustomerId()); |
|
|
|
List<GridGroupUserCountResultDTO> memberCountList = factOriginGroupMainDailyService.selectDistinctGroupMemberCount(formDTO.getCustomerId(), ProjectConstant.AGENCY_ID); |
|
|
|
if (CollectionUtils.isEmpty(memberCountList)) { |
|
|
|
log.error("抽取【公众参与-人均议题】,获取应表决人数为空"); |
|
|
|
return; |
|
|
|
} |
|
|
|
gridMemberCount = memberCountList.stream().collect(Collectors.toMap(GridGroupUserCountResultDTO::getGridId, o -> o.getMemberCount())); |
|
|
|
gridMemberCount = memberCountList.stream().collect(Collectors.toMap(GridGroupUserCountResultDTO::getOrgId, o -> o.getMemberCount())); |
|
|
|
} |
|
|
|
|
|
|
|
//百人平均参与度:每个议题的实际参与数/应参与数 的平均值:(每个议题的实际参与数/应参与数)的和)/被表决的议题数
|
|
|
|
|
|
|
|
//遍历实际参与人数
|
|
|
|
Map<String, List<IssueVoteUserCountResultDTO>> voteMap = voteCountList.stream().collect(Collectors.groupingBy(IssueVoteUserCountResultDTO::getGridId)); |
|
|
|
Map<String, List<IssueVoteUserCountResultDTO>> voteMap = voteCountList.stream().collect(Collectors.groupingBy(IssueVoteUserCountResultDTO::getOrgId)); |
|
|
|
for (Map.Entry<String, List<IssueVoteUserCountResultDTO>> entry : voteMap.entrySet()) { |
|
|
|
String gridId = entry.getKey(); |
|
|
|
ScreenUserJoinEntity entity = insertMap.get(gridId); |
|
|
@ -148,6 +156,7 @@ public class PublicPartExtractServiceImpl implements PublicPartExtractService { |
|
|
|
} |
|
|
|
entity.setAvgJoin(bigDecimal.divide(votedByIssueCount).multiply(new BigDecimal(NumConstant.ONE_HUNDRED))); |
|
|
|
} |
|
|
|
screenUserJoinService.deleteAndInsertBatch(formDTO, new ArrayList<>(insertMap.values())); |
|
|
|
} |
|
|
|
|
|
|
|
private void extractAgencyUserJoin(ExtractScreenFormDTO formDTO) { |
|
|
@ -158,10 +167,63 @@ public class PublicPartExtractServiceImpl implements PublicPartExtractService { |
|
|
|
} |
|
|
|
//构建组织数据
|
|
|
|
Map<String, ScreenUserJoinEntity> insertMap = new HashMap<>(); |
|
|
|
orgList.forEach(org -> { |
|
|
|
buildUserJoinEntity(formDTO, org, insertMap); |
|
|
|
orgList.forEach(org -> buildUserJoinEntity(formDTO, org, insertMap)); |
|
|
|
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::getGridId, 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)
|
|
|
|
BigDecimal avgIssueCount = new BigDecimal(issue.getIssueIncr()).divide(new BigDecimal(user.getRegTotal()).divide(new BigDecimal(NumConstant.ONE_HUNDRED))); |
|
|
|
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.error("抽取【公众参与-人均议题】,获取应表决人数为空"); |
|
|
|
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; |
|
|
|
} |
|
|
|
bigDecimal = bigDecimal.add(new BigDecimal(vote.getVoteCount() / memberCount)); |
|
|
|
} |
|
|
|
entity.setAvgJoin(bigDecimal.divide(votedByIssueCount).multiply(new BigDecimal(NumConstant.ONE_HUNDRED))); |
|
|
|
} |
|
|
|
}); |
|
|
|
List<FactIssueGridMonthlyEntity> issueTotal = factIssueGridMonthlyService.getIssueCount(formDTO.getCustomerId(), formDTO.getMonthId()); |
|
|
|
screenUserJoinService.deleteAndInsertBatch(formDTO, new ArrayList<>(insertMap.values())); |
|
|
|
} |
|
|
|
|
|
|
|
private void buildUserJoinEntity(ExtractScreenFormDTO formDTO, Object org, Map<String, ScreenUserJoinEntity> result) { |
|
|
|