diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/PatrolDailySumResult.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/PatrolDailySumResult.java new file mode 100644 index 0000000000..5400a1247f --- /dev/null +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/PatrolDailySumResult.java @@ -0,0 +1,21 @@ +package com.epmet.dataaggre.dto.epmetuser.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * desc: + * + * @author: LiuJanJun + * @date: 2021/8/8 11:01 上午 + * @version: 1.0 + */ +@Data +public class PatrolDailySumResult implements Serializable { + private static final long serialVersionUID = 310405655189243944L; + + private String fullAgencyId; + private Integer patrolTotal; + private Integer totalTime; +} diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/ScreenCustomerAgencyDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/ScreenCustomerAgencyDTO.java index 3b2c818967..2ad0113f89 100644 --- a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/ScreenCustomerAgencyDTO.java +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/ScreenCustomerAgencyDTO.java @@ -23,6 +23,11 @@ public class ScreenCustomerAgencyDTO implements Serializable { */ private String agencyId; + /** + * pids + */ + private String pids; + /** * 组织名称 */ diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/StatsStaffPatrolRecordDailyDao.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/StatsStaffPatrolRecordDailyDao.java index 4d082fe5d9..c7e68c410e 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/StatsStaffPatrolRecordDailyDao.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/StatsStaffPatrolRecordDailyDao.java @@ -19,6 +19,7 @@ package com.epmet.dataaggre.dao.epmetuser; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dataaggre.dto.epmetuser.result.PatrolDailySumResult; import com.epmet.dataaggre.entity.epmetuser.StatsStaffPatrolRecordDailyEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -36,10 +37,10 @@ public interface StatsStaffPatrolRecordDailyDao extends BaseDao getPatrolSumList(@Param("agencyList") List agencyList, @Param("startDateId") String startDateId, @Param("endDateId") String endDateId); + List getPatrolSumList(@Param("agencyFullIdList") List agencyFullIdList, @Param("startDateId") String startDateId, @Param("endDateId") String endDateId); } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java index e8cfd1c8ba..520247cbe6 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java +++ b/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; @@ -11,6 +12,7 @@ import com.epmet.dataaggre.dao.datastats.FactGridMemberStatisticsDailyDao; import com.epmet.dataaggre.dto.datastats.FactGroupActDailyDTO; import com.epmet.dataaggre.dto.datastats.form.*; import com.epmet.dataaggre.dto.datastats.result.*; +import com.epmet.dataaggre.dto.epmetuser.result.PatrolDailySumResult; import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerAgencyDTO; import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerGridDTO; import com.epmet.dataaggre.dto.evaluationindex.ScreenGovernRankDataDailyDTO; @@ -19,7 +21,6 @@ import com.epmet.dataaggre.dto.resigroup.ActCategoryDictDTO; import com.epmet.dataaggre.dto.resigroup.result.GroupActRankDetailDTO; import com.epmet.dataaggre.entity.datastats.DimAgencyEntity; import com.epmet.dataaggre.entity.datastats.FactAgencyGovernDailyEntity; -import com.epmet.dataaggre.entity.epmetuser.StatsStaffPatrolRecordDailyEntity; import com.epmet.dataaggre.service.datastats.DataStatsService; import com.epmet.dataaggre.service.epmetuser.StatsStaffPatrolRecordDailyService; import com.epmet.dataaggre.service.evaluationindex.EvaluationIndexService; @@ -1538,8 +1539,8 @@ public class DataStatsServiceImpl implements DataStatsService { Map closeProjectStartMap = closeProjectStart.stream().collect(Collectors.toMap(SubGridProjectResultDTO::getGridId, SubGridProjectResultDTO::getClosedProjectTotal, (o1, o2) -> o1)); Map closeProjectEndMap = closeProjectEnd.stream().collect(Collectors.toMap(SubGridProjectResultDTO::getGridId, SubGridProjectResultDTO::getClosedProjectTotal, (o1, o2) -> o1)); //巡查次数和时间 - List patrolList = statsStaffPatrolRecordDailyService.getPatrolSumList(gridIdList,formDTO.getStartDateId(),formDTO.getEndDateId()); - Map patrolListMap = patrolList.stream().collect(Collectors.toMap(StatsStaffPatrolRecordDailyEntity::getAgencyId, o -> o, (o1, o2) -> o1)); + List patrolList = statsStaffPatrolRecordDailyService.getPatrolSumList(gridIdList,formDTO.getStartDateId(),formDTO.getEndDateId()); + Map patrolListMap = patrolList.stream().collect(Collectors.toMap(PatrolDailySumResult::getFullAgencyId, o -> o, (o1, o2) -> o1)); subAgencyList.forEach(agency->{ String gridId = agency.getGridId(); @@ -1549,14 +1550,9 @@ public class DataStatsServiceImpl implements DataStatsService { resultDTO.setTopicToIssueTotal(getTotal(toIssueStartMap,toIssueEndMap,gridId)); resultDTO.setIssueToProjectTotal(getTotal(toProjectStartMap,toProjectEndMap,gridId)); resultDTO.setClosedProjectTotal(getTotal(closeProjectStartMap,closeProjectEndMap,gridId)); - StatsStaffPatrolRecordDailyEntity patrolRecordDTO = patrolListMap.get(gridId); - if (patrolRecordDTO != null){ - resultDTO.setPatrolTotal(patrolRecordDTO.getPatrolTotal()); - Integer totalTime = patrolRecordDTO.getTotalTime(); - int minutes = totalTime / 60; - String totalTimeDesc = minutes / 60 + "小时"+ minutes % 60 + "分"; - resultDTO.setPatrolTotalTime(totalTimeDesc); - } + + PatrolDailySumResult patrolRecordDTO = patrolListMap.get(agency.getAllParentIds()); + setPatrolAttr(resultDTO, patrolRecordDTO); result.add(resultDTO); }); }else { @@ -1583,8 +1579,9 @@ public class DataStatsServiceImpl implements DataStatsService { Map closeProjectStartMap = closeProjectStart.stream().collect(Collectors.toMap(SubAgencyProjectResultDTO::getAgencyId, SubAgencyProjectResultDTO::getClosedProjectTotal, (o1, o2) -> o1)); Map closeProjectEndMap = closeProjectEnd.stream().collect(Collectors.toMap(SubAgencyProjectResultDTO::getAgencyId, SubAgencyProjectResultDTO::getClosedProjectTotal, (o1, o2) -> o1)); //巡查次数和时间 - List patrolList = statsStaffPatrolRecordDailyService.getPatrolSumList(agencyList,formDTO.getStartDateId(),formDTO.getEndDateId()); - Map patrolListMap = patrolList.stream().collect(Collectors.toMap(StatsStaffPatrolRecordDailyEntity::getAgencyId, o -> o, (o1, o2) -> o1)); + List agencyFullIds = subAgencyList.stream().map(o -> o.getPids().concat(StrConstant.COLON).concat(o.getAgencyId())).collect(Collectors.toList()); + List patrolList = statsStaffPatrolRecordDailyService.getPatrolSumList(agencyFullIds,formDTO.getStartDateId(),formDTO.getEndDateId()); + Map patrolListMap = patrolList.stream().collect(Collectors.toMap(PatrolDailySumResult::getFullAgencyId, o -> o, (o1, o2) -> o1)); subAgencyList.forEach(agency->{ String agencyId = agency.getAgencyId(); @@ -1594,14 +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)); - StatsStaffPatrolRecordDailyEntity patrolRecordDTO = patrolListMap.get(agencyId); - if (patrolRecordDTO != null){ - resultDTO.setPatrolTotal(patrolRecordDTO.getPatrolTotal()); - Integer totalTime = patrolRecordDTO.getTotalTime(); - int minutes = totalTime / 60; - String totalTimeDesc = minutes / 60 + "小时"+ minutes % 60 + "分"; - resultDTO.setPatrolTotalTime(totalTimeDesc); - } + String fullAgencyId = agency.getPids().concat(StrConstant.COLON).concat(agencyId); + PatrolDailySumResult patrolRecordDTO = patrolListMap.get(fullAgencyId); + setPatrolAttr(resultDTO,patrolRecordDTO); result.add(resultDTO); }); } @@ -1609,6 +1601,21 @@ public class DataStatsServiceImpl implements DataStatsService { List 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 startMap, Map endMap,String agencyId){ Integer total1 = startMap.getOrDefault(agencyId,NumConstant.ZERO); Integer total2 = endMap.getOrDefault(agencyId,NumConstant.ZERO); diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/StatsStaffPatrolRecordDailyService.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/StatsStaffPatrolRecordDailyService.java index 4de390526a..e8ec143b3c 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/StatsStaffPatrolRecordDailyService.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/StatsStaffPatrolRecordDailyService.java @@ -18,6 +18,7 @@ package com.epmet.dataaggre.service.epmetuser; import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.dataaggre.dto.epmetuser.result.PatrolDailySumResult; import com.epmet.dataaggre.entity.epmetuser.StatsStaffPatrolRecordDailyEntity; import java.util.List; @@ -37,6 +38,6 @@ public interface StatsStaffPatrolRecordDailyService extends BaseService getPatrolSumList(List agencyList, String startDateId, String endDateId); + List getPatrolSumList(List agencyList, String startDateId, String endDateId); } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/StatsStaffPatrolRecordDailyServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/StatsStaffPatrolRecordDailyServiceImpl.java index 1d246813f0..aad90034f3 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/StatsStaffPatrolRecordDailyServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/StatsStaffPatrolRecordDailyServiceImpl.java @@ -4,6 +4,7 @@ import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.dataaggre.constant.DataSourceConstant; import com.epmet.dataaggre.dao.epmetuser.StatsStaffPatrolRecordDailyDao; +import com.epmet.dataaggre.dto.epmetuser.result.PatrolDailySumResult; import com.epmet.dataaggre.entity.epmetuser.StatsStaffPatrolRecordDailyEntity; import com.epmet.dataaggre.service.epmetuser.StatsStaffPatrolRecordDailyService; import lombok.extern.slf4j.Slf4j; @@ -25,14 +26,14 @@ public class StatsStaffPatrolRecordDailyServiceImpl extends BaseServiceImpl getPatrolSumList(List agencyList, String startDateId, String endDateId) { - return baseDao.getPatrolSumList(agencyList,startDateId,endDateId); + public List getPatrolSumList(List agencyFullIdList, String startDateId, String endDateId) { + return baseDao.getPatrolSumList(agencyFullIdList,startDateId,endDateId); } } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StatsStaffPatrolRecordDailyDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StatsStaffPatrolRecordDailyDao.xml index 1e54dc1a1e..5642d17f40 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StatsStaffPatrolRecordDailyDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StatsStaffPatrolRecordDailyDao.xml @@ -1,17 +1,18 @@ - + SELECT - agency_id, + LEFT (GRID_PIDS,LENGTH( #{fullAgencyId} )) fullAgencyId, sum(patrol_total) patrolTotal, sum(TOTAL_TIME) totalTime FROM stats_staff_patrol_record_daily WHERE del_flag = '0' AND date_id BETWEEN #{startDateId} and #{endDateId} - - GRID_PIDS like CONCAT( #{agencyId},'%') - - GROUP BY customer_id,agency_id + AND GRID_PIDS like CONCAT( #{fullAgencyId},'%') + GROUP BY fullAgencyId + + diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/evaluationindex/EvaluationIndexDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/evaluationindex/EvaluationIndexDao.xml index d248aa13df..7ad70627dc 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/evaluationindex/EvaluationIndexDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/evaluationindex/EvaluationIndexDao.xml @@ -154,7 +154,8 @@ agency_name AS agencyName, level AS level, area_code AS areaCode, - parent_area_code AS parentAreaCode + parent_area_code AS parentAreaCode, + PIDS FROM screen_customer_agency WHERE @@ -174,4 +175,4 @@ - \ No newline at end of file +