Browse Source

Merge remote-tracking branch 'remotes/origin/dev'

dev_shibei_match
jianjun 5 years ago
parent
commit
fc40b2c73e
  1. 2
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  2. 2
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/result/ProjectParticipatedAgencyResultDTO.java
  3. 1
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java
  4. 31
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginProjectLogDailyDao.java
  5. 7
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/CalculateFlagModel.java
  6. 25
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollCommunityServiceImpl.java
  7. 24
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollDistrictServiceImpl.java
  8. 24
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollStreetServiceImpl.java
  9. 8
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginProjectLogDailyService.java
  10. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginExtractServiceImpl.java
  11. 102
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginProjectLogDailyServiceImpl.java
  12. 8
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java
  13. 94
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectLogDailyDao.xml

2
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java

@ -313,7 +313,7 @@ public class RedisKeys {
* @return * @return
*/ */
public static String getIndexCodeWeightKey(String customerId) { public static String getIndexCodeWeightKey(String customerId) {
return rootPrefix.concat("stats:indexcal:indexcode:weight").concat(customerId); return rootPrefix.concat("stats:indexcal:indexcode:weight").concat(StrConstant.COLON).concat(customerId);
} }
/** /**

2
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 String agencyId;
private int count; private int count;
private String projectId;
} }

1
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java

@ -165,6 +165,7 @@ public class IndexCalculateController {
CalculateFlagModel flag = new CalculateFlagModel(); CalculateFlagModel flag = new CalculateFlagModel();
flag.setStatus(CalculateStatus.CALCULATING); flag.setStatus(CalculateStatus.CALCULATING);
flag.setForm(formDTO); flag.setForm(formDTO);
flag.setStartTime(DateUtils.format(new Date(), DateUtils.DATE_TIME_PATTERN));
redisUtils.set(RedisKeys.getCustomerStatsCalFlag(formDTO.getCustomerId()), flag); redisUtils.set(RedisKeys.getCustomerStatsCalFlag(formDTO.getCustomerId()), flag);
} }

31
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.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
/** /**
@ -116,7 +117,7 @@ public interface FactOriginProjectLogDailyDao extends BaseDao<FactOriginProjectL
List<ProjectParticipatedAgencyResultDTO> selectProjectParticipatedAgency(@Param("agencies") List<String> agencies, @Param("customerId") String customerId,@Param("dimId") String dimId); List<ProjectParticipatedAgencyResultDTO> selectProjectParticipatedAgency(@Param("agencies") List<String> agencies, @Param("customerId") String customerId,@Param("dimId") String dimId);
/*** /***
* @Description 评价周期内被吹哨 * @Description 评价周期内被吹哨项目
* @param agencies * @param agencies
* @param customerId * @param customerId
* @param dimId * @param dimId
@ -125,7 +126,16 @@ public interface FactOriginProjectLogDailyDao extends BaseDao<FactOriginProjectL
* @date 2020.10.15 11:20 * @date 2020.10.15 11:20
*/ */
List<ProjectParticipatedAgencyResultDTO> selectAgencyWhistledCount(@Param("agencies") List<String> agencies, @Param("customerId") String customerId,@Param("dimId") String dimId); List<ProjectParticipatedAgencyResultDTO> selectAgencyWhistledCount(@Param("agencies") List<String> agencies, @Param("customerId") String customerId,@Param("dimId") String dimId);
/***
* @Description 评价周期内被吹哨且被办结(无论是哪一级办结)的项目数
* @param agencies
* @param customerId
* @param dimId
* @return java.util.List<com.epmet.dto.extract.result.ProjectParticipatedAgencyResultDTO>
* @author wangc
* @date 2020.10.16 10:43
*/
List<ProjectParticipatedAgencyResultDTO> selectWhistledAgencyClosedProjectCount(@Param("agencies") List<String> agencies, @Param("customerId") String customerId,@Param("dimId") String dimId);
/*** /***
* @Description 查询机关办结次数 * @Description 查询机关办结次数
* @param agencies * @param agencies
@ -134,7 +144,24 @@ public interface FactOriginProjectLogDailyDao extends BaseDao<FactOriginProjectL
* @date 2020.10.14 10:27 * @date 2020.10.14 10:27
*/ */
List<ProjectParticipatedAgencyResultDTO> selectAgencyHandledProjectCount(@Param("agencies") List<String> agencies,@Param("customerId") String customerId,@Param("dimId") String dimId); List<ProjectParticipatedAgencyResultDTO> selectAgencyHandledProjectCount(@Param("agencies") List<String> agencies,@Param("customerId") String customerId,@Param("dimId") String dimId);
/**
* @Description 查询评价周期内各级别机关办结的项目Id
* @param customerId
* @param dimId
* @return java.util.List<com.epmet.dto.extract.result.ProjectParticipatedAgencyResultDTO>
* @author wangc
* @date 2020.10.15 17:29
*/
List<ProjectParticipatedAgencyResultDTO> selectProjectIdHandledByAgency(@Param("customerId") String customerId,@Param("dimId") String dimId);
/**
* @Description 计算每个办结项目的总耗时
* @param projectIds
* @return java.util.List<com.epmet.dto.extract.result.ProjectParticipatedAgencyResultDTO>
* @author wangc
* @date 2020.10.15 17:32
*/
List<ProjectParticipatedAgencyResultDTO> selectProjectCostTime(@Param("projectIds") List<String> projectIds);
/** /**
* 网格项目响应度 * 网格项目响应度
* @author zhaoqifeng * @author zhaoqifeng

7
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/CalculateFlagModel.java

@ -17,4 +17,11 @@ public class CalculateFlagModel {
*/ */
private String status; private String status;
/**
* 开始时间
* CalculateStatus.java
*/
private String startTime;
} }

