Explorar el Código

线上版本-打分优化-20201116

xiaof hace 4 años
padre
commit
75b30c43c2

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

@@ -53,10 +53,10 @@ 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 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)
+    @Query(value = "select count(1) from mark_task m inner join paper p on m.paper_id = p.id and p.level = ?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 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 and p.score is not null", nativeQuery = true)
+    @Query(value = "select count(1) from mark_task m inner join paper p on m.paper_id = p.id and p.level = ?4 and p.score_batch_no is not null and p.score is not null where m.question_id = ?1 and m.marker_id = ?2 and m.stage = ?3 and m.result is not null", nativeQuery = true)
     int countScoreByQuestionIdAndMarkerIdAndStageAndResultAll(Long questionId, Long markerId, int stage, String result);
     /**
      * 查询评卷员的评卷任务
@@ -173,7 +173,7 @@ 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 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)
+    @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 and p.is_shift = 0 and p.is_shift_score = 0 where m.question_id = ?1 and m.marker_id = ?2 and m.stage = ?3 and m.result is null", 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.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)
@@ -192,10 +192,10 @@ public interface MarkTaskRepo extends JpaRepository<MarkTask, Long>, JpaSpecific
 
     List<MarkTask> findByWorkId(Long workId);
 
-    @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 = 1", 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.is_shift = 1 where m.question_id = ?1 and m.marker_id = ?2 and m.stage = ?3 and m.result is null", nativeQuery = true)
     int countShiftByQuestionIdAndMarkerIdAndStageAndResultIsNullAndIsMissing(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.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)
+    @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.is_shift = 0 and p.is_shift_score = 1 where m.question_id = ?1 and m.marker_id = ?2 and m.stage = ?3 and m.result is null", 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)

+ 9 - 8
stmms-ms-marking/src/main/java/cn/com/qmth/stmms/ms/marking/api/MakrerApi.java

@@ -277,10 +277,10 @@ public class MakrerApi {
             public Map<String, Long> call() throws Exception {
                 Map<String, Long> map = new HashMap<>();
                 //当前老师当前试卷的评档次数(不分档位)
-                long kdtotal = markTaskRepo.countScoreByQuestionId(questionId, batchNo, marker.getId());
+//                long kdtotal = markTaskRepo.countScoreByQuestionId(questionId, batchNo, marker.getId());
                 //当前老师所有的评档次数(不分档位)
                 long total = paperRepo.countByWorkIdAndQuestionId(markSubject.getWorkId(), questionId);
-                map.put("kdtotal", kdtotal);
+//                map.put("kdtotal", kdtotal);
                 map.put("total", total);
                 return map;
             }
@@ -307,12 +307,12 @@ public class MakrerApi {
                 dto.setPercent(0.0);
 
                 //当前老师当前档位评档次数(所有考试)
-                int countNew;
-                if (ParamCache.paramMap.get(marker.getWorkId()).getScoreShowAllPaper() == 1) {
+                int countNew =0;
+                /*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);
             }
@@ -320,12 +320,13 @@ public class MakrerApi {
         long kdtotal = 0L, total = 0L;
         if (Objects.nonNull(future) && Objects.nonNull(future.get())) {
             Map<String, Long> map = (Map<String, Long>) future.get();
-            kdtotal = map.get("kdtotal");
+//            kdtotal = map.get("kdtotal");
             total = map.get("total");
         }
 
-        long finalKdtotal = kdtotal;
+//        long finalKdtotal = kdtotal;
         long finalTotal = total;
+        Integer scoreShowAllPaper = ParamCache.paramMap.get(marker.getWorkId()).getScoreShowAllPaper();
         levelStatDTOs.forEach(o -> {
             if (o.getId() != null) {
                 o.setPt(levelMap.get(o.getId()).getPt());
@@ -341,7 +342,7 @@ public class MakrerApi {
                 o.setGpercent(gbd.doubleValue());
 
                 int count;
-                if(ParamCache.paramMap.get(marker.getWorkId()).getScoreShowAllPaper() == 1){
+                if(scoreShowAllPaper == 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);

+ 31 - 13
stmms-ms-marking/src/main/java/cn/com/qmth/stmms/ms/marking/api/MarkTaskApi.java

@@ -31,6 +31,8 @@ import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.*;
 
 import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.Join;
+import javax.persistence.criteria.JoinType;
 import javax.persistence.criteria.Predicate;
 import java.math.BigDecimal;
 import java.util.*;
@@ -99,6 +101,8 @@ public class MarkTaskApi {
         MarkUser markUser = markUserRepo.findOne(markerId);
         Specification<MarkTask> specification = (root, query, builder) -> {
             List<Predicate> predicates = new ArrayList<>();
+            List<Predicate> onPredicates = new ArrayList<>();
+            Join<MarkTask, Paper> join = root.join("paper", JoinType.LEFT);
             if (Objects.nonNull(questionId)) {
                 predicates.add(builder.equal(root.get("questionId"), questionId));
             }
@@ -107,8 +111,10 @@ public class MarkTaskApi {
             if (level == null) {
                 predicates.add(builder.isNull(root.get("result")));
                 if (stage == MarkStage.SCORE) {
-                    predicates.add(builder.equal(root.get("paper").get("isShift"), false));
-                    predicates.add(builder.equal(root.get("paper").get("isShiftScore"), false));
+//                    predicates.add(builder.equal(root.get("paper").get("isShift"), false));
+//                    predicates.add(builder.equal(root.get("paper").get("isShiftScore"), false));
+                    onPredicates.add(builder.equal(join.get("isShift"), false));
+                    onPredicates.add(builder.equal(join.get("isShiftScore"), false));
                 }
             } else if (stage == MarkStage.LEVEL) {
                 //查询
@@ -117,34 +123,46 @@ public class MarkTaskApi {
 //                    Long batchNo = paperRepo.findByQuestionId(questionId);
                     Long batchNo = paperRepo.findMaxBatchNoByWorkIdAndSubject(workId, markUser.getSubject());
                     if (!Objects.isNull(batchNo)) {
-                        predicates.add(builder.equal(root.get("paper").get("batchNo"), batchNo));
+//                        predicates.add(builder.equal(root.get("paper").get("batchNo"), batchNo));
+                        onPredicates.add(builder.equal(join.get("batchNo"), batchNo));
                     }
                 }
             } else if (stage == MarkStage.SCORE) {
 //                Long batchNo = paperRepo.findScoreBatchNoByQuestionId(questionId);
                 Long batchNo = paperRepo.findMaxScoreBatchNoByWorkIdAndSubject(workId, markUser.getSubject());
-                predicates.add(builder.equal(root.get("paper").get("level"), level));
+//                predicates.add(builder.equal(root.get("paper").get("level"), level));
+                onPredicates.add(builder.equal(join.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));
+//                predicates.add(builder.equal(root.get("paper").get("isShift"), false));
+//                predicates.add(builder.equal(root.get("paper").get("isShiftScore"), false));
+                onPredicates.add(builder.equal(join.get("isShift"), false));
+                onPredicates.add(builder.equal(join.get("isShiftScore"), false));
                 if(ParamCache.paramMap.get(workId).getScoreShowAllPaper() == 1){
-                    predicates.add(builder.isNotNull(root.get("paper").get("scoreBatchNo")));
+//                    predicates.add(builder.isNotNull(root.get("paper").get("scoreBatchNo")));
+                    onPredicates.add(builder.isNotNull(join.get("scoreBatchNo")));
                 } else {
-                    predicates.add(builder.equal(root.get("paper").get("scoreBatchNo"), batchNo));
+//                    predicates.add(builder.equal(root.get("paper").get("scoreBatchNo"), batchNo));
+                    onPredicates.add(builder.equal(join.get("scoreBatchNo"), batchNo));
                 }
             }
             if (isSample != null) {
-                predicates.add(builder.equal(root.get("paper").get("isSample"), isSample));
+//                predicates.add(builder.equal(root.get("paper").get("isSample"), isSample));
+                onPredicates.add(builder.equal(join.get("isSample"), isSample));
             }
             if (reject != null) {
-                predicates.add(builder.equal(root.get("paper").get("isRejected"), reject));
+//                predicates.add(builder.equal(root.get("paper").get("isRejected"), reject));
+                onPredicates.add(builder.equal(join.get("isRejected"), reject));
             }
-            predicates.add(builder.equal(root.get("paper").get("isMissing"), false));
-            predicates.add(builder.equal(root.get("paper").get("active"), true));
+//            predicates.add(builder.equal(root.get("paper").get("isMissing"), false));
+//            predicates.add(builder.equal(root.get("paper").get("active"), true));
+            onPredicates.add(builder.equal(join.get("isMissing"), false));
+            onPredicates.add(builder.equal(join.get("active"), true));
             //过滤考区
             if (Objects.nonNull(areaCode)) {
-                predicates.add(builder.equal(root.get("paper").get("areaCode"), areaCode));
+//                predicates.add(builder.equal(root.get("paper").get("areaCode"), areaCode));
+                onPredicates.add(builder.equal(join.get("areaCode"), areaCode));
             }
+            join.on(onPredicates.toArray(new Predicate[onPredicates.size()]));
 //            predicates.add(builder.equal(root.get("isActive"), false));
             return builder.and(predicates.toArray(new Predicate[predicates.size()]));
         };