fix: 修复学生报告中的排位问题

11111
winter 1 year ago
parent ef1979cbd7
commit 40d4826695

@ -111,8 +111,8 @@ public interface AppraiseRecordRepository extends CosmosRepository<AppraiseRecor
"group by c.targetId, n.appraiseNode.isPraise") "group by c.targetId, n.appraiseNode.isPraise")
List<RankPo> studentRank(String code, String academicYearId, Long startTime, Long endTime); List<RankPo> studentRank(String code, String academicYearId, Long startTime, Long endTime);
@Query("select c.targetId, c.praiseCount from Student as c where c.code = @code and c.academicYearId = @academicYearId and c.targetType = 'student' and c.classId = @classId") @Query("SELECT value count(1) FROM Student AS c where c.code = @code and c.academicYearId = @academicYearId and c.classId = @classId and c.praiseCount > @praiseCount")
List<AppraiseRecord> findClassRecord(String code, String academicYearId, String classId); int findClassRecord(String code, String academicYearId, String classId, int praiseCount);

@ -426,8 +426,8 @@ public class EvaluationServiceImpl implements EvaluationService {
academicYearId, academicYearId,
String.format(PK.PK_APPRAISE_RECORD, schoolId) String.format(PK.PK_APPRAISE_RECORD, schoolId)
); );
// 班级内学生总数
int stuInClassCount = studentRepository.countByClassIdAndCode(classId, String.format(PK.STUDENT, schoolId)); int stuInClassCount = studentRepository.countByClassIdAndCode(classId, String.format(PK.STUDENT, schoolId));
List<AppraiseRecord> classRecord = appraiseRecordRepository.findClassRecord(String.format(PK.PK_APPRAISE_RECORD, schoolId), academicYearId, classId);
if (appraiseRecord == null || appraiseRecord.getNodes() == null) { if (appraiseRecord == null || appraiseRecord.getNodes() == null) {
throw new ServiceException(ErrorCode.OPERATION_ERROR.getCode(), "当前学生暂未产生评价数据,无法生成报告"); throw new ServiceException(ErrorCode.OPERATION_ERROR.getCode(), "当前学生暂未产生评价数据,无法生成报告");
@ -450,9 +450,11 @@ public class EvaluationServiceImpl implements EvaluationService {
Map<String, Integer> praiseNodeMap = new HashMap<>(); Map<String, Integer> praiseNodeMap = new HashMap<>();
Map<String, Integer> criticalNodeMap = new HashMap<>(); Map<String, Integer> criticalNodeMap = new HashMap<>();
// 计算当前学生排名在全班次位 // 计算当前学生排名在全班次位
int greaterCount = appraiseRecordRepository.findClassRecord(String.format(PK.PK_APPRAISE_RECORD, schoolId), academicYearId, classId, praiseCount);
float beyondPercent = 0; float beyondPercent = 0;
long currentRank = classRecord.stream().filter(item -> item.getPraiseCount() < praiseCount).count(); long currentRank = stuInClassCount - greaterCount;
beyondPercent = (float) currentRank / stuInClassCount; beyondPercent = (float) currentRank / stuInClassCount;
// 根据全部数据计算结果 // 根据全部数据计算结果
for (AppraiseRecordItem record : records) { for (AppraiseRecordItem record : records) {
AppraiseTreeNode appraiseNode = record.getAppraiseNode(); AppraiseTreeNode appraiseNode = record.getAppraiseNode();

@ -231,7 +231,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")); System.out.println(appraiseRecordRepository.findClassRecord("AppraiseRecord-hbcn", "2023-08b81e76-e7d2-4001-8b4c-e7c789ef4bs1", "ae01dc81-1422-4643-bf13-0b38c6d15b1b", 8));
} }

Loading…
Cancel
Save