25
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollCommunityServiceImpl.java

@ -134,24 +134,19 @@ public class IndexCollCommunityServiceImpl implements IndexCollCommunityService
})); }));
} }
//办结数
List<String> agencies = agencyList.stream().map(DimAgencyDTO :: getId).distinct().collect(Collectors.toList()); List<String> agencies = agencyList.stream().map(DimAgencyDTO :: getId).distinct().collect(Collectors.toList());
//办结数
Map<String, Integer> agencyHandleCount = factOriginProjectLogDailyService.getProjectHandledAgency(agencies,customerId,dimId.getMonthId(),"month"); Map<String, Integer> agencyHandleCount = factOriginProjectLogDailyService.getProjectHandledAgency(agencies,customerId,dimId.getMonthId(),"month");
Map<String,BigDecimal> efficiencyMap = factOriginProjectLogDailyService.getAgencyWorkPieceRatio(agencies,customerId,dimId.getMonthId(),"month"); //办结率
Map<String, BigDecimal> handlingRatioMap = factOriginProjectLogDailyService.getHandlingRatio(agencies,customerId,dimId.getMonthId(),"month");
//处理效率
Map<String,BigDecimal> efficiencyMap = factOriginProjectLogDailyService.getAgencyWorkPieceRatio(customerId,dimId.getMonthId(),"month");
list.forEach(entity ->{ list.forEach(entity ->{
entity.setClosedProjectCount(agencyHandleCount.get(entity.getAgencyId()) == null? NumConstant.ZERO : agencyHandleCount.get(entity.getAgencyId())); //办结数
BigDecimal element = new BigDecimal(entity.getClosedProjectCount()); entity.setClosedProjectCount(Optional.ofNullable(agencyHandleCount.get(entity.getAgencyId())).orElse(NumConstant.ZERO));
//分母,即机关参与过的项目数(去重) //办结率
//“评价周期内被吹哨且办结的项目数”/“评价周期内被吹哨的所有项目数” entity.setClosedProjectRatio(Optional.ofNullable(handlingRatioMap.get(entity.getAgencyId())).orElse(BigDecimal.ZERO));
Integer denominator = entity.getTransferedCount();
if (null != denominator && denominator != NumConstant.ZERO) {
//办结率
entity.setClosedProjectRatio(
element.divide(new BigDecimal(denominator), NumConstant.SIX, RoundingMode.HALF_UP)
);
}else{
entity.setClosedProjectRatio(BigDecimal.ZERO);
}
//办结效率 //办结效率
entity.setHandleProjectRatio(Optional.ofNullable(efficiencyMap.get(entity.getAgencyId())).orElse(BigDecimal.ZERO)); entity.setHandleProjectRatio(Optional.ofNullable(efficiencyMap.get(entity.getAgencyId())).orElse(BigDecimal.ZERO));

24
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollDistrictServiceImpl.java

@ -127,25 +127,19 @@ public class IndexCollDistrictServiceImpl implements IndexCollDistrictService {
} }
})); }));
} }
//办结数
List<String> agencies = agencyList.stream().map(DimAgencyDTO :: getId).distinct().collect(Collectors.toList()); List<String> agencies = agencyList.stream().map(DimAgencyDTO :: getId).distinct().collect(Collectors.toList());
//办结数
Map<String, Integer> agencyHandleCount = factOriginProjectLogDailyService.getProjectHandledAgency(agencies,customerId,dimId.getMonthId(),"month"); Map<String, Integer> agencyHandleCount = factOriginProjectLogDailyService.getProjectHandledAgency(agencies,customerId,dimId.getMonthId(),"month");
//办结率
Map<String,BigDecimal> efficiencyMap = factOriginProjectLogDailyService.getAgencyWorkPieceRatio(agencies,customerId,dimId.getMonthId(),"month"); Map<String, BigDecimal> handlingRatioMap = factOriginProjectLogDailyService.getHandlingRatio(agencies,customerId,dimId.getMonthId(),"month");
//处理效率
Map<String,BigDecimal> efficiencyMap = factOriginProjectLogDailyService.getAgencyWorkPieceRatio(customerId,dimId.getMonthId(),"month");
list.forEach(entity ->{ list.forEach(entity ->{
//办结数
entity.setClosedProjectCount(agencyHandleCount.get(entity.getAgencyId()) == null? NumConstant.ZERO : agencyHandleCount.get(entity.getAgencyId())); entity.setClosedProjectCount(agencyHandleCount.get(entity.getAgencyId()) == null? NumConstant.ZERO : agencyHandleCount.get(entity.getAgencyId()));
BigDecimal element = new BigDecimal(entity.getClosedProjectCount()); //办结率
//分母,即机关参与过的项目数(去重) entity.setClosedProjectRatio(Optional.ofNullable(handlingRatioMap.get(entity.getAgencyId())).orElse(BigDecimal.ZERO));
//“评价周期内被吹哨且办结的项目数”/“评价周期内被吹哨的所有项目数”
Integer denominator = entity.getTransferedCount();
if (null != denominator && denominator != NumConstant.ZERO) {
//办结率
entity.setClosedProjectRatio(
element.divide(new BigDecimal(denominator), NumConstant.SIX, RoundingMode.HALF_UP)
);
}else{
entity.setClosedProjectRatio(BigDecimal.ZERO);
}
//办结效率 //办结效率
entity.setHandleProjectRatio(Optional.ofNullable(efficiencyMap.get(entity.getAgencyId())).orElse(BigDecimal.ZERO)); entity.setHandleProjectRatio(Optional.ofNullable(efficiencyMap.get(entity.getAgencyId())).orElse(BigDecimal.ZERO));
}); });

