Bläddra i källkod

任务投放,重评bug修复

xiaof 5 år sedan
förälder
incheckning
fdd4f0c4ca

+ 10 - 6
stmms-ms-core/src/main/java/cn/com/qmth/stmms/ms/core/repository/MarkTaskRepo.java

@@ -37,11 +37,13 @@ public interface MarkTaskRepo extends JpaRepository<MarkTask, Long>, JpaSpecific
 
     long countByQuestionIdIn(List<Long> questionIds);
 
-    long countByQuestionId(Long questionId);
+    @Query(value = "select count(1) from mark_task m left join paper p on m.paper_id = p.id where m.question_id = ? and p.batch_no = (select max(batch_no) from paper where question_id = ?)", nativeQuery = true)
+    long countByQuestionId(Long questionId, Long questionId1);
 
     int countByQuestionIdAndStageAndResultIsNull(Long questionId, MarkStage stage);
 
-    int countByQuestionIdAndStageAndResult(Long questionId, MarkStage stage, String result);
+    @Query(value = "select count(1) from mark_task m left join paper p on m.paper_id = p.id where m.question_id = ?1 and m.stage = ?2 and m.result = ?3 and p.batch_no = (select max(batch_no) from paper where question_id = ?1)", nativeQuery = true)
+    int countByQuestionIdAndStageAndResult(Long questionId, int stage, String result);
 
     int countByQuestionIdAndMarkerIdAndStageAndResultIsNull(Long questionId, Long markerId, MarkStage stage);
 
@@ -173,9 +175,11 @@ public interface MarkTaskRepo extends JpaRepository<MarkTask, Long>, JpaSpecific
             "WHERE t.workId = ?1 and t.subject = ?2 and t.markerId = ?3 and t.stage = ?4 and t.questionId = ?5 ")
     Integer findRandomSeqByWorkIdAndSubjectAndMarkerIdAndStageAndQuestionId(Long workId, Subject subject, Long markerId, MarkStage stage, Long questionId);
 
-    @Query(value = "SELECT count(1) from mark_task m left join paper p on m.paper_id = p.id where m.question_id = ?1 and m.marker_id = ?2 and m.stage = ?3 and m.result is null and p.is_missing = ?4", nativeQuery = true)
-    int countByQuestionIdAndMarkerIdAndStageAndResultIsNullAndIsMissing(Long questionId, Long markerId, int stage, boolean isMissing);
+    @Query(value = "SELECT count(1) from mark_task m left join paper p on m.paper_id = p.id where m.question_id = ?1 and m.marker_id = ?2 and m.stage = ?3 and m.result is null and p.is_missing = ?4 and p.batch_no = (select max(batch_no) from paper where question_id = ?5)", nativeQuery = true)
+    int countByQuestionIdAndMarkerIdAndStageAndResultIsNullAndIsMissing(Long questionId, Long markerId, int stage, boolean isMissing, Long questionId1);
 
-    @Query(value = "SELECT count(1) from mark_task m left join paper p on m.paper_id = p.id where m.question_id = ?1 and m.stage = ?2 and m.result =?3 and p.is_missing = ?4", nativeQuery = true)
-    int countByQuestionIdAndStageAndResultAndIsMissing(Long questionId, int stage, String result, boolean isMissing);
+    @Query(value = "SELECT count(1) from mark_task m left join paper p on m.paper_id = p.id where m.question_id = ?1 and m.stage = ?2 and m.result =?3 and p.is_missing = ?4 and p.batch_no = (select max(batch_no) from paper where question_id = ?5", nativeQuery = true)
+    int countByQuestionIdAndStageAndResultAndIsMissing(Long questionId, int stage, String result, boolean isMissing, Long questionId1);
+
+    MarkTask findByPaperIdAndSecretNumber(Long paperId, String secretNumber);
 }

+ 5 - 4
stmms-ms-marking/src/main/java/cn/com/qmth/stmms/ms/marking/api/MakrerApi.java

@@ -110,6 +110,7 @@ public class MakrerApi {
     public List<LevelStatDTO> levelStats(@PathVariable MarkUser marker, @RequestParam Long questionId) throws Exception {
         List<LevelStatDTO> levelStatDTOs = new ArrayList<>();
         MarkSubject markSubject = markSubjectRepo.findOne(marker.getWorkId() + "-" + marker.getSubject().toString());
+        System.out.println(markSubject.getTest());
         List<Level> levels = levelRepo.findByWorkId(markSubject.getWorkId());
         Map<String, Level> levelMap = levels.stream().collect(Collectors.toMap(Level::getCode, l -> l));
         //统计workId下各考点的数量
@@ -120,11 +121,11 @@ public class MakrerApi {
                     if (Objects.isNull(levelStatDTO.getId())) {
                         //求任务数为null的条数
 //                        int count = markTaskRepo.countByQuestionIdAndMarkerIdAndStageAndResultIsNull(questionId, marker.getId(), MarkStage.LEVEL);
-                        int count = markTaskRepo.countByQuestionIdAndMarkerIdAndStageAndResultIsNullAndIsMissing(questionId, marker.getId(), MarkStage.LEVEL.ordinal(), false);
+                        int count = markTaskRepo.countByQuestionIdAndMarkerIdAndStageAndResultIsNullAndIsMissing(questionId, marker.getId(), MarkStage.LEVEL.ordinal(), false, questionId);
                         levelStatDTO.setCount(count);
                     } else {
 //                        int count = markTaskRepo.countByQuestionIdAndStageAndResult(questionId, MarkStage.LEVEL, levelStatDTO.getId().toString());
-                        int count = markTaskRepo.countByQuestionIdAndStageAndResultAndIsMissing(questionId, MarkStage.LEVEL.ordinal(), levelStatDTO.getId().toString(), false);
+                        int count = markTaskRepo.countByQuestionIdAndStageAndResultAndIsMissing(questionId, MarkStage.LEVEL.ordinal(), levelStatDTO.getId().toString(), false, questionId);
                         levelStatDTO.setCount(count);
                     }
                     levelStatDTOs.add(levelStatDTO);
@@ -140,14 +141,14 @@ public class MakrerApi {
                 dto.setPercent(0.0);
 
                 //当前老师当前档位评档次数(所有考试)
-                int countNew = markTaskRepo.countByQuestionIdAndStageAndResult(questionId, MarkStage.LEVEL, level.getCode());
+                int countNew = markTaskRepo.countByQuestionIdAndStageAndResult(questionId, MarkStage.LEVEL.ordinal(), level.getCode());
                 dto.setCount(countNew);
                 levelStatDTOs.add(dto);
             }
         }
 
         //当前老师当前试卷的评档次数(不分档位)
-        long kdtotal = markTaskRepo.countByQuestionId(questionId);
+        long kdtotal = markTaskRepo.countByQuestionId(questionId, questionId);
         //当前老师所有的评档次数(不分档位)
         long total = paperRepo.countByWorkIdAndQuestionId(markSubject.getWorkId(), questionId);
 

+ 34 - 20
stmms-ms-marking/src/main/java/cn/com/qmth/stmms/ms/marking/api/TaskApi.java

@@ -1,8 +1,10 @@
 package cn.com.qmth.stmms.ms.marking.api;
 
+import cn.com.qmth.stmms.ms.core.domain.MarkLog;
 import cn.com.qmth.stmms.ms.core.domain.MarkStage;
 import cn.com.qmth.stmms.ms.core.domain.Paper;
 import cn.com.qmth.stmms.ms.core.domain.task.MarkTask;
+import cn.com.qmth.stmms.ms.core.repository.MarkLogRepo;
 import cn.com.qmth.stmms.ms.core.repository.MarkTaskRepo;
 import cn.com.qmth.stmms.ms.core.repository.PaperRepo;
 import cn.com.qmth.stmms.ms.marking.assembler.PaperAssembler;
@@ -10,15 +12,13 @@ import cn.com.qmth.stmms.ms.marking.dto.PaperDTO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.data.jpa.domain.Specification;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.persistence.criteria.Predicate;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
+import java.util.*;
 
 /**
  * @author by xf
@@ -37,6 +37,9 @@ public class TaskApi {
     @Autowired
     private MarkTaskRepo markTaskRepo;
 
+    @Autowired
+    private MarkLogRepo markLogRepo;
+
     /**
      * 任务管理查询
      * @param workId
@@ -77,6 +80,8 @@ public class TaskApi {
                     .getContent().stream().findFirst();
             if(taskOptional.isPresent()){
                 paperDTO = paperAssembler.toDTO(taskOptional.get().getPaper());
+                //设置为任务的密号
+                paperDTO.setSn(taskOptional.get().getSecretNumber());
             }
         }
         return paperDTO;
@@ -86,32 +91,41 @@ public class TaskApi {
     /**
      * 重评
      * @param paperId
-     * @param ranges
+     * @param secretNumber
      * @return
      */
+    @Transactional
     @RequestMapping("/reevaluation")
     public boolean reevaluation(@RequestParam("paperId") Long paperId,
-                                @RequestParam("rangs") String ranges){
+                                @RequestParam("secretNumber") String secretNumber){
         Paper paper = paperRepo.findOne(paperId);
         paper.reject(null);
         //重评后撤销标准卷
 //        paper.setSample(false);
-        List<MarkTask> markTasks = markTaskRepo.findByPaperIdAndStage(paper.getId(), MarkStage.LEVEL);
-        for (MarkTask markTask : markTasks) {
-            String[] range = ranges.split(",");
-            if(range.length > 0){
-                for (String r : range) {
-                    if(Objects.equals(String.valueOf(markTask.getMarkerId()), r)){
-                        markTask.setRejected(true);
-                        markTask.setOriginLevel(markTask.getResult());
-                        markTask.setResult(null);
-//                        markTask.setActive(false);
-                    }
-                }
-            }
+        MarkTask markTask = markTaskRepo.findByPaperIdAndSecretNumber(paperId, secretNumber);
+        if(markTask != null){
+            markTask.setRejected(true);
+            markTask.setOriginLevel(markTask.getResult());
+            markTask.setResult(null);
         }
-        markTaskRepo.save(markTasks);
+        markTaskRepo.save(markTask);
         paperRepo.save(paper);
+
+        //记录日志
+        MarkLog markLog = new MarkLog();
+        markLog.setExamNumber(paper.getExamNumber());
+        markLog.setWorkId(paper.getWorkId());
+        markLog.setPaperId(paperId);
+        markLog.setSubject(paper.getSubject().toString());
+        markLog.setCreateRole("管理员");
+        markLog.setCreateTime(new Date());
+        markLog.setCreateUserId(0L);
+        markLog.setCreateUserName("admin-cy");
+        markLog.setOperType(5);
+        markLog.setStage(MarkStage.LEVEL);
+        markLog.setStudentName(paper.getStudentName());
+        markLogRepo.save(markLog);
+
         return true;
     }