1
0
Просмотр исходного кода

优化更新评卷质量定时任务
在原有逻辑基础上,过滤未登陆、最后评卷时间超过期限、最近更新时间后没有评卷的评卷员

luoshi 5 лет назад
Родитель
Сommit
1fa2573a1c

+ 34 - 34
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/mark/dao/MarkLibraryDao.java

@@ -4,7 +4,9 @@ import java.util.Date;
 import java.util.List;
 import java.util.Set;
 
+import cn.com.qmth.stmms.common.enums.MarkStatus;
 import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.Modifying;
@@ -17,78 +19,77 @@ public interface MarkLibraryDao extends JpaRepository<MarkLibrary, Integer>, Jpa
 
     List<MarkLibrary> findByExamIdAndSubjectCode(Integer examId, String subjectCode, Pageable page);
 
-    List<MarkLibrary> findByExamIdAndSubjectCodeAndGroupNumberAndStatus(Integer examId, String subjectCode,
-            Integer groupNumber, LibraryStatus status, Pageable page);
+    List<MarkLibrary> findByExamIdAndSubjectCodeAndGroupNumberAndStatus(Integer examId, String subjectCode, Integer groupNumber,
+            LibraryStatus status, Pageable page);
 
-    List<MarkLibrary> findByExamIdAndSubjectCodeAndGroupNumberAndStatusIn(Integer examId, String subjectCode,
-            Integer groupNumber, Set<LibraryStatus> statusSet, Pageable page);
+    List<MarkLibrary> findByExamIdAndSubjectCodeAndGroupNumberAndStatusIn(Integer examId, String subjectCode, Integer groupNumber,
+            Set<LibraryStatus> statusSet, Pageable page);
 
     @Query("select l1 from MarkLibrary l1 where l1.examId=?1 and l1.subjectCode=?2 and l1.groupNumber=?3 and l1.status in (?5) "
             + "and not exists (select l2 from MarkLibrary l2 where l2.studentId=l1.studentId and l2.id!=l1.id and l2.markerId=?4)")
-    List<MarkLibrary> findUnMarked(Integer examId, String subjectCode, Integer groupNumber, Integer markerId,
-            Set<LibraryStatus> statusSet, Pageable page);
+    List<MarkLibrary> findUnMarked(Integer examId, String subjectCode, Integer groupNumber, Integer markerId, Set<LibraryStatus> statusSet,
+            Pageable page);
 
     @Query("select l1 from MarkLibrary l1 where l1.examId=?1 and l1.subjectCode=?2 and l1.groupNumber=?3 and l1.status in (?5) "
             + "and not exists (select l2 from MarkLibrary l2 where l2.studentId=l1.studentId and l2.id!=l1.id and l2.markerId=?4) "
             + "and exists (select mc.id from MarkerClass mc, ExamStudent s where l1.studentId=s.id and mc.markerId=?4 and s.className=mc.className)")
-    List<MarkLibrary> findUnMarkedFilterClass(Integer examId, String subjectCode, Integer groupNumber,
-            Integer markerId, Set<LibraryStatus> statusSet, Pageable page);
+    List<MarkLibrary> findUnMarkedFilterClass(Integer examId, String subjectCode, Integer groupNumber, Integer markerId,
+            Set<LibraryStatus> statusSet, Pageable page);
 
     List<MarkLibrary> findByMarkerId(Integer markerId);
 
+    List<MarkLibrary> findByMarkerIdAndStatus(Integer markerId, LibraryStatus status, Pageable page);
+
     @Query("select l from MarkLibrary l where l.studentId=?1 order by l.groupNumber ")
     List<MarkLibrary> findByStudentId(Integer studentId);
 
     List<MarkLibrary> findByStudentIdAndGroupNumber(Integer studentId, Integer groupNumber);
 
     @Query("select l from MarkLibrary l where l.studentId=?1 and l.groupNumber=?2 and l.status in (?3) ")
-    List<MarkLibrary> findByStudentIdAndGroupNumberAndStatus(Integer studentId, Integer groupNumber,
-            LibraryStatus... status);
+    List<MarkLibrary> findByStudentIdAndGroupNumberAndStatus(Integer studentId, Integer groupNumber, LibraryStatus... status);
 
-    @Query("select count(*) from MarkLibrary f where f.examId=?1 and f.subjectCode=?2 and f.groupNumber=?3")
+    @Query("select count(f) from MarkLibrary f where f.examId=?1 and f.subjectCode=?2 and f.groupNumber=?3")
     long countByExamIdAndSubjectCodeAndGroupNumber(Integer examId, String subjectCode, Integer groupNumber);
 
