浏览代码

川音美术阅卷,加了考点阀值的版本,但是没有合并广州的样卷和分数水印功能

YuanPan 7 年之前
父节点
当前提交
6d381e571c

+ 12 - 0
stmms-ms-core/src/main/java/cn/com/qmth/stmms/ms/core/domain/Level.java

@@ -88,6 +88,10 @@ public class Level implements Serializable{
      * 占比阈值。percent thredhold,0-100
      */
     private int pt = 0;
+    /**
+     * 考点阀值
+     */
+    private int kdpt = 0;
 
     public Level(){}
 
@@ -163,4 +167,12 @@ public class Level implements Serializable{
     public void setPt(int pt) {
         this.pt = pt;
     }
+
+    public int getKdpt() {
+        return kdpt;
+    }
+
+    public void setKdpt(int kdpt) {
+        this.kdpt = kdpt;
+    }
 }

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

@@ -36,8 +36,12 @@ public interface MarkTaskRepo extends JpaRepository<MarkTask, Long>, JpaSpecific
 
     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);
+
     int countByWorkIdAndSubjectAndMarkerIdAndStage(Long workId, Subject subject, Long markerId, MarkStage stage);
 
+    int countByWorkIdAndSubjectAndMarkerIdAndStageAndQuestionId(Long workId, Subject subject, Long markerId, MarkStage stage, Long questionId);
+
     /**
      * 查询评卷员的评卷任务
      *
@@ -89,7 +93,22 @@ public interface MarkTaskRepo extends JpaRepository<MarkTask, Long>, JpaSpecific
     @Query(value = "SELECT t.result,COUNT(*) FROM mark_task t " +
             "WHERE t.`question_id` = ? AND t.`marker_id` = ? and t.stage = 1 " +
             "GROUP BY t.`result` ORDER BY t.result", nativeQuery = true)
-    List<Object[]> countGroupByLevel(Long questionId, Long markerId);
+    List<Object[]> countGroupByQuestionIdAndLevel(Long questionId, Long markerId);
+
+    @Query(value = "SELECT t.result,COUNT(*) FROM mark_task t " +
+            "WHERE t.`marker_id` = ? and t.stage = 1 " +
+            "GROUP BY t.`result` ORDER BY t.result", nativeQuery = true)
+    List<Object[]> countGroupByLevel(Long markerId);
+
+
+    @Query(value = "SELECT COUNT(*) FROM mark_task t " +
+            "WHERE t.`marker_id` = ? and t.stage = 1 and t.result = ? ", nativeQuery = true)
+    int countByLevelAndResult(Long markerId, String result);
+
+    @Query(value = "SELECT COUNT(*) FROM mark_task t " +
+            "WHERE t.`marker_id` = ? and t.stage = 1 and t.result is null", nativeQuery = true)
+    int countByLevel(Long markerId);
+
 
     /**
      * 统计指定试卷的所有任务数量

+ 63 - 36
stmms-ms-marking/src/main/java/cn/com/qmth/stmms/ms/marking/api/MakrerApi.java

@@ -37,19 +37,19 @@ public class MakrerApi {
 
     @Autowired
     private MarkUserRepo markUserRepo;
-    
+
     @Autowired
     private MarkTaskRepo markTaskRepo;
 
-	@Autowired
-	private MarkerAssembler markerAssembler;
+    @Autowired
+    private MarkerAssembler markerAssembler;
 
     @Autowired
     private QuestionStatAssembler questionStatAssembler;
-    
+
     @Autowired
     private MarkSubjectRepo markSubjectRepo;
-    
+
     @Autowired
     private LevelRepo levelRepo;
 
@@ -58,66 +58,92 @@ public class MakrerApi {
 
     /**
      * 评卷员信息
+     *
      * @param markerId 评卷员用户id
      * @return
      */
-	@RequestMapping(value = "{markerId}",method = RequestMethod.GET)
-	public MarkerDTO getMarker(@PathVariable Long markerId){
-		MarkUser marker = markUserRepo.findOne(markerId);
-		return markerAssembler.toDTO(marker);
-	}
+    @RequestMapping(value = "{markerId}", method = RequestMethod.GET)
+    public MarkerDTO getMarker(@PathVariable Long markerId) {
+        MarkUser marker = markUserRepo.findOne(markerId);
+        return markerAssembler.toDTO(marker);
+    }
 
     /**
      * 评卷员列表
-     * @param workId 评卷工作id
-     * @param subject 科目
+     *
+     * @param workId    评卷工作id
+     * @param subject   科目
      * @param markStage 允许参与的阶段
      * @return
      */
     @RequestMapping(method = RequestMethod.GET)
     public List<MarkUser> list(@RequestParam Long workId,
                                @RequestParam Subject subject,
-                               @RequestParam MarkStage markStage){
-    	List<MarkUser>  markUsers = markUserRepo.findByWorkIdAndSubjectAndRole(workId,subject, Role.MARKER);
-    	if(MarkStage.LEVEL == markStage ){
-    		markUsers = markUsers.stream().filter(m -> m.getMarkRight() == MarkRight.ALLOW_LEVELING||m.getMarkRight() == MarkRight.ALLOW_ALL).collect(Collectors.toList());
-    	}else if(MarkStage.SCORE == markStage){
-    		markUsers = markUsers.stream().filter(m -> m.getMarkRight() == MarkRight.ALLOW_SCORING||m.getMarkRight() == MarkRight.ALLOW_ALL).collect(Collectors.toList());
-    	}
+                               @RequestParam MarkStage markStage) {
+        List<MarkUser> markUsers = markUserRepo.findByWorkIdAndSubjectAndRole(workId, subject, Role.MARKER);
+        if (MarkStage.LEVEL == markStage) {
+            markUsers = markUsers.stream().filter(m -> m.getMarkRight() == MarkRight.ALLOW_LEVELING || m.getMarkRight() == MarkRight.ALLOW_ALL).collect(Collectors.toList());
+        } else if (MarkStage.SCORE == markStage) {
+            markUsers = markUsers.stream().filter(m -> m.getMarkRight() == MarkRight.ALLOW_SCORING || m.getMarkRight() == MarkRight.ALLOW_ALL).collect(Collectors.toList());
+        }
         return markUsers;
     }
 
     /**
      * 评卷员分档数量及占比数据
-     * @param marker 评卷员用户id
+     *
+     * @param marker     评卷员用户id
      * @param questionId 试题id
      * @return
      */
