|
|
@ -1,8 +1,8 @@ |
|
|
|
package com.epmet.dataaggre.service.datastats.impl; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|
|
|
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.enums.OrgLevelEnum; |
|
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
|
import com.epmet.dataaggre.constant.DataSourceConstant; |
|
|
|
import com.epmet.dataaggre.constant.OrgConstant; |
|
|
@ -11,20 +11,20 @@ import com.epmet.dataaggre.dao.datastats.FactGridMemberStatisticsDailyDao; |
|
|
|
import com.epmet.dataaggre.dto.datastats.FactGroupActDailyDTO; |
|
|
|
import com.epmet.dataaggre.dto.datastats.form.*; |
|
|
|
import com.epmet.dataaggre.dto.datastats.result.*; |
|
|
|
import com.epmet.dataaggre.dto.govorg.result.GridMemberDataAnalysisResultDTO; |
|
|
|
import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerAgencyDTO; |
|
|
|
import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerGridDTO; |
|
|
|
import com.epmet.dataaggre.dto.evaluationindex.ScreenGovernRankDataDailyDTO; |
|
|
|
import com.epmet.dataaggre.dto.govorg.result.GridMemberDataAnalysisResultDTO; |
|
|
|
import com.epmet.dataaggre.dto.resigroup.ActCategoryDictDTO; |
|
|
|
import com.epmet.dataaggre.dto.resigroup.result.GroupActRankDetailDTO; |
|
|
|
import com.epmet.dataaggre.entity.datastats.DimAgencyEntity; |
|
|
|
import com.epmet.dataaggre.entity.datastats.DimGridEntity; |
|
|
|
import com.epmet.dataaggre.entity.datastats.FactGridMemberStatisticsDailyEntity; |
|
|
|
import com.epmet.dataaggre.entity.datastats.FactAgencyGovernDailyEntity; |
|
|
|
import com.epmet.dataaggre.entity.epmetuser.StatsStaffPatrolRecordDailyEntity; |
|
|
|
import com.epmet.dataaggre.service.datastats.DataStatsService; |
|
|
|
import com.epmet.dataaggre.service.epmetuser.StatsStaffPatrolRecordDailyService; |
|
|
|
import com.epmet.dataaggre.service.evaluationindex.EvaluationIndexService; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.epmet.dataaggre.service.opercrm.CustomerRelation; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
@ -57,6 +57,8 @@ public class DataStatsServiceImpl implements DataStatsService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private FactGridMemberStatisticsDailyDao factGridMemberStatisticsDailyDao; |
|
|
|
@Autowired |
|
|
|
private StatsStaffPatrolRecordDailyService statsStaffPatrolRecordDailyService; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
@ -1428,6 +1430,194 @@ public class DataStatsServiceImpl implements DataStatsService { |
|
|
|
public GridMemberDataAnalysisResultDTO getGridMemberIssueProjectStats(String staffId) { |
|
|
|
return factGridMemberStatisticsDailyDao.getGridMemberIssueProjectStats( staffId); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public BaseStatsDataResultDTO getBaseStatsData(BaseDataFormDTO formDTO) { |
|
|
|
//入参有日期的则按具体时间执行,没有的则按当前时间前一天执行
|
|
|
|
if (StringUtils.isBlank(formDTO.getDateId())) { |
|
|
|
Date yesterday = DateUtils.addDateDays(new Date(), -1); |
|
|
|
SimpleDateFormat format = new SimpleDateFormat(DateUtils.DATE_PATTERN_YYYYMMDD); |
|
|
|
formDTO.setDateId(format.format(yesterday)); |
|
|
|
} |
|
|
|
BaseStatsDataResultDTO result = new BaseStatsDataResultDTO(); |
|
|
|
result.setTopicTotal(0); |
|
|
|
result.setTopicIncr(0); |
|
|
|
|
|
|
|
result.setIssueTotal(0); |
|
|
|
result.setIssueIncr(0); |
|
|
|
result.setProjectTotal(0); |
|
|
|
result.setProjectIncr(0); |
|
|
|
result.setClosedProjectTotal(0); |
|
|
|
result.setClosedProjectIncr(0); |
|
|
|
|
|
|
|
|
|
|
|
//0.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表
|
|
|
|
List<String> agencyList = indexService.getAgencyIdsByAgencyId(formDTO.getAgencyId()); |
|
|
|
agencyList.add(formDTO.getAgencyId()); |
|
|
|
TotalAndIncrResultDTO sum = dataStatsDao.getAgencySumTopic(agencyList, formDTO.getDateId()); |
|
|
|
if (sum == null){ |
|
|
|
return result; |
|
|
|
} |
|
|
|
result.setTopicIncr(sum.getIncr()); |
|
|
|
result.setTopicTotal(sum.getTotal()); |
|
|
|
|
|
|
|
sum = dataStatsDao.getAgencySumIssue(agencyList,formDTO.getDateId()); |
|
|
|
result.setIssueIncr(sum.getIncr()); |
|
|
|
result.setIssueTotal(sum.getTotal()); |
|
|
|
|
|
|
|
sum = dataStatsDao.getAgencySumProject(agencyList,formDTO.getDateId()); |
|
|
|
result.setProjectIncr(sum.getIncr()); |
|
|
|
result.setProjectTotal(sum.getTotal()); |
|
|
|
result.setClosedProjectIncr(sum.getIncr2()); |
|
|
|
result.setClosedProjectTotal(sum.getTotal2()); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<WorkFactResultDTO> getSubWorkFact(BaseDataFormDTO formDTO) { |
|
|
|
//入参有日期的则按具体时间执行,没有的则按当前时间前一天执行
|
|
|
|
if (StringUtils.isBlank(formDTO.getType())){ |
|
|
|
formDTO.setType("yesterday"); |
|
|
|
} |
|
|
|
Date yesterday = DateUtils.addDateDays(new Date(), -1); |
|
|
|
if (StringUtils.isBlank(formDTO.getDateId())) { |
|
|
|
SimpleDateFormat format = new SimpleDateFormat(DateUtils.DATE_PATTERN_YYYYMMDD); |
|
|
|
formDTO.setDateId(format.format(yesterday)); |
|
|
|
} |
|
|
|
String startDate = null; |
|
|
|
String endDate = null; |
|
|
|
Date dateIdDate = DateUtils.parse(formDTO.getDateId(), DateUtils.DATE_PATTERN_YYYYMMDD); |
|
|
|
boolean isYesterday = DateUtils.getBeforeNDay(1,DateUtils.DATE_PATTERN_YYYYMMDD).equals(formDTO.getDateId()); |
|
|
|
switch (formDTO.getType()){ |
|
|
|
case "yesterday": |
|
|
|
startDate = DateUtils.getBeforeNDay(formDTO.getDateId(),1); |
|
|
|
endDate = formDTO.getDateId(); |
|
|
|
break; |
|
|
|
case "thisWeek": |
|
|
|
startDate = DateUtils.getWeekStart(formDTO.getDateId()); |
|
|
|
startDate = DateUtils.getBeforeNDay(startDate,1); |
|
|
|
DateUtils.format(DateUtils.addDateDays(yesterday, -1),DateUtils.DATE_PATTERN_YYYYMMDD); |
|
|
|
if (!isYesterday){ |
|
|
|
endDate = DateUtils.getWeekEnd(formDTO.getDateId()); |
|
|
|
} |
|
|
|
break; |
|
|
|
case "thisMonth": |
|
|
|
startDate = DateUtils.format(DateUtils.getMonthStart(dateIdDate),DateUtils.DATE_PATTERN_YYYYMMDD); |
|
|
|
startDate = DateUtils.getBeforeNDay(startDate,1); |
|
|
|
if (!isYesterday) { |
|
|
|
endDate = DateUtils.format(DateUtils.getMonthEnd(dateIdDate), DateUtils.DATE_PATTERN_YYYYMMDD); |
|
|
|
} |
|
|
|
break; |
|
|
|
default: |
|
|
|
log.warn("==========="); |
|
|
|
} |
|
|
|
formDTO.setStartDateId(startDate); |
|
|
|
formDTO.setEndDateId(endDate); |
|
|
|
List<WorkFactResultDTO> result = new ArrayList<>(); |
|
|
|
//如果是社区 则下级是网格 查询网格的数据
|
|
|
|
if (OrgLevelEnum.COMMUNITY.getCode().equals(formDTO.getAgencyLevel())){ |
|
|
|
//0.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表
|
|
|
|
List<ScreenCustomerGridDTO> subAgencyList = indexService.getSubGridList(formDTO.getAgencyId()); |
|
|
|
if (subAgencyList.size() < NumConstant.ONE) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
List<String> gridIdList = subAgencyList.stream().map(ScreenCustomerGridDTO::getGridId).collect(Collectors.toList()); |
|
|
|
//查询组织的话题转议题数据
|
|
|
|
List<SubGridFormDTO.Topic> toIssueStart = dataStatsDao.getSubGridTopicShiftIssue(gridIdList, formDTO.getStartDateId()); |
|
|
|
List<SubGridFormDTO.Topic> toIssueEnd = dataStatsDao.getSubGridTopicShiftIssue(gridIdList, formDTO.getEndDateId()); |
|
|
|
Map<String, Integer> toIssueStartMap = toIssueStart.stream().collect(Collectors.toMap(SubGridFormDTO.Topic::getGridId, SubGridFormDTO.Topic::getShiftedIssueTotal, (o1, o2) -> o1)); |
|
|
|
Map<String, Integer> toIssueEndMap = toIssueEnd.stream().collect(Collectors.toMap(SubGridFormDTO.Topic::getGridId, SubGridFormDTO.Topic::getShiftedIssueTotal, (o1, o2) -> o1)); |
|
|
|
//查询组织的议题转项目数据
|
|
|
|
List<SubGridIssueResultDTO> toProjectStart = dataStatsDao.getSubGridIssue(gridIdList, formDTO.getStartDateId()); |
|
|
|
List<SubGridIssueResultDTO> toProjectEnd = dataStatsDao.getSubGridIssue(gridIdList, formDTO.getEndDateId()); |
|
|
|
Map<String, Integer> toProjectStartMap = toProjectStart.stream().collect(Collectors.toMap(SubGridIssueResultDTO::getGridId, SubGridIssueResultDTO::getShiftProjectTotal, (o1, o2) -> o1)); |
|
|
|
Map<String, Integer> toProjectEndMap = toProjectEnd.stream().collect(Collectors.toMap(SubGridIssueResultDTO::getGridId, SubGridIssueResultDTO::getShiftProjectTotal, (o1, o2) -> o1)); |
|
|
|
//查询组织已关闭的项目数据
|
|
|
|
List<SubGridProjectResultDTO> closeProjectStart = dataStatsDao.getSubGridProject(gridIdList, formDTO.getStartDateId()); |
|
|
|
List<SubGridProjectResultDTO> closeProjectEnd = dataStatsDao.getSubGridProject(gridIdList, formDTO.getEndDateId()); |
|
|
|
Map<String, Integer> closeProjectStartMap = closeProjectStart.stream().collect(Collectors.toMap(SubGridProjectResultDTO::getGridId, SubGridProjectResultDTO::getClosedProjectTotal, (o1, o2) -> o1)); |
|
|
|
Map<String, Integer> closeProjectEndMap = closeProjectEnd.stream().collect(Collectors.toMap(SubGridProjectResultDTO::getGridId, SubGridProjectResultDTO::getClosedProjectTotal, (o1, o2) -> o1)); |
|
|
|
//巡查次数和时间
|
|
|
|
List<StatsStaffPatrolRecordDailyEntity> patrolList = statsStaffPatrolRecordDailyService.getPatrolSumList(gridIdList,formDTO.getStartDateId(),formDTO.getEndDateId()); |
|
|
|
Map<String, StatsStaffPatrolRecordDailyEntity> patrolListMap = patrolList.stream().collect(Collectors.toMap(StatsStaffPatrolRecordDailyEntity::getAgencyId, o -> o, (o1, o2) -> o1)); |
|
|
|
|
|
|
|
subAgencyList.forEach(agency->{ |
|
|
|
String gridId = agency.getGridId(); |
|
|
|
WorkFactResultDTO resultDTO = new WorkFactResultDTO(); |
|
|
|
resultDTO.setOrgId(gridId); |
|
|
|
resultDTO.setOrgName(agency.getGridName()); |
|
|
|
resultDTO.setTopicToIssueTotal(getTotal(toIssueStartMap,toIssueEndMap,gridId)); |
|
|
|
resultDTO.setIssueToProjectTotal(getTotal(toProjectStartMap,toProjectEndMap,gridId)); |
|
|
|
resultDTO.setClosedProjectTotal(getTotal(closeProjectStartMap,closeProjectEndMap,gridId)); |
|
|
|
StatsStaffPatrolRecordDailyEntity patrolRecordDTO = patrolListMap.get(gridId); |
|
|
|
if (patrolRecordDTO != null){ |
|
|
|
resultDTO.setPatrolTotal(patrolRecordDTO.getPatrolTotal()); |
|
|
|
Integer totalTime = patrolRecordDTO.getTotalTime(); |
|
|
|
int minutes = totalTime / 60; |
|
|
|
String totalTimeDesc = minutes / 60 + "小时"+ minutes % 60 + "分"; |
|
|
|
resultDTO.setPatrolTotalTime(totalTimeDesc); |
|
|
|
} |
|
|
|
result.add(resultDTO); |
|
|
|
}); |
|
|
|
}else { |
|
|
|
//0.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表
|
|
|
|
List<ScreenCustomerAgencyDTO> subAgencyList = indexService.getSubAgencyListByAgency(formDTO.getAgencyId()); |
|
|
|
if (subAgencyList.size() < NumConstant.ONE) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
List<String> agencyList = subAgencyList.stream().map(ScreenCustomerAgencyDTO::getAgencyId).collect(Collectors.toList()); |
|
|
|
//查询组织的话题转议题数据
|
|
|
|
List<SubAgencyFormDTO.Topic> toIssueStart = dataStatsDao.getSubAgencyTopicShiftIssue(agencyList, formDTO.getStartDateId()); |
|
|
|
List<SubAgencyFormDTO.Topic> toIssueEnd = dataStatsDao.getSubAgencyTopicShiftIssue(agencyList, formDTO.getEndDateId()); |
|
|
|
Map<String, Integer> toIssueStartMap = toIssueStart.stream().collect(Collectors.toMap(SubAgencyFormDTO.Topic::getAgencyId, SubAgencyFormDTO.Topic::getShiftedIssueTotal, (o1, o2) -> o1)); |
|
|
|
Map<String, Integer> toIssueEndMap = toIssueEnd.stream().collect(Collectors.toMap(SubAgencyFormDTO.Topic::getAgencyId, SubAgencyFormDTO.Topic::getShiftedIssueTotal, (o1, o2) -> o1)); |
|
|
|
//查询组织的议题转项目数据
|
|
|
|
List<SubAgencyIssueResultDTO> toProjectStart = dataStatsDao.getSubAgencyIssue(agencyList, formDTO.getStartDateId()); |
|
|
|
List<SubAgencyIssueResultDTO> toProjectEnd = dataStatsDao.getSubAgencyIssue(agencyList, formDTO.getEndDateId()); |
|
|
|
Map<String, Integer> toProjectStartMap = toProjectStart.stream().collect(Collectors.toMap(SubAgencyIssueResultDTO::getAgencyId, SubAgencyIssueResultDTO::getShiftProjectTotal, (o1, o2) -> o1)); |
|
|
|
Map<String, Integer> toProjectEndMap = toProjectEnd.stream().collect(Collectors.toMap(SubAgencyIssueResultDTO::getAgencyId, SubAgencyIssueResultDTO::getShiftProjectTotal, (o1, o2) -> o1)); |
|
|
|
//查询组织已关闭的项目数据
|
|
|
|
List<SubAgencyProjectResultDTO> closeProjectStart = dataStatsDao.getSubAgencyProject(agencyList, formDTO.getStartDateId()); |
|
|
|
List<SubAgencyProjectResultDTO> closeProjectEnd = dataStatsDao.getSubAgencyProject(agencyList, formDTO.getEndDateId()); |
|
|
|
Map<String, Integer> closeProjectStartMap = closeProjectStart.stream().collect(Collectors.toMap(SubAgencyProjectResultDTO::getAgencyId, SubAgencyProjectResultDTO::getClosedProjectTotal, (o1, o2) -> o1)); |
|
|
|
Map<String, Integer> closeProjectEndMap = closeProjectEnd.stream().collect(Collectors.toMap(SubAgencyProjectResultDTO::getAgencyId, SubAgencyProjectResultDTO::getClosedProjectTotal, (o1, o2) -> o1)); |
|
|
|
//巡查次数和时间
|
|
|
|
List<StatsStaffPatrolRecordDailyEntity> patrolList = statsStaffPatrolRecordDailyService.getPatrolSumList(agencyList,formDTO.getStartDateId(),formDTO.getEndDateId()); |
|
|
|
Map<String, StatsStaffPatrolRecordDailyEntity> patrolListMap = patrolList.stream().collect(Collectors.toMap(StatsStaffPatrolRecordDailyEntity::getAgencyId, o -> o, (o1, o2) -> o1)); |
|
|
|
|
|
|
|
subAgencyList.forEach(agency->{ |
|
|
|
String agencyId = agency.getAgencyId(); |
|
|
|
WorkFactResultDTO resultDTO = new WorkFactResultDTO(); |
|
|
|
resultDTO.setOrgId(agencyId); |
|
|
|
resultDTO.setOrgName(agency.getAgencyName()); |
|
|
|
resultDTO.setTopicToIssueTotal(getTotal(toIssueStartMap,toIssueEndMap,agencyId)); |
|
|
|
resultDTO.setIssueToProjectTotal(getTotal(toProjectStartMap,toProjectEndMap,agencyId)); |
|
|
|
resultDTO.setClosedProjectTotal(getTotal(closeProjectStartMap,closeProjectEndMap,agencyId)); |
|
|
|
StatsStaffPatrolRecordDailyEntity patrolRecordDTO = patrolListMap.get(agencyId); |
|
|
|
if (patrolRecordDTO != null){ |
|
|
|
resultDTO.setPatrolTotal(patrolRecordDTO.getPatrolTotal()); |
|
|
|
Integer totalTime = patrolRecordDTO.getTotalTime(); |
|
|
|
int minutes = totalTime / 60; |
|
|
|
String totalTimeDesc = minutes / 60 + "小时"+ minutes % 60 + "分"; |
|
|
|
resultDTO.setPatrolTotalTime(totalTimeDesc); |
|
|
|
} |
|
|
|
result.add(resultDTO); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
List<WorkFactResultDTO> newResult = result.stream().sorted(Comparator.comparing(o -> o.getTopicToIssueTotal() + o.getIssueToProjectTotal() + o.getClosedProjectTotal() + o.getPatrolTotal())).collect(Collectors.toList()); |
|
|
|
return newResult; |
|
|
|
} |
|
|
|
private Integer getTotal(Map<String,Integer> startMap, Map<String,Integer> endMap,String agencyId){ |
|
|
|
Integer total1 = startMap.getOrDefault(agencyId,NumConstant.ZERO); |
|
|
|
Integer total2 = endMap.getOrDefault(agencyId,NumConstant.ZERO); |
|
|
|
if (total1.equals(total2)){ |
|
|
|
log.warn("===========相等,total:{}",total1); |
|
|
|
} |
|
|
|
return Math.max(total2-total1,0); |
|
|
|
} |
|
|
|
|
|
|
|
private String getPercentage(Integer countInt, Integer totalInt) { |
|
|
|
if (NumConstant.ZERO == totalInt) { |
|
|
|
return "0%"; |
|
|
@ -1439,4 +1629,172 @@ public class DataStatsServiceImpl implements DataStatsService { |
|
|
|
return ratio.toString().concat("%"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Param formDTO |
|
|
|
* @Description 对外接口--查询下级用户党员数 |
|
|
|
* @author sun |
|
|
|
* @param formDTO |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<SubUserTotalResultDTO> subUserTotal(BaseDataFormDTO formDTO) { |
|
|
|
List<SubUserTotalResultDTO> resultList = new ArrayList<>(); |
|
|
|
//1.入参有日期的则按具体时间执行,没有的则按当前时间前一天执行
|
|
|
|
if (StringUtils.isBlank(formDTO.getDateId())) { |
|
|
|
Date yesterday = DateUtils.addDateDays(new Date(), -1); |
|
|
|
SimpleDateFormat format = new SimpleDateFormat(DateUtils.DATE_PATTERN_YYYYMMDD); |
|
|
|
formDTO.setDateId(format.format(yesterday)); |
|
|
|
} |
|
|
|
|
|
|
|
//根据组织级别判断查询直属下级组织或网格数据
|
|
|
|
//2.直属网格
|
|
|
|
if ("community".equals(formDTO.getAgencyLevel())) { |
|
|
|
//2-1.查询组织直属网格列表【网格维度】
|
|
|
|
List<ScreenCustomerGridDTO> gridList = indexService.getSubGridList(formDTO.getAgencyId()); |
|
|
|
if (gridList.size() < NumConstant.ONE) { |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
List<String> gridIds = gridList.stream().map(ScreenCustomerGridDTO::getGridId).collect(Collectors.toList()); |
|
|
|
//2-2.查询网格下用户、党员日统计数据,按用户总数降序
|
|
|
|
List<SubGridUserResultDTO> list = dataStatsDao.getSubGridUser(gridIds, formDTO.getDateId()); |
|
|
|
//2-3.封装数据
|
|
|
|
gridList.forEach(gr -> { |
|
|
|
SubUserTotalResultDTO dto = new SubUserTotalResultDTO(); |
|
|
|
dto.setOrgId(gr.getGridId()); |
|
|
|
dto.setOrgName(gr.getGridName()); |
|
|
|
list.forEach(re -> { |
|
|
|
if (gr.getGridId().equals(re.getGridId())) { |
|
|
|
dto.setUserTotal(re.getUserTotal()); |
|
|
|
dto.setPartyMemberTotal(re.getPartyMemberTotal()); |
|
|
|
} |
|
|
|
}); |
|
|
|
resultList.add(dto); |
|
|
|
}); |
|
|
|
|
|
|
|
} else { |
|
|
|
//3.直属组织
|
|
|
|
//3-1.查询直属下级组织列表,有子客户的按areaCode查没有的按agencyId查
|
|
|
|
List<ScreenCustomerAgencyDTO> subAgencyList = indexService.getSubAgencyListByAgency(formDTO.getAgencyId()); |
|
|
|
if (subAgencyList.size() < NumConstant.ONE) { |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
List<String> agencyIds = subAgencyList.stream().map(ScreenCustomerAgencyDTO::getAgencyId).collect(Collectors.toList()); |
|
|
|
//3-2.查询组织下用户、党员日统计数据,按用户总数降序
|
|
|
|
List<SubAgencyUserResultDTO> list = dataStatsDao.getSubAgencyUser(agencyIds, formDTO.getDateId()); |
|
|
|
//3-3.封装数据
|
|
|
|
subAgencyList.forEach(sub -> { |
|
|
|
SubUserTotalResultDTO dto = new SubUserTotalResultDTO(); |
|
|
|
dto.setOrgId(sub.getAgencyId()); |
|
|
|
dto.setOrgName(sub.getAgencyName()); |
|
|
|
list.forEach(u -> { |
|
|
|
if (sub.getAgencyId().equals(u.getAgencyId())) { |
|
|
|
dto.setUserTotal(u.getUserTotal()); |
|
|
|
dto.setPartyMemberTotal(u.getPartyMemberTotal()); |
|
|
|
} |
|
|
|
}); |
|
|
|
resultList.add(dto); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
//4.按用户数降序排序并返回
|
|
|
|
Collections.sort(resultList, new Comparator<SubUserTotalResultDTO>() { |
|
|
|
@Override |
|
|
|
public int compare(SubUserTotalResultDTO o1, SubUserTotalResultDTO o2) { |
|
|
|
//降序
|
|
|
|
return o2.getUserTotal().compareTo(o1.getUserTotal()); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Param formDTO |
|
|
|
* @Description 对外接口--查询下级话题和小组数 |
|
|
|
* @author sun |
|
|
|
* @param formDTO |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<SubTopicAndGroupResultDTO> subTopicAndGroup(BaseDataFormDTO formDTO) { |
|
|
|
List<SubTopicAndGroupResultDTO> resultList = new ArrayList<>(); |
|
|
|
//1.入参有日期的则按具体时间执行,没有的则按当前时间前一天执行
|
|
|
|
if (StringUtils.isBlank(formDTO.getDateId())) { |
|
|
|
Date yesterday = DateUtils.addDateDays(new Date(), -1); |
|
|
|
SimpleDateFormat format = new SimpleDateFormat(DateUtils.DATE_PATTERN_YYYYMMDD); |
|
|
|
formDTO.setDateId(format.format(yesterday)); |
|
|
|
} |
|
|
|
|
|
|
|
//根据组织级别判断查询直属下级组织或网格数据
|
|
|
|
//2.直属网格
|
|
|
|
if ("community".equals(formDTO.getAgencyLevel())) { |
|
|
|
//2-1.查询组织直属网格列表【网格维度】
|
|
|
|
List<ScreenCustomerGridDTO> gridList = indexService.getSubGridList(formDTO.getAgencyId()); |
|
|
|
if (gridList.size() < NumConstant.ONE) { |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
List<String> gridIds = gridList.stream().map(ScreenCustomerGridDTO::getGridId).collect(Collectors.toList()); |
|
|
|
//2-2.查询网格下热议中话题日统计数据
|
|
|
|
List<SubGridFormDTO.Topic> hotdiscuss = dataStatsDao.getSubGridTopicHotDiscuss(gridIds, formDTO.getDateId()); |
|
|
|
//2-2.查询网格层级小组日统计数据
|
|
|
|
List<SubGridGroupResultDTO> list = dataStatsDao.getSubGridGroup(gridIds, formDTO.getDateId()); |
|
|
|
//2-3.封装数据
|
|
|
|
gridList.forEach(gr -> { |
|
|
|
SubTopicAndGroupResultDTO resultDTO = new SubTopicAndGroupResultDTO(); |
|
|
|
resultDTO.setOrgId(gr.getGridId()); |
|
|
|
resultDTO.setOrgName(gr.getGridName()); |
|
|
|
hotdiscuss.forEach(t -> { |
|
|
|
if (t.getGridId().equals(gr.getGridId())) { |
|
|
|
resultDTO.setTopicTotal(t.getTopicTotal()); |
|
|
|
} |
|
|
|
}); |
|
|
|
list.forEach(l -> { |
|
|
|
if (l.getGridId().equals(gr.getGridId())) { |
|
|
|
resultDTO.setGroupTotal(l.getGroupTotal()); |
|
|
|
} |
|
|
|
}); |
|
|
|
resultList.add(resultDTO); |
|
|
|
}); |
|
|
|
|
|
|
|
} else { |
|
|
|
//3.直属组织
|
|
|
|
//3-1.查询直属下级组织列表,有子客户的按areaCode查没有的按agencyId查
|
|
|
|
List<ScreenCustomerAgencyDTO> subAgencyList = indexService.getSubAgencyListByAgency(formDTO.getAgencyId()); |
|
|
|
if (subAgencyList.size() < NumConstant.ONE) { |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
List<String> agencyIds = subAgencyList.stream().map(ScreenCustomerAgencyDTO::getAgencyId).collect(Collectors.toList()); |
|
|
|
//3-2.查询组织下热议中话题日统计数据
|
|
|
|
List<SubAgencyFormDTO.Topic> hotdiscuss = dataStatsDao.getSubAgencyTopicHotDiscuss(agencyIds, formDTO.getDateId()); |
|
|
|
//3-3.查询直属下级组织小组日统计数据
|
|
|
|
List<SubAgencyGroupResultDTO> list = dataStatsDao.getSubAgencyGroup(agencyIds, formDTO.getDateId()); |
|
|
|
//3-4.封装数据
|
|
|
|
subAgencyList.forEach(sub -> { |
|
|
|
SubTopicAndGroupResultDTO resultDTO = new SubTopicAndGroupResultDTO(); |
|
|
|
resultDTO.setOrgId(sub.getAgencyId()); |
|
|
|
resultDTO.setOrgName(sub.getAgencyName()); |
|
|
|
hotdiscuss.forEach(t -> { |
|
|
|
if (t.getAgencyId().equals(sub.getAgencyId())) { |
|
|
|
resultDTO.setTopicTotal(t.getTopicTotal()); |
|
|
|
} |
|
|
|
}); |
|
|
|
list.forEach(u -> { |
|
|
|
if (sub.getAgencyId().equals(u.getAgencyId())) { |
|
|
|
resultDTO.setGroupTotal(u.getGroupTotal()); |
|
|
|
} |
|
|
|
}); |
|
|
|
resultList.add(resultDTO); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
//4.按用户数降序排序并返回
|
|
|
|
Collections.sort(resultList, new Comparator<SubTopicAndGroupResultDTO>() { |
|
|
|
@Override |
|
|
|
public int compare(SubTopicAndGroupResultDTO o1, SubTopicAndGroupResultDTO o2) { |
|
|
|
//降序
|
|
|
|
return o2.getTopicTotal().compareTo(o1.getTopicTotal()); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|