feat: 评价指标排序添加 path 和 praise

11111
winter 1 year ago
parent 178e3cfc03
commit 8301c973c0

@ -3,10 +3,7 @@ package cn.teammodel.controller.admin.controller;
import cn.teammodel.common.R; import cn.teammodel.common.R;
import cn.teammodel.controller.admin.service.AdminAppraiseService; import cn.teammodel.controller.admin.service.AdminAppraiseService;
import cn.teammodel.model.dto.admin.TimeRangeDto; import cn.teammodel.model.dto.admin.TimeRangeDto;
import cn.teammodel.model.vo.admin.IndexData; import cn.teammodel.model.vo.admin.*;
import cn.teammodel.model.vo.admin.RankPo;
import cn.teammodel.model.vo.admin.RankVo;
import cn.teammodel.model.vo.admin.StudentRankVo;
import cn.teammodel.model.vo.appraise.RecordVo; import cn.teammodel.model.vo.appraise.RecordVo;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -61,8 +58,8 @@ public class IndexController {
} }
@PostMapping("appraiseNodeRank") @PostMapping("appraiseNodeRank")
@ApiOperation("评价指标活跃排行榜: Top10") @ApiOperation("评价指标活跃排行榜: Top10")
public R<List<RankPo>> appraiseNodeRank(@Valid @RequestBody TimeRangeDto timeRangeDto) { public R<List<AppraiseNodeRankVo>> appraiseNodeRank(@Valid @RequestBody TimeRangeDto timeRangeDto) {
List<RankPo> res = adminAppraiseService.appraiseNodeRank(timeRangeDto); List<AppraiseNodeRankVo> res = adminAppraiseService.appraiseNodeRank(timeRangeDto);
return R.success(res); return R.success(res);
} }

