|
|
@ -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,8 +58,14 @@ 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、党员参与话题数(支持、反对、评论、浏览)---目前只统计 党员评论话题次数之和
|
|
|
@ -62,10 +74,19 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { |
|
|
|
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); |
|
|
|
//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、党员提出话题数
|
|
|
@ -85,20 +106,24 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { |
|
|
|
indexPartyAblityCpcEntity.setShiftProjectCount(shiftProjectCountMap.get(indexPartyAblityCpcEntity.getUserId())); |
|
|
|
} |
|
|
|
//5、参加“三会一课”次数 目前没有此业务,默认0
|
|
|
|
//6、党员自建群群众人数 TODO
|
|
|
|
//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())) { |
|
|
|
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 |
|
|
|