-    @Query("select count(*) from MarkLibrary f where f.examId=?1 and f.subjectCode=?2 and f.groupNumber=?3 and f.taskNumber=?4")
-    long countByExamIdAndSubjectCodeAndGroupNumberAndTaskNumber(Integer examId, String subjectCode,
-            Integer groupNumber, Integer taskNumber);
+    @Query("select count(f) from MarkLibrary f where f.examId=?1 and f.subjectCode=?2 and f.groupNumber=?3 and f.taskNumber=?4")
+    long countByExamIdAndSubjectCodeAndGroupNumberAndTaskNumber(Integer examId, String subjectCode, Integer groupNumber,
+            Integer taskNumber);
 
-    @Query("select count(*) from MarkLibrary f where f.examId=?1 and f.subjectCode=?2 and f.groupNumber=?3 and f.status in (?4)")
+    @Query("select count(f) from MarkLibrary f where f.examId=?1 and f.subjectCode=?2 and f.groupNumber=?3 and f.status in (?4)")
     long countByExamIdAndSubjectCodeAndGroupNumberAndStatus(Integer examId, String subjectCode, Integer groupNumber,
             LibraryStatus... status);
 
-    @Query("select count(*) from MarkLibrary f where f.studentId=?1 and f.groupNumber=?2")
+    @Query("select count(f) from MarkLibrary f where f.studentId=?1 and f.groupNumber=?2")
     long countByStudentIdAndGroupNumber(Integer studentId, Integer groupNumber);
 
-    @Query("select count(*) from MarkLibrary f where f.studentId=?1 and f.markerId=?2")
+    @Query("select count(f) from MarkLibrary f where f.studentId=?1 and f.markerId=?2")
     long countByStudentIdAndMarkerId(Integer studentId, Integer markerId);
 
-    @Query("select count(*) from MarkLibrary f where f.studentId=?1 and f.markerId=?2 and f.id!=?3")
+    @Query("select count(f) from MarkLibrary f where f.studentId=?1 and f.markerId=?2 and f.id!=?3")
     long countByStudentIdAndMarkerIdAndIdNotEqual(Integer studentId, Integer markerId, Integer id);
 
     @Modifying(clearAutomatically = true)
     @Query("update MarkLibrary m set m.status=?4, m.markerId=null, m.markerTime=null, m.markerScore=null, m.markerScoreList=null, m.markerSpent=null, "
             + "m.headerId=null , m.headerTime=null , m.headerScore=null , m.headerScoreList=null where m.examId=?1 and m.subjectCode=?2 and m.groupNumber=?3")
-    void resetByExamIdAndSubjectCodeAndGroupNumber(Integer examId, String subjectCode, Integer groupNumber,
-            LibraryStatus status);
+    void resetByExamIdAndSubjectCodeAndGroupNumber(Integer examId, String subjectCode, Integer groupNumber, LibraryStatus status);
 
     @Modifying(clearAutomatically = true)
     @Query("update MarkLibrary m set m.status=?2, m.markerId=null, m.markerTime=null, m.markerScore=null, m.markerScoreList=null, m.markerSpent=null, "
             + "m.headerId=null , m.headerTime=null , m.headerScore=null , m.headerScoreList=null  where m.markerId=?1 and m.status!=?3 and m.status not in (?4) ")
-    void resetByMarkerId(Integer markerId, LibraryStatus status, LibraryStatus libraryStatus1,
-            LibraryStatus... libraryStatus);
+    void resetByMarkerId(Integer markerId, LibraryStatus status, LibraryStatus libraryStatus1, LibraryStatus... libraryStatus);
 
     @Modifying(clearAutomatically = true)
     @Query("update MarkLibrary m set m.status=?2, m.markerId=null, m.markerTime=null, m.markerScore=null, m.markerScoreList=null, m.markerSpent=null, "
             + "m.headerId=null , m.headerTime=null , m.headerScore=null , m.headerScoreList=null where m.id=?1 and m.status in (?3)")
     int resetById(Integer id, LibraryStatus newStatus, LibraryStatus... previousStatus);
 
-    @Query("select f.markerId, count(*) as markerCount from MarkLibrary f where f.examId=?1 and f.status in (?2) group by f.markerId")
+    @Query("select f.markerId, count(f) as markerCount from MarkLibrary f where f.examId=?1 and f.status in (?2) group by f.markerId")
     List<Object[]> countMarkerAndStatus(Integer examId, LibraryStatus... status);
 
-    @Query("select f.markerId, count(*) as markerCount from MarkLibrary f where f.examId=?1 and f.subjectCode=?2 and f.status in (?3) group by f.markerId")
+    @Query("select f.markerId, count(f) as markerCount from MarkLibrary f where f.examId=?1 and f.subjectCode=?2 and f.status in (?3) group by f.markerId")
     List<Object[]> countMarkerAndStatus(Integer examId, String subjectCode, LibraryStatus... status);
 
