Browse Source

党员相关-党建能力计算V0.3

master
yinzuomei 5 years ago
parent
commit
d92ba7db0b
  1. 18
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginGroupMainDailyDao.java
  2. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginIssueLogDailyDao.java
  3. 19
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginIssueMainDailyDao.java
  4. 22
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginProjectMainDailyDao.java
  5. 20
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginTopicLogDailyDao.java
  6. 21
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/FactOriginProjectMainDailyService.java
  7. 20
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/FactOriginTopicLogDailyService.java
  8. 30
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/IssueExtractService.java
  9. 245
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/CalCpcIndexServiceImpl.java
  10. 37
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/FactOriginProjectMainDailyServiceImpl.java
  11. 32
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/FactOriginTopicLogDailyServiceImpl.java
  12. 1
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/FactOriginTopicMainDailyServiceImpl.java
  13. 44
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/IssueExtractServiceImpl.java
  14. 23
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginGroupMainDailyDao.xml
  15. 16
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginIssueLogDailyDao.xml
  16. 42
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginIssueMainDailyDao.xml
  17. 31
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectMainDailyDao.xml
  18. 28
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginTopicLogDailyDao.xml

18
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<FactOriginGroupMain
*/
List<PartyCreateGroupCountResultDTO> selectPartyCreateGroupCount(@Param("customerId") String customerId,@Param("monthId") String monthId);
/**
* @param customerId
* @param groupOwnerId
* @return java.util.List<java.lang.String>
* @author yinzuomei
* @description 查询当前用户建的所有群id
* @Date 2020/9/20 21:22
**/
List<String> selectGroupIds(@Param("customerId") String customerId, @Param("groupOwnerId") String groupOwnerId);
/**
* @return java.util.List<java.lang.String>
* @param groupIdList
* @author yinzuomei
* @description 查询组成员数去重
* @Date 2020/9/20 21:29
**/
List<String> selectGroupMemberList(@Param("list") List<String> groupIdList);
}

10
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<FactOriginIssueLogDa
*/
void deleteOldLogRecord(@Param("customerId")String customerId,@Param("dateId")String dateId);
/**
* @return java.lang.Integer
* @param userId 用户id
* @param customerId
* @param monthId
* @author yinzuomei
* @description 查询用户在这个月内表决的总次数
* @Date 2020/9/20 21:52
**/
Integer selectCountUserVote(@Param("userId") String userId, @Param("customerId") String customerId, @Param("monthId")String monthId);
}

19
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginIssueMainDailyDao.java

@ -83,16 +83,6 @@ public interface FactOriginIssueMainDailyDao extends BaseDao<FactOriginIssueMain
**/
List<Map<String, Integer>> selectShiftIssueCount(@Param("customerId") String customerId,@Param("monthId") String monthId);
/**
* @return java.util.List<java.util.Map<java.lang.String,java.lang.Integer>>
* @param customerId
* @param monthId
* @author yinzuomei
* @description 党员提出的议题转项目数
* @Date 2020/9/18 14:11
**/
List<Map<String, Integer>> selectShiftProjectCount(@Param("customerId") String customerId,@Param("monthId") String monthId);
/**
* @Description 查询网格 党员/群众 人均提出的议题转项目数
* @param customerId
@ -102,4 +92,13 @@ public interface FactOriginIssueMainDailyDao extends BaseDao<FactOriginIssueMain
* @date 2020/9/19 2:26 下午
*/
List<ShiftProjectCountResultDTO> 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<String> topicIdList);
}

22
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<FactOriginProject
* @return void
*/
void deleteByDate(@Param("date") String date);
/**
* @return java.util.List<java.util.Map<java.lang.String,java.lang.Integer>>
* @param customerId
* @param monthId
* @author yinzuomei
* @description 党员提出的议题转项目数
* @Date 2020/9/18 14:11
**/
List<Map<String, Integer>> 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<String> topicIdList);
}

