|
@ -1933,16 +1933,13 @@ public class DataStatsServiceImpl implements DataStatsService { |
|
|
* @author sun |
|
|
* @author sun |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public List<CustomerDataManageResultDTO> operateExport(CustomerDataManageFormDTO formDTO) throws ParseException { |
|
|
public CustomerDataManageResultDTO operateExport(CustomerDataManageFormDTO formDTO) throws ParseException { |
|
|
List<CustomerDataManageResultDTO> resultList = new ArrayList<>(); |
|
|
CustomerDataManageResultDTO resultDTO = new CustomerDataManageResultDTO(); |
|
|
|
|
|
List<CustomerDataManageResultDTO.CustomerDataManage> dataManageList = new ArrayList<>(); |
|
|
//1.必要参数校验及处理
|
|
|
//1.必要参数校验及处理
|
|
|
if ("Interval".equals(formDTO.getType()) && StringUtils.isEmpty(formDTO.getStartTime())) { |
|
|
if ("Interval".equals(formDTO.getType()) && StringUtils.isEmpty(formDTO.getStartTime())) { |
|
|
throw new RenException("请选择开始时间或查询累计值"); |
|
|
throw new RenException("请选择开始时间或查询累计值"); |
|
|
} |
|
|
} |
|
|
if (formDTO.getIsPage()) { |
|
|
|
|
|
int pageIndex = (formDTO.getPageNo() - NumConstant.ONE) * formDTO.getPageSize(); |
|
|
|
|
|
formDTO.setPageNo(pageIndex); |
|
|
|
|
|
} |
|
|
|
|
|
//入参有开始时间的则需要减去一天
|
|
|
//入参有开始时间的则需要减去一天
|
|
|
if (StringUtils.isNotBlank(formDTO.getStartTime())) { |
|
|
if (StringUtils.isNotBlank(formDTO.getStartTime())) { |
|
|
SimpleDateFormat format = new SimpleDateFormat(DateUtils.DATE_PATTERN_YYYYMMDD); |
|
|
SimpleDateFormat format = new SimpleDateFormat(DateUtils.DATE_PATTERN_YYYYMMDD); |
|
@ -1954,27 +1951,29 @@ public class DataStatsServiceImpl implements DataStatsService { |
|
|
//2.查询组织信息,判断查询下级组织还是网格数据
|
|
|
//2.查询组织信息,判断查询下级组织还是网格数据
|
|
|
ScreenAgencyOrGridListDTO agencyGrid = indexService.getSubAgencyOrGridList(formDTO.getAgencyId()); |
|
|
ScreenAgencyOrGridListDTO agencyGrid = indexService.getSubAgencyOrGridList(formDTO.getAgencyId()); |
|
|
if (null == agencyGrid) { |
|
|
if (null == agencyGrid) { |
|
|
return new ArrayList<>(); |
|
|
return new CustomerDataManageResultDTO(); |
|
|
} |
|
|
} |
|
|
//组织或网格Id集合
|
|
|
//组织或网格Id集合
|
|
|
List<String> idList = agencyGrid.getAgencyGridList().stream().map(ScreenAgencyOrGridListDTO.AgencyGrid::getOrgId).collect(Collectors.toList()); |
|
|
List<String> idList = agencyGrid.getAgencyGridList().stream().map(ScreenAgencyOrGridListDTO.AgencyGrid::getOrgId).collect(Collectors.toList()); |
|
|
formDTO.setDataType(!"community".equals(agencyGrid.getLevel()) ? "agency" : "grid"); |
|
|
formDTO.setDataType(!"community".equals(agencyGrid.getLevel()) ? "agency" : "grid"); |
|
|
formDTO.setIdList(idList); |
|
|
formDTO.setIdList(idList); |
|
|
|
|
|
resultDTO.setTotal(idList.size()); |
|
|
|
|
|
|
|
|
//3.查询截止日期用户、群组、话题、议题、项目、巡查数据
|
|
|
//3.查询截止日期用户、群组、话题、议题、项目、巡查数据
|
|
|
List<CustomerDataManageResultDTO> userEnd = dataStatsDao.regUserList(formDTO); |
|
|
List<CustomerDataManageResultDTO.CustomerDataManage> userEnd = dataStatsDao.regUserList(formDTO); |
|
|
List<CustomerDataManageResultDTO> groupEnd = dataStatsDao.groupList(formDTO); |
|
|
List<CustomerDataManageResultDTO.CustomerDataManage> groupEnd = dataStatsDao.groupList(formDTO); |
|
|
List<CustomerDataManageResultDTO> topicEnd = dataStatsDao.topicList(formDTO); |
|
|
List<CustomerDataManageResultDTO.CustomerDataManage> topicEnd = dataStatsDao.topicList(formDTO); |
|
|
List<CustomerDataManageResultDTO> issueEnd = dataStatsDao.issueList(formDTO); |
|
|
List<CustomerDataManageResultDTO.CustomerDataManage> issueEnd = dataStatsDao.issueList(formDTO); |
|
|
List<CustomerDataManageResultDTO> projectEnd = dataStatsDao.projectList(formDTO); |
|
|
List<CustomerDataManageResultDTO.CustomerDataManage> projectEnd = dataStatsDao.projectList(formDTO); |
|
|
List<CustomerDataManageResultDTO> patrolEnd = statsStaffPatrolRecordDailyService.patrolList(formDTO); |
|
|
//巡查数据不区分区间差值,只计算累计值,人员做去重处理且是有巡查记录的人员
|
|
|
|
|
|
List<CustomerDataManageResultDTO.CustomerDataManage> patrolEnd = statsStaffPatrolRecordDailyService.patrolList(formDTO); |
|
|
|
|
|
|
|
|
//4.判断是否需要查询起始日期用户、群组、话题、议题、项目、巡查数据
|
|
|
//4.判断是否需要查询起始日期用户、群组、话题、议题、项目、巡查数据
|
|
|
List<CustomerDataManageResultDTO> userStart = new ArrayList<>(); |
|
|
List<CustomerDataManageResultDTO.CustomerDataManage> userStart = new ArrayList<>(); |
|
|
List<CustomerDataManageResultDTO> groupStart = new ArrayList<>(); |
|
|
List<CustomerDataManageResultDTO.CustomerDataManage> groupStart = new ArrayList<>(); |
|
|
List<CustomerDataManageResultDTO> topicStart = new ArrayList<>(); |
|
|
List<CustomerDataManageResultDTO.CustomerDataManage> topicStart = new ArrayList<>(); |
|
|
List<CustomerDataManageResultDTO> issueStart = new ArrayList<>(); |
|
|
List<CustomerDataManageResultDTO.CustomerDataManage> issueStart = new ArrayList<>(); |
|
|
List<CustomerDataManageResultDTO> projectStart = new ArrayList<>(); |
|
|
List<CustomerDataManageResultDTO.CustomerDataManage> projectStart = new ArrayList<>(); |
|
|
if ("Interval".equals(formDTO.getType())) { |
|
|
if ("Interval".equals(formDTO.getType())) { |
|
|
userStart = dataStatsDao.regUserList(formDTO); |
|
|
userStart = dataStatsDao.regUserList(formDTO); |
|
|
groupStart = dataStatsDao.groupList(formDTO); |
|
|
groupStart = dataStatsDao.groupList(formDTO); |
|
@ -1984,25 +1983,25 @@ public class DataStatsServiceImpl implements DataStatsService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//5.封装数据
|
|
|
//5.封装数据
|
|
|
List<CustomerDataManageResultDTO> finalUserStart = userStart; |
|
|
List<CustomerDataManageResultDTO.CustomerDataManage> finalUserStart = userStart; |
|
|
List<CustomerDataManageResultDTO> finalGroupStart = groupStart; |
|
|
List<CustomerDataManageResultDTO.CustomerDataManage> finalGroupStart = groupStart; |
|
|
List<CustomerDataManageResultDTO> finalTopicStart = topicStart; |
|
|
List<CustomerDataManageResultDTO.CustomerDataManage> finalTopicStart = topicStart; |
|
|
List<CustomerDataManageResultDTO> finalIssueStart = issueStart; |
|
|
List<CustomerDataManageResultDTO.CustomerDataManage> finalIssueStart = issueStart; |
|
|
List<CustomerDataManageResultDTO> finalProjectStart = projectStart; |
|
|
List<CustomerDataManageResultDTO.CustomerDataManage> finalProjectStart = projectStart; |
|
|
agencyGrid.getAgencyGridList().forEach(org -> { |
|
|
agencyGrid.getAgencyGridList().forEach(org -> { |
|
|
CustomerDataManageResultDTO dto = new CustomerDataManageResultDTO(); |
|
|
CustomerDataManageResultDTO.CustomerDataManage dto = new CustomerDataManageResultDTO.CustomerDataManage(); |
|
|
dto.setOrgId(org.getOrgId()); |
|
|
dto.setOrgId(org.getOrgId()); |
|
|
dto.setOrgName(org.getOrgName()); |
|
|
dto.setOrgName(org.getOrgName()); |
|
|
int user = 0; |
|
|
int user = 0; |
|
|
int resi = 0; |
|
|
int resi = 0; |
|
|
int part = 0; |
|
|
int part = 0; |
|
|
for (CustomerDataManageResultDTO u : userEnd) { |
|
|
for (CustomerDataManageResultDTO.CustomerDataManage u : userEnd) { |
|
|
if (org.getOrgId().equals(u.getOrgId())) { |
|
|
if (org.getOrgId().equals(u.getOrgId())) { |
|
|
user = u.getUserCount(); |
|
|
user = u.getUserCount(); |
|
|
resi = u.getResidentCount(); |
|
|
resi = u.getResidentCount(); |
|
|
part = u.getPartyMemberCount(); |
|
|
part = u.getPartyMemberCount(); |
|
|
if ("Interval".equals(formDTO.getType())) { |
|
|
if ("Interval".equals(formDTO.getType())) { |
|
|
for (CustomerDataManageResultDTO s : finalUserStart) { |
|
|
for (CustomerDataManageResultDTO.CustomerDataManage s : finalUserStart) { |
|
|
if (u.getOrgId().equals(s.getOrgId())) { |
|
|
if (u.getOrgId().equals(s.getOrgId())) { |
|
|
user = user - s.getUserCount(); |
|
|
user = user - s.getUserCount(); |
|
|
resi = resi - s.getResidentCount(); |
|
|
resi = resi - s.getResidentCount(); |
|
@ -2013,11 +2012,11 @@ public class DataStatsServiceImpl implements DataStatsService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
int group = 0; |
|
|
int group = 0; |
|
|
for (CustomerDataManageResultDTO u : groupEnd) { |
|
|
for (CustomerDataManageResultDTO.CustomerDataManage u : groupEnd) { |
|
|
if (org.getOrgId().equals(u.getOrgId())) { |
|
|
if (org.getOrgId().equals(u.getOrgId())) { |
|
|
group = u.getGroupCount(); |
|
|
group = u.getGroupCount(); |
|
|
if ("Interval".equals(formDTO.getType())) { |
|
|
if ("Interval".equals(formDTO.getType())) { |
|
|
for (CustomerDataManageResultDTO s : finalGroupStart) { |
|
|
for (CustomerDataManageResultDTO.CustomerDataManage s : finalGroupStart) { |
|
|
if (u.getOrgId().equals(s.getOrgId())) { |
|
|
if (u.getOrgId().equals(s.getOrgId())) { |
|
|
group = group - s.getGroupCount(); |
|
|
group = group - s.getGroupCount(); |
|
|
} |
|
|
} |
|
@ -2026,11 +2025,11 @@ public class DataStatsServiceImpl implements DataStatsService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
int topic = 0; |
|
|
int topic = 0; |
|
|
for (CustomerDataManageResultDTO u : topicEnd) { |
|
|
for (CustomerDataManageResultDTO.CustomerDataManage u : topicEnd) { |
|
|
if (org.getOrgId().equals(u.getOrgId())) { |
|
|
if (org.getOrgId().equals(u.getOrgId())) { |
|
|
topic = u.getTopicCount(); |
|
|
topic = u.getTopicCount(); |
|
|
if ("Interval".equals(formDTO.getType())) { |
|
|
if ("Interval".equals(formDTO.getType())) { |
|
|
for (CustomerDataManageResultDTO s : finalTopicStart) { |
|
|
for (CustomerDataManageResultDTO.CustomerDataManage s : finalTopicStart) { |
|
|
if (u.getOrgId().equals(s.getOrgId())) { |
|
|
if (u.getOrgId().equals(s.getOrgId())) { |
|
|
topic = topic - s.getTopicCount(); |
|
|
topic = topic - s.getTopicCount(); |
|
|
} |
|
|
} |
|
@ -2039,11 +2038,11 @@ public class DataStatsServiceImpl implements DataStatsService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
int issue = 0; |
|
|
int issue = 0; |
|
|
for (CustomerDataManageResultDTO u : issueEnd) { |
|
|
for (CustomerDataManageResultDTO.CustomerDataManage u : issueEnd) { |
|
|
if (org.getOrgId().equals(u.getOrgId())) { |
|
|
if (org.getOrgId().equals(u.getOrgId())) { |
|
|
issue = u.getIssueCount(); |
|
|
issue = u.getIssueCount(); |
|
|
if ("Interval".equals(formDTO.getType())) { |
|
|
if ("Interval".equals(formDTO.getType())) { |
|
|
for (CustomerDataManageResultDTO s : finalIssueStart) { |
|
|
for (CustomerDataManageResultDTO.CustomerDataManage s : finalIssueStart) { |
|
|
if (u.getOrgId().equals(s.getOrgId())) { |
|
|
if (u.getOrgId().equals(s.getOrgId())) { |
|
|
issue = issue - s.getIssueCount(); |
|
|
issue = issue - s.getIssueCount(); |
|
|
} |
|
|
} |
|
@ -2053,12 +2052,12 @@ public class DataStatsServiceImpl implements DataStatsService { |
|
|
} |
|
|
} |
|
|
int project = 0; |
|
|
int project = 0; |
|
|
int closed = 0; |
|
|
int closed = 0; |
|
|
for (CustomerDataManageResultDTO u : projectEnd) { |
|
|
for (CustomerDataManageResultDTO.CustomerDataManage u : projectEnd) { |
|
|
if (org.getOrgId().equals(u.getOrgId())) { |
|
|
if (org.getOrgId().equals(u.getOrgId())) { |
|
|
project = u.getProjectCount(); |
|
|
project = u.getProjectCount(); |
|
|
closed = u.getClosedProjectCount(); |
|
|
closed = u.getClosedProjectCount(); |
|
|
if ("Interval".equals(formDTO.getType())) { |
|
|
if ("Interval".equals(formDTO.getType())) { |
|
|
for (CustomerDataManageResultDTO s : finalProjectStart) { |
|
|
for (CustomerDataManageResultDTO.CustomerDataManage s : finalProjectStart) { |
|
|
if (u.getOrgId().equals(s.getOrgId())) { |
|
|
if (u.getOrgId().equals(s.getOrgId())) { |
|
|
project = project - s.getProjectCount(); |
|
|
project = project - s.getProjectCount(); |
|
|
closed = closed - s.getClosedProjectCount(); |
|
|
closed = closed - s.getClosedProjectCount(); |
|
@ -2071,15 +2070,14 @@ public class DataStatsServiceImpl implements DataStatsService { |
|
|
int patroCount = 0; |
|
|
int patroCount = 0; |
|
|
String patrolDuration = ""; |
|
|
String patrolDuration = ""; |
|
|
int patrolDurationInteger = 0; |
|
|
int patrolDurationInteger = 0; |
|
|
List<String> list = new ArrayList<>(); |
|
|
HashSet set = new HashSet(); |
|
|
for (CustomerDataManageResultDTO u : patrolEnd) { |
|
|
for (CustomerDataManageResultDTO.CustomerDataManage u : patrolEnd) { |
|
|
if (org.getOrgId().equals(u.getOrgId())) { |
|
|
if (org.getOrgId().equals(u.getOrgId())) { |
|
|
patroCount += u.getPatrolCount(); |
|
|
patroCount += u.getPatrolCount(); |
|
|
patrolDurationInteger += u.getPatrolDurationInteger(); |
|
|
patrolDurationInteger += u.getPatrolDurationInteger(); |
|
|
list.add(u.getStaffId()); |
|
|
set.add(u.getStaffId()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
HashSet set = new HashSet(list); |
|
|
|
|
|
patro = set.size(); |
|
|
patro = set.size(); |
|
|
Integer minutes = patrolDurationInteger / 60; |
|
|
Integer minutes = patrolDurationInteger / 60; |
|
|
patrolDuration = (minutes / 60 > 0 ? minutes / 60 + "小时" : "") + (minutes % 60 > 0 ? minutes % 60 + "分钟" : "0分钟"); |
|
|
patrolDuration = (minutes / 60 > 0 ? minutes / 60 + "小时" : "") + (minutes % 60 > 0 ? minutes % 60 + "分钟" : "0分钟"); |
|
@ -2097,18 +2095,28 @@ public class DataStatsServiceImpl implements DataStatsService { |
|
|
dto.setPatrolDuration(patrolDuration); |
|
|
dto.setPatrolDuration(patrolDuration); |
|
|
dto.setPatrolDurationInteger(patrolDurationInteger); |
|
|
dto.setPatrolDurationInteger(patrolDurationInteger); |
|
|
|
|
|
|
|
|
resultList.add(dto); |
|
|
dataManageList.add(dto); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
//6.默认按用户总数降序
|
|
|
//6.默认按用户总数降序
|
|
|
Collections.sort(resultList, new Comparator<CustomerDataManageResultDTO>() { |
|
|
Collections.sort(dataManageList, new Comparator<CustomerDataManageResultDTO.CustomerDataManage>() { |
|
|
@Override |
|
|
@Override |
|
|
public int compare(CustomerDataManageResultDTO o1, CustomerDataManageResultDTO o2) { |
|
|
public int compare(CustomerDataManageResultDTO.CustomerDataManage o1, CustomerDataManageResultDTO.CustomerDataManage o2) { |
|
|
return o2.getUserCount().compareTo(o1.getUserCount()); |
|
|
return o2.getUserCount().compareTo(o1.getUserCount()); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
return resultList; |
|
|
//7.物理分页并返回
|
|
|
|
|
|
if (formDTO.getIsPage()) { |
|
|
|
|
|
int firstIndex = (formDTO.getPageNo() - 1) * formDTO.getPageSize(); |
|
|
|
|
|
int lastIndex = formDTO.getPageNo() * formDTO.getPageSize(); |
|
|
|
|
|
List<CustomerDataManageResultDTO.CustomerDataManage> list = dataManageList.subList((firstIndex > dataManageList.size() ? dataManageList.size() : firstIndex), (lastIndex > dataManageList.size() ? dataManageList.size() : lastIndex)); |
|
|
|
|
|
resultDTO.setDataManageList(list); |
|
|
|
|
|
return resultDTO; |
|
|
} |
|
|
} |
|
|
|
|
|
resultDTO.setDataManageList(dataManageList); |
|
|
|
|
|
return resultDTO; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|