Explorar el Código

3.3.0 识别对照仅更新客观题结果和分数

yin hace 1 año
padre
commit
995c0bf249

+ 14 - 6
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/MarkStudentService.java

@@ -48,11 +48,15 @@ public interface MarkStudentService extends IService<MarkStudent> {
 
     void updateSubjectiveStatusAndScore(Long studentId, SubjectiveStatus status, Double score, String scoreList);
 
-    void updateSubjectiveStatusAndScore(Long examId, String paperNumber, SubjectiveStatus status, double score, String scoreList);
+    void updateSubjectiveStatusAndScore(Long examId, String paperNumber, SubjectiveStatus status, double score,
+            String scoreList);
 
     ScanExamInfoVo getScanExamInfo(BasicExam exam, String courseCode, String coursePaperId);
 
-    IPage<StudentScoreDetailDto> pageStudentScore(Long examId, String paperNumber, String college, String className, String teacher, Integer filter, Boolean absent, Boolean breach, Double startScore, Double endScore, Double subScore, Integer objectiveScoreRateLt, String studentName, String studentCode, String orderType, String orderField, Integer pageNumber, Integer pageSize);
+    IPage<StudentScoreDetailDto> pageStudentScore(Long examId, String paperNumber, String college, String className,
+            String teacher, Integer filter, Boolean absent, Boolean breach, Double startScore, Double endScore,
+            Double subScore, Integer objectiveScoreRateLt, String studentName, String studentCode, String orderType,
+            String orderField, Integer pageNumber, Integer pageSize);
 
     List<SheetUrlDto> buildSheetUrls(Long studentId);
 
@@ -65,7 +69,6 @@ public interface MarkStudentService extends IService<MarkStudent> {
 
     MarkStudent findByExamIdAndCoursePaperIdAndStudentCode(Long examId, String coursePaperId, String studentCode);
 
-
     StudentObjectiveDetailDto getObjectiveInspectedTask(Long studentId);
 
     Boolean saveObjectiveInspectedTask(Long studentId, String answers);
@@ -102,7 +105,8 @@ public interface MarkStudentService extends IService<MarkStudent> {
 
     UpdateTimeVo confirm(Long examId, String coursePaperId, String studentCode, Boolean omrAbsent);
 
-    List<Long> findIdByExamIdAndPaperNumberAndSubjectiveStatus(Long examId, String paperNumber, SubjectiveStatus unmark, SubjectiveStatus marked);
+    List<Long> findIdByExamIdAndPaperNumberAndSubjectiveStatus(Long examId, String paperNumber, SubjectiveStatus unmark,
+            SubjectiveStatus marked);
 
     Task getSubjectiveInspectedTask(Long studentId);
 
@@ -134,11 +138,15 @@ public interface MarkStudentService extends IService<MarkStudent> {
 
     boolean updateAssignConfirm(Long studentId, boolean assignConfirm);
 
-    int getAssignedCount(Long examId, Boolean checked, String courseCode, String coursePaperId, MarkPaperStatus status, DataPermissionRule dpr);
+    int getAssignedCount(Long examId, Boolean checked, String courseCode, String coursePaperId, MarkPaperStatus status,
+            DataPermissionRule dpr);
 
     int countAbsentByExamIdAndPaperNumber(Long examId, String paperNumber);
 
-    List<MarkStudent> listScanCollegeByExamIdAndCourseCodeAndCoursePaperId(Long examId, String courseCode, String coursePaperId, String status, DataPermissionRule dpr);
+    List<MarkStudent> listScanCollegeByExamIdAndCourseCodeAndCoursePaperId(Long examId, String courseCode,
+            String coursePaperId, String status, DataPermissionRule dpr);
 
     int countUnexistByExamIdAndPaperNumberAndPaperType(Long examId, String paperNumber, String paperType);
+
+    void updateStudentAnswer(@NotNull Long studentId);
 }

+ 26 - 1
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/impl/MarkStudentServiceImpl.java

@@ -728,7 +728,7 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
                 }
                 scanPaperService.savePaperAndPages(paperEntity, pages);
             }
-            updateStudentByPaper(userId, student.getId(), false);
+            updateStudentByPaper(userId, student.getId(), true);
             return UpdateTimeVo.create();
         } finally {
             concurrentService.getReadWriteLock(LockType.STUDENT + "-" + student.getId()).writeLock().unlock();
@@ -1206,4 +1206,29 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
         markStudent.setMarkPaperStatus(MarkPaperStatus.FORMAL.name());
         return baseMapper.selectCountByQuery(markStudent, null);
     }
+
+    @Override
+    public void updateStudentAnswer(Long studentId) {
+        List<String> objectiveAnswers = new ArrayList<>();
+        MarkStudent student = this.getById(studentId);
+        List<ScanStudentPaper> studentPaperList = studentPaperService.findByStudentId(studentId);
+        for (ScanStudentPaper studentPaper : studentPaperList) {
+            List<ScanPaperPage> scanPaperPages = scanPaperPageService.listByPaperId(studentPaper.getPaperId());
+            for (ScanPaperPage scanPaperPage : scanPaperPages) {
+                if (scanPaperPage.getQuestion() != null
+                        && CollectionUtils.isNotEmpty(scanPaperPage.getQuestion().getResult())) {
+                    for (String s : scanPaperPage.getQuestion().getResult()) {
+                        if (s.startsWith("?")) {
+                            s = s.replace("?", "");
+                        }
+                        objectiveAnswers.add(s);
+                    }
+                }
+            }
+        }
+        student.setAnswers(JSON.toJSONString(objectiveAnswers));
+        this.saveOrUpdate(student);
+        // 客观题统分
+        this.calculateObjectiveScore(student);
+    }
 }

+ 106 - 84
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/impl/ScanOmrTaskServiceImpl.java

@@ -1,5 +1,16 @@
 package com.qmth.teachcloud.mark.service.impl;
 
+import java.util.*;
+import java.util.stream.Collectors;
+
+import javax.annotation.Resource;
+import javax.validation.constraints.NotNull;
+
+import org.apache.commons.collections4.CollectionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -28,15 +39,6 @@ import com.qmth.teachcloud.mark.enums.LockType;
 import com.qmth.teachcloud.mark.enums.OmrTaskStatus;
 import com.qmth.teachcloud.mark.mapper.ScanOmrTaskMapper;
 import com.qmth.teachcloud.mark.service.*;
-import org.apache.commons.collections4.CollectionUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import javax.annotation.Resource;
-import javax.validation.constraints.NotNull;
-import java.util.*;
-import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -48,22 +50,31 @@ import java.util.stream.Collectors;
  */
 @Service
 public class ScanOmrTaskServiceImpl extends ServiceImpl<ScanOmrTaskMapper, ScanOmrTask> implements ScanOmrTaskService {
+
     @Autowired
     private ScanStudentPaperService studentPaperService;
+
     @Autowired
     private MarkStudentService studentService;
+
     @Autowired
     private ScanPaperService paperService;
+
     @Autowired
     private ScanPaperPageService pageService;
+
     @Autowired
     private ConcurrentService concurrentService;
+
     @Autowired
     private MarkQuestionService questionService;
+
     @Resource
     private MarkPaperService markPaperService;
+
     @Resource
     private TeachcloudCommonService teachcloudCommonService;
+
     @Resource
     private BasicRoleDataPermissionService basicRoleDataPermissionService;
 
@@ -127,28 +138,28 @@ public class ScanOmrTaskServiceImpl extends ServiceImpl<ScanOmrTaskMapper, ScanO
                     pageDto.setItems(items);
                 }
                 // 卷型空选
-//                if (ConditionType.PAPER_TYPE_BLANK.equals(c)) {
-//                    if (pageEntity.getPaperType() != null
-//                            && pageEntity.getPaperType().getResult().contains(OMR_BLANK)) {
-//                        OmrTaskItem item = new OmrTaskItem();
-//                        item.setIndex(1);
-//                        item.setField(OmrField.PAPER_TYPE);
-//                        item.setOmrResult(pageEntity.getPaperType().getResult());
-//                        items.add(item);
-//                    }
-//                }
+                // if (ConditionType.PAPER_TYPE_BLANK.equals(c)) {
+                // if (pageEntity.getPaperType() != null
+                // && pageEntity.getPaperType().getResult().contains(OMR_BLANK)) {
+                // OmrTaskItem item = new OmrTaskItem();
+                // item.setIndex(1);
+                // item.setField(OmrField.PAPER_TYPE);
+                // item.setOmrResult(pageEntity.getPaperType().getResult());
+                // items.add(item);
+                // }
+                // }
                 // 卷型多选
-//                if (ConditionType.PAPER_TYPE_EXCEED.equals(c)) {
-//                    if ((!pageEntity.getPaperType().getResult().contains(OMR_SUSPECT)
-//                            && pageEntity.getPaperType().getResult().length() > 2)
-//                            || (pageEntity.getPaperType().getResult().contains(OMR_SUSPECT)
-//                                    && pageEntity.getPaperType().getResult().length() > 1)) {
-//                        OmrTaskItem item = new OmrTaskItem();
-//                        item.setField(OmrField.PAPER_TYPE);
-//                        item.setOmrResult(pageEntity.getPaperType().getResult());
-//                        items.add(item);
-//                    }
-//                }
+                // if (ConditionType.PAPER_TYPE_EXCEED.equals(c)) {
+                // if ((!pageEntity.getPaperType().getResult().contains(OMR_SUSPECT)
+                // && pageEntity.getPaperType().getResult().length() > 2)
+                // || (pageEntity.getPaperType().getResult().contains(OMR_SUSPECT)
+                // && pageEntity.getPaperType().getResult().length() > 1)) {
+                // OmrTaskItem item = new OmrTaskItem();
+                // item.setField(OmrField.PAPER_TYPE);
+                // item.setOmrResult(pageEntity.getPaperType().getResult());
+                // items.add(item);
+                // }
+                // }
                 if (ConditionType.QUESTION_MULTI_BLANK.equals(c)) {
                     List<MarkQuestion> questiongList = questionService
                             .listByExamIdAndPaperNumberAndPaperIndexAndPageIndex(student.getExamId(),
@@ -205,8 +216,8 @@ public class ScanOmrTaskServiceImpl extends ServiceImpl<ScanOmrTaskMapper, ScanO
                         }
                     }
                 }
-                if (ConditionType.QUESTION_SINGLE_EXCEED.equals(c)
-                        && ScanStatus.SCANNED.equals(student.getScanStatus()) && !allObjectiveBlank) {
+                if (ConditionType.QUESTION_SINGLE_EXCEED.equals(c) && ScanStatus.SCANNED.equals(student.getScanStatus())
+                        && !allObjectiveBlank) {
                     List<MarkQuestion> questiongList = questionService
                             .listByExamIdAndPaperNumberAndPaperIndexAndPageIndex(student.getExamId(),
                                     student.getPaperNumber(), spe.getPaperIndex(), pageEntity.getPageIndex());
@@ -219,7 +230,8 @@ public class ScanOmrTaskServiceImpl extends ServiceImpl<ScanOmrTaskMapper, ScanO
                     for (int i = 0; i < size; i++) {
                         String result = pageEntity.getQuestion().getResult().get(i);
                         MarkQuestion question = questiongList.get(i);
-                        if (question.getQuestionType().equals(QuestionType.SINGLE.getValue()) && result != null && result.length() > 1) {
+                        if (question.getQuestionType().equals(QuestionType.SINGLE.getValue()) && result != null
+                                && result.length() > 1) {
                             OmrTaskItem item = new OmrTaskItem();
                             item.setIndex(i + 1);
                             item.setField(OmrField.QUESTION);
@@ -387,36 +399,36 @@ public class ScanOmrTaskServiceImpl extends ServiceImpl<ScanOmrTaskMapper, ScanO
             for (OmrTaskPage taskPage : task.getPages()) {
                 ScanOmrTaskPageDto page = new ScanOmrTaskPageDto();
                 Map<Integer, List<String>> question = new HashMap<>();
-                Map<Integer, List<String>> selective = new HashMap<>();
+                // Map<Integer, List<String>> selective = new HashMap<>();
                 for (OmrTaskItem item : taskPage.getItems()) {
-                    if (OmrField.ABSENT.equals(item.getField())) {
-                        page.setAbsent(getBooleanItem(item));
-                    }
-                    if (OmrField.BREACH.equals(item.getField())) {
-                        page.setBreach(getBooleanItem(item));
-                    }
-                    if (OmrField.PAPER_TYPE.equals(item.getField())) {
-                        page.setPaperType(getStringItem(item));
-                    }
+                    // if (OmrField.ABSENT.equals(item.getField())) {
+                    // page.setAbsent(getBooleanItem(item));
+                    // }
+                    // if (OmrField.BREACH.equals(item.getField())) {
+                    // page.setBreach(getBooleanItem(item));
+                    // }
+                    // if (OmrField.PAPER_TYPE.equals(item.getField())) {
+                    // page.setPaperType(getStringItem(item));
+                    // }
                     if (OmrField.QUESTION.equals(item.getField())) {
                         List<String> content = getStringItem(item);
                         if (content != null) {
                             question.put(item.getIndex(), content);
                         }
                     }
-                    if (OmrField.SELECTIVE.equals(item.getField())) {
-                        List<String> content = getStringItem(item);
-                        if (content != null) {
-                            selective.put(item.getIndex(), content);
-                        }
-                    }
+                    // if (OmrField.SELECTIVE.equals(item.getField())) {
+                    // List<String> content = getStringItem(item);
+                    // if (content != null) {
+                    // selective.put(item.getIndex(), content);
+                    // }
+                    // }
                 }
                 if (question.size() > 0) {
                     page.setQuestion(question);
                 }
-                if (selective.size() > 0) {
-                    page.setSelective(selective);
-                }
+                // if (selective.size() > 0) {
+                // page.setSelective(selective);
+                // }
                 // 有需要仲裁的数据才返回结构
                 if (page.getAbsent() != null || page.getBreach() != null || page.getPaperType() != null
                         || page.getQuestion() != null || page.getSelective() != null) {
@@ -434,7 +446,7 @@ public class ScanOmrTaskServiceImpl extends ServiceImpl<ScanOmrTaskMapper, ScanO
     }
 
     private List<String> getStringItem(OmrTaskItem item) {
-        //只取最新的值
+        // 只取最新的值
         List<String> value = new ArrayList<>();
         if (item.getSecondResult() != null) {
             value.add(item.getSecondResult());
@@ -476,7 +488,8 @@ public class ScanOmrTaskServiceImpl extends ServiceImpl<ScanOmrTaskMapper, ScanO
             if (markStudent == null) {
                 throw new ParameterException("考生不存在");
             }
-            MarkPaper markPaper = markPaperService.getByExamIdAndCoursePaperId(markStudent.getExamId(), markStudent.getCoursePaperId());
+            MarkPaper markPaper = markPaperService.getByExamIdAndCoursePaperId(markStudent.getExamId(),
+                    markStudent.getCoursePaperId());
             if (markPaper == null) {
                 throw new ParameterException("课程不存在");
             }
@@ -492,18 +505,18 @@ public class ScanOmrTaskServiceImpl extends ServiceImpl<ScanOmrTaskMapper, ScanO
                         throw new ParameterException("page[" + page.getIndex() + "]不存在");
                     }
                     for (OmrTaskItem item : page.getItems()) {
-                        if (OmrField.ABSENT.equals(item.getField())) {
-                            if (pageVo.getAbsent() == null) {
-                                throw new ParameterException("page[" + page.getIndex() + "].absent不存在");
-                            }
-                            item.setFirstResult(pageVo.getAbsent().toString());
-                        }
-                        if (OmrField.BREACH.equals(item.getField())) {
-                            if (pageVo.getBreach() == null) {
-                                throw new ParameterException("page[" + page.getIndex() + "].breach不存在");
-                            }
-                            item.setFirstResult(pageVo.getBreach().toString());
-                        }
+                        // if (OmrField.ABSENT.equals(item.getField())) {
+                        // if (pageVo.getAbsent() == null) {
+                        // throw new ParameterException("page[" + page.getIndex() + "].absent不存在");
+                        // }
+                        // item.setFirstResult(pageVo.getAbsent().toString());
+                        // }
+                        // if (OmrField.BREACH.equals(item.getField())) {
+                        // if (pageVo.getBreach() == null) {
+                        // throw new ParameterException("page[" + page.getIndex() + "].breach不存在");
+                        // }
+                        // item.setFirstResult(pageVo.getBreach().toString());
+                        // }
                         if (OmrField.QUESTION.equals(item.getField())) {
                             String content = pageVo.getQuestion() != null ? pageVo.getQuestion().get(item.getIndex())
                                     : null;
@@ -513,15 +526,16 @@ public class ScanOmrTaskServiceImpl extends ServiceImpl<ScanOmrTaskMapper, ScanO
                             }
                             item.setFirstResult(content);
                         }
-                        if (OmrField.SELECTIVE.equals(item.getField())) {
-                            String content = pageVo.getSelective() != null ? pageVo.getSelective().get(item.getIndex())
-                                    : null;
-                            if (content == null) {
-                                throw new ParameterException(
-                                        "page[" + page.getIndex() + "].selective[" + item.getIndex() + "]不存在");
-                            }
-                            item.setFirstResult(content);
-                        }
+                        // if (OmrField.SELECTIVE.equals(item.getField())) {
+                        // String content = pageVo.getSelective() != null ?
+                        // pageVo.getSelective().get(item.getIndex())
+                        // : null;
+                        // if (content == null) {
+                        // throw new ParameterException(
+                        // "page[" + page.getIndex() + "].selective[" + item.getIndex() + "]不存在");
+                        // }
+                        // item.setFirstResult(content);
+                        // }
                     }
                 }
                 task.setStatus(OmrTaskStatus.PROCESSED);
@@ -559,22 +573,27 @@ public class ScanOmrTaskServiceImpl extends ServiceImpl<ScanOmrTaskMapper, ScanO
             }
         }
         paperService.savePaperAndPages(paper, pages);
-        studentService.updateStudentByPaper(userId, sp.getStudentId(), false);
+        studentService.updateStudentAnswer(sp.getStudentId());
     }
 
     @Override
     public ScanOmrTaskStatusDto getStatus(Long examId, String courseCode, String coursePaperId) {
         SysUser user = (SysUser) ServletUtil.getRequestUser();
-        DataPermissionRule dpr = basicRoleDataPermissionService.findDataPermission(user.getSchoolId(), user.getId(), ServletUtil.getRequest().getServletPath());
+        DataPermissionRule dpr = basicRoleDataPermissionService.findDataPermission(user.getSchoolId(), user.getId(),
+                ServletUtil.getRequest().getServletPath());
         ScanOmrTaskStatusDto status = new ScanOmrTaskStatusDto();
-        status.setFinishCount(this.getFinishStudentCountByExamAndUserId(examId, courseCode, coursePaperId, OmrTaskStatus.PROCESSED.name(), dpr));
-        status.setTodoCount(this.getFinishStudentCountByExamAndUserId(examId, courseCode, coursePaperId, OmrTaskStatus.WAITING.name(), dpr));
+        status.setFinishCount(this.getFinishStudentCountByExamAndUserId(examId, courseCode, coursePaperId,
+                OmrTaskStatus.PROCESSED.name(), dpr));
+        status.setTodoCount(this.getFinishStudentCountByExamAndUserId(examId, courseCode, coursePaperId,
+                OmrTaskStatus.WAITING.name(), dpr));
         return status;
     }
 
     @Override
-    public int getFinishStudentCountByExamAndUserId(Long examId, String courseCode, String coursePaperId, String status, DataPermissionRule dpr) {
-        return this.baseMapper.getStudentCountByExamAndStatusAndUserId(examId, courseCode, coursePaperId, status, MarkPaperStatus.FORMAL.name(), dpr);
+    public int getFinishStudentCountByExamAndUserId(Long examId, String courseCode, String coursePaperId, String status,
+            DataPermissionRule dpr) {
+        return this.baseMapper.getStudentCountByExamAndStatusAndUserId(examId, courseCode, coursePaperId, status,
+                MarkPaperStatus.FORMAL.name(), dpr);
     }
 
     @Transactional
@@ -598,7 +617,8 @@ public class ScanOmrTaskServiceImpl extends ServiceImpl<ScanOmrTaskMapper, ScanO
     }
 
     @Override
-    public int getCount(Long examId, OmrTaskStatus status, String courseCode, String coursePaperId, MarkPaperStatus markPaperStatus, DataPermissionRule dpr) {
+    public int getCount(Long examId, OmrTaskStatus status, String courseCode, String coursePaperId,
+            MarkPaperStatus markPaperStatus, DataPermissionRule dpr) {
         ScanOmrTask scanOmrTask = new ScanOmrTask();
         scanOmrTask.setExamId(examId);
         scanOmrTask.setCourseCode(courseCode);
@@ -611,8 +631,10 @@ public class ScanOmrTaskServiceImpl extends ServiceImpl<ScanOmrTaskMapper, ScanO
     @Override
     public List<ScanStudentDto> list(Long examId, String courseCode, String coursePaperId, OmrTaskStatus status) {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-        DataPermissionRule dpr = basicRoleDataPermissionService.findDataPermission(sysUser.getSchoolId(), sysUser.getId(), ServletUtil.getRequest().getServletPath());
-        return this.baseMapper.listByExamIdAndStatusAndUserId(examId, courseCode, coursePaperId, status, MarkPaperStatus.FORMAL.name(), dpr);
+        DataPermissionRule dpr = basicRoleDataPermissionService.findDataPermission(sysUser.getSchoolId(),
+                sysUser.getId(), ServletUtil.getRequest().getServletPath());
+        return this.baseMapper.listByExamIdAndStatusAndUserId(examId, courseCode, coursePaperId, status,
+                MarkPaperStatus.FORMAL.name(), dpr);
     }
 
     @Override