Forráskód Böngészése

美术阅卷10月新增需求-分数比例和显示BUG修复

wangliang 5 éve
szülő
commit
65279755aa

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

@@ -39,6 +39,12 @@ public interface MarkTaskRepo extends JpaRepository<MarkTask, Long>, JpaSpecific
 
     long countByQuestionId(Long questionId);
 
+    int countByQuestionIdAndStageAndResultIsNull(Long questionId, MarkStage stage);
+
+    int countByQuestionIdAndStageAndResult(Long questionId, MarkStage stage, String result);
+
+    int countByQuestionIdAndMarkerIdAndStageAndResult(Long questionId, Long markerId, MarkStage stage, String result);
+
     int countByWorkIdAndSubjectAndMarkerIdAndStageAndResult(Long workId, Subject subject, Long markerId, MarkStage stage, String result);
 
     int countByWorkIdAndSubjectAndMarkerIdAndStageAndQuestionIdAndResult(Long workId, Subject subject, Long markerId, MarkStage stage, Long questionId, String result);

+ 12 - 113
stmms-ms-marking/src/main/java/cn/com/qmth/stmms/ms/marking/api/MakrerApi.java

@@ -63,6 +63,9 @@ public class MakrerApi {
     @Autowired
     SqlUtil sqlUtil;
 
+    @Autowired
+    PaperRepo paperRepo;
+
     /**
      * 评卷员信息
      *
@@ -105,124 +108,23 @@ public class MakrerApi {
      */
     @RequestMapping(value = "{marker}/stat/levels", method = RequestMethod.GET)
     public List<LevelStatDTO> levelStats(@PathVariable MarkUser marker, @RequestParam Long questionId) throws Exception {
-//        List<LevelStatDTO> levelStatDTOs = new ArrayList<>();
-//        markTaskRepo.countGroupByLevel(marker.getId())
-//                .forEach(o -> {
-//                    levelStatAssembler.toDTO(o);
-//                    levelStatDTOs.add();
-//                });
-//        ExamQuestion examQuestion = examQuestionRepo.findOne(questionId);
-//        if (Objects.isNull(examQuestion)) {
-//            throw new Exception("当前考试试卷为空");
-//        }
-//        //获取当前考试当前科目所在地区的所有questionId
-//        List<ExamQuestion> examQuestionList = examQuestionRepo.findAllByAreaCodeAndSubjectAndWorkId(examQuestion.getAreaCode(), examQuestion.getSubject(), examQuestion.getWorkId());
-//        List<Long> questionIds = examQuestionList.stream()
-//                .map(m -> m.getId())
-//                .collect(Collectors.toList());
-//        StringBuilder startSql = new StringBuilder("select t.`result`,sum(if(t.questionId <> t.currentQuesId, 0, t.sumCount)) as sumCount from(SELECT t.result,COUNT(*) as sumCount,t.question_id as questionId,? as currentQuesId FROM mark_task t WHERE t.`question_id` in ( ");
-//        String endSql = " ) and t.stage = 1 GROUP BY t.`result`,t.question_id ORDER BY t.result) t group by t.`result` ";
-//        questionIds.forEach(o -> startSql.append(o).append(","));
-//        //当前老师当前试卷的评档次数
-//        StringBuilder sql = new StringBuilder(startSql.toString().substring(0, startSql.toString().length() - 1));
-//        sql.append(endSql);
-//        String finalSql = sqlUtil.sqlPrint(sql.toString(), questionId);
-//        List list = sqlUtil.execSqlForMap(finalSql);
-//        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));
-////        Map<String, LevelStatDTO> filterLevelMap = new HashMap<>();
-//        for (int i = 0; i < list.size(); i++) {
-//            Map map = (Map) list.get(i);
-//            List finalList = (List) map.values().stream()
-//                    .collect(Collectors.toList());
-//            Object[] o = finalList.toArray();
-//            LevelStatDTO levelStatDTO = levelStatAssembler.toDTO(o);
-//            if (levelStatDTO.getId() == null) {
-//                //当前老师未评档的次数
-////              int gcount = markTaskRepo.countByLevel(marker.getId());
-//                int gcount = markTaskRepo.countByQuestionIdInAndStageAndResultIsNull(questionIds, MarkStage.LEVEL);
-//                levelStatDTO.setGcount(gcount);
-//                levelStatDTOs.add(levelStatDTO);
-//            } else {
-//                //当前老师每个档位已评档位的次数
-////              int gcount = markTaskRepo.countByLevelAndResult(marker.getId(), levelStatDTO.getId().toString());
-//                int gcount = markTaskRepo.countByQuestionIdInAndStageAndResult(questionIds, MarkStage.LEVEL, levelStatDTO.getId().toString());
-//                levelStatDTO.setGcount(gcount);
-//            }
-//            if (Objects.nonNull(levelMap.get(levelStatDTO.getId()))) {
-//                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);
-//
-//                //当前老师当前档位评档次数(所有考试)
-////                int gcount = markTaskRepo.countByLevelAndResult(marker.getId(), level.getCode());
-//                int gcount = markTaskRepo.countByQuestionIdInAndStageAndResult(questionIds, MarkStage.LEVEL, level.getCode());
-//                dto.setGcount(gcount);
-//                levelStatDTOs.add(dto);
-//            }
-//        }
-//
-//        //当前老师当前试卷的评档次数(不分档位)
-////        long kdtotal = markTaskRepo.countByMarkerIdAndQuestionId(marker.getId(), questionId);
-//        long kdtotal = markTaskRepo.countByQuestionIdIn(questionIds);
-//        //当前老师所有的评档次数(不分档位)
-//        long total = markTaskRepo.countByMarkerId(marker.getId());
-////        long total = markTaskRepo.countByQuestionId(questionId);
-//
-//        levelStatDTOs.forEach(o -> {
-//            if (o.getId() != null) {
-//                o.setPt(levelMap.get(o.getId()).getPt());
-//                o.setKdpt(levelMap.get(o.getId()).getKdpt());
-//                double p = (double) o.getCount() / total;
-//                BigDecimal bd = new BigDecimal(p).setScale(3, RoundingMode.HALF_EVEN);
-//                o.setPercent(bd.doubleValue());
-//
-//                double gp = (double) o.getGcount() / kdtotal;
-//                BigDecimal gbd = new BigDecimal(gp).setScale(3, RoundingMode.HALF_EVEN);
-//                o.setGpercent(gbd.doubleValue());
-//            }
-//        });
-//        return levelStatDTOs;
         List<LevelStatDTO> levelStatDTOs = new ArrayList<>();
-//        ExamQuestion examQuestion = examQuestionRepo.findOne(questionId);
-//        if (Objects.isNull(examQuestion)) {
-//            throw new Exception("当前考试试卷为空");
-//        }
         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));
         //统计workId下各考点的数量
         paperRepo.countGroupByLevel(questionId)
                 .forEach(o -> {
-//                    levelStatDTOs.add(levelStatAssembler.toDTO(o));
                     LevelStatDTO levelStatDTO = levelStatAssembler.toDTO(o);
                     if (Objects.isNull(levelStatDTO.getId())) {
-                        int gcount = markTaskRepo.countByLevel(marker.getId());
+                        //求任务数为null的条数
+                        int gcount = markTaskRepo.countByQuestionIdAndStageAndResultIsNull(questionId, MarkStage.LEVEL);
                         levelStatDTO.setGcount(gcount);
-                        levelStatDTOs.add(levelStatDTO);
                     } else {
-                        int gcount = markTaskRepo.countByLevelAndResult(marker.getId(), levelStatDTO.getId().toString());
+                        int gcount = markTaskRepo.countByQuestionIdAndStageAndResult(questionId, MarkStage.LEVEL, levelStatDTO.getId().toString());
                         levelStatDTO.setGcount(gcount);
                     }
-                    if (Objects.nonNull(levelMap.get(levelStatDTO.getId()))) {
-                        levelStatDTOs.add(levelStatDTO);
-                    }
-//                    if (levelStatDTO.getId() == null) {
-//                        //当前老师未评档的次数
-//                        //              int gcount = markTaskRepo.countByLevel(marker.getId());
-//                        int gcount = markTaskRepo.countByQuestionIdInAndStageAndResultIsNull(questionIds, MarkStage.LEVEL);
-//                        levelStatDTO.setGcount(gcount);
-//                        levelStatDTOs.add(levelStatDTO);
-//                    }
+                    levelStatDTOs.add(levelStatDTO);
                 });
 
         for (Level level : levels) {
@@ -235,19 +137,16 @@ public class MakrerApi {
                 dto.setPercent(0.0);
 
                 //当前老师当前档位评档次数(所有考试)
-                int gcount = markTaskRepo.countByLevelAndResult(marker.getId(), level.getCode());
-//                int gcount = markTaskRepo.countByQuestionIdInAndStageAndResult(questionIds, MarkStage.LEVEL, level.getCode());
+                int gcount = markTaskRepo.countByQuestionIdAndStageAndResult(questionId, MarkStage.LEVEL, level.getCode());
                 dto.setGcount(gcount);
                 levelStatDTOs.add(dto);
             }
         }
 
         //当前老师当前试卷的评档次数(不分档位)
