Browse Source

按照提示优化代码;尽量使用常量

dev
jianjun 4 years ago
parent
commit
e0e715ef40
  1. 354
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java

354
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java

@ -4,7 +4,8 @@
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.constant.NumConstant;
import com.epmet.commons.tools.enums.OrgLevelEnum; import com.epmet.commons.tools.enums.OrgLevelEnum;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.enums.OrgTypeEnum;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.feign.ResultDataResolver;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.DateUtils;
@ -98,15 +99,15 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
formDTO.setDateId(format.format(yesterday)); formDTO.setDateId(format.format(yesterday));
} }
//0.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表 //NumConstant.ZERO.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表
agencyList = indexService.getAgencyIdsByAgencyId(formDTO.getAgencyId()); agencyList = indexService.getAgencyIdsByAgencyId(formDTO.getAgencyId());
agencyList.add(formDTO.getAgencyId()); agencyList.add(formDTO.getAgencyId());
//1.查询组织下注册用户最新日统计数据【只查询注册用户的统计数据,不涉及参与用户的】 //1.查询组织下注册用户最新日统计数据【只查询注册用户的统计数据,不涉及参与用户的】
List<AgencyBasicDataResultDTO> userList = dataStatsDao.getAgnecyRegUser(agencyList, formDTO.getDateId()); List<AgencyBasicDataResultDTO> userList = dataStatsDao.getAgnecyRegUser(agencyList, formDTO.getDateId());
int userTotal = 0; int userTotal = NumConstant.ZERO;
int resiTotal = 0; int resiTotal = NumConstant.ZERO;
int partyMemberTotal = 0; int partyMemberTotal = NumConstant.ZERO;
for (AgencyBasicDataResultDTO u : userList){ for (AgencyBasicDataResultDTO u : userList){
userTotal+=u.getUserTotal(); userTotal+=u.getUserTotal();
resiTotal+=u.getResiTotal(); resiTotal+=u.getResiTotal();
@ -114,15 +115,15 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
} }
resultDTO.setUserTotal(userTotal); resultDTO.setUserTotal(userTotal);
resultDTO.setResiTotal(resiTotal); resultDTO.setResiTotal(resiTotal);
resultDTO.setResiRatio(resultDTO.getResiTotal() == 0 || resultDTO.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getResiTotal() / (float) resultDTO.getUserTotal()))); resultDTO.setResiRatio(resultDTO.getResiTotal() == NumConstant.ZERO || resultDTO.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getResiTotal() / (float) resultDTO.getUserTotal())));
resultDTO.setPartyMemberTotal(partyMemberTotal); resultDTO.setPartyMemberTotal(partyMemberTotal);
resultDTO.setPartyMemberRatio(resultDTO.getPartyMemberTotal() == 0 || resultDTO.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPartyMemberTotal() / (float) resultDTO.getUserTotal()))); resultDTO.setPartyMemberRatio(resultDTO.getPartyMemberTotal() == NumConstant.ZERO || resultDTO.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPartyMemberTotal() / (float) resultDTO.getUserTotal())));
//2.查询组织下最新群组日统计数据 //2.查询组织下最新群组日统计数据
List<AgencyBasicDataResultDTO> groupList = dataStatsDao.getAgnecyGroup(agencyList, formDTO.getDateId()); List<AgencyBasicDataResultDTO> groupList = dataStatsDao.getAgnecyGroup(agencyList, formDTO.getDateId());
int groupTotal = 0; int groupTotal = NumConstant.ZERO;
int ordinaryTotal = 0; int ordinaryTotal = NumConstant.ZERO;
int branchTotal = 0; int branchTotal = NumConstant.ZERO;
for (AgencyBasicDataResultDTO g : groupList){ for (AgencyBasicDataResultDTO g : groupList){
groupTotal+=g.getGroupTotal(); groupTotal+=g.getGroupTotal();
ordinaryTotal+=g.getOrdinaryTotal(); ordinaryTotal+=g.getOrdinaryTotal();
@ -130,9 +131,9 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
} }
resultDTO.setGroupTotal(groupTotal); resultDTO.setGroupTotal(groupTotal);
resultDTO.setOrdinaryTotal(ordinaryTotal); resultDTO.setOrdinaryTotal(ordinaryTotal);
resultDTO.setOrdinaryRatio(resultDTO.getOrdinaryTotal() == 0 || resultDTO.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getOrdinaryTotal() / (float) resultDTO.getGroupTotal()))); resultDTO.setOrdinaryRatio(resultDTO.getOrdinaryTotal() == NumConstant.ZERO || resultDTO.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getOrdinaryTotal() / (float) resultDTO.getGroupTotal())));
resultDTO.setBranchTotal(branchTotal); resultDTO.setBranchTotal(branchTotal);
resultDTO.setBranchRatio(resultDTO.getBranchTotal() == 0 || resultDTO.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getBranchTotal() / (float) resultDTO.getGroupTotal()))); resultDTO.setBranchRatio(resultDTO.getBranchTotal() == NumConstant.ZERO || resultDTO.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getBranchTotal() / (float) resultDTO.getGroupTotal())));
//3.查询组织下最新话题日统计数据 //3.查询组织下最新话题日统计数据
//状态话题-机关日统计数据表最新日期三种状态数据 //状态话题-机关日统计数据表最新日期三种状态数据
@ -148,21 +149,21 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
//转议题 //转议题
int shiftIssueTotal = topicSHiftIssue.stream().mapToInt(AgencyBasicDataResultDTO.Topic::getShiftedIssueTotal).sum(); int shiftIssueTotal = topicSHiftIssue.stream().mapToInt(AgencyBasicDataResultDTO.Topic::getShiftedIssueTotal).sum();
resultDTO.setShiftIssueTotal(shiftIssueTotal); resultDTO.setShiftIssueTotal(shiftIssueTotal);
resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal()))); resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal())));
//热议中 //热议中
int discussingTotal = hotdiscuss.stream().mapToInt(AgencyBasicDataResultDTO.Topic::getTopicCount).sum(); int discussingTotal = hotdiscuss.stream().mapToInt(AgencyBasicDataResultDTO.Topic::getTopicCount).sum();
resultDTO.setDiscussingTotal(discussingTotal); resultDTO.setDiscussingTotal(discussingTotal);
resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal()))); resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal())));
//已处理 //已处理
resultDTO.setClosedTopicTotal(closedTotal); resultDTO.setClosedTopicTotal(closedTotal);
resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal()))); resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal())));
//4.查询组织下最新议题日统计数据 //NumConstant.FOUR.查询组织下最新议题日统计数据
List<AgencyBasicDataResultDTO> issueList = dataStatsDao.getAgencyIssue(agencyList, formDTO.getDateId()); List<AgencyBasicDataResultDTO> issueList = dataStatsDao.getAgencyIssue(agencyList, formDTO.getDateId());
int issueTotal = 0; int issueTotal = NumConstant.ZERO;
int votingTotal = 0; int votingTotal = NumConstant.ZERO;
int closedIssueTotal = 0; int closedIssueTotal = NumConstant.ZERO;
int shiftProjectTotal = 0; int shiftProjectTotal = NumConstant.ZERO;
for (AgencyBasicDataResultDTO i : issueList){ for (AgencyBasicDataResultDTO i : issueList){
issueTotal+=i.getIssueTotal(); issueTotal+=i.getIssueTotal();
votingTotal+=i.getVotingTotal(); votingTotal+=i.getVotingTotal();
@ -171,17 +172,17 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
} }
resultDTO.setIssueTotal(issueTotal); resultDTO.setIssueTotal(issueTotal);
resultDTO.setVotingTotal(votingTotal); resultDTO.setVotingTotal(votingTotal);
resultDTO.setVotingRatio(resultDTO.getVotingTotal() == 0 || resultDTO.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getVotingTotal() / (float) resultDTO.getIssueTotal()))); resultDTO.setVotingRatio(resultDTO.getVotingTotal() == NumConstant.ZERO || resultDTO.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getVotingTotal() / (float) resultDTO.getIssueTotal())));
resultDTO.setClosedIssueTotal(closedIssueTotal); resultDTO.setClosedIssueTotal(closedIssueTotal);
resultDTO.setClosedIssueRatio(resultDTO.getClosedIssueTotal() == 0 || resultDTO.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedIssueTotal() / (float) resultDTO.getIssueTotal()))); resultDTO.setClosedIssueRatio(resultDTO.getClosedIssueTotal() == NumConstant.ZERO || resultDTO.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedIssueTotal() / (float) resultDTO.getIssueTotal())));
resultDTO.setShiftProjectTotal(shiftProjectTotal); resultDTO.setShiftProjectTotal(shiftProjectTotal);
resultDTO.setShiftProjectRatio(resultDTO.getShiftProjectTotal() == 0 || resultDTO.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftProjectTotal() / (float) resultDTO.getIssueTotal()))); resultDTO.setShiftProjectRatio(resultDTO.getShiftProjectTotal() == NumConstant.ZERO || resultDTO.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftProjectTotal() / (float) resultDTO.getIssueTotal())));
//5.查询组织下最新项目日统计数据 //5.查询组织下最新项目日统计数据
List<AgencyBasicDataResultDTO> projectList = dataStatsDao.getAgencyProject(agencyList, formDTO.getDateId()); List<AgencyBasicDataResultDTO> projectList = dataStatsDao.getAgencyProject(agencyList, formDTO.getDateId());
int projectTotal = 0; int projectTotal = NumConstant.ZERO;
int pendingTotal = 0; int pendingTotal = NumConstant.ZERO;
int closedProjectTotal = 0; int closedProjectTotal = NumConstant.ZERO;
for (AgencyBasicDataResultDTO p : projectList){ for (AgencyBasicDataResultDTO p : projectList){
projectTotal+=p.getProjectTotal(); projectTotal+=p.getProjectTotal();
pendingTotal+=p.getPendingTotal(); pendingTotal+=p.getPendingTotal();
@ -189,9 +190,9 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
} }
resultDTO.setProjectTotal(projectTotal); resultDTO.setProjectTotal(projectTotal);
resultDTO.setPendingTotal(pendingTotal); resultDTO.setPendingTotal(pendingTotal);
resultDTO.setPendingRatio(resultDTO.getPendingTotal() == 0 || resultDTO.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPendingTotal() / (float) resultDTO.getProjectTotal()))); resultDTO.setPendingRatio(resultDTO.getPendingTotal() == NumConstant.ZERO || resultDTO.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPendingTotal() / (float) resultDTO.getProjectTotal())));
resultDTO.setClosedProjectTotal(closedProjectTotal); resultDTO.setClosedProjectTotal(closedProjectTotal);
resultDTO.setClosedProjectRatio(resultDTO.getClosedProjectTotal() == 0 || resultDTO.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedProjectTotal() / (float) resultDTO.getProjectTotal()))); resultDTO.setClosedProjectRatio(resultDTO.getClosedProjectTotal() == NumConstant.ZERO || resultDTO.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedProjectTotal() / (float) resultDTO.getProjectTotal())));
return resultDTO; return resultDTO;
} }
@ -220,21 +221,21 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
gridIds.add(formDTO.getGridId()); gridIds.add(formDTO.getGridId());
List<SubGridUserResultDTO> userList = dataStatsDao.getSubGridUser(gridIds, formDTO.getDateId()); List<SubGridUserResultDTO> userList = dataStatsDao.getSubGridUser(gridIds, formDTO.getDateId());
if (userList.size() > NumConstant.ZERO) { if (userList.size() > NumConstant.ZERO) {
resultDTO.setUserTotal(userList.get(0).getUserTotal()); resultDTO.setUserTotal(userList.get(NumConstant.ZERO).getUserTotal());
resultDTO.setResiTotal(userList.get(0).getResiTotal()); resultDTO.setResiTotal(userList.get(NumConstant.ZERO).getResiTotal());
resultDTO.setResiRatio(resultDTO.getResiTotal() == 0 || resultDTO.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getResiTotal() / (float) resultDTO.getUserTotal()))); resultDTO.setResiRatio(resultDTO.getResiTotal() == NumConstant.ZERO || resultDTO.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getResiTotal() / (float) resultDTO.getUserTotal())));
resultDTO.setPartyMemberTotal(userList.get(0).getPartyMemberTotal()); resultDTO.setPartyMemberTotal(userList.get(NumConstant.ZERO).getPartyMemberTotal());
resultDTO.setPartyMemberRatio(resultDTO.getPartyMemberTotal() == 0 || resultDTO.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPartyMemberTotal() / (float) resultDTO.getUserTotal()))); resultDTO.setPartyMemberRatio(resultDTO.getPartyMemberTotal() == NumConstant.ZERO || resultDTO.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPartyMemberTotal() / (float) resultDTO.getUserTotal())));
} }
//2.查询网格下最新群组日统计数据 //2.查询网格下最新群组日统计数据
List<SubGridGroupResultDTO> groupList = dataStatsDao.getSubGridGroup(gridIds, formDTO.getDateId()); List<SubGridGroupResultDTO> groupList = dataStatsDao.getSubGridGroup(gridIds, formDTO.getDateId());
if (groupList.size() > NumConstant.ZERO) { if (groupList.size() > NumConstant.ZERO) {
resultDTO.setGroupTotal(groupList.get(0).getGroupTotal()); resultDTO.setGroupTotal(groupList.get(NumConstant.ZERO).getGroupTotal());
resultDTO.setOrdinaryTotal(groupList.get(0).getOrdinaryTotal()); resultDTO.setOrdinaryTotal(groupList.get(NumConstant.ZERO).getOrdinaryTotal());
resultDTO.setOrdinaryRatio(resultDTO.getOrdinaryTotal() == 0 || resultDTO.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getOrdinaryTotal() / (float) resultDTO.getGroupTotal()))); resultDTO.setOrdinaryRatio(resultDTO.getOrdinaryTotal() == NumConstant.ZERO || resultDTO.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getOrdinaryTotal() / (float) resultDTO.getGroupTotal())));
resultDTO.setBranchTotal(groupList.get(0).getBranchTotal()); resultDTO.setBranchTotal(groupList.get(NumConstant.ZERO).getBranchTotal());
resultDTO.setBranchRatio(resultDTO.getBranchTotal() == 0 || resultDTO.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getBranchTotal() / (float) resultDTO.getGroupTotal()))); resultDTO.setBranchRatio(resultDTO.getBranchTotal() == NumConstant.ZERO || resultDTO.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getBranchTotal() / (float) resultDTO.getGroupTotal())));
} }
//3.查询网格下最新话题日统计数据 //3.查询网格下最新话题日统计数据
@ -245,7 +246,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
List<SubGridFormDTO.Topic> topicShiftIssueList = dataStatsDao.getSubGridTopicShiftIssue(gridIds, formDTO.getDateId()); List<SubGridFormDTO.Topic> topicShiftIssueList = dataStatsDao.getSubGridTopicShiftIssue(gridIds, formDTO.getDateId());
//热议中话题-网格日统计数据 //热议中话题-网格日统计数据
List<SubGridFormDTO.Topic> hotdiscussList = dataStatsDao.getSubGridTopicHotDiscuss(gridIds, formDTO.getDateId()); List<SubGridFormDTO.Topic> hotdiscussList = dataStatsDao.getSubGridTopicHotDiscuss(gridIds, formDTO.getDateId());
AtomicReference<Integer> closedTotal = new AtomicReference<>(0); AtomicReference<Integer> closedTotal = new AtomicReference<>(NumConstant.ZERO);
if (topicList.size() > NumConstant.ZERO) { if (topicList.size() > NumConstant.ZERO) {
resultDTO.setTopicTotal(topicList.stream().collect(Collectors.summingInt(SubGridFormDTO.Topic::getTopicCount))); resultDTO.setTopicTotal(topicList.stream().collect(Collectors.summingInt(SubGridFormDTO.Topic::getTopicCount)));
topicList.forEach(t -> { topicList.forEach(t -> {
@ -256,38 +257,38 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
} }
//转议题 //转议题
if (topicShiftIssueList.size() > NumConstant.ZERO) { if (topicShiftIssueList.size() > NumConstant.ZERO) {
resultDTO.setShiftIssueTotal(topicShiftIssueList.get(0).getShiftedIssueTotal()); resultDTO.setShiftIssueTotal(topicShiftIssueList.get(NumConstant.ZERO).getShiftedIssueTotal());
resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal()))); resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal())));
} }
//热议中 //热议中
if (hotdiscussList.size() > NumConstant.ZERO) { if (hotdiscussList.size() > NumConstant.ZERO) {
resultDTO.setDiscussingTotal(hotdiscussList.get(0).getTopicCount()); resultDTO.setDiscussingTotal(hotdiscussList.get(NumConstant.ZERO).getTopicCount());
resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal()))); resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal())));
} }
//已处理 //已处理
resultDTO.setClosedTopicTotal(closedTotal.get()); resultDTO.setClosedTopicTotal(closedTotal.get());
resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal()))); resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal())));
//4.查询网格下最新议题日统计数据 //NumConstant.FOUR.查询网格下最新议题日统计数据
List<SubGridIssueResultDTO> issueList = dataStatsDao.getSubGridIssue(gridIds, formDTO.getDateId()); List<SubGridIssueResultDTO> issueList = dataStatsDao.getSubGridIssue(gridIds, formDTO.getDateId());
if (issueList.size() > NumConstant.ZERO) { if (issueList.size() > NumConstant.ZERO) {
resultDTO.setIssueTotal(issueList.get(0).getIssueTotal()); resultDTO.setIssueTotal(issueList.get(NumConstant.ZERO).getIssueTotal());
resultDTO.setVotingTotal(issueList.get(0).getVotingTotal()); resultDTO.setVotingTotal(issueList.get(NumConstant.ZERO).getVotingTotal());
resultDTO.setVotingRatio(resultDTO.getVotingTotal() == 0 || resultDTO.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getVotingTotal() / (float) resultDTO.getIssueTotal()))); resultDTO.setVotingRatio(resultDTO.getVotingTotal() == NumConstant.ZERO || resultDTO.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getVotingTotal() / (float) resultDTO.getIssueTotal())));
resultDTO.setClosedIssueTotal(issueList.get(0).getClosedIssueTotal()); resultDTO.setClosedIssueTotal(issueList.get(NumConstant.ZERO).getClosedIssueTotal());
resultDTO.setClosedIssueRatio(resultDTO.getClosedIssueTotal() == 0 || resultDTO.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedIssueTotal() / (float) resultDTO.getIssueTotal()))); resultDTO.setClosedIssueRatio(resultDTO.getClosedIssueTotal() == NumConstant.ZERO || resultDTO.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedIssueTotal() / (float) resultDTO.getIssueTotal())));
resultDTO.setShiftProjectTotal(issueList.get(0).getShiftProjectTotal()); resultDTO.setShiftProjectTotal(issueList.get(NumConstant.ZERO).getShiftProjectTotal());
resultDTO.setShiftProjectRatio(resultDTO.getShiftProjectTotal() == 0 || resultDTO.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftProjectTotal() / (float) resultDTO.getIssueTotal()))); resultDTO.setShiftProjectRatio(resultDTO.getShiftProjectTotal() == NumConstant.ZERO || resultDTO.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftProjectTotal() / (float) resultDTO.getIssueTotal())));
} }
//5.查询网格下最新项目日统计数据 //5.查询网格下最新项目日统计数据
List<SubGridProjectResultDTO> projectList = dataStatsDao.getSubGridProject(gridIds, formDTO.getDateId()); List<SubGridProjectResultDTO> projectList = dataStatsDao.getSubGridProject(gridIds, formDTO.getDateId());
if (projectList.size() > NumConstant.ZERO) { if (projectList.size() > NumConstant.ZERO) {
resultDTO.setProjectTotal(projectList.get(0).getProjectTotal()); resultDTO.setProjectTotal(projectList.get(NumConstant.ZERO).getProjectTotal());
resultDTO.setPendingTotal(projectList.get(0).getPendingTotal()); resultDTO.setPendingTotal(projectList.get(NumConstant.ZERO).getPendingTotal());
resultDTO.setPendingRatio(resultDTO.getPendingTotal() == 0 || resultDTO.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPendingTotal() / (float) resultDTO.getProjectTotal()))); resultDTO.setPendingRatio(resultDTO.getPendingTotal() == NumConstant.ZERO || resultDTO.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPendingTotal() / (float) resultDTO.getProjectTotal())));
resultDTO.setClosedProjectTotal(projectList.get(0).getClosedProjectTotal()); resultDTO.setClosedProjectTotal(projectList.get(NumConstant.ZERO).getClosedProjectTotal());
resultDTO.setClosedProjectRatio(resultDTO.getClosedProjectTotal() == 0 || resultDTO.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedProjectTotal() / (float) resultDTO.getProjectTotal()))); resultDTO.setClosedProjectRatio(resultDTO.getClosedProjectTotal() == NumConstant.ZERO || resultDTO.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedProjectTotal() / (float) resultDTO.getProjectTotal())));
} }
return resultDTO; return resultDTO;
@ -339,12 +340,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
dto.setResiTotal(u.getResiTotal()); dto.setResiTotal(u.getResiTotal());
} }
} }
dto.setPartyMemberRatio(dto.getPartyMemberTotal() == 0 || dto.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPartyMemberTotal() / (float) dto.getUserTotal()))); dto.setPartyMemberRatio(dto.getPartyMemberTotal() == NumConstant.ZERO || dto.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPartyMemberTotal() / (float) dto.getUserTotal())));
dto.setResiRatio(dto.getResiTotal() == 0 || dto.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getResiTotal() / (float) dto.getUserTotal()))); dto.setResiRatio(dto.getResiTotal() == NumConstant.ZERO || dto.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getResiTotal() / (float) dto.getUserTotal())));
resultList.add(dto); resultList.add(dto);
} }
//4.按要求排序并返回 //NumConstant.FOUR.按要求排序并返回
Collections.sort(resultList, new Comparator<SubAgencyUserResultDTO>() { Collections.sort(resultList, new Comparator<SubAgencyUserResultDTO>() {
@Override @Override
public int compare(SubAgencyUserResultDTO o1, SubAgencyUserResultDTO o2) { public int compare(SubAgencyUserResultDTO o1, SubAgencyUserResultDTO o2) {
@ -408,12 +409,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
dto.setResiTotal(re.getResiTotal()); dto.setResiTotal(re.getResiTotal());
} }
} }
dto.setPartyMemberRatio(dto.getPartyMemberTotal() == 0 || dto.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPartyMemberTotal() / (float) dto.getUserTotal()))); dto.setPartyMemberRatio(dto.getPartyMemberTotal() == NumConstant.ZERO || dto.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPartyMemberTotal() / (float) dto.getUserTotal())));
dto.setResiRatio(dto.getResiTotal() == 0 || dto.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getResiTotal() / (float) dto.getUserTotal()))); dto.setResiRatio(dto.getResiTotal() == NumConstant.ZERO || dto.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getResiTotal() / (float) dto.getUserTotal())));
resultList.add(dto); resultList.add(dto);
} }
//4.按要求排序并返回 //NumConstant.FOUR.按要求排序并返回
Collections.sort(resultList, new Comparator<SubGridUserResultDTO>() { Collections.sort(resultList, new Comparator<SubGridUserResultDTO>() {
@Override @Override
public int compare(SubGridUserResultDTO o1, SubGridUserResultDTO o2) { public int compare(SubGridUserResultDTO o1, SubGridUserResultDTO o2) {
@ -477,12 +478,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
dto.setBranchTotal(u.getBranchTotal()); dto.setBranchTotal(u.getBranchTotal());
} }
} }
dto.setOrdinaryRatio(dto.getOrdinaryTotal() == 0 || dto.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getOrdinaryTotal() / (float) dto.getGroupTotal()))); dto.setOrdinaryRatio(dto.getOrdinaryTotal() == NumConstant.ZERO || dto.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getOrdinaryTotal() / (float) dto.getGroupTotal())));
dto.setBranchRatio(dto.getBranchTotal() == 0 || dto.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getBranchTotal() / (float) dto.getGroupTotal()))); dto.setBranchRatio(dto.getBranchTotal() == NumConstant.ZERO || dto.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getBranchTotal() / (float) dto.getGroupTotal())));
resultList.add(dto); resultList.add(dto);
} }
//4.按要求排序并返回 //NumConstant.FOUR.按要求排序并返回
Collections.sort(resultList, new Comparator<SubAgencyGroupResultDTO>() { Collections.sort(resultList, new Comparator<SubAgencyGroupResultDTO>() {
@Override @Override
public int compare(SubAgencyGroupResultDTO o1, SubAgencyGroupResultDTO o2) { public int compare(SubAgencyGroupResultDTO o1, SubAgencyGroupResultDTO o2) {
@ -543,12 +544,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
dto.setBranchTotal(re.getBranchTotal()); dto.setBranchTotal(re.getBranchTotal());
} }
} }
dto.setOrdinaryRatio(dto.getOrdinaryTotal() == 0 || dto.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getOrdinaryTotal() / (float) dto.getGroupTotal()))); dto.setOrdinaryRatio(dto.getOrdinaryTotal() == NumConstant.ZERO || dto.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getOrdinaryTotal() / (float) dto.getGroupTotal())));
dto.setBranchRatio(dto.getBranchTotal() == 0 || dto.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getBranchTotal() / (float) dto.getGroupTotal()))); dto.setBranchRatio(dto.getBranchTotal() == NumConstant.ZERO || dto.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getBranchTotal() / (float) dto.getGroupTotal())));
resultList.add(dto); resultList.add(dto);
} }
//4.按要求排序并返回 //NumConstant.FOUR.按要求排序并返回
Collections.sort(resultList, new Comparator<SubGridGroupResultDTO>() { Collections.sort(resultList, new Comparator<SubGridGroupResultDTO>() {
@Override @Override
public int compare(SubGridGroupResultDTO o1, SubGridGroupResultDTO o2) { public int compare(SubGridGroupResultDTO o1, SubGridGroupResultDTO o2) {
@ -604,10 +605,10 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
List<SubAgencyFormDTO.Topic> hotdiscuss = dataStatsDao.getSubAgencyTopicHotDiscuss(agencyIds, formDTO.getDateId()); List<SubAgencyFormDTO.Topic> hotdiscuss = dataStatsDao.getSubAgencyTopicHotDiscuss(agencyIds, formDTO.getDateId());
subAgencyList.forEach(sub -> { subAgencyList.forEach(sub -> {
SubAgencyTopicResultDTO resultDTO = new SubAgencyTopicResultDTO(); SubAgencyTopicResultDTO resultDTO = new SubAgencyTopicResultDTO();
AtomicInteger topicTotal = new AtomicInteger(0); AtomicInteger topicTotal = new AtomicInteger(NumConstant.ZERO);
AtomicInteger closedTotal = new AtomicInteger(0); AtomicInteger closedTotal = new AtomicInteger(NumConstant.ZERO);
AtomicInteger shiftIssueTotal = new AtomicInteger(0); AtomicInteger shiftIssueTotal = new AtomicInteger(NumConstant.ZERO);
AtomicInteger hotdiscussTotal = new AtomicInteger(0); AtomicInteger hotdiscussTotal = new AtomicInteger(NumConstant.ZERO);
topic.forEach(t -> { topic.forEach(t -> {
if (t.getAgencyId().equals(sub.getAgencyId())) { if (t.getAgencyId().equals(sub.getAgencyId())) {
topicTotal.addAndGet(t.getTopicCount()); topicTotal.addAndGet(t.getTopicCount());
@ -633,28 +634,25 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
resultDTO.setAreaCode(null == sub.getAreaCode() ? "" : sub.getAreaCode()); resultDTO.setAreaCode(null == sub.getAreaCode() ? "" : sub.getAreaCode());
resultDTO.setTopicTotal(topicTotal.get()); resultDTO.setTopicTotal(topicTotal.get());
resultDTO.setDiscussingTotal(hotdiscussTotal.get()); resultDTO.setDiscussingTotal(hotdiscussTotal.get());
resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal()))); resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal())));
resultDTO.setClosedTopicTotal(closedTotal.get()); resultDTO.setClosedTopicTotal(closedTotal.get());
resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal()))); resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal())));
resultDTO.setShiftIssueTotal(shiftIssueTotal.get()); resultDTO.setShiftIssueTotal(shiftIssueTotal.get());
resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal()))); resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal())));
resultList.add(resultDTO); resultList.add(resultDTO);
}); });
//3.按要求排序并返回 //3.按要求排序并返回
Collections.sort(resultList, new Comparator<SubAgencyTopicResultDTO>() { resultList.sort((o1, o2) -> {
@Override if ("discussing".equals(formDTO.getType())) {
public int compare(SubAgencyTopicResultDTO o1, SubAgencyTopicResultDTO o2) { return o2.getDiscussingTotal().compareTo(o1.getDiscussingTotal());
if ("discussing".equals(formDTO.getType())) { } else if ("closed".equals(formDTO.getType())) {
return o2.getDiscussingTotal().compareTo(o1.getDiscussingTotal()); return o2.getClosedTopicTotal().compareTo(o1.getClosedTopicTotal());
} else if ("closed".equals(formDTO.getType())) { } else if ("shiftIssue".equals(formDTO.getType())) {
return o2.getClosedTopicTotal().compareTo(o1.getClosedTopicTotal()); return o2.getShiftIssueTotal().compareTo(o1.getShiftIssueTotal());
} else if ("shiftIssue".equals(formDTO.getType())) { } else {
return o2.getShiftIssueTotal().compareTo(o1.getShiftIssueTotal()); return o2.getTopicTotal().compareTo(o1.getTopicTotal());
} else {
return o2.getTopicTotal().compareTo(o1.getTopicTotal());
}
} }
}); });
@ -700,10 +698,10 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
List<SubGridFormDTO.Topic> hotdiscuss = dataStatsDao.getSubGridTopicHotDiscuss(gridIds, formDTO.getDateId()); List<SubGridFormDTO.Topic> hotdiscuss = dataStatsDao.getSubGridTopicHotDiscuss(gridIds, formDTO.getDateId());
gridList.forEach(gr -> { gridList.forEach(gr -> {
SubGridTopicResultDTO resultDTO = new SubGridTopicResultDTO(); SubGridTopicResultDTO resultDTO = new SubGridTopicResultDTO();
AtomicInteger topicTotal = new AtomicInteger(0); AtomicInteger topicTotal = new AtomicInteger(NumConstant.ZERO);
AtomicInteger closedTotal = new AtomicInteger(0); AtomicInteger closedTotal = new AtomicInteger(NumConstant.ZERO);
AtomicInteger shiftIssueTotal = new AtomicInteger(0); AtomicInteger shiftIssueTotal = new AtomicInteger(NumConstant.ZERO);
AtomicInteger hotdiscussTotal = new AtomicInteger(0); AtomicInteger hotdiscussTotal = new AtomicInteger(NumConstant.ZERO);
topic.forEach(t -> { topic.forEach(t -> {
if (t.getGridId().equals(gr.getGridId())) { if (t.getGridId().equals(gr.getGridId())) {
topicTotal.addAndGet(t.getTopicCount()); topicTotal.addAndGet(t.getTopicCount());
@ -727,11 +725,11 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
resultDTO.setGridName(gr.getGridName()); resultDTO.setGridName(gr.getGridName());
resultDTO.setTopicTotal(topicTotal.get()); resultDTO.setTopicTotal(topicTotal.get());
resultDTO.setDiscussingTotal(hotdiscussTotal.get()); resultDTO.setDiscussingTotal(hotdiscussTotal.get());
resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal()))); resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal())));
resultDTO.setClosedTopicTotal(closedTotal.get()); resultDTO.setClosedTopicTotal(closedTotal.get());
resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal()))); resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal())));
resultDTO.setShiftIssueTotal(shiftIssueTotal.get()); resultDTO.setShiftIssueTotal(shiftIssueTotal.get());
resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal()))); resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal())));
resultList.add(resultDTO); resultList.add(resultDTO);
}); });
@ -802,13 +800,13 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
dto.setShiftProjectTotal(u.getShiftProjectTotal()); dto.setShiftProjectTotal(u.getShiftProjectTotal());
} }
} }
dto.setVotingRatio(dto.getVotingTotal() == 0 || dto.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getVotingTotal() / (float) dto.getIssueTotal()))); dto.setVotingRatio(dto.getVotingTotal() == NumConstant.ZERO || dto.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getVotingTotal() / (float) dto.getIssueTotal())));
dto.setClosedIssueRatio(dto.getClosedIssueTotal() == 0 || dto.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedIssueTotal() / (float) dto.getIssueTotal()))); dto.setClosedIssueRatio(dto.getClosedIssueTotal() == NumConstant.ZERO || dto.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedIssueTotal() / (float) dto.getIssueTotal())));
dto.setShiftProjectRatio(dto.getShiftProjectTotal() == 0 || dto.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getShiftProjectTotal() / (float) dto.getIssueTotal()))); dto.setShiftProjectRatio(dto.getShiftProjectTotal() == NumConstant.ZERO || dto.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getShiftProjectTotal() / (float) dto.getIssueTotal())));
resultList.add(dto); resultList.add(dto);
} }
//4.按要求排序并返回 //NumConstant.FOUR.按要求排序并返回
Collections.sort(resultList, new Comparator<SubAgencyIssueResultDTO>() { Collections.sort(resultList, new Comparator<SubAgencyIssueResultDTO>() {
@Override @Override
public int compare(SubAgencyIssueResultDTO o1, SubAgencyIssueResultDTO o2) { public int compare(SubAgencyIssueResultDTO o1, SubAgencyIssueResultDTO o2) {
@ -872,13 +870,13 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
dto.setShiftProjectTotal(re.getShiftProjectTotal()); dto.setShiftProjectTotal(re.getShiftProjectTotal());
} }
} }
dto.setVotingRatio(dto.getVotingTotal() == 0 || dto.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getVotingTotal() / (float) dto.getIssueTotal()))); dto.setVotingRatio(dto.getVotingTotal() == NumConstant.ZERO || dto.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getVotingTotal() / (float) dto.getIssueTotal())));
dto.setClosedIssueRatio(dto.getClosedIssueTotal() == 0 || dto.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedIssueTotal() / (float) dto.getIssueTotal()))); dto.setClosedIssueRatio(dto.getClosedIssueTotal() == NumConstant.ZERO || dto.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedIssueTotal() / (float) dto.getIssueTotal())));
dto.setShiftProjectRatio(dto.getShiftProjectTotal() == 0 || dto.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getShiftProjectTotal() / (float) dto.getIssueTotal()))); dto.setShiftProjectRatio(dto.getShiftProjectTotal() == NumConstant.ZERO || dto.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getShiftProjectTotal() / (float) dto.getIssueTotal())));
resultList.add(dto); resultList.add(dto);
} }
//4.按要求排序并返回 //NumConstant.FOUR.按要求排序并返回
Collections.sort(resultList, new Comparator<SubGridIssueResultDTO>() { Collections.sort(resultList, new Comparator<SubGridIssueResultDTO>() {
@Override @Override
public int compare(SubGridIssueResultDTO o1, SubGridIssueResultDTO o2) { public int compare(SubGridIssueResultDTO o1, SubGridIssueResultDTO o2) {
@ -943,12 +941,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
dto.setClosedProjectTotal(u.getClosedProjectTotal()); dto.setClosedProjectTotal(u.getClosedProjectTotal());
} }
} }
dto.setPendingRatio(dto.getPendingTotal() == 0 || dto.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPendingTotal() / (float) dto.getProjectTotal()))); dto.setPendingRatio(dto.getPendingTotal() == NumConstant.ZERO || dto.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPendingTotal() / (float) dto.getProjectTotal())));
dto.setClosedProjectRatio(dto.getClosedProjectTotal() == 0 || dto.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedProjectTotal() / (float) dto.getProjectTotal()))); dto.setClosedProjectRatio(dto.getClosedProjectTotal() == NumConstant.ZERO || dto.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedProjectTotal() / (float) dto.getProjectTotal())));
resultList.add(dto); resultList.add(dto);
} }
//4.按要求排序并返回 //NumConstant.FOUR.按要求排序并返回
Collections.sort(resultList, new Comparator<SubAgencyProjectResultDTO>() { Collections.sort(resultList, new Comparator<SubAgencyProjectResultDTO>() {
@Override @Override
public int compare(SubAgencyProjectResultDTO o1, SubAgencyProjectResultDTO o2) { public int compare(SubAgencyProjectResultDTO o1, SubAgencyProjectResultDTO o2) {
@ -1009,12 +1007,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
dto.setClosedProjectTotal(re.getClosedProjectTotal()); dto.setClosedProjectTotal(re.getClosedProjectTotal());
} }
} }
dto.setPendingRatio(dto.getPendingTotal() == 0 || dto.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPendingTotal() / (float) dto.getProjectTotal()))); dto.setPendingRatio(dto.getPendingTotal() == NumConstant.ZERO || dto.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPendingTotal() / (float) dto.getProjectTotal())));
dto.setClosedProjectRatio(dto.getClosedProjectTotal() == 0 || dto.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedProjectTotal() / (float) dto.getProjectTotal()))); dto.setClosedProjectRatio(dto.getClosedProjectTotal() == NumConstant.ZERO || dto.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedProjectTotal() / (float) dto.getProjectTotal())));
resultList.add(dto); resultList.add(dto);
} }
//4.按要求排序并返回 //NumConstant.FOUR.按要求排序并返回
Collections.sort(resultList, new Comparator<SubGridProjectResultDTO>() { Collections.sort(resultList, new Comparator<SubGridProjectResultDTO>() {
@Override @Override
public int compare(SubGridProjectResultDTO o1, SubGridProjectResultDTO o2) { public int compare(SubGridProjectResultDTO o1, SubGridProjectResultDTO o2) {
@ -1278,7 +1276,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
resultList.add(dto); resultList.add(dto);
} }
//4.按要求排序并返回 //NumConstant.FOUR.按要求排序并返回
Collections.sort(resultList, new Comparator<AgencyGovrnResultDTO>() { Collections.sort(resultList, new Comparator<AgencyGovrnResultDTO>() {
@Override @Override
public int compare(AgencyGovrnResultDTO o1, AgencyGovrnResultDTO o2) { public int compare(AgencyGovrnResultDTO o1, AgencyGovrnResultDTO o2) {
@ -1380,7 +1378,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
resultList.add(dto); resultList.add(dto);
} }
//4.按要求排序并返回 //NumConstant.FOUR.按要求排序并返回
Collections.sort(resultList, new Comparator<GridGovrnResultDTO>() { Collections.sort(resultList, new Comparator<GridGovrnResultDTO>() {
@Override @Override
public int compare(GridGovrnResultDTO o1, GridGovrnResultDTO o2) { public int compare(GridGovrnResultDTO o1, GridGovrnResultDTO o2) {
@ -1471,18 +1469,18 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
formDTO.setDateId(format.format(yesterday)); formDTO.setDateId(format.format(yesterday));
} }
BaseStatsDataResultDTO result = new BaseStatsDataResultDTO(); BaseStatsDataResultDTO result = new BaseStatsDataResultDTO();
result.setTopicTotal(0); result.setTopicTotal(NumConstant.ZERO);
result.setTopicIncr(0); result.setTopicIncr(NumConstant.ZERO);
result.setIssueTotal(0); result.setIssueTotal(NumConstant.ZERO);
result.setIssueIncr(0); result.setIssueIncr(NumConstant.ZERO);
result.setProjectTotal(0); result.setProjectTotal(NumConstant.ZERO);
result.setProjectIncr(0); result.setProjectIncr(NumConstant.ZERO);
result.setClosedProjectTotal(0); result.setClosedProjectTotal(NumConstant.ZERO);
result.setClosedProjectIncr(0); result.setClosedProjectIncr(NumConstant.ZERO);
//0.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表 //NumConstant.ZERO.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表
List<String> agencyList = indexService.getAgencyIdsByAgencyId(formDTO.getAgencyId()); List<String> agencyList = indexService.getAgencyIdsByAgencyId(formDTO.getAgencyId());
agencyList.add(formDTO.getAgencyId()); agencyList.add(formDTO.getAgencyId());
TotalAndIncrResultDTO sum = dataStatsDao.getAgencySumTopic(agencyList, formDTO.getDateId()); TotalAndIncrResultDTO sum = dataStatsDao.getAgencySumTopic(agencyList, formDTO.getDateId());
@ -1546,7 +1544,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
List<WorkFactResultDTO> result = new ArrayList<>(); List<WorkFactResultDTO> result = new ArrayList<>();
//如果是社区 则下级是网格 查询网格的数据 //如果是社区 则下级是网格 查询网格的数据
if (OrgLevelEnum.COMMUNITY.getCode().equals(formDTO.getAgencyLevel())){ if (OrgLevelEnum.COMMUNITY.getCode().equals(formDTO.getAgencyLevel())){
//0.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表 //NumConstant.ZERO.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表
List<ScreenCustomerGridDTO> subAgencyList = indexService.getSubGridList(formDTO.getAgencyId()); List<ScreenCustomerGridDTO> subAgencyList = indexService.getSubGridList(formDTO.getAgencyId());
if (subAgencyList.size() < NumConstant.ONE) { if (subAgencyList.size() < NumConstant.ONE) {
return null; return null;
@ -1585,7 +1583,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
result.add(resultDTO); result.add(resultDTO);
}); });
}else { }else {
//0.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表 //NumConstant.ZERO.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表
List<ScreenCustomerAgencyDTO> subAgencyList = indexService.getSubAgencyListByAgency(formDTO.getAgencyId()); List<ScreenCustomerAgencyDTO> subAgencyList = indexService.getSubAgencyListByAgency(formDTO.getAgencyId());
if (subAgencyList.size() < NumConstant.ONE) { if (subAgencyList.size() < NumConstant.ONE) {
return null; return null;
@ -1636,9 +1634,9 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
resultDTO.setRoutineWorkCount(patrolRecordDTO.getRoutineWorkCount()); resultDTO.setRoutineWorkCount(patrolRecordDTO.getRoutineWorkCount());
resultDTO.setPatrolTotal(patrolRecordDTO.getPatrolTotal()); resultDTO.setPatrolTotal(patrolRecordDTO.getPatrolTotal());
Integer totalTime = patrolRecordDTO.getTotalTime(); Integer totalTime = patrolRecordDTO.getTotalTime();
if (totalTime != null || totalTime > 0){ if (totalTime != null || totalTime > NumConstant.ZERO){
int minutes = totalTime / 60; int minutes = totalTime / 60;
if (minutes >0){ if (minutes >NumConstant.ZERO){
String totalTimeDesc = minutes / 60 + "小时"+ minutes % 60 + "分"; String totalTimeDesc = minutes / 60 + "小时"+ minutes % 60 + "分";
resultDTO.setPatrolTotalTime(totalTimeDesc); resultDTO.setPatrolTotalTime(totalTimeDesc);
} }
@ -1649,12 +1647,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
private Integer getTotal(Map<String,Integer> startMap, Map<String,Integer> endMap,String agencyId){ private Integer getTotal(Map<String,Integer> startMap, Map<String,Integer> endMap,String agencyId){
Integer total1 = startMap.getOrDefault(agencyId,NumConstant.ZERO); Integer total1 = startMap.getOrDefault(agencyId,NumConstant.ZERO);
Integer total2 = endMap.getOrDefault(agencyId,NumConstant.ZERO); Integer total2 = endMap.getOrDefault(agencyId,NumConstant.ZERO);
return Math.max(total2-total1,0); return Math.max(total2-total1,NumConstant.ZERO);
} }
private String getPercentage(Integer countInt, Integer totalInt) { private String getPercentage(Integer countInt, Integer totalInt) {
if (NumConstant.ZERO == totalInt) { if (NumConstant.ZERO == totalInt) {
return "0%"; return "NumConstant.ZERO%";
} }
BigDecimal count = new BigDecimal(countInt); BigDecimal count = new BigDecimal(countInt);
BigDecimal total = new BigDecimal(totalInt); BigDecimal total = new BigDecimal(totalInt);
@ -1729,8 +1727,8 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
}); });
} }
//4.按用户数降序排序并返回 //NumConstant.FOUR.按用户数降序排序并返回
Collections.sort(resultList, (o1, o2) -> { resultList.sort((o1, o2) -> {
//降序 //降序
return o2.getUserTotal().compareTo(o1.getUserTotal()); return o2.getUserTotal().compareTo(o1.getUserTotal());
}); });
@ -1798,7 +1796,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
List<SubAgencyFormDTO.Topic> hotdiscuss = dataStatsDao.getSubAgencyTopicHotDiscuss(agencyIds, formDTO.getDateId()); List<SubAgencyFormDTO.Topic> hotdiscuss = dataStatsDao.getSubAgencyTopicHotDiscuss(agencyIds, formDTO.getDateId());
//3-3.查询直属下级组织小组日统计数据 //3-3.查询直属下级组织小组日统计数据
List<SubAgencyGroupResultDTO> list = dataStatsDao.getSubAgencyGroup(agencyIds, formDTO.getDateId()); List<SubAgencyGroupResultDTO> list = dataStatsDao.getSubAgencyGroup(agencyIds, formDTO.getDateId());
//3-4.封装数据 //3-NumConstant.FOUR.封装数据
subAgencyList.forEach(sub -> { subAgencyList.forEach(sub -> {
SubTopicAndGroupResultDTO resultDTO = new SubTopicAndGroupResultDTO(); SubTopicAndGroupResultDTO resultDTO = new SubTopicAndGroupResultDTO();
resultDTO.setOrgId(sub.getAgencyId()); resultDTO.setOrgId(sub.getAgencyId());
@ -1817,12 +1815,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
}); });
} }
//4.按用户数降序排序并返回 //NumConstant.FOUR.按用户数降序排序并返回
Collections.sort(resultList, (o1, o2) -> { resultList.sort((o1, o2) -> {
//降序 //降序
return o2.getTopicTotal().compareTo(o1.getTopicTotal()); return o2.getTopicTotal().compareTo(o1.getTopicTotal());
}); });
AtomicInteger i = new AtomicInteger(1); AtomicInteger i = new AtomicInteger(NumConstant.ONE);
resultList.forEach(e->e.setSort(i.getAndIncrement())); resultList.forEach(e->e.setSort(i.getAndIncrement()));
return resultList; return resultList;
} }
@ -1880,17 +1878,17 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
if (!CollectionUtils.isEmpty(result)){ if (!CollectionUtils.isEmpty(result)){
CustomerDataManageResultDTO.CustomerDataManage c = new CustomerDataManageResultDTO.CustomerDataManage(); CustomerDataManageResultDTO.CustomerDataManage c = new CustomerDataManageResultDTO.CustomerDataManage();
c.setOrgName("合计"); c.setOrgName("合计");
c.setUserCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getUserCount))); c.setUserCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getUserCount).sum());
c.setResidentCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getResidentCount))); c.setResidentCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getResidentCount).sum());
c.setPartyMemberCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getPartyMemberCount))); c.setPartyMemberCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getPartyMemberCount).sum());
c.setGroupCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getGroupCount))); c.setGroupCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getGroupCount).sum());
c.setTopicCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getTopicCount))); c.setTopicCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getTopicCount).sum());
c.setIssueCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getIssueCount))); c.setIssueCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getIssueCount).sum());
c.setProjectCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getProjectCount))); c.setProjectCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getProjectCount).sum());
c.setClosedProjectCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getClosedProjectCount))); c.setClosedProjectCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getClosedProjectCount).sum());
c.setPatrolPeopleCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getPatrolPeopleCount))); c.setPatrolPeopleCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getPatrolPeopleCount).sum());
c.setPatrolCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getPatrolCount))); c.setPatrolCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getPatrolCount).sum());
c.setPatrolDurationInteger(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getPatrolDurationInteger))); c.setPatrolDurationInteger(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getPatrolDurationInteger).sum());
c.setPatrolDuration(getHm(c.getPatrolDurationInteger())); c.setPatrolDuration(getHm(c.getPatrolDurationInteger()));
result.add(c); result.add(c);
} }
@ -1908,7 +1906,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
String result = "0分钟"; String result = "0分钟";
if (seconds >= NumConstant.SIXTY) { if (seconds >= NumConstant.SIXTY) {
Integer hours = seconds / 3600; Integer hours = seconds / 3600;
Integer minutes = seconds % 3600 / 60; Integer minutes = seconds % 3600 / NumConstant.SIXTY;
result = (hours < NumConstant.ONE ? "" : hours + "小时") + (minutes < NumConstant.ONE ? "" : minutes + "分钟"); result = (hours < NumConstant.ONE ? "" : hours + "小时") + (minutes < NumConstant.ONE ? "" : minutes + "分钟");
}else if (seconds < NumConstant.SIXTY && seconds > NumConstant.ZERO){ }else if (seconds < NumConstant.SIXTY && seconds > NumConstant.ZERO){
result = "1分钟"; result = "1分钟";
@ -1928,20 +1926,20 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
s.append(agencyName); s.append(agencyName);
if (StringUtils.isNotBlank(formDTO.getStartTime())){ if (StringUtils.isNotBlank(formDTO.getStartTime())){
String startTime = formDTO.getStartTime(); String startTime = formDTO.getStartTime();
String sYear = startTime.substring(0, 4); String sYear = startTime.substring(NumConstant.ZERO, NumConstant.FOUR);
String sMonth = startTime.substring(4, 6); String sMonth = startTime.substring(NumConstant.FOUR, NumConstant.SIX);
String sDay = startTime.substring(6, 8); String sDay = startTime.substring(NumConstant.SIX, NumConstant.EIGHT);
String endTime = formDTO.getEndTime(); String endTime = formDTO.getEndTime();
String eYear = endTime.substring(0, 4); String eYear = endTime.substring(NumConstant.ZERO, NumConstant.FOUR);
String eMonth = endTime.substring(4, 6); String eMonth = endTime.substring(NumConstant.FOUR, NumConstant.SIX);
String eDay = endTime.substring(6, 8); String eDay = endTime.substring(NumConstant.SIX, NumConstant.EIGHT);
s.append(sYear).append("年").append(sMonth).append("月").append(sDay).append("日-") s.append(sYear).append("年").append(sMonth).append("月").append(sDay).append("日-")
.append(eYear).append("年").append(eMonth).append("月").append(eDay).append("日区间新增值"); .append(eYear).append("年").append(eMonth).append("月").append(eDay).append("日区间新增值");
}else { }else {
String endTime = formDTO.getEndTime(); String endTime = formDTO.getEndTime();
String eYear = endTime.substring(0, 4); String eYear = endTime.substring(NumConstant.ZERO, NumConstant.FOUR);
String eMonth = endTime.substring(4, 6); String eMonth = endTime.substring(NumConstant.FOUR, NumConstant.SIX);
String eDay = endTime.substring(6, 8); String eDay = endTime.substring(NumConstant.SIX, NumConstant.EIGHT);
s.append(eYear).append("年").append(eMonth).append("月").append(eDay).append("日截止累计值"); s.append(eYear).append("年").append(eMonth).append("月").append(eDay).append("日截止累计值");
} }
return s.toString(); return s.toString();
@ -1976,7 +1974,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
} }
//组织或网格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(!OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) ? OrgTypeEnum.AGENCY.getCode() : OrgTypeEnum.GRID.getCode());
formDTO.setIdList(idList); formDTO.setIdList(idList);
resultDTO.setTotal(idList.size()); resultDTO.setTotal(idList.size());
@ -1984,25 +1982,25 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
formDTO.setSourceType("end"); formDTO.setSourceType("end");
List<CustomerDataManageResultDTO.CustomerDataManage> userEnd = dataStatsDao.regUserList(formDTO); List<CustomerDataManageResultDTO.CustomerDataManage> userEnd = dataStatsDao.regUserList(formDTO);
HashMap<String, CustomerDataManageResultDTO.CustomerDataManage> uEndMap = new HashMap<>(); HashMap<String, CustomerDataManageResultDTO.CustomerDataManage> uEndMap = new HashMap<>();
userEnd.stream().forEach(u->uEndMap.put(u.getOrgId(),u)); userEnd.forEach(u->uEndMap.put(u.getOrgId(),u));
List<CustomerDataManageResultDTO.CustomerDataManage> groupEnd = dataStatsDao.groupList(formDTO); List<CustomerDataManageResultDTO.CustomerDataManage> groupEnd = dataStatsDao.groupList(formDTO);
HashMap<String, CustomerDataManageResultDTO.CustomerDataManage> gEndMap = new HashMap<>(); HashMap<String, CustomerDataManageResultDTO.CustomerDataManage> gEndMap = new HashMap<>();
groupEnd.stream().forEach(u->gEndMap.put(u.getOrgId(),u)); groupEnd.forEach(u->gEndMap.put(u.getOrgId(),u));
List<CustomerDataManageResultDTO.CustomerDataManage> topicEnd = dataStatsDao.topicList(formDTO); List<CustomerDataManageResultDTO.CustomerDataManage> topicEnd = dataStatsDao.topicList(formDTO);
HashMap<String, CustomerDataManageResultDTO.CustomerDataManage> tEndMap = new HashMap<>(); HashMap<String, CustomerDataManageResultDTO.CustomerDataManage> tEndMap = new HashMap<>();
topicEnd.stream().forEach(u->tEndMap.put(u.getOrgId(),u)); topicEnd.forEach(u->tEndMap.put(u.getOrgId(),u));
List<CustomerDataManageResultDTO.CustomerDataManage> issueEnd = dataStatsDao.issueList(formDTO); List<CustomerDataManageResultDTO.CustomerDataManage> issueEnd = dataStatsDao.issueList(formDTO);
HashMap<String, CustomerDataManageResultDTO.CustomerDataManage> iEndMap = new HashMap<>(); HashMap<String, CustomerDataManageResultDTO.CustomerDataManage> iEndMap = new HashMap<>();
issueEnd.stream().forEach(u->iEndMap.put(u.getOrgId(),u)); issueEnd.forEach(u->iEndMap.put(u.getOrgId(),u));
List<CustomerDataManageResultDTO.CustomerDataManage> projectEnd = dataStatsDao.projectList(formDTO); List<CustomerDataManageResultDTO.CustomerDataManage> projectEnd = dataStatsDao.projectList(formDTO);
HashMap<String, CustomerDataManageResultDTO.CustomerDataManage> pEndMap = new HashMap<>(); HashMap<String, CustomerDataManageResultDTO.CustomerDataManage> pEndMap = new HashMap<>();
projectEnd.stream().forEach(u->pEndMap.put(u.getOrgId(),u)); projectEnd.forEach(u->pEndMap.put(u.getOrgId(),u));
//巡查数据不区分区间差值,只计算累计值,人员做去重处理且是有巡查记录的人员 == //巡查数据不区分区间差值,只计算累计值,人员做去重处理且是有巡查记录的人员 ==
CustomerDataManageFormDTO patrolForm = ConvertUtils.sourceToTarget(formDTO,CustomerDataManageFormDTO.class); CustomerDataManageFormDTO patrolForm = ConvertUtils.sourceToTarget(formDTO,CustomerDataManageFormDTO.class);
patrolForm.setStartTime(startTimeForm); patrolForm.setStartTime(startTimeForm);
List<CustomerDataManageResultDTO.CustomerDataManage> patrolEnd = statsStaffPatrolRecordDailyService.patrolList(patrolForm); List<CustomerDataManageResultDTO.CustomerDataManage> patrolEnd = statsStaffPatrolRecordDailyService.patrolList(patrolForm);
//4.判断是否需要查询起始日期用户、群组、话题、议题、项目、巡查数据 //NumConstant.FOUR.判断是否需要查询起始日期用户、群组、话题、议题、项目、巡查数据
HashMap<String, CustomerDataManageResultDTO.CustomerDataManage> uStartMap = new HashMap<>(); HashMap<String, CustomerDataManageResultDTO.CustomerDataManage> uStartMap = new HashMap<>();
HashMap<String, CustomerDataManageResultDTO.CustomerDataManage> gStartMap = new HashMap<>(); HashMap<String, CustomerDataManageResultDTO.CustomerDataManage> gStartMap = new HashMap<>();
HashMap<String, CustomerDataManageResultDTO.CustomerDataManage> tStartMap = new HashMap<>(); HashMap<String, CustomerDataManageResultDTO.CustomerDataManage> tStartMap = new HashMap<>();
@ -2011,15 +2009,15 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
if ("Interval".equals(formDTO.getType())) { if ("Interval".equals(formDTO.getType())) {
formDTO.setSourceType("start"); formDTO.setSourceType("start");
List<CustomerDataManageResultDTO.CustomerDataManage> userStart = dataStatsDao.regUserList(formDTO); List<CustomerDataManageResultDTO.CustomerDataManage> userStart = dataStatsDao.regUserList(formDTO);
userStart.stream().forEach(u->uStartMap.put(u.getOrgId(),u)); userStart.forEach(u->uStartMap.put(u.getOrgId(),u));
List<CustomerDataManageResultDTO.CustomerDataManage> groupStart = dataStatsDao.groupList(formDTO); List<CustomerDataManageResultDTO.CustomerDataManage> groupStart = dataStatsDao.groupList(formDTO);
groupStart.stream().forEach(u->gStartMap.put(u.getOrgId(),u)); groupStart.forEach(u->gStartMap.put(u.getOrgId(),u));
List<CustomerDataManageResultDTO.CustomerDataManage> topicStart = dataStatsDao.topicList(formDTO); List<CustomerDataManageResultDTO.CustomerDataManage> topicStart = dataStatsDao.topicList(formDTO);
topicStart.stream().forEach(u->tStartMap.put(u.getOrgId(),u)); topicStart.forEach(u->tStartMap.put(u.getOrgId(),u));
List<CustomerDataManageResultDTO.CustomerDataManage> issueStart = dataStatsDao.issueList(formDTO); List<CustomerDataManageResultDTO.CustomerDataManage> issueStart = dataStatsDao.issueList(formDTO);
issueStart.stream().forEach(u->iStartMap.put(u.getOrgId(),u)); issueStart.forEach(u->iStartMap.put(u.getOrgId(),u));
List<CustomerDataManageResultDTO.CustomerDataManage> projectStart = dataStatsDao.projectList(formDTO); List<CustomerDataManageResultDTO.CustomerDataManage> projectStart = dataStatsDao.projectList(formDTO);
projectStart.stream().forEach(u->pStartMap.put(u.getOrgId(),u)); projectStart.forEach(u->pStartMap.put(u.getOrgId(),u));
} }
//5.封装数据 //5.封装数据
@ -2027,9 +2025,9 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
CustomerDataManageResultDTO.CustomerDataManage dto = new CustomerDataManageResultDTO.CustomerDataManage(); 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 = NumConstant.ZERO;
int resi = 0; int resi = NumConstant.ZERO;
int part = 0; int part = NumConstant.ZERO;
if(uEndMap.containsKey(org.getOrgId())){ if(uEndMap.containsKey(org.getOrgId())){
user = uEndMap.get(org.getOrgId()).getUserCount(); user = uEndMap.get(org.getOrgId()).getUserCount();
resi = uEndMap.get(org.getOrgId()).getResidentCount(); resi = uEndMap.get(org.getOrgId()).getResidentCount();
@ -2040,29 +2038,29 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
part = part - uStartMap.get(org.getOrgId()).getPartyMemberCount(); part = part - uStartMap.get(org.getOrgId()).getPartyMemberCount();
} }
} }
int group = 0; int group = NumConstant.ZERO;
if(gEndMap.containsKey(org.getOrgId())){ if(gEndMap.containsKey(org.getOrgId())){
group = gEndMap.get(org.getOrgId()).getGroupCount(); group = gEndMap.get(org.getOrgId()).getGroupCount();
if ("Interval".equals(formDTO.getType())&&gStartMap.containsKey(org.getOrgId())) { if ("Interval".equals(formDTO.getType())&&gStartMap.containsKey(org.getOrgId())) {
group = group - gStartMap.get(org.getOrgId()).getGroupCount(); group = group - gStartMap.get(org.getOrgId()).getGroupCount();
} }
} }
int topic = 0; int topic = NumConstant.ZERO;
if(tEndMap.containsKey(org.getOrgId())){ if(tEndMap.containsKey(org.getOrgId())){
topic = tEndMap.get(org.getOrgId()).getTopicCount(); topic = tEndMap.get(org.getOrgId()).getTopicCount();
if ("Interval".equals(formDTO.getType())&&tStartMap.containsKey(org.getOrgId())) { if ("Interval".equals(formDTO.getType())&&tStartMap.containsKey(org.getOrgId())) {
topic = topic - tStartMap.get(org.getOrgId()).getTopicCount(); topic = topic - tStartMap.get(org.getOrgId()).getTopicCount();
} }
} }
int issue = 0; int issue = NumConstant.ZERO;
if(iEndMap.containsKey(org.getOrgId())){ if(iEndMap.containsKey(org.getOrgId())){
issue = iEndMap.get(org.getOrgId()).getIssueCount(); issue = iEndMap.get(org.getOrgId()).getIssueCount();
if ("Interval".equals(formDTO.getType())&&iStartMap.containsKey(org.getOrgId())) { if ("Interval".equals(formDTO.getType())&&iStartMap.containsKey(org.getOrgId())) {
issue = issue - iStartMap.get(org.getOrgId()).getIssueCount(); issue = issue - iStartMap.get(org.getOrgId()).getIssueCount();
} }
} }
int project = 0; int project = NumConstant.ZERO;
int closed = 0; int closed = NumConstant.ZERO;
if(pEndMap.containsKey(org.getOrgId())){ if(pEndMap.containsKey(org.getOrgId())){
project = pEndMap.get(org.getOrgId()).getProjectCount(); project = pEndMap.get(org.getOrgId()).getProjectCount();
closed = pEndMap.get(org.getOrgId()).getClosedProjectCount(); closed = pEndMap.get(org.getOrgId()).getClosedProjectCount();
@ -2071,10 +2069,10 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
closed = closed - pStartMap.get(org.getOrgId()).getClosedProjectCount(); closed = closed - pStartMap.get(org.getOrgId()).getClosedProjectCount();
} }
} }
int patro = 0; int patro = NumConstant.ZERO;
int patroCount = 0; int patroCount = NumConstant.ZERO;
String patrolDuration = ""; String patrolDuration = "";
int patrolDurationInteger = 0; int patrolDurationInteger = NumConstant.ZERO;
HashSet set = new HashSet(); HashSet set = new HashSet();
for (CustomerDataManageResultDTO.CustomerDataManage u : patrolEnd) { for (CustomerDataManageResultDTO.CustomerDataManage u : patrolEnd) {
if ("community".equals(agencyGrid.getLevel()) && org.getOrgId().equals(u.getOrgId())) { if ("community".equals(agencyGrid.getLevel()) && org.getOrgId().equals(u.getOrgId())) {
@ -2091,7 +2089,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
} }
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 > NumConstant.ZERO ? minutes / 60 + "小时" : "") + (minutes % 60 > NumConstant.ZERO ? minutes % 60 + "分钟" : "0分钟");
dto.setUserCount(user); dto.setUserCount(user);
dto.setResidentCount(resi); dto.setResidentCount(resi);
@ -2109,7 +2107,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
dataManageList.add(dto); dataManageList.add(dto);
}); });
//6.默认按用户总数降序 //NumConstant.SIX.默认按用户总数降序
Collections.sort(dataManageList, new Comparator<CustomerDataManageResultDTO.CustomerDataManage>() { Collections.sort(dataManageList, new Comparator<CustomerDataManageResultDTO.CustomerDataManage>() {
@Override @Override
public int compare(CustomerDataManageResultDTO.CustomerDataManage o1, CustomerDataManageResultDTO.CustomerDataManage o2) { public int compare(CustomerDataManageResultDTO.CustomerDataManage o1, CustomerDataManageResultDTO.CustomerDataManage o2) {

Loading…
Cancel
Save