20
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<FactOriginTopicLogDa
* @Date 2020/9/18 15:05
**/
List<Map<String, Integer>> 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<java.lang.String>
* @param groupIdList
* @author yinzuomei
* @description 组内的所有话题id
* @Date 2020/9/20 22:18
**/
List<String> selectTopicIds(@Param("list") List<String> groupIdList);
}

21
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<FactOrigi
* @return void
*/
void deleteByDate(String date);
/**
* @return java.util.List<java.util.Map<java.lang.String,java.lang.Integer>>
* @param customerId
* @param monthId
* @author yinzuomei
* @description 党员提出的议题转项目数
* @Date 2020/9/18 14:11
**/
List<Map<String, Integer>> 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<String> topicIdList);
}

20
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<FactOriginTo
* @Date 2020/9/18 14:33
**/
List<Map<String, Integer>> 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<java.lang.String>
* @param groupIdList
* @author yinzuomei
* @description 组内的所有话题id
* @Date 2020/9/20 22:17
**/
List<String> selectTopicIds(List<String> groupIdList);
}

30
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<Map<String, Integer>> selectShiftIssueCount(String customerId, String monthId);
/**
* @return java.util.List<java.util.Map<java.lang.String,java.lang.Integer>>
* @param customerId
* @param monthId
* @author yinzuomei
* @description 党员提出的议题转项目数
* @Date 2020/9/18 14:11
**/
List<Map<String, Integer>> selectShiftProjectCount(String customerId, String monthId);
/**
* @Description 查询网格 党员/群众 人均提出的议题转项目数
* @param customerId
@ -80,4 +70,24 @@ public interface IssueExtractService {
* @date 2020/9/19 2:26 下午
*/
List<ShiftProjectCountResultDTO> 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<String> topicIdList);
}