24
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollStreetServiceImpl.java

@ -125,25 +125,19 @@ public class IndexCollStreetServiceImpl implements IndexCollStreetService {
} }
})); }));
} }
//办结数
List<String> agencies = agencyList.stream().map(DimAgencyDTO :: getId).distinct().collect(Collectors.toList()); List<String> agencies = agencyList.stream().map(DimAgencyDTO :: getId).distinct().collect(Collectors.toList());
//办结数
Map<String, Integer> agencyHandleCount = factOriginProjectLogDailyService.getProjectHandledAgency(agencies,customerId,dimId.getMonthId(),"month"); Map<String, Integer> agencyHandleCount = factOriginProjectLogDailyService.getProjectHandledAgency(agencies,customerId,dimId.getMonthId(),"month");
//办结率
Map<String,BigDecimal> efficiencyMap = factOriginProjectLogDailyService.getAgencyWorkPieceRatio(agencies,customerId,dimId.getMonthId(),"month"); Map<String, BigDecimal> handlingRatioMap = factOriginProjectLogDailyService.getHandlingRatio(agencies,customerId,dimId.getMonthId(),"month");
//处理效率
Map<String,BigDecimal> efficiencyMap = factOriginProjectLogDailyService.getAgencyWorkPieceRatio(customerId,dimId.getMonthId(),"month");
list.forEach(entity ->{ list.forEach(entity ->{
//办结数
entity.setClosedProjectCount(agencyHandleCount.get(entity.getAgencyId()) == null? NumConstant.ZERO : agencyHandleCount.get(entity.getAgencyId())); entity.setClosedProjectCount(agencyHandleCount.get(entity.getAgencyId()) == null? NumConstant.ZERO : agencyHandleCount.get(entity.getAgencyId()));
BigDecimal element = new BigDecimal(entity.getClosedProjectCount()); //办结率
//分母,吹哨次数 entity.setClosedProjectRatio(Optional.ofNullable(handlingRatioMap.get(entity.getAgencyId())).orElse(BigDecimal.ZERO));
Integer denominator = entity.getTransferedCount();
if (null != denominator && denominator != NumConstant.ZERO) {
//办结率
//“评价周期内被吹哨且办结的项目数”/“评价周期内被吹哨的所有项目数”
entity.setClosedProjectRatio(
element.divide(new BigDecimal(denominator), NumConstant.SIX, RoundingMode.HALF_UP)
);
}else{
entity.setClosedProjectRatio(BigDecimal.ZERO);
}
//办结效率 //办结效率
entity.setHandleProjectRatio(Optional.ofNullable(efficiencyMap.get(entity.getAgencyId())).orElse(BigDecimal.ZERO)); entity.setHandleProjectRatio(Optional.ofNullable(efficiencyMap.get(entity.getAgencyId())).orElse(BigDecimal.ZERO));
}); });

