Browse Source

线下版本-分档、打分优化-20201124

xiaof 4 years ago
parent
commit
2f8910112d

+ 2 - 2
stmms-ms-commons/src/main/java/cn/com/qmth/stmms/ms/commons/utils/RandomUtil.java

@@ -17,8 +17,8 @@ import java.util.*;
 @Component
 @Component
 public class RandomUtil {
 public class RandomUtil {
     private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(RandomUtil.class);
     private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(RandomUtil.class);
-    private final int minSize = 1000000;
-    private final int maxSize = 1000001;
+    private final int minSize = 10000000;
+    private final int maxSize = 10000001;
     private final int randomSize = 2000000;
     private final int randomSize = 2000000;
     private int randomNum = 0;
     private int randomNum = 0;
     private Map<Long, List<Long>> randomMap = new HashMap<>();
     private Map<Long, List<Long>> randomMap = new HashMap<>();

+ 199 - 40
stmms-ms-marking/src/main/java/cn/com/qmth/stmms/ms/marking/api/MakrerApi.java

@@ -133,7 +133,6 @@ public class MakrerApi {
     @RequestMapping(value = "{marker}/stat/levels", method = RequestMethod.GET)
     @RequestMapping(value = "{marker}/stat/levels", method = RequestMethod.GET)
     public List<LevelStatDTO> levelStats(@PathVariable MarkUser marker, @RequestParam Long questionId) throws Exception {
     public List<LevelStatDTO> levelStats(@PathVariable MarkUser marker, @RequestParam Long questionId) throws Exception {
         List<LevelStatDTO> levelStatDTOs = new ArrayList<>();
         List<LevelStatDTO> levelStatDTOs = new ArrayList<>();
-        long t1 = System.currentTimeMillis();
         MarkSubject markSubject = markSubjectRepo.findOne(marker.getWorkId() + "-" + marker.getSubject().toString());
         MarkSubject markSubject = markSubjectRepo.findOne(marker.getWorkId() + "-" + marker.getSubject().toString());
         List<Level> levels = levelRepo.findByWorkId(markSubject.getWorkId());
         List<Level> levels = levelRepo.findByWorkId(markSubject.getWorkId());
         Map<String, Level> levelMap = levels.stream().collect(Collectors.toMap(Level::getCode, l -> l));
         Map<String, Level> levelMap = levels.stream().collect(Collectors.toMap(Level::getCode, l -> l));
@@ -143,8 +142,6 @@ public class MakrerApi {
         if(levelShowAllPaper == 0){
         if(levelShowAllPaper == 0){
             batchNo = paperRepo.findMaxBatchNoByWorkIdAndSubject(marker.getWorkId(), marker.getSubject());
             batchNo = paperRepo.findMaxBatchNoByWorkIdAndSubject(marker.getWorkId(), marker.getSubject());
         }
         }
-        long t2 = System.currentTimeMillis();
-        System.out.println("l1:"+(t2-t1));
         Long finalBatchNo = batchNo;
         Long finalBatchNo = batchNo;
         Future future = myThreadPool.arbitratePoolTaskExecutor.submit(new Callable<Map<String, Long>>() {
         Future future = myThreadPool.arbitratePoolTaskExecutor.submit(new Callable<Map<String, Long>>() {
 
 
@@ -153,15 +150,12 @@ public class MakrerApi {
                 Map<String, Long> map = new HashMap<>();
                 Map<String, Long> map = new HashMap<>();
                 //当前老师当前批次试卷总数
                 //当前老师当前批次试卷总数
                 long kdtotal;
                 long kdtotal;
-                long t21 = System.currentTimeMillis();
                 if (levelShowAllPaper == 1) {
                 if (levelShowAllPaper == 1) {
                     kdtotal = markTaskRepo.countByQuestionIdAll(questionId, marker.getId());
                     kdtotal = markTaskRepo.countByQuestionIdAll(questionId, marker.getId());
                 } else {
                 } else {
 //                    kdtotal = markTaskRepo.countByQuestionId(questionId, finalBatchNo, marker.getId());
 //                    kdtotal = markTaskRepo.countByQuestionId(questionId, finalBatchNo, marker.getId());
                     kdtotal = markTaskRepo.countByQuestionIdAndBatchNo(questionId, finalBatchNo, marker.getId());
                     kdtotal = markTaskRepo.countByQuestionIdAndBatchNo(questionId, finalBatchNo, marker.getId());
                 }
                 }
-                long t22 = System.currentTimeMillis();
-                System.out.println("l61:"+(t22-t21));
                 //当前考区内试卷总数
                 //当前考区内试卷总数
                 long total = paperRepo.countByWorkIdAndQuestionId(markSubject.getWorkId(), questionId);
                 long total = paperRepo.countByWorkIdAndQuestionId(markSubject.getWorkId(), questionId);
                 map.put("kdtotal", kdtotal);
                 map.put("kdtotal", kdtotal);
@@ -169,38 +163,27 @@ public class MakrerApi {
                 return map;
                 return map;
             }
             }
         });
         });
-        long t3 = System.currentTimeMillis();
-        System.out.println("l2:"+(t3-t2));
         //当前考区各档位定档数量
         //当前考区各档位定档数量
         List<Object[]> list = paperRepo.countGroupByLevel(questionId);
         List<Object[]> list = paperRepo.countGroupByLevel(questionId);
-        long t4 = System.currentTimeMillis();
-        System.out.println("l3:"+(t4-t3));
         list.forEach(o -> {
         list.forEach(o -> {
                     LevelStatDTO levelStatDTO = levelStatAssembler.toDTO(o);
                     LevelStatDTO levelStatDTO = levelStatAssembler.toDTO(o);
                     levelStatDTO.setGcount(levelStatDTO.getCount());
                     levelStatDTO.setGcount(levelStatDTO.getCount());
                     if (Objects.isNull(levelStatDTO.getId())) {
                     if (Objects.isNull(levelStatDTO.getId())) {
                         //求任务数为null的条数
                         //求任务数为null的条数
                         int count;
                         int count;
-                        long t41 = System.currentTimeMillis();
                         if (levelShowAllPaper == 1) {
                         if (levelShowAllPaper == 1) {
                             count = markTaskRepo.countByQuestionIdAndMarkerIdAndStageAndResultIsNullAll(questionId, marker.getId(), MarkStage.LEVEL.ordinal());
                             count = markTaskRepo.countByQuestionIdAndMarkerIdAndStageAndResultIsNullAll(questionId, marker.getId(), MarkStage.LEVEL.ordinal());
                         } else {
                         } else {
                             count = markTaskRepo.countByQuestionIdAndMarkerIdAndStageAndResultNull(questionId, marker.getId(), MarkStage.LEVEL.ordinal(), finalBatchNo);
                             count = markTaskRepo.countByQuestionIdAndMarkerIdAndStageAndResultNull(questionId, marker.getId(), MarkStage.LEVEL.ordinal(), finalBatchNo);
                         }
                         }
-                        long t42 = System.currentTimeMillis();
-                        System.out.println("l41:"+(t42-t41));
                         //查询当前老师打回个数
                         //查询当前老师打回个数
 //                        int rejectCount = markTaskRepo.countByQuestionIdAndMarkerIdAndStageAndIsRejectedTrueAndIsMissing(questionId, marker.getId(), MarkStage.LEVEL.ordinal(), false);
 //                        int rejectCount = markTaskRepo.countByQuestionIdAndMarkerIdAndStageAndIsRejectedTrueAndIsMissing(questionId, marker.getId(), MarkStage.LEVEL.ordinal(), false);
                         int rejectCount = markTaskRepo.countByQuestionIdAndMarkerIdAndStageAndIsRejectedTrue(questionId, marker.getId(), MarkStage.LEVEL.ordinal());
                         int rejectCount = markTaskRepo.countByQuestionIdAndMarkerIdAndStageAndIsRejectedTrue(questionId, marker.getId(), MarkStage.LEVEL.ordinal());
-                        long t43 = System.currentTimeMillis();
-                        System.out.println("l42:"+(t43-t42));
                         levelStatDTO.setCount(count);
                         levelStatDTO.setCount(count);
                         levelStatDTO.setRejected(rejectCount);
                         levelStatDTO.setRejected(rejectCount);
                     }
                     }
                     levelStatDTOs.add(levelStatDTO);
                     levelStatDTOs.add(levelStatDTO);
                 });
                 });
-        long t5 = System.currentTimeMillis();
-        System.out.println("l4:"+(t5-t4));
         for (Level level : levels) {
         for (Level level : levels) {
             //所有档位依次比较
             //所有档位依次比较
             long count = levelStatDTOs.stream().filter(l -> String.valueOf(l.getId()).equals(level.getCode())).count();
             long count = levelStatDTOs.stream().filter(l -> String.valueOf(l.getId()).equals(level.getCode())).count();
@@ -212,16 +195,12 @@ public class MakrerApi {
                 levelStatDTOs.add(dto);
                 levelStatDTOs.add(dto);
             }
             }
         }
         }
-        long t6 = System.currentTimeMillis();
-        System.out.println("l5:"+(t6-t5));
         long kdtotal = 0L, total = 0L;
         long kdtotal = 0L, total = 0L;
         if (Objects.nonNull(future) && Objects.nonNull(future.get())) {
         if (Objects.nonNull(future) && Objects.nonNull(future.get())) {
             Map<String, Long> map = (Map<String, Long>) future.get();
             Map<String, Long> map = (Map<String, Long>) future.get();
             kdtotal = map.get("kdtotal");
             kdtotal = map.get("kdtotal");
             total = map.get("total");
             total = map.get("total");
         }
         }
-        long t7 = System.currentTimeMillis();
-        System.out.println("l6:"+(t7-t6));
 
 
         long finalKdtotal = kdtotal;
         long finalKdtotal = kdtotal;
         long finalTotal = total;
         long finalTotal = total;
@@ -252,8 +231,121 @@ public class MakrerApi {
                 o.setGpercent(gbd.doubleValue());
                 o.setGpercent(gbd.doubleValue());
             }
             }
         });
         });