-    @Query("select count(*) from MarkLibrary f where f.markerId=?1 and f.status in (?2)")
+    @Query("select count(f) from MarkLibrary f where f.markerId=?1 and f.status in (?2)")
     long countByMarkerAndStatus(Integer markerId, LibraryStatus... status);
 
     @Modifying
@@ -105,8 +106,8 @@ public interface MarkLibraryDao extends JpaRepository<MarkLibrary, Integer>, Jpa
     @Modifying(clearAutomatically = true)
     @Query("update MarkLibrary m set m.headerId=?3, m.headerScore=?4, m.headerScoreList=?5, m.headerTime=?6, m.status=?7 "
             + " where m.studentId=?1 and m.groupNumber=?2")
-    void updateHeaderResult(Integer studentId, Integer groupNumber, Integer userId, Double totalScore,
-            String scoreList, Date updateTime, LibraryStatus arbitrated);
+    void updateHeaderResult(Integer studentId, Integer groupNumber, Integer userId, Double totalScore, String scoreList, Date updateTime,
+            LibraryStatus arbitrated);
 
     @Modifying(clearAutomatically = true)
     @Query("update MarkLibrary m set m.status=?3 where m.studentId=?1 and m.groupNumber=?2")
@@ -115,20 +116,19 @@ public interface MarkLibraryDao extends JpaRepository<MarkLibrary, Integer>, Jpa
     @Modifying(clearAutomatically = true)
     @Query("update MarkLibrary l set l.status=?2, l.markerId=?3, l.markerScore=?4, l.markerScoreList=?5, l.markerTime=?6, "
             + "l.markerSpent=?7 where l.id=?1 and l.status in (?8) and (l.markerId=null or l.markerId=?3)")
-    int updateMarkerResult(Integer id, LibraryStatus newStatus, Integer markerId, Double markerScore,
-            String markerScoreList, Date markerTime, Integer spent, LibraryStatus... previousStatus);
+    int updateMarkerResult(Integer id, LibraryStatus newStatus, Integer markerId, Double markerScore, String markerScoreList,
+            Date markerTime, Integer spent, LibraryStatus... previousStatus);
 
-    @Query("select m.markerScore ,count(*) from MarkLibrary m where m.examId=?1 and m.subjectCode=?2 and m.groupNumber=?3 and m.markerId=?4 and m.status in (?5) group by m.markerScore ")
-    List<Object[]> findScoreCount(int examId, String subjectCode, Integer groupNumber, Integer markerId,
-            LibraryStatus... status);
+    @Query("select m.markerScore ,count(m) from MarkLibrary m where m.examId=?1 and m.subjectCode=?2 and m.groupNumber=?3 and m.markerId=?4 and m.status in (?5) group by m.markerScore ")
+    List<Object[]> findScoreCount(int examId, String subjectCode, Integer groupNumber, Integer markerId, LibraryStatus... status);
 
     @Query("select m.markerScore from MarkLibrary m where m.examId=?1 and m.subjectCode=?2 and m.groupNumber=?3 and m.status in (?4) group by m.markerScore ")
     List<Double> findScore(int examId, String subjectCode, Integer groupNumber, LibraryStatus... status);
 
     @Modifying
     @Query("delete MarkLibrary m where m.examId=?1 and m.subjectCode=?2 and m.groupNumber=?3 and m.taskNumber=?4")
