Explorar el Código

fix:优化数据处理

caozixuan hace 3 años
padre
commit
6e9b2a01c2

+ 3 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/contant/SystemConstant.java

@@ -68,6 +68,9 @@ public class SystemConstant {
     public static final int OPER_SCALE = 8;
     public static final String HYPHEN = "-";
     public static final String DEFAULT_SIGN = "#";
+    public static final String COMMA_OF_ENGLISH = ",";
+    public static final String COMMA_OF_CHINESE = ",";
+    public static final String PAUSE_SIGN = "、";
     public static final String PARENT_ORG = "武汉大学教务处";
     public static final String SCHOOL_CODE = "ggjckcjfx";
 //    public static final int MAX_RETRY_CREATE_PDF_COUNT = 5;

+ 12 - 5
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/BasicCourseServiceImpl.java

@@ -14,6 +14,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.util.List;
+import java.util.Objects;
 
 /**
  * <p>
@@ -85,16 +86,22 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
     public void createCourse(Long schoolId, String courseCode, String courseName) {
         // 向'basic_course'表新增数据
         List<BasicCourse> basicCourseList = this.list(new QueryWrapper<BasicCourse>().lambda()
-                .eq(BasicCourse::getSchoolId,schoolId).eq(BasicCourse::getCode,courseCode));
+                .eq(BasicCourse::getSchoolId, schoolId).eq(BasicCourse::getCode, courseCode));
+        if (basicCourseList.size() > 1) {
+            throw ExceptionResultEnum.ERROR.exception("学校id为【" + schoolId + "】,课程编号为【" + courseCode + "】的课程在 'basic_course' 表中存在多条异常");
+        }
+        // 课程
+        Long id;
         if (basicCourseList.size() > 0){
-            return;
-//            throw ExceptionResultEnum.ERROR.exception("已存在学校id为【" + schoolId + "】,课程编号为【" + courseCode + "】的课程");
+            id = basicCourseList.get(0).getId();
+        }else {
+            id = SystemConstant.getDbUuid();
         }
         BasicCourse basicCourse = new BasicCourse();
-        basicCourse.setId(SystemConstant.getDbUuid());
+        basicCourse.setId(id);
         basicCourse.setCode(courseCode);
         basicCourse.setName(courseName);
         basicCourse.setSchoolId(schoolId);
-        this.save(basicCourse);
+        this.saveOrUpdate(basicCourse);
     }
 }

+ 2 - 2
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/AnalyzeForReportService.java

@@ -203,8 +203,8 @@ public interface AnalyzeForReportService {
     /**
      * 计算前的准备工作 1.计算中状态报错 2.把其他状态改为计算中
      *
-     * @param examId
-     * @param courseCode
+     * @param examId 考试id
+     * @param courseCode 科目编号
      */
     void realityForCalculate(Long examId, String courseCode);
 

+ 98 - 106
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/AnalyzeForReportServiceImpl.java

@@ -27,6 +27,7 @@ import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -135,13 +136,13 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
             // 满分
             BigDecimal totalScore = tbPaper.getTotalScore();
             // 赋分系数
-            String coefficient = "";
+            String coefficient;
             BigDecimal paperCoefficient = tbPaper.getCoefficient();
             paperCoefficient = paperCoefficient.stripTrailingZeros();
             AssignEnum assignEnum = tbPaper.getScoreType();
-            if (AssignEnum.SPECIAL_ASSIGN_SCORE.equals(assignEnum)){
+            if (AssignEnum.SPECIAL_ASSIGN_SCORE.equals(assignEnum)) {
                 coefficient = SystemConstant.DEFAULT_SIGN;
-            }else {
+            } else {
                 coefficient = paperCoefficient.toPlainString();
             }
 
@@ -163,14 +164,14 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
             DoubleSummaryStatistics totalStatistics = totalScoreList.stream().collect(Collectors.summarizingDouble(e -> e));
             double avgScore = totalStatistics.getAverage();
             long passCount = totalScoreList.stream().filter(e -> e >= passScore.doubleValue()).count();
-            BigDecimal passRate = BigDecimal.valueOf(passCount).divide(BigDecimal.valueOf(realityCount), 4, BigDecimal.ROUND_HALF_UP);
+            BigDecimal passRate = BigDecimal.valueOf(passCount).divide(BigDecimal.valueOf(realityCount), 4, RoundingMode.HALF_UP);
 
             // -------------------卷面分------------------------
             List<Double> paperTotalScoreList = totalDatasource.stream().filter(e -> !e.getAbsent()).map(e -> e.getTotalScore().doubleValue()).collect(Collectors.toList());
             DoubleSummaryStatistics paperTotalStatistics = paperTotalScoreList.stream().collect(Collectors.summarizingDouble(e -> e));
             double paperAvgScore = paperTotalStatistics.getAverage();
             long paperPassCount = paperTotalScoreList.stream().filter(e -> e >= passScore.doubleValue()).count();
-            BigDecimal paperPassRate = BigDecimal.valueOf(paperPassCount).divide(BigDecimal.valueOf(realityCount), 4, BigDecimal.ROUND_HALF_UP);
+            BigDecimal paperPassRate = BigDecimal.valueOf(paperPassCount).divide(BigDecimal.valueOf(realityCount), 4, RoundingMode.HALF_UP);
 
 
 
@@ -186,7 +187,7 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
             if (pastTotalCount != pastRealityCount + pastAbsentCount) {
                 throw ExceptionResultEnum.ERROR.exception("考试往届生人数数据异常");
             }
-            BigDecimal pastRealityRate = BigDecimal.valueOf(pastRealityCount).divide(BigDecimal.valueOf(realityCount), 4, BigDecimal.ROUND_HALF_UP);
+            BigDecimal pastRealityRate = BigDecimal.valueOf(pastRealityCount).divide(BigDecimal.valueOf(realityCount), 4, RoundingMode.HALF_UP);
 
             /*
                 该课程应届生成绩分析
@@ -201,13 +202,13 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
             if (currentTotalCount != currentRealityCount + currentAbsentCount) {
                 throw ExceptionResultEnum.ERROR.exception("考试应届生人数数据异常");
             }
-            BigDecimal currentRealityRate = BigDecimal.valueOf(currentRealityCount).divide(BigDecimal.valueOf(realityCount), 4, BigDecimal.ROUND_HALF_UP);
+            BigDecimal currentRealityRate = BigDecimal.valueOf(currentRealityCount).divide(BigDecimal.valueOf(realityCount), 4, RoundingMode.HALF_UP);
 
             // 通过率统计
             List<Double> currentScoreList = currentDatasource.stream().filter(e -> !e.getAbsent()).map(e -> e.getAssignedScore().doubleValue()).collect(Collectors.toList());
             DoubleSummaryStatistics currentStatistics = currentScoreList.stream().collect(Collectors.summarizingDouble(e -> e));
             long currentPassCount = currentScoreList.stream().filter(e -> e >= passScore.doubleValue()).count();
-            BigDecimal currentPassRate = BigDecimal.valueOf(currentPassCount).divide(BigDecimal.valueOf(currentRealityCount), 4, BigDecimal.ROUND_HALF_UP);
+            BigDecimal currentPassRate = BigDecimal.valueOf(currentPassCount).divide(BigDecimal.valueOf(currentRealityCount), 4, RoundingMode.HALF_UP);
 
             // 描述统计
             double currentMinScore = currentStatistics.getMin();
@@ -236,19 +237,19 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
             BigDecimal scoreRate;
             double standardAvgScore = currentDatasource.stream().collect(Collectors.summarizingDouble(e -> e.getTotalScore().doubleValue())).getAverage();
             if (standardAvgScore != 0 && totalScore.compareTo(BigDecimal.ZERO) > 0) {
-                scoreRate = BigDecimal.valueOf(standardAvgScore).divide(totalScore, 4, BigDecimal.ROUND_HALF_UP);
+                scoreRate = BigDecimal.valueOf(standardAvgScore).divide(totalScore, 4, RoundingMode.HALF_UP);
             } else {
                 scoreRate = BigDecimal.ZERO;
             }
             // 难度系数保留1位数
-            scoreRate = scoreRate.setScale(1, BigDecimal.ROUND_HALF_UP); // 难度系数保留1位有效数字
+            scoreRate = scoreRate.setScale(1, RoundingMode.HALF_UP); // 难度系数保留1位有效数字
             String difficulty = this.handleLevel(examId, effectiveCourseCode, "难度等级", scoreRate.doubleValue());
             //--------------------------应届-卷面成绩-----------------------
             List<Double> paperCurrentScoreList = currentDatasource.stream().filter(e -> !e.getAbsent()).map(e -> e.getTotalScore().doubleValue()).collect(Collectors.toList());
             DoubleSummaryStatistics paperCurrentStatistics = paperCurrentScoreList.stream().collect(Collectors.summarizingDouble(e -> e));
             double paperCurrentAvgScore = paperCurrentStatistics.getAverage();
             long paperCurrentPassCount = paperCurrentScoreList.stream().filter(e -> e >= passScore.doubleValue()).count();
-            BigDecimal paperCurrentPassRate = BigDecimal.valueOf(paperCurrentPassCount).divide(BigDecimal.valueOf(currentRealityCount), 4, BigDecimal.ROUND_HALF_UP);
+            BigDecimal paperCurrentPassRate = BigDecimal.valueOf(paperCurrentPassCount).divide(BigDecimal.valueOf(currentRealityCount), 4, RoundingMode.HALF_UP);
 
             /*
                 学院信息
@@ -270,11 +271,11 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                 teachCollegeName = tbSchoolCollege.getName();
             }
             int inspectCollegeCount = inspectCollegeIdList.size();
-            if (inspectCollegeIdList.size() == 0){
+            if (inspectCollegeIdList.size() == 0) {
                 throw ExceptionResultEnum.ERROR.exception("没有考察学院");
             }
             List<SysOrg> sysOrgList = sysOrgService.listByIds(inspectCollegeIdList);
-            String inspectCollegeNames = StringUtils.join(sysOrgList.stream().map(SysOrg::getName).collect(Collectors.toList()),'、');
+            String inspectCollegeNames = StringUtils.join(sysOrgList.stream().map(SysOrg::getName).collect(Collectors.toList()), '、');
 
 
             /*
@@ -361,10 +362,10 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                 long sameCount = dataSource.stream().filter(e -> e.getTotalScore().compareTo(totalScore) == 0).count(); // 和我相同的人数
                 int totalCount = dataSource.size(); //总人数
                 // 标准回归系数
-                if (standardDeviation.compareTo(BigDecimal.ZERO) == 0){
+                if (standardDeviation.compareTo(BigDecimal.ZERO) == 0) {
                     standardDeviation = BigDecimal.valueOf(0.001);
                 }
-                BigDecimal standardizedCoefficients = (taExamCourseRecord.getAssignedScore().subtract(avgScore)).divide(standardDeviation, 4, BigDecimal.ROUND_HALF_UP);
+                BigDecimal standardizedCoefficients = (taExamCourseRecord.getAssignedScore().subtract(avgScore)).divide(standardDeviation, 4, RoundingMode.HALF_UP);
 
                 int percentGrade = this.handlePercentGrade(BigDecimal.valueOf(lowCount), BigDecimal.valueOf(sameCount), BigDecimal.valueOf(totalCount));
                 taExamCourseRecord.setPercentGrade(percentGrade);
@@ -509,16 +510,16 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                         .eq(TBExamStudent::getCourseCode, effectiveCourseCode)
                         .eq(TBExamStudent::getClazzId, clazzId));
                 List<Long> teachCollegeIdList = tbExamStudentList.stream().map(TBExamStudent::getTeachCollegeId).distinct().collect(Collectors.toList());
-                String collegeName = "";
+                StringBuilder collegeName = new StringBuilder();
                 for (Long collegeId : teachCollegeIdList) {
                     SysOrg tbSchoolCollege = sysOrgService.getById(collegeId);
                     if (Objects.isNull(tbSchoolCollege)) {
-                        collegeName = collegeName + SystemConstant.DEFAULT_SIGN + ",";
+                        collegeName.append(SystemConstant.DEFAULT_SIGN).append(",");
                     } else {
-                        collegeName = collegeName + tbSchoolCollege.getName() + ",";
+                        collegeName.append(tbSchoolCollege.getName()).append(",");
                     }
                 }
-                collegeName = collegeName.substring(0, collegeName.length() - 1);
+                collegeName = new StringBuilder(collegeName.substring(0, collegeName.length() - 1));
 
                 TAExamCourseClazz taExamCourseClazz = new TAExamCourseClazz();
                 taExamCourseClazz.setId(SystemConstant.getDbUuid());
@@ -533,7 +534,7 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                 taExamCourseClazz.setRealityCount(realityCount);
                 taExamCourseClazz.setAbsentCount(absentCount);
                 taExamCourseClazz.setTotalCount(totalCount);
-                taExamCourseClazz.setCollegeName(collegeName);
+                taExamCourseClazz.setCollegeName(collegeName.toString());
                 taExamCourseClazzList.add(taExamCourseClazz);
             }
         }
@@ -586,7 +587,6 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                 throw ExceptionResultEnum.ERROR.exception("试卷基础数据查找失败");
             }
             for (TBPaper tbPaper : tbPaperList) {
-                String paperType = tbPaper.getPaperType();
                 Long paperId = tbPaper.getId();
                 // 试卷结构数据源
                 List<TBPaperStruct> tbPaperStructList = tbPaperStructService.list(new QueryWrapper<TBPaperStruct>().lambda()
@@ -851,8 +851,8 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
         for (String effectiveCourseCode : effectiveCourseCodeList) {
             // 删除原有数据
             taExamCourseTeacherDioService.remove(new QueryWrapper<TAExamCourseTeacherDio>().lambda()
-                    .eq(TAExamCourseTeacherDio::getExamId,examId)
-                    .eq(TAExamCourseTeacherDio::getCourseCode,effectiveCourseCode));
+                    .eq(TAExamCourseTeacherDio::getExamId, examId)
+                    .eq(TAExamCourseTeacherDio::getCourseCode, effectiveCourseCode));
 
             taExamCourseTeacherDioService.insertByTAExamCourseRecordDio(examId, effectiveCourseCode);
         }
@@ -867,8 +867,8 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
         for (String effectiveCourseCode : effectiveCourseCodeList) {
             // 删除原有数据
             taExamCourseTeacherCollegeDioService.remove(new QueryWrapper<TAExamCourseTeacherCollegeDio>().lambda()
-                    .eq(TAExamCourseTeacherCollegeDio::getExamId,examId)
-                    .eq(TAExamCourseTeacherCollegeDio::getCourseCode,effectiveCourseCode));
+                    .eq(TAExamCourseTeacherCollegeDio::getExamId, examId)
+                    .eq(TAExamCourseTeacherCollegeDio::getCourseCode, effectiveCourseCode));
 
             taExamCourseTeacherCollegeDioService.insertByTAExamCourseRecordDio(examId, effectiveCourseCode);
         }
@@ -911,14 +911,14 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                                     numberType.equals(e.getNumberType()) &&
                                     mainNumber.equals(e.getMainNumber()) &&
                                     subNumber.equals(e.getSubNumber())).collect(Collectors.toList()); //某道小题的所有参考学生作答信息(并且按照该科目的参考学生百分等级从高到低排序了)
-                    if (oneQuestionAnswerDetailList.size() == 0){
+                    if (oneQuestionAnswerDetailList.size() == 0) {
                         System.out.println("异常");
                     }
                     BigDecimal fullScore = paperStruct.getFullScore();
                     PaperStructJudgeEnum paperStructJudgeEnum;
-                    if (oneQuestionAnswerDetailList.stream().anyMatch(e -> fullScore.compareTo(e.getScore()) != 0)){
+                    if (oneQuestionAnswerDetailList.stream().anyMatch(e -> fullScore.compareTo(e.getScore()) != 0)) {
                         paperStructJudgeEnum = PaperStructJudgeEnum.NOT_QUITE_RIGHT;
-                    }else {
+                    } else {
                         paperStructJudgeEnum = PaperStructJudgeEnum.ALL_CORRECT;
                     }
 
@@ -926,8 +926,8 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                             .collect(Collectors.summarizingDouble(e -> e.getScore().doubleValue()));
 
                     double scoreAvg = descriptiveStatistics.getAverage();
-                    BigDecimal standardScoreRate = BigDecimal.valueOf(scoreAvg).divide(fullScore, 4, BigDecimal.ROUND_HALF_UP);
-                    BigDecimal scoreRate = standardScoreRate.setScale(1, BigDecimal.ROUND_HALF_UP);
+                    BigDecimal standardScoreRate = BigDecimal.valueOf(scoreAvg).divide(fullScore, 4, RoundingMode.HALF_UP);
+                    BigDecimal scoreRate = standardScoreRate.setScale(1, RoundingMode.HALF_UP);
                     String difficult = this.analyzeDifficult(examId, effectiveCourseCode, scoreRate.doubleValue());
 
                     double validity = this.calculateValidity(oneQuestionAnswerDetailList, fullScore.doubleValue());
@@ -1011,14 +1011,14 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                                         numberType.equals(e.getNumberType()) &&
                                         mainNumber.equals(e.getMainNumber()) &&
                                         subNumber.equals(e.getSubNumber())).collect(Collectors.toList()); //某学院某道小题的所有参考学生作答信息(并且按照该科目的参考学生百分等级从高到低排序了)
-                        if (oneQuestionAnswerDetailList.size() == 0){
+                        if (oneQuestionAnswerDetailList.size() == 0) {
                             System.out.println("异常");
                         }
                         BigDecimal fullScore = paperStruct.getFullScore();
                         PaperStructJudgeEnum paperStructJudgeEnum;
-                        if (oneQuestionAnswerDetailList.stream().anyMatch(e -> fullScore.compareTo(e.getScore()) != 0)){
+                        if (oneQuestionAnswerDetailList.stream().anyMatch(e -> fullScore.compareTo(e.getScore()) != 0)) {
                             paperStructJudgeEnum = PaperStructJudgeEnum.NOT_QUITE_RIGHT;
-                        }else {
+                        } else {
                             paperStructJudgeEnum = PaperStructJudgeEnum.ALL_CORRECT;
                         }
 
@@ -1026,8 +1026,8 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                                 .collect(Collectors.summarizingDouble(e -> e.getScore().doubleValue()));
 
                         double scoreAvg = descriptiveStatistics.getAverage();
-                        BigDecimal standardScoreRate = BigDecimal.valueOf(scoreAvg).divide(fullScore, 4, BigDecimal.ROUND_HALF_UP);
-                        BigDecimal scoreRate = standardScoreRate.setScale(1, BigDecimal.ROUND_HALF_UP);
+                        BigDecimal standardScoreRate = BigDecimal.valueOf(scoreAvg).divide(fullScore, 4, RoundingMode.HALF_UP);
+                        BigDecimal scoreRate = standardScoreRate.setScale(1, RoundingMode.HALF_UP);
                         String difficult = this.analyzeDifficult(examId, effectiveCourseCode, scoreRate.doubleValue());
 
                         TAExamCourseCollegePaperStruct taExamCourseCollegePaperStruct = new TAExamCourseCollegePaperStruct();
@@ -1112,14 +1112,14 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                                         numberType.equals(e.getNumberType()) &&
                                         mainNumber.equals(e.getMainNumber()) &&
                                         subNumber.equals(e.getSubNumber())).collect(Collectors.toList()); //某教师某道小题的所有参考学生作答信息(并且按照该科目的参考学生百分等级从高到低排序了)
-                        if (oneQuestionAnswerDetailList.size() == 0){
+                        if (oneQuestionAnswerDetailList.size() == 0) {
                             System.out.println("异常");
                         }
                         BigDecimal fullScore = paperStruct.getFullScore();
                         PaperStructJudgeEnum paperStructJudgeEnum;
-                        if (oneQuestionAnswerDetailList.stream().anyMatch(e -> fullScore.compareTo(e.getScore()) != 0)){
+                        if (oneQuestionAnswerDetailList.stream().anyMatch(e -> fullScore.compareTo(e.getScore()) != 0)) {
                             paperStructJudgeEnum = PaperStructJudgeEnum.NOT_QUITE_RIGHT;
-                        }else {
+                        } else {
                             paperStructJudgeEnum = PaperStructJudgeEnum.ALL_CORRECT;
                         }
 
@@ -1127,8 +1127,8 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                                 .collect(Collectors.summarizingDouble(e -> e.getScore().doubleValue()));
 
                         double scoreAvg = descriptiveStatistics.getAverage();
-                        BigDecimal standardScoreRate = BigDecimal.valueOf(scoreAvg).divide(fullScore, 4, BigDecimal.ROUND_HALF_UP);
-                        BigDecimal scoreRate = standardScoreRate.setScale(1, BigDecimal.ROUND_HALF_UP);
+                        BigDecimal standardScoreRate = BigDecimal.valueOf(scoreAvg).divide(fullScore, 4, RoundingMode.HALF_UP);
+                        BigDecimal scoreRate = standardScoreRate.setScale(1, RoundingMode.HALF_UP);
                         String difficult = this.analyzeDifficult(examId, effectiveCourseCode, scoreRate.doubleValue());
 
                         TAExamCourseTeacherPaperStruct taExamCourseTeacherPaperStruct = new TAExamCourseTeacherPaperStruct();
@@ -1200,13 +1200,9 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                 if (tbPaperStructList.size() == 0) {
                     throw ExceptionResultEnum.ERROR.exception("试卷结构数据异常");
                 }
-                /**
-                 * 试卷下
-                 */
+                // 试卷下
                 for (Long teacherId : teacherIdSet) {
-                    /**
-                     * 教师下
-                     */
+                    // 教师下
                     String teacherName = sysUserService.getById(teacherId).getRealName();
 
                     // 参考该试卷的考察学院id集合
@@ -1217,15 +1213,11 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                             .collect(Collectors.toSet());
 
                     for (Long inspectCollegeId : inspectCollegeIdSet) {
-                        /**
-                         * 学院下
-                         */
+                        // 学院下
                         String inspectCollegeName = sysOrgService.getById(inspectCollegeId).getName();
 
                         for (TBPaperStruct paperStruct : tbPaperStructList) {
-                            /**
-                             * 试题下
-                             */
+                            // 试题下
                             String numberType = paperStruct.getNumberType();
                             String mainNumber = paperStruct.getBigQuestionNumber();
                             String subNumber = paperStruct.getSmallQuestionNumber();
@@ -1237,14 +1229,14 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                                             numberType.equals(e.getNumberType()) &&
                                             mainNumber.equals(e.getMainNumber()) &&
                                             subNumber.equals(e.getSubNumber())).collect(Collectors.toList()); //某教师某道小题的所有参考学生作答信息(并且按照该科目的参考学生百分等级从高到低排序了)
-                            if (oneQuestionAnswerDetailList.size() == 0){
+                            if (oneQuestionAnswerDetailList.size() == 0) {
                                 System.out.println("异常");
                             }
                             BigDecimal fullScore = paperStruct.getFullScore();
                             PaperStructJudgeEnum paperStructJudgeEnum;
-                            if (oneQuestionAnswerDetailList.stream().anyMatch(e -> fullScore.compareTo(e.getScore()) != 0)){
+                            if (oneQuestionAnswerDetailList.stream().anyMatch(e -> fullScore.compareTo(e.getScore()) != 0)) {
                                 paperStructJudgeEnum = PaperStructJudgeEnum.NOT_QUITE_RIGHT;
-                            }else {
+                            } else {
                                 paperStructJudgeEnum = PaperStructJudgeEnum.ALL_CORRECT;
                             }
 
@@ -1252,8 +1244,8 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                                     .collect(Collectors.summarizingDouble(e -> e.getScore().doubleValue()));
 
                             double scoreAvg = descriptiveStatistics.getAverage();
-                            BigDecimal standardScoreRate = BigDecimal.valueOf(scoreAvg).divide(fullScore, 4, BigDecimal.ROUND_HALF_UP);
-                            BigDecimal scoreRate = standardScoreRate.setScale(1, BigDecimal.ROUND_HALF_UP);
+                            BigDecimal standardScoreRate = BigDecimal.valueOf(scoreAvg).divide(fullScore, 4, RoundingMode.HALF_UP);
+                            BigDecimal scoreRate = standardScoreRate.setScale(1, RoundingMode.HALF_UP);
                             String difficult = this.analyzeDifficult(examId, effectiveCourseCode, scoreRate.doubleValue());
 
                             TAExamCourseTeacherCollegePaperStruct taExamCourseTeacherCollegePaperStruct = new TAExamCourseTeacherCollegePaperStruct();
@@ -1312,7 +1304,7 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
             List<TBCommonLevelConfig> configLevelDatasource = tbCommonLevelConfigService.list(new QueryWrapper<TBCommonLevelConfig>().lambda()
                     .eq(TBCommonLevelConfig::getExamId, examId)
                     .eq(TBCommonLevelConfig::getCourseCode, effectiveCourseCode)
-                    .eq(TBCommonLevelConfig::getLevelType,"难度等级"));// 该科目试题难度情况数据源
+                    .eq(TBCommonLevelConfig::getLevelType, "难度等级"));// 该科目试题难度情况数据源
 
             List<TAPaperStruct> questionDatasource = taPaperStructService.list(new QueryWrapper<TAPaperStruct>().lambda()
                     .eq(TAPaperStruct::getExamId, examId).eq(TAPaperStruct::getCourseCode, effectiveCourseCode));// 该科目试题情况数据源
@@ -1340,11 +1332,11 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
 
                     // 学院id集合
                     List<Long> collegeIdList = taExamCourseRecordService.list(new QueryWrapper<TAExamCourseRecord>().lambda()
-                            .eq(TAExamCourseRecord::getExamId, examId)
-                            .eq(TAExamCourseRecord::getCourseCode, effectiveCourseCode)
-                            .eq(TAExamCourseRecord::getPaperId, paperId)
-                            .eq(TAExamCourseRecord::getAbsent, false)
-                            .eq(TAExamCourseRecord::getStudentCurrent, true))
+                                    .eq(TAExamCourseRecord::getExamId, examId)
+                                    .eq(TAExamCourseRecord::getCourseCode, effectiveCourseCode)
+                                    .eq(TAExamCourseRecord::getPaperId, paperId)
+                                    .eq(TAExamCourseRecord::getAbsent, false)
+                                    .eq(TAExamCourseRecord::getStudentCurrent, true))
                             .stream()
                             .map(TAExamCourseRecord::getInspectCollegeId).distinct()
                             .collect(Collectors.toList());
@@ -1354,7 +1346,7 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                                 .filter(e -> collegeId.equals(e.getCollegeId())).collect(Collectors.toList());
 
                         double colAvgScoreRate = 0;
-                        if (answerDetailForCol.size() > 0){
+                        if (answerDetailForCol.size() > 0) {
                             colAvgScoreRate = answerDetailForCol.stream().collect(Collectors.summarizingDouble(e -> e.getAnswerScore().doubleValue())).getSum() / answerDetailForCol.stream().collect(Collectors.summarizingDouble(e -> e.getFullScore().doubleValue())).getSum();
                         }
                         // 得分率保留2位小数处理
@@ -1430,11 +1422,11 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
 
                     // 教师id集合
                     List<Long> teacherIdList = taExamCourseRecordService.list(new QueryWrapper<TAExamCourseRecord>().lambda()
-                            .eq(TAExamCourseRecord::getExamId, examId)
-                            .eq(TAExamCourseRecord::getCourseCode, effectiveCourseCode)
-                            .eq(TAExamCourseRecord::getPaperId, paperId)
-                            .eq(TAExamCourseRecord::getAbsent, false)
-                            .eq(TAExamCourseRecord::getStudentCurrent, true))
+                                    .eq(TAExamCourseRecord::getExamId, examId)
+                                    .eq(TAExamCourseRecord::getCourseCode, effectiveCourseCode)
+                                    .eq(TAExamCourseRecord::getPaperId, paperId)
+                                    .eq(TAExamCourseRecord::getAbsent, false)
+                                    .eq(TAExamCourseRecord::getStudentCurrent, true))
                             .stream()
                             .map(TAExamCourseRecord::getTeacherId).distinct()
                             .collect(Collectors.toList());
@@ -1512,11 +1504,11 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
 
                     // 学院id集合
                     List<Long> collegeIdList = taExamCourseRecordService.list(new QueryWrapper<TAExamCourseRecord>().lambda()
-                            .eq(TAExamCourseRecord::getExamId, examId)
-                            .eq(TAExamCourseRecord::getCourseCode, effectiveCourseCode)
-                            .eq(TAExamCourseRecord::getPaperId, paperId)
-                            .eq(TAExamCourseRecord::getAbsent, false)
-                            .eq(TAExamCourseRecord::getStudentCurrent, true))
+                                    .eq(TAExamCourseRecord::getExamId, examId)
+                                    .eq(TAExamCourseRecord::getCourseCode, effectiveCourseCode)
+                                    .eq(TAExamCourseRecord::getPaperId, paperId)
+                                    .eq(TAExamCourseRecord::getAbsent, false)
+                                    .eq(TAExamCourseRecord::getStudentCurrent, true))
                             .stream()
                             .map(TAExamCourseRecord::getInspectCollegeId).distinct()
                             .collect(Collectors.toList());
@@ -1538,18 +1530,18 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                                 .filter(e -> collegeId.equals(e.getCollegeId())).collect(Collectors.toList());
 
                         double colAvgScoreRate = 0;
-                        if (answerDetailForCol.size() > 0){
+                        if (answerDetailForCol.size() > 0) {
                             colAvgScoreRate = answerDetailForCol.stream().collect(Collectors.summarizingDouble(e -> e.getAnswerScore().doubleValue())).getSum() / answerDetailForCol.stream().collect(Collectors.summarizingDouble(e -> e.getFullScore().doubleValue())).getSum();
                         }
 
                         // 教师id集合
                         List<Long> teacherIdList = taExamCourseRecordService.list(new QueryWrapper<TAExamCourseRecord>().lambda()
-                                .eq(TAExamCourseRecord::getExamId, examId)
-                                .eq(TAExamCourseRecord::getCourseCode, effectiveCourseCode)
-                                .eq(TAExamCourseRecord::getPaperId, paperId)
-                                .eq(TAExamCourseRecord::getInspectCollegeId,collegeId)
-                                .eq(TAExamCourseRecord::getAbsent, false)
-                                .eq(TAExamCourseRecord::getStudentCurrent, true))
+                                        .eq(TAExamCourseRecord::getExamId, examId)
+                                        .eq(TAExamCourseRecord::getCourseCode, effectiveCourseCode)
+                                        .eq(TAExamCourseRecord::getPaperId, paperId)
+                                        .eq(TAExamCourseRecord::getInspectCollegeId, collegeId)
+                                        .eq(TAExamCourseRecord::getAbsent, false)
+                                        .eq(TAExamCourseRecord::getStudentCurrent, true))
                                 .stream()
                                 .map(TAExamCourseRecord::getTeacherId).distinct()
                                 .collect(Collectors.toList());
@@ -1613,14 +1605,14 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                 .map(TAExamCourseRecord::getInspectCollegeId).distinct().collect(Collectors.toList());
         // 考查学院数量
         int collegeCount = inspectCollegeInfo.size();
-        String inspectCollegeNames = "";
+        StringBuilder inspectCollegeNames = new StringBuilder();
         if (collegeCount > 0) {
             for (Long inspectCollegeId : inspectCollegeInfo) {
                 SysOrg college = sysOrgService.getById(inspectCollegeId);
-                inspectCollegeNames = inspectCollegeNames + college.getName() + "、";
+                inspectCollegeNames.append(college.getName()).append("、");
             }
             // 考查学院名称
-            inspectCollegeNames = inspectCollegeNames.substring(0, inspectCollegeNames.length() - 1);
+            inspectCollegeNames = new StringBuilder(inspectCollegeNames.substring(0, inspectCollegeNames.length() - 1));
         }
 
         // 课程
@@ -1654,7 +1646,7 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
         taExamTotal.setExamId(examId);
         taExamTotal.setSchoolId(tbExamService.getById(examId).getSchoolId());
         taExamTotal.setCollegeCount(collegeCount);
-        taExamTotal.setCollegeNames(inspectCollegeNames);
+        taExamTotal.setCollegeNames(inspectCollegeNames.toString());
         taExamTotal.setCourseCount(courseCount);
         taExamTotal.setPublicCourseCount(courseCount);
         taExamTotal.setMajorCourseCount(0);
@@ -1849,7 +1841,7 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                 // 计算教师排名
                 for (TAExamCourseCollegeTeacher taExamCourseCollegeTeacher : rankTempList) {
                     BigDecimal thisAvgScoreAssign = taExamCourseCollegeTeacher.getAvgScoreAssign();
-                    int rank = (int) (rankTempList.stream().filter(e -> (e.getAvgScoreAssign().setScale(SystemConstant.FINAL_SCALE,BigDecimal.ROUND_HALF_UP)).compareTo(thisAvgScoreAssign.setScale(SystemConstant.FINAL_SCALE,BigDecimal.ROUND_HALF_UP)) > 0).count() + 1);
+                    int rank = (int) (rankTempList.stream().filter(e -> (e.getAvgScoreAssign().setScale(SystemConstant.FINAL_SCALE, RoundingMode.HALF_UP)).compareTo(thisAvgScoreAssign.setScale(SystemConstant.FINAL_SCALE, RoundingMode.HALF_UP)) > 0).count() + 1);
                     taExamCourseCollegeTeacher.setTeacherRank(rank);
                     taExamCourseCollegeTeacherList.add(taExamCourseCollegeTeacher);
                 }
@@ -1947,7 +1939,7 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
 
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public String updateCoursePublishStatus(Long examId, String courseCode,PublishStatusEnum publishStatusEnum ) {
+    public String updateCoursePublishStatus(Long examId, String courseCode, PublishStatusEnum publishStatusEnum) {
         // 可分析有效课程信息
         List<String> effectiveCourseCodeList = tbExamCourseService.findEffectiveByExamId(examId, courseCode);
         List<TBExamCourse> tbExamCourseList = new ArrayList<>();
@@ -1964,9 +1956,9 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
 
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public void dataCalculate(Long examId,String courseCode) throws Exception {
+    public void dataCalculate(Long examId, String courseCode) throws Exception {
         AnalyzeForReportService analyzeForReportService = SpringContextHolder.getBean(AnalyzeForReportService.class);
-        analyzeForReportService.buildAnalyzeExamCourse(examId,courseCode);
+        analyzeForReportService.buildAnalyzeExamCourse(examId, courseCode);
         analyzeForReportService.buildAnalyzeExamCourseRecord(examId, courseCode);
         analyzeForReportService.buildAnalyzeExamCourseCollegeInspect(examId, courseCode);
         analyzeForReportService.buildAnalyzeExamCourseClazz(examId, courseCode);
@@ -1989,29 +1981,29 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
     @Override
     public void realityForCalculate(Long examId, String courseCode) {
         this.verifyComputing(examId, courseCode);
-        this.updateCoursePublishStatus(examId, courseCode,PublishStatusEnum.COMPUTING);
+        this.updateCoursePublishStatus(examId, courseCode, PublishStatusEnum.COMPUTING);
     }
 
     @Override
     public void publishReport(Long examId, String courseCode, PublishStatusEnum publishStatusEnum) {
         TBExamCourse tbExamCourse = tbExamCourseService.getOne(new QueryWrapper<TBExamCourse>().lambda()
-                .eq(TBExamCourse::getExamId,examId)
-                .eq(TBExamCourse::getCourseCode,courseCode));
+                .eq(TBExamCourse::getExamId, examId)
+                .eq(TBExamCourse::getCourseCode, courseCode));
         PublishStatusEnum status = tbExamCourse.getPublishStatus();
-        if (publishStatusEnum.equals(PublishStatusEnum.PUBLISH) && status.equals(PublishStatusEnum.UN_PUBLISH)){
+        if (publishStatusEnum.equals(PublishStatusEnum.PUBLISH) && status.equals(PublishStatusEnum.UN_PUBLISH)) {
             // 待发布状态 -》 发布
             tbExamCourse.setPublishStatus(publishStatusEnum);
-        }else if (publishStatusEnum.equals(PublishStatusEnum.UN_PUBLISH) && status.equals(PublishStatusEnum.PUBLISH)){
+        } else if (publishStatusEnum.equals(PublishStatusEnum.UN_PUBLISH) && status.equals(PublishStatusEnum.PUBLISH)) {
             // 发布状态 -》 撤回
             tbExamCourse.setPublishStatus(publishStatusEnum);
-        }else {
+        } else {
             String statusDesc = "未明确的操作";
-            if (publishStatusEnum.equals(PublishStatusEnum.PUBLISH)){
+            if (publishStatusEnum.equals(PublishStatusEnum.PUBLISH)) {
                 statusDesc = "发布";
-            }else if (publishStatusEnum.equals(PublishStatusEnum.UN_PUBLISH)){
+            } else if (publishStatusEnum.equals(PublishStatusEnum.UN_PUBLISH)) {
                 statusDesc = "撤回";
             }
-            throw ExceptionResultEnum.ERROR.exception("【" + status + "】状态的课程无法进行" + "【" + statusDesc + "】" );
+            throw ExceptionResultEnum.ERROR.exception("【" + status + "】状态的课程无法进行" + "【" + statusDesc + "】");
         }
         tbExamCourseService.updateById(tbExamCourse);
     }
@@ -2051,7 +2043,7 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                     BigDecimal assignScore;
                     // 当该试卷的赋分系数不为0时赋分
                     if (coefficient != null && coefficient.compareTo(BigDecimal.ZERO) > 0 && !absent) {
-                        assignScore = myScore.add((fullScore.subtract(myScore)).divide(coefficient, 4, BigDecimal.ROUND_HALF_UP)).setScale(0,BigDecimal.ROUND_HALF_UP);
+                        assignScore = myScore.add((fullScore.subtract(myScore)).divide(coefficient, 4, RoundingMode.HALF_UP)).setScale(0, RoundingMode.HALF_UP);
                     } else {
                         assignScore = myScore;
                     }
@@ -2083,15 +2075,15 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
     }
 
 
-    private void verifyComputing(Long examId,String courseCode){
+    private void verifyComputing(Long examId, String courseCode) {
         List<String> effectiveCourseCodeList = tbExamCourseService.findEffectiveByExamId(examId, courseCode);
         for (String effectiveCourseCode : effectiveCourseCodeList) {
             TBExamCourse tbExamCourse = tbExamCourseService.getOne(new QueryWrapper<TBExamCourse>().lambda()
                     .eq(TBExamCourse::getExamId, examId)
                     .eq(TBExamCourse::getCourseCode, effectiveCourseCode));
             PublishStatusEnum publishStatusEnum = tbExamCourse.getPublishStatus();
-            if (publishStatusEnum.equals(PublishStatusEnum.COMPUTING)){
-                throw ExceptionResultEnum.ERROR.exception("计算中的课程无法再计算 课程【" +tbExamCourse.getCourseName() + "】");
+            if (publishStatusEnum.equals(PublishStatusEnum.COMPUTING)) {
+                throw ExceptionResultEnum.ERROR.exception("计算中的课程无法再计算 课程【" + tbExamCourse.getCourseName() + "】");
             }
         }
     }
@@ -2107,8 +2099,8 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
     private int handlePercentGrade(BigDecimal lowCount, BigDecimal sameCount, BigDecimal totalCount) {
         // ((lowCount + sameCount * 0.5) / totalCount) * 100
         BigDecimal percentGrade = (lowCount.add(sameCount.multiply(new BigDecimal("0.5"))))
-                .divide(totalCount, 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
-        int result = percentGrade.setScale(0, BigDecimal.ROUND_HALF_UP).intValue();
+                .divide(totalCount, 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100"));
+        int result = percentGrade.setScale(0, RoundingMode.HALF_UP).intValue();
         if (result == 100) {
             result = 99;
         }
@@ -2177,7 +2169,7 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
         double lowCount = examRecordSameCol.stream().filter(e -> e.getAssignedScore().compareTo(taExamCourseRecord.getAssignedScore()) < 0).count();
         BigDecimal overCollegeRate;
         if (examRecordSameCol.size() > 1) {
-            overCollegeRate = BigDecimal.valueOf(lowCount).divide(BigDecimal.valueOf(examRecordSameCol.size() - 1), 4, BigDecimal.ROUND_HALF_UP);
+            overCollegeRate = BigDecimal.valueOf(lowCount).divide(BigDecimal.valueOf(examRecordSameCol.size() - 1), 4, RoundingMode.HALF_UP);
         } else {
             overCollegeRate = BigDecimal.ONE;
         }
@@ -2524,7 +2516,7 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
             }
             temp.setRank(rank);
         }
-        if (sortList.size() == 0){
+        if (sortList.size() == 0) {
             System.out.println("异常");
         }
         double endRank = sortList.get(sortList.size() - 1).getRank();

+ 4 - 4
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/TBExamCourseServiceImpl.java

@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.teachcloud.common.bean.auth.AuthBean;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.BasicCourse;
-import com.qmth.teachcloud.common.entity.SysOrg;
 import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import com.qmth.teachcloud.common.enums.RoleTypeEnum;
@@ -21,12 +20,14 @@ import com.qmth.teachcloud.report.business.enums.TestStatusEnum;
 import com.qmth.teachcloud.report.business.mapper.TBExamCourseMapper;
 import com.qmth.teachcloud.report.business.service.TBExamCourseService;
 import com.qmth.teachcloud.report.business.service.TBExaminationRelationService;
-import org.apache.poi.ss.formula.functions.T;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Objects;
 import java.util.stream.Collectors;
 
 /**
@@ -161,7 +162,6 @@ public class TBExamCourseServiceImpl extends ServiceImpl<TBExamCourseMapper, TBE
                 .eq(TBExamCourse::getExamId, examId)
                 .eq(TBExamCourse::getSchoolId, schoolId)
                 .eq(TBExamCourse::getCourseCode, courseCode)
-                .eq(TBExamCourse::getCourseName, courseName)
                 .eq(TBExamCourse::getExaminationCourseCode, examinationCourseCode));
         if (tbExamCourseList.size() > 0) {
             throw ExceptionResultEnum.ERROR.exception("考试课程已存在");

+ 56 - 24
teachcloud-report/src/main/java/com/qmth/teachcloud/report/api/BasicDatasourceController.java

@@ -42,6 +42,7 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.annotation.Resource;
 import java.io.IOException;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
@@ -54,6 +55,7 @@ import java.util.stream.Stream;
 @Api(tags = "数据源处理controller")
 @RestController
 @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/${prefix.url.datasource}")
+//@Aac(strict = BOOL.FALSE, auth = BOOL.FALSE)
 public class BasicDatasourceController {
     @Resource
     private TBPaperService tbPaperService;
@@ -183,8 +185,21 @@ public class BasicDatasourceController {
 
                         String paperType = paperStructDto.getPaperCode();
                         Long paperId = paperMap.get(paperType);
+
+                        // 考察点去空格
+                        String knowledgeDimension = paperStructDto.getKnowledgeDimension();
+                        if (SystemConstant.strNotNull(knowledgeDimension)){
+                            knowledgeDimension = knowledgeDimension.trim().replaceAll(SystemConstant.COMMA_OF_CHINESE,SystemConstant.COMMA_OF_ENGLISH).replaceAll(SystemConstant.PAUSE_SIGN,SystemConstant.COMMA_OF_ENGLISH);
+                        }
+                        String abilityDimension = paperStructDto.getAbilityDimension();
+                        if (SystemConstant.strNotNull(abilityDimension)){
+                            abilityDimension = abilityDimension.trim().replaceAll(SystemConstant.COMMA_OF_CHINESE,SystemConstant.COMMA_OF_ENGLISH).replaceAll(SystemConstant.PAUSE_SIGN,SystemConstant.COMMA_OF_ENGLISH);
+                        }
+
+                        // 题号组合与匹配
                         String mainNumber = paperStructDto.getMainNumber();
                         String subNumber = paperStructDto.getSubNumber();
+
                         String questionType = paperStructDto.getQuestionType();
                         if (questionType == null) {
                             questionType = "";
@@ -203,8 +218,8 @@ public class BasicDatasourceController {
                         tbPaperStruct.setFullScore(BigDecimal.valueOf(Double.parseDouble(paperStructDto.getFullScore())));
                         tbPaperStruct.setScoreRules(paperStructDto.getScoreRules());
                         tbPaperStruct.setRulesDesc(paperStructDto.getRulesDesc());
-                        tbPaperStruct.setKnowledgeDimension(paperStructDto.getKnowledgeDimension());
-                        tbPaperStruct.setAbilityDimension(paperStructDto.getAbilityDimension());
+                        tbPaperStruct.setKnowledgeDimension(knowledgeDimension);
+                        tbPaperStruct.setAbilityDimension(abilityDimension);
                         tbPaperStructList.add(tbPaperStruct);
                     }
                 }
@@ -448,10 +463,10 @@ public class BasicDatasourceController {
     @RequestMapping(value = "/examAnswer/import", method = RequestMethod.POST)
     @Transactional(rollbackFor = Exception.class)
     @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
-    public Result examAnswerImport(@ApiParam(value = "云阅卷考试id", required = true) @RequestParam Long id, @ApiParam(value = "云阅卷考试编号", required = false)
-    @RequestParam(required = false) String cloudExamCode,
-                                   @ApiParam(value = "教研分析将AB卷分开分析时自定义科目和卷形的连接符(连接符必须和’t_e_course‘表中的科目名称中连接符对应)")
-                                   @RequestParam(required = false) String linkSign, @RequestParam Long pSchoolId) throws IOException {
+    public Result examAnswerImport(@ApiParam(value = "云阅卷考试id", required = true) @RequestParam Long id,
+                                   @ApiParam(value = "云阅卷考试编号") @RequestParam(required = false) String cloudExamCode,
+                                   @ApiParam(value = "教研分析将AB卷分开分析时自定义科目和卷形的连接符(连接符必须和’t_e_course‘表中的科目名称中连接符对应)") @RequestParam(required = false) String linkSign,
+                                   @ApiParam(value = "学校id") @RequestParam Long pSchoolId) throws IOException {
         TBExam tbExam = tbExamService.findByCloudExamId(id);
         Long examId = tbExam.getId();
         Long schoolId = tbExamService.getById(examId).getSchoolId();
@@ -512,11 +527,27 @@ public class BasicDatasourceController {
 
             String teacherInfo = teacherPackage.get("teacherInfo");
             String subjectName = teacherPackage.get("subjectName");
-            List<TBExamCourse> tmpList = tbExamCourseList.stream().filter(e -> e.getCourseName().equals(subjectName)).collect(Collectors.toList());
-            if (tmpList.size() != 1) {
-                throw ExceptionResultEnum.ERROR.exception("课程信息异常");
+
+            Long teacherCollegeId = null;
+            // 如果存在A、B卷
+            for (TBExamCourse tbExamCourse : tbExamCourseList) {
+                String courseName = tbExamCourse.getCourseName();
+                if (SystemConstant.strNotNull(linkSign) && courseName.contains(linkSign)) {
+                    String[] cellArr = courseName.split(linkSign);
+                    if (cellArr.length != 2) {
+                        throw ExceptionResultEnum.ERROR.exception("无法解析存在分隔符为 【" + linkSign + "】的课程 【" + courseName + "】");
+                    }
+                    if (cellArr[0].equals(subjectName)) {
+                        teacherCollegeId = tbExamCourse.getTeachCollegeId();
+                        break;
+                    }
+                } else {
+                    if (courseName.equals(subjectName)) {
+                        teacherCollegeId = tbExamCourse.getTeachCollegeId();
+                        break;
+                    }
+                }
             }
-            Long teacherCollegeId = tmpList.get(0).getTeachCollegeId();
 
             // 教师信息统一化处理逻辑
             Map<String, String> map = this.disposeTeacherInfo(teacherInfo);
@@ -581,6 +612,7 @@ public class BasicDatasourceController {
             String studentCode = (String) map.get(ExamCloudDataEnum.STUDENT_CODE.getName()); //学号
             String name = (String) map.get(ExamCloudDataEnum.NAME.getName()); //名称
             String paperType = (String) map.get(ExamCloudDataEnum.PAPER_TYPE.getName()); //试卷类型
+            // 循环依次为#生成(分配)试卷编号为A、B、C......A、B、C......
             if (count > 0 && paperType.equals(specialPaperType)) {
                 paperType = paperTypeList.get(i);
                 i++;
@@ -608,7 +640,7 @@ public class BasicDatasourceController {
              */
             if (checkMap.containsKey(studentCode)) {
                 if (!checkMap.get(studentCode).getName().equals(name)) {
-                    throw ExceptionResultEnum.ERROR.exception("有学号【" + studentCode + "】的学生名称不同意");
+                    throw ExceptionResultEnum.ERROR.exception("有学号【" + studentCode + "】的学生名称不统一");
                 }
             } else {
                 TBStudent studentTemp = tbStudentService.getOne(new QueryWrapper<TBStudent>().lambda()
@@ -739,7 +771,7 @@ public class BasicDatasourceController {
         Set<Long> examStudentRemoveIdSet = new HashSet<>();
         for (String s : courseInfoList) {
             Set<Long> ids = tbExamStudentService.list(new QueryWrapper<TBExamStudent>().lambda()
-                    .eq(TBExamStudent::getCourseCode, s))
+                            .eq(TBExamStudent::getCourseCode, s))
                     .stream().map(TBExamStudent::getId).collect(Collectors.toSet());
             examStudentRemoveIdSet.addAll(ids);
         }
@@ -813,7 +845,7 @@ public class BasicDatasourceController {
                     BigDecimal coefficient = tbPaper.getCoefficient();
                     BigDecimal assignScore;
                     if (coefficient != null && coefficient.compareTo(BigDecimal.ZERO) > 0 && !basicExamRecordDto.getAbsent()) {
-                        assignScore = myScore.add(fullScore.subtract(myScore).divide(coefficient, 4, BigDecimal.ROUND_HALF_UP)).setScale(0, BigDecimal.ROUND_HALF_UP);
+                        assignScore = myScore.add(fullScore.subtract(myScore).divide(coefficient, 4, RoundingMode.HALF_UP)).setScale(0, RoundingMode.HALF_UP);
                     } else {
                         assignScore = myScore;
                     }
@@ -1058,7 +1090,7 @@ public class BasicDatasourceController {
             }
             tbExamStudentService.saveOrUpdateBatch(willUpdate);
         }
-        return ResultUtil.ok("有【" + count + "】条缺考学生数据被更新");
+        return ResultUtil.ok("有【" + count + "】条非应届学生数据被更新");
     }
 
     @ApiOperation(value = "异常考生-按学号处理")
@@ -1456,8 +1488,8 @@ public class BasicDatasourceController {
      * @return 键值对
      */
     private Map<String, String> disposeTeacherInfo(String teacherInfo) {
-        String teacherName = "";
-        String teacherCode = "";
+        StringBuilder teacherName = new StringBuilder();
+        StringBuilder teacherCode = new StringBuilder();
         teacherInfo = teacherInfo.trim().replaceAll(";", ";").replaceAll("\\\\", "/");
         String[] teacherInfoArr = teacherInfo.split(";");
         for (String teacher : teacherInfoArr) {
@@ -1473,22 +1505,22 @@ public class BasicDatasourceController {
                 System.out.println("error");
             }
             if (SystemConstant.strNotNull(cellName)) {
-                teacherName = teacherName + cellName + ";";
+                teacherName.append(cellName).append(";");
             }
             if (SystemConstant.strNotNull(cellCode)) {
-                teacherCode = teacherCode + cellCode + ";";
+                teacherCode.append(cellCode).append(";");
             }
         }
-        if (SystemConstant.strNotNull(teacherName)) {
-            teacherName = teacherName.substring(0, teacherName.length() - 1);
+        if (SystemConstant.strNotNull(teacherName.toString())) {
+            teacherName = new StringBuilder(teacherName.substring(0, teacherName.length() - 1));
         }
-        if (SystemConstant.strNotNull(teacherCode)) {
-            teacherCode = teacherCode.substring(0, teacherCode.length() - 1);
+        if (SystemConstant.strNotNull(teacherCode.toString())) {
+            teacherCode = new StringBuilder(teacherCode.substring(0, teacherCode.length() - 1));
         }
 
         Map<String, String> map = new HashMap<>();
-        map.put("teacherName", teacherName);
-        map.put("teacherCode", teacherCode);
+        map.put("teacherName", teacherName.toString());
+        map.put("teacherCode", teacherCode.toString());
         return map;
     }
 }