|
@@ -100,7 +100,7 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
private ApplicationTypeDao applicationTypeDao;
|
|
|
|
|
|
@Autowired
|
|
|
- private ResourceDao resourceDao;
|
|
|
+ private ResourceDao resourceDao;
|
|
|
|
|
|
@Autowired
|
|
|
private ResourceTypeDao resourceTypeDao;
|
|
@@ -113,26 +113,24 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
|
|
|
@Override
|
|
|
public List<UserVO> renderMoreUser(Pageable pageable) {
|
|
|
- List<UserVO> userVOS=new ArrayList<>();
|
|
|
- List<RankCountInfo> rankCountInfos=taskToUserDao.findTotalCountOfUser();
|
|
|
- long []ids=new long[rankCountInfos.size()];
|
|
|
- for(int i=0;i<rankCountInfos.size();i++){
|
|
|
- if(userDao.findById(rankCountInfos.get(i).getEntityId()).isPresent()){
|
|
|
- ids[i]=rankCountInfos.get(i).getEntityId();
|
|
|
- Optional<UserPO> userPO=userDao.findById(ids[i]);
|
|
|
- User user=new User(userPO.get());
|
|
|
- UserVO userVO=new UserVO(user);
|
|
|
- userVO.setTaskCount(rankCountInfos.get(i).getCount());
|
|
|
- userVOS.add(userVO);
|
|
|
+ //获取众测人员排名
|
|
|
+ String agencyName = agencyDao.findById(Long.parseLong(agencyId)).get().getEvaluationAgencyName();
|
|
|
+ List<UserVO> userVOS = 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());
|
|
|
return userVOS;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<CrowdTaskVO> findMoreHotTasks() {
|
|
|
- List<CrowdTestTaskPO> list=taskDao.findMoreHotTasks();//已经根据创建时间排序好了。
|
|
|
+ List<CrowdTestTaskPO> list = taskDao.findMoreHotTasks();//已经根据创建时间排序好了。
|
|
|
List<CrowdTaskVO> hotMoreTestprojects = taskDao.findMoreHotTasks().stream().map(crowdTestTaskPO -> {
|
|
|
CrowdTestTask task = new CrowdTestTask();
|
|
|
BeanUtils.copyProperties(crowdTestTaskPO, task);
|
|
@@ -143,8 +141,8 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
|
|
|
@Override
|
|
|
public List<CrowdTestProjectVO> findMoreHotProjects() {
|
|
|
- List<CrowdTestProjectPO> list=projectDao.findMoreHotProjects();//已经根据创建时间排序好了。
|
|
|
- //根据 参加人数倒序排序
|
|
|
+ List<CrowdTestProjectPO> list = projectDao.findMoreHotProjects();//已经根据创建时间排序好了。
|
|
|
+ //根据 参加人数倒序排序
|
|
|
List<CrowdTestProjectVO> hotMoreTestprojects = projectDao.findMoreHotProjects().stream().map(crowdTestProjectPO -> {
|
|
|
CrowdTestProject project = new CrowdTestProject();
|
|
|
BeanUtils.copyProperties(crowdTestProjectPO, project);
|
|
@@ -214,10 +212,10 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
|
|
|
//获取机构排名
|
|
|
String agencyName = agencyDao.findById(Long.parseLong(agencyId)).get().getEvaluationAgencyName();
|
|
|
- List<EvolutionAgencyVO> agencyRank = taskToUserDao.findTotalCountOfUser().stream().map(rankInfo -> {
|
|
|
+ List<EvaluationAgencyVO> agencyRank = taskToUserDao.findTotalCountOfUser().stream().map(rankInfo -> {
|
|
|
EvaluationAgencyPO agency = agencyDao.findByUserId(rankInfo.getEntityId());
|
|
|
if (agency != null && !agency.getEvaluationAgencyName().equals(agencyName)) {
|
|
|
- EvolutionAgencyVO agencyVO = new EvolutionAgencyVO();
|
|
|
+ EvaluationAgencyVO agencyVO = new EvaluationAgencyVO();
|
|
|
agencyVO.setEvaluationAgencyName(agency.getEvaluationAgencyName());
|
|
|
agencyVO.setAgencyPhoto(agency.getAgencyPhoto());
|
|
|
agencyVO.setTaskCount(rankInfo.getCount());
|
|
@@ -227,7 +225,7 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
}
|
|
|
return null;
|
|
|
}).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
- List<EvolutionAgencyVO> agencyRanks = new ArrayList<>();
|
|
|
+ List<EvaluationAgencyVO> agencyRanks = new ArrayList<>();
|
|
|
if (agencyRank.size() > top) {
|
|
|
for (int i = 0; i < top; i++) {
|
|
|
agencyRanks.add(agencyRank.get(i));
|
|
@@ -315,10 +313,10 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
|
|
|
// 获取合作机构
|
|
|
List<ResidentAgency> allResidentAgency = commonRepo.getAllResidentAgency();
|
|
|
- List<EvolutionAgencyVO> agencyVOS = allResidentAgency.stream().map(residentAgency -> {
|
|
|
+ List<EvaluationAgencyVO> agencyVOS = allResidentAgency.stream().map(residentAgency -> {
|
|
|
EvaluationAgency agency = evaluationAgencyRepo.findAgencyById(residentAgency.getAgencyId());
|
|
|
- EvolutionAgencyVO evolutionAgencyVO = new EvolutionAgencyVO(agency);
|
|
|
- return evolutionAgencyVO;
|
|
|
+ EvaluationAgencyVO evalutionAgencyVO = new EvaluationAgencyVO(agency);
|
|
|
+ return evalutionAgencyVO;
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
indexInfoDTO.setApplicationTypeRank(applicationTypeRanks);
|
|
@@ -336,7 +334,6 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
|
|
|
@Override
|
|
|
public IndexDTO renderIndex() {
|
|
|
-
|
|
|
Pageable pageable = PageRequest.of(0, 10);
|
|
|
//获取用户排名
|
|
|
List<UserVO> userRanks = projectDao.findTotalPriceOfUser(pageable).stream().map(rankInfo -> {
|
|
@@ -351,10 +348,10 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
return null;
|
|
|
}).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
//获取机构排名
|
|
|
- List<EvolutionAgencyVO> agencyRanks = taskToUserDao.findTotalPriceOfAgency(pageable).stream().map(rankInfo -> {
|
|
|
+ List<EvaluationAgencyVO> agencyRanks = taskToUserDao.findTotalPriceOfAgency(pageable).stream().map(rankInfo -> {
|
|
|
EvaluationAgencyPO agency = agencyDao.findByUserId(rankInfo.getEntityId());
|
|
|
if (agency != null) {
|
|
|
- EvolutionAgencyVO agencyVO = new EvolutionAgencyVO();
|
|
|
+ EvaluationAgencyVO agencyVO = new EvaluationAgencyVO();
|
|
|
agencyVO.setEvaluationAgencyName(agency.getEvaluationAgencyName());
|
|
|
agencyVO.setAgencyPhoto(agency.getAgencyPhoto());
|
|
|
agencyVO.setAllTaskPrice(rankInfo.getTotalPrice());
|
|
@@ -495,6 +492,57 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
return myCrowdDTO;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public UserDataDTO renderMyCrowdData(Long userId) {
|
|
|
+ UserDataDTO userDataDTO = new UserDataDTO();
|
|
|
+ User user = userRepo.getByID(userId);
|
|
|
+ //我的众测 - 项目相关信息
|
|
|
+ //获取我创建的项目列表
|
|
|
+ List<CrowdProjectDataVO> myProjects = projectDao.findByUserIdAndIsDeleted(userId, DeletedStatus.isNotDeleted).stream().map(CrowdTestProject::new).collect(Collectors.toList())
|
|
|
+ .stream().map(CrowdProjectDataVO::new).collect(Collectors.toList());
|
|
|
+ UserVO userVO = new UserVO(user);
|
|
|
+ userDataDTO.setMyProjects(myProjects);
|
|
|
+ userDataDTO.setUserVO(userVO);
|
|
|
+ if (user.getRoleList().stream().noneMatch(role -> role.getName().equals("evaluationAgency")))
|
|
|
+ return userDataDTO;
|
|
|
+ List<CrowdTestTask> allTaskOfAgency = null;
|
|
|
+ List<CrowdTestTask> unfinishedTasks = null;
|
|
|
+ List<CrowdTestTask> finishedTasks = null;
|
|
|
+ if (user.getRoleList().stream().anyMatch(role -> role.getName().equals("evaluationAgency"))) {
|
|
|
+ List<TaskToUserPO> taskToUserPOS = taskToUserDao.findByUserId(user.getId());
|
|
|
+ if (taskToUserPOS != null && taskToUserPOS.size() > 0) {
|
|
|
+ allTaskOfAgency = taskToUserPOS.stream().sorted(Comparator.comparing(TaskToUserPO::getAcceptTime))
|
|
|
+ .map(taskToUserPO -> {
|
|
|
+ CrowdTestTaskPO crowdTestTaskPO = taskDao.findByCodeAndIsDeleted(taskToUserPO.getTaskCode(), DeletedStatus.isNotDeleted);
|
|
|
+ if (crowdTestTaskPO != null) {
|
|
|
+ CrowdTestTask task = new CrowdTestTask();
|
|
|
+ BeanUtils.copyProperties(crowdTestTaskPO, task);
|
|
|
+
|
|
|
+ // 测试类型的转换
|
|
|
+ Optional<TestTypePO> testTypePO = testTypeDao.findByCode(task.getType());
|
|
|
+ if (!testTypePO.isPresent()) {
|
|
|
+ throw new HttpBadRequestException("请选择测试类型");
|
|
|
+ }
|
|
|
+ task.setType(testTypePO.get().getName());
|
|
|
+ CrowdTestTask taskDetail = projectRepo.getTaskDetail(task, user.getId());
|
|
|
+ return taskDetail;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ unfinishedTasks = allTaskOfAgency.stream()
|
|
|
+ .filter(crowdTestTask -> crowdTestTask.getStatus() >= CrowdTestTaskStatus.HAS_RELEASED && crowdTestTask.getStatus() < CrowdTestTaskStatus.HAS_FINISHED)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ finishedTasks = allTaskOfAgency.stream()
|
|
|
+ .filter(crowdTestTask -> crowdTestTask.getStatus() == CrowdTestTaskStatus.HAS_FINISHED)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ userDataDTO.setFinishedTasks(finishedTasks);
|
|
|
+ userDataDTO.setUnfinishedTasks(unfinishedTasks);
|
|
|
+ return userDataDTO;
|
|
|
+ }
|
|
|
+
|
|
|
private CrowdProjectVO changeApplicationType(CrowdProjectVO projectVO) {
|
|
|
// 应用类型值的转换
|
|
|
Optional<ApplicationTypePO> applicationTypePO = applicationTypeDao.findByCode(projectVO.getPlatform());
|
|
@@ -580,9 +628,9 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
|
|
|
// 领域类型值的转换
|
|
|
Optional<FieldPO> fieldPO = fieldDao.findByCode(projectVO.getField());
|
|
|
- if(fieldPO.isPresent()){
|
|
|
+ if (fieldPO.isPresent()) {
|
|
|
projectVO.setField(fieldPO.get().getName());
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
throw new HttpBadRequestException("请选择领域类型");
|
|
|
}
|
|
|
|
|
@@ -642,15 +690,24 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ReportDetailsDTO renderProjectReportDetails(String projectCode, String reportCode, Long userId) {
|
|
|
+ public ReportDetailsDTO renderProjectReportDetails(String projectCode, String reportCode, Long userId){
|
|
|
CrowdTestProject project = projectRepo.getByProjectCode(projectCode);
|
|
|
CrowdTestReport report = project.getCrowdTestReportForProject();
|
|
|
if (report == null)
|
|
|
throw new CrowdTestReportNotExistException();
|
|
|
ReportDetailsDTO reportDetailsDTO = new ReportDetailsDTO();
|
|
|
+ /*
|
|
|
+ 如果该项目是已经完成的那么报告是不能修改的这边我在Vo上面加了一个属性Updated
|
|
|
+ */
|
|
|
+ if (project.getStatus() == CrowdTestProjectStatus.HAS_FINISHED){
|
|
|
+ report.setUpdated(false);
|
|
|
+ }
|
|
|
reportDetailsDTO.setCrowdReportVO(new CrowdReportVO(report));
|
|
|
- if (project.getStatus() < CrowdTestProjectStatus.HAS_FINISHED && project.getRegionalManagerId().equals(userId))
|
|
|
+
|
|
|
+ if (project.getStatus() < CrowdTestProjectStatus.HAS_FINISHED && project.getRegionalManagerId().equals(userId)) {
|
|
|
reportDetailsDTO.setOperational(true);
|
|
|
+
|
|
|
+ }
|
|
|
return reportDetailsDTO;
|
|
|
}
|
|
|
|
|
@@ -775,11 +832,11 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<EvolutionAgencyVO> renderAgencyList() {
|
|
|
- List<EvolutionAgencyVO> agencyList = new ArrayList<>();
|
|
|
+ public List<EvaluationAgencyVO> renderAgencyList() {
|
|
|
+ List<EvaluationAgencyVO> agencyList = new ArrayList<>();
|
|
|
EvaluationAgency agencyTemplate = evaluationAgencyRepo.findAgencyById(Long.parseLong(agencyId));
|
|
|
agencyDao.findAll().forEach(evaluationAgencyPO -> {
|
|
|
- EvolutionAgencyVO agencyVO = new EvolutionAgencyVO();
|
|
|
+ EvaluationAgencyVO agencyVO = new EvaluationAgencyVO();
|
|
|
agencyVO.setId(evaluationAgencyPO.getUserId());
|
|
|
agencyVO.setEvaluationAgencyName(evaluationAgencyPO.getEvaluationAgencyName());
|
|
|
agencyList.add(agencyVO);
|
|
@@ -910,7 +967,7 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
@Override
|
|
|
public UserDTO updateInformation(long userId, UserVO userVO) {
|
|
|
Optional<UserPO> userPO = userDao.findById(userId);
|
|
|
- if(userVO.getUnit()==null||userVO.getUnit().length()<=0){
|
|
|
+ if (userVO.getUnit() == null || userVO.getUnit().length() <= 0) {
|
|
|
throw new HttpBadRequestException("请输入企业简称");
|
|
|
}
|
|
|
userPO.get().setUnit(userVO.getUnit());
|
|
@@ -1004,7 +1061,7 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
String result = restTemplate.getForObject(url, String.class);
|
|
|
JSONObject json = new JSONObject(result);
|
|
|
String validated = String.valueOf(json.get("validated"));
|
|
|
- if("false".equals(validated)){
|
|
|
+ if ("false".equals(validated)) {
|
|
|
throw new HttpBadRequestException("请输入正确的卡号");
|
|
|
}
|
|
|
String bank = String.valueOf(json.get("bank"));
|
|
@@ -1054,13 +1111,13 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
resourceVO.setRemarks(resourcePO.getRemarks());
|
|
|
resourceVOList.add(resourceVO);
|
|
|
});
|
|
|
- List<ResourceVO> results=resourceVOList.stream().sorted(Comparator.comparing(ResourceVO::getStartTime).reversed()).collect(Collectors.toList());
|
|
|
+ List<ResourceVO> results = resourceVOList.stream().sorted(Comparator.comparing(ResourceVO::getStartTime).reversed()).collect(Collectors.toList());
|
|
|
return results;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public ResourceVO getResourceDetailed(String code) {
|
|
|
- Optional<ResourcePO> resourcePO=resourceDao.findByCode(code);
|
|
|
+ Optional<ResourcePO> resourcePO = resourceDao.findByCode(code);
|
|
|
ResourceVO resourceVO = new ResourceVO();
|
|
|
resourceVO.setCode(resourcePO.get().getCode());
|
|
|
resourceVO.setName(resourcePO.get().getName());
|
|
@@ -1102,7 +1159,7 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
resourceVO.setRemarks(resourcePO.getRemarks());
|
|
|
resourceVOList.add(resourceVO);
|
|
|
});
|
|
|
- List<ResourceVO> results=resourceVOList.stream().sorted(Comparator.comparing(ResourceVO::getStartTime).reversed()).collect(Collectors.toList());
|
|
|
+ List<ResourceVO> results = resourceVOList.stream().sorted(Comparator.comparing(ResourceVO::getStartTime).reversed()).collect(Collectors.toList());
|
|
|
return results;
|
|
|
}
|
|
|
|
|
@@ -1110,7 +1167,7 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
ProjectOperationControl operationControl = new ProjectOperationControl();
|
|
|
if (user == null)
|
|
|
return operationControl;
|
|
|
- if(project.getStatus() == CrowdTestProjectStatus.HAS_TIME_OUT){
|
|
|
+ if (project.getStatus() == CrowdTestProjectStatus.HAS_TIME_OUT) {
|
|
|
return operationControl;
|
|
|
}
|
|
|
|
|
@@ -1168,7 +1225,7 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
TaskOperationControl taskOperationControl = new TaskOperationControl();
|
|
|
if (user == null)
|
|
|
return taskOperationControl;
|
|
|
- if(task.getStatus() == CrowdTestTaskStatus.HAS_TIME_OUT){
|
|
|
+ if (task.getStatus() == CrowdTestTaskStatus.HAS_TIME_OUT) {
|
|
|
return taskOperationControl;
|
|
|
}
|
|
|
|