|
@@ -25,7 +25,6 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.stereotype.Component;
|
|
@@ -101,9 +100,18 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
public IndexInfoDTO renderIndexInfos() {
|
|
|
IndexInfoDTO indexInfoDTO = new IndexInfoDTO();
|
|
|
Pageable pageable = PageRequest.of(0, 3);
|
|
|
+ int top = 3;
|
|
|
+ //获取热门众测
|
|
|
+ List<FieldVO> fieldRanks = projectDao.findTotalCountOfField(pageable).stream().map(fieldRankInfo -> {
|
|
|
+ Field field = commonRepo.getFieldByFieldCode(fieldRankInfo.getName());
|
|
|
+ FieldVO fieldVO = new FieldVO(field);
|
|
|
+ fieldVO.setCount(fieldRankInfo.getCount());
|
|
|
+ return fieldVO;
|
|
|
+ }).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
+
|
|
|
//获取机构排名
|
|
|
String agencyName = agencyDao.findById(Long.parseLong(agencyId)).get().getEvaluationAgencyName();
|
|
|
- List<EvolutionAgencyVO> agencyRanks = taskToUserDao.findTotalCountOfUser(pageable).stream().map(rankInfo -> {
|
|
|
+ List<EvolutionAgencyVO> agencyRanks = taskToUserDao.findTotalCountOfUser().stream().map(rankInfo -> {
|
|
|
EvaluationAgencyPO agency = agencyDao.findByUserId(rankInfo.getEntityId());
|
|
|
if (agency!=null && !agency.getEvaluationAgencyName().equals(agencyName)) {
|
|
|
EvolutionAgencyVO agencyVO = new EvolutionAgencyVO();
|
|
@@ -116,21 +124,34 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
}
|
|
|
return null;
|
|
|
}).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
+ if(agencyRanks.size() > top){
|
|
|
+ agencyRanks = agencyRanks.subList(0,top);
|
|
|
+ }
|
|
|
|
|
|
//获取众测人员排名
|
|
|
- List<EvolutionAgencyVO> userRanks = taskToUserDao.findTotalCountOfUser(pageable).stream().map(rankInfo -> {
|
|
|
+ List<UserVO> userRanks = taskToUserDao.findTotalCountOfUser().stream().map(rankInfo -> {
|
|
|
EvaluationAgencyPO agency = agencyDao.findByUserId(rankInfo.getEntityId());
|
|
|
if (agency!=null && agency.getEvaluationAgencyName().equals(agencyName)) {
|
|
|
- EvolutionAgencyVO agencyVO = new EvolutionAgencyVO();
|
|
|
- agencyVO.setName(agency.getEvaluationAgencyName());
|
|
|
- agencyVO.setLogo(agency.getAgencyPhoto());
|
|
|
- agencyVO.setTaskCount(rankInfo.getCount());
|
|
|
- agencyVO.setId(agency.getId());
|
|
|
- agencyVO.setUserId(agency.getUserId());
|
|
|
- return agencyVO;
|
|
|
+ User user = userRepo.getByID(agency.getUserId());
|
|
|
+ UserVO userVO = new UserVO(user);
|
|
|
+ userVO.setTaskCount(rankInfo.getCount());
|
|
|
+ return userVO;
|
|
|
}
|
|
|
return null;
|
|
|
}).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
+ if(userRanks.size() > top){
|
|
|
+ userRanks = userRanks.subList(0,top);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取大赛信息
|
|
|
+ List<Competition> competitionList = commonRepo.getAllCompetition();
|
|
|
+ if(competitionList.size() > top){
|
|
|
+ competitionList = competitionList.subList(0,top);
|
|
|
+ }
|
|
|
+ List<CompetitionVO> competitionVOS = competitionList.stream().map(competition -> {
|
|
|
+ CompetitionVO competitionVO = new CompetitionVO(competition);
|
|
|
+ return competitionVO;
|
|
|
+ }).sorted(Comparator.comparing(CompetitionVO::getStartTime).reversed()).collect(Collectors.toList());
|
|
|
|
|
|
// 获取服务类型
|
|
|
List<TestType> allTestType = commonRepo.getAllTestType();
|
|
@@ -159,16 +180,6 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
return fieldVO;
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
- // 获取大赛信息
|
|
|
- List<Competition> competitionList = commonRepo.getAllCompetition();
|
|
|
- if(competitionList.size() > 3){
|
|
|
- competitionList = competitionList.subList(0,3);
|
|
|
- }
|
|
|
- List<CompetitionVO> competitionVOS = competitionList.stream().map(competition -> {
|
|
|
- CompetitionVO competitionVO = new CompetitionVO(competition);
|
|
|
- return competitionVO;
|
|
|
- }).sorted(Comparator.comparing(CompetitionVO::getStartTime).reversed()).collect(Collectors.toList());
|
|
|
-
|
|
|
// 获取资源和工具
|
|
|
List<Resource> resourceList = commonRepo.getAllResource();
|
|
|
List<ResourceVO> resourceVOS = resourceList.stream().map(resource -> {
|
|
@@ -191,10 +202,11 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
return evolutionAgencyVO;
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
- Page<CrowdTestProjectPO> all = projectDao.findAll(pageable);
|
|
|
+// Page<CrowdTestProjectPO> all = projectDao.findAll(pageable);
|
|
|
|
|
|
+ indexInfoDTO.setFieldRank(fieldRanks);
|
|
|
indexInfoDTO.setAgencyRank(agencyRanks);
|
|
|
-// indexInfoDTO.setUserRank(userRanks);
|
|
|
+ indexInfoDTO.setUserRank(userRanks);
|
|
|
indexInfoDTO.setTestTypeList(testTypeVOS);
|
|
|
indexInfoDTO.setApplicationTypeList(applicationTypeVOS);
|
|
|
indexInfoDTO.setFieldList(fieldVOS);
|