Browse Source

用户统计的修改

dev_shibei_match
wangchao 5 years ago
parent
commit
8f4fd4bd1d
  1. 4
      epmet-module/data-report/data-report-server/src/main/resources/mapper/user/UserAnalysisDao.xml
  2. 2
      epmet-module/data-statistical/data-statistical-server/pom.xml
  3. 329
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/topic/impl/TopicServiceImpl.java
  4. 8
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java

4
epmet-module/data-report/data-report-server/src/main/resources/mapper/user/UserAnalysisDao.xml

@ -57,8 +57,8 @@
m.id, m.id,
m.DATE_ID AS currentDate, m.DATE_ID AS currentDate,
m.DATE_ID AS dateId, m.DATE_ID AS dateId,
m.REG_TOTAL AS regTotal, m.REG_TOTAL AS partiTotal,
0 AS partiTotal, 0 AS regTotal,
m.PARTYMEMBER_TOTAL AS partymemberTotal, m.PARTYMEMBER_TOTAL AS partymemberTotal,
m.PARTYMEMBER_PROPORTION*100 AS partymemberProportionValue, m.PARTYMEMBER_PROPORTION*100 AS partymemberProportionValue,
m.WARM_HEARTED_TOTAL AS warmHeartedTotal, m.WARM_HEARTED_TOTAL AS warmHeartedTotal,

2
epmet-module/data-statistical/data-statistical-server/pom.xml

@ -159,7 +159,7 @@
<spring.redis.port>6379</spring.redis.port> <spring.redis.port>6379</spring.redis.port>
<spring.redis.password>123456</spring.redis.password> <spring.redis.password>123456</spring.redis.password>
<!-- nacos --> <!-- nacos -->
<nacos.register-enabled>true</nacos.register-enabled> <nacos.register-enabled>false</nacos.register-enabled>
<nacos.server-addr>122.152.200.70:8848</nacos.server-addr> <nacos.server-addr>122.152.200.70:8848</nacos.server-addr>
<nacos.discovery.namespace>fcd6fc8f-ca3a-4b01-8026-2b05cdc5976b</nacos.discovery.namespace> <nacos.discovery.namespace>fcd6fc8f-ca3a-4b01-8026-2b05cdc5976b</nacos.discovery.namespace>
<nacos.config.namespace></nacos.config.namespace> <nacos.config.namespace></nacos.config.namespace>

329
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/topic/impl/TopicServiceImpl.java

@ -921,4 +921,333 @@ public class TopicServiceImpl implements TopicService {
} }
/**
* @Description 根据话题状态的维度自动匹配分析数据
* @param
* @return
* @author wangc
* @date 2020.06.30 17:04
**/
void analyzeTopicGroupByIssueStatus(Map<String, Set<String>> subGridOfAgency, List<AgencySubTreeDto> agencies, Map<String,List<ResiGroupTopicResultDTO>> gridGroupMap, Map<String,List<ResiTopicOperationResultDTO>> topicOperationMap, Date targetDate, TopicStatisticalData dataPacket, List<DimTopicStatusDTO> statusDimension, DimIdGenerator.DimIdBean timeDimension){
//Boolean isMonthEnd = false;
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
//前一天零点
calendar.add(Calendar.DATE, NumConstant.ONE_NEG);
calendar.set(Calendar.HOUR_OF_DAY, NumConstant.ZERO);
calendar.set(Calendar.MINUTE, NumConstant.ZERO);
calendar.set(Calendar.SECOND, NumConstant.ZERO);
Date targetDateCheck = null == targetDate ? calendar.getTime() : targetDate;
calendar.setTime(targetDateCheck);
//如果目标日期是当月的最后一天
//if(calendar.get(Calendar.DATE) == calendar.getActualMaximum(Calendar.DAY_OF_MONTH)){
//求出这个月的第一天
calendar.setTime(new Date());
calendar.set(Calendar.DAY_OF_MONTH, NumConstant.ONE);
calendar.set(Calendar.HOUR_OF_DAY, NumConstant.ZERO);
calendar.set(Calendar.MINUTE, NumConstant.ZERO);
calendar.set(Calendar.SECOND, NumConstant.ZERO);
// isMonthEnd = true;
//}
//计算百分比使用,保留小数点后两位
NumberFormat numberFormat = NumberFormat.getInstance();
numberFormat.setMaximumFractionDigits(NumConstant.SIX);
Map<String,DimTopicStatusDTO> statusMap = new HashMap<>();
statusDimension.forEach(status -> statusMap.put(status.getId(),status));
Map<String,AgencySubTreeDto> agencyMap = new HashMap<>();
agencies.forEach(agency -> {agencyMap.put(agency.getAgencyId(),agency);});
List<ResiGroupTopicResultDTO> groupList = new LinkedList<>();
for(Map.Entry<String,List<ResiGroupTopicResultDTO>> entry : gridGroupMap.entrySet()){
if(null != entry.getValue() && entry.getValue().size() > NumConstant.ZERO)
groupList.addAll(entry.getValue());
}
//key -> groupId
Map<String,GroupTopicData> groupTopicData = traverseGroupTopic(groupList,topicOperationMap);
Map<String,Boolean> gridDistinct = new HashMap<>();
agencies.forEach(agency -> {
if(null != agency.getGridIds() && agency.getGridIds().size() > NumConstant.ZERO){
agency.getGridIds().forEach(grid -> {
gridDistinct.put(grid,false);
});
}
});
for(Map.Entry<String,Set<String>> entry : subGridOfAgency.entrySet()){
FactTopicIssueAgencyDailyDTO issueAgencyD = new FactTopicIssueAgencyDailyDTO();
FactTopicTotalAgencyDailyDTO totalAgencyD = new FactTopicTotalAgencyDailyDTO();
//initAgencyDailyDTO(entry.getKey(),agencyMap.get(entry.getKey()).getPid(),agencyMap.get(entry.getKey()).getCustomerId(),timeDimension,statusMap,issueAgencyD,totalAgencyD);
statusMap.forEach((k,v) -> {
//无状态标识
boolean noStatusFlag = false;
if(StringUtils.equals(k,"discussing")){
noStatusFlag = true;
}
final boolean noStatusFlagFinal = noStatusFlag;
//k:状态的key
//对应状态key的一条话题-状态记录
FactTopicStatusAgencyDailyDTO topicAgencyD = new FactTopicStatusAgencyDailyDTO();
topicAgencyD.setTopicStatusId(k);
//initAgencyDailyDTO
if(null != entry.getValue() && entry.getValue().size() > NumConstant.ZERO){
entry.getValue().forEach(gridId -> {
FactTopicStatusGridDailyDTO topicGridD = new FactTopicStatusGridDailyDTO();
topicGridD.setTopicStatusId(k);
FactTopicIssueGridDailyDTO issueGridD = new FactTopicIssueGridDailyDTO();
FactTopicTotalGridDailyDTO totalGirdD = new FactTopicTotalGridDailyDTO();
//init
//if(noStatusFlagFinal){
//initGridDailyDTO(entry.getKey(),gridId,agencyMap.get(entry.getKey()).getCustomerId(),timeDimension,statusMap,issueGridD,totalGirdD,topicGridD_discussing);
//}else{
//initGridDailyDTO(entry.getKey(),gridId,agencyMap.get(entry.getKey()).getCustomerId(),timeDimension,statusMap,topicGridD_discussing);
//}
List<ResiGroupTopicResultDTO> groups = gridGroupMap.get(gridId);
if(null != groups && groups.size() > NumConstant.ZERO) {
groups.forEach(group -> {
if (null != group && StringUtils.isNotBlank(group.getGroupId())) {
if(noStatusFlagFinal) {
issueAgencyD.setIssueIncr(issueAgencyD.getIssueIncr() + groupTopicData.get(group.getGroupId()).getIssueIncr());
issueAgencyD.setIssueTotal(issueAgencyD.getIssueTotal() + groupTopicData.get(group.getGroupId()).getIssueTotal());
totalAgencyD.setIssueTotalCount(issueAgencyD.getIssueTotal());
totalAgencyD.setHiddenTotalCount(totalAgencyD.getHiddenTotalCount() + groupTopicData.get(group.getGroupId()).getHiddenTotal());
totalAgencyD.setTopicIncr(totalAgencyD.getTopicIncr() + groupTopicData.get(group.getGroupId()).getTopicIncr());
totalAgencyD.setTopicTotal(totalAgencyD.getTopicTotal() + groupTopicData.get(group.getGroupId()).getTotal());
issueGridD.setIssueIncr(issueGridD.getIssueIncr() + groupTopicData.get(group.getGroupId()).getIssueIncr());
issueGridD.setIssueTotal(issueGridD.getIssueTotal() + groupTopicData.get(group.getGroupId()).getIssueTotal());
totalGirdD.setIssueTotalCount(issueGridD.getIssueTotal());
totalGirdD.setHiddenTotalCount(totalGirdD.getHiddenTotalCount() + groupTopicData.get(group.getGroupId()).getHiddenTotal());
totalGirdD.setTopicIncr(totalGirdD.getTopicIncr() + groupTopicData.get(group.getGroupId()).getTopicIncr());
totalGirdD.setTopicTotal(totalGirdD.getTopicTotal() + groupTopicData.get(group.getGroupId()).getTotal());
}
GroupTopicData data = groupTopicData.get(group.getGroupId());
if (null != data) {
//根据当前的话题状态key,去data中取相应的数据
switch(k){
case "discussing":
topicAgencyD.setTopicCount(topicAgencyD.getTopicCount() + data.getDiscussingTotal());
topicAgencyD.setTopicIncrement(topicAgencyD.getTopicIncrement() + data.getDiscussingIncr());
topicGridD.setTopicCount(topicGridD.getTopicCount() + data.getDiscussingTotal());
topicGridD.setTopicIncrement(topicGridD.getTopicIncrement() + data.getDiscussingIncr());
break;
case "hidden":
topicAgencyD.setTopicCount(topicAgencyD.getTopicCount() + data.getHiddenTotal());
topicAgencyD.setTopicIncrement(topicAgencyD.getTopicIncrement() + data.getHiddenIncr());
topicGridD.setTopicCount(topicGridD.getTopicCount() + data.getHiddenTotal());
topicGridD.setTopicIncrement(topicGridD.getTopicIncrement() + data.getHiddenIncr());
break;
case "closed":
topicAgencyD.setTopicCount(topicAgencyD.getTopicCount() + data.getClosedTotal());
topicAgencyD.setTopicIncrement(topicAgencyD.getTopicIncrement() + data.getClosedIncr());
topicGridD.setTopicCount(topicGridD.getTopicCount() + data.getClosedTotal());
topicGridD.setTopicIncrement(topicGridD.getTopicIncrement() + data.getClosedIncr());
break;
}
}
}
});
}
//网格-百分比
//setGridTopicProportion(numberFormat, topicGridD, totalGirdD);
if(!gridDistinct.get(gridId)) {
//setGridDailyDataPacket(dataPacket, issueGridD, totalGirdD, topicGridD_discussing, topicGridD_hidden, topicGridD_closed);
/*
if(noStatusFlagFinal){
set :: issueGridD | totalGridD | topicGridD
}else{
set :: topicGridD
}
*/
gridDistinct.put(gridId,true);
}
});
}
//机关-百分比
//setAgencyTopicProportion(numberFormat,topicAgencyD,totalAgencyD);
//setAgencyDailyDataPacket(dataPacket,issueAgencyD,totalAgencyD,topicAgencyD_discussing,topicAgencyD_hidden,topicAgencyD_closed);
/*
if(noStatusFlagFinal){
set :: issueAgencyD | totalAgencyD | topicAgencyD
}else{
set :: topicAgencyD
}
*/
});
}
gridDistinct.forEach((k,v) -> {
gridDistinct.put(k,false);
});
List<ResiGroupTopicResultDTO> topicsBetweenTimeRange = topicDao.selectGroupOrderByGridBetweenTimeRange(calendar.getTime(),targetDate,dataPacket.getCustomerId());
//key : gridId
Map<String,List<ResiGroupTopicResultDTO>> GridGroupMapBetweenTimeRange =
topicsBetweenTimeRange.stream().collect(Collectors.groupingBy(ResiGroupTopicResultDTO::getGridId));
List<ResiGroupTopicResultDTO> groupListBetweenTimeRange = new LinkedList<>();
for(Map.Entry<String,List<ResiGroupTopicResultDTO>> entryBetweenTimeRange : GridGroupMapBetweenTimeRange.entrySet()){
if(null != entryBetweenTimeRange.getValue() && entryBetweenTimeRange.getValue().size() > NumConstant.ZERO)
groupListBetweenTimeRange.addAll(entryBetweenTimeRange.getValue());
}
List<ResiTopicOperationResultDTO> operationsBetweenTimeRange =
topicDao.selectTopicOperationRecordBetweenTimeRange(calendar.getTime(),targetDate);
//key: topicId
Map<String,List<ResiTopicOperationResultDTO>> topicOperationMapBetweenTimeRange =
operationsBetweenTimeRange.stream().collect(Collectors.groupingBy(ResiTopicOperationResultDTO::getTopicId));
//key: groupId
Map<String,GroupTopicData> groupTopicDataBetweenTimeRange = traverseGroupTopic(groupListBetweenTimeRange,topicOperationMapBetweenTimeRange);
for(Map.Entry<String,Set<String>> entry : subGridOfAgency.entrySet()){
FactTopicIssueAgencyMonthlyDTO issueAgencyM = new FactTopicIssueAgencyMonthlyDTO();
//initAgencyMonthlyDTO(entry.getKey(),agencyMap.get(entry.getKey()).getPid(),agencyMap.get(entry.getKey()).getCustomerId(),timeDimension,statusMap,issueAgencyM);
statusMap.forEach((k,v) -> {
boolean noStatusFlag = false;
if(StringUtils.equals(k,"discussing")){
noStatusFlag = true;
}
final boolean noStatusFlagFinal = noStatusFlag;
FactTopicStatusAgencyMonthlyDTO topicAgencyM = new FactTopicStatusAgencyMonthlyDTO();
topicAgencyM.setTopicStatusId(k);
if(null != entry.getValue() && entry.getValue().size() > NumConstant.ZERO){
entry.getValue().forEach(gridId -> {
FactTopicIssueGridMonthlyDTO issueGridM = new FactTopicIssueGridMonthlyDTO();
initGridMonthlyDTO(entry.getKey(),gridId,agencyMap.get(entry.getKey()).getCustomerId(),timeDimension,issueGridM);
List<ResiGroupTopicResultDTO> groups = gridGroupMap.get(gridId);
if(null != groups) {
groups.forEach(group -> {
if (null != group && StringUtils.isNotBlank(group.getGroupId())) {
if(noStatusFlagFinal) {
issueAgencyM.setIssueIncr(issueAgencyM.getIssueIncr() + groupTopicDataBetweenTimeRange.get(group.getGroupId()).getIssueIncr());
issueAgencyM.setIssueTotal(issueAgencyM.getIssueTotal() + groupTopicDataBetweenTimeRange.get(group.getGroupId()).getIssueTotal());
issueGridM.setIssueIncr(issueGridM.getIssueIncr() + groupTopicDataBetweenTimeRange.get(group.getGroupId()).getIssueIncr());
issueGridM.setIssueTotal(issueGridM.getIssueTotal() + groupTopicDataBetweenTimeRange.get(group.getGroupId()).getIssueTotal());
}
GroupTopicData data = groupTopicDataBetweenTimeRange.get(group.getGroupId());
if (null != data) {
switch(k){
case "discussing":
topicAgencyM.setTopicCount(topicAgencyM.getTopicCount() + data.getDiscussingTotal());
topicAgencyM.setTopicIncr(topicAgencyM.getTopicIncr() + data.getDiscussingIncr());
break;
case "hidden":
topicAgencyM.setTopicCount(topicAgencyM.getTopicCount() + data.getHiddenTotal());
topicAgencyM.setTopicIncr(topicAgencyM.getTopicIncr() + data.getHiddenIncr());
break;
case "closed":
topicAgencyM.setTopicCount(topicAgencyM.getTopicCount() + data.getClosedTotal());
topicAgencyM.setTopicIncr(topicAgencyM.getTopicIncr() + data.getClosedIncr());
break;
}
}
}
});
}
if(!gridDistinct.get(gridId)) {
setGridMonthlyDataPacket(dataPacket, issueGridM);
}
gridDistinct.put(gridId,true);
});
}
//机关-百分比
//Integer topicTotal = dataPacket.getTotalAgencyDailyList().stream().filter( obj -> StringUtils.equals(obj.getAgencyId(),entry.getKey())).findFirst().get().getTopicTotal();
//setAgencyTopicMonthlyProportion(numberFormat,topicAgencyM,topicTotal);
/*
if(noStatusFlagFinal){
set :: issueAgencyM | topicAgencyM
}else{
set topicAgencyM
}
*/
});
}
}
} }

8
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java

@ -186,15 +186,17 @@ public class UserServiceImpl implements UserService {
Boolean isMonthBeginning = true; Boolean isMonthBeginning = true;
Calendar calendar =Calendar.getInstance(); Calendar calendar =Calendar.getInstance();
//求出T-1
calendar.setTime(new Date()); calendar.setTime(new Date());
calendar.add(Calendar.DATE, NumConstant.ONE_NEG); calendar.add(Calendar.DATE, NumConstant.ONE_NEG);
Date targetDateCheck = null == targetDate ? calendar.getTime() : targetDate; Date targetDateCheck = null == targetDate ? calendar.getTime() : targetDate;
//指定日期 OR T-1
calendar.setTime(targetDateCheck); calendar.setTime(targetDateCheck);
//如果目标日期不是是当月的第一天 //如果目标日期不是是当月的第一天
if(calendar.get(Calendar.DATE) != calendar.getActualMinimum(Calendar.DAY_OF_MONTH)){ if(calendar.get(Calendar.DATE) != calendar.getActualMinimum(Calendar.DAY_OF_MONTH)){
//求出这个月的第一天 //求出这个月的第一天
calendar.setTime(new Date());
calendar.set(Calendar.DAY_OF_MONTH, NumConstant.ONE); calendar.set(Calendar.DAY_OF_MONTH, NumConstant.ONE);
calendar.set(Calendar.HOUR_OF_DAY, NumConstant.ZERO); calendar.set(Calendar.HOUR_OF_DAY, NumConstant.ZERO);
calendar.set(Calendar.MINUTE, NumConstant.ZERO); calendar.set(Calendar.MINUTE, NumConstant.ZERO);
@ -255,7 +257,7 @@ public class UserServiceImpl implements UserService {
regAgencyD.setPartymemberTotal(partyRegData.getTotal()); regAgencyD.setPartymemberTotal(partyRegData.getTotal());
regAgencyD.setRegIncr(regData.getIncr()); regAgencyD.setRegIncr(regData.getIncr());
regAgencyD.setWarmIncr(warmRegData.getIncr()); regAgencyD.setWarmIncr(warmRegData.getIncr());
regAgencyD.setPartymemberIncr(partiData.getIncr()); regAgencyD.setPartymemberIncr(partyPartiData.getIncr());
regAgencyD.setResiProportion(new BigDecimal(NumConstant.ONE)); regAgencyD.setResiProportion(new BigDecimal(NumConstant.ONE));
regAgencyD.setPartymemberProportion(null == regData.getTotal() || regData.getTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float)partyRegData.getTotal()/(float)regData.getTotal() ))); regAgencyD.setPartymemberProportion(null == regData.getTotal() || regData.getTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float)partyRegData.getTotal()/(float)regData.getTotal() )));
regAgencyD.setWarmHeartedProportion(null == regData.getTotal() || regData.getTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float)warmRegData.getTotal()/(float)regData.getTotal() ))); regAgencyD.setWarmHeartedProportion(null == regData.getTotal() || regData.getTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float)warmRegData.getTotal()/(float)regData.getTotal() )));
@ -312,7 +314,7 @@ public class UserServiceImpl implements UserService {
regAgencyM.setPartymemberTotal(partyRegData.getTotal()); regAgencyM.setPartymemberTotal(partyRegData.getTotal());
regAgencyM.setRegIncr(regData.getIncr()); regAgencyM.setRegIncr(regData.getIncr());
regAgencyM.setWarmIncr(warmRegData.getIncr()); regAgencyM.setWarmIncr(warmRegData.getIncr());
regAgencyM.setPartymemberIncr(partiData.getIncr()); regAgencyM.setPartymemberIncr(partyPartiData.getIncr());
regAgencyM.setResiProportion(new BigDecimal(NumConstant.ONE)); regAgencyM.setResiProportion(new BigDecimal(NumConstant.ONE));
regAgencyM.setPartymemberProportion(regAgencyD.getPartymemberProportion()); regAgencyM.setPartymemberProportion(regAgencyD.getPartymemberProportion());
regAgencyM.setWarmHeartedProportion(regAgencyD.getWarmHeartedProportion()); regAgencyM.setWarmHeartedProportion(regAgencyD.getWarmHeartedProportion());

Loading…
Cancel
Save