diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginGroupMainDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginGroupMainDailyDao.java index ff1c16d1ec..f492bb1462 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginGroupMainDailyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginGroupMainDailyDao.java @@ -43,4 +43,22 @@ public interface FactOriginGroupMainDailyDao extends BaseDao selectPartyCreateGroupCount(@Param("customerId") String customerId,@Param("monthId") String monthId); + /** + * @param customerId + * @param groupOwnerId + * @return java.util.List + * @author yinzuomei + * @description 查询当前用户建的所有群id + * @Date 2020/9/20 21:22 + **/ + List selectGroupIds(@Param("customerId") String customerId, @Param("groupOwnerId") String groupOwnerId); + + /** + * @return java.util.List + * @param groupIdList + * @author yinzuomei + * @description 查询组成员数(去重) + * @Date 2020/9/20 21:29 + **/ + List selectGroupMemberList(@Param("list") List groupIdList); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginIssueLogDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginIssueLogDailyDao.java index a98372928e..b7d86e4353 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginIssueLogDailyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginIssueLogDailyDao.java @@ -51,4 +51,14 @@ public interface FactOriginIssueLogDailyDao extends BaseDao> selectShiftIssueCount(@Param("customerId") String customerId,@Param("monthId") String monthId); - /** - * @return java.util.List> - * @param customerId - * @param monthId - * @author yinzuomei - * @description 党员提出的议题转项目数 - * @Date 2020/9/18 14:11 - **/ - List> selectShiftProjectCount(@Param("customerId") String customerId,@Param("monthId") String monthId); - /** * @Description 查询网格 党员/群众 人均提出的议题转项目数 * @param customerId @@ -102,4 +92,13 @@ public interface FactOriginIssueMainDailyDao extends BaseDao selectShiftProjectCountPlus(@Param("customerId") String customerId,@Param("monthId") String monthId,@Param("isParty") Integer isParty); + + /** + * @return java.lang.Integer + * @param topicIdList + * @author yinzuomei + * @description 查询本周期和上周期内,自建群内话题转为议题的数量的总和 + * @Date 2020/9/20 22:54 + **/ + Integer selectIssueTotalTwoMonth(@Param("list") List topicIdList); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginProjectMainDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginProjectMainDailyDao.java index a8fef6685c..db30525d58 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginProjectMainDailyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginProjectMainDailyDao.java @@ -26,6 +26,7 @@ import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; +import java.util.Map; /** * 项目主表_日统计 @@ -81,4 +82,25 @@ public interface FactOriginProjectMainDailyDao extends BaseDao> + * @param customerId + * @param monthId + * @author yinzuomei + * @description 党员提出的议题转项目数 + * @Date 2020/9/18 14:11 + **/ + List> selectShiftProjectCount(@Param("customerId") String customerId, @Param("monthId") String monthId); + + /** + * @return java.lang.Integer + * @param customerId + * @param monthId + * @param topicIdList + * @author yinzuomei + * @description 9、自建群活跃度——议题转项目率 用 + * @Date 2020/9/20 22:27 + **/ + Integer selectCountByPartyUser(@Param("customerId") String customerId, @Param("monthId")String monthId, @Param("list")List topicIdList); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginTopicLogDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginTopicLogDailyDao.java index 2694c66397..ab43a21b2e 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginTopicLogDailyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginTopicLogDailyDao.java @@ -73,4 +73,24 @@ public interface FactOriginTopicLogDailyDao extends BaseDao> selectGroupTopicCount(@Param("customerId") String customerId, @Param("monthId") String monthId); + + /** + * @return java.lang.Integer + * @param userId + * @param customerId + * @param monthId + * @author yinzuomei + * @description 查询当前用户在本月内评论的次数 + * @Date 2020/9/20 21:46 + **/ + Integer selectUserCommentCount(@Param("userId") String userId, @Param("customerId") String customerId, @Param("monthId") String monthId); + + /** + * @return java.util.List + * @param groupIdList + * @author yinzuomei + * @description 组内的所有话题id + * @Date 2020/9/20 22:18 + **/ + List selectTopicIds(@Param("list") List groupIdList); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/FactOriginProjectMainDailyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/FactOriginProjectMainDailyService.java index 338418717b..a21fb1c1a2 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/FactOriginProjectMainDailyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/FactOriginProjectMainDailyService.java @@ -140,4 +140,25 @@ public interface FactOriginProjectMainDailyService extends BaseService> + * @param customerId + * @param monthId + * @author yinzuomei + * @description 党员提出的议题转项目数 + * @Date 2020/9/18 14:11 + **/ + List> selectShiftProjectCount(String customerId, String monthId); + + /** + * @return java.lang.Integer + * @param customerId + * @param monthId + * @param topicIdList + * @author yinzuomei + * @description 9、自建群活跃度——议题转项目率 用 + * @Date 2020/9/20 22:25 + **/ + Integer selectCountByPartyUser(String customerId, String monthId, List topicIdList); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/FactOriginTopicLogDailyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/FactOriginTopicLogDailyService.java index 18971cf15a..f5eb32bd09 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/FactOriginTopicLogDailyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/FactOriginTopicLogDailyService.java @@ -51,4 +51,24 @@ public interface FactOriginTopicLogDailyService extends BaseService> selectGroupTopicCount(String customerId, String monthId); + + /** + * @return int + * @param userId + * @param customerId + * @param monthId + * @author yinzuomei + * @description + * @Date 2020/9/20 21:43 + **/ + Integer selectUserCommentCount(String userId,String customerId, String monthId ); + + /** + * @return java.util.List + * @param groupIdList + * @author yinzuomei + * @description 组内的所有话题id + * @Date 2020/9/20 22:17 + **/ + List selectTopicIds(List groupIdList); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/IssueExtractService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/IssueExtractService.java index 55cf8cd348..0b7ec04c48 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/IssueExtractService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/IssueExtractService.java @@ -61,16 +61,6 @@ public interface IssueExtractService { **/ List> selectShiftIssueCount(String customerId, String monthId); - /** - * @return java.util.List> - * @param customerId - * @param monthId - * @author yinzuomei - * @description 党员提出的议题转项目数 - * @Date 2020/9/18 14:11 - **/ - List> selectShiftProjectCount(String customerId, String monthId); - /** * @Description 查询网格 党员/群众 人均提出的议题转项目数 * @param customerId @@ -80,4 +70,24 @@ public interface IssueExtractService { * @date 2020/9/19 2:26 下午 */ List selectShiftProjectCountPlus(String customerId, String monthId,Integer isParty); + + /** + * @return java.lang.Integer + * @param userId 用户id + * @param customerId + * @param monthId + * @author yinzuomei + * @description 查询用户在这个月内表决的总次数 + * @Date 2020/9/20 21:50 + **/ + Integer selectCountUserVote(String userId, String customerId, String monthId); + + /** + * @return java.lang.Integer + * @param topicIdList + * @author yinzuomei + * @description + * @Date 2020/9/20 22:50 + **/ + Integer selectIssueTotalTwoMonth(List topicIdList); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/CalCpcIndexServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/CalCpcIndexServiceImpl.java index 8559025963..d7cf968388 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/CalCpcIndexServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/CalCpcIndexServiceImpl.java @@ -4,18 +4,20 @@ import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.constant.DataSourceConstant; import com.epmet.constant.IndexCalConstant; +import com.epmet.dao.evaluationindex.extract.FactOriginGroupMainDailyDao; import com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthlyDao; import com.epmet.entity.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthlyEntity; -import com.epmet.service.evaluationindex.extract.CalCpcIndexService; -import com.epmet.service.evaluationindex.extract.FactOriginTopicLogDailyService; -import com.epmet.service.evaluationindex.extract.FactOriginTopicMainDailyService; -import com.epmet.service.evaluationindex.extract.IssueExtractService; +import com.epmet.service.evaluationindex.extract.*; import com.epmet.service.stats.DimCustomerPartymemberService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.ListUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.math.BigDecimal; +import java.text.NumberFormat; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -39,6 +41,10 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { private FactOriginTopicLogDailyService factOriginTopicLogDailyService; @Autowired private IssueExtractService issueExtractService; + @Autowired + private FactOriginProjectMainDailyService factOriginProjectMainDailyService; + @Autowired + private FactOriginGroupMainDailyDao factOriginGroupMainDailyDao; /** * @param customerId 客户id @@ -52,20 +58,35 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { public void calCpcPartyAbility(String customerId, String monthId) { //1、构造初始值 List indexPartyAblityCpcList = dimCustomerPartymemberService.selectPartyMemberList(customerId); + if (CollectionUtils.isEmpty(indexPartyAblityCpcList)) { + log.info("dim_customer_partymember do not any records"); + return; + } //2、删除之前统计过的 deleteFactIndexPartyAblityCpcMonthly(customerId, monthId); + + //1、党员提出话题数 Map createTopicCountMap = calCreateTopicCount(customerId, monthId); //2、党员参与话题数(支持、反对、评论、浏览)---目前只统计 党员评论话题次数之和 - Map joinTopicCountMap=calJoinTopicCount(customerId,monthId); + Map joinTopicCountMap = calJoinTopicCount(customerId, monthId); //3、党员提出的话题转议题数 - Map shiftIssueCountMap=calShiftIssueCount(customerId,monthId); + Map shiftIssueCountMap = calShiftIssueCount(customerId, monthId); //4、党员提出的议题转项目数 - Map shiftProjectCountMap=calShiftProjectCount(customerId,monthId); - //6、党员自建群群众人数 - Map groupUserCountMap=calgroupUserCount(customerId,monthId); - //8、党员自建群活跃度——话题数 - Map groupTopicCountMap=calGroupTopicCountMap(customerId,monthId); + Map shiftProjectCountMap = calShiftProjectCount(customerId, monthId); + //5、参加“三会一课”次数 默认0 + + //可以先查询出每个党员的 自建群 + Map> userCreatedGroups = queryUserCreatedGroups(customerId, indexPartyAblityCpcList); + //6、党员自建群群众人数 (todo 和monthId无关??) + Map groupUserCountMap = calgroupUserCount(customerId, monthId, indexPartyAblityCpcList, userCreatedGroups); + //7、党员自建群活跃群众人数 + Map groupActiveUserCountMap = calGroupActiveUserCount(customerId, monthId, indexPartyAblityCpcList, userCreatedGroups); + //8、党员自建群活跃度——话题数 (todo 校验sql正确性) + Map groupTopicCountMap = calGroupTopicCount(customerId, monthId); + //9、自建群活跃度——议题转项目率 + Map topicToIssueRatioMap = caltopicToIssueRatio(customerId, monthId, indexPartyAblityCpcList, userCreatedGroups); + //3、计算实际值,更新 for (FactIndexPartyAblityCpcMonthlyEntity indexPartyAblityCpcEntity : indexPartyAblityCpcList) { //1、党员提出话题数 @@ -73,32 +94,36 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { indexPartyAblityCpcEntity.setCreateTopicCount(createTopicCountMap.get(indexPartyAblityCpcEntity.getUserId())); } //2、党员参与话题数(支持、反对、评论、浏览)---目前只统计 党员评论话题次数之和 - if(joinTopicCountMap.containsKey(indexPartyAblityCpcEntity.getUserId())){ + if (joinTopicCountMap.containsKey(indexPartyAblityCpcEntity.getUserId())) { indexPartyAblityCpcEntity.setJoinTopicCount(joinTopicCountMap.get(indexPartyAblityCpcEntity.getUserId())); } //3、党员提出的话题转议题数 - if(shiftIssueCountMap.containsKey(indexPartyAblityCpcEntity.getUserId())){ + if (shiftIssueCountMap.containsKey(indexPartyAblityCpcEntity.getUserId())) { indexPartyAblityCpcEntity.setShiftIssueCount(shiftIssueCountMap.get(indexPartyAblityCpcEntity.getUserId())); } //4、党员提出的议题转项目数 - if(shiftProjectCountMap.containsKey(indexPartyAblityCpcEntity.getUserId())){ + if (shiftProjectCountMap.containsKey(indexPartyAblityCpcEntity.getUserId())) { indexPartyAblityCpcEntity.setShiftProjectCount(shiftProjectCountMap.get(indexPartyAblityCpcEntity.getUserId())); } //5、参加“三会一课”次数 目前没有此业务,默认0 - //6、党员自建群群众人数 TODO - if(groupUserCountMap.containsKey(indexPartyAblityCpcEntity.getUserId())){ + //6、党员自建群群众人数 + if (groupUserCountMap.containsKey(indexPartyAblityCpcEntity.getUserId())) { indexPartyAblityCpcEntity.setGroupUserCount(groupUserCountMap.get(indexPartyAblityCpcEntity.getUserId())); } - //7、党员自建群活跃群众人数 TODO + //7、党员自建群活跃群众人数 + if (groupActiveUserCountMap.containsKey(indexPartyAblityCpcEntity.getUserId())) { + indexPartyAblityCpcEntity.setGroupActiveUserCount(groupActiveUserCountMap.get(indexPartyAblityCpcEntity.getUserId())); + } //8、党员自建群活跃度——话题数 - if(groupTopicCountMap.containsKey(indexPartyAblityCpcEntity.getUserId())){ + if (groupTopicCountMap.containsKey(indexPartyAblityCpcEntity.getUserId())) { indexPartyAblityCpcEntity.setGroupTopicCount(groupTopicCountMap.get(indexPartyAblityCpcEntity.getUserId())); } - //9、自建群活跃度——议题转项目率 TODO - + //9、自建群活跃度——议题转项目率 + if (topicToIssueRatioMap.containsKey(indexPartyAblityCpcEntity.getUserId())) { + indexPartyAblityCpcEntity.setTopicToIssueRatio(topicToIssueRatioMap.get(indexPartyAblityCpcEntity.getUserId())); + } } - //4、分批插入 - //批量插入 + //4、分批插入批量插入 List> partition = ListUtils.partition(indexPartyAblityCpcList, IndexCalConstant.INSERT_SIZE); partition.forEach(list -> { this.FactIndexPartyAblityCpcMonthlyEntity(list); @@ -106,6 +131,30 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { } + + /** + * @param customerId + * @param partyMemberList + * @return java.util.Map> + * @author yinzuomei + * @description 查询每个党员的自建群 + * @Date 2020/9/20 22:07 + **/ + private Map> queryUserCreatedGroups(String customerId, List partyMemberList) { + Map> map = new HashMap<>(); + for (FactIndexPartyAblityCpcMonthlyEntity partyMember : partyMemberList) { + //查询当前党员建了多少个组 + List groupIdList = factOriginGroupMainDailyDao.selectGroupIds(customerId, partyMember.getUserId()); + if (CollectionUtils.isEmpty(groupIdList)) { + map.put(partyMember.getUserId(), new ArrayList<>()); + continue; + } else { + map.put(partyMember.getUserId(), groupIdList); + } + } + return map; + } + /** * @param customerId * @param monthId @@ -126,9 +175,9 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { } /** - * @return java.util.Map * @param customerId * @param monthId + * @return java.util.Map * @author yinzuomei * @description 2、查询客户下,这个月内,每个党员评论话题的次数 * @Date 2020/9/18 13:33 @@ -146,9 +195,9 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { /** - * @return java.util.Map * @param customerId * @param monthId + * @return java.util.Map * @author yinzuomei * @description 3、党员提出的话题转议题数 * @Date 2020/9/18 13:53 @@ -165,15 +214,16 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { } /** - * @return java.util.Map * @param customerId * @param monthId + * @return java.util.Map * @author yinzuomei * @description 4、党员提出的议题转项目数 * @Date 2020/9/18 14:10 **/ private Map calShiftProjectCount(String customerId, String monthId) { - List> mapList = issueExtractService.selectShiftProjectCount(customerId, monthId); + //查询fact_origin_project_main_daily 表 中议题的议题的状态为 shift_ + List> mapList = factOriginProjectMainDailyService.selectShiftProjectCount(customerId, monthId); Map resultMap = new HashMap<>(); for (Map map : mapList) { for (Map.Entry m : map.entrySet()) { @@ -184,18 +234,99 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { } /** - * @return java.util.Map * @param customerId * @param monthId + * @return java.util.Map * @author yinzuomei * @description 6、党员自建群群众人数 * @Date 2020/9/18 15:38 **/ - private Map calgroupUserCount(String customerId, String monthId) { - // TODO - return null; + private Map calgroupUserCount(String customerId, String monthId, + List partyMemberList, + Map> userCreatedGroups) { + /*含义:评价周期内,党员自建群中群众成员数。 + 数据来源:用户社群关系表。 + 计算方法:对党员i的所有j个自建群,从用户社群关系表中统计属于每个自建群的群众用户总人数,并对j个群众用户总数进行不重复累加。 + 对评价结果的影响:正向。*/ + Map map = new HashMap<>(); + for (FactIndexPartyAblityCpcMonthlyEntity partyMember : partyMemberList) { + //查询当前党员建了多少个组 + List groupIdList = userCreatedGroups.get(partyMember.getUserId()); + if (CollectionUtils.isEmpty(groupIdList)) { + map.put(partyMember.getUserId(), NumConstant.ZERO); + continue; + } + //去重组里面的成员 + List memberIdList = factOriginGroupMainDailyDao.selectGroupMemberList(groupIdList); + if (CollectionUtils.isEmpty(memberIdList)) { + map.put(partyMember.getUserId(), NumConstant.ZERO); + continue; + } else { + map.put(partyMember.getUserId(), memberIdList.size()); + } + } + return map; + } + + /** + * @param customerId + * @param monthId + * @param partyMemberList + * @return java.util.Map + * @author yinzuomei + * @description 7、党员自建群活跃群众人数 + * @Date 2020/9/20 21:36 + **/ + private Map calGroupActiveUserCount(String customerId, String monthId, + List partyMemberList, + Map> userCreatedGroups) { + /*含义:评价周期内,党员自建群中活跃群众成员数。所谓活跃群成员,即评价周期内参与话题、事件评论、点赞、点踩总次数大于给定阈值的群众用户。 + 数据来源:话题用户阅读表、话题评论用户表态表、话题评论表、事件点赞点踩表、事件评论点赞点踩表、事件评论表、用户信息表。 + 计算方法: + a)判断群中的群众成员是否活跃 + for each 群众成员 i + 统计i的话题阅读次数、话题评论次数、话题评论表态次数、事件点赞点踩次数、事件评论点赞点踩次数、事件评论总次数。 + If 总次数>阈值 + 成员i为活跃群众成员 + b)不重复累加活跃群众成员数 + 对评价结果的影响:正向。*/ + //结合目前产品,数据来源:话题评论、议题表决 + Map map = new HashMap<>(); + for (FactIndexPartyAblityCpcMonthlyEntity partyMember : partyMemberList) { + int groupActiveUserCount = 0; + //1、查询当前党员建了多少个组 + List groupIdList = userCreatedGroups.get(partyMember.getUserId()); + if (CollectionUtils.isEmpty(groupIdList)) { + map.put(partyMember.getUserId(), NumConstant.ZERO); + continue; + } + //2、去重组里面的成员 + List memberIdList = factOriginGroupMainDailyDao.selectGroupMemberList(groupIdList); + if (CollectionUtils.isEmpty(memberIdList)) { + map.put(partyMember.getUserId(), NumConstant.ZERO); + continue; + } + //3、判断每个成员是否 “活跃” + for (String memberId : memberIdList) { + //1、判断成员在本月内是否评论过 + Integer topicCommentCount = factOriginTopicLogDailyService.selectUserCommentCount(memberId, customerId, monthId); + if (topicCommentCount > 0) { + groupActiveUserCount++; + continue; + } + //2、判断成员在本月内是否表决过(支持or反对)议题 + Integer voteCount = issueExtractService.selectCountUserVote(memberId, customerId, monthId); + if (voteCount > 0) { + groupActiveUserCount++; + } + } + //赋值每个党员的 -- 党员自建群活跃群众人数 + map.put(partyMember.getUserId(), groupActiveUserCount); + } + return map; } + /** * @param customerId * @param monthId @@ -204,7 +335,11 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { * @description 8、党员自建群活跃度——话题数 * @Date 2020/9/18 14:31 **/ - private Map calGroupTopicCountMap(String customerId, String monthId) { + private Map calGroupTopicCount(String customerId, String monthId) { + /*含义:评价周期内,党员自建群中话题发布数。 + 数据来源:话题表。 + 计算方法:从话题表中统计党员自建群i的话题总数;对所有自建群话题数累加。 + 对评价结果的影响:正向。*/ List> mapList = factOriginTopicLogDailyService.selectGroupTopicCount(customerId, monthId); Map resultMap = new HashMap<>(); for (Map map : mapList) { @@ -215,6 +350,54 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { return resultMap; } + /** + * @param userCreatedGroups 党员自建群 + * @return java.util.Map + * @author yinzuomei + * @description 9、自建群活跃度——议题转项目率 + * @Date 2020/9/20 22:11 + **/ + private Map caltopicToIssueRatio(String customerId, + String monthId, + List partyMemberList, + Map> userCreatedGroups) { + Map map = new HashMap<>(); + for (FactIndexPartyAblityCpcMonthlyEntity partyMember : partyMemberList) { + //如果党员自建群为空,直接赋值0 + if (CollectionUtils.isEmpty(userCreatedGroups.get(partyMember.getUserId()))) { + map.put(partyMember.getUserId(), BigDecimal.ZERO); + continue; + } + //自建群出来的话题 + List groupIdList = userCreatedGroups.get(partyMember.getUserId()); + List topicIdList = factOriginTopicLogDailyService.selectTopicIds(groupIdList); + if (CollectionUtils.isEmpty(topicIdList)) { + map.put(partyMember.getUserId(), BigDecimal.ZERO); + continue; + } + //分子 + //本月内新增的项目(and 源于自建群中的话题) + Integer projectTotal = factOriginProjectMainDailyService.selectCountByPartyUser(customerId, monthId, topicIdList); + if (null == projectTotal || projectTotal == NumConstant.ZERO) { + map.put(partyMember.getUserId(), BigDecimal.ZERO); + continue; + } + //分母 + //本评价周期+上一个评价周期内自建群中的议题数 + Integer issueTotal = issueExtractService.selectIssueTotalTwoMonth(topicIdList); + if (null == issueTotal || issueTotal == NumConstant.ZERO) { + map.put(partyMember.getUserId(), BigDecimal.ZERO); + continue; + } + NumberFormat numberFormat = NumberFormat.getInstance(); + numberFormat.setMaximumFractionDigits(6); + String topicToIssueRatioStr = numberFormat.format((float) projectTotal / issueTotal); + BigDecimal topicToIssueRatio = new BigDecimal(topicToIssueRatioStr); + map.put(partyMember.getUserId(), topicToIssueRatio); + } + return map; + } + /** * @param customerId * @param monthId diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/FactOriginProjectMainDailyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/FactOriginProjectMainDailyServiceImpl.java index 1358c2fdc4..a32bbe22f0 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/FactOriginProjectMainDailyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/FactOriginProjectMainDailyServiceImpl.java @@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.dao.evaluationindex.extract.FactOriginProjectMainDailyDao; @@ -32,7 +33,9 @@ import com.epmet.service.evaluationindex.extract.FactOriginProjectMainDailyServi import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -131,4 +134,38 @@ public class FactOriginProjectMainDailyServiceImpl extends BaseServiceImpl> + * @author yinzuomei + * @description 党员提出的议题转项目数 + * @Date 2020/9/18 14:11 + **/ + @Override + public List> selectShiftProjectCount(String customerId, String monthId) { + //查询项目主表fact_origin_project_main_daily,这个月内新增的项目,按话题发布人分组 + /*含义:评价周期内,党员提出的议题转数目数。 + 数据来源:项目表。 + 计算方法:从项目表中按照用户ID和党员标识统计。 + 对评价结果的影响:正向。*/ + return baseDao.selectShiftProjectCount(customerId,monthId); + } + + /** + * @param customerId + * @param monthId + * @param topicIdList + * @return java.lang.Integer + * @author yinzuomei + * @description 9、自建群活跃度——议题转项目率 用 + * @Date 2020/9/20 22:25 + **/ + @Override + public Integer selectCountByPartyUser(String customerId, String monthId, List topicIdList) { + if(CollectionUtils.isEmpty(topicIdList)){ + return NumConstant.ZERO; + } + return baseDao.selectCountByPartyUser(customerId,monthId,topicIdList); + } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/FactOriginTopicLogDailyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/FactOriginTopicLogDailyServiceImpl.java index 07a220fa44..d1f1ed681a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/FactOriginTopicLogDailyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/FactOriginTopicLogDailyServiceImpl.java @@ -24,7 +24,9 @@ import com.epmet.dao.evaluationindex.extract.FactOriginTopicLogDailyDao; import com.epmet.entity.evaluationindex.extract.FactOriginTopicLogDailyEntity; import com.epmet.service.evaluationindex.extract.FactOriginTopicLogDailyService; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -49,6 +51,7 @@ public class FactOriginTopicLogDailyServiceImpl extends BaseServiceImpl> selectJoinTopicCount(String customerId, String monthId) { + //这个月内新增的话题评论,按人分组,不限制评论时的身份,以当前用户最新身份为准 return baseDao.selectJoinTopicCount(customerId,monthId); } @@ -64,4 +67,33 @@ public class FactOriginTopicLogDailyServiceImpl extends BaseServiceImpl> selectGroupTopicCount(String customerId, String monthId) { return baseDao.selectGroupTopicCount(customerId,monthId); } + + /** + * @return java.lang.Integer + * @param userId + * @param customerId + * @param monthId + * @author yinzuomei + * @description 查询当前用户在本月内评论的次数 + * @Date 2020/9/20 21:45 + **/ + @Override + public Integer selectUserCommentCount(String userId,String customerId, String monthId) { + return baseDao.selectUserCommentCount(userId,customerId,monthId); + } + + /** + * @param groupIdList + * @return java.util.List + * @author yinzuomei + * @description 组内的所有话题id + * @Date 2020/9/20 22:17 + **/ + @Override + public List selectTopicIds(List groupIdList) { + if(CollectionUtils.isEmpty(groupIdList)){ + return new ArrayList<>(); + } + return baseDao.selectTopicIds(groupIdList); + } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/FactOriginTopicMainDailyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/FactOriginTopicMainDailyServiceImpl.java index a61eab5a48..b82592861a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/FactOriginTopicMainDailyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/FactOriginTopicMainDailyServiceImpl.java @@ -238,6 +238,7 @@ public class FactOriginTopicMainDailyServiceImpl extends BaseServiceImpl> selectPartyCreateTopicCount(String customerId, String monthId) { + //这个月内新增的话题,按人分组,不限制发话题人的身份,也就是说以用户最新的身份为准 return baseDao.selectPartyCreateTopicCount(customerId,monthId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/IssueExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/IssueExtractServiceImpl.java index 46ae7c8557..78bb8a187c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/IssueExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/IssueExtractServiceImpl.java @@ -278,22 +278,14 @@ public class IssueExtractServiceImpl implements IssueExtractService { @DataSource(DataSourceConstant.STATS) @Override public List> selectShiftIssueCount(String customerId, String monthId) { + //查询fact_origin_issue_main_daily 表,转议题的时间在评价周期内的,按发布话题的人分组 + /*含义:评价周期内,党员提出的话题转为议题的数目。 + 数据来源:议题表。 + 计算方法:从议题表中按照用户ID和党员标识统计。 + 对评价结果的影响:正向。*/ return issueMainDailyDao.selectShiftIssueCount(customerId,monthId); } - /** - * @param customerId - * @param monthId - * @return java.util.List> - * @author yinzuomei - * @description 党员提出的议题转项目数 - * @Date 2020/9/18 14:11 - **/ - @Override - public List> selectShiftProjectCount(String customerId, String monthId) { - return issueMainDailyDao.selectShiftProjectCount(customerId,monthId); - } - /** * @Description 查询网格 党员/群众 人均提出的议题转项目数 * @param customerId @@ -306,4 +298,30 @@ public class IssueExtractServiceImpl implements IssueExtractService { public List selectShiftProjectCountPlus(String customerId, String monthId, Integer isParty) { return issueMainDailyDao.selectShiftProjectCountPlus(customerId, monthId, isParty); } + + /** + * @param userId 用户id + * @param customerId + * @param monthId + * @return java.lang.Integer + * @author yinzuomei + * @description 查询用户在这个月内表决的总次数 + * @Date 2020/9/20 21:50 + **/ + @Override + public Integer selectCountUserVote(String userId, String customerId, String monthId) { + return issueLogDailyDao.selectCountUserVote(userId,customerId,monthId); + } + + /** + * @param topicIdList + * @return java.lang.Integer + * @author yinzuomei + * @description 查询本周期和上周期内,自建群内话题转为议题的数量的总和 + * @Date 2020/9/20 22:48 + **/ + @Override + public Integer selectIssueTotalTwoMonth(List topicIdList) { + return issueMainDailyDao.selectIssueTotalTwoMonth(topicIdList); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginGroupMainDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginGroupMainDailyDao.xml index fd90cd5a18..6894e88ce1 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginGroupMainDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginGroupMainDailyDao.xml @@ -17,5 +17,28 @@ GROUP BY GRID_ID + + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginIssueLogDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginIssueLogDailyDao.xml index ab19b88e80..862f0488c5 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginIssueLogDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginIssueLogDailyDao.xml @@ -62,4 +62,20 @@ CUSTOMER_ID = #{customerId} AND DATE_ID = #{dateId} + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginIssueMainDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginIssueMainDailyDao.xml index 2e4884a8f6..de03f24dc5 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginIssueMainDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginIssueMainDailyDao.xml @@ -111,27 +111,12 @@ -- AND t1.TOPIC_USER_IS_PARTY = '1' AND t1.CUSTOMER_ID = #{customerId} AND t1.MONTH_ID = #{monthId} + AND ISNULL(T1.CREATE_TOPIC_USER_ID)=0 + AND LENGTH(trim(T1.CREATE_TOPIC_USER_ID))>0 GROUP BY T1.CREATE_TOPIC_USER_ID - - - + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectMainDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectMainDailyDao.xml index 81472beb65..a619489c28 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectMainDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectMainDailyDao.xml @@ -108,4 +108,35 @@ + + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginTopicLogDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginTopicLogDailyDao.xml index 3fcd8fba28..848a0d733a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginTopicLogDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginTopicLogDailyDao.xml @@ -100,4 +100,32 @@ and t1.MONTH_ID=#{monthId} group by t2.USER_ID + + + + + + + \ No newline at end of file