8
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<FactOrigin
Map<String,Integer> getProjectHandledAgency(List<String> agencies, String customerId, String dimId,String dateType); Map<String,Integer> getProjectHandledAgency(List<String> agencies, String customerId, String dimId,String dateType);
/** /**
* @Description 查询机关单位经手的项目数去重 * @Description 办结率
* @param agencies * @param agencies
* @param dimId * @param dimId
* @param dateType - 日期维度类型 month date week quarter year * @param dateType - 日期维度类型 month date week quarter year
@ -186,16 +186,16 @@ public interface FactOriginProjectLogDailyService extends BaseService<FactOrigin
* @author wangc * @author wangc
* @date 2020.09.23 10:06 * @date 2020.09.23 10:06
**/ **/
Map<String,Integer> getCountOfDealingAgency(List<String> agencies, String customerId,String dimId,String dateType); Map<String,BigDecimal> getHandlingRatio(List<String> agencies, String customerId,String dimId,String dateType);
/** /**
* @Description 计算机关办结项目效率 * @Description 计算机关办结项目效率
* @param agencies * @param customerId
* @return * @return
* @author wangc * @author wangc
* @date 2020.09.21 02:16 * @date 2020.09.21 02:16
**/ **/
Map<String, BigDecimal> getAgencyWorkPieceRatio(List<String> agencies, String customerId,String dimId,String dateType); Map<String, BigDecimal> getAgencyWorkPieceRatio( String customerId,String dimId,String dateType);
/** /**
* 网格项目响应度 * 网格项目响应度

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginExtractServiceImpl.java

@ -151,7 +151,7 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService {
log.error("抽取【话题数据】发生异常,参数:" + JSON.toJSONString(paramNew), e); log.error("抽取【话题数据】发生异常,参数:" + JSON.toJSONString(paramNew), e);
} }
} }
log.info("extractAll end param:{}", JSON.toJSONString(paramNew)); log.debug("extractAll end param:{}", JSON.toJSONString(paramNew));
}); });
threadPool.submit(() -> { threadPool.submit(() -> {
ExtractOriginFormDTO paramNew = ConvertUtils.sourceToTarget(param, ExtractOriginFormDTO.class); ExtractOriginFormDTO paramNew = ConvertUtils.sourceToTarget(param, ExtractOriginFormDTO.class);

102
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.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import javax.naming.LinkLoopException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.*; import java.util.*;
@ -183,7 +184,7 @@ public class FactOriginProjectLogDailyServiceImpl extends BaseServiceImpl<FactOr
/** /**
* @Description 查询机关单位经手的项目数去重 * @Description 办结率
* @param agencies * @param agencies
* @param dimId * @param dimId
* @param dateType - 日期维度类型 month date week quarter year * @param dateType - 日期维度类型 month date week quarter year
@ -192,59 +193,88 @@ public class FactOriginProjectLogDailyServiceImpl extends BaseServiceImpl<FactOr
* @date 2020.09.23 10:06 * @date 2020.09.23 10:06
**/ **/
@Override @Override
public Map<String, Integer> getCountOfDealingAgency(List<String> agencies, String customerId,String dimId, String dateType) { public Map<String, BigDecimal> getHandlingRatio(List<String> agencies, String customerId,String dimId, String dateType) {
Map<String,Integer> result = new HashMap<>(); //计算方式:“评价周期内被吹哨且办结(无论是哪一级办结)的项目数”/“评价周期内被吹哨的所有项目数”
List<ProjectParticipatedAgencyResultDTO> projectAgencyCount = baseDao.selectProjectParticipatedAgency(agencies,customerId,dimId);
Map<String,BigDecimal> result = new HashMap<>();
List<ProjectParticipatedAgencyResultDTO> projectAgencyCount = baseDao.selectWhistledAgencyClosedProjectCount(agencies,customerId,dimId);
if(!CollectionUtils.isEmpty(projectAgencyCount)){ if(!CollectionUtils.isEmpty(projectAgencyCount)){
result = projectAgencyCount.stream().collect(Collectors.toMap(ProjectParticipatedAgencyResultDTO::getAgencyId,ProjectParticipatedAgencyResultDTO::getCount)); Map<String,Integer> whistledAndHandledProjectTotalMap = projectAgencyCount.stream().collect(Collectors.toMap(ProjectParticipatedAgencyResultDTO::getAgencyId,ProjectParticipatedAgencyResultDTO::getCount));
List<ProjectParticipatedAgencyResultDTO> whistledProjectTotal = baseDao.selectAgencyWhistledCount(agencies,customerId,dimId);
Map<String,Integer> whistledProjectTotalMap = whistledProjectTotal.stream().collect(Collectors.toMap(ProjectParticipatedAgencyResultDTO::getAgencyId,ProjectParticipatedAgencyResultDTO::getCount));
whistledAndHandledProjectTotalMap.forEach((agencyId,count) -> {
//分母 被吹哨项目数
Integer denominator = whistledProjectTotalMap.get(agencyId);
if(null == denominator || NumConstant.ZERO == denominator){
result.put(agencyId,BigDecimal.ZERO);
}else{
result.put(agencyId,new BigDecimal(count).divide(new BigDecimal(denominator), NumConstant.SIX, RoundingMode.HALF_UP));
}
});
} }
return result; return result;
} }
/** /**
* @Description 计算机关办结项目效率 * @Description 计算机关办结项目效率
* @param agencies * @param
* @return * @return
* @author wangc * @author wangc
* @date 2020.09.21 02:16 * @date 2020.09.21 02:16
**/ **/
@Override @Override
public Map<String, BigDecimal> getAgencyWorkPieceRatio(List<String> agencies, String customerId,String dimId, String dateType) { public Map<String, BigDecimal> getAgencyWorkPieceRatio(String customerId,String dimId, String dateType) {
//网格、部门的办结系数 //计算方法 : 评价周期内办结项目的平均处理时长的倒数
List<OrgResponseTimeResultDTO> gridDeptResponse = projectOrgPeriodDailyDao.selectSubOrgResponseCoefficient(customerId, dimId, dateType);
//机关的办结系数
List<OrgResponseTimeResultDTO> agencyResponse = projectOrgPeriodDailyDao.selectAgencyResponseCoefficient(customerId, dimId, dateType); //1.评价周期内结案了的项目
Map<String,BigDecimal> consumingMap = new HashMap<>(); List<ProjectParticipatedAgencyResultDTO> projectsHandledByAgency = baseDao.selectProjectIdHandledByAgency(customerId,dimId);
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
Map<String,BigDecimal> efficiencyMap = new HashMap<>(); Map<String,BigDecimal> efficiencyMap = new HashMap<>();
if(!CollectionUtils.isEmpty(consumingMap)) { if(!CollectionUtils.isEmpty(projectsHandledByAgency)){
consumingMap.keySet().forEach(agencyId -> { Map<String,List<String>> agencyProjectsMap = new HashMap<>();
efficiencyMap.put(agencyId, consumingMap.get(agencyId).divide(timeMap.get(agencyId), NumConstant.SIX, RoundingMode.HALF_UP));
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; return efficiencyMap;
} }
@Override @Override
public List<OrgStatisticsResultDTO> getGridResponse(String customerId, String monthId) { public List<OrgStatisticsResultDTO> getGridResponse(String customerId, String monthId) {
return baseDao.selectGridResponse(customerId, monthId); return baseDao.selectGridResponse(customerId, monthId);

8
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java

@ -2,7 +2,9 @@ package com.epmet.service.evaluationindex.extract.toscreen.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.enums.EnvEnum;
import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.dto.extract.form.ExtractOriginFormDTO; import com.epmet.dto.extract.form.ExtractOriginFormDTO;
import com.epmet.dto.extract.form.ExtractScreenFormDTO; import com.epmet.dto.extract.form.ExtractScreenFormDTO;
import com.epmet.dto.indexcal.CalculateCommonFormDTO; import com.epmet.dto.indexcal.CalculateCommonFormDTO;
@ -167,6 +169,7 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
}catch (Exception e){ }catch (Exception e){
log.error("基层治理-难点赌点抽取到大屏失败,customerId为:"+customerId+"dateId为:"+dateId, e); log.error("基层治理-难点赌点抽取到大屏失败,customerId为:"+customerId+"dateId为:"+dateId, e);
} }
log.info("===== extractDaily method end ======");
} }
/** /**
@ -245,14 +248,17 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
//此方法保持在最后即可 计算指标分数 todo 优化 手动创建线程池 控制任务数量 //此方法保持在最后即可 计算指标分数 todo 优化 手动创建线程池 控制任务数量
ExecutorService pool = Executors.newSingleThreadExecutor(); ExecutorService pool = Executors.newSingleThreadExecutor();
pool.submit(() -> { pool.submit(() -> {
long start = System.currentTimeMillis();
CalculateCommonFormDTO formDTO1 = new CalculateCommonFormDTO(); CalculateCommonFormDTO formDTO1 = new CalculateCommonFormDTO();
try { try {
formDTO1.setMonthId(monthId); formDTO1.setMonthId(monthId);
formDTO1.setCustomerId(customerId); formDTO1.setCustomerId(customerId);
indexCalculateService.indexCalculate(formDTO1); Boolean aBoolean = indexCalculateService.indexCalculate(formDTO1);
HttpClientManager.getInstance().sendAlarmMsg(EnvEnum.getCurrentEnv().getName() + "客户Id:" + formDTO.getCustomerId() + ",calculateAll全部指标计算完成,是否成功:" + aBoolean + ",总耗时:" + (System.currentTimeMillis() - start) / 1000 + "秒");
} catch (Exception e) { } catch (Exception e) {
log.error("extractMonthly 计算分数异常,参数:{}", JSON.toJSONString(formDTO1)); log.error("extractMonthly 计算分数异常,参数:{}", JSON.toJSONString(formDTO1));
} }
}); });
log.info("===== extractMonthly method end ======");
} }
} }

94
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectLogDailyDao.xml

@ -23,7 +23,7 @@
AND da.`LEVEL` = #{level} AND da.`LEVEL` = #{level}
WHERE WHERE
fopld.IS_ACTIVE = 0 fopld.IS_ACTIVE = 0
AND fopld.ACTION_CODE = 'transfer' AND (fopld.ACTION_CODE = 'transfer' OR fopld.ACTION_CODE = 'created')
AND fopld.MONTH_ID = #{monthId} AND fopld.MONTH_ID = #{monthId}
AND fopld.CUSTOMER_ID = #{customerId} AND fopld.CUSTOMER_ID = #{customerId}
GROUP BY GROUP BY
@ -160,11 +160,11 @@
GROUP BY AGENCY_ID GROUP BY AGENCY_ID
</select> </select>
<!-- 评价周期内被吹哨次数 --> <!-- 评价周期内被吹哨项目数-->
<select id="selectAgencyWhistledCount" resultType="com.epmet.dto.extract.result.ProjectParticipatedAgencyResultDTO"> <select id="selectAgencyWhistledCount" resultType="com.epmet.dto.extract.result.ProjectParticipatedAgencyResultDTO">
SELECT SELECT
AGENCY_ID, AGENCY_ID,
COUNT(ID) AS count COUNT(DISTINCT PROJECT_ID) AS count
FROM FROM
fact_origin_project_log_daily fact_origin_project_log_daily
WHERE DEL_FLAG = '0' WHERE DEL_FLAG = '0'
@ -172,6 +172,18 @@
AND IS_ACTIVE = '0' AND IS_ACTIVE = '0'
<if test='null != dimId and "" != dimId.trim()'> <if test='null != dimId and "" != dimId.trim()'>
AND MONTH_ID = #{dimId} AND MONTH_ID = #{dimId}
AND NOT EXISTS(
SELECT ID
FROM fact_origin_project_log_daily
WHERE DEL_FLAG = '0'
AND MONTH_ID <![CDATA[ < ]]> #{dimId}
AND IS_ACTIVE = '0'
<if test="agencies != null and agencies.size() > 0">
<foreach collection="agencies" item="agencyId" open="AND (" close=" )" separator=" OR ">
AGENCY_ID = #{agencyId}
</foreach>
</if>
)
</if> </if>
<if test="agencies != null and agencies.size() > 0"> <if test="agencies != null and agencies.size() > 0">
<foreach collection="agencies" item="agencyId" open="AND (" close=" )" separator=" OR "> <foreach collection="agencies" item="agencyId" open="AND (" close=" )" separator=" OR ">
@ -180,6 +192,29 @@
</if> </if>
GROUP BY AGENCY_ID GROUP BY AGENCY_ID
</select> </select>
<!-- 评价周期内被吹哨且被办结(无论是哪一级办结)的项目数 -->
<select id="selectWhistledAgencyClosedProjectCount" resultType="com.epmet.dto.extract.result.ProjectParticipatedAgencyResultDTO">
SELECT
log.AGENCY_ID,
COUNT(DISTINCT log.PROJECT_ID) AS count
FROM
fact_origin_project_log_daily log
LEFT JOIN fact_origin_project_main_daily project ON log.PROJECT_ID = project.ID AND project.DEL_FLAG = '0' AND project.CUSTOMER_ID = #{customerId}
WHERE log.DEL_FLAG = '0'
AND project.PROJECT_STATUS LIKE 'close%'
AND log.CUSTOMER_ID = #{customerId}
AND log.IS_ACTIVE = '0'
<if test='null != dimId and "" != dimId.trim()'>
AND log.MONTH_ID = #{dimId}
</if>
<if test="agencies != null and agencies.size() > 0">
<foreach collection="agencies" item="agencyId" open="AND (" close=" )" separator=" OR ">
log.AGENCY_ID = #{agencyId}
</foreach>
</if>
GROUP BY log.AGENCY_ID
</select>
<!-- 查询机关办结次数 --> <!-- 查询机关办结次数 -->
<select id="selectAgencyHandledProjectCount" resultType="com.epmet.dto.extract.result.ProjectParticipatedAgencyResultDTO"> <select id="selectAgencyHandledProjectCount" resultType="com.epmet.dto.extract.result.ProjectParticipatedAgencyResultDTO">
SELECT SELECT
@ -201,7 +236,60 @@
</if> </if>
GROUP BY SUBSTRING_INDEX(main.FINISH_ORG_IDS,':',1) GROUP BY SUBSTRING_INDEX(main.FINISH_ORG_IDS,':',1)
</select> </select>
<!-- 查询评价周期内各级别机关办结的项目Id -->
<select id="selectProjectIdHandledByAgency" resultType="com.epmet.dto.extract.result.ProjectParticipatedAgencyResultDTO">
SELECT
ID AS projectId,
SUBSTRING_INDEX(FINISH_ORG_IDS,':',1) AS agencyId
FROM
fact_origin_project_main_daily
WHERE
DEL_FLAG = '0'
AND ID IN (
SELECT DISTINCT PROJECT_ID FROM fact_origin_project_log_daily
WHERE DEL_FLAG = '0' AND CUSTOMER_ID = #{customerId}
AND ACTION_CODE = 'close'
<if test='null != dimId and "" != dimId'>
AND MONTH_ID = #{dimId}
</if>
)
ORDER BY agencyId
</select>
<!-- 计算每个办结项目的总耗时 -->
<select id="selectProjectCostTime" resultType="com.epmet.dto.extract.result.ProjectParticipatedAgencyResultDTO">
SELECT
DISTINCT
log1.PROJECT_ID,
IF(
TIMESTAMPDIFF( DAY, log2.createdDate, DATE_FORMAT( log1.DATE_ID, '%Y-%m-%d' ) ) = 0,
1,
TIMESTAMPDIFF( DAY, log2.createdDate, DATE_FORMAT( log1.DATE_ID, '%Y-%m-%d' ) )
) * 8 * 60 AS count
FROM
fact_origin_project_log_daily log1
LEFT JOIN (
SELECT
ID ,
DATE_FORMAT( DATE_ID, '%Y-%m-%d' ) AS createdDate
FROM
fact_origin_project_main_daily
WHERE
DEL_FLAG = '0'
<foreach collection="projectIds" item="projectId" open="AND ( " separator=" OR " close=" ) ">
ID = #{projectId}
</foreach>
AND PROJECT_STATUS = 'closed'
) log2 ON log1.PROJECT_ID = log2.ID
WHERE
log1.DEL_FLAG = '0'
<foreach collection="projectIds" item="projectId" open="AND ( " separator=" OR " close=" ) ">
log1.PROJECT_ID = #{projectId}
</foreach>
AND log1.IS_ACTIVE = '1'
AND log1.ACTION_CODE = 'close'
</select>
<select id="selectGridResponse" resultType="com.epmet.dto.extract.result.OrgStatisticsResultDTO"> <select id="selectGridResponse" resultType="com.epmet.dto.extract.result.OrgStatisticsResultDTO">
SELECT a.ORG_ID, SELECT a.ORG_ID,
a.count AS "sum", a.count AS "sum",

Loading…
Cancel
Save