diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactIssueGridMonthlyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactIssueGridMonthlyDao.java index 502363d1b0..2a2fc36ed9 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactIssueGridMonthlyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactIssueGridMonthlyDao.java @@ -26,7 +26,7 @@ import org.apache.ibatis.annotations.Param; import java.util.List; /** - * 网格议题数量(按月) + * 网格议题数量(按月) * * @author generator generator@elink-cn.com * @since v1.0.0 2020-06-17 @@ -35,21 +35,25 @@ import java.util.List; public interface FactIssueGridMonthlyDao extends BaseDao { /** * 统计网格议题各个指标月度增量 - * @author zhaoqifeng - * @date 2020/6/19 10:41 + * * @param customerId * @param monthId * @return java.util.List + * @author zhaoqifeng + * @date 2020/6/19 10:41 */ List selectGridMonthlyInc(@Param("customerId") String customerId, @Param("monthId") String monthId); /** * 删除 - * @author zhaoqifeng - * @date 2020/6/23 14:02 + * * @param customerId * @param monthId * @return void + * @author zhaoqifeng + * @date 2020/6/23 14:02 */ void deleteByCustomerId(@Param("customerId") String customerId, @Param("monthId") String monthId); + + List getIssueCount(@Param("customerId") String customerId, @Param("monthId") String monthId); } \ No newline at end of file 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 dd409600a8..3fd70b4e5a 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 @@ -1,11 +1,13 @@ package com.epmet.service.evaluationindex.extract.toscreen.impl; import com.alibaba.fastjson.JSON; +import com.epmet.commons.tools.constant.NumConstant; 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.dto.extract.form.ExtractScreenFormDTO; +import com.epmet.dto.extract.result.GridUserCountResultDTO; import com.epmet.entity.evaluationindex.screen.ScreenUserJoinEntity; import com.epmet.entity.stats.DimAgencyEntity; import com.epmet.entity.stats.DimGridEntity; @@ -14,6 +16,7 @@ import com.epmet.service.evaluationindex.extract.toscreen.PublicPartExtractServi import com.epmet.service.stats.DimAgencyService; import com.epmet.service.stats.DimGridService; import com.epmet.service.stats.FactIssueGridMonthlyService; +import com.epmet.service.stats.user.FactRegUserGridMonthlyService; import com.epmet.util.DimIdGenerator; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -25,6 +28,7 @@ import java.math.BigDecimal; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * desc:公众参与抽取到大屏的接口实现类 @@ -42,13 +46,15 @@ public class PublicPartExtractServiceImpl implements PublicPartExtractService { private DimGridService dimGridService; @Autowired private FactIssueGridMonthlyService factIssueGridMonthlyService; + @Autowired + private FactRegUserGridMonthlyService factRegUserGridMonthlyService; /** * desc: 【月】抽取公众参与 人均议题 总次数和平均参与度 * target:screen_user_join * 总参与:统计周期内议题表决的人数 - * 百人人均议题:统计周期内总的议题数/(用户数/100) + * 百人人均议题:统计周期内总的议题数/(注册用户数/100) * 百人平均参与度:每个议题的实际参与数/应参与数 的平均值:(每个议题的实际参与数/应参与数)的和)/被表决的议题数 * 不考虑市北:人均议题:统计周期内议题总数/发过议题的人数 参与度:各个行为(表决)的总数/发生行为的人数 * @@ -76,6 +82,29 @@ public class PublicPartExtractServiceImpl implements PublicPartExtractService { //构建组织数据 Map insertMap = new HashMap<>(); orgList.forEach(org -> buildUserJoinEntity(formDTO, org, insertMap)); + //获取议题月份增量 + List issueTotal = factIssueGridMonthlyService.getIssueCount(formDTO.getCustomerId(), formDTO.getMonthId()); + if (CollectionUtils.isEmpty(issueTotal)) { + log.error("抽取【公众参与-人均议题】,获取议题增量为空"); + return; + } + List userCountList = factRegUserGridMonthlyService.selectGridUserCount(formDTO.getCustomerId(), formDTO.getMonthId()); + if (CollectionUtils.isEmpty(issueTotal)) { + log.error("抽取【公众参与-人均议题】,获取注册用户数为空"); + return; + } + Map userCountMap = userCountList.stream().collect(Collectors.toMap(GridUserCountResultDTO::getGridId, o -> o)); + issueTotal.forEach(issue -> { + String gridId = issue.getGridId(); + ScreenUserJoinEntity entity = insertMap.get(gridId); + 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))); + // 需要修改字段类型 + //entity.setAvgIssue(avgIssueCount); + }); + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactIssueGridMonthlyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactIssueGridMonthlyServiceImpl.java index cabdb020ca..c002e0e3ca 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactIssueGridMonthlyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactIssueGridMonthlyServiceImpl.java @@ -75,7 +75,7 @@ public class FactIssueGridMonthlyServiceImpl extends BaseServiceImpl getIssueCount(String customerId, String monthId) { - return null; + return baseDao.getIssueCount(customerId, monthId); } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactIssueGridMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactIssueGridMonthlyDao.xml index 35ca051fa1..e02c95dcfb 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactIssueGridMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactIssueGridMonthlyDao.xml @@ -67,7 +67,7 @@ SUM(IFNULL(CLOSED_CASE_UNRESOLVED_INCR, 0)) AS "closedCaseUnresolvedIncr" FROM dim_grid dg - LEFT JOIN fact_issue_grid_daily figd ON figd.GRID_ID = dg.ID AND figd.DEL_FLAG = 0 + LEFT JOIN fact_issue_grid_daily figd ON figd.GRID_ID = dg.ID AND figd.DEL_FLAG = '0' AND figd.MONTH_ID = #{monthId} WHERE dg.DEL_FLAG = 0 @@ -75,4 +75,14 @@ GROUP BY dg.AGENCY_ID, dg.ID + + \ No newline at end of file