From edfa4ccd1d804717439d1f55dcff0c7b2f57044f Mon Sep 17 00:00:00 2001 From: weishengyou <2454197255@qq.com> Date: Tue, 2 Dec 2025 15:34:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E8=AF=84=E8=AF=AD=E9=89=B4?= =?UTF-8?q?=E5=AE=9A=E6=A8=A1=E5=9D=97-=E6=80=BB=E5=88=86=E7=AE=97?= =?UTF-8?q?=E6=B3=95=E8=B0=83=E6=95=B4=E4=BB=A5=E5=8F=8A=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E5=AD=A6=E5=B9=B4=E6=88=90=E7=BB=A9=E7=A9=BA?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/GraduateTextImpI.java | 112 +++++++++++++++++- .../mapper/comprehensive/SrsCqScoreMapper.xml | 4 +- 2 files changed, 111 insertions(+), 5 deletions(-) diff --git a/srs-comprehensive/src/main/java/com/srs/comprehensive/service/impl/GraduateTextImpI.java b/srs-comprehensive/src/main/java/com/srs/comprehensive/service/impl/GraduateTextImpI.java index 41cb760..648b0fd 100644 --- a/srs-comprehensive/src/main/java/com/srs/comprehensive/service/impl/GraduateTextImpI.java +++ b/srs-comprehensive/src/main/java/com/srs/comprehensive/service/impl/GraduateTextImpI.java @@ -77,7 +77,7 @@ public class GraduateTextImpI implements GraduateTextService { * @param graduateStudents 毕业生信息列表 * 邵政文 * 2025-07-02 - */ + *//* @Override public int addGraduateList(List graduateStudents) { int count = 0; @@ -93,7 +93,6 @@ public class GraduateTextImpI implements GraduateTextService { // 查询该学生已有的学年信息 List 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 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 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 毕业生信息列表 diff --git a/srs-comprehensive/src/main/resources/mapper/comprehensive/SrsCqScoreMapper.xml b/srs-comprehensive/src/main/resources/mapper/comprehensive/SrsCqScoreMapper.xml index a190929..7c07024 100644 --- a/srs-comprehensive/src/main/resources/mapper/comprehensive/SrsCqScoreMapper.xml +++ b/srs-comprehensive/src/main/resources/mapper/comprehensive/SrsCqScoreMapper.xml @@ -105,10 +105,10 @@