-        long t8 = System.currentTimeMillis();
-        System.out.println("l7:"+(t8-t7));
+        Collections.sort(levelStatDTOs, (o1, o2) -> {
+            if (o1.getId() == null || o2.getId() == null) {
+                return 1;
+            }
+            return o1.getId().toString().compareTo(o2.getId().toString());
+        });
+        return levelStatDTOs;
+    }
+
+    /**
+     * 评卷员分档数量及占比数据
+     *
+     * @param marker     评卷员用户id
+     * @param questionId 试题id
+     * @return
+     */
+    @RequestMapping(value = "{marker}/stat/totalLevels", method = RequestMethod.GET)
+    public List<LevelStatDTO> totalLevels(@PathVariable MarkUser marker, @RequestParam Long questionId) throws Exception {
+        List<LevelStatDTO> levelStatDTOs = new ArrayList<>();
+        MarkSubject markSubject = markSubjectRepo.findOne(marker.getWorkId() + "-" + marker.getSubject().toString());
+        List<Level> levels = levelRepo.findByWorkId(markSubject.getWorkId());
+        Map<String, Level> levelMap = levels.stream().collect(Collectors.toMap(Level::getCode, l -> l));
+        Integer levelShowAllPaper = ParamCache.paramMap.get(marker.getWorkId()).getLevelShowAllPaper();
+        Long batchNo = null;
+        if(levelShowAllPaper == 0){
+            batchNo = paperRepo.findMaxBatchNoByWorkIdAndSubject(marker.getWorkId(), marker.getSubject());
+        }
+        Long finalBatchNo = batchNo;
+        Future future = myThreadPool.arbitratePoolTaskExecutor.submit(new Callable<Map<String, Long>>() {
+            @Override
+            public Map<String, Long> call() throws Exception {
+                Map<String, Long> map = new HashMap<>();
+                //当前老师当前批次试卷总数
+                long kdtotal;
+                if (levelShowAllPaper == 1) {
+                    kdtotal = markTaskRepo.countByQuestionIdAll(questionId, marker.getId());
+                } else {
+                    kdtotal = markTaskRepo.countByQuestionIdAndBatchNo(questionId, finalBatchNo, marker.getId());
+                }
+                //当前考区内试卷总数
+                long total = paperRepo.countByWorkIdAndQuestionId(markSubject.getWorkId(), questionId);
+                map.put("kdtotal", kdtotal);
+                map.put("total", total);
+                return map;
+            }
+        });
+        //当前考区各档位定档数量
+        List<Object[]> list = paperRepo.countGroupByLevel(questionId);
+        list.forEach(o -> {
+            LevelStatDTO levelStatDTO = levelStatAssembler.toDTO(o);
+            levelStatDTO.setGcount(levelStatDTO.getCount());
+            if (Objects.isNull(levelStatDTO.getId())) {
+                //求任务数为null的条数
+                int count;
+                if (levelShowAllPaper == 1) {
+                    count = markTaskRepo.countByQuestionIdAndMarkerIdAndStageAndResultIsNullAll(questionId, marker.getId(), MarkStage.LEVEL.ordinal());
+                } else {
+                    count = markTaskRepo.countByQuestionIdAndMarkerIdAndStageAndResultNull(questionId, marker.getId(), MarkStage.LEVEL.ordinal(), finalBatchNo);
+                }
+                //查询当前老师打回个数
+//                        int rejectCount = markTaskRepo.countByQuestionIdAndMarkerIdAndStageAndIsRejectedTrueAndIsMissing(questionId, marker.getId(), MarkStage.LEVEL.ordinal(), false);
+                int rejectCount = markTaskRepo.countByQuestionIdAndMarkerIdAndStageAndIsRejectedTrue(questionId, marker.getId(), MarkStage.LEVEL.ordinal());
+                levelStatDTO.setCount(count);
+                levelStatDTO.setRejected(rejectCount);
+            }
+            levelStatDTOs.add(levelStatDTO);
+        });
+        for (Level level : levels) {
+            //所有档位依次比较
+            long count = levelStatDTOs.stream().filter(l -> String.valueOf(l.getId()).equals(level.getCode())).count();
+            if (count == 0) {
+                LevelStatDTO dto = new LevelStatDTO();
+                dto.setId(level.getCode());
+                dto.setCount(0);
+                dto.setPercent(0.0);
+                levelStatDTOs.add(dto);
+            }
+        }
+        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");
+            total = map.get("total");
+        }
+
+        long finalKdtotal = kdtotal;
+        long finalTotal = total;
+        levelStatDTOs.forEach(o -> {
+            if (o.getId() != null) {
+                //当前老师各档位数量
+                int countNew;
+                if (levelShowAllPaper == 1) {
+                    countNew = markTaskRepo.countByQuestionIdAndMarkerIdAndStageAndResultAll(questionId, marker.getId(), MarkStage.LEVEL.ordinal(), String.valueOf(o.getId()));
+                } else {
+                    countNew = markTaskRepo.countByQuestionIdAndMarkerIdAndStageAndResult(questionId, marker.getId(), MarkStage.LEVEL.ordinal(), String.valueOf(o.getId()), finalBatchNo);
+                }
+                o.setCount(countNew);
+                //该档位考区内已定档数量
+                long gcountNew = paperRepo.countByQuestionIdAndLevelAndSubjectAndWorkId(questionId, String.valueOf(o.getId()), markSubject.getSubject(), marker.getWorkId());
+                o.setGcount((int) gcountNew);
+
+                o.setPt(levelMap.get(o.getId()).getPt());
+                o.setKdpt(levelMap.get(o.getId()).getKdpt());
+                double p = finalKdtotal == 0 ? 0 : (double) o.getCount() / finalKdtotal * 100;
+                BigDecimal bd = new BigDecimal(p).setScale(3, RoundingMode.HALF_EVEN);
+                o.setPercent(bd.doubleValue());
+                o.setFinalKdTotal(Math.toIntExact(finalKdtotal));
+
+                o.setGcount(Objects.isNull(o.getGcount()) ? 0 : o.getGcount());
+                double gp = finalTotal == 0 ? 0 : (double) o.getGcount() / finalTotal * 100;
+                BigDecimal gbd = new BigDecimal(gp).setScale(3, RoundingMode.HALF_EVEN);
+                o.setGpercent(gbd.doubleValue());
+                o.setFinalTotal(Math.toIntExact(finalTotal));
+            }
+        });
         Collections.sort(levelStatDTOs, (o1, o2) -> {
         Collections.sort(levelStatDTOs, (o1, o2) -> {
             if (o1.getId() == null || o2.getId() == null) {
             if (o1.getId() == null || o2.getId() == null) {
                 return 1;
                 return 1;
@@ -273,13 +365,10 @@ public class MakrerApi {
     @RequestMapping(value = "{marker}/stat/scores", method = RequestMethod.GET)
     @RequestMapping(value = "{marker}/stat/scores", method = RequestMethod.GET)
     public List<LevelStatDTO> scoreStats(@PathVariable MarkUser marker, @RequestParam Long questionId) throws Exception {
     public List<LevelStatDTO> scoreStats(@PathVariable MarkUser marker, @RequestParam Long questionId) throws Exception {
         List<LevelStatDTO> levelStatDTOs = new ArrayList<>();
         List<LevelStatDTO> levelStatDTOs = new ArrayList<>();
-        long t1 = System.currentTimeMillis();
         MarkSubject markSubject = markSubjectRepo.findOne(marker.getWorkId() + "-" + marker.getSubject().toString());
         MarkSubject markSubject = markSubjectRepo.findOne(marker.getWorkId() + "-" + marker.getSubject().toString());
         List<Level> levels = levelRepo.findByWorkId(markSubject.getWorkId());
         List<Level> levels = levelRepo.findByWorkId(markSubject.getWorkId());
         Map<String, Level> levelMap = levels.stream().collect(Collectors.toMap(Level::getCode, l -> l));
         Map<String, Level> levelMap = levels.stream().collect(Collectors.toMap(Level::getCode, l -> l));
         Long batchNo = paperRepo.findMaxScoreBatchNoByWorkIdAndSubject(marker.getWorkId(), marker.getSubject());
         Long batchNo = paperRepo.findMaxScoreBatchNoByWorkIdAndSubject(marker.getWorkId(), marker.getSubject());
-        long t2 = System.currentTimeMillis();
-        System.out.println("s1:"+(t2-t1));
         Future future = myThreadPool.arbitratePoolTaskExecutor.submit(new Callable<Map<String, Long>>() {
         Future future = myThreadPool.arbitratePoolTaskExecutor.submit(new Callable<Map<String, Long>>() {
 
 
             @Override
             @Override
@@ -292,27 +381,19 @@ public class MakrerApi {
                 return map;
                 return map;
             }
             }
         });
         });
-        long t3 = System.currentTimeMillis();
-        System.out.println("s2:"+(t3-t2));
         LevelStatDTO levelStatDTO = new LevelStatDTO();
         LevelStatDTO levelStatDTO = new LevelStatDTO();
         //求任务数为null的条数
         //求任务数为null的条数
 //        int totalCount = markTaskRepo.countScoreByQuestionIdAndMarkerIdAndStageAndResultIsNullAndIsMissing(questionId, marker.getId(), MarkStage.SCORE.ordinal(), false, batchNo);
 //        int totalCount = markTaskRepo.countScoreByQuestionIdAndMarkerIdAndStageAndResultIsNullAndIsMissing(questionId, marker.getId(), MarkStage.SCORE.ordinal(), false, batchNo);
         int totalCount = markTaskRepo.countScoreByQuestionIdAndMarkerIdAndStageAndResultIsNull(questionId, marker.getId(), MarkStage.SCORE.ordinal(), batchNo);
         int totalCount = markTaskRepo.countScoreByQuestionIdAndMarkerIdAndStageAndResultIsNull(questionId, marker.getId(), MarkStage.SCORE.ordinal(), batchNo);
         levelStatDTO.setCount(totalCount);
         levelStatDTO.setCount(totalCount);
-        long t4 = System.currentTimeMillis();
-        System.out.println("s3:"+(t4-t3));
         //查询改档
         //查询改档
         int shiftCount = markTaskRepo.countShiftByQuestionIdAndMarkerIdAndStageAndResultIsNullAndIsMissing(questionId, marker.getId(), MarkStage.LEVEL.ordinal(), false);
         int shiftCount = markTaskRepo.countShiftByQuestionIdAndMarkerIdAndStageAndResultIsNullAndIsMissing(questionId, marker.getId(), MarkStage.LEVEL.ordinal(), false);
         levelStatDTO.setShift(shiftCount);
         levelStatDTO.setShift(shiftCount);
-        long t5 = System.currentTimeMillis();
-        System.out.println("s4:"+(t5-t4));
         //查询改档打分
         //查询改档打分
 //        int shiftScoreCount = markTaskRepo.countShiftScoreByQuestionIdAndMarkerIdAndStageAndResultIsNullAndIsMissing(questionId, marker.getId(), MarkStage.SCORE.ordinal(), false);
 //        int shiftScoreCount = markTaskRepo.countShiftScoreByQuestionIdAndMarkerIdAndStageAndResultIsNullAndIsMissing(questionId, marker.getId(), MarkStage.SCORE.ordinal(), false);
         int shiftScoreCount = markTaskRepo.countShiftScoreByQuestionIdAndMarkerIdAndStageAndResultIsNull(questionId, marker.getId(), MarkStage.SCORE.ordinal());
         int shiftScoreCount = markTaskRepo.countShiftScoreByQuestionIdAndMarkerIdAndStageAndResultIsNull(questionId, marker.getId(), MarkStage.SCORE.ordinal());
         levelStatDTO.setShiftScore(shiftScoreCount);
         levelStatDTO.setShiftScore(shiftScoreCount);
         levelStatDTOs.add(levelStatDTO);
         levelStatDTOs.add(levelStatDTO);
-        long t6 = System.currentTimeMillis();
-        System.out.println("s5:"+(t6-t5));
 
 
         for (Level level : levels) {
         for (Level level : levels) {
             //所有档位依次比较
             //所有档位依次比较
@@ -328,15 +409,11 @@ public class MakrerApi {
                 levelStatDTOs.add(dto);
                 levelStatDTOs.add(dto);
             }
             }
         }
         }
-        long t7 = System.currentTimeMillis();
-        System.out.println("s6:"+(t7-t6));
         long total = 0L;
         long total = 0L;
         if (Objects.nonNull(future) && Objects.nonNull(future.get())) {
         if (Objects.nonNull(future) && Objects.nonNull(future.get())) {
             Map<String, Long> map = (Map<String, Long>) future.get();
             Map<String, Long> map = (Map<String, Long>) future.get();
             total = map.get("total");
             total = map.get("total");
         }
         }
-        long t8 = System.currentTimeMillis();
-        System.out.println("s7:"+(t8-t7));
 
 
         long finalTotal = total;
         long finalTotal = total;
         levelStatDTOs.forEach(o -> {
         levelStatDTOs.forEach(o -> {
@@ -361,8 +438,90 @@ public class MakrerApi {
                 o.setCount(count);
                 o.setCount(count);
             }
             }
         });
         });
-        long t9 = System.currentTimeMillis();
-        System.out.println("s8:"+(t9-t8));
+        return levelStatDTOs;
+    }
+
+    /**
+     * 评卷员打分数量
+     *
+     * @param marker     评卷员用户id
+     * @param questionId 试题id
+     * @return
+     */
+    @RequestMapping(value = "{marker}/stat/totalScores", method = RequestMethod.GET)
+    public List<LevelStatDTO> totalScores(@PathVariable MarkUser marker, @RequestParam Long questionId) throws Exception {
+        List<LevelStatDTO> levelStatDTOs = new ArrayList<>();
+        MarkSubject markSubject = markSubjectRepo.findOne(marker.getWorkId() + "-" + marker.getSubject().toString());
+        List<Level> levels = levelRepo.findByWorkId(markSubject.getWorkId());
+        Map<String, Level> levelMap = levels.stream().collect(Collectors.toMap(Level::getCode, l -> l));
+        Long batchNo = paperRepo.findMaxScoreBatchNoByWorkIdAndSubject(marker.getWorkId(), marker.getSubject());
+        Future future = myThreadPool.arbitratePoolTaskExecutor.submit(new Callable<Map<String, Long>>() {
+            @Override
+            public Map<String, Long> call() {
+                Map<String, Long> map = new HashMap<>();
+                //当前老师所有的评档次数(不分档位)
+//                long total = paperRepo.countByWorkIdAndQuestionId(markSubject.getWorkId(), questionId);
+                long total = paperRepo.countByQuestionId(questionId);
+                map.put("total", total);
+                return map;
+            }
+        });
+        LevelStatDTO levelStatDTO = new LevelStatDTO();
+        //求任务数为null的条数
+        int totalCount = markTaskRepo.countScoreByQuestionIdAndMarkerIdAndStageAndResultIsNull(questionId, marker.getId(), MarkStage.SCORE.ordinal(), batchNo);
+        levelStatDTO.setCount(totalCount);
+        //查询改档
+        int shiftCount = markTaskRepo.countShiftByQuestionIdAndMarkerIdAndStageAndResultIsNullAndIsMissing(questionId, marker.getId(), MarkStage.LEVEL.ordinal(), false);
+        levelStatDTO.setShift(shiftCount);
+        //查询改档打分
+        int shiftScoreCount = markTaskRepo.countShiftScoreByQuestionIdAndMarkerIdAndStageAndResultIsNull(questionId, marker.getId(), MarkStage.SCORE.ordinal());
+        levelStatDTO.setShiftScore(shiftScoreCount);
+        levelStatDTOs.add(levelStatDTO);
+
+        for (Level level : levels) {
+            //所有档位依次比较
+            long count = levelStatDTOs.stream().filter(l -> String.valueOf(l.getId()).equals(level.getCode())).count();
+            if (count == 0) {
+                LevelStatDTO dto = new LevelStatDTO();
+                dto.setId(level.getCode());
+                dto.setCount(0);
+                dto.setPercent(0.0);
+
+                //当前老师当前档位评档次数(所有考试)
+                dto.setCount(0);
+                levelStatDTOs.add(dto);
+            }
+        }
+        long total = 0L;
+        if (Objects.nonNull(future) && Objects.nonNull(future.get())) {
+            Map<String, Long> map = (Map<String, Long>) future.get();
+            total = map.get("total");
+        }
+
+        long finalTotal = total;
+        levelStatDTOs.forEach(o -> {
+            if (o.getId() != null) {
+                o.setPt(levelMap.get(o.getId()).getPt());
+                o.setKdpt(levelMap.get(o.getId()).getKdpt());
+                o.setCount(Objects.isNull(o.getCount()) ? 0 : o.getCount());
+                o.setPercent(0D);
+
+                o.setGcount(Objects.isNull(o.getGcount()) ? 0 : o.getGcount());
+                double gp = (double) o.getGcount() / finalTotal;
+                BigDecimal gbd = new BigDecimal(gp).setScale(3, RoundingMode.HALF_EVEN);
+                o.setGpercent(gbd.doubleValue());
+                o.setFinalTotal(Math.toIntExact(finalTotal));
+
+                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);
+            }
+        });
         return levelStatDTOs;
         return levelStatDTOs;
     }
     }
 
 

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

@@ -12,8 +12,10 @@ import cn.com.qmth.stmms.ms.core.repository.*;
 import cn.com.qmth.stmms.ms.core.vo.Subject;
 import cn.com.qmth.stmms.ms.core.vo.Subject;
 import cn.com.qmth.stmms.ms.marking.assembler.MarkTaskAssembler;
 import cn.com.qmth.stmms.ms.marking.assembler.MarkTaskAssembler;
 import cn.com.qmth.stmms.ms.marking.assembler.MarkerAssembler;
 import cn.com.qmth.stmms.ms.marking.assembler.MarkerAssembler;
+import cn.com.qmth.stmms.ms.marking.assembler.PaperAssembler;
 import cn.com.qmth.stmms.ms.marking.dto.LevelDetailDTO;
 import cn.com.qmth.stmms.ms.marking.dto.LevelDetailDTO;
 import cn.com.qmth.stmms.ms.marking.dto.MarkTaskDTO;
 import cn.com.qmth.stmms.ms.marking.dto.MarkTaskDTO;
+import cn.com.qmth.stmms.ms.marking.dto.PaperDTO;
 import cn.com.qmth.stmms.ms.marking.service.MarkingService;
 import cn.com.qmth.stmms.ms.marking.service.MarkingService;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
@@ -51,6 +53,9 @@ public class MarkTaskApi {
     @Autowired
     @Autowired
     private MarkTaskAssembler markTaskAssembler;
     private MarkTaskAssembler markTaskAssembler;
 
 
+    @Autowired
+    private PaperAssembler paperAssembler;
+
     @Autowired
     @Autowired
     ExamQuestionRepo examQuestionRepo;
     ExamQuestionRepo examQuestionRepo;
 
 
@@ -164,22 +169,12 @@ public class MarkTaskApi {
 //            predicates.add(builder.equal(root.get("isActive"), false));
 //            predicates.add(builder.equal(root.get("isActive"), false));
             return builder.and(predicates.toArray(new Predicate[predicates.size()]));
             return builder.and(predicates.toArray(new Predicate[predicates.size()]));
         };
         };
-//        Sort sort = new Sort( "randomSeq","level", "is_sample","serialNumber", "randomSeqNew");
-        List<Sort.Order> orders = new ArrayList<>();
-        Sort.Order order1=new Sort.Order(Sort.Direction.ASC, "randomSeq");
-        orders.add(order1);
-        Sort.Order order2=new Sort.Order(Sort.Direction.DESC, "isSample");
-        orders.add(order2);
-        Sort.Order order3=new Sort.Order(Sort.Direction.ASC, "level");
-        orders.add(order3);
-        Sort.Order order4=new Sort.Order(Sort.Direction.ASC, "serialNumber");
-        orders.add(order4);
-        Sort.Order order5=new Sort.Order(Sort.Direction.ASC, "randomSeqNew");
-        orders.add(order5);
-        Sort sort = new Sort(orders);
+        Sort sort = new Sort( "randomSeq", "randomSeqNew");
         Pageable pageable1 = new PageRequest(pageable.getPageNumber(), pageable.getPageSize(), sort);
         Pageable pageable1 = new PageRequest(pageable.getPageNumber(), pageable.getPageSize(), sort);
+        long t1 = System.currentTimeMillis();
         Page<MarkTask> markTasks = markTaskRepo.findAll(specification, pageable1);
         Page<MarkTask> markTasks = markTaskRepo.findAll(specification, pageable1);
-
+        long t2 = System.currentTimeMillis();
+        System.out.println("m1:" + (t2 - t1));
 
 
         if (Objects.isNull(markTasks) || markTasks.getContent().size() == 0) {
         if (Objects.isNull(markTasks) || markTasks.getContent().size() == 0) {
             if (Objects.nonNull(isSample) && isSample) {
             if (Objects.nonNull(isSample) && isSample) {
@@ -379,9 +374,9 @@ public class MarkTaskApi {
         Long batchNo = null;
         Long batchNo = null;
         Long socreBatchNo = null;
         Long socreBatchNo = null;
         if (stage == MarkStage.LEVEL) {
         if (stage == MarkStage.LEVEL) {
-             batchNo = paperRepo.findByQuestionId(questionId);
-        }else if (stage == MarkStage.SCORE) {
-            socreBatchNo=paperRepo.findScoreBatchNoByQuestionId(questionId);
+            batchNo = paperRepo.findByQuestionId(questionId);
+        } else if (stage == MarkStage.SCORE) {
+            socreBatchNo = paperRepo.findScoreBatchNoByQuestionId(questionId);
         }
         }
 
 
         Long finalBatchNo = batchNo;
         Long finalBatchNo = batchNo;
@@ -402,11 +397,10 @@ public class MarkTaskApi {
                 //分档需要过滤标准卷
                 //分档需要过滤标准卷
                 predicates.add(builder.equal(root.get("paper").get("isSample"), false));
                 predicates.add(builder.equal(root.get("paper").get("isSample"), false));
             } else if (stage == MarkStage.SCORE) {
             } else if (stage == MarkStage.SCORE) {
-
+                predicates.add(builder.isNotNull(root.get("result")));
                 if (!Objects.isNull(finalSocreBatchNo)) {
                 if (!Objects.isNull(finalSocreBatchNo)) {
                     predicates.add(builder.equal(root.get("paper").get("scoreBatchNo"), finalSocreBatchNo));
                     predicates.add(builder.equal(root.get("paper").get("scoreBatchNo"), finalSocreBatchNo));
                 }
                 }
-                predicates.add(builder.isNotNull(root.get("result")));
             }
             }
             //过滤考区
             //过滤考区
             if (Objects.nonNull(areaCode)) {
             if (Objects.nonNull(areaCode)) {
@@ -422,6 +416,34 @@ public class MarkTaskApi {
     }
     }
 
 
 
 
+
+    @RequestMapping(value = "/kzzReviewPaper", method = RequestMethod.GET)
+    public List<PaperDTO> reviewPaper(@RequestParam Long workId,
+                                         @RequestParam Subject subject,
+                                         @RequestParam Long questionId) {
+        Specification<Paper> specification = (root, query, builder) -> {
+            List<Predicate> predicates = new ArrayList<>();
+            predicates.add(builder.equal(root.get("workId"), workId));
+            predicates.add(builder.equal(root.get("subject"), subject));
+            if (Objects.nonNull(questionId)) {
+                predicates.add(builder.equal(root.get("questionId"), questionId));
+            }
+            predicates.add(builder.equal(root.get("isOneClick"), true));
+            return builder.and(predicates.toArray(new Predicate[predicates.size()]));
+        };
+
+        Sort sort = new Sort(Sort.Direction.DESC, "updatedOn");
+        Pageable pageable = new PageRequest(0, 5, sort);
+        Page<Paper> papers = paperRepo.findAll(specification, pageable);
+
+        List<PaperDTO> paperList = new ArrayList<>();
+        papers.getContent().forEach(p -> {
+            paperList.add(paperAssembler.toDTO(p));
+        });
+        return paperList;
+    }
+
+
     /**
     /**
      * 分档详情
      * 分档详情
      *
      *

+ 8 - 0
stmms-ms-marking/src/main/java/cn/com/qmth/stmms/ms/marking/api/PaperApi.java

@@ -353,6 +353,14 @@ public class PaperApi {
                 paper.setMarkByLeader(false);
                 paper.setMarkByLeader(false);
                 paper.setSample(false);
                 paper.setSample(false);
                 paperRepo.save(paper);
                 paperRepo.save(paper);
+
+                List<MarkTask> markTasks = markTaskRepo.findByPaperIdAndStage(paper.getId(), MarkStage.LEVEL);
+                for (MarkTask markTask : markTasks) {
+                    markTask.setResult(null);
+                    markTask.setLevel(null);
+                    markTask.setSample(false);
+                    markTaskRepo.save(markTask);
+                }
             }
             }
             return new ResponseEntity(true, HttpStatus.OK);
             return new ResponseEntity(true, HttpStatus.OK);
         }
         }

+ 20 - 0
stmms-ms-marking/src/main/java/cn/com/qmth/stmms/ms/marking/dto/LevelStatDTO.java

@@ -30,6 +30,10 @@ public class LevelStatDTO implements Serializable {
      */
      */
     private int kdpt = 0;
     private int kdpt = 0;
 
 
+    private Integer finalKdTotal;
+
+    private Integer finalTotal;
+
     public static long getSerialVersionUID() {
     public static long getSerialVersionUID() {
         return serialVersionUID;
         return serialVersionUID;
     }
     }
@@ -129,4 +133,20 @@ public class LevelStatDTO implements Serializable {
     public void setShiftScore(Integer shiftScore) {
     public void setShiftScore(Integer shiftScore) {
         this.shiftScore = shiftScore;
         this.shiftScore = shiftScore;
     }
     }
+
+    public Integer getFinalKdTotal() {
+        return finalKdTotal;
+    }
+
+    public void setFinalKdTotal(Integer finalKdTotal) {
+        this.finalKdTotal = finalKdTotal;
+    }
+
+    public Integer getFinalTotal() {
+        return finalTotal;
+    }
+
+    public void setFinalTotal(Integer finalTotal) {
+        this.finalTotal = finalTotal;
+    }
 }
 }

+ 21 - 1
stmms-ms-marking/src/main/java/cn/com/qmth/stmms/ms/marking/service/AssignTaskService.java

@@ -129,8 +129,11 @@ public class AssignTaskService {
         List<Object[]> markTasks = markTaskRepo.findAllByWorkId(markSubject.getWorkId());
         List<Object[]> markTasks = markTaskRepo.findAllByWorkId(markSubject.getWorkId());
         Map<Long, Object> randomMap = new HashMap<>();
         Map<Long, Object> randomMap = new HashMap<>();
         markTasks.forEach(m -> randomMap.put(Long.valueOf(m[1].toString()), m[0]));
         markTasks.forEach(m -> randomMap.put(Long.valueOf(m[1].toString()), m[0]));
+        List<Level> levels = levelRepo.findByWorkId(markSubject.getWorkId());
+        Map<String, Level> levelMap = levels.stream().collect(Collectors.toMap(Level::getCode, l -> l));
         //定序序号记录
         //定序序号记录
         Map map = new HashMap();
         Map map = new HashMap();
+        Map seqNewMap = new HashMap();
         while (iterator.hasNext()) {
         while (iterator.hasNext()) {
             if (idx >= groupSize) {
             if (idx >= groupSize) {
                 idx = 0;
                 idx = 0;
@@ -138,6 +141,7 @@ public class AssignTaskService {
             Paper paper = iterator.next();
             Paper paper = iterator.next();
             String serialNumber = null;
             String serialNumber = null;
             Integer displayNumber = null;
             Integer displayNumber = null;
+            Integer seqNewNumber = null;
             if (Objects.equals(MarkStage.SCORE, markSubject.getStage())) {
             if (Objects.equals(MarkStage.SCORE, markSubject.getStage())) {
                 //是否定序
                 //是否定序
                 int seq = 0;
                 int seq = 0;
@@ -153,6 +157,13 @@ public class AssignTaskService {
                     displayNumber = (int) display;
                     displayNumber = (int) display;
                     //设置新值
                     //设置新值
                     map.put(paper.getLevel() + idx, seq);
                     map.put(paper.getLevel() + idx, seq);
+
+                    int seqNew = 100000;
+                    if(seqNewMap.containsKey(paper.getLevel())){
+                        seqNew = (int) seqNewMap.get(paper.getLevel());
+                    }
+                    seqNewNumber = ++seqNew;
+                    seqNewMap.put(paper.getLevel(), seqNew);
                 }
                 }
             }
             }
             for (MarkUser marker : markerGroups.get(idx).getMarkers()) {
             for (MarkUser marker : markerGroups.get(idx).getMarkers()) {
@@ -160,6 +171,12 @@ public class AssignTaskService {
                 MarkTask markTask = null;
                 MarkTask markTask = null;
                 if (Objects.equals(MarkStage.SCORE, markSubject.getStage())) {
                 if (Objects.equals(MarkStage.SCORE, markSubject.getStage())) {
                     markTask = new MarkTask(marker, paper, markSubject.getStage(), random, markSubject.getTest());
                     markTask = new MarkTask(marker, paper, markSubject.getStage(), random, markSubject.getTest());
+                    String levelValue = String.valueOf(levelMap.get(paper.getLevel()).getLevelValue() + 1);
+                    if (Objects.nonNull(serialNumber)) {
+                        markTask.setRandomSeqNew(Long.valueOf(levelValue + seqNewNumber));
+                    } else {
+                        markTask.setRandomSeqNew(Long.valueOf(levelValue + markTask.getRandomSeqNew()));
+                    }
                     markTask.setBatchNo(currentTime);
                     markTask.setBatchNo(currentTime);
                     markTask.setSerialNumber(serialNumber);
                     markTask.setSerialNumber(serialNumber);
                     markTask.setDisplayNumber(displayNumber);
                     markTask.setDisplayNumber(displayNumber);
@@ -192,6 +209,9 @@ public class AssignTaskService {
                     paper.setScoreBatchNo(currentTime);
                     paper.setScoreBatchNo(currentTime);
                     paperList.add(paper);
                     paperList.add(paper);
                 }
                 }
+            } else {
+                paper.setBatchNo(currentTime);
+                paperList.add(paper);
             }
             }
             idx++;
             idx++;
         }
         }
@@ -199,7 +219,7 @@ public class AssignTaskService {
         List<MarkTask> data = new ArrayList<>();
         List<MarkTask> data = new ArrayList<>();
         //5000条提交一次
         //5000条提交一次
         for (MarkTask markTask : markTaskList) {
         for (MarkTask markTask : markTaskList) {
-            if (data.size() == 5000) {
+            if (data.size() == 2000) {
                 markTaskRepo.save(data);
                 markTaskRepo.save(data);
                 data.clear();
                 data.clear();
             }
             }