|
|
@ -1531,12 +1531,66 @@ public class DataStatsServiceImpl implements DataStatsService { |
|
|
|
formDTO.setDateId(format.format(yesterday)); |
|
|
|
} |
|
|
|
|
|
|
|
//2.
|
|
|
|
//3.
|
|
|
|
//4.
|
|
|
|
//根据组织级别判断查询直属下级组织或网格数据
|
|
|
|
//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); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
//4.按用户数降序排序并返回
|
|
|
|
Collections.sort(resultList, new Comparator<SubUserTotalResultDTO>() { |
|
|
|
@Override |
|
|
|
public int compare(SubUserTotalResultDTO o1, SubUserTotalResultDTO o2) { |
|
|
|
//降序
|
|
|
|
return o2.getUserTotal().compareTo(o1.getUserTotal()); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -1546,7 +1600,86 @@ public class DataStatsServiceImpl implements DataStatsService { |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<SubTopicAndGroupResultDTO> subTopicAndGroup(SubTopicAndGroupFormDTO formDTO) { |
|
|
|
return null; |
|
|
|
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; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|