|  |  | @ -21,23 +21,25 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
			
		
	
		
			
				
					|  |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.constant.FieldConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.constant.NumConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.page.PageData; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.utils.ConvertUtils; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.evaluationindex.extract.FactOriginProjectLogDailyDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.evaluationindex.extract.FactOriginProjectOrgPeriodDailyDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.extract.FactOriginProjectLogDailyDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.extract.result.OrgStatisticsResultDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.extract.result.AutoNoMyResultDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.extract.result.NotReturnProjectResultDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.extract.result.ProjectEvaluateResultDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.extract.result.*; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.entity.evaluationindex.extract.FactOriginProjectLogDailyEntity; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.evaluationindex.extract.FactOriginProjectLogDailyService; | 
			
		
	
		
			
				
					|  |  |  | import org.apache.commons.lang3.StringUtils; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.stereotype.Service; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.util.CollectionUtils; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import java.util.Arrays; | 
			
		
	
		
			
				
					|  |  |  | import java.util.List; | 
			
		
	
		
			
				
					|  |  |  | import java.util.Map; | 
			
		
	
		
			
				
					|  |  |  | import java.math.BigDecimal; | 
			
		
	
		
			
				
					|  |  |  | import java.math.RoundingMode; | 
			
		
	
		
			
				
					|  |  |  | import java.util.*; | 
			
		
	
		
			
				
					|  |  |  | import java.util.stream.Collectors; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | /** | 
			
		
	
		
			
				
					|  |  |  |  * 项目明细_日统计 | 
			
		
	
	
		
			
				
					|  |  | @ -48,6 +50,8 @@ import java.util.Map; | 
			
		
	
		
			
				
					|  |  |  | @Service | 
			
		
	
		
			
				
					|  |  |  | public class FactOriginProjectLogDailyServiceImpl extends BaseServiceImpl<FactOriginProjectLogDailyDao, FactOriginProjectLogDailyEntity> implements FactOriginProjectLogDailyService { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private FactOriginProjectOrgPeriodDailyDao projectOrgPeriodDailyDao; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public PageData<FactOriginProjectLogDailyDTO> page(Map<String, Object> params) { | 
			
		
	
	
		
			
				
					|  |  | @ -152,4 +156,79 @@ public class FactOriginProjectLogDailyServiceImpl extends BaseServiceImpl<FactOr | 
			
		
	
		
			
				
					|  |  |  |         return baseDao.selectSatisfaction(customerId, monthId, level); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * @Description 查询各项目经受了多少机关 | 
			
		
	
		
			
				
					|  |  |  |      * @param customerId | 
			
		
	
		
			
				
					|  |  |  |      * @return | 
			
		
	
		
			
				
					|  |  |  |      * @author wangc | 
			
		
	
		
			
				
					|  |  |  |      * @date 2020.09.20 23:46 | 
			
		
	
		
			
				
					|  |  |  |      **/ | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public Map<String, Integer> getProjectHandledAgency(String customerId, String dimId, String dateType) { | 
			
		
	
		
			
				
					|  |  |  |         Map<String, Integer> result = new HashMap<>(); | 
			
		
	
		
			
				
					|  |  |  |         List<ProjectParticipatedAgencyResultDTO> projectAgency = baseDao.selectProjectParticipatedAgency(customerId,dimId,dateType); | 
			
		
	
		
			
				
					|  |  |  |         if(!CollectionUtils.isEmpty(projectAgency)){ | 
			
		
	
		
			
				
					|  |  |  |             Map<String,List<ProjectParticipatedAgencyResultDTO>> map | 
			
		
	
		
			
				
					|  |  |  |                     = projectAgency.stream().collect(Collectors.groupingBy(ProjectParticipatedAgencyResultDTO :: getProjectId)); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             map.forEach((key ,agencies) ->{ | 
			
		
	
		
			
				
					|  |  |  |                 if(!CollectionUtils.isEmpty(agencies)) { | 
			
		
	
		
			
				
					|  |  |  |                     String highest = agencies.get(NumConstant.ZERO).getLevel(); | 
			
		
	
		
			
				
					|  |  |  |                     for (int i = NumConstant.ZERO; i < agencies.size(); i++) { | 
			
		
	
		
			
				
					|  |  |  |                         if(StringUtils.equals(agencies.get(i).getLevel(),highest)){ | 
			
		
	
		
			
				
					|  |  |  |                             if(null != result.get(agencies.get(i).getAgencyId())){ | 
			
		
	
		
			
				
					|  |  |  |                                 result.put(key,result.get(agencies.get(i).getAgencyId()) + NumConstant.ONE); | 
			
		
	
		
			
				
					|  |  |  |                             }else{ | 
			
		
	
		
			
				
					|  |  |  |                                 result.put(key,NumConstant.ONE); | 
			
		
	
		
			
				
					|  |  |  |                             } | 
			
		
	
		
			
				
					|  |  |  |                         }else break; | 
			
		
	
		
			
				
					|  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |             }); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         return result; | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * @Description 计算机关响应度 | 
			
		
	
		
			
				
					|  |  |  |      * @param customerId | 
			
		
	
		
			
				
					|  |  |  |      * @return | 
			
		
	
		
			
				
					|  |  |  |      * @author wangc | 
			
		
	
		
			
				
					|  |  |  |      * @date 2020.09.21 02:16 | 
			
		
	
		
			
				
					|  |  |  |      **/ | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public Map<String, BigDecimal> getAgencyResponseRatio(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<String,BigDecimal> ratioMap = new HashMap<>(); | 
			
		
	
		
			
				
					|  |  |  |         if(!CollectionUtils.isEmpty(consumingMap)) { | 
			
		
	
		
			
				
					|  |  |  |             consumingMap.keySet().forEach(agencyId -> { | 
			
		
	
		
			
				
					|  |  |  |                 ratioMap.put(agencyId, consumingMap.get(agencyId).divide(timeMap.get(agencyId), NumConstant.SIX, RoundingMode.HALF_UP)); | 
			
		
	
		
			
				
					|  |  |  |             }); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         return ratioMap; | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | } |