xiaof преди 4 години
родител
ревизия
e5401ecac5

+ 20 - 20
stmms-ms-admin/src/main/java/cn/com/qmth/stmms/ms/admin/api/ParamApi.java

@@ -1,5 +1,6 @@
 package cn.com.qmth.stmms.ms.admin.api;
 
+import cn.com.qmth.stmms.ms.core.cache.ParamCache;
 import cn.com.qmth.stmms.ms.core.domain.MarkSubject;
 import cn.com.qmth.stmms.ms.core.domain.Paper;
 import cn.com.qmth.stmms.ms.core.domain.ParamSetting;
@@ -12,12 +13,11 @@ import cn.com.qmth.stmms.ms.core.repository.ParamSettingRepo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
+import java.util.Arrays;
 import java.util.List;
+import java.util.Map;
 import java.util.Objects;
 
 /**
@@ -83,6 +83,7 @@ public class ParamApi {
         paramSetting.setNameRule(nameRule);
         paramSetting.setPaperStage(paperStage);
         paramSettingRepo.saveAndFlush(paramSetting);
+        ParamCache.resetParam(paramSetting);
 
         return new ResponseEntity(HttpStatus.OK);
     }
@@ -105,19 +106,19 @@ public class ParamApi {
                                            @RequestParam Integer majority,
                                            @RequestParam Integer cumulativeError,
                                            @RequestParam Integer levelShowAllPaper) {
-        List<MarkSubject> markSubjects = markSubjectRepo.findByWorkIdAndTestNot(workId, TrialEnum.DEFAULT.ordinal());
+        List<MarkSubject> markSubjects = markSubjectRepo.findByWorkIdAndTestNotIn(workId, Arrays.asList(TrialEnum.DEFAULT.ordinal(), TrialEnum.START_FORMAL.ordinal()));
         List<MarkTask> markTasks = markTaskRepo.findByWorkId(workId);
         boolean flag = false;
-        if((markSubjects == null || markSubjects.size() == 0) && (markTasks != null && markTasks.size() > 0)){
+        if ((markSubjects == null || markSubjects.size() == 0) && (markTasks != null && markTasks.size() > 0)) {
             flag = true;
         }
 
         //保存分档参数
         ParamSetting paramSetting = paramSettingRepo.findByWorkId(workId);
-        if(flag && (!Objects.equals(deviation, paramSetting.getDeviation())
+        if (flag && (!Objects.equals(deviation, paramSetting.getDeviation())
                 || !Objects.equals(autoCallback, paramSetting.getAutoCallback())
                 || !Objects.equals(majority, paramSetting.getMajority())
-                || !Objects.equals(cumulativeError, paramSetting.getCumulativeError()))){
+                || !Objects.equals(cumulativeError, paramSetting.getCumulativeError()))) {
             throw new RuntimeException("该评卷工作已有评卷数据,不能修改");
         }
         if (paramSetting == null) {
@@ -129,6 +130,7 @@ public class ParamApi {
         paramSetting.setCumulativeError(cumulativeError);
         paramSetting.setLevelShowAllPaper(levelShowAllPaper);
         paramSettingRepo.saveAndFlush(paramSetting);
+        ParamCache.resetParam(paramSetting);
 
         return new ResponseEntity(HttpStatus.OK);
     }
@@ -136,28 +138,25 @@ public class ParamApi {
     /**
      * 打分改档参数
      *
-     * @param workId
-     * @param roundUp
-     * @param changeStage
-     * @param scoreShowAllPaper
      * @return
      */
     @RequestMapping(value = "/score", method = RequestMethod.POST)
-    public ResponseEntity updateScoreParam(@RequestParam Long workId,
-                                           @RequestParam Integer roundUp,
-                                           @RequestParam Integer changeStage,
-                                           @RequestParam Integer scoreShowAllPaper) {
-        List<MarkSubject> markSubjects = markSubjectRepo.findByWorkIdAndTestNot(workId, TrialEnum.DEFAULT.ordinal());
+    public ResponseEntity updateScoreParam(@RequestBody Map map) {
+        Long workId = Long.valueOf(map.get("workId").toString());
+        Integer roundUp = (Integer) map.get("roundUp");
+        Integer changeStage = (Integer) map.get("changeStage");
+        Integer scoreShowAllPaper = (Integer) map.get("scoreShowAllPaper");
+        List<MarkSubject> markSubjects = markSubjectRepo.findByWorkIdAndTestNotIn(workId, Arrays.asList(TrialEnum.DEFAULT.ordinal(), TrialEnum.START_FORMAL.ordinal()));
         List<MarkTask> markTasks = markTaskRepo.findByWorkId(workId);
         boolean flag = false;
-        if((markSubjects == null || markSubjects.size() == 0) && (markTasks != null && markTasks.size() > 0)){
+        if ((markSubjects == null || markSubjects.size() == 0) && (markTasks != null && markTasks.size() > 0)) {
             flag = true;
         }
 
         //保存打分参数
         ParamSetting paramSetting = paramSettingRepo.findByWorkId(workId);
-        if(flag && (!Objects.equals(roundUp, paramSetting.getRoundUp())
-                || !Objects.equals(changeStage, paramSetting.getChangeStage()))){
+        if (flag && (!Objects.equals(roundUp, paramSetting.getRoundUp())
+                || !Objects.equals(changeStage, paramSetting.getChangeStage()))) {
             throw new RuntimeException("该评卷工作已有评卷数据,不能修改");
         }
         if (paramSetting == null) {
@@ -167,6 +166,7 @@ public class ParamApi {
         paramSetting.setChangeStage(changeStage);
         paramSetting.setScoreShowAllPaper(scoreShowAllPaper);
         paramSettingRepo.saveAndFlush(paramSetting);
+        ParamCache.resetParam(paramSetting);
 
         return new ResponseEntity(HttpStatus.OK);
     }

+ 61 - 0
stmms-ms-admin/src/main/java/cn/com/qmth/stmms/ms/admin/dto/OneClickExpDTO.java

@@ -0,0 +1,61 @@
+package cn.com.qmth.stmms.ms.admin.dto;
+
+import cn.com.qmth.stmms.ms.commons.utils.excel.ExcelProperty;
+
+public class OneClickExpDTO {
+
+    @ExcelProperty(name = "科目", index = 0, type = 1)
+    private String subject;
+
+    @ExcelProperty(name = "序号", index = 1, type = 1)
+    private Integer seqNo;
+
+    @ExcelProperty(name = "考号", index = 2, type = 1)
+    private String examNumber;
+
+    @ExcelProperty(name = "原档位", index = 3, type = 1)
+    private String originLevel;
+
+    @ExcelProperty(name = "复审后档位", index = 4, type = 1)
+    private String level;
+
+    public String getSubject() {
+        return subject;
+    }
+
+    public void setSubject(String subject) {
+        this.subject = subject;
+    }
+
+    public Integer getSeqNo() {
+        return seqNo;
+    }
+
+    public void setSeqNo(Integer seqNo) {
+        this.seqNo = seqNo;
+    }
+
+    public String getExamNumber() {
+        return examNumber;
+    }
+
+    public void setExamNumber(String examNumber) {
+        this.examNumber = examNumber;
+    }
+
+    public String getOriginLevel() {
+        return originLevel;
+    }
+
+    public void setOriginLevel(String originLevel) {
+        this.originLevel = originLevel;
+    }
+
+    public String getLevel() {
+        return level;
+    }
+
+    public void setLevel(String level) {
+        this.level = level;
+    }
+}

+ 36 - 3
stmms-ms-admin/src/main/java/cn/com/qmth/stmms/ms/admin/exporter/PaperExporter.java

@@ -1,12 +1,12 @@
 package cn.com.qmth.stmms.ms.admin.exporter;
 
+import cn.com.qmth.stmms.ms.admin.dto.OneClickExpDTO;
 import cn.com.qmth.stmms.ms.admin.dto.PaperExpDTO;
 import cn.com.qmth.stmms.ms.admin.dto.SampleExpDTO;
 import cn.com.qmth.stmms.ms.admin.dto.ScoreDTO;
 import cn.com.qmth.stmms.ms.commons.utils.excel.ExportUtils;
-import cn.com.qmth.stmms.ms.core.domain.MarkSubject;
-import cn.com.qmth.stmms.ms.core.domain.Paper;
-import cn.com.qmth.stmms.ms.core.domain.Work;
+import cn.com.qmth.stmms.ms.core.domain.*;
+import cn.com.qmth.stmms.ms.core.repository.MarkLogRepo;
 import cn.com.qmth.stmms.ms.core.repository.MarkSubjectRepo;
 import cn.com.qmth.stmms.ms.core.repository.PaperRepo;
 import cn.com.qmth.stmms.ms.core.vo.Subject;
@@ -31,6 +31,9 @@ public class PaperExporter {
     @Autowired
     private PaperRepo paperRepo;
 
+    @Autowired
+    MarkLogRepo markLogRepo;
+
     @Autowired
     private MarkSubjectRepo markSubjectRepo;
 
@@ -78,4 +81,34 @@ public class PaperExporter {
         }
         ExportUtils.exportEXCEL("标准卷信息", SampleExpDTO.class, sampleExpDTOS, response);
     }
+
+    /**
+     * 一键定档导出
+     * @param workId
+     * @param subject
+     * @param response
+     */
+    @GetMapping("{workId}/{subject}/oneClick")
+    public void exportOneClick(@PathVariable Long workId, @PathVariable Subject subject, HttpServletResponse response){
+        MarkSubject markSubject = markSubjectRepo.findOne(workId+"-"+subject.name());
+        //科目名称
+        String subjectName = Objects.isNull(markSubject) ? subject.name() : markSubject.getName();
+        List<OneClickExpDTO> oneClickExpDTOS = new ArrayList<>();
+        List<Paper> papers = paperRepo.findByWorkIdAndSubjectAndIsOneClickTrue(workId, subject);
+        if(papers != null && papers.size() >0) {
+            List<Long> paperIds = papers.stream().map(Paper::getId).collect(Collectors.toList());
+            List<MarkLog> marklogs = markLogRepo.findByWorkIdAndSubjectAndOperTypeAndPaperIdIn(workId, subject, MarkLogOperType.ONE_CLICK_LEVEl, paperIds);
+            for (int i = 1; i <= marklogs.size(); i++) {
+                MarkLog markLog = marklogs.get(i);
+                OneClickExpDTO oneClickExpDTO = new OneClickExpDTO();
+                oneClickExpDTO.setSubject(subjectName);
+                oneClickExpDTO.setSeqNo(i);
+                oneClickExpDTO.setExamNumber(markLog.getExamNumber());
+                oneClickExpDTO.setOriginLevel(markLog.getOperDataBefore());
+                oneClickExpDTO.setLevel(markLog.getOperDataAfter());
+                oneClickExpDTOS.add(oneClickExpDTO);
+            }
+            ExportUtils.exportEXCEL("专家复评导出", OneClickExpDTO.class, oneClickExpDTOS, response);
+        }
+    }
 }

+ 13 - 0
stmms-ms-core/src/main/java/cn/com/qmth/stmms/ms/core/domain/Paper.java

@@ -138,6 +138,11 @@ public class Paper implements Serializable {
 
     private boolean isShiftScore;
 
+    /**
+     * 是否一键定档
+     */
+    private boolean isOneClick;
+
     public int getTest() {
         return test;
     }
@@ -516,4 +521,12 @@ public class Paper implements Serializable {
     public void setShiftScore(boolean shiftScore) {
         isShiftScore = shiftScore;
     }
+
+    public boolean isOneClick() {
+        return isOneClick;
+    }
+
+    public void setOneClick(boolean oneClick) {
+        isOneClick = oneClick;
+    }
 }

+ 2 - 0
stmms-ms-core/src/main/java/cn/com/qmth/stmms/ms/core/repository/ExamQuestionRepo.java

@@ -36,4 +36,6 @@ public interface ExamQuestionRepo extends JpaRepository<ExamQuestion, Long> {
 
     @Query("select distinct s.areaCode, s.areaName from ExamQuestion s where s.workId = ?1")
     List<Object[]> findByWorkId(Long workId);
+
+    List<ExamQuestion> findByWorkIdAndSubjectAndTestNot(Long workId, Subject subject, int id);
 }

+ 5 - 0
stmms-ms-core/src/main/java/cn/com/qmth/stmms/ms/core/repository/MarkLogRepo.java

@@ -1,6 +1,9 @@
 package cn.com.qmth.stmms.ms.core.repository;
 
 import cn.com.qmth.stmms.ms.core.domain.MarkLog;
+import cn.com.qmth.stmms.ms.core.domain.MarkLogOperType;
+import cn.com.qmth.stmms.ms.core.domain.Paper;
+import cn.com.qmth.stmms.ms.core.vo.Subject;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.repository.JpaRepository;
@@ -36,4 +39,6 @@ public interface MarkLogRepo extends JpaRepository<MarkLog, Long>, JpaSpecificat
 
     @Query("select distinct s.createUserName as createUserName, max(s.id) as id from MarkLog s where s.createRole = '采集员' and s.workId = ?1 group by s.createUserName")
     Page<Map> findByWorkId(@Param("workId") Long workId, Pageable pageable);
+
+    List<MarkLog> findByWorkIdAndSubjectAndOperTypeAndPaperIdIn(Long workId, Subject subject, MarkLogOperType one_click_levEl, List<Long> paperIds);
 }

+ 1 - 1
stmms-ms-core/src/main/java/cn/com/qmth/stmms/ms/core/repository/MarkSubjectRepo.java

@@ -24,5 +24,5 @@ public interface MarkSubjectRepo extends JpaRepository<MarkSubject,String> {
      */
     List<MarkSubject> findAllByWorkIdAndEnableTrue(Long workId);
 
-    List<MarkSubject> findByWorkIdAndTestNot(Long workId, int ordinal);
+    List<MarkSubject> findByWorkIdAndTestNotIn(Long workId, List<Integer> ints);
 }

+ 27 - 3
stmms-ms-core/src/main/java/cn/com/qmth/stmms/ms/core/repository/MarkTaskRepo.java

@@ -44,12 +44,20 @@ public interface MarkTaskRepo extends JpaRepository<MarkTask, Long>, JpaSpecific
     @Query(value = "select count(1) from mark_task m inner join paper p on m.paper_id = p.id and p.score_batch_no = ?2 where m.question_id = ?1 and m.marker_id = ?3", nativeQuery = true)
     long countScoreByQuestionId(Long questionId, Long batchNo, Long markerId);
 
-    @Query(value = "select count(1) from mark_task m inner 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 = ?4 and p.batch_no = ?5", nativeQuery = true)
+    @Query(value = "select count(1) from mark_task m inner join paper p on m.paper_id = p.id and p.score_batch_no is not null where m.question_id = ?1 and m.marker_id = ?2", nativeQuery = true)
+    long countScoreByQuestionIdAll(Long questionId, Long markerId);
+
+    @Query(value = "select count(1) from mark_task m inner 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 = ?4 and p.batch_no = ?5 and p.is_rejected = false", nativeQuery = true)
     int countByQuestionIdAndMarkerIdAndStageAndResult(Long questionId, Long markerId, int stage, String result, Long batchNo);
 
+    @Query(value = "select count(1) from mark_task m inner 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 = ?4 and p.batch_no is not null and p.is_rejected = false ", nativeQuery = true)
+    int countByQuestionIdAndMarkerIdAndStageAndResultAll(Long questionId, Long markerId, int stage, String result);
+
     @Query(value = "select count(1) from mark_task m inner join paper p on m.paper_id = p.id where m.question_id = ?1 and m.marker_id = ?2 and m.stage = ?3 and p.level = ?4 and p.score_batch_no = ?5 and m.result is not null", nativeQuery = true)
     int countScoreByQuestionIdAndMarkerIdAndStageAndResult(Long questionId, Long markerId, int stage, String result, Long batchNo);
 
+    @Query(value = "select count(1) from mark_task m inner join paper p on m.paper_id = p.id where m.question_id = ?1 and m.marker_id = ?2 and m.stage = ?3 and p.level = ?4 and p.score_batch_no is not null and m.result is not null", nativeQuery = true)
+    int countScoreByQuestionIdAndMarkerIdAndStageAndResultAll(Long questionId, Long markerId, int stage, String result);
     /**
      * 查询评卷员的评卷任务
      *
@@ -161,18 +169,24 @@ 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 inner join paper p on m.paper_id = p.id and p.is_missing = ?4 and p.batch_no = ?5 where m.question_id = ?1 and m.marker_id = ?2 and m.stage = ?3 and m.result is null", nativeQuery = true)
+    @Query(value = "SELECT count(1) from mark_task m inner join paper p on m.paper_id = p.id and p.is_missing = ?4 and p.batch_no = ?5 where m.question_id = ?1 and m.marker_id = ?2 and m.stage = ?3 and m.result is null and p.is_rejected = false", nativeQuery = true)
     int countByQuestionIdAndMarkerIdAndStageAndResultIsNullAndIsMissing(Long questionId, Long markerId, int stage, boolean isMissing, Long batchNo);
 
     @Query(value = "SELECT count(1) from mark_task m inner join paper p on m.paper_id = p.id and p.is_missing = ?4 and p.score_batch_no = ?5 where m.question_id = ?1 and m.marker_id = ?2 and m.stage = ?3 and m.result is null and p.is_shift = 0 and p.is_shift_score = 0", nativeQuery = true)
     int countScoreByQuestionIdAndMarkerIdAndStageAndResultIsNullAndIsMissing(Long questionId, Long markerId, int stage, boolean isMissing, Long batchNo);
 
-    @Query(value = "SELECT count(1) from mark_task m inner join paper p on m.paper_id = p.id and p.is_missing = ?4 and p.batch_no = ?5 where m.question_id = ?1 and m.marker_id = ?6 and m.stage = ?2 and m.result =?3", nativeQuery = true)
+    @Query(value = "SELECT count(1) from mark_task m inner join paper p on m.paper_id = p.id and p.is_missing = ?4 and p.score_batch_no is not null where m.question_id = ?1 and m.marker_id = ?2 and m.stage = ?3 and m.result is null and p.is_shift = 0 and p.is_shift_score = 0", nativeQuery = true)
+    int countScoreByQuestionIdAndMarkerIdAndStageAndResultIsNullAndIsMissingAll(Long questionId, Long markerId, int stage, boolean isMissing);
+
+    @Query(value = "SELECT count(1) from mark_task m inner join paper p on m.paper_id = p.id and p.is_missing = ?4 and p.batch_no = ?5 where m.question_id = ?1 and m.marker_id = ?6 and m.stage = ?2 and m.result =?3 and p.is_rejected = false", nativeQuery = true)
     int countByQuestionIdAndStageAndResultAndIsMissing(Long questionId, int stage, String result, boolean isMissing,Long batchNo,Long markerId);
 
     @Query(value = "SELECT count(1) from mark_task m inner join paper p on m.paper_id = p.id and p.is_missing = ?4 and p.score_batch_no = ?5 where m.question_id = ?1 and m.marker_id = ?6 and m.stage = ?2 and p.level =?3 and m.result is not null", nativeQuery = true)
     int countScoreByQuestionIdAndStageAndResultAndIsMissing(Long questionId, int stage, String result, boolean isMissing,Long batchNo,Long markerId);
 
+    @Query(value = "SELECT count(1) from mark_task m inner join paper p on m.paper_id = p.id and p.is_missing = ?4 and p.score_batch_no is not null where m.question_id = ?1 and m.marker_id = ?5 and m.stage = ?2 and p.level =?3 and m.result is not null", nativeQuery = true)
+    int countScoreByQuestionIdAndStageAndResultAndIsMissingAll(Long questionId, int stage, String result, boolean isMissing,Long markerId);
+
     MarkTask findByPaperIdAndMarkerId(Long paperId, Long markId);
 
     List<MarkTask> findByWorkId(Long workId);
@@ -182,4 +196,14 @@ public interface MarkTaskRepo extends JpaRepository<MarkTask, Long>, JpaSpecific
 
     @Query(value = "SELECT count(1) from mark_task m inner join paper p on m.paper_id = p.id and p.is_missing = ?4 where m.question_id = ?1 and m.marker_id = ?2 and m.stage = ?3 and m.result is null and p.is_shift = 0 and p.is_shift_score = 1", nativeQuery = true)
     int countShiftScoreByQuestionIdAndMarkerIdAndStageAndResultIsNullAndIsMissing(Long questionId, Long id, int ordinal, boolean b);
+
+    @Query(value = "select count(1) from mark_task m inner join paper p on m.paper_id = p.id and p.batch_no is not null where m.question_id = ?1 and m.marker_id = ?2", nativeQuery = true)
+    long countByQuestionIdAll(Long questionId, Long markId);
+
+    @Query(value = "SELECT count(1) from mark_task m inner join paper p on m.paper_id = p.id and p.is_missing = ?4 and p.batch_no is not null where m.question_id = ?1 and m.marker_id = ?2 and m.stage = ?3 and m.result is null and p.is_rejected = false", nativeQuery = true)
+    int countByQuestionIdAndMarkerIdAndStageAndResultIsNullAndIsMissingAll(Long questionId, Long markerId, int stage, boolean isMissing);
+
+    @Query(value = "SELECT count(1) from mark_task m inner join paper p on m.paper_id = p.id and p.is_missing = ?4 and p.batch_no is not null where m.question_id = ?1 and m.marker_id = ?5 and m.stage = ?2 and m.result =?3 and p.is_rejected = false", nativeQuery = true)
+    int countByQuestionIdAndStageAndResultAndIsMissingAll(Long questionId, int stage, String result, boolean isMissing,Long markerId);
+
 }

+ 2 - 0
stmms-ms-core/src/main/java/cn/com/qmth/stmms/ms/core/repository/PaperRepo.java

@@ -312,5 +312,7 @@ public interface PaperRepo extends JpaRepository<Paper, Long>, JpaSpecificationE
 
     int countByWorkIdAndSubjectAndScoreNotNullAndIsMissingFalseAndActiveTrueAndTest(Long workId, Subject subject, int i);
 
+    List<Paper> findByWorkIdAndSubjectAndIsOneClickTrue(Long workId, Subject subject);
+
 //    List<Paper> findByWorkIdAndSubjectAndInspectRange(Long workId, Subject subject, Long inspectRange);
 }

+ 12 - 0
stmms-ms-log/src/main/java/cn/com/qmth/stmms/ms/log/aop/MarkLogAop.java

@@ -128,17 +128,23 @@ public class MarkLogAop {
         JSONObject jsonObjectResult = (JSONObject) jsonArgsArray.get(1);
         String action = null;
         Integer operType = null;
+        String originLevel = null;
         if (Objects.nonNull(jsonObjectResult) && Objects.nonNull(jsonObjectResult.get(ACTION))) {
             action = (String) jsonObjectResult.get(ACTION);
             if (Objects.equals(SAMPLING, action)) {
                 //标准卷设置
                 operType = MarkLogOperType.CRITERION_PAPER_SET.getId();
+                paper.setOneClick(false);
             } else if (Objects.equals(LEVELING, action)) {
                 //定档设置
                 operType = MarkLogOperType.ONE_CLICK_LEVEl.getId();
+                //原始档位
+                originLevel = Objects.nonNull(jsonObjectResult.get("originLevel")) ? (String) jsonObjectResult.get("originLevel") : null;
+                paper.setOneClick(true);
             } else if (Objects.equals(REJECT, action)) {
                 //档位打回设置
                 operType = MarkLogOperType.CALLBACK_LEVEl.getId();
+                paper.setOneClick(false);
             }
         }
         //标准卷设置、定档设置、档位打回start
@@ -147,11 +153,17 @@ public class MarkLogAop {
         if (Objects.nonNull(markLogPrev)) {
             operResult = Optional.ofNullable(markLogPrev.getOperDataAfter()).orElse(DEFAULT_RESULT);
         }
+        if (Objects.equals(LEVELING, action)) {
+            //定档设置
+            operResult = originLevel;
+        }
         Work work = workRepo.findOne(paper.getWorkId());
         MarkLog markLog = new MarkLog(markUser.getId(), markUser.getName(), markUser.getRole(), markUser.getSubject(), paper.getExamNumber(), paper.getStudentName(), operType, paper.getWorkId(), paper.getId(), MarkStage.LEVEL, operResult, String.valueOf(jsonObjectResult.get(LEVEL)), null, work.getName());
         LOGGER.info("markLog:{}", JSONObject.toJSONString(markLog));
         //标准卷设置、定档设置、档位打回end
         markLogRepo.save(markLog);
+        //更新
+        paperRepo.save(paper);
     }
 
     /**

+ 5 - 1
stmms-ms-marking/src/main/java/cn/com/qmth/stmms/ms/marking/api/ExamQuestionApi.java

@@ -38,7 +38,11 @@ public class ExamQuestionApi {
     @RequestMapping(method = RequestMethod.GET)
     public List<ExamQuestion> list(@RequestParam Long workId, @RequestParam Subject subject) {
         if (!imageConfig.isCustomSubject()) {
-            return examQuestionRepo.findByWorkIdAndSubjectAndTest(workId, subject, TrialEnum.DEFAULT.getId());
+            List<ExamQuestion> questions = examQuestionRepo.findByWorkIdAndSubjectAndTestNot(workId, subject, TrialEnum.DEFAULT.getId());
+            if(questions == null || questions.size() == 0){
+                questions = examQuestionRepo.findByWorkIdAndSubjectAndTest(workId, subject, TrialEnum.DEFAULT.getId());
+            }
+            return questions;
         } else {
             return examQuestionRepo.findByWorkIdAndSubjectAndTest(workId, Subject.CUSTOM, TrialEnum.DEFAULT.getId());
         }

+ 44 - 33
stmms-ms-marking/src/main/java/cn/com/qmth/stmms/ms/marking/api/MakrerApi.java

@@ -2,6 +2,7 @@ package cn.com.qmth.stmms.ms.marking.api;
 
 import cn.com.qmth.stmms.ms.commons.threadPool.MyThreadPool;
 import cn.com.qmth.stmms.ms.commons.utils.SqlUtil;
+import cn.com.qmth.stmms.ms.core.cache.ParamCache;
 import cn.com.qmth.stmms.ms.core.domain.Level;
 import cn.com.qmth.stmms.ms.core.domain.MarkStage;
 import cn.com.qmth.stmms.ms.core.domain.MarkSubject;
@@ -16,6 +17,7 @@ import cn.com.qmth.stmms.ms.marking.assembler.LevelStatAssembler;
 import cn.com.qmth.stmms.ms.marking.assembler.MarkerAssembler;
 import cn.com.qmth.stmms.ms.marking.assembler.QuestionStatAssembler;
 import cn.com.qmth.stmms.ms.marking.dto.*;
+import javassist.bytecode.stackmap.BasicBlock;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
@@ -141,7 +143,12 @@ public class MakrerApi {
             public Map<String, Long> call() throws Exception {
                 Map<String, Long> map = new HashMap<>();
                 //当前老师当前试卷的评档次数(不分档位)
-                long kdtotal = markTaskRepo.countByQuestionId(questionId, batchNo, marker.getId());
+                long kdtotal;
+                if (ParamCache.paramMap.get(marker.getWorkId()).getLevelShowAllPaper() == 1) {
+                    kdtotal = markTaskRepo.countByQuestionIdAll(questionId, marker.getId());
+                } else {
+                    kdtotal = markTaskRepo.countByQuestionId(questionId, batchNo, marker.getId());
+                }
                 //当前老师所有的评档次数(不分档位)
                 long total = paperRepo.countByWorkIdAndQuestionId(markSubject.getWorkId(), questionId);
                 map.put("kdtotal", kdtotal);
@@ -156,12 +163,20 @@ public class MakrerApi {
                     levelStatDTO.setGcount(levelStatDTO.getCount());
                     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, batchNo);
+                        int count;
+                        if (ParamCache.paramMap.get(marker.getWorkId()).getLevelShowAllPaper() == 1) {
+                            count = markTaskRepo.countByQuestionIdAndMarkerIdAndStageAndResultIsNullAndIsMissingAll(questionId, marker.getId(), MarkStage.LEVEL.ordinal(), false);
+                        } else {
+                            count = markTaskRepo.countByQuestionIdAndMarkerIdAndStageAndResultIsNullAndIsMissing(questionId, marker.getId(), MarkStage.LEVEL.ordinal(), false, batchNo);
+                        }
                         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, batchNo, marker.getId());
+                        int count;
+                        if (ParamCache.paramMap.get(marker.getWorkId()).getLevelShowAllPaper() == 1) {
+                            count = markTaskRepo.countByQuestionIdAndStageAndResultAndIsMissingAll(questionId, MarkStage.LEVEL.ordinal(), levelStatDTO.getId().toString(), false, marker.getId());
+                        } else {
+                            count = markTaskRepo.countByQuestionIdAndStageAndResultAndIsMissing(questionId, MarkStage.LEVEL.ordinal(), levelStatDTO.getId().toString(), false, batchNo, marker.getId());
+                        }
                         levelStatDTO.setCount(count);
                     }
                     levelStatDTOs.add(levelStatDTO);
@@ -176,7 +191,12 @@ public class MakrerApi {
                 dto.setPercent(0.0);
 
                 //当前老师当前档位评档次数(所有考试)
-                int countNew = markTaskRepo.countByQuestionIdAndStageAndResultAndIsMissing(questionId, MarkStage.LEVEL.ordinal(), level.getCode(), false, batchNo, marker.getId());
+                int countNew;
+                if (ParamCache.paramMap.get(marker.getWorkId()).getLevelShowAllPaper() == 1) {
+                    countNew = markTaskRepo.countByQuestionIdAndStageAndResultAndIsMissingAll(questionId, MarkStage.LEVEL.ordinal(), level.getCode(), false, marker.getId());
+                } else {
+                    countNew = markTaskRepo.countByQuestionIdAndStageAndResultAndIsMissing(questionId, MarkStage.LEVEL.ordinal(), level.getCode(), false, batchNo, marker.getId());
+                }
 //                dto.setPercent(countNew == 0 ? 0D : dto.getPercent());
                 dto.setCount(countNew);
                 levelStatDTOs.add(dto);
@@ -208,8 +228,12 @@ public class MakrerApi {
                 double gp = (double) o.getGcount() / finalTotal;
                 BigDecimal gbd = new BigDecimal(gp).setScale(3, RoundingMode.HALF_EVEN);
                 o.setGpercent(gbd.doubleValue());
-
-                int count = markTaskRepo.countByQuestionIdAndMarkerIdAndStageAndResult(questionId, marker.getId(), MarkStage.LEVEL.ordinal(), o.getId().toString(), batchNo);
+                int count;
+                if (ParamCache.paramMap.get(marker.getWorkId()).getLevelShowAllPaper() == 1) {
+                    count = markTaskRepo.countByQuestionIdAndMarkerIdAndStageAndResultAll(questionId, marker.getId(), MarkStage.LEVEL.ordinal(), o.getId().toString());
+                } else {
+                    count = markTaskRepo.countByQuestionIdAndMarkerIdAndStageAndResult(questionId, marker.getId(), MarkStage.LEVEL.ordinal(), o.getId().toString(), batchNo);
+                }
                 o.setPercent(count == 0 ? 0 : o.getPercent());
                 o.setCount(count);
             }
@@ -251,28 +275,6 @@ public class MakrerApi {
                 return map;
             }
         });
-        //统计workId下各考点的数量
-//        paperRepo.countScoreGroupByLevel(questionId, batchNo)
-//                .forEach(o -> {
-//                    LevelStatDTO levelStatDTO = levelStatAssembler.toScoreDTO(o);
-//                    levelStatDTO.setGcount(levelStatDTO.getCount());
-//                    if (Objects.isNull(levelStatDTO.getId())) {
-//                        //求任务数为null的条数
-//                        int count = markTaskRepo.countScoreByQuestionIdAndMarkerIdAndStageAndResultIsNullAndIsMissing(questionId, marker.getId(), MarkStage.SCORE.ordinal(), false, batchNo);
-//                        levelStatDTO.setCount(count);
-//                        //查询改档
-//                        int shiftCount = markTaskRepo.countShiftByQuestionIdAndMarkerIdAndStageAndResultIsNullAndIsMissing(questionId, marker.getId(), MarkStage.LEVEL.ordinal(), false, batchNo);
-//                        levelStatDTO.setShift(shiftCount);
-//                        //查询改档打分
-//                        int shiftScoreCount = markTaskRepo.countShiftScoreByQuestionIdAndMarkerIdAndStageAndResultIsNullAndIsMissing(questionId, marker.getId(), MarkStage.SCORE.ordinal(), false, batchNo);
-//                        levelStatDTO.setShiftScore(shiftScoreCount - shiftCount);
-//                    }
-////                    else {
-////                        int count = markTaskRepo.countScoreByQuestionIdAndStageAndResultAndIsMissing(questionId, MarkStage.SCORE.ordinal(), levelStatDTO.getId().toString(), false, batchNo, marker.getId());
-////                        levelStatDTO.setCount(count);
-////                    }
-//                    levelStatDTOs.add(levelStatDTO);
-//                });
         LevelStatDTO levelStatDTO = new LevelStatDTO();
         //求任务数为null的条数
         int totalCount = markTaskRepo.countScoreByQuestionIdAndMarkerIdAndStageAndResultIsNullAndIsMissing(questionId, marker.getId(), MarkStage.SCORE.ordinal(), false, batchNo);
@@ -295,8 +297,12 @@ public class MakrerApi {
                 dto.setPercent(0.0);
 
                 //当前老师当前档位评档次数(所有考试)
-                int countNew = markTaskRepo.countScoreByQuestionIdAndStageAndResultAndIsMissing(questionId, MarkStage.SCORE.ordinal(), level.getCode(), false, batchNo, marker.getId());
-//                dto.setPercent(countNew == 0 ? 0D : dto.getPercent());
+                int countNew;
+                if (ParamCache.paramMap.get(marker.getWorkId()).getScoreShowAllPaper() == 1) {
+                    countNew = markTaskRepo.countScoreByQuestionIdAndStageAndResultAndIsMissingAll(questionId, MarkStage.SCORE.ordinal(), level.getCode(), false, marker.getId());
+                } else {
+                    countNew = markTaskRepo.countScoreByQuestionIdAndStageAndResultAndIsMissing(questionId, MarkStage.SCORE.ordinal(), level.getCode(), false, batchNo, marker.getId());
+                }
                 dto.setCount(countNew);
                 levelStatDTOs.add(dto);
             }
@@ -324,7 +330,12 @@ public class MakrerApi {
                 BigDecimal gbd = new BigDecimal(gp).setScale(3, RoundingMode.HALF_EVEN);
                 o.setGpercent(gbd.doubleValue());
 
-                int count = markTaskRepo.countScoreByQuestionIdAndMarkerIdAndStageAndResult(questionId, marker.getId(), MarkStage.SCORE.ordinal(), o.getId().toString(), batchNo);
+                int count;
+                if(ParamCache.paramMap.get(marker.getWorkId()).getScoreShowAllPaper() == 1){
+                    count = markTaskRepo.countScoreByQuestionIdAndMarkerIdAndStageAndResultAll(questionId, marker.getId(), MarkStage.SCORE.ordinal(), o.getId().toString());
+                } else {
+                    count = markTaskRepo.countScoreByQuestionIdAndMarkerIdAndStageAndResult(questionId, marker.getId(), MarkStage.SCORE.ordinal(), o.getId().toString(), batchNo);
+                }
                 o.setPercent(count == 0 ? 0 : o.getPercent());
                 o.setCount(count);
             }

+ 19 - 4
stmms-ms-marking/src/main/java/cn/com/qmth/stmms/ms/marking/api/MarkTaskApi.java

@@ -3,6 +3,7 @@ package cn.com.qmth.stmms.ms.marking.api;
 import cn.com.qmth.stmms.ms.commons.config.ScoreConfig;
 import cn.com.qmth.stmms.ms.commons.utils.SqlUtil;
 import cn.com.qmth.stmms.ms.commons.web.PageableDTO;
+import cn.com.qmth.stmms.ms.core.cache.ParamCache;
 import cn.com.qmth.stmms.ms.core.domain.*;
 import cn.com.qmth.stmms.ms.core.domain.enums.TrialEnum;
 import cn.com.qmth.stmms.ms.core.domain.task.MarkTask;
@@ -82,8 +83,10 @@ public class MarkTaskApi {
      */
     @RequestMapping(method = RequestMethod.GET)
     public PageableDTO list(@RequestParam Long markerId,
+                            @RequestParam Long workId,
                             @RequestParam MarkStage stage,
                             @RequestParam(required = false) Boolean isSample,
+                            @RequestParam(defaultValue = "false") Boolean reject,
                             @RequestParam(required = false) String level,
                             @RequestParam(required = false) String sn,
                             @RequestParam Long questionId,
@@ -105,21 +108,31 @@ public class MarkTaskApi {
                 }
             } else if (stage == MarkStage.LEVEL) {
                 //查询
-                Long batchNo = paperRepo.findByQuestionId(questionId);
                 predicates.add(builder.equal(root.get("result"), level));
-                if (!Objects.isNull(batchNo)) {
-                    predicates.add(builder.equal(root.get("paper").get("batchNo"), batchNo));
+                if(ParamCache.paramMap.get(workId).getLevelShowAllPaper() == 1) {
+                    Long batchNo = paperRepo.findByQuestionId(questionId);
+                    if (!Objects.isNull(batchNo)) {
+                        predicates.add(builder.equal(root.get("paper").get("batchNo"), batchNo));
+                    }
                 }
             } else if (stage == MarkStage.SCORE) {
-//                predicates.add(builder.isNotNull(root.get("result")));
+                Long batchNo = paperRepo.findScoreBatchNoByQuestionId(questionId);
                 predicates.add(builder.equal(root.get("paper").get("level"), level));
                 predicates.add(builder.isNotNull(root.get("result")));
                 predicates.add(builder.equal(root.get("paper").get("isShift"), false));
                 predicates.add(builder.equal(root.get("paper").get("isShiftScore"), false));
+                if(ParamCache.paramMap.get(workId).getScoreShowAllPaper() == 1){
+                    predicates.add(builder.isNotNull(root.get("paper").get("scoreBatchNo")));
+                } else {
+                    predicates.add(builder.equal(root.get("paper").get("scoreBatchNo"), batchNo));
+                }
             }
             if (isSample != null) {
                 predicates.add(builder.equal(root.get("paper").get("isSample"), isSample));
             }
+            if (reject != null) {
+                predicates.add(builder.equal(root.get("paper").get("isRejected"), reject));
+            }
             predicates.add(builder.equal(root.get("paper").get("isMissing"), false));
             predicates.add(builder.equal(root.get("paper").get("active"), true));
             //过滤考区
@@ -173,6 +186,7 @@ public class MarkTaskApi {
      */
     @RequestMapping(value = "/shift", method = RequestMethod.GET)
     public PageableDTO list(@RequestParam Long markerId,
+                            @RequestParam(required = false) Long workId,
                             @RequestParam(required = false) Boolean isShift,
                             @RequestParam(required = false) Boolean isShiftScore,
                             @RequestParam Long questionId,
@@ -298,6 +312,7 @@ public class MarkTaskApi {
                 if (!Objects.isNull(batchNo)) {
                     predicates.add(builder.equal(root.get("paper").get("batchNo"), batchNo));
                 }
+                predicates.add(builder.isNotNull(root.get("result")));
             } else if (stage == MarkStage.SCORE) {
                 predicates.add(builder.isNotNull(root.get("result")));
             }

+ 6 - 3
stmms-ms-marking/src/main/java/cn/com/qmth/stmms/ms/marking/service/AssignTaskService.java

@@ -118,7 +118,7 @@ public class AssignTaskService {
         markerGroups = markerGroups.stream().filter(m -> m.getMarkers().size() > 0).collect(Collectors.toList());
         int sum = markerGroups.stream().mapToInt(m -> m.getMarkers().size()).sum();
         int groupSize = markerGroups.size();
-        int idx = 0;
+        int idx = 0, seq=0;
         long currentTime = System.currentTimeMillis();
         Iterator<Paper> iterator = papers.iterator();
         List<MarkTask> markTaskList = new ArrayList<>(papers.size() * sum);
@@ -138,8 +138,10 @@ public class AssignTaskService {
                     markTask.setBatchNo(currentTime);
                     //是否显示序号
                     long display = taskList.stream().filter(m->Objects.equals(m.getCode(), paper.getLevel())&& m.getDisplayNumber() == 1).count();
-                    markTask.setSerialNumber(paper.getLevel() + (idx+1));
-                    markTask.setDisplayNumber((int) display);
+                    if(display !=0) {
+                        markTask.setSerialNumber(paper.getLevel() + (seq + 1));
+                        markTask.setDisplayNumber((int) display);
+                    }
                 } else {
                     markTask = new MarkTask(marker, paper, markSubject.getStage(), random, markSubject.getTest());
                 }
@@ -164,6 +166,7 @@ public class AssignTaskService {
                 }
             }
             idx++;
+            seq ++;
         }
         markTaskRepo.save(markTaskList);
         paperRepo.save(paperList);