|
@@ -2,12 +2,10 @@ package com.mooctest.crowd.site.service.impl;
|
|
|
|
|
|
import com.mooctest.crowd.domain.dao.CrowdTestProjectDao;
|
|
|
import com.mooctest.crowd.domain.dao.ResourceTypeDao;
|
|
|
-import com.mooctest.crowd.domain.domainobject.CrowdTestProject;
|
|
|
-import com.mooctest.crowd.domain.domainobject.CrowdTestProjectStatus;
|
|
|
-import com.mooctest.crowd.domain.domainobject.CrowdTestTask;
|
|
|
-import com.mooctest.crowd.domain.domainobject.User;
|
|
|
+import com.mooctest.crowd.domain.domainobject.*;
|
|
|
import com.mooctest.crowd.domain.exception.HaveNotAgencyAuthException;
|
|
|
import com.mooctest.crowd.domain.exception.HaveNotPartAuthException;
|
|
|
+import com.mooctest.crowd.domain.model.CrowdTestProjectPO;
|
|
|
import com.mooctest.crowd.domain.model.ResourceTypePO;
|
|
|
import com.mooctest.crowd.domain.repository.*;
|
|
|
import com.mooctest.crowd.site.constants.CommonConstant;
|
|
@@ -283,6 +281,35 @@ public class CommonServiceImpl implements CommonService {
|
|
|
return statisticsList;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<Map.Entry<String, Long>> getAgencyProjectCount() {
|
|
|
+ HashMap<String, Long> agencyProjectCountMap = new HashMap<>();
|
|
|
+ List<EvaluationAgency> evaluationAgencyList = agencyRepo.findAll();
|
|
|
+ for (EvaluationAgency evaluationAgency : evaluationAgencyList){
|
|
|
+ //获取我创建的项目列表
|
|
|
+ List<CrowdTestProjectPO> myProjects = projectDao.findByUserIdAndIsDeleted(evaluationAgency.getUserId(), DeletedStatus.isNotDeleted);
|
|
|
+ agencyProjectCountMap.put(evaluationAgency.getEvaluationAgencyName(), (long) myProjects.size());
|
|
|
+ }
|
|
|
+
|
|
|
+ //////借助list实现hashMap排序//////
|
|
|
+ //注意 ArrayList<>() 括号里要传入map.entrySet()
|
|
|
+ List<Map.Entry<String, Long>> resultList = new ArrayList<>(agencyProjectCountMap.entrySet());
|
|
|
+ Collections.sort(resultList, new Comparator<Map.Entry<String, Long>>()
|
|
|
+ {
|
|
|
+ @Override
|
|
|
+ public int compare(Map.Entry<String, Long> o1, Map.Entry<String, Long> o2)
|
|
|
+ {
|
|
|
+ //按照value值,重小到大排序
|
|
|
+// return o1.getValue() - o2.getValue();
|
|
|
+ //按照value值,从大到小排序
|
|
|
+ return (int) (o2.getValue() - o1.getValue());
|
|
|
+ //按照value值,用compareTo()方法默认是从小到大排序
|
|
|
+// return o1.getValue().compareTo(o2.getValue());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return resultList.stream().filter(result -> !result.getValue().equals(0L)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
Pageable getPageable(SearchConditionVO searchConditionVO) {
|
|
|
int activePage = searchConditionVO.getActivePage() == 0 ? 1 : searchConditionVO.getActivePage();
|
|
|
Sort sort = new Sort(Sort.Direction.DESC, "id");
|