diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/result/ProjectParticipatedAgencyResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/result/ProjectParticipatedAgencyResultDTO.java index 0065a286ec..f7714ca882 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/result/ProjectParticipatedAgencyResultDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/result/ProjectParticipatedAgencyResultDTO.java @@ -17,4 +17,6 @@ public class ProjectParticipatedAgencyResultDTO implements Serializable { private String agencyId; private int count; + + private String projectId; } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginProjectLogDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginProjectLogDailyDao.java index 180ce535bc..a4ef520287 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginProjectLogDailyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginProjectLogDailyDao.java @@ -23,6 +23,7 @@ import com.epmet.entity.evaluationindex.extract.FactOriginProjectLogDailyEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; + import java.util.List; /** @@ -125,7 +126,16 @@ public interface FactOriginProjectLogDailyDao extends BaseDao selectAgencyWhistledCount(@Param("agencies") List agencies, @Param("customerId") String customerId,@Param("dimId") String dimId); - + /*** + * @Description 评价周期内被吹哨且被办结(无论是哪一级办结)的项目数 + * @param agencies + * @param customerId + * @param dimId + * @return java.util.List + * @author wangc + * @date 2020.10.16 10:43 + */ + List selectWhistledAgencyClosedProjectCount(@Param("agencies") List agencies, @Param("customerId") String customerId,@Param("dimId") String dimId); /*** * @Description 查询机关办结次数 * @param agencies @@ -134,7 +144,24 @@ public interface FactOriginProjectLogDailyDao extends BaseDao selectAgencyHandledProjectCount(@Param("agencies") List agencies,@Param("customerId") String customerId,@Param("dimId") String dimId); + /** + * @Description 查询评价周期内各级别机关办结的项目Id + * @param customerId + * @param dimId + * @return java.util.List + * @author wangc + * @date 2020.10.15 17:29 + */ + List selectProjectIdHandledByAgency(@Param("customerId") String customerId,@Param("dimId") String dimId); + /** + * @Description 计算每个办结项目的总耗时 + * @param projectIds + * @return java.util.List + * @author wangc + * @date 2020.10.15 17:32 + */ + List selectProjectCostTime(@Param("projectIds") List projectIds); /** * 网格项目响应度 * @author zhaoqifeng diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollCommunityServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollCommunityServiceImpl.java index e33f7a4982..d8c024085b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollCommunityServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollCommunityServiceImpl.java @@ -134,13 +134,17 @@ public class IndexCollCommunityServiceImpl implements IndexCollCommunityService })); } - //办结数 + List agencies = agencyList.stream().map(DimAgencyDTO :: getId).distinct().collect(Collectors.toList()); + //办结数 Map agencyHandleCount = factOriginProjectLogDailyService.getProjectHandledAgency(agencies,customerId,dimId.getMonthId(),"month"); - Map efficiencyMap = factOriginProjectLogDailyService.getAgencyWorkPieceRatio(agencies,customerId,dimId.getMonthId(),"month"); + ////评价周期内被吹哨且被办结(无论是哪一级办结)的项目数 + Map whistledAgencyClosedProject = factOriginProjectLogDailyService.getWhistledAgencyClosedProjectCount(agencies,customerId,dimId.getMonthId(),"month"); + //处理效率 + Map efficiencyMap = factOriginProjectLogDailyService.getAgencyWorkPieceRatio(customerId,dimId.getMonthId(),"month"); list.forEach(entity ->{ entity.setClosedProjectCount(agencyHandleCount.get(entity.getAgencyId()) == null? NumConstant.ZERO : agencyHandleCount.get(entity.getAgencyId())); - BigDecimal element = new BigDecimal(entity.getClosedProjectCount()); + BigDecimal element = new BigDecimal(Optional.ofNullable(whistledAgencyClosedProject.get(entity.getAgencyId())).orElse(NumConstant.ZERO)); //分母,即机关参与过的项目数(去重) //“评价周期内被吹哨且办结的项目数”/“评价周期内被吹哨的所有项目数” Integer denominator = entity.getTransferedCount(); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollDistrictServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollDistrictServiceImpl.java index 1e576f2ba3..5271e87177 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollDistrictServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollDistrictServiceImpl.java @@ -127,14 +127,17 @@ public class IndexCollDistrictServiceImpl implements IndexCollDistrictService { } })); } - //办结数 + List agencies = agencyList.stream().map(DimAgencyDTO :: getId).distinct().collect(Collectors.toList()); + //办结数 Map agencyHandleCount = factOriginProjectLogDailyService.getProjectHandledAgency(agencies,customerId,dimId.getMonthId(),"month"); - - Map efficiencyMap = factOriginProjectLogDailyService.getAgencyWorkPieceRatio(agencies,customerId,dimId.getMonthId(),"month"); + //评价周期内被吹哨且被办结(无论是哪一级办结)的项目数 + Map whistledAgencyClosedProject = factOriginProjectLogDailyService.getWhistledAgencyClosedProjectCount(agencies,customerId,dimId.getMonthId(),"month"); + //处理效率 + Map efficiencyMap = factOriginProjectLogDailyService.getAgencyWorkPieceRatio(customerId,dimId.getMonthId(),"month"); list.forEach(entity ->{ entity.setClosedProjectCount(agencyHandleCount.get(entity.getAgencyId()) == null? NumConstant.ZERO : agencyHandleCount.get(entity.getAgencyId())); - BigDecimal element = new BigDecimal(entity.getClosedProjectCount()); + BigDecimal element = new BigDecimal(Optional.ofNullable(whistledAgencyClosedProject.get(entity.getAgencyId())).orElse(NumConstant.ZERO)); //分母,即机关参与过的项目数(去重) //“评价周期内被吹哨且办结的项目数”/“评价周期内被吹哨的所有项目数” Integer denominator = entity.getTransferedCount(); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollStreetServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollStreetServiceImpl.java index edd1742ec0..6de2c28648 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollStreetServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollStreetServiceImpl.java @@ -125,14 +125,17 @@ public class IndexCollStreetServiceImpl implements IndexCollStreetService { } })); } - //办结数 + List agencies = agencyList.stream().map(DimAgencyDTO :: getId).distinct().collect(Collectors.toList()); + //办结数 Map agencyHandleCount = factOriginProjectLogDailyService.getProjectHandledAgency(agencies,customerId,dimId.getMonthId(),"month"); - - Map efficiencyMap = factOriginProjectLogDailyService.getAgencyWorkPieceRatio(agencies,customerId,dimId.getMonthId(),"month"); + ////评价周期内被吹哨且被办结(无论是哪一级办结)的项目数 + Map whistledAgencyClosedProject = factOriginProjectLogDailyService.getWhistledAgencyClosedProjectCount(agencies,customerId,dimId.getMonthId(),"month"); + //处理效率 + Map efficiencyMap = factOriginProjectLogDailyService.getAgencyWorkPieceRatio(customerId,dimId.getMonthId(),"month"); list.forEach(entity ->{ entity.setClosedProjectCount(agencyHandleCount.get(entity.getAgencyId()) == null? NumConstant.ZERO : agencyHandleCount.get(entity.getAgencyId())); - BigDecimal element = new BigDecimal(entity.getClosedProjectCount()); + BigDecimal element = new BigDecimal(Optional.ofNullable(whistledAgencyClosedProject.get(entity.getAgencyId())).orElse(NumConstant.ZERO)); //分母,吹哨次数 Integer denominator = entity.getTransferedCount(); if (null != denominator && denominator != NumConstant.ZERO) { diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginProjectLogDailyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginProjectLogDailyService.java index f8f430eb0a..84a4c06392 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginProjectLogDailyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginProjectLogDailyService.java @@ -178,7 +178,7 @@ public interface FactOriginProjectLogDailyService extends BaseService getProjectHandledAgency(List agencies, String customerId, String dimId,String dateType); /** - * @Description 查询机关单位经手的项目数,去重 + * @Description 评价周期内被吹哨且被办结(无论是哪一级办结)的项目数 * @param agencies * @param dimId * @param dateType - 日期维度类型 month date week quarter year @@ -186,16 +186,16 @@ public interface FactOriginProjectLogDailyService extends BaseService getCountOfDealingAgency(List agencies, String customerId,String dimId,String dateType); + Map getWhistledAgencyClosedProjectCount(List agencies, String customerId,String dimId,String dateType); /** * @Description 计算机关办结项目效率 - * @param agencies + * @param customerId * @return * @author wangc * @date 2020.09.21 02:16 **/ - Map getAgencyWorkPieceRatio(List agencies, String customerId,String dimId,String dateType); + Map getAgencyWorkPieceRatio( String customerId,String dimId,String dateType); /** * 网格项目响应度 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginProjectLogDailyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginProjectLogDailyServiceImpl.java index cff8dc53c1..435990bc38 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginProjectLogDailyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginProjectLogDailyServiceImpl.java @@ -38,6 +38,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +import javax.naming.LinkLoopException; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.*; @@ -183,7 +184,7 @@ public class FactOriginProjectLogDailyServiceImpl extends BaseServiceImpl getCountOfDealingAgency(List agencies, String customerId,String dimId, String dateType) { + public Map getWhistledAgencyClosedProjectCount(List agencies, String customerId,String dimId, String dateType) { Map result = new HashMap<>(); - List projectAgencyCount = baseDao.selectProjectParticipatedAgency(agencies,customerId,dimId); + List projectAgencyCount = baseDao.selectWhistledAgencyClosedProjectCount(agencies,customerId,dimId); if(!CollectionUtils.isEmpty(projectAgencyCount)){ result = projectAgencyCount.stream().collect(Collectors.toMap(ProjectParticipatedAgencyResultDTO::getAgencyId,ProjectParticipatedAgencyResultDTO::getCount)); } @@ -203,48 +204,63 @@ public class FactOriginProjectLogDailyServiceImpl extends BaseServiceImpl getAgencyWorkPieceRatio(List agencies, String customerId,String dimId, String dateType) { - //网格、部门的办结系数 - List gridDeptResponse = projectOrgPeriodDailyDao.selectSubOrgResponseCoefficient(customerId, dimId, dateType); - //机关的办结系数 - List agencyResponse = projectOrgPeriodDailyDao.selectAgencyResponseCoefficient(customerId, dimId, dateType); - Map consumingMap = new HashMap<>(); - Map timeMap = new HashMap<>(); - if(!CollectionUtils.isEmpty(agencyResponse)){ - agencyResponse.forEach(response -> { - consumingMap.put(response.getAgencyId(),response.getResponseTime()); - //注意,这里取的是去重后的项目次数,例如一个部门被项目流转了多次,项目数只算一次 - //如果需要改成不去重,只需response.getProjectTotal() - timeMap.put(response.getAgencyId(),response.getDistinctProjectTotal()); - }); - } - if(!CollectionUtils.isEmpty(gridDeptResponse)){ - gridDeptResponse.forEach(response -> { - if(null != consumingMap.get(response.getAgencyId())){ - consumingMap.put(response.getAgencyId(),consumingMap.get(response.getAgencyId()).add(response.getResponseTime())); - timeMap.put(response.getAgencyId(),timeMap.get(response.getAgencyId()).add(response.getDistinctProjectTotal())); - }else{ - consumingMap.put(response.getAgencyId(),response.getResponseTime()); - timeMap.put(response.getAgencyId(),response.getDistinctProjectTotal()); - } - }); - } - //效率map + public Map getAgencyWorkPieceRatio(String customerId,String dimId, String dateType) { + //计算方法 : 评价周期内办结项目的平均处理时长的倒数 + + + //1.评价周期内结案了的项目 + List projectsHandledByAgency = baseDao.selectProjectIdHandledByAgency(customerId,dimId); Map efficiencyMap = new HashMap<>(); - if(!CollectionUtils.isEmpty(consumingMap)) { - consumingMap.keySet().forEach(agencyId -> { - efficiencyMap.put(agencyId, consumingMap.get(agencyId).divide(timeMap.get(agencyId), NumConstant.SIX, RoundingMode.HALF_UP)); + if(!CollectionUtils.isEmpty(projectsHandledByAgency)){ + Map> agencyProjectsMap = new HashMap<>(); + + projectsHandledByAgency.forEach(o -> { + String agencyId = o.getAgencyId(); + String projectId = o.getProjectId(); + if(CollectionUtils.isEmpty(agencyProjectsMap.get(agencyId))){ + List projectUnit = new LinkedList<>(); + projectUnit.add(projectId); + agencyProjectsMap.put(agencyId,projectUnit); + }else{ + agencyProjectsMap.get(agencyId).add(projectId); + } + }); + + List projects = new LinkedList<>(); + agencyProjectsMap.forEach((key,value) -> {projects.addAll(value);}); + //2.结案项目的总耗时 + List costTimes = baseDao.selectProjectCostTime(projects); + + Map projectCostTime = costTimes.stream().collect(Collectors.toMap(ProjectParticipatedAgencyResultDTO::getProjectId,ProjectParticipatedAgencyResultDTO::getCount)); + agencyProjectsMap.forEach((k,v) -> { + //k -> agencyId v -> projects + int total = NumConstant.ZERO; + if(!CollectionUtils.isEmpty(v)){ + for(String p : v){ + Integer cost = projectCostTime.get(p); + total = total + (null == cost ? NumConstant.ZERO : cost); + } + //每个机关的项目平均耗时 + BigDecimal avgCost = new BigDecimal(total).divide(new BigDecimal(v.size()),4, BigDecimal.ROUND_HALF_UP); + + efficiencyMap.put(k,BigDecimal.ONE.divide(avgCost,4, BigDecimal.ROUND_HALF_UP)); + + }else{ + efficiencyMap.put(k,BigDecimal.ZERO); + } }); } + return efficiencyMap; } + @Override public List getGridResponse(String customerId, String monthId) { return baseDao.selectGridResponse(customerId, monthId); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectLogDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectLogDailyDao.xml index b389aa1aa3..3ec448ae2c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectLogDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectLogDailyDao.xml @@ -180,6 +180,29 @@ GROUP BY AGENCY_ID + + + + + +