-    @RequestMapping(value = "{marker}/stat/levels",method = RequestMethod.GET)
-    public List<LevelStatDTO> levelStats(@PathVariable MarkUser marker, @RequestParam Long questionId){
-    	List<LevelStatDTO> levelStatDTOs = new ArrayList<>();
-        markTaskRepo.countGroupByLevel(questionId,marker.getId())
+    @RequestMapping(value = "{marker}/stat/levels", method = RequestMethod.GET)
+    public List<LevelStatDTO> levelStats(@PathVariable MarkUser marker, @RequestParam Long questionId) {
+        List<LevelStatDTO> levelStatDTOs = new ArrayList<>();
+//        markTaskRepo.countGroupByLevel(marker.getId())
+//                .forEach(o -> {
+//                    levelStatAssembler.toDTO(o);
+//                    levelStatDTOs.add();
+//                });
+
+        markTaskRepo.countGroupByQuestionIdAndLevel(questionId, marker.getId())
                 .forEach(o -> {
-                    levelStatDTOs.add(levelStatAssembler.toDTO(o));
+                    LevelStatDTO levelStatDTO = levelStatAssembler.toDTO(o);
+                    if (levelStatDTO.getId() == null) {
+                        int gcount = markTaskRepo.countByLevel(marker.getId());
+                        levelStatDTO.setGcount(gcount);
+                    } else {
+                        int gcount = markTaskRepo.countByLevelAndResult(marker.getId(), levelStatDTO.getId().toString());
+                        levelStatDTO.setGcount(gcount);
+                    }
+                    levelStatDTOs.add(levelStatDTO);
                 });
         MarkSubject markSubject = markSubjectRepo.findOne(marker.getWorkId() + "-" + marker.getSubject().toString());
         List<Level> levels = levelRepo.findByWorkId(markSubject.getWorkId());
-        for(Level level : levels){
+        for (Level level : levels) {
             long count = levelStatDTOs.stream().filter(l -> String.valueOf(l.getId()).equals(level.getCode())).count();
-            if(count == 0){
+            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());
+                dto.setGcount(gcount);
                 levelStatDTOs.add(dto);
             }
         }
-        long total = markTaskRepo.countByMarkerIdAndQuestionId(marker.getId(),questionId);
+        long kdtotal = markTaskRepo.countByMarkerIdAndQuestionId(marker.getId(), questionId);
+        long total = markTaskRepo.countByMarkerId(marker.getId());
+
         levelStatDTOs.forEach(o -> {
-            if(o.getId()!=null){
-                double p = (double)o.getCount()/total;
+            if (o.getId() != null) {
+                double p = (double) o.getCount() / kdtotal;
                 BigDecimal bd = new BigDecimal(p).setScale(3, RoundingMode.HALF_EVEN);
-            	o.setPercent(bd.doubleValue());
+                o.setPercent(bd.doubleValue());
+
+                double gp = (double) o.getGcount() / total;
+                BigDecimal gbd = new BigDecimal(gp).setScale(3, RoundingMode.HALF_EVEN);
+                o.setGpercent(gbd.doubleValue());
             }
         });
         return levelStatDTOs;
@@ -125,16 +151,17 @@ public class MakrerApi {
 
     /**
      * 各试题统计数据
+     *
      * @param marker 评卷员用户id
      * @return
      */
-    @RequestMapping(value = "{marker}/stat/questions",method = RequestMethod.GET)
-    public List<QuestionStatDTO> questions(@PathVariable MarkUser marker){
+    @RequestMapping(value = "{marker}/stat/questions", method = RequestMethod.GET)
+    public List<QuestionStatDTO> questions(@PathVariable MarkUser marker) {
         List<QuestionStatDTO> questionStatDTOs = new ArrayList<>();
         List<Object[]> qStats = null;
         MarkSubject markSubject = markSubjectRepo.findOne(marker.getWorkId() + "-" + marker.getSubject().toString());
-        qStats = markTaskRepo.countGroupByQuestion(marker.getId(),markSubject.getStage().ordinal());
-        if(qStats != null) {
+        qStats = markTaskRepo.countGroupByQuestion(marker.getId(), markSubject.getStage().ordinal());
+        if (qStats != null) {
             for (Object[] objects : qStats) {
                 QuestionStatDTO dto = questionStatAssembler.toDTO(objects);
                 questionStatDTOs.add(dto);
@@ -142,5 +169,5 @@ public class MakrerApi {
         }
         return questionStatDTOs;
     }
-	
+
 }

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

@@ -6,7 +6,7 @@ import java.io.Serializable;
  * 分档统计
  * Created by zhengmin on 2016/10/14.
  */
-public class LevelStatDTO implements Serializable{
+public class LevelStatDTO implements Serializable {
 
     private static final long serialVersionUID = 3168673814275283746L;
 
@@ -17,6 +17,10 @@ public class LevelStatDTO implements Serializable{
     private Double percent;
     private int pt;
 
+    private int gpt;//全局的pt
+    private Double gpercent;//全局的percent
+    private Integer gcount;//全局的count
+
     public Object getId() {
         return id;
     }
@@ -64,4 +68,28 @@ public class LevelStatDTO implements Serializable{
     public void setPt(int pt) {
         this.pt = pt;
     }
+
+    public int getGpt() {
+        return gpt;
+    }
+
+    public void setGpt(int gpt) {
+        this.gpt = gpt;
+    }
+
+    public Double getGpercent() {
+        return gpercent;
+    }
+
+    public void setGpercent(Double gpercent) {
+        this.gpercent = gpercent;
+    }
+
+    public Integer getGcount() {
+        return gcount;
+    }
+
+    public void setGcount(Integer gcount) {
+        this.gcount = gcount;
+    }
 }

+ 8 - 3
stmms-ms-marking/src/main/java/cn/com/qmth/stmms/ms/marking/service/MarkingService.java

@@ -79,10 +79,15 @@ public class MarkingService {
         int count = markTaskRepo.countByWorkIdAndSubjectAndMarkerIdAndStageAndResult(markTask.getWorkId(), markTask.getSubject(), markTask.getMarkerId(), markTask.getStage(), levelCode);
         int total = markTaskRepo.countByWorkIdAndSubjectAndMarkerIdAndStage(markTask.getWorkId(), markTask.getSubject(), markTask.getMarkerId(), markTask.getStage());
 
-        LOG.info("pt = {}, count = {}, total = {}", pt, count, total);
         if ((count + 1.0D) / total * 1.0D > pt / 100.D) {
-
-            throw new RuntimeException(levelCode + "档已满");
+            throw new RuntimeException(levelCode + "档已满,占比总阀值已达" + pt + "%。");
+        }
+        //判断考点阀值是否已满
+        int kdpt = targetLevel.getKdpt();
+        int kdcount = markTaskRepo.countByWorkIdAndSubjectAndMarkerIdAndStageAndQuestionIdAndResult(markTask.getWorkId(), markTask.getSubject(), markTask.getMarkerId(), markTask.getStage(), markTask.getQuestionId(), levelCode);
+        int kdtotal = markTaskRepo.countByWorkIdAndSubjectAndMarkerIdAndStageAndQuestionId(markTask.getWorkId(), markTask.getSubject(), markTask.getMarkerId(), markTask.getStage(), markTask.getQuestionId());
+        if ((kdcount + 1.0D) / kdtotal * 1.0D > kdpt / 100.D) {
+            throw new RuntimeException(levelCode + "档已满,考点阀值已达" + kdpt + "%。");
         }