学生评语鉴定模块-总分算法调整以及修复第二学年成绩空数据问题
This commit is contained in:
@@ -77,7 +77,7 @@ public class GraduateTextImpI implements GraduateTextService {
|
||||
* @param graduateStudents 毕业生信息列表
|
||||
* 邵政文
|
||||
* 2025-07-02
|
||||
*/
|
||||
*//*
|
||||
@Override
|
||||
public int addGraduateList(List<GraduateStudentNews> graduateStudents) {
|
||||
int count = 0;
|
||||
@@ -93,7 +93,6 @@ public class GraduateTextImpI implements GraduateTextService {
|
||||
|
||||
// 查询该学生已有的学年信息
|
||||
List<Integer> existingYears = graduateTextMapper.selectStuYearByStudentCode(studentCode);
|
||||
|
||||
// 如果学年信息存在于集合中,则更新子表
|
||||
if (existingYears != null && existingYears.contains(student.getStuYear())) {
|
||||
int updateResult = graduateTextMapper.updateGraduateStudentByGraduateId(student);
|
||||
@@ -120,7 +119,7 @@ public class GraduateTextImpI implements GraduateTextService {
|
||||
if(ress != null) {
|
||||
student.setNation(ress.getMz());
|
||||
}
|
||||
double totalPoints = 0;
|
||||
double totalPoints = 0;//总分
|
||||
if (cphCollegeLook != null) {
|
||||
totalPoints += cphCollegeLook.getIamScore() != null ? Double.parseDouble(cphCollegeLook.getIamScore()) : 0;
|
||||
totalPoints += cphCollegeLook.getStuScore() != null ? Double.parseDouble(cphCollegeLook.getStuScore()) : 0;
|
||||
@@ -143,10 +142,117 @@ public class GraduateTextImpI implements GraduateTextService {
|
||||
count += insertResult;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* 添加毕业生信息
|
||||
* @param graduateStudents 毕业生信息列表
|
||||
* 邵政文
|
||||
* 2025-07-02
|
||||
*/
|
||||
@Override
|
||||
public int addGraduateList(List<GraduateStudentNews> graduateStudents) {
|
||||
int count = 0;
|
||||
for (GraduateStudentNews student : graduateStudents) {
|
||||
String studentCode = student.getStudentCode();
|
||||
// 根据学号查询是否已存在该学生信息
|
||||
GraduateStudentNews existingStudent = graduateTextMapper.selectByStudentCode(studentCode);
|
||||
|
||||
if (existingStudent != null) {
|
||||
// 存在,使用现有 id 作为 graduate_id
|
||||
Long graduateId = existingStudent.getId();
|
||||
student.setGraduateId(graduateId.intValue()); // 设置 graduate_id
|
||||
|
||||
// 查询该学生已有的学年信息
|
||||
List<Integer> existingYears = graduateTextMapper.selectStuYearByStudentCode(studentCode);
|
||||
|
||||
// 如果学年信息存在于集合中,则更新子表
|
||||
if (existingYears != null && existingYears.contains(student.getStuYear())) {
|
||||
|
||||
//查询该学生学年分数信息
|
||||
CphCollegeLook cphCollegeLook = graduateTextMapper.selectStudentFnByStuNOAndStuYear(student);
|
||||
// 更新各项成绩字段
|
||||
updateStudentScore(student, cphCollegeLook);
|
||||
|
||||
int updateResult = graduateTextMapper.updateGraduateStudentByGraduateId(student);
|
||||
count += updateResult;
|
||||
} else {
|
||||
// 否则插入子表
|
||||
|
||||
//查询该学生学年分数信息
|
||||
CphCollegeLook cphCollegeLook = graduateTextMapper.selectStudentFnByStuNOAndStuYear(student);
|
||||
// 更新各项成绩字段
|
||||
updateStudentScore(student, cphCollegeLook);
|
||||
|
||||
int insertResult = graduateTextMapper.insertGraduateStudent(student);
|
||||
count += insertResult;
|
||||
}
|
||||
} else {
|
||||
// 不存在,先插入主表 graduate_studentinfo
|
||||
// 查询该学生基本信息
|
||||
ViewStuInfo res = graduateTextMapper.selectStudentByStudentCode(student.getStudentCode());
|
||||
//查询该学生民族信息
|
||||
CphStuExtraInfo ress = graduateTextMapper.selectStudentMZByStudentCode(student.getStudentCode());
|
||||
//查询该学生学年分数信息
|
||||
CphCollegeLook cphCollegeLook = graduateTextMapper.selectStudentFnByStuNOAndStuYear(student);
|
||||
|
||||
student.setStudentCollege(res.getDeptName());
|
||||
student.setStudentGrade(res.getGradeName());
|
||||
student.setStudentClass(res.getClassName());
|
||||
student.setSex(res.getGender());
|
||||
student.setBirthData(res.getBirthday());
|
||||
if(ress != null) {
|
||||
student.setNation(ress.getMz());
|
||||
}
|
||||
|
||||
updateStudentScore(student,cphCollegeLook);
|
||||
|
||||
// 注意:由于 useGeneratedKeys=true,插入后会自动回填 id 到 student.id
|
||||
graduateTextMapper.inserts(student);
|
||||
|
||||
// 获取新生成的 id 并设置为 graduate_id
|
||||
Integer newGraduateId = student.getId().intValue();
|
||||
student.setGraduateId(newGraduateId);
|
||||
|
||||
// 插入子表 graduate_student
|
||||
int insertResult = graduateTextMapper.insertGraduateStudent(student);
|
||||
count += insertResult;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取毕业生成绩列表
|
||||
* @param student 毕业生信息
|
||||
* 邵政文
|
||||
* 2025-07-01
|
||||
*/
|
||||
private void updateStudentScore(GraduateStudentNews student, CphCollegeLook cphCollegeLook){
|
||||
Double totalPoints = null;//当综测成绩为空时,总分设为null而不是0,更符合实际情况
|
||||
if (cphCollegeLook != null) {
|
||||
//直接使用查询到学生学年分数信息中的综测成绩作为总分
|
||||
if (cphCollegeLook.getCphScore() != null && !cphCollegeLook.getCphScore().isEmpty()) {//综测成绩不为空
|
||||
try {
|
||||
totalPoints = Double.parseDouble(cphCollegeLook.getCphScore());//转换为double
|
||||
// 保留两位小数
|
||||
totalPoints = Math.round(totalPoints * 100.0) / 100.0;
|
||||
} catch (NumberFormatException e) {
|
||||
// 如果转换失败,保持totalPoints为null
|
||||
totalPoints = null;
|
||||
}
|
||||
}
|
||||
student.setLdeologicalPolitical(cphCollegeLook.getIamScore());
|
||||
student.setScientificQuality(cphCollegeLook.getStuScore());
|
||||
student.setPhysicalQuality(cphCollegeLook.getSportScore());
|
||||
}
|
||||
//设置总分,如果综测成绩为空则设为null
|
||||
student.setTotalPoints(totalPoints);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据ids批量查询毕业生信息
|
||||
* @return 毕业生信息列表
|
||||
|
||||
@@ -105,10 +105,10 @@
|
||||
</select>
|
||||
|
||||
<select id="rankDis" parameterType="CphSearch" resultType="com.srs.comprehensive.domain.Vo.DataScreen">
|
||||
select concat(t2.`name`,'-班级第',t2.class_rank,'名--专业第',t2.major_rank,"名") as `name`,
|
||||
select concat(t2.`name`,'-班级第',t2.class_rank,'名--专业第',t2.major_rank,'名') as `name`,
|
||||
t2.`value` from
|
||||
(select * from (
|
||||
select concat(c.class_name,"--",b.`name`) as `name` ,a.cph_score as `value`,
|
||||
select concat(c.class_name,'--',b.`name`) as `name` ,a.cph_score as `value`,
|
||||
RANK() OVER(PARTITION BY c.class_id,a.stu_year_id,c.grade_id ORDER BY a.cph_score DESC ) as class_rank,
|
||||
RANK() OVER(PARTITION BY c.major_id,a.stu_year_id,c.grade_id ORDER BY a.cph_score DESC ) as major_rank,
|
||||
c.class_id,
|
||||
|
||||
Reference in New Issue
Block a user