Bläddra i källkod

线下版本-打分任务发布优化-20201116

xiaof 4 år sedan
förälder
incheckning
55ed31232b

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

@@ -226,4 +226,7 @@ public interface MarkTaskRepo extends JpaRepository<MarkTask, Long>, JpaSpecific
 
 
     @Query(value = "select count(1) from mark_task m where m.work_id = ?1", nativeQuery = true)
     @Query(value = "select count(1) from mark_task m where m.work_id = ?1", nativeQuery = true)
     int countByWorkId(Long workId);
     int countByWorkId(Long workId);
+
+    @Query(value = "select id, random_seq_new randomSeqNew from mark_task m where m.work_id = ?1", nativeQuery = true)
+    List<Object[]> findAllByWorkId(Long workId);
 }
 }

+ 7 - 4
stmms-ms-marking/src/main/java/cn/com/qmth/stmms/ms/marking/service/AssignTaskService.java

@@ -67,7 +67,7 @@ public class AssignTaskService {
             randomBundleCount += 1;
             randomBundleCount += 1;
         }
         }
         List<MarkTask> markTaskList = markTaskRepo.findByWorkId(markSubject.getWorkId());
         List<MarkTask> markTaskList = markTaskRepo.findByWorkId(markSubject.getWorkId());
-        Map<Long, MarkTask> randomMap = markTaskList.stream().collect(Collectors.toMap(MarkTask::getRandomSeqNew, Function.identity(), (dto1, dto2) -> dto1));
+        Map<Long, Object> randomMap = markTaskList.stream().collect(Collectors.toMap(MarkTask::getRandomSeqNew, Function.identity(), (dto1, dto2) -> dto1));
         for (int i = 0; i < randomBundleCount; i++) {
         for (int i = 0; i < randomBundleCount; i++) {
             int fromIndex = i * randomBundleSize;
             int fromIndex = i * randomBundleSize;
             int endIndex = i * randomBundleSize + randomBundleSize;
             int endIndex = i * randomBundleSize + randomBundleSize;
@@ -123,8 +123,11 @@ public class AssignTaskService {
         Iterator<Paper> iterator = papers.iterator();
         Iterator<Paper> iterator = papers.iterator();
         List<MarkTask> markTaskList = new ArrayList<>(papers.size() * sum);
         List<MarkTask> markTaskList = new ArrayList<>(papers.size() * sum);
         List<Paper> paperList = new ArrayList<>(papers.size());
         List<Paper> paperList = new ArrayList<>(papers.size());
-        List<MarkTask> markTasks = markTaskRepo.findByWorkId(markSubject.getWorkId());
-        Map<Long, MarkTask> randomMap = markTasks.stream().collect(Collectors.toMap(MarkTask::getRandomSeqNew, Function.identity(), (dto1, dto2) -> dto1));
+//        List<MarkTask> markTasks = markTaskRepo.findByWorkId(markSubject.getWorkId());
+//        Map<Long, MarkTask> randomMap = markTasks.stream().collect(Collectors.toMap(MarkTask::getRandomSeqNew, Function.identity(), (dto1, dto2) -> dto1));
+        List<Object[]> markTasks = markTaskRepo.findAllByWorkId(markSubject.getWorkId());
+        Map<Long, Object> randomMap = new HashMap<>();
+        markTasks.forEach(m-> randomMap.put(Long.valueOf(m[1].toString()), m[0]));
         //定序序号记录
         //定序序号记录
         Map map = new HashMap();
         Map map = new HashMap();
         while (iterator.hasNext()) {
         while (iterator.hasNext()) {
@@ -278,7 +281,7 @@ public class AssignTaskService {
      * @return
      * @return
      * @throws Exception
      * @throws Exception
      */
      */
-    public Long getRandom(Long markerId, Long paperId, Long workId, String examNumber, Map<Long, MarkTask> randomMap) throws Exception {
+    public Long getRandom(Long markerId, Long paperId, Long workId, String examNumber, Map<Long, Object> randomMap) throws Exception {
         int count = 0;
         int count = 0;
         Long random = 0L;
         Long random = 0L;
         while (true) {
         while (true) {