|
@@ -19,6 +19,7 @@ import com.mooctest.crowd.site.data.dto.*;
|
|
|
import com.mooctest.crowd.site.data.enums.RoleType;
|
|
|
import com.mooctest.crowd.site.data.vo.*;
|
|
|
import com.mooctest.crowd.site.mediator.ViewMediator;
|
|
|
+import com.mooctest.crowd.site.service.CrowdTaskService;
|
|
|
import com.mooctest.crowd.site.service.ThemeStatusService;
|
|
|
import com.mooctest.crowd.site.service.ThemeStatusTaskService;
|
|
|
import com.mooctest.crowd.site.service.impl.AuthCheckServiceImpl;
|
|
@@ -47,6 +48,9 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
private TestTypeDao testTypeDao;
|
|
|
|
|
|
@Autowired
|
|
|
+ private CrowdTaskService crowdTaskService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private CrowdTestProjectRepo projectRepo;
|
|
|
|
|
|
@Autowired
|
|
@@ -139,6 +143,33 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
@Value("${feature.client.oss}")
|
|
|
private Boolean usingOss;
|
|
|
|
|
|
+ @Value("${index.count.project}")
|
|
|
+ private String indexProjectCount;
|
|
|
+
|
|
|
+ @Value("${index.count.task}")
|
|
|
+ private String indexTaskCount;
|
|
|
+
|
|
|
+ @Value("${index.count.residentAgency}")
|
|
|
+ private String indexResidentAgencyCount;
|
|
|
+
|
|
|
+ @Value("${index.count.competition}")
|
|
|
+ private String indexCompetitionCount;
|
|
|
+
|
|
|
+ @Value("${index.count.crowd}")
|
|
|
+ private String indexCrowdCount;
|
|
|
+
|
|
|
+ @Value("${index.count.agency}")
|
|
|
+ private String indexAgencyCount;
|
|
|
+
|
|
|
+ @Value("${index.count.user}")
|
|
|
+ private String indexUserCount;
|
|
|
+
|
|
|
+ @Value("${index.count.tool}")
|
|
|
+ private String indexToolCount;
|
|
|
+
|
|
|
+ @Value("${index.count.resource}")
|
|
|
+ private String indexResourceCount;
|
|
|
+
|
|
|
@Override
|
|
|
public List<CrowdTestProjectVO> crowdTestProjects() {
|
|
|
List<CrowdTestProjectVO> resultList = new ArrayList<>();
|
|
@@ -302,133 +333,51 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
@Override
|
|
|
public IndexInfoDTO renderIndexInfosCache() {
|
|
|
IndexInfoDTO indexInfoDTO = new IndexInfoDTO();
|
|
|
- int top = 3;
|
|
|
// 获取大赛信息
|
|
|
- List<Competition> competitionList = commonRepo.getAllCompetition();
|
|
|
- List<Competition> competitionLists = new ArrayList<>();
|
|
|
- if (competitionList.size() > top) {
|
|
|
- for (int i = 0; i < top; i++) {
|
|
|
- competitionLists.add(competitionList.get(i));
|
|
|
- }
|
|
|
- } else {
|
|
|
- competitionLists = competitionList;
|
|
|
- }
|
|
|
-
|
|
|
- List<CompetitionVO> competitionVOS = competitionLists.stream().map(competition -> {
|
|
|
- CompetitionVO competitionVO = new CompetitionVO(competition);
|
|
|
- return competitionVO;
|
|
|
- }).sorted(Comparator.comparing(CompetitionVO::getStartTime).reversed()).collect(Collectors.toList());
|
|
|
-
|
|
|
+ List<CompetitionVO> competitionVOS = commonRepo.getAllCompetition(Integer.parseInt(indexCompetitionCount)).stream().map(CompetitionVO::new).collect(Collectors.toList());
|
|
|
+ // 获取领域划分
|
|
|
+ List<FieldVO> fieldVOS = commonRepo.getAllFieldType().stream().map(FieldVO::new).collect(Collectors.toList());
|
|
|
// 获取服务类型
|
|
|
- List<TestType> allTestType = commonRepo.getAllTestType();
|
|
|
- List<TestTypeVO> testTypeVOS = allTestType.stream().map(testType -> {
|
|
|
- TestTypeVO testTypeVO = new TestTypeVO(testType);
|
|
|
- return testTypeVO;
|
|
|
- }).collect(Collectors.toList());
|
|
|
-
|
|
|
+ List<TestTypeVO> testTypeVOS = commonRepo.getAllTestType().stream().map(TestTypeVO::new).collect(Collectors.toList());
|
|
|
// 获取应用类型
|
|
|
List<ApplicationTypeVO> applicationTypeVOS = commonRepo.getAllApplicationType().stream().map(ApplicationTypeVO::new).collect(Collectors.toList());
|
|
|
-// List<ApplicationType> allApplicationType = commonRepo.getAllApplicationType();
|
|
|
-// List<ApplicationTypeVO> applicationTypeVOS = allApplicationType.stream().map(applicationType -> {
|
|
|
-// ApplicationTypeVO applicationTypeVO = new ApplicationTypeVO(applicationType);
|
|
|
-// List<TestType> testTypeList = commonRepo.getTestTypeListByAppCode(applicationType.getCode());
|
|
|
-// List<TestTypeVO> typeVOS = testTypeList.stream().map(testType -> {
|
|
|
-// TestTypeVO testTypeVO = new TestTypeVO(testType);
|
|
|
-// return testTypeVO;
|
|
|
-// }).collect(Collectors.toList());
|
|
|
-// applicationTypeVO.setTestTypeList(typeVOS);
|
|
|
-// return applicationTypeVO;
|
|
|
-// }).collect(Collectors.toList());
|
|
|
-
|
|
|
- // 获取领域划分
|
|
|
- List<Field> fieldList = commonRepo.getAllFieldType();
|
|
|
- List<FieldVO> fieldVOS = fieldList.stream().map(field -> {
|
|
|
- FieldVO fieldVO = new FieldVO(field);
|
|
|
- return fieldVO;
|
|
|
- }).collect(Collectors.toList());
|
|
|
-
|
|
|
// 获取入驻品牌机构
|
|
|
- List<ResidentAgency> allResidentAgency = commonRepo.getAllResidentAgency();
|
|
|
- List<EvaluationAgencyVO> agencyVOS = new ArrayList<>();
|
|
|
- List<EvaluationAgencyVO> agencyVOList = allResidentAgency.stream().map(residentAgency -> {
|
|
|
+ List<ResidentAgency> allResidentAgency = commonRepo.getAllResidentAgency(Integer.parseInt(indexResidentAgencyCount));
|
|
|
+ // 获取资源
|
|
|
+// List<ResourceVO> resourceVOS = commonRepo.getAllResource().stream().map(ResourceVO::new).limit(Integer.parseInt(indexResourceCount)).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 获取工具
|
|
|
+ List<ToolVO> toolVOS = toolRepo.getAllTools().stream().map(tool -> new ToolVO(tool)).limit(Integer.parseInt(indexToolCount)).collect(Collectors.toList());
|
|
|
+ List<EvaluationAgencyVO> agencyVOS = allResidentAgency.stream().map(residentAgency -> {
|
|
|
EvaluationAgency agency = evaluationAgencyRepo.findAgencyById(residentAgency.getAgencyId());
|
|
|
EvaluationAgencyVO evalutionAgencyVO = new EvaluationAgencyVO(agency);
|
|
|
return evalutionAgencyVO;
|
|
|
}).collect(Collectors.toList());
|
|
|
- if (agencyVOList.size() > 12) {
|
|
|
- for (int i = 0; i < 12; i++) {
|
|
|
- agencyVOS.add(agencyVOList.get(i));
|
|
|
- }
|
|
|
- } else {
|
|
|
- agencyVOS = agencyVOList;
|
|
|
- }
|
|
|
-
|
|
|
- // 获取热门任务
|
|
|
- List<CrowdTaskVO> taskVOList = taskDao.findMoreHotTasks().stream().map(crowdTestTaskPO -> {
|
|
|
- CrowdTestTask task = new CrowdTestTask();
|
|
|
- BeanUtils.copyProperties(crowdTestTaskPO, task);
|
|
|
- return new CrowdTaskVO(task);
|
|
|
- }).collect(Collectors.toList());
|
|
|
-
|
|
|
- List<CrowdTaskVO> taskVOS = new ArrayList<>();
|
|
|
- if (taskVOList.size() > top) {
|
|
|
- for (int i = 0; i < top; i++) {
|
|
|
- taskVOS.add(taskVOList.get(i));
|
|
|
- }
|
|
|
- } else {
|
|
|
- taskVOS = taskVOList;
|
|
|
- }
|
|
|
-
|
|
|
- // 获取合作机构
|
|
|
-// List<Partner> partnerList = commonRepo.getAllPartner();
|
|
|
-// List<PartnerVO> partnerVOS = partnerList.stream().map(partner -> {
|
|
|
-// PartnerVO partnerVO = new PartnerVO(partner);
|
|
|
-// return partnerVO;
|
|
|
-// }).collect(Collectors.toList());
|
|
|
|
|
|
indexInfoDTO.setTestTypeList(testTypeVOS);
|
|
|
indexInfoDTO.setApplicationTypeList(applicationTypeVOS);
|
|
|
indexInfoDTO.setFieldList(fieldVOS);
|
|
|
indexInfoDTO.setCompetitionList(competitionVOS);
|
|
|
indexInfoDTO.setResidentAgencyList(agencyVOS);
|
|
|
-// indexInfoDTO.setPartnerList(partnerVOS);
|
|
|
- indexInfoDTO.setTaskList(taskVOS);
|
|
|
+// indexInfoDTO.setResourceList(resourceVOS);
|
|
|
+ indexInfoDTO.setToolList(toolVOS);
|
|
|
return indexInfoDTO;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public IndexInfoDTO renderIndexInfos() {
|
|
|
IndexInfoDTO indexInfoDTO = new IndexInfoDTO();
|
|
|
- Pageable pageable = PageRequest.of(0, 3);
|
|
|
- int top = 3;
|
|
|
- List<ApplicationTypeVO> applicationTypeRank = getApplicationTypeRankVOS(pageable);
|
|
|
- List<ApplicationTypeVO> applicationTypeRanks = new ArrayList<>();
|
|
|
- if (applicationTypeRanks.size() > top) {
|
|
|
- for (int i = 0; i < top; i++) {
|
|
|
- applicationTypeRanks.add(applicationTypeRank.get(i));
|
|
|
- }
|
|
|
- } else {
|
|
|
- applicationTypeRanks = applicationTypeRank;
|
|
|
- }
|
|
|
+ Pageable pageable = PageRequest.of(0, Integer.parseInt(indexCrowdCount));
|
|
|
+ // 获取热门项目
|
|
|
+ List<CrowdTestProjectVO> projectVOS = projectRepo.findHotProjectCardLimitCount(Integer.parseInt(indexProjectCount)).stream().map(CrowdTestProjectVO::new).collect(Collectors.toList());
|
|
|
+ // 获取热门任务
|
|
|
+ List<CrowdTaskVO> taskVOS = crowdTaskService.findMoreHotTasksList("", Integer.parseInt(indexTaskCount));
|
|
|
+ // 获取热门众测
|
|
|
+ List<ApplicationTypeVO> applicationTypeRanks = getApplicationTypeRankVOS(pageable).stream().limit(Integer.parseInt(indexCrowdCount)).collect(Collectors.toList());
|
|
|
|
|
|
//获取机构排名
|
|
|
-// String agencyName = agencyDao.findById(Long.parseLong(agencyId)).get().getEvaluationAgencyName();
|
|
|
-// List<EvaluationAgencyVO> agencyRank = taskToUserDao.findTotalCountOfUser().stream().map(rankInfo -> {
|
|
|
-// EvaluationAgencyPO agency = agencyDao.findByUserId(rankInfo.getEntityId());
|
|
|
-// if (agency != null && !agency.getEvaluationAgencyName().equals(agencyName)) {
|
|
|
-// EvaluationAgencyVO agencyVO = new EvaluationAgencyVO();
|
|
|
-// agencyVO.setEvaluationAgencyName(agency.getEvaluationAgencyName());
|
|
|
-// agencyVO.setAgencyPhoto(agency.getAgencyPhoto());
|
|
|
-// agencyVO.setTaskCount(rankInfo.getCount());
|
|
|
-// agencyVO.setId(agency.getId());
|
|
|
-// agencyVO.setUserId(agency.getUserId());
|
|
|
-// return agencyVO;
|
|
|
-// }
|
|
|
-// return null;
|
|
|
-// }).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
-
|
|
|
List<EvaluationAgencyVO> agencyRanks = userTaskCountDao.findByType(RoleType.AGENCY.getId())
|
|
|
- .stream().sorted(Comparator.comparing(UserTaskCountPO::getCount).reversed()).limit(top).collect(Collectors.toList())
|
|
|
+ .stream().sorted(Comparator.comparing(UserTaskCountPO::getCount).reversed()).limit(Integer.parseInt(indexAgencyCount)).collect(Collectors.toList())
|
|
|
.stream().map(userTaskCountPO -> {
|
|
|
EvaluationAgencyPO agency = agencyDao.findByUserId(userTaskCountPO.getUserId());
|
|
|
EvaluationAgencyVO agencyVO = new EvaluationAgencyVO();
|
|
@@ -440,29 +389,9 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
return agencyVO;
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
-// List<EvaluationAgencyVO> agencyRanks = new ArrayList<>();
|
|
|
-// if (agencyRank.size() > top) {
|
|
|
-// for (int i = 0; i < top; i++) {
|
|
|
-// agencyRanks.add(agencyRank.get(i));
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// agencyRanks = agencyRank;
|
|
|
-// }
|
|
|
-
|
|
|
//获取众测人员排名
|
|
|
-// List<UserVO> userRank = taskToUserDao.findTotalCountOfUser().stream().map(rankInfo -> {
|
|
|
-// EvaluationAgencyPO agency = agencyDao.findByUserId(rankInfo.getEntityId());
|
|
|
-// if (agency != null && agency.getEvaluationAgencyName().equals(agencyName)) {
|
|
|
-// 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());
|
|
|
-
|
|
|
List<UserVO> userRanks = userTaskCountDao.findByType(RoleType.EVALUATION_USER.getId())
|
|
|
- .stream().sorted(Comparator.comparing(UserTaskCountPO::getCount).reversed()).limit(top).collect(Collectors.toList())
|
|
|
+ .stream().sorted(Comparator.comparing(UserTaskCountPO::getCount).reversed()).limit(Integer.parseInt(indexUserCount)).collect(Collectors.toList())
|
|
|
.stream().map(userTaskCountPO -> {
|
|
|
User user = userRepo.getByIDJustInfo(userTaskCountPO.getUserId());
|
|
|
UserVO userVO = new UserVO(user);
|
|
@@ -470,47 +399,11 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
return userVO;
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
-// List<UserVO> userRanks = new ArrayList<>();
|
|
|
-// if (userRank.size() > top) {
|
|
|
-// for (int i = 0; i < top; i++) {
|
|
|
-// userRanks.add(userRank.get(i));
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// userRanks = userRank;
|
|
|
-// }
|
|
|
-
|
|
|
- // 获取资源
|
|
|
- List<Resource> resourceList = commonRepo.getAllResource();
|
|
|
- List<ResourceVO> resourceVOS = new ArrayList<>();
|
|
|
- List<ResourceVO> resourceVOList = resourceList.stream().map(resource -> {
|
|
|
- ResourceVO resourceVO = new ResourceVO(resource);
|
|
|
- return resourceVO;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- if (resourceVOList.size() > 12) {
|
|
|
- for (int i = 0; i < 12; i++) {
|
|
|
- resourceVOS.add(resourceVOList.get(i));
|
|
|
- }
|
|
|
- } else {
|
|
|
- resourceVOS = resourceVOList;
|
|
|
- }
|
|
|
-
|
|
|
- // 获取工具
|
|
|
- List<Tool> toolList = toolRepo.getAllTools();
|
|
|
- List<ToolVO> toolVOS = new ArrayList<>();
|
|
|
- List<ToolVO> toolVOList = toolList.stream().map(tool -> new ToolVO(tool)).collect(Collectors.toList());
|
|
|
- if (toolVOList.size() > 12) {
|
|
|
- for (int i = 0; i < 12; i++) {
|
|
|
- toolVOS.add(toolVOList.get(i));
|
|
|
- }
|
|
|
- } else {
|
|
|
- toolVOS = toolVOList;
|
|
|
- }
|
|
|
-
|
|
|
+ indexInfoDTO.setTaskList(taskVOS);
|
|
|
+ indexInfoDTO.setProjectList(projectVOS);
|
|
|
indexInfoDTO.setApplicationTypeRank(applicationTypeRanks);
|
|
|
indexInfoDTO.setAgencyRank(agencyRanks);
|
|
|
indexInfoDTO.setUserRank(userRanks);
|
|
|
- indexInfoDTO.setResourceList(resourceVOS);
|
|
|
- indexInfoDTO.setToolList(toolVOS);
|
|
|
return indexInfoDTO;
|
|
|
}
|
|
|
|