|
|
@ -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<FactOr |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 查询机关单位经手的项目数,去重 |
|
|
|
* @Description 评价周期内被吹哨且被办结(无论是哪一级办结)的项目数 |
|
|
|
* @param agencies |
|
|
|
* @param dimId |
|
|
|
* @param dateType - 日期维度类型 month date week quarter year |
|
|
@ -192,9 +193,9 @@ public class FactOriginProjectLogDailyServiceImpl extends BaseServiceImpl<FactOr |
|
|
|
* @date 2020.09.23 10:06 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public Map<String, Integer> getCountOfDealingAgency(List<String> agencies, String customerId,String dimId, String dateType) { |
|
|
|
public Map<String, Integer> getWhistledAgencyClosedProjectCount(List<String> agencies, String customerId,String dimId, String dateType) { |
|
|
|
Map<String,Integer> result = new HashMap<>(); |
|
|
|
List<ProjectParticipatedAgencyResultDTO> projectAgencyCount = baseDao.selectProjectParticipatedAgency(agencies,customerId,dimId); |
|
|
|
List<ProjectParticipatedAgencyResultDTO> 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<FactOr |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 计算机关办结项目效率 |
|
|
|
* @param agencies |
|
|
|
* @param |
|
|
|
* @return |
|
|
|
* @author wangc |
|
|
|
* @date 2020.09.21 02:16 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public Map<String, BigDecimal> getAgencyWorkPieceRatio(List<String> agencies, String customerId,String dimId, String dateType) { |
|
|
|
//网格、部门的办结系数
|
|
|
|
List<OrgResponseTimeResultDTO> gridDeptResponse = projectOrgPeriodDailyDao.selectSubOrgResponseCoefficient(customerId, dimId, dateType); |
|
|
|
//机关的办结系数
|
|
|
|
List<OrgResponseTimeResultDTO> agencyResponse = projectOrgPeriodDailyDao.selectAgencyResponseCoefficient(customerId, dimId, dateType); |
|
|
|
Map<String,BigDecimal> consumingMap = new HashMap<>(); |
|
|
|
Map<String,BigDecimal> 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<String, BigDecimal> getAgencyWorkPieceRatio(String customerId,String dimId, String dateType) { |
|
|
|
//计算方法 : 评价周期内办结项目的平均处理时长的倒数
|
|
|
|
|
|
|
|
|
|
|
|
//1.评价周期内结案了的项目
|
|
|
|
List<ProjectParticipatedAgencyResultDTO> projectsHandledByAgency = baseDao.selectProjectIdHandledByAgency(customerId,dimId); |
|
|
|
Map<String,BigDecimal> 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<String,List<String>> agencyProjectsMap = new HashMap<>(); |
|
|
|
|
|
|
|
projectsHandledByAgency.forEach(o -> { |
|
|
|
String agencyId = o.getAgencyId(); |
|
|
|
String projectId = o.getProjectId(); |
|
|
|
if(CollectionUtils.isEmpty(agencyProjectsMap.get(agencyId))){ |
|
|
|
List<String> projectUnit = new LinkedList<>(); |
|
|
|
projectUnit.add(projectId); |
|
|
|
agencyProjectsMap.put(agencyId,projectUnit); |
|
|
|
}else{ |
|
|
|
agencyProjectsMap.get(agencyId).add(projectId); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
List<String> projects = new LinkedList<>(); |
|
|
|
agencyProjectsMap.forEach((key,value) -> {projects.addAll(value);}); |
|
|
|
//2.结案项目的总耗时
|
|
|
|
List<ProjectParticipatedAgencyResultDTO> costTimes = baseDao.selectProjectCostTime(projects); |
|
|
|
|
|
|
|
Map<String,Integer> 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<OrgStatisticsResultDTO> getGridResponse(String customerId, String monthId) { |
|
|
|
return baseDao.selectGridResponse(customerId, monthId); |
|
|
|