Bladeren bron

3.4.5 update-20250416,新功能开发

xiaofei 2 maanden geleden
bovenliggende
commit
336539688d

+ 14 - 3
distributed-print/src/main/java/com/qmth/distributed/print/api/mark/MarkAiQuestionParamController.java

@@ -90,6 +90,8 @@ public class MarkAiQuestionParamController {
             MarkPaper markPaper = markPaperService.getByExamIdAndPaperNumber(markAiQuestionParam.getExamId(), markAiQuestionParam.getPaperNumber());
             Objects.requireNonNull(markPaper, "试卷信息为空");
             Objects.requireNonNull(markPaper.getAiMark(), "AI评卷信息为空");
+            MarkQuestion markQuestion = markQuestionService.getById(markAiQuestionParam.getQuestionId());
+            Objects.requireNonNull(markQuestion, "题目为空");
             if (!MarkPaperAiMark.NONE.equals(markPaper.getAiMark())
                     && (CollectionUtils.isNotEmpty(markAiQuestionParam.getPointList()) || CollectionUtils.isEmpty(markAiQuestionParam.getLevelList()))
                     && markTaskService.countByExamIdAndPaperNumberAndQuestionIdAndTaskNumberAndAiMarkedAndStatusNotIn(markAiQuestionParam.getExamId(), markAiQuestionParam.getPaperNumber(), markAiQuestionParam.getQuestionId(), 1, false, Arrays.asList(MarkTaskStatus.WAITING)) > 0) {
@@ -102,9 +104,14 @@ public class MarkAiQuestionParamController {
                     }
                     // 最小分校验
                     MarkAiQuestionPoint markAiQuestionPoint = markAiQuestionParam.getPointList().stream().min(Comparator.comparingDouble(MarkAiQuestionPoint::getScore)).get();
-                    if(markAiQuestionParam.getMinScore() > markAiQuestionPoint.getScore()){
+                    if (markAiQuestionParam.getMinScore() > markAiQuestionPoint.getScore()) {
                         throw ExceptionResultEnum.ERROR.exception("最小分不能超过得分点的最小分值");
                     }
+                    // 各知识点得分总和校验
+                    Double sumScore = markAiQuestionParam.getPointList().stream().filter(m -> m.getScore() != null).collect(Collectors.summingDouble(MarkAiQuestionPoint::getScore));
+                    if (sumScore.doubleValue() - markQuestion.getTotalScore().doubleValue() != 0) {
+                        throw ExceptionResultEnum.ERROR.exception("各知识点得分总和必须等于小题满分[" + markQuestion.getTotalScore() + "]分");
+                    }
                     if (Objects.isNull(markAiQuestionParam.getId())) {//新增
                         markAiQuestionParam.insertInfo(sysUser.getId());
                         markAiQuestionParam.getPointList().stream().peek(s -> {
@@ -147,9 +154,14 @@ public class MarkAiQuestionParamController {
                     }
                     // 最小分校验
                     MarkAiQuestionLevel markAiQuestionLevel = markAiQuestionParam.getLevelList().stream().min(Comparator.comparingDouble(MarkAiQuestionLevel::getMinScore)).get();
-                    if(markAiQuestionParam.getMinScore() > markAiQuestionLevel.getMinScore()){
+                    if (markAiQuestionParam.getMinScore() > markAiQuestionLevel.getMinScore()) {
                         throw ExceptionResultEnum.ERROR.exception("最小分不能超过档次的最小分值");
                     }
+                    // 档位最大分校验
+                    Double maxScore = markAiQuestionParam.getLevelList().stream().filter(m -> m.getMaxScore() != null).max(Comparator.comparingDouble(MarkAiQuestionLevel::getMaxScore)).get().getMaxScore();
+                    if (maxScore.doubleValue() - markQuestion.getTotalScore().doubleValue() != 0) {
+                        throw ExceptionResultEnum.ERROR.exception("档位最大分必须等于小题满分[" + markQuestion.getTotalScore() + "]分");
+                    }
                     if (Objects.isNull(markAiQuestionParam.getId())) {//新增
                         markAiQuestionParam.insertInfo(sysUser.getId());
                         markAiQuestionParam.getLevelList().stream().peek(s -> {
@@ -197,7 +209,6 @@ public class MarkAiQuestionParamController {
 
             if (markAiQuestionParamService.existMarkAiQuestionPointOrLevel(markAiQuestionParam.getExamId(), markAiQuestionParam.getPaperNumber(), markAiQuestionParam.getQuestionId())
                     && markTaskService.countByExamIdAndPaperNumberAndQuestionIdAndTaskNumberAndAiMarkedAndStatusNotIn(markAiQuestionParam.getExamId(), markAiQuestionParam.getPaperNumber(), markAiQuestionParam.getQuestionId(), 1, false, null) > 0) {
-                MarkQuestion markQuestion = markQuestionService.getById(markAiQuestionParam.getQuestionId());
                 markService.deleteMarkTask(markQuestion, true);
                 markService.checkStudentSubjectiveScore(markAiQuestionParam.getExamId(), markPaper.getCoursePaperId());
                 markService.updateMarkedCount(markAiQuestionParam.getExamId(), markAiQuestionParam.getPaperNumber(), markAiQuestionParam.getQuestionId());

+ 40 - 8
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/impl/MarkServiceImpl.java

@@ -67,6 +67,7 @@ import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.function.Function;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 @Service
 public class MarkServiceImpl implements MarkService {
@@ -1639,14 +1640,45 @@ public class MarkServiceImpl implements MarkService {
         double[] doubles = autoScoreResult.getStepScore();
         // 轨迹打印在第一个评卷区上
         List<MarkConfigItem> pictureConfigList = markQuestion.getPictureConfigList();
-        MarkConfigItem markConfigItem = pictureConfigList.get(0);
-//        SheetImageDto sheetImageDto = fileMap.get(markConfigItem.getI());
-        MarkOcrStudentQuestion markOcrStudentQuestion = markOcrStudentQuestions.stream().filter(m -> m.getNumber().equals(markConfigItem.getI())).findFirst().get();
-        int step = 150;
-        for (int i = 0; i < doubles.length; i++) {
-            int offsetX = (int) (markOcrStudentQuestion.getImageWidth() * markConfigItem.getX()) + 200 + step * (i + 1);
-            int offsetY = (int) (markOcrStudentQuestion.getImageHeight() * markConfigItem.getY()) + 300;
-            list.add(new TrackDTO(markQuestion, i + 1, doubles[i], markConfigItem.getI(), offsetX, offsetY));
+
+        int initXAdd = 100, initYAdd = 100, stepXAdd = 100, stepYAdd = 30;
+        int count = 0;
+        for (int i = 0; i < pictureConfigList.size(); i++) {
+            MarkConfigItem markConfigItem = pictureConfigList.get(i);
+            int finalI = i + 1;
+            MarkOcrStudentQuestion markOcrStudentQuestion = markOcrStudentQuestions.stream().filter(m -> m.getNumber().equals(finalI)).findFirst().get();
+
+
+            int offsetX = 0, offsetY = 0;
+            for (int j = 0; j < doubles.length; j++) {
+                int picX = (int) (markOcrStudentQuestion.getImageWidth() * markConfigItem.getX());
+                int picY = (int) (markOcrStudentQuestion.getImageHeight() * markConfigItem.getY());
+                int picW = (int) (markOcrStudentQuestion.getImageWidth() * markConfigItem.getW());
+                int picH = (int) (markOcrStudentQuestion.getImageHeight() * markConfigItem.getH());
+
+                if (j == 0) {
+                    offsetX = picX + initXAdd;
+                    offsetY = picY + initYAdd;
+                } else {
+                    offsetX = offsetX + stepXAdd;
+                }
+                if (offsetX > picX + picW) {
+                    if (offsetY > picY + picH) {
+                        continue;
+                    } else {
+                        offsetX = picX + initXAdd;
+                        offsetY = offsetY + stepYAdd;
+                    }
+                }
+                if (offsetY > picY + picH) {
+                    continue;
+                }
+                list.add(new TrackDTO(markQuestion, j + 1, doubles[count++], markConfigItem.getI(), offsetX, offsetY));
+
+                if (count == doubles.length) {
+                    break;
+                }
+            }
         }
         return list;
     }