-        long kdtotal = markTaskRepo.countByMarkerIdAndQuestionId(marker.getId(), questionId);
-//        long kdtotal = markTaskRepo.countByQuestionIdIn(questionIds);
+        long kdtotal = markTaskRepo.countByQuestionId(questionId);
         //当前老师所有的评档次数(不分档位)
         long total = paperRepo.countByWorkIdAndQuestionId(markSubject.getWorkId(), questionId);
-//        long total = markTaskRepo.countByQuestionId(questionId);
 
         levelStatDTOs.forEach(o -> {
             if (o.getId() != null) {
@@ -262,14 +161,14 @@ public class MakrerApi {
                 double gp = (double) o.getGcount() / kdtotal;
                 BigDecimal gbd = new BigDecimal(gp).setScale(3, RoundingMode.HALF_EVEN);
                 o.setGpercent(gbd.doubleValue());
+
+                int gcount = markTaskRepo.countByQuestionIdAndMarkerIdAndStageAndResult(questionId, marker.getId(), MarkStage.LEVEL, o.getId().toString());
+                o.setGcount(gcount);
             }
         });
         return levelStatDTOs;
     }
 
-    @Autowired
-    private PaperRepo paperRepo;
-
     /**
      * 各试题统计数据
      *

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

@@ -11,7 +11,7 @@ public class LevelStatDTO implements Serializable {
     private static final long serialVersionUID = 3168673814275283746L;
 
     private Object id;//level code
-    private Integer count;
+    private Integer count;//paper总数
     private Integer rejected;
     private Integer arbitrated;
     private Double percent;
@@ -22,7 +22,7 @@ public class LevelStatDTO implements Serializable {
 
     private int gpt;//全局的pt
     private Double gpercent;//全局的percent
-    private Integer gcount;//全局的count
+    private Integer gcount;//全局的count(任务数量总数)
     /**
      * 考点阀值
      */