@ -3,10 +3,7 @@ package cn.teammodel.controller.admin.service;
import cn.teammodel.model.dto.admin.TimeRangeDto; import cn.teammodel.model.dto.admin.TimeRangeDto;
import cn.teammodel.model.dto.admin.UpdateAchievementRuleDto; import cn.teammodel.model.dto.admin.UpdateAchievementRuleDto;
import cn.teammodel.model.entity.appraise.AchievementRule; import cn.teammodel.model.entity.appraise.AchievementRule;
import cn.teammodel.model.vo.admin.IndexData; import cn.teammodel.model.vo.admin.*;
import cn.teammodel.model.vo.admin.RankPo;
import cn.teammodel.model.vo.admin.RankVo;
import cn.teammodel.model.vo.admin.StudentRankVo;
import cn.teammodel.model.vo.appraise.RecordVo; import cn.teammodel.model.vo.appraise.RecordVo;
import java.util.List; import java.util.List;
@ -27,7 +24,7 @@ public interface AdminAppraiseService {
List<RankVo> teacherRank(TimeRangeDto timeRangeDto); List<RankVo> teacherRank(TimeRangeDto timeRangeDto);
List<RankPo> appraiseNodeRank(TimeRangeDto timeRangeDto); List<AppraiseNodeRankVo> appraiseNodeRank(TimeRangeDto timeRangeDto);
List<StudentRankVo> studentRank(TimeRangeDto timeRangeDto); List<StudentRankVo> studentRank(TimeRangeDto timeRangeDto);

@ -10,14 +10,12 @@ import cn.teammodel.model.dto.admin.UpdateAchievementRuleDto;
import cn.teammodel.model.entity.User; import cn.teammodel.model.entity.User;
import cn.teammodel.model.entity.appraise.AchievementRule; import cn.teammodel.model.entity.appraise.AchievementRule;
import cn.teammodel.model.entity.appraise.Appraise; import cn.teammodel.model.entity.appraise.Appraise;
import cn.teammodel.model.entity.appraise.AppraiseTreeNode;
import cn.teammodel.model.entity.school.ClassInfo; import cn.teammodel.model.entity.school.ClassInfo;
import cn.teammodel.model.entity.school.School; import cn.teammodel.model.entity.school.School;
import cn.teammodel.model.entity.school.Student; import cn.teammodel.model.entity.school.Student;
import cn.teammodel.model.entity.school.Teacher; import cn.teammodel.model.entity.school.Teacher;
import cn.teammodel.model.vo.admin.IndexData; import cn.teammodel.model.vo.admin.*;
import cn.teammodel.model.vo.admin.RankPo;
import cn.teammodel.model.vo.admin.RankVo;
import cn.teammodel.model.vo.admin.StudentRankVo;
import cn.teammodel.model.vo.appraise.RecordVo; import cn.teammodel.model.vo.appraise.RecordVo;
import cn.teammodel.security.utils.SecurityUtil; import cn.teammodel.security.utils.SecurityUtil;
import cn.teammodel.utils.RepositoryUtil; import cn.teammodel.utils.RepositoryUtil;
@ -237,25 +235,43 @@ public class AdminAppraiseServiceImpl implements AdminAppraiseService {
} }
@Override @Override
public List<RankPo> appraiseNodeRank(TimeRangeDto timeRangeDto) { public List<AppraiseNodeRankVo> appraiseNodeRank(TimeRangeDto timeRangeDto) {
Long startTime = timeRangeDto.getStartTime(); Long startTime = timeRangeDto.getStartTime();
Long endTime = timeRangeDto.getEndTime(); Long endTime = timeRangeDto.getEndTime();
String academicYearId = timeRangeDto.getAcademicYearId(); String academicYearId = timeRangeDto.getAcademicYearId();
String schoolId = SecurityUtil.getLoginUser().getSchoolId(); String schoolId = SecurityUtil.getLoginUser().getSchoolId();
List<RankPo> rankPoList = appraiseRecordRepository.appraiseNodeRank( List<AppraiseNodeRankVo> rankVoList = appraiseRecordRepository.appraiseNodeRank(
String.format(PK.PK_APPRAISE_RECORD, schoolId), String.format(PK.PK_APPRAISE_RECORD, schoolId),
academicYearId, academicYearId,
startTime, startTime,
endTime endTime
); );
if (rankPoList == null) return null; if (rankVoList == null) return null;
rankPoList = rankPoList.stream() List<String> names = rankVoList.stream().map(AppraiseNodeRankVo::getName).collect(Collectors.toList());
// 去重后的 nodes
List<AppraiseTreeNode> nodesByName = appraiseRecordRepository.findAppraiseRecordInNames(String.format(PK.PK_APPRAISE_RECORD, schoolId), academicYearId, names);
// 正常情况下 name 一一对应
Map<String, AppraiseTreeNode> nameNodeMap = nodesByName.stream().collect(Collectors.toMap(AppraiseTreeNode::getName, item -> item, (existing, replacement) -> {
if (replacement.getPath() != null) {
return replacement;
}
return existing;
}));
rankVoList = rankVoList.stream()
.sorted(Comparator.comparing(RankPo::getCount).reversed()) .sorted(Comparator.comparing(RankPo::getCount).reversed())
// 流中对元素操作但不改变流
.peek(s -> {
AppraiseTreeNode node = nameNodeMap.get(s.getName());
if (node != null) {
s.setPath(node.getPath());
s.setIsPraise(node.isPraise());
}
})
.collect(Collectors.toList()); .collect(Collectors.toList());
return rankVoList;
return rankPoList;
} }
@Override @Override

@ -1,6 +1,8 @@
package cn.teammodel.dao; package cn.teammodel.dao;
import cn.teammodel.model.entity.appraise.AppraiseRecord; import cn.teammodel.model.entity.appraise.AppraiseRecord;
import cn.teammodel.model.entity.appraise.AppraiseTreeNode;
import cn.teammodel.model.vo.admin.AppraiseNodeRankVo;
import cn.teammodel.model.vo.admin.RankPo; import cn.teammodel.model.vo.admin.RankPo;
import cn.teammodel.model.vo.appraise.AppraiseRecordVo; import cn.teammodel.model.vo.appraise.AppraiseRecordVo;
import cn.teammodel.model.vo.appraise.RecordVo; import cn.teammodel.model.vo.appraise.RecordVo;
@ -97,7 +99,13 @@ public interface AppraiseRecordRepository extends CosmosRepository<AppraiseRecor
"(IS_NULL(@endTime) or n.createTime <= @endTime) and " + "(IS_NULL(@endTime) or n.createTime <= @endTime) and " +
"(c.code = @code) " + "(c.code = @code) " +
"group by n.appraiseNode.name") "group by n.appraiseNode.name")
List<RankPo> appraiseNodeRank(String code, String academicYearId, Long startTime, Long endTime); List<AppraiseNodeRankVo> appraiseNodeRank(String code, String academicYearId, Long startTime, Long endTime);
@Query("select DISTINCT n.appraiseNode.name, n.appraiseNode.path, n.appraiseNode.isPraise from Student as c join n in c.nodes where " +
" (c.academicYearId = @academicYearId) and " +
" (c.code = @code) and " +
" n.appraiseNode.name in (@names)")
List<AppraiseTreeNode> findAppraiseRecordInNames(String code, String academicYearId, List<String> names);
/** /**
* , * ,

@ -0,0 +1,14 @@
package cn.teammodel.model.vo.admin;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author winter
* @create 2023-12-25 17:44
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class AppraiseNodeRankVo extends RankPo {
String[] Path;
}

@ -8,7 +8,6 @@ import cn.teammodel.model.dto.admin.TimeRangeDto;
import cn.teammodel.model.dto.admin.UpdateAchievementRuleDto; import cn.teammodel.model.dto.admin.UpdateAchievementRuleDto;
import cn.teammodel.model.entity.appraise.*; import cn.teammodel.model.entity.appraise.*;
import cn.teammodel.model.entity.school.School; import cn.teammodel.model.entity.school.School;
import cn.teammodel.model.vo.admin.RankPo;
import cn.teammodel.service.EvaluationService; import cn.teammodel.service.EvaluationService;
import cn.teammodel.service.impl.EvaluationServiceImpl; import cn.teammodel.service.impl.EvaluationServiceImpl;
import com.azure.cosmos.models.PartitionKey; import com.azure.cosmos.models.PartitionKey;
@ -20,10 +19,7 @@ import org.springframework.boot.test.context.SpringBootTest;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.temporal.WeekFields; import java.time.temporal.WeekFields;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Locale;
import java.util.UUID;
@SpringBootTest @SpringBootTest
class TeamModelExtensionApplicationTests { class TeamModelExtensionApplicationTests {
@ -179,8 +175,8 @@ class TeamModelExtensionApplicationTests {
public void testIndexData() { public void testIndexData() {
TimeRangeDto timeRangeDto = new TimeRangeDto(); TimeRangeDto timeRangeDto = new TimeRangeDto();
timeRangeDto.setAcademicYearId("2023-71fbd0bd-9a46-0490-f6b3-7d16cba4c017"); timeRangeDto.setAcademicYearId("2023-71fbd0bd-9a46-0490-f6b3-7d16cba4c017");
List<RankPo> list = adminAppraiseService.appraiseNodeRank(timeRangeDto); // List<RankPo> list = adminAppraiseService.appraiseNodeRank(timeRangeDto);
System.out.println(list); // System.out.println(list);
} }
@Test @Test
@ -231,7 +227,7 @@ class TeamModelExtensionApplicationTests {
// System.out.println(chatSessionRepository.save("111e90e5-6afd-413b-ae0f-646d957aedf8", PK.of(PK.CHAT_SESSION), ChatSession.class, options)); // System.out.println(chatSessionRepository.save("111e90e5-6afd-413b-ae0f-646d957aedf8", PK.of(PK.CHAT_SESSION), ChatSession.class, options));
// System.out.println(chatSessionRepository.findLatestMessage("111e90e5-6afd-413b-ae0f-646d957aedf8")); // System.out.println(chatSessionRepository.findLatestMessage("111e90e5-6afd-413b-ae0f-646d957aedf8"));
System.out.println(appraiseRecordRepository.findClassRecord("AppraiseRecord-hbcn", "2023-08b81e76-e7d2-4001-8b4c-e7c789ef4bs1", "ae01dc81-1422-4643-bf13-0b38c6d15b1b", 8)); System.out.println(appraiseRecordRepository.findAppraiseRecordInNames("AppraiseRecord-hbcn", "2023-08b81e76-e7d2-4001-8b4c-e7c789ef4bs1", Arrays.asList("能够感知美")));
} }

Loading…
Cancel
Save