From 19719a06f41fb62fe03f6ad039c7294d38e83046 Mon Sep 17 00:00:00 2001 From: jianjun Date: Sun, 8 Aug 2021 11:22:05 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=9A=82=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../result/PatrolDailySumResult.java | 21 +++++++++++++++++++ .../ScreenCustomerAgencyDTO.java | 5 +++++ .../StatsStaffPatrolRecordDailyDao.java | 5 +++-- .../datastats/impl/DataStatsServiceImpl.java | 17 ++++++++------- .../StatsStaffPatrolRecordDailyService.java | 3 ++- ...tatsStaffPatrolRecordDailyServiceImpl.java | 7 ++++--- .../StatsStaffPatrolRecordDailyDao.xml | 13 ++++++------ .../evaluationindex/EvaluationIndexDao.xml | 5 +++-- 8 files changed, 55 insertions(+), 21 deletions(-) create mode 100644 epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/PatrolDailySumResult.java 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..2b42fbda86 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 @@ -11,6 +11,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 +20,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 +1538,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,7 +1549,8 @@ 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); + + PatrolDailySumResult patrolRecordDTO = patrolListMap.get(agency.getAllParentIds()); if (patrolRecordDTO != null){ resultDTO.setPatrolTotal(patrolRecordDTO.getPatrolTotal()); Integer totalTime = patrolRecordDTO.getTotalTime(); @@ -1583,8 +1584,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(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,7 +1596,8 @@ 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); + String fullAgencyId = agency.getPids().concat(agencyId); + PatrolDailySumResult patrolRecordDTO = patrolListMap.get(fullAgencyId); if (patrolRecordDTO != null){ resultDTO.setPatrolTotal(patrolRecordDTO.getPatrolTotal()); Integer totalTime = patrolRecordDTO.getTotalTime(); 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..3470e2f60d 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 + From 68d92cc375931f4b7151d0743e8b37a67ad16323 Mon Sep 17 00:00:00 2001 From: jianjun Date: Sun, 8 Aug 2021 12:54:29 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=BB=84=E7=BB=87=20?= =?UTF-8?q?=E5=B7=A1=E6=9F=A5=E6=AC=A1=E6=95=B0=E5=8F=8A=E6=97=B6=E9=95=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datastats/impl/DataStatsServiceImpl.java | 38 ++++++++++--------- .../StatsStaffPatrolRecordDailyDao.xml | 2 +- 2 files changed, 22 insertions(+), 18 deletions(-) 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 2b42fbda86..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; @@ -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 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 agencyFullIds = subAgencyList.stream().map(o -> o.getPids().concat(o.getAgencyId())).collect(Collectors.toList()); + 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)); @@ -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 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/resources/mapper/epmetuser/StatsStaffPatrolRecordDailyDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StatsStaffPatrolRecordDailyDao.xml index 3470e2f60d..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 @@ -4,7 +4,7 @@