Преглед на файлове

add: 增加机构和人员的top3排行

guo00guo преди 5 години
родител
ревизия
c2957b1e54

+ 1 - 1
core/src/main/java/com/mooctest/crowd/domain/dao/TaskToUserDao.java

@@ -29,5 +29,5 @@ public interface TaskToUserDao extends CrudRepository<TaskToUserPO,Long> {
     List<RankInfo> findTotalPriceOfAgency(Pageable pageable);
 
     @Query(value = "SELECT new com.mooctest.crowd.domain.model.RankCountInfo(SUM(t.isCommitted), t.userId) FROM TaskToUserPO t where t.userId is not null and t.isCommitted=1 GROUP BY t.userId ORDER BY SUM(t.isCommitted) DESC")
-    List<RankCountInfo> findTotalCountOfUser(Pageable pageable);
+    List<RankCountInfo> findTotalCountOfUser();
 }

Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
site/src/main/java/com/mooctest/crowd/site/controller/CommonController.java


+ 5 - 5
site/src/main/java/com/mooctest/crowd/site/data/vo/UserVO.java

@@ -6,8 +6,6 @@ import lombok.Data;
 import lombok.NoArgsConstructor;
 import org.springframework.beans.BeanUtils;
 
-import java.util.Date;
-
 /**
  * @Author: xuexb
  * @Date: 2019.7.15 20:41
@@ -27,6 +25,7 @@ public class UserVO {
     private String photoUrl;
     private Double allProjectPrice;
     private String authType;
+    private Long taskCount;
 
     public UserVO(User user){
         BeanUtils.copyProperties(user, this);
@@ -41,9 +40,10 @@ public class UserVO {
             this.authType = "noAuth";
     }
 
-    public User toUser(){
-        //todo
-        return new User();
+    public void toUser(User user){
+        id = user.getId();
+        name = user.getName();
+        userName = user.getUserName();
     }
 
     public UserVO(Account account){

+ 17 - 14
site/src/main/java/com/mooctest/crowd/site/mediator/impl/WebMediatorImpl.java

@@ -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,10 @@ public class WebMediatorImpl implements ViewMediator {
     public IndexInfoDTO renderIndexInfos() {
         IndexInfoDTO indexInfoDTO = new IndexInfoDTO();
         Pageable pageable = PageRequest.of(0, 3);
+        int top = 3;
         //获取机构排名
         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 +116,24 @@ 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<TestType> allTestType = commonRepo.getAllTestType();
@@ -161,8 +164,8 @@ public class WebMediatorImpl implements ViewMediator {
 
         // 获取大赛信息
         List<Competition> competitionList = commonRepo.getAllCompetition();
-        if(competitionList.size() > 3){
-            competitionList = competitionList.subList(0,3);
+        if(competitionList.size() > top){
+            competitionList = competitionList.subList(0,top);
         }
         List<CompetitionVO> competitionVOS = competitionList.stream().map(competition -> {
             CompetitionVO competitionVO = new CompetitionVO(competition);
@@ -191,10 +194,10 @@ public class WebMediatorImpl implements ViewMediator {
             return evolutionAgencyVO;
         }).collect(Collectors.toList());
 
-        Page<CrowdTestProjectPO> all = projectDao.findAll(pageable);
+//        Page<CrowdTestProjectPO> all = projectDao.findAll(pageable);
 
         indexInfoDTO.setAgencyRank(agencyRanks);
-//        indexInfoDTO.setUserRank(userRanks);
+        indexInfoDTO.setUserRank(userRanks);
         indexInfoDTO.setTestTypeList(testTypeVOS);
         indexInfoDTO.setApplicationTypeList(applicationTypeVOS);
         indexInfoDTO.setFieldList(fieldVOS);

+ 2 - 0
site/src/main/java/com/mooctest/crowd/site/service/CommonService.java

@@ -10,4 +10,6 @@ public interface CommonService {
     IndexDTO getIndexInfo();
 
     MyCrowdDTO getPersonCrowd(Long userId);
+
+    IndexInfoDTO getIndexInfos();
 }

+ 5 - 0
site/src/main/java/com/mooctest/crowd/site/service/impl/CommonServiceImpl.java

@@ -25,4 +25,9 @@ public class CommonServiceImpl implements CommonService {
     public MyCrowdDTO getPersonCrowd(Long userId) {
         return viewMediator.renderMyCrowd(userId);
     }
+
+    @Override
+    public IndexInfoDTO getIndexInfos() {
+        return viewMediator.renderIndexInfos();
+    }
 }

Някои файлове не бяха показани, защото твърде много файлове са промени