245
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<FactIndexPartyAblityCpcMonthlyEntity> indexPartyAblityCpcList = dimCustomerPartymemberService.selectPartyMemberList(customerId);
if (CollectionUtils.isEmpty(indexPartyAblityCpcList)) {
log.info("dim_customer_partymember do not any records");
return;
}
//2、删除之前统计过的
deleteFactIndexPartyAblityCpcMonthly(customerId, monthId);
//1、党员提出话题数
Map<String, Integer> createTopicCountMap = calCreateTopicCount(customerId, monthId);
//2、党员参与话题数(支持、反对、评论、浏览)---目前只统计 党员评论话题次数之和
Map<String,Integer> joinTopicCountMap=calJoinTopicCount(customerId,monthId);
Map<String, Integer> joinTopicCountMap = calJoinTopicCount(customerId, monthId);
//3、党员提出的话题转议题数
Map<String,Integer> shiftIssueCountMap=calShiftIssueCount(customerId,monthId);
Map<String, Integer> shiftIssueCountMap = calShiftIssueCount(customerId, monthId);
//4、党员提出的议题转项目数
Map<String,Integer> shiftProjectCountMap=calShiftProjectCount(customerId,monthId);
//6、党员自建群群众人数
Map<String,Integer> groupUserCountMap=calgroupUserCount(customerId,monthId);
//8、党员自建群活跃度——话题数
Map<String,Integer> groupTopicCountMap=calGroupTopicCountMap(customerId,monthId);
Map<String, Integer> shiftProjectCountMap = calShiftProjectCount(customerId, monthId);
//5、参加“三会一课”次数 默认0
//可以先查询出每个党员的 自建群
Map<String, List<String>> userCreatedGroups = queryUserCreatedGroups(customerId, indexPartyAblityCpcList);
//6、党员自建群群众人数 (todo 和monthId无关??)
Map<String, Integer> groupUserCountMap = calgroupUserCount(customerId, monthId, indexPartyAblityCpcList, userCreatedGroups);
//7、党员自建群活跃群众人数
Map<String, Integer> groupActiveUserCountMap = calGroupActiveUserCount(customerId, monthId, indexPartyAblityCpcList, userCreatedGroups);
//8、党员自建群活跃度——话题数 (todo 校验sql正确性)
Map<String, Integer> groupTopicCountMap = calGroupTopicCount(customerId, monthId);
//9、自建群活跃度——议题转项目率
Map<String, BigDecimal> 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<List<FactIndexPartyAblityCpcMonthlyEntity>> 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<java.lang.String, java.util.List < java.lang.String>>
* @author yinzuomei
* @description 查询每个党员的自建群
* @Date 2020/9/20 22:07
**/
private Map<String, List<String>> queryUserCreatedGroups(String customerId, List<FactIndexPartyAblityCpcMonthlyEntity> partyMemberList) {
Map<String, List<String>> map = new HashMap<>();
for (FactIndexPartyAblityCpcMonthlyEntity partyMember : partyMemberList) {
//查询当前党员建了多少个组
List<String> 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<java.lang.String,java.lang.Integer>
* @param customerId
* @param monthId
* @return java.util.Map<java.lang.String, java.lang.Integer>
* @author yinzuomei
* @description 2查询客户下这个月内每个党员评论话题的次数
* @Date 2020/9/18 13:33
@ -146,9 +195,9 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService {
/**
* @return java.util.Map<java.lang.String,java.lang.Integer>
* @param customerId
* @param monthId
* @return java.util.Map<java.lang.String, java.lang.Integer>
* @author yinzuomei
* @description 3党员提出的话题转议题数
* @Date 2020/9/18 13:53
@ -165,15 +214,16 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService {
}
/**
* @return java.util.Map<java.lang.String,java.lang.Integer>
* @param customerId
* @param monthId
* @return java.util.Map<java.lang.String, java.lang.Integer>
* @author yinzuomei
* @description 4党员提出的议题转项目数
* @Date 2020/9/18 14:10
**/
private Map<String, Integer> calShiftProjectCount(String customerId, String monthId) {
List<Map<String, Integer>> mapList = issueExtractService.selectShiftProjectCount(customerId, monthId);
//查询fact_origin_project_main_daily 表 中议题的议题的状态为 shift_
List<Map<String, Integer>> mapList = factOriginProjectMainDailyService.selectShiftProjectCount(customerId, monthId);
Map<String, Integer> resultMap = new HashMap<>();
for (Map<String, Integer> map : mapList) {
for (Map.Entry<String, Integer> m : map.entrySet()) {
@ -184,18 +234,99 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService {
}
/**
* @return java.util.Map<java.lang.String,java.lang.Integer>
* @param customerId
* @param monthId
* @return java.util.Map<java.lang.String, java.lang.Integer>
* @author yinzuomei
* @description 6党员自建群群众人数
* @Date 2020/9/18 15:38
**/
private Map<String, Integer> calgroupUserCount(String customerId, String monthId) {
// TODO
return null;
private Map<String, Integer> calgroupUserCount(String customerId, String monthId,
List<FactIndexPartyAblityCpcMonthlyEntity> partyMemberList,
Map<String, List<String>> userCreatedGroups) {
/*含义评价周期内党员自建群中群众成员数
数据来源用户社群关系表
计算方法对党员i的所有j个自建群从用户社群关系表中统计属于每个自建群的群众用户总人数并对j个群众用户总数进行不重复累加
对评价结果的影响正向*/
Map<String, Integer> map = new HashMap<>();
for (FactIndexPartyAblityCpcMonthlyEntity partyMember : partyMemberList) {
//查询当前党员建了多少个组
List<String> groupIdList = userCreatedGroups.get(partyMember.getUserId());
if (CollectionUtils.isEmpty(groupIdList)) {
map.put(partyMember.getUserId(), NumConstant.ZERO);
continue;
}
//去重组里面的成员
List<String> 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<java.lang.String, java.lang.Integer>
* @author yinzuomei
* @description 7党员自建群活跃群众人数
* @Date 2020/9/20 21:36
**/
private Map<String, Integer> calGroupActiveUserCount(String customerId, String monthId,
List<FactIndexPartyAblityCpcMonthlyEntity> partyMemberList,
Map<String, List<String>> userCreatedGroups) {
/*含义评价周期内党员自建群中活跃群众成员数所谓活跃群成员即评价周期内参与话题事件评论点赞点踩总次数大于给定阈值的群众用户
数据来源话题用户阅读表话题评论用户表态表话题评论表事件点赞点踩表事件评论点赞点踩表事件评论表用户信息表
计算方法
a)判断群中的群众成员是否活跃
for each 群众成员 i
统计i的话题阅读次数话题评论次数话题评论表态次数事件点赞点踩次数事件评论点赞点踩次数事件评论总次数
If 总次数>阈值
成员i为活跃群众成员
b)不重复累加活跃群众成员数
对评价结果的影响正向*/
//结合目前产品,数据来源:话题评论、议题表决
Map<String, Integer> map = new HashMap<>();
for (FactIndexPartyAblityCpcMonthlyEntity partyMember : partyMemberList) {
int groupActiveUserCount = 0;
//1、查询当前党员建了多少个组
List<String> groupIdList = userCreatedGroups.get(partyMember.getUserId());
if (CollectionUtils.isEmpty(groupIdList)) {
map.put(partyMember.getUserId(), NumConstant.ZERO);
continue;
}
//2、去重组里面的成员
List<String> 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<String, Integer> calGroupTopicCountMap(String customerId, String monthId) {
private Map<String, Integer> calGroupTopicCount(String customerId, String monthId) {
/*含义评价周期内党员自建群中话题发布数
数据来源话题表
计算方法从话题表中统计党员自建群i的话题总数对所有自建群话题数累加
对评价结果的影响正向*/
List<Map<String, Integer>> mapList = factOriginTopicLogDailyService.selectGroupTopicCount(customerId, monthId);
Map<String, Integer> resultMap = new HashMap<>();
for (Map<String, Integer> map : mapList) {
@ -215,6 +350,54 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService {
return resultMap;
}
/**
* @param userCreatedGroups 党员自建群
* @return java.util.Map<java.lang.String, java.math.BigDecimal>
* @author yinzuomei
* @description 9自建群活跃度议题转项目率
* @Date 2020/9/20 22:11
**/
private Map<String, BigDecimal> caltopicToIssueRatio(String customerId,
String monthId,
List<FactIndexPartyAblityCpcMonthlyEntity> partyMemberList,
Map<String, List<String>> userCreatedGroups) {
Map<String, BigDecimal> map = new HashMap<>();
for (FactIndexPartyAblityCpcMonthlyEntity partyMember : partyMemberList) {
//如果党员自建群为空,直接赋值0
if (CollectionUtils.isEmpty(userCreatedGroups.get(partyMember.getUserId()))) {
map.put(partyMember.getUserId(), BigDecimal.ZERO);
continue;
}
//自建群出来的话题
List<String> groupIdList = userCreatedGroups.get(partyMember.getUserId());
List<String> 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

37
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<FactO
baseDao.deleteByDate(date);
}
/**
* @param customerId
* @param monthId
* @return java.util.List<java.util.Map < java.lang.String, java.lang.Integer>>
* @author yinzuomei
* @description 党员提出的议题转项目数
* @Date 2020/9/18 14:11
**/
@Override
public List<Map<String, Integer>> 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<String> topicIdList) {
if(CollectionUtils.isEmpty(topicIdList)){
return NumConstant.ZERO;
}
return baseDao.selectCountByPartyUser(customerId,monthId,topicIdList);
}
}

32
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<FactOrig
**/
@Override
public List<Map<String, Integer>> selectJoinTopicCount(String customerId, String monthId) {
//这个月内新增的话题评论,按人分组,不限制评论时的身份,以当前用户最新身份为准
return baseDao.selectJoinTopicCount(customerId,monthId);
}
@ -64,4 +67,33 @@ public class FactOriginTopicLogDailyServiceImpl extends BaseServiceImpl<FactOrig
public List<Map<String, Integer>> 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<java.lang.String>
* @author yinzuomei
* @description 组内的所有话题id
* @Date 2020/9/20 22:17
**/
@Override
public List<String> selectTopicIds(List<String> groupIdList) {
if(CollectionUtils.isEmpty(groupIdList)){
return new ArrayList<>();
}
return baseDao.selectTopicIds(groupIdList);
}
}

1
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<FactOri
**/
@Override
public List<Map<String, Integer>> selectPartyCreateTopicCount(String customerId, String monthId) {
//这个月内新增的话题,按人分组,不限制发话题人的身份,也就是说以用户最新的身份为准
return baseDao.selectPartyCreateTopicCount(customerId,monthId);
}

44
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<Map<String, Integer>> selectShiftIssueCount(String customerId, String monthId) {
//查询fact_origin_issue_main_daily 表,转议题的时间在评价周期内的,按发布话题的人分组
/*含义评价周期内党员提出的话题转为议题的数目
数据来源议题表
计算方法从议题表中按照用户ID和党员标识统计
对评价结果的影响正向*/
return issueMainDailyDao.selectShiftIssueCount(customerId,monthId);
}
/**
* @param customerId
* @param monthId
* @return java.util.List<java.util.Map < java.lang.String, java.lang.Integer>>
* @author yinzuomei
* @description 党员提出的议题转项目数
* @Date 2020/9/18 14:11
**/
@Override
public List<Map<String, Integer>> selectShiftProjectCount(String customerId, String monthId) {
return issueMainDailyDao.selectShiftProjectCount(customerId,monthId);
}
/**
* @Description 查询网格 党员/群众 人均提出的议题转项目数
* @param customerId
@ -306,4 +298,30 @@ public class IssueExtractServiceImpl implements IssueExtractService {
public List<ShiftProjectCountResultDTO> 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<String> topicIdList) {
return issueMainDailyDao.selectIssueTotalTwoMonth(topicIdList);
}
}

23
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginGroupMainDailyDao.xml

@ -17,5 +17,28 @@
GROUP BY GRID_ID
</select>
<!-- 查询当前用户建的所有群id -->
<select id="selectGroupIds" parameterType="map" resultType="java.lang.String">
SELECT
t1.id AS groupId
FROM
fact_origin_group_main_daily t1
WHERE t1.DEL_FLAG='0'
and t1.CUSTOMER_ID = #{customerId}
AND t1.GROUP_OWNER_ID = #{groupOwnerId}
</select>
<!-- 查询组成员数(去重) -->
<select id="selectGroupMemberList" parameterType="map" resultType="java.lang.String">
SELECT DISTINCT
MEMBER_ID AS userId
FROM
fact_origin_group_member_daily m
WHERE
m.DEL_FLAG = '0'
AND
<foreach collection="list" item="groupId" separator="or" open="(" close=")">
m.GROUP_ID =#{groupId}
</foreach>
</select>
</mapper>

16
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}
</delete>
<!-- 查询用户在这个月内表决的总次数 -->
<select id="selectCountUserVote" parameterType="map" resultType="java.lang.Integer">
SELECT
COUNT( 1 ) AS TOTAL
FROM
fact_origin_issue_log_daily T1
WHERE
T1.DEL_FLAG = '0'
AND T1.CUSTOMER_ID = #{customerId}
AND T1.MONTH_ID = #{monthId}
AND T1.OPERATION_USER_ID = #{userId}
AND (
T1.ACTION_CODE = 'vote_support'
OR T1.ACTION_CODE = 'vote_opposition')
</select>
</mapper>

42
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
</select>
<!-- 党员提出的议题转项目数 -->
<select id="selectShiftProjectCount" parameterType="map" resultType="java.util.Map">
SELECT
t1.CREATE_TOPIC_USER_ID AS USER_ID,
COUNT( 1 ) AS SHIFT_PROJECT_COUNT
FROM
fact_origin_issue_main_daily t1
WHERE
t1.DEL_FLAG = '0'
-- AND t1.TOPIC_USER_IS_PARTY = '1'
AND T1.ISSUE_STATUS='shift_project'
AND t1.CUSTOMER_ID = #{customerId}
AND t1.MONTH_ID = #{monthId}
GROUP BY
T1.CREATE_TOPIC_USER_ID
</select>
<!-- 查询网格 党员/群众 人均提出的议题转项目数 -->
<select id="selectShiftProjectCountPlus" resultType="com.epmet.dto.extract.result.ShiftProjectCountResultDTO">
SELECT
@ -145,4 +130,27 @@
AND IS_PARTY = #{isParty}
GROUP BY GRID_ID
</select>
<!-- 查询本周期和上周期内,自建群内话题转为议题的数量的总和 -->
<select id="selectIssueTotalTwoMonth" parameterType="map" resultType="java.lang.Integer">
select sum(t.total) as totalIssue
from (
SELECT
t1.MONTH_ID,
count( 1 ) as total
FROM
fact_origin_issue_main_daily t1
WHERE
t1.DEL_FLAG = '0'
AND
<foreach collection="list" item="topicId" separator="or" open="(" close=")">
t1.TOPIC_ID =#{topicId}
</foreach>
GROUP BY
MONTH_ID
ORDER BY
t1.MONTH_ID DESC
LIMIT 2
)t
</select>
</mapper>

31
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectMainDailyDao.xml

@ -108,4 +108,35 @@
</if>
</delete>
<!-- 党员提出的议题转项目数 -->
<select id="selectShiftProjectCount" parameterType="map" resultType="java.util.Map">
SELECT
t1.TOPIC_CREATOR_ID AS USER_ID,
COUNT( 1 ) AS SHIFT_PROJECT_COUNT
FROM
fact_origin_project_main_daily t1
WHERE
t1.DEL_FLAG = '0'
AND t1.CUSTOMER_ID = #{customerId}
AND t1.MONTH_ID = #{monthId}
AND ISNULL(T1.TOPIC_CREATOR_ID)=0
AND LENGTH(trim(T1.TOPIC_CREATOR_ID))>0
GROUP BY
T1.TOPIC_CREATOR_ID
</select>
<select id="selectCountByPartyUser" parameterType="map" resultType="java.lang.Integer">
SELECT
COUNT( 1 ) AS TOTAL
FROM
fact_origin_project_main_daily T1
WHERE
T1.DEL_FLAG = '0'
AND T1.CUSTOMER_ID = #{customerId}
AND T1.MONTH_ID = #{monthId}
AND
<foreach collection="list" item="topicId" separator="or" open="(" close=")">
T1.TOPIC_ID =#{topicId}
</foreach>
</select>
</mapper>

28
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
</select>
<!-- 查询当前用户在本月内评论的次数 -->
<select id="selectUserCommentCount" parameterType="map" resultType="java.lang.Integer">
SELECT
COUNT( 1 ) AS TOTAL
FROM
fact_origin_topic_main_daily T1
WHERE
T1.DEL_FLAG = '0'
AND T1.CUSTOMER_ID = #{customerId}
AND T1.MONTH_ID = #{monthId}
AND T1.OPERATE_USER_ID = #{userId}
</select>
<!-- 组内的所有话题id -->
<select id="selectTopicIds" parameterType="map" resultType="java.lang.String">
SELECT
T1.TOPIC_ID
FROM
fact_origin_topic_log_daily T1
WHERE
T1.DEL_FLAG = '0'
AND
<foreach collection="list" item="groupId" separator="or" open="(" close=")">
T1.GROUP_ID =#{groupId}
</foreach>
</select>
</mapper>
Loading…
Cancel
Save