-    void deleteByExamIdAndSubjectCodeAndGroupNumberAndTaskNumber(Integer examId, String subjectCode,
-            Integer groupNumber, Integer taskNumber);
+    void deleteByExamIdAndSubjectCodeAndGroupNumberAndTaskNumber(Integer examId, String subjectCode, Integer groupNumber,
+            Integer taskNumber);
 
     @Modifying(clearAutomatically = true)
     @Query("update MarkLibrary l set l.status=?2, l.markerId=?3, l.markerTime=?4, "

+ 8 - 3
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/mark/service/Impl/MarkCronService.java

@@ -63,6 +63,9 @@ public class MarkCronService {
     @Value("${mark.cleanTimeoutMinute}")
     private long timeoutMinute;
 
+    @Value("${mark.activeExpireMinute}")
+    private long markerActiveExpireMinute;
+
     /**
      * 自动释放可清除的锁
      */
@@ -112,7 +115,7 @@ public class MarkCronService {
      */
     @Scheduled(fixedDelay = 60 * 1000, initialDelay = 60 * 1000)
     public void updateMarkerQuality() {
-        log.debug("start auto-update marker");
+        log.info("start auto-update marker");
         try {
             List<Integer> examIds = groupService.findExamIdByStatus(MarkStatus.FORMAL);
             for (Integer examId : examIds) {
@@ -121,7 +124,7 @@ public class MarkCronService {
         } catch (Exception e) {
             log.error("auto-update marker error", e);
         } finally {
-            log.debug("finish auto-update marker");
+            log.info("finish auto-update marker");
         }
     }
 
@@ -134,7 +137,9 @@ public class MarkCronService {
                 List<Marker> markers = markerService.findByExamAndSubjectAndGroup(examId, subject.getCode(), markGroup.getNumber());
                 for (Marker marker : markers) {
                     try {
-                        markService.updateQuality(marker);
+                        if (markService.needUpdateQuality(marker, markerActiveExpireMinute)) {
+                            markService.updateQuality(marker);
+                        }
                     } catch (Exception e) {
                         log.error("update marker quality error for markerId=" + marker.getId(), e);
                     }

+ 105 - 87
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/mark/service/Impl/MarkServiceImpl.java

@@ -1,16 +1,16 @@
 package cn.com.qmth.stmms.biz.mark.service.Impl;
 
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
 
+import cn.com.qmth.stmms.biz.mark.query.MarkLibrarySearchQuery;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -111,11 +111,13 @@ public class MarkServiceImpl implements MarkService {
     @Autowired
     private ProblemHistoryDao problemHistoryDao;
 
+    private Map<Integer, Long> markerLastUpdateTime = new ConcurrentHashMap<>();
+
     /**
-     * 某个大题已申请的评卷任务数量
+     * 某个评卷分组已申请的评卷任务数量
      *
-     * @param group
-     * @return
+     * @param group - 评卷分组
+     * @return int
      */
     @Override
     public int applyCount(MarkGroup group) {
@@ -131,9 +133,8 @@ public class MarkServiceImpl implements MarkService {
     /**
      * 某个评卷员已申请的评卷任务数量
      *
-     * @param marker
-     * @param status
-     * @return
+     * @param marker - 评卷员
+     * @return int
      */
     @Override
     public int applyCount(Marker marker) {
@@ -154,9 +155,8 @@ public class MarkServiceImpl implements MarkService {
     /**
      * 某个评卷员已完成的评卷任务数量
      *
-     * @param marker
-     * @param status
-     * @return
+     * @param marker - 评卷员
+     * @return long
      */
     @Override
     public long markedCount(Marker marker) {
@@ -176,9 +176,9 @@ public class MarkServiceImpl implements MarkService {
     }
 
     /**
-     * 释放某个大题的锁定任务
+     * 释放某个评卷分组的锁定任务
      *
-     * @param group
+     * @param group - 评卷分组
      */
     @Override
     public void releaseByGroup(MarkGroup group) {
@@ -190,9 +190,9 @@ public class MarkServiceImpl implements MarkService {
     }
 
     /**
-     * 重置某个大题的所有评卷任务
+     * 重置某个评卷分组的所有评卷任务
      *
-     * @param group
+     * @param group - 评卷分组
      */
     @Override
     @Transactional
@@ -201,9 +201,9 @@ public class MarkServiceImpl implements MarkService {
     }
 
     /**
-     * 删除某个大题
+     * 删除某个评卷分组
      *
-     * @param group
+     * @param group - 评卷分组
      */
     @Override
     @Transactional
@@ -235,9 +235,9 @@ public class MarkServiceImpl implements MarkService {
     }
 
     /**
-     * 修改某个大题给分步骤,并重置评卷任务
+     * 修改某个评卷分组给分步骤,并重置评卷任务
      *
-     * @param group
+     * @param group - 评卷分组
      */
     @Override
     @Transactional
@@ -261,8 +261,8 @@ public class MarkServiceImpl implements MarkService {
     /**
      * 评卷员申请领取某个正式评卷任务
      *
-     * @param library
-     * @param marker
+     * @param library - 正评任务
+     * @param marker  - 评卷员
      */
     @Override
     public boolean applyLibrary(MarkLibrary library, Marker marker) {
@@ -278,8 +278,9 @@ public class MarkServiceImpl implements MarkService {
     /**
      * 评卷员申请领取某个试评评卷任务
      *
-     * @param library
-     * @param marker
+     * @param library - 试评任务
+     * @param marker  - 评卷员
+     * @return boolean
      */
     @Override
     public boolean applyLibrary(TrialLibrary library, Marker marker) {
@@ -289,9 +290,9 @@ public class MarkServiceImpl implements MarkService {
     /**
      * 评卷员是否已领取了某个正式评卷任务
      *
-     * @param library
-     * @param marker
-     * @return
+     * @param library - 正评任务
+     * @param marker  - 评卷员
+     * @return boolean
      */
     @Override
     public boolean hasApplied(MarkLibrary library, Marker marker) {
@@ -301,9 +302,9 @@ public class MarkServiceImpl implements MarkService {
     /**
      * 评卷员是否已领取了某个试评评卷任务
      *
-     * @param library
-     * @param marker
-     * @return
+     * @param library - 试评任务
+     * @param marker  - 评卷员
+     * @return boolean
      */
     @Override
     public boolean hasApplied(TrialLibrary library, Marker marker) {
@@ -313,8 +314,8 @@ public class MarkServiceImpl implements MarkService {
     /**
      * 释放某个评卷员已领取的正评任务
      *
-     * @param library
-     * @param marker
+     * @param library - 正评任务
+     * @param marker  - 评卷员
      */
     @Override
     public void releaseLibrary(MarkLibrary library, Marker marker) {
@@ -324,8 +325,8 @@ public class MarkServiceImpl implements MarkService {
     /**
      * 释放某个评卷员已领取的试评任务
      *
-     * @param library
-     * @param marker
+     * @param library - 试评任务
+     * @param marker  - 评卷员
      */
     @Override
     public void releaseLibrary(TrialLibrary library, Marker marker) {
@@ -335,8 +336,7 @@ public class MarkServiceImpl implements MarkService {
     /**
      * 释放某个评卷员的所有锁定任务
      *
-     * @param marker
-     * @param group
+     * @param marker - 评卷员
      */
     @Override
     public void releaseByMarker(Marker marker) {
@@ -347,7 +347,7 @@ public class MarkServiceImpl implements MarkService {
     /**
      * 重置某个评卷员
      *
-     * @param marker
+     * @param marker - 评卷员
      */
     @Override
     @Transactional
@@ -373,9 +373,9 @@ public class MarkServiceImpl implements MarkService {
     }
 
     /**
-     * 根据考生ID删除评卷任务
+     * 根据考生删除评卷任务
      *
-     * @param studentId
+     * @param student - 考生
      */
     @Override
     @Transactional
@@ -398,14 +398,14 @@ public class MarkServiceImpl implements MarkService {
     /**
      * 评卷员提交评卷任务
      *
-     * @param task
-     * @param marker
-     * @return
+     * @param result - 评卷结果
+     * @param marker - 评卷员
+     * @return boolean
      */
     @Override
     @Transactional
     public boolean submitTask(MarkResult result, Marker marker) {
-        // 判断大题是否存在/评卷是否结束
+        // 判断评卷分组是否存在/评卷是否结束
         MarkGroup group = groupDao.findOne(marker.getExamId(), marker.getSubjectCode(), marker.getGroupNumber());
         if (group == null || group.getStatus() == MarkStatus.FINISH || group.getStatus().getValue() != result.getStatusValue()) {
             return false;
@@ -414,7 +414,7 @@ public class MarkServiceImpl implements MarkService {
         // 根据评卷状态选择读取不同的评卷任务
         if (group.getStatus() == MarkStatus.FORMAL) {
             MarkLibrary library = libraryDao.findOne(result.getLibraryId());
-            if (result.isProblem()) {
+            if (library != null && result.isProblem()) {
                 ProblemHistory history = new ProblemHistory();
                 history.setCreateTime(new Date());
                 history.setExamId(library.getExamId());
@@ -481,10 +481,10 @@ public class MarkServiceImpl implements MarkService {
     /**
      * 评卷员提交某个正评任务
      *
-     * @param library
-     * @param marker
-     * @param trackMap
-     * @param tagList
+     * @param library - 正评任务
+     * @param marker  - 评卷员
+     * @param group   - 评卷分组
+     * @param result  - 评卷结果
      */
     private boolean submitLibrary(MarkLibrary library, Marker marker, MarkGroup group, MarkResult result) {
         // 非本人领取的待评任务
@@ -614,7 +614,7 @@ public class MarkServiceImpl implements MarkService {
      * 管理员/组长打回某个评卷任务<br>
      * 暂时不用到BACKED状态,直接等同于重置该评卷任务
      *
-     * @param library
+     * @param library - 正评任务
      */
     @Override
     @Transactional
@@ -639,7 +639,7 @@ public class MarkServiceImpl implements MarkService {
     /**
      * 管理员/组长重置某个试评任务
      *
-     * @param library
+     * @param library - 试评任务
      */
     @Override
     @Transactional
@@ -657,7 +657,7 @@ public class MarkServiceImpl implements MarkService {
     /**
      * 管理员/组长处理仲裁卷
      *
-     * @param history
+     * @param history - 仲裁卷
      */
     @Override
     @Transactional
@@ -675,9 +675,8 @@ public class MarkServiceImpl implements MarkService {
     /**
      * 对某个考生某个科目进行主观题统分
      *
-     * @param examId
-     * @param subjectCode
-     * @param studentId
+     * @param student - 考生
+     * @param groups  - 所有评卷分组
      */
     @Override
     @Transactional
@@ -685,9 +684,9 @@ public class MarkServiceImpl implements MarkService {
         if (student == null || groups == null || groups.isEmpty()) {
             return;
         }
-        List<ScoreItem> scoreList = new ArrayList<ScoreItem>();
+        List<ScoreItem> scoreList = new ArrayList<>();
         double totalScore = 0.0;
-        // 循环所有大题
+        // 循环所有评卷分组
         for (MarkGroup group : groups) {
             if (group.getStatus().equals(MarkStatus.TRIAL)) {
                 return;
@@ -708,7 +707,7 @@ public class MarkServiceImpl implements MarkService {
 
     private boolean calculateGroup(MarkGroup group, Integer studentId) {
         double score = 0;
-        List<ScoreItem> detail = new ArrayList<ScoreItem>();
+        List<ScoreItem> detail = new ArrayList<>();
         int count = 0;
         // 未设置算分策略的情况下,默认取平均分
         ScorePolicy policy = group.getScorePolicy() != null ? group.getScorePolicy() : ScorePolicy.AVG;
@@ -728,7 +727,7 @@ public class MarkServiceImpl implements MarkService {
             // Collections.sort(list,
             // Comparator.comparing(MarkLibrary::getMarkerScore));
             // 从小到大排序
-            Collections.sort(list, new Comparator<MarkLibrary>() {
+            list.sort(new Comparator<MarkLibrary>() {
 
                 @Override
                 public int compare(MarkLibrary o1, MarkLibrary o2) {
@@ -793,8 +792,7 @@ public class MarkServiceImpl implements MarkService {
         // 取平均分策略下,累计分数需要重新计算一次
         if (policy == ScorePolicy.AVG && count > 1) {
             score = score / count;
-            for (int i = 0; i < detail.size(); i++) {
-                ScoreItem item = detail.get(i);
+            for (ScoreItem item : detail) {
                 item.setScore(item.getScore() / count);
             }
         }
@@ -811,9 +809,9 @@ public class MarkServiceImpl implements MarkService {
     }
 
     /**
-     * 更新某个大题已评任务数量
+     * 更新某个评卷分组已评任务数量
      *
-     * @param group
+     * @param group - 评卷分组
      */
     @Override
     @Transactional
@@ -829,9 +827,9 @@ public class MarkServiceImpl implements MarkService {
     }
 
     /**
-     * 更新某个大题评卷任务总量
+     * 更新某个评卷分组评卷任务总量
      *
-     * @param group
+     * @param group - 评卷分组
      */
     @Override
     @Transactional
@@ -848,11 +846,10 @@ public class MarkServiceImpl implements MarkService {
     }
 
     /**
-     * 更新某个科目所有大题评卷任务数量
+     * 更新某个科目所有评卷分组评卷任务数量
      *
-     * @param examId
-     * @param subjectCode
-     * @param groupNumber
+     * @param examId      - 考试ID
+     * @param subjectCode - 科目代码
      */
     @Transactional
     @Override
@@ -865,12 +862,12 @@ public class MarkServiceImpl implements MarkService {
     }
 
     /**
-     * 根据考生、学习中心、大题构造正式评卷任务
+     * 根据考生、学习中心、评卷分组构造正式评卷任务
      *
-     * @param student
-     * @param campus
-     * @param group
-     * @param subject
+     * @param student - 考生
+     * @param campus  - 学习中心
+     * @param group   - 评卷分组
+     * @param subject - 科目
      */
     @Override
     @Transactional
@@ -922,11 +919,11 @@ public class MarkServiceImpl implements MarkService {
     }
 
     /**
-     * 根据考生、学习中心、大题构造试评评卷任务
+     * 根据考生、学习中心、评卷分组构造试评评卷任务
      *
-     * @param student
-     * @param campus
-     * @param group
+     * @param student - 考生
+     * @param campus  - 学习中心
+     * @param group   - 评卷分组
      */
     @Override
     @Transactional
@@ -948,8 +945,7 @@ public class MarkServiceImpl implements MarkService {
      * 领取正式评卷任务时,用来区分的唯一标识<br/>
      * 多评时同一个考生的多份任务不能被同一位评卷员领取
      *
-     * @param library
-     * @return
+     * @param library - 正评任务
      */
     private String getApplyTaskId(MarkLibrary library) {
         return library.getStudentId() + "_" + library.getGroupNumber();
@@ -958,8 +954,7 @@ public class MarkServiceImpl implements MarkService {
     /**
      * 领取试评评卷任务时,用来区分的唯一标识
      *
-     * @param library
-     * @return
+     * @param library - 试评任务
      */
     private String getApplyTaskId(TrialLibrary library, Marker marker) {
         return library.getId() + "_" + marker.getId();
@@ -968,7 +963,7 @@ public class MarkServiceImpl implements MarkService {
     /**
      * 重置评卷分组的连带操作
      *
-     * @param group
+     * @param group - 评卷分组
      */
     private void resetGroup(MarkGroup group) {
         if (group.getStatus() == MarkStatus.FORMAL) {
@@ -994,7 +989,7 @@ public class MarkServiceImpl implements MarkService {
     /**
      * 计算并更新指定评卷员的评卷质量指标
      *
-     * @param marker
+     * @param marker - 评卷员
      */
     @Override
     @Transactional
@@ -1008,7 +1003,6 @@ public class MarkServiceImpl implements MarkService {
         double stdevScore = 0;
         double sumSpent = 0;
         double avgSpent = 0;
-        BigDecimal bd = BigDecimal.ZERO;
         for (MarkLibrary library : list) {
             finishCount++;
             if (library.getStatus() == LibraryStatus.MARKED || library.getStatus() == LibraryStatus.INSPECTED) {
@@ -1028,11 +1022,35 @@ public class MarkServiceImpl implements MarkService {
             }
         }
         markerDao.updateQualityById(marker.getId(), finishCount, validCount, avgSpent / 1000, avgScore, stdevScore);
+        markerLastUpdateTime.put(marker.getId(), System.currentTimeMillis());
     }
 
     private double sumTotalScore(Integer examId, String subjectCode) {
         Double score = groupDao.sumTotalScore(examId, subjectCode);
-        return score != null ? score.doubleValue() : 0d;
+        return score != null ? score : 0d;
+    }
+
+    @Override
+    public boolean needUpdateQuality(Marker marker, long expireMinutes) {
+        if (marker == null || marker.getLastLoginTime() == null) {
+            return false;
+        }
+        Long lastUpdateTime = markerLastUpdateTime.get(marker.getId());
+        MarkLibrarySearchQuery query = new MarkLibrarySearchQuery();
+        query.setPageNumber(1);
+        query.setPageSize(1);
+        query.setSort(new Sort(Sort.Direction.DESC, "markerTime"));
+        List<MarkLibrary> list = libraryDao.findByMarkerIdAndStatus(marker.getId(), LibraryStatus.MARKED, query);
+        MarkLibrary library = list.isEmpty() ? null : list.get(0);
+        if (library != null && library.getMarkerTime() != null) {
+            long lastMarkTime = library.getMarkerTime().getTime();
+            if (lastUpdateTime != null && lastUpdateTime > lastMarkTime) {
+                return false;
+            } else {
+                return (System.currentTimeMillis() - lastMarkTime) < (expireMinutes * 60 * 1000);
+            }
+        }
+        return false;
     }
 
 }

+ 36 - 27
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/mark/service/MarkService.java

@@ -19,7 +19,7 @@ public interface MarkService {
 
     /**
      * 释放某个评卷员已领取的正评任务
-     * 
+     *
      * @param library
      * @param marker
      */
@@ -27,7 +27,7 @@ public interface MarkService {
 
     /**
      * 释放某个评卷员已领取的试评任务
-     * 
+     *
      * @param library
      * @param marker
      */
@@ -35,28 +35,28 @@ public interface MarkService {
 
     /**
      * /** 释放某个大题的锁定任务
-     * 
+     *
      * @param group
      */
     void releaseByGroup(MarkGroup group);
 
     /**
      * 重置某个大题的所有评卷任务
-     * 
+     *
      * @param group
      */
     void resetByGroup(MarkGroup group);
 
     /**
      * 删除某个大题
-     * 
+     *
      * @param group
      */
     void deleteGroup(MarkGroup group);
 
     /**
      * 修改并重置某个大题
-     * 
+     *
      * @param group
      * @param third
      */
@@ -64,7 +64,7 @@ public interface MarkService {
 
     /**
      * 评卷员申请领取某个正式评卷任务
-     * 
+     *
      * @param library
      * @param marker
      */
@@ -72,7 +72,7 @@ public interface MarkService {
 
     /**
      * 评卷员申请领取某个试评评卷任务
-     * 
+     *
      * @param library
      * @param marker
      * @return
@@ -81,7 +81,7 @@ public interface MarkService {
 
     /**
      * 评卷员是否已领取某个正式评卷任务
-     * 
+     *
      * @param library
      * @param marker
      * @return
@@ -90,7 +90,7 @@ public interface MarkService {
 
     /**
      * 评卷员是否已领取某个试评评卷任务
-     * 
+     *
      * @param library
      * @param marker
      * @return
@@ -99,7 +99,7 @@ public interface MarkService {
 
     /**
      * 释放某个评卷员的所有锁定任务
-     * 
+     *
      * @param marker
      * @param group
      */
@@ -107,21 +107,21 @@ public interface MarkService {
 
     /**
      * 重置某个评卷员
-     * 
+     *
      * @param marker
      */
     void resetMarker(Marker marker);
 
     /**
      * 根据考生删除评卷任务
-     * 
+     *
      * @param student
      */
     void deleteByStudent(ExamStudent student);
 
     /**
      * 对某个考生某个科目进行主观题统分
-     * 
+     *
      * @param student
      * @param groups
      */
@@ -129,14 +129,14 @@ public interface MarkService {
 
     /**
      * 管理员/组长处理仲裁卷
-     * 
+     *
      * @param history
      */
     void processArbitrate(ArbitrateHistory history);
 
     /**
      * 管理员/组长打回某个评卷任务
-     * 
+     *
      * @param library
      * @return
      */
@@ -144,21 +144,21 @@ public interface MarkService {
 
     /**
      * 更新某个大题已评任务数量
-     * 
+     *
      * @param group
      */
     void updateMarkedCount(MarkGroup group);
 
     /**
      * 更新某个大题评卷任务总量
-     * 
+     *
      * @param group
      */
     void updateLibraryCount(MarkGroup group);
 
     /**
      * 更新某个科目所有大题评卷任务总量与已评数量
-     * 
+     *
      * @param examId
      * @param subjectCode
      */
@@ -166,7 +166,7 @@ public interface MarkService {
 
     /**
      * 某个大题已申请的评卷任务数量
-     * 
+     *
      * @param group
      * @return
      */
@@ -174,7 +174,7 @@ public interface MarkService {
 
     /**
      * 某个评卷员已申请的评卷任务数量
-     * 
+     *
      * @param marker
      * @return
      */
@@ -182,7 +182,7 @@ public interface MarkService {
 
     /**
      * 根据考生、学习中心、大题构造正式评卷任务
-     * 
+     *
      * @param student
      * @param campus
      * @param group
@@ -192,7 +192,7 @@ public interface MarkService {
 
     /**
      * 根据考生、学习中心、大题构造试评评卷任务
-     * 
+     *
      * @param student
      * @param campus
      * @param group
@@ -201,7 +201,7 @@ public interface MarkService {
 
     /**
      * 评卷员提交评卷任务
-     * 
+     *
      * @param task
      * @param marker
      * @return
@@ -210,7 +210,7 @@ public interface MarkService {
 
     /**
      * 管理员/组长重置某个试评任务
-     * 
+     *
      * @param library
      * @return
      */
@@ -218,7 +218,7 @@ public interface MarkService {
 
     /**
      * 某个评卷员已完成的评卷任务数量
-     * 
+     *
      * @param marker
      * @return
      */
@@ -226,9 +226,18 @@ public interface MarkService {
 
     /**
      * 计算并更新指定评卷员的评卷质量指标
-     * 
+     *
      * @param marker
      */
     void updateQuality(Marker marker);
 
+    /**
+     * 判断评卷员是否需要更新评卷质量
+     *
+     * @param marker
+     * @param expireMinutes
+     * @return
+     */
+    boolean needUpdateQuality(Marker marker, long expireMinutes);
+
 }

+ 4 - 3
stmms-web/src/main/webapp/WEB-INF/application.properties

@@ -1,9 +1,9 @@
 #jdbc config
 driverClassName=com.mysql.jdbc.Driver
 #jdbc config
-url=jdbc:mysql://localhost:3306/stmms_ft?useUnicode=true&characterEncoding=UTF-8
-username=root
-password=root
+url=jdbc:mysql://192.168.10.30:3306/stmms_ft?useUnicode=true&characterEncoding=UTF-8
+username=stmms
+password=stmms
 
 #cookie config
 cookie.max.age=36000
@@ -39,6 +39,7 @@ upyun.slice.username=
 upyun.slice.password=
 
 mark.cleanTimeoutMinute=20
+mark.activeExpireMinute=30
 mark.cleanTaskSchedule=0 0/10 6-23 * * ?
 mark.cleanLockSchedule=0 0 3 * * ?