Browse Source

获取组织 巡查次数及时长

master
jianjun 4 years ago
parent
commit
68d92cc375
  1. 38
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java
  2. 2
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StatsStaffPatrolRecordDailyDao.xml

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

@ -2,7 +2,8 @@
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.constant.StrConstant;
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;
@ -1551,13 +1552,7 @@ public class DataStatsServiceImpl implements DataStatsService {
resultDTO.setClosedProjectTotal(getTotal(closeProjectStartMap,closeProjectEndMap,gridId));
PatrolDailySumResult patrolRecordDTO = patrolListMap.get(agency.getAllParentIds());
if (patrolRecordDTO != null){
resultDTO.setPatrolTotal(patrolRecordDTO.getPatrolTotal());
Integer totalTime = patrolRecordDTO.getTotalTime();
int minutes = totalTime / 60;
String totalTimeDesc = minutes / 60 + "小时"+ minutes % 60 + "分";
resultDTO.setPatrolTotalTime(totalTimeDesc);
}
setPatrolAttr(resultDTO, patrolRecordDTO);
result.add(resultDTO);
});
}else {
@ -1584,7 +1579,7 @@ public class DataStatsServiceImpl implements DataStatsService {
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<String> agencyFullIds = subAgencyList.stream().map(o -> o.getPids().concat(o.getAgencyId())).collect(Collectors.toList());
List<String> agencyFullIds = subAgencyList.stream().map(o -> o.getPids().concat(StrConstant.COLON).concat(o.getAgencyId())).collect(Collectors.toList());
List<PatrolDailySumResult> patrolList = statsStaffPatrolRecordDailyService.getPatrolSumList(agencyFullIds,formDTO.getStartDateId(),formDTO.getEndDateId());
Map<String, PatrolDailySumResult> patrolListMap = patrolList.stream().collect(Collectors.toMap(PatrolDailySumResult::getFullAgencyId, o -> o, (o1, o2) -> o1));
@ -1596,15 +1591,9 @@ public class DataStatsServiceImpl implements DataStatsService {
resultDTO.setTopicToIssueTotal(getTotal(toIssueStartMap,toIssueEndMap,agencyId));
resultDTO.setIssueToProjectTotal(getTotal(toProjectStartMap,toProjectEndMap,agencyId));
resultDTO.setClosedProjectTotal(getTotal(closeProjectStartMap,closeProjectEndMap,agencyId));
String fullAgencyId = agency.getPids().concat(agencyId);
String fullAgencyId = agency.getPids().concat(StrConstant.COLON).concat(agencyId);
PatrolDailySumResult patrolRecordDTO = patrolListMap.get(fullAgencyId);
if (patrolRecordDTO != null){
resultDTO.setPatrolTotal(patrolRecordDTO.getPatrolTotal());
Integer totalTime = patrolRecordDTO.getTotalTime();
int minutes = totalTime / 60;
String totalTimeDesc = minutes / 60 + "小时"+ minutes % 60 + "分";
resultDTO.setPatrolTotalTime(totalTimeDesc);
}
setPatrolAttr(resultDTO,patrolRecordDTO);
result.add(resultDTO);
});
}
@ -1612,6 +1601,21 @@ public class DataStatsServiceImpl implements DataStatsService {
List<WorkFactResultDTO> newResult = result.stream().sorted(Comparator.comparing(o -> o.getTopicToIssueTotal() + o.getIssueToProjectTotal() + o.getClosedProjectTotal() + o.getPatrolTotal())).collect(Collectors.toList());
return newResult;
}
private void setPatrolAttr(WorkFactResultDTO resultDTO, PatrolDailySumResult patrolRecordDTO) {
if (patrolRecordDTO != null){
resultDTO.setPatrolTotal(patrolRecordDTO.getPatrolTotal());
Integer totalTime = patrolRecordDTO.getTotalTime();
if (totalTime != null || totalTime > 0){
int minutes = totalTime / 60;
if (minutes >0){
String totalTimeDesc = minutes / 60 + "小时"+ minutes % 60 + "分";
resultDTO.setPatrolTotalTime(totalTimeDesc);
}
}
}
}
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);

2
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StatsStaffPatrolRecordDailyDao.xml

@ -4,7 +4,7 @@
<select id="getPatrolSumList" resultType="com.epmet.dataaggre.dto.epmetuser.result.PatrolDailySumResult">
<foreach collection="agencyFullIdList" item="fullAgencyId" separator="UNION ALL">
SELECT
LEFT (GRID_PIDS,LENGTH( ${fullAgencyId} )) fullAgencyId,
LEFT (GRID_PIDS,LENGTH( #{fullAgencyId} )) fullAgencyId,
sum(patrol_total) patrolTotal,
sum(TOTAL_TIME) totalTime
FROM stats_staff_patrol_record_daily

Loading…
Cancel
Save