|
|
@ -3,7 +3,9 @@ package cn.teammodel.controller.admin.service.impl;
|
|
|
|
import cn.teammodel.common.ErrorCode;
|
|
|
|
import cn.teammodel.common.ErrorCode;
|
|
|
|
import cn.teammodel.common.PK;
|
|
|
|
import cn.teammodel.common.PK;
|
|
|
|
import cn.teammodel.config.exception.ServiceException;
|
|
|
|
import cn.teammodel.config.exception.ServiceException;
|
|
|
|
|
|
|
|
import cn.teammodel.controller.admin.service.CommonService;
|
|
|
|
import cn.teammodel.controller.admin.service.LaborEducationService;
|
|
|
|
import cn.teammodel.controller.admin.service.LaborEducationService;
|
|
|
|
|
|
|
|
import cn.teammodel.model.dto.admin.common.GCDto;
|
|
|
|
import cn.teammodel.model.dto.admin.common.GroupDto;
|
|
|
|
import cn.teammodel.model.dto.admin.common.GroupDto;
|
|
|
|
import cn.teammodel.model.dto.admin.common.RMember;
|
|
|
|
import cn.teammodel.model.dto.admin.common.RMember;
|
|
|
|
import cn.teammodel.model.dto.admin.labor.LaborDto;
|
|
|
|
import cn.teammodel.model.dto.admin.labor.LaborDto;
|
|
|
@ -13,6 +15,8 @@ import cn.teammodel.model.entity.common.Exam;
|
|
|
|
import cn.teammodel.model.entity.common.ExamClassResult;
|
|
|
|
import cn.teammodel.model.entity.common.ExamClassResult;
|
|
|
|
import cn.teammodel.model.entity.school.ClassInfo;
|
|
|
|
import cn.teammodel.model.entity.school.ClassInfo;
|
|
|
|
import cn.teammodel.model.entity.school.LessonRecord;
|
|
|
|
import cn.teammodel.model.entity.school.LessonRecord;
|
|
|
|
|
|
|
|
import cn.teammodel.model.entity.school.School;
|
|
|
|
|
|
|
|
import cn.teammodel.model.vo.admin.GradeAndClassVo;
|
|
|
|
import cn.teammodel.model.vo.appraise.RecordVo;
|
|
|
|
import cn.teammodel.model.vo.appraise.RecordVo;
|
|
|
|
import cn.teammodel.repository.*;
|
|
|
|
import cn.teammodel.repository.*;
|
|
|
|
import cn.teammodel.security.utils.SecurityUtil;
|
|
|
|
import cn.teammodel.security.utils.SecurityUtil;
|
|
|
@ -51,6 +55,11 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
private AppraiseRepository appraiseRepository;
|
|
|
|
private AppraiseRepository appraiseRepository;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private EvaluationServiceImpl evaluationService;
|
|
|
|
private EvaluationServiceImpl evaluationService;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private SchoolRepository schoolRepository;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private CommonService commonService;
|
|
|
|
|
|
|
|
|
|
|
|
private static Environment environment; // 静态字段
|
|
|
|
private static Environment environment; // 静态字段
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private Environment env; // 非静态字段
|
|
|
|
private Environment env; // 非静态字段
|
|
|
@ -156,6 +165,10 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
if (!examIds.isEmpty()) {
|
|
|
|
if (!examIds.isEmpty()) {
|
|
|
|
examResults = examClassResultRepository.findAll(String.format(PK.CLASS_RESULT, laborDto.getCode()),examIds);
|
|
|
|
examResults = examClassResultRepository.findAll(String.format(PK.CLASS_RESULT, laborDto.getCode()),examIds);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//获取学校基础信息
|
|
|
|
|
|
|
|
List<School.Period> period = schoolRepository.findPeriodById(schoolId,periodId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<GradeAndClassVo> gradeAndClassVos = commonService.getGradeAndClass(new GCDto(schoolId, periodId));
|
|
|
|
Map<String, Object> resMap = new HashMap<>();
|
|
|
|
Map<String, Object> resMap = new HashMap<>();
|
|
|
|
//处理德育知识块和知识点的关联关系
|
|
|
|
//处理德育知识块和知识点的关联关系
|
|
|
|
resMap.put("subjectiveCount", res.size()); //主观评价数
|
|
|
|
resMap.put("subjectiveCount", res.size()); //主观评价数
|
|
|
@ -174,9 +187,9 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
classScoreRate = calculateKnowledgeScoreRateForClass(laborDto.getClassId(), examResults, knowledgeMap, appraise, point,res,request);
|
|
|
|
classScoreRate = calculateKnowledgeScoreRateForClass(laborDto.getClassId(), examResults, knowledgeMap, appraise, point,res,request);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (laborDto.getGrade() != null) {
|
|
|
|
if (laborDto.getGrade() != null) {
|
|
|
|
gradeScoreRate = calculateKnowledgeScoreForGrade(laborDto.getGrade(), examResults, knowledgeMap,appraise, point,res);
|
|
|
|
gradeScoreRate = calculateKnowledgeScoreForGrade(laborDto.getGrade(), examResults, knowledgeMap,appraise, point,res,gradeAndClassVos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Map<String,Object> schoolScoreRate = calculateKnowledgeScoreForSchool(examResults, knowledgeMap,appraise, point,res);
|
|
|
|
Map<String,Object> schoolScoreRate = calculateKnowledgeScoreForSchool(examResults, knowledgeMap,appraise, point,res,period,gradeAndClassVos);
|
|
|
|
resMap.put("gradeScoreRate", gradeScoreRate);
|
|
|
|
resMap.put("gradeScoreRate", gradeScoreRate);
|
|
|
|
resMap.put("classScoreRate", classScoreRate);
|
|
|
|
resMap.put("classScoreRate", classScoreRate);
|
|
|
|
resMap.put("schoolScoreRate", schoolScoreRate);
|
|
|
|
resMap.put("schoolScoreRate", schoolScoreRate);
|
|
|
@ -705,12 +718,19 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
Map<String, List<List<String>>> knowledgeMap,
|
|
|
|
Map<String, List<List<String>>> knowledgeMap,
|
|
|
|
Appraise appraise,
|
|
|
|
Appraise appraise,
|
|
|
|
Map<String, List<Double>> points,
|
|
|
|
Map<String, List<Double>> points,
|
|
|
|
List<RecordVo> res) { // 新增主观评价记录
|
|
|
|
List<RecordVo> res,
|
|
|
|
|
|
|
|
List<GradeAndClassVo> gradeAndClassVos) {
|
|
|
|
|
|
|
|
|
|
|
|
// 1. 获取年级所有班级的客观分数
|
|
|
|
// 1. 获取年级所有班级的客观分数
|
|
|
|
Map<String, Map<String, Double>> classScores = new HashMap<>();
|
|
|
|
Map<String, Map<String, Double>> classScores = new HashMap<>();
|
|
|
|
Map<String, Double> gradeScores = new HashMap<>();
|
|
|
|
Map<String, Double> gradeScores = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 根据 gradeId 匹配并取出 classId 集合
|
|
|
|
|
|
|
|
List<GradeAndClassVo.CI> classInfos = gradeAndClassVos.stream()
|
|
|
|
|
|
|
|
.filter(gradeAndClassVo -> String.valueOf(gradeAndClassVo.getGradeId()).equals(gradeId))
|
|
|
|
|
|
|
|
.flatMap(gradeAndClassVo -> gradeAndClassVo.getClasses().stream())
|
|
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
// 过滤出该年级的考试结果
|
|
|
|
// 过滤出该年级的考试结果
|
|
|
|
List<ExamClassResult> gradeExamResults = examResults.stream()
|
|
|
|
List<ExamClassResult> gradeExamResults = examResults.stream()
|
|
|
|
.filter(examResult -> examResult.getGradeId().equals(gradeId))
|
|
|
|
.filter(examResult -> examResult.getGradeId().equals(gradeId))
|
|
|
@ -740,64 +760,66 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 4. 遍历年级下的所有班级
|
|
|
|
// 4. 遍历年级下的所有班级
|
|
|
|
for (ExamClassResult examResult : gradeExamResults) {
|
|
|
|
for (GradeAndClassVo.CI info : classInfos) {
|
|
|
|
String classId = examResult.getInfo().getId();
|
|
|
|
String className = info.getClassName();
|
|
|
|
String className = examResult.getInfo().getName();
|
|
|
|
|
|
|
|
Map<String, Double> classScoreSum = new HashMap<>();
|
|
|
|
|
|
|
|
Map<String, Integer> classScoreCount = new HashMap<>();
|
|
|
|
|
|
|
|
Map<String, Double> classScoresInner = new HashMap<>();
|
|
|
|
Map<String, Double> classScoresInner = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
// 获取学生状态列表
|
|
|
|
for (ExamClassResult examResult : gradeExamResults) {
|
|
|
|
List<Integer> statuses = examResult.getStatus();
|
|
|
|
if (examResult.getInfo().getId().equals(info.getClassId())) {
|
|
|
|
// 遍历班级中的每个学生
|
|
|
|
Map<String, Double> classScoreSum = new HashMap<>();
|
|
|
|
for (int i = 0; i < examResult.getStudentIds().size(); i++) {
|
|
|
|
Map<String, Integer> classScoreCount = new HashMap<>();
|
|
|
|
String studentId = examResult.getStudentIds().get(i);
|
|
|
|
|
|
|
|
if (statuses.get(i) == 1) {
|
|
|
|
// 获取学生状态列表
|
|
|
|
continue;
|
|
|
|
List<Integer> statuses = examResult.getStatus();
|
|
|
|
}
|
|
|
|
// 遍历班级中的每个学生
|
|
|
|
|
|
|
|
for (int i = 0; i < examResult.getStudentIds().size(); i++) {
|
|
|
|
|
|
|
|
String studentId = examResult.getStudentIds().get(i);
|
|
|
|
|
|
|
|
if (statuses.get(i) == 1) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 计算学生的知识点得分(客观分数)
|
|
|
|
// 计算学生的知识点得分(客观分数)
|
|
|
|
Map<String, Double> studentObjectiveScores = calculateKnowledgeScoreRateForStudent(
|
|
|
|
Map<String, Double> studentObjectiveScores = calculateKnowledgeScoreRateForStudent(
|
|
|
|
studentId, examResults, knowledgeMap, appraise, points
|
|
|
|
studentId, examResults, knowledgeMap, appraise, points
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取学生的主观分数
|
|
|
|
|
|
|
|
Map<String, Double> studentSubjectiveScores = subjectiveScores.getOrDefault(studentId, new HashMap<>());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 计算综合得分(主观60%,客观40%)
|
|
|
|
|
|
|
|
Map<String, Double> studentCompositeScores = new HashMap<>();
|
|
|
|
|
|
|
|
for (Map.Entry<String, Double> entry : studentObjectiveScores.entrySet()) {
|
|
|
|
|
|
|
|
String block = entry.getKey();
|
|
|
|
|
|
|
|
double objectiveScore = entry.getValue();
|
|
|
|
|
|
|
|
double subjectiveScore = studentSubjectiveScores.getOrDefault(block, 0.0);
|
|
|
|
|
|
|
|
double compositeScore = (subjectiveScore * 0.6) + (objectiveScore * 0.4);
|
|
|
|
|
|
|
|
studentCompositeScores.put(block, compositeScore);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取学生的主观分数
|
|
|
|
// 累加班级整体得分
|
|
|
|
Map<String, Double> studentSubjectiveScores = subjectiveScores.getOrDefault(studentId, new HashMap<>());
|
|
|
|
for (Map.Entry<String, Double> entry : studentCompositeScores.entrySet()) {
|
|
|
|
|
|
|
|
String nodeName = entry.getKey();
|
|
|
|
// 计算综合得分(主观60%,客观40%)
|
|
|
|
double score = entry.getValue();
|
|
|
|
Map<String, Double> studentCompositeScores = new HashMap<>();
|
|
|
|
classScoreSum.put(nodeName, classScoreSum.getOrDefault(nodeName, 0.0) + score);
|
|
|
|
for (Map.Entry<String, Double> entry : studentObjectiveScores.entrySet()) {
|
|
|
|
classScoreCount.put(nodeName, classScoreCount.getOrDefault(nodeName, 0) + 1);
|
|
|
|
String block = entry.getKey();
|
|
|
|
}
|
|
|
|
double objectiveScore = entry.getValue();
|
|
|
|
}
|
|
|
|
double subjectiveScore = studentSubjectiveScores.getOrDefault(block, 0.0);
|
|
|
|
|
|
|
|
double compositeScore = (subjectiveScore * 0.6) + (objectiveScore * 0.4);
|
|
|
|
|
|
|
|
studentCompositeScores.put(block, compositeScore);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 累加班级整体得分
|
|
|
|
// 计算班级平均得分
|
|
|
|
for (Map.Entry<String, Double> entry : studentCompositeScores.entrySet()) {
|
|
|
|
for (Map.Entry<String, Double> entry : classScoreSum.entrySet()) {
|
|
|
|
String nodeName = entry.getKey();
|
|
|
|
String nodeName = entry.getKey();
|
|
|
|
double score = entry.getValue();
|
|
|
|
double totalScore = entry.getValue();
|
|
|
|
classScoreSum.put(nodeName, classScoreSum.getOrDefault(nodeName, 0.0) + score);
|
|
|
|
int count = classScoreCount.get(nodeName);
|
|
|
|
classScoreCount.put(nodeName, classScoreCount.getOrDefault(nodeName, 0) + 1);
|
|
|
|
classScoresInner.put(nodeName, Double.parseDouble(String.format("%.2f", totalScore / count))); // 保留小数点后两位
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 计算班级平均得分
|
|
|
|
|
|
|
|
for (Map.Entry<String, Double> entry : classScoreSum.entrySet()) {
|
|
|
|
|
|
|
|
String nodeName = entry.getKey();
|
|
|
|
|
|
|
|
double totalScore = entry.getValue();
|
|
|
|
|
|
|
|
int count = classScoreCount.get(nodeName);
|
|
|
|
|
|
|
|
classScoresInner.put(nodeName, Double.parseDouble(String.format("%.2f", totalScore / count))); // 保留小数点后两位
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 初始化所有同层的父节点
|
|
|
|
// 初始化所有同层的父节点
|
|
|
|
for (AppraiseTreeNode node : appraise.getNodes()) {
|
|
|
|
for (AppraiseTreeNode node : appraise.getNodes()) {
|
|
|
|
if (node.getName().equals("德育")) {
|
|
|
|
if ("德育".equals(node.getName())) {
|
|
|
|
for (AppraiseTreeNode child : node.getChildren()) {
|
|
|
|
for (AppraiseTreeNode child : node.getChildren()) {
|
|
|
|
if (!classScoresInner.containsKey(child.getName())) {
|
|
|
|
classScoresInner.putIfAbsent(child.getName(), 0.0);
|
|
|
|
classScoresInner.put(child.getName(), 0.0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -826,11 +848,9 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
|
|
|
|
|
|
|
|
// 初始化所有同层的父节点
|
|
|
|
// 初始化所有同层的父节点
|
|
|
|
for (AppraiseTreeNode node : appraise.getNodes()) {
|
|
|
|
for (AppraiseTreeNode node : appraise.getNodes()) {
|
|
|
|
if (node.getName().equals("德育")) {
|
|
|
|
if ("德育".equals(node.getName())) {
|
|
|
|
for (AppraiseTreeNode child : node.getChildren()) {
|
|
|
|
for (AppraiseTreeNode child : node.getChildren()) {
|
|
|
|
if (!gradeScores.containsKey(child.getName())) {
|
|
|
|
gradeScores.putIfAbsent(child.getName(), 0.0);
|
|
|
|
gradeScores.put(child.getName(), 0.0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -844,21 +864,29 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static Map<String, Object> calculateKnowledgeScoreForSchool(
|
|
|
|
public static Map<String, Object> calculateKnowledgeScoreForSchool(
|
|
|
|
List<ExamClassResult> examResults,
|
|
|
|
List<ExamClassResult> examResults,
|
|
|
|
Map<String, List<List<String>>> knowledgeMap,
|
|
|
|
Map<String, List<List<String>>> knowledgeMap,
|
|
|
|
Appraise appraise,
|
|
|
|
Appraise appraise,
|
|
|
|
Map<String, List<Double>> points,
|
|
|
|
Map<String, List<Double>> points,
|
|
|
|
List<RecordVo> res) { // 新增主观评价记录
|
|
|
|
List<RecordVo> res,
|
|
|
|
|
|
|
|
List<School.Period> period,
|
|
|
|
|
|
|
|
List<GradeAndClassVo> gradeAndClassVos) { // 新增主观评价记录
|
|
|
|
|
|
|
|
|
|
|
|
// 1. 获取全校所有年级的客观分数
|
|
|
|
// 1. 获取全校所有年级的客观分数
|
|
|
|
Map<String, Map<String, Double>> gradeScores = new HashMap<>();
|
|
|
|
Map<String, Map<String, Double>> gradeScores = new HashMap<>();
|
|
|
|
Map<String, Double> schoolScores = new HashMap<>();
|
|
|
|
Map<String, Double> schoolScores = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取所有年级的 ID
|
|
|
|
// 获取所有年级的 ID
|
|
|
|
Set<String> gradeIds = examResults.stream()
|
|
|
|
List<String> gradeIds = period.stream()
|
|
|
|
|
|
|
|
.flatMap(period1 -> period1.getGrades().stream())
|
|
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*Set<String> gradeIds = examResults.stream()
|
|
|
|
.map(ExamClassResult::getGradeId)
|
|
|
|
.map(ExamClassResult::getGradeId)
|
|
|
|
.collect(Collectors.toSet());
|
|
|
|
.collect(Collectors.toSet());*/
|
|
|
|
|
|
|
|
|
|
|
|
// 2. 获取全校所有学生的主观分数(次数)
|
|
|
|
// 2. 获取全校所有学生的主观分数(次数)
|
|
|
|
List<Map<String, Object>> subjectiveScoresList = calculateScoresWithDetails(res, appraise);
|
|
|
|
List<Map<String, Object>> subjectiveScoresList = calculateScoresWithDetails(res, appraise);
|
|
|
@ -884,10 +912,11 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 4. 遍历所有年级
|
|
|
|
// 4. 遍历所有年级
|
|
|
|
|
|
|
|
int index = 0;
|
|
|
|
for (String gradeId : gradeIds) {
|
|
|
|
for (String gradeId : gradeIds) {
|
|
|
|
// 计算该年级的平均得分(包含主观和客观分数)
|
|
|
|
// 计算该年级的平均得分(包含主观和客观分数)
|
|
|
|
Map<String, Object> gradeResult = calculateKnowledgeScoreForGrade(
|
|
|
|
Map<String, Object> gradeResult = calculateKnowledgeScoreForGrade(
|
|
|
|
gradeId, examResults, knowledgeMap, appraise, points, res
|
|
|
|
String.valueOf(index),examResults, knowledgeMap, appraise, points, res,gradeAndClassVos
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
// 获取该年级的平均得分
|
|
|
|
// 获取该年级的平均得分
|
|
|
@ -903,6 +932,7 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
schoolScores.put(nodeName, schoolScores.getOrDefault(nodeName, 0.0) + score);
|
|
|
|
schoolScores.put(nodeName, schoolScores.getOrDefault(nodeName, 0.0) + score);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 5. 计算全校的平均得分
|
|
|
|
// 5. 计算全校的平均得分
|
|
|
|