|  |  | @ -47,6 +47,7 @@ import com.epmet.feign.GovIssueOpenFeignClient; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.redis.ProjectRedis; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.redis.ProjectSatisfactionDetailRedis; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.ProjectSatisfactionDetailService; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.ProjectSatisfactionStatisticsService; | 
			
		
	
		
			
				
					|  |  |  | import lombok.extern.slf4j.Slf4j; | 
			
		
	
		
			
				
					|  |  |  | import org.apache.commons.lang3.StringUtils; | 
			
		
	
		
			
				
					|  |  |  | import org.redisson.api.RLock; | 
			
		
	
	
		
			
				
					|  |  | @ -55,6 +56,7 @@ import org.springframework.beans.factory.annotation.Autowired; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.beans.factory.annotation.Value; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.stereotype.Service; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.util.CollectionUtils; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import java.util.*; | 
			
		
	
		
			
				
					|  |  |  | import java.util.stream.Collectors; | 
			
		
	
	
		
			
				
					|  |  | @ -87,6 +89,8 @@ public class ProjectSatisfactionDetailServiceImpl extends BaseServiceImpl<Projec | 
			
		
	
		
			
				
					|  |  |  |     private ProjectRedis projectRedis; | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private GovIssueOpenFeignClient govIssueOpenFeignClient; | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private ProjectSatisfactionStatisticsService projectSatisfactionStatisticsService; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public PageData<ProjectSatisfactionDetailDTO> page(Map<String, Object> params) { | 
			
		
	
	
		
			
				
					|  |  | @ -243,7 +247,6 @@ public class ProjectSatisfactionDetailServiceImpl extends BaseServiceImpl<Projec | 
			
		
	
		
			
				
					|  |  |  |                 if (null == projectEntity){ | 
			
		
	
		
			
				
					|  |  |  |                     throw new RenException("未查询到项目信息"); | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |                 VoteRedisFormDTO issueVoteDetail = projectRedis.getIssueVoteDetail(projectEntity.getOriginId()); | 
			
		
	
		
			
				
					|  |  |  |                 // 应评价数 = 话题创建者 + 议题发起者 + 议题表决人 【去重】
 | 
			
		
	
		
			
				
					|  |  |  |                 // 议题发起者 和 议题表决人 和 话题创建者 查询
 | 
			
		
	
		
			
				
					|  |  |  |                 Result<List<String>> canEvaluateProjectCount = govIssueOpenFeignClient.canEvaluateProjectCount(projectEntity.getOriginId()); | 
			
		
	
	
		
			
				
					|  |  | @ -300,4 +303,75 @@ public class ProjectSatisfactionDetailServiceImpl extends BaseServiceImpl<Projec | 
			
		
	
		
			
				
					|  |  |  |         return baseDao.projectEvaluationList(formDTO); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * @Description  补全项目评价统计 | 
			
		
	
		
			
				
					|  |  |  |      * @author zxc | 
			
		
	
		
			
				
					|  |  |  |      * @date 2021/5/12 10:04 上午 | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public void complementedProjectEvaluate() { | 
			
		
	
		
			
				
					|  |  |  |         // 查询所有已关闭的项目【醒目来源为'issue'】
 | 
			
		
	
		
			
				
					|  |  |  |         List<ComplementedProjectEvaluateResultDTO> allProjects = projectDao.selectAllClosedProject(); | 
			
		
	
		
			
				
					|  |  |  |         if (CollectionUtils.isEmpty(allProjects)){ | 
			
		
	
		
			
				
					|  |  |  |             log.warn("不存在可补全的数据"); | 
			
		
	
		
			
				
					|  |  |  |             return; | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         // 查询已存在的项目记录
 | 
			
		
	
		
			
				
					|  |  |  |         List<String> existsProjects = statisticsDao.selectExistsProject(); | 
			
		
	
		
			
				
					|  |  |  |         List<ComplementedProjectEvaluateResultDTO> projects = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |         if (CollectionUtils.isEmpty(existsProjects)){ | 
			
		
	
		
			
				
					|  |  |  |             projects = allProjects; | 
			
		
	
		
			
				
					|  |  |  |         }else { | 
			
		
	
		
			
				
					|  |  |  |             allProjects.forEach(a -> { | 
			
		
	
		
			
				
					|  |  |  |                 existsProjects.forEach(p -> { | 
			
		
	
		
			
				
					|  |  |  |                     if (a.getProjectId().equals(p)){ | 
			
		
	
		
			
				
					|  |  |  |                         a.setDisposeStatus(true); | 
			
		
	
		
			
				
					|  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |                 }); | 
			
		
	
		
			
				
					|  |  |  |             }); | 
			
		
	
		
			
				
					|  |  |  |             Map<Boolean, List<ComplementedProjectEvaluateResultDTO>> groupByStatus = allProjects.stream().collect(Collectors.groupingBy(ComplementedProjectEvaluateResultDTO::getDisposeStatus)); | 
			
		
	
		
			
				
					|  |  |  |             // 去除存在记录的项目
 | 
			
		
	
		
			
				
					|  |  |  |             projects = groupByStatus.get(false); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         List<ProjectSatisfactionStatisticsEntity> needAdd = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |         if (!CollectionUtils.isEmpty(projects)){ | 
			
		
	
		
			
				
					|  |  |  |             List<String> projectIds = projects.stream().map(m -> m.getIssueId()).collect(Collectors.toList()); | 
			
		
	
		
			
				
					|  |  |  |             List<ProjectEvaluateDetailResultDTO> projectEvaluateDetailResult = baseDao.selectProjectEvaluateDetail(projectIds); | 
			
		
	
		
			
				
					|  |  |  |             Map<String, List<ProjectEvaluateDetailResultDTO>> groupByProject = projectEvaluateDetailResult.stream().collect(Collectors.groupingBy(ProjectEvaluateDetailResultDTO::getProjectId)); | 
			
		
	
		
			
				
					|  |  |  |             boolean empty = groupByProject.isEmpty(); | 
			
		
	
		
			
				
					|  |  |  |             // 项目应评价人数 = 话题创建者 + 议题发起者 + 议题表决人 【去重】
 | 
			
		
	
		
			
				
					|  |  |  |             Result<List<CanEvaluateProjectCountBatchResultDTO>> canEvaluateProjectCountBatch = govIssueOpenFeignClient.canEvaluateProjectCountBatch(projectIds); | 
			
		
	
		
			
				
					|  |  |  |             if (!canEvaluateProjectCountBatch.success()){ | 
			
		
	
		
			
				
					|  |  |  |                 throw new RenException("【查询项目应评价人数失败】,【"+canEvaluateProjectCountBatch.getMsg()+"】"); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |             projects.forEach(p -> { | 
			
		
	
		
			
				
					|  |  |  |                 ProjectSatisfactionStatisticsEntity e = new ProjectSatisfactionStatisticsEntity(); | 
			
		
	
		
			
				
					|  |  |  |                 e.setCustomerId(p.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |                 e.setProjectId(p.getProjectId()); | 
			
		
	
		
			
				
					|  |  |  |                 if (!empty){ | 
			
		
	
		
			
				
					|  |  |  |                     groupByProject.forEach((projectId,list) -> { | 
			
		
	
		
			
				
					|  |  |  |                         if (p.getProjectId().equals(projectId)){ | 
			
		
	
		
			
				
					|  |  |  |                             Map<String, List<ProjectEvaluateDetailResultDTO>> groupByS = list.stream().collect(Collectors.groupingBy(ProjectEvaluateDetailResultDTO::getSatisfaction)); | 
			
		
	
		
			
				
					|  |  |  |                             e.setBadCount(groupByS.get(ProjectConstant.EVALUATE_BAD).size()); | 
			
		
	
		
			
				
					|  |  |  |                             e.setGoodCount(groupByS.get(ProjectConstant.EVALUATE_GOOD).size()); | 
			
		
	
		
			
				
					|  |  |  |                             e.setPerfectCount(groupByS.get(ProjectConstant.EVALUATE_PERFECT).size()); | 
			
		
	
		
			
				
					|  |  |  |                         } | 
			
		
	
		
			
				
					|  |  |  |                     }); | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |                 if (!CollectionUtils.isEmpty(canEvaluateProjectCountBatch.getData())){ | 
			
		
	
		
			
				
					|  |  |  |                     canEvaluateProjectCountBatch.getData().forEach(ep -> { | 
			
		
	
		
			
				
					|  |  |  |                         if (p.getIssueId().equals(ep.getIssueId())){ | 
			
		
	
		
			
				
					|  |  |  |                             e.setShouldEvaluateCount(ep.getUserIds().size()); | 
			
		
	
		
			
				
					|  |  |  |                         } | 
			
		
	
		
			
				
					|  |  |  |                     }); | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |                 needAdd.add(e); | 
			
		
	
		
			
				
					|  |  |  |             }); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         if (!CollectionUtils.isEmpty(needAdd)){ | 
			
		
	
		
			
				
					|  |  |  |             projectSatisfactionStatisticsService.insertBatch(needAdd); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | } |