|
|
@@ -1,12 +1,10 @@
|
|
|
package com.mooctest.crowd.site.mediator.impl;
|
|
|
|
|
|
-import com.mooctest.crowd.domain.dao.CrowdTestProjectDao;
|
|
|
-import com.mooctest.crowd.domain.dao.CrowdTestTaskDao;
|
|
|
-import com.mooctest.crowd.domain.dao.EvaluationAgencyDao;
|
|
|
-import com.mooctest.crowd.domain.dao.UserDao;
|
|
|
+import com.mooctest.crowd.domain.dao.*;
|
|
|
import com.mooctest.crowd.domain.domainobject.*;
|
|
|
import com.mooctest.crowd.domain.exception.AccountNotExistException;
|
|
|
import com.mooctest.crowd.domain.model.EvaluationAgencyPO;
|
|
|
+import com.mooctest.crowd.domain.model.RegionalManagerPO;
|
|
|
import com.mooctest.crowd.domain.model.UserPO;
|
|
|
import com.mooctest.crowd.domain.repository.CrowdTestProjectRepo;
|
|
|
import com.mooctest.crowd.domain.repository.EvaluationAgencyRepo;
|
|
|
@@ -49,6 +47,9 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
private UserDao userDao;
|
|
|
|
|
|
@Autowired
|
|
|
+ private RegionalManagerDao regionalManagerDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private EvaluationAgencyDao agencyDao;
|
|
|
|
|
|
@Autowired
|
|
|
@@ -100,83 +101,6 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
return new CrowdTaskVO(task);
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
-// ArrayList<CrowdTaskVO> allTasks = new ArrayList<>();
|
|
|
-// List<CrowdTestProject> allProjects = projectRepo.getAllCrowdTestProject();
|
|
|
-// allProjects.forEach(project -> {
|
|
|
-// allTasks.addAll(project.getCrowdTestTaskList()
|
|
|
-// .stream().filter(crowdTestTask -> crowdTestTask.getStatus() == CrowdTestTaskStatus.HAS_RELEASED)
|
|
|
-// .map(crowdTestTask -> new CrowdTaskVO(crowdTestTask)).collect(Collectors.toList()));
|
|
|
-// });
|
|
|
-
|
|
|
-// //对Project按照UserId进行分组
|
|
|
-// Map<Long, List<CrowdTestProject>> projectsGroup = new HashMap<>();
|
|
|
-// allProjects.forEach(project -> {
|
|
|
-// if (!projectsGroup.keySet().contains(project.getUserId()))
|
|
|
-// projectsGroup.put(project.getUserId(), new ArrayList<>());
|
|
|
-// projectsGroup.get(project.getUserId()).add(project);
|
|
|
-// });
|
|
|
-// //根据组的项目总价进行排序,提取UserId
|
|
|
-// List<Long> userIds = projectsGroup.entrySet().stream().sorted((o1, o2) -> {
|
|
|
-// Double sumPrice1 = o1.getValue().stream().mapToDouble(CrowdTestProject::getQuotedPrice).sum();
|
|
|
-// Double sumPrice2 = o2.getValue().stream().mapToDouble(CrowdTestProject::getQuotedPrice).sum();
|
|
|
-// if (sumPrice1 > sumPrice2)
|
|
|
-// return -1;
|
|
|
-// else if (sumPrice1 < sumPrice2)
|
|
|
-// return 1;
|
|
|
-// else
|
|
|
-// return 0;
|
|
|
-// }).map(Map.Entry::getKey).collect(Collectors.toList());
|
|
|
-// for (Long id : userIds)
|
|
|
-// log.info("UserId from Project: " + id);
|
|
|
-// if (userIds.size()>10)
|
|
|
-// userIds = userIds.subList(0,9);
|
|
|
-// List<UserVO> userRanks = userIds.stream().map(id -> new UserVO(userRepo.getByID(id))).collect(Collectors.toList());
|
|
|
-// userRanks.forEach(userVO -> userVO.setAllProjectPrice(projectsGroup.get(userVO.getId()).stream().mapToDouble(CrowdTestProject::getQuotedPrice).sum()));
|
|
|
-//
|
|
|
-// allTasks.sort(Comparator.comparing(CrowdTaskVO::getQuotePrice).reversed());
|
|
|
-// List<CrowdTaskVO> hotTasks = allTasks.subList(0,3);
|
|
|
-// List<EvolutionAgencyVO> agencyVOS = new ArrayList<>();
|
|
|
-// EvolutionAgencyVO agency1 = new EvolutionAgencyVO();
|
|
|
-// agency1.setLogo("http://www.mooctest.net/assets/img/mooctest.png");
|
|
|
-// agency1.setName("agency1");
|
|
|
-// EvolutionAgencyVO agency2 = new EvolutionAgencyVO();
|
|
|
-// agency2.setLogo("http://www.mooctest.net/assets/img/mooctest.png");
|
|
|
-// agency2.setName("agency2");
|
|
|
-// EvolutionAgencyVO agency3 = new EvolutionAgencyVO();
|
|
|
-// agency3.setLogo("http://www.mooctest.net/assets/img/mooctest.png");
|
|
|
-// agency3.setName("agency3");
|
|
|
-// EvolutionAgencyVO agency4 = new EvolutionAgencyVO();
|
|
|
-// agency4.setLogo("http://www.mooctest.net/assets/img/mooctest.png");
|
|
|
-// agency4.setName("agency4");
|
|
|
-// EvolutionAgencyVO agency5 = new EvolutionAgencyVO();
|
|
|
-// agency5.setLogo("http://www.mooctest.net/assets/img/mooctest.png");
|
|
|
-// agency5.setName("agency5");
|
|
|
-// EvolutionAgencyVO agency6 = new EvolutionAgencyVO();
|
|
|
-// agency6.setLogo("http://www.mooctest.net/assets/img/mooctest.png");
|
|
|
-// agency6.setName("agency6");
|
|
|
-// EvolutionAgencyVO agency7 = new EvolutionAgencyVO();
|
|
|
-// agency7.setLogo("http://www.mooctest.net/assets/img/mooctest.png");
|
|
|
-// agency7.setName("agency7");
|
|
|
-// EvolutionAgencyVO agency8 = new EvolutionAgencyVO();
|
|
|
-// agency8.setLogo("http://www.mooctest.net/assets/img/mooctest.png");
|
|
|
-// agency8.setName("agency8");
|
|
|
-// EvolutionAgencyVO agency9 = new EvolutionAgencyVO();
|
|
|
-// agency9.setLogo("http://www.mooctest.net/assets/img/mooctest.png");
|
|
|
-// agency9.setName("agency9");
|
|
|
-// EvolutionAgencyVO agency10 = new EvolutionAgencyVO();
|
|
|
-// agency10.setLogo("http://www.mooctest.net/assets/img/mooctest.png");
|
|
|
-// agency10.setName("agency10");
|
|
|
-// agencyVOS.add(agency1);
|
|
|
-// agencyVOS.add(agency2);
|
|
|
-// agencyVOS.add(agency3);
|
|
|
-// agencyVOS.add(agency4);
|
|
|
-// agencyVOS.add(agency5);
|
|
|
-// agencyVOS.add(agency6);
|
|
|
-// agencyVOS.add(agency7);
|
|
|
-// agencyVOS.add(agency8);
|
|
|
-// agencyVOS.add(agency9);
|
|
|
-// agencyVOS.add(agency10);
|
|
|
-
|
|
|
IndexDTO indexDTO = new IndexDTO();
|
|
|
indexDTO.setHotTaskList(hotTasks);
|
|
|
indexDTO.setUserRank(userRanks);
|
|
|
@@ -261,9 +185,23 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
@Override
|
|
|
public UserDTO renderUser(User user) {
|
|
|
UserDTO userDTO = new UserDTO();
|
|
|
+ userDTO.setRoleList(user.getRoleList().stream().map(Role::getName).collect(Collectors.toList()));
|
|
|
userDTO.setUserVO(new UserVO(user));
|
|
|
if (user.getEvaluationAgency() != null)
|
|
|
userDTO.setAgencyVO(new AgencyVO(user.getEvaluationAgency()));
|
|
|
return userDTO;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<RegionalManagerVO> renderRegionManager() {
|
|
|
+ List<RegionalManagerVO> regionalManagerVOList = new ArrayList<>();
|
|
|
+ regionalManagerDao.findAll().forEach(regionalManagerPO -> {
|
|
|
+ RegionalManagerVO regionalManagerVO = new RegionalManagerVO();
|
|
|
+ regionalManagerVO.setId(regionalManagerPO.getUserId());
|
|
|
+ regionalManagerVO.setName(userDao.findById(regionalManagerPO.getUserId()).get().getName());
|
|
|
+ regionalManagerVOList.add(regionalManagerVO);
|
|
|
+ });
|
|
|
+ List<RegionalManagerVO> results = regionalManagerVOList.stream().distinct().collect(Collectors.toList());
|
|
|
+ return results;
|
|
|
+ }
|
|
|
}
|