|
@@ -1,22 +1,21 @@
|
|
package cn.com.qmth.stmms.ms.marking.service;
|
|
package cn.com.qmth.stmms.ms.marking.service;
|
|
|
|
|
|
-import java.util.*;
|
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
-
|
|
|
|
|
|
+import cn.com.qmth.stmms.ms.commons.utils.RandomUtil;
|
|
import cn.com.qmth.stmms.ms.core.domain.MarkStage;
|
|
import cn.com.qmth.stmms.ms.core.domain.MarkStage;
|
|
import cn.com.qmth.stmms.ms.core.domain.MarkSubject;
|
|
import cn.com.qmth.stmms.ms.core.domain.MarkSubject;
|
|
import cn.com.qmth.stmms.ms.core.domain.Paper;
|
|
import cn.com.qmth.stmms.ms.core.domain.Paper;
|
|
-
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
|
-
|
|
|
|
import cn.com.qmth.stmms.ms.core.domain.task.MarkTask;
|
|
import cn.com.qmth.stmms.ms.core.domain.task.MarkTask;
|
|
import cn.com.qmth.stmms.ms.core.domain.user.MarkUser;
|
|
import cn.com.qmth.stmms.ms.core.domain.user.MarkUser;
|
|
import cn.com.qmth.stmms.ms.core.domain.user.MarkerGroup;
|
|
import cn.com.qmth.stmms.ms.core.domain.user.MarkerGroup;
|
|
import cn.com.qmth.stmms.ms.core.repository.MarkTaskRepo;
|
|
import cn.com.qmth.stmms.ms.core.repository.MarkTaskRepo;
|
|
import cn.com.qmth.stmms.ms.core.repository.MarkerGroupRepo;
|
|
import cn.com.qmth.stmms.ms.core.repository.MarkerGroupRepo;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 评卷任务分配
|
|
* 评卷任务分配
|
|
@@ -42,7 +41,7 @@ public class AssignTaskService {
|
|
* @param markers
|
|
* @param markers
|
|
*/
|
|
*/
|
|
@Transactional
|
|
@Transactional
|
|
- public void assignForAll(List<Paper> papers, Iterable<MarkUser> markers, MarkSubject markSubject) {
|
|
|
|
|
|
+ public void assignForAll(List<Paper> papers, Iterable<MarkUser> markers, MarkSubject markSubject) throws Exception {
|
|
List<MarkTask> markTasks = new ArrayList<>();
|
|
List<MarkTask> markTasks = new ArrayList<>();
|
|
int paperCount = papers.size();
|
|
int paperCount = papers.size();
|
|
int randomBundleCount = paperCount / randomBundleSize;
|
|
int randomBundleCount = paperCount / randomBundleSize;
|
|
@@ -65,7 +64,9 @@ public class AssignTaskService {
|
|
Collections.shuffle(markerPaperList);//乱序
|
|
Collections.shuffle(markerPaperList);//乱序
|
|
|
|
|
|
for (int j = 0; j < markerPaperList.size(); j++) {
|
|
for (int j = 0; j < markerPaperList.size(); j++) {
|
|
- MarkTask markTask = new MarkTask(marker, markerPaperList.get(j), markSubject.getStage());
|
|
|
|
|
|
+ Paper paper = markerPaperList.get(j);
|
|
|
|
+ Long random = getRandom(marker.getId(), paper.getId(), marker.getWorkId(), paper.getExamNumber());
|
|
|
|
+ MarkTask markTask = new MarkTask(marker, paper, markSubject.getStage(), random);
|
|
markTask.setRandomSeq(i * randomBundleSize + j + 1);
|
|
markTask.setRandomSeq(i * randomBundleSize + j + 1);
|
|
markTasks.add(markTask);
|
|
markTasks.add(markTask);
|
|
}
|
|
}
|
|
@@ -94,7 +95,7 @@ public class AssignTaskService {
|
|
* @param markerGroups
|
|
* @param markerGroups
|
|
*/
|
|
*/
|
|
@Transactional
|
|
@Transactional
|
|
- public void assignForGrouping(List<Paper> papers, List<MarkerGroup> markerGroups, MarkSubject markSubject) {
|
|
|
|
|
|
+ public void assignForGrouping(List<Paper> papers, List<MarkerGroup> markerGroups, MarkSubject markSubject) throws Exception {
|
|
markerGroups = markerGroups.stream().filter(m -> m.getMarkers().size() > 0).collect(Collectors.toList());
|
|
markerGroups = markerGroups.stream().filter(m -> m.getMarkers().size() > 0).collect(Collectors.toList());
|
|
int groupSize = markerGroups.size();
|
|
int groupSize = markerGroups.size();
|
|
int idx = 0;
|
|
int idx = 0;
|
|
@@ -105,18 +106,46 @@ public class AssignTaskService {
|
|
}
|
|
}
|
|
Paper paper = iterator.next();
|
|
Paper paper = iterator.next();
|
|
for (MarkUser marker : markerGroups.get(idx).getMarkers()) {
|
|
for (MarkUser marker : markerGroups.get(idx).getMarkers()) {
|
|
- MarkTask markTask = new MarkTask(marker, paper, markSubject.getStage());
|
|
|
|
|
|
+ Long random = getRandom(marker.getId(), paper.getId(), marker.getWorkId(), paper.getExamNumber());
|
|
|
|
+ MarkTask markTask = new MarkTask(marker, paper, markSubject.getStage(), random);
|
|
markTaskRepo.save(markTask);
|
|
markTaskRepo.save(markTask);
|
|
}
|
|
}
|
|
idx++;
|
|
idx++;
|
|
}
|
|
}
|
|
//进入分档阶段后,清空当前分组,以便打分阶段前重新分组
|
|
//进入分档阶段后,清空当前分组,以便打分阶段前重新分组
|
|
- if(MarkStage.LEVEL.equals(markSubject.getStage())){
|
|
|
|
- for (MarkerGroup markerGroup : markerGroups) {
|
|
|
|
- markerGroup.setMarkers(null);
|
|
|
|
- }
|
|
|
|
- markerGroupRepo.delete(markerGroups);
|
|
|
|
|
|
+ if (MarkStage.LEVEL.equals(markSubject.getStage())) {
|
|
|
|
+ for (MarkerGroup markerGroup : markerGroups) {
|
|
|
|
+ markerGroup.setMarkers(null);
|
|
|
|
+ }
|
|
|
|
+ markerGroupRepo.delete(markerGroups);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 获取随机号
|
|
|
|
+ *
|
|
|
|
+ * @param markerId
|
|
|
|
+ * @param paperId
|
|
|
|
+ * @param workId
|
|
|
|
+ * @param examNumber
|
|
|
|
+ * @return
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ public Long getRandom(Long markerId, Long paperId, Long workId, String examNumber) throws Exception {
|
|
|
|
+ int count = 0, result = 0;
|
|
|
|
+ Long random = 0L;
|
|
|
|
+ while (true) {
|
|
|
|
+ random = RandomUtil.randomMap.get(workId).get(new Random().nextInt(RandomUtil.randomMap.get(workId).size()));
|
|
|
|
+ result = markTaskRepo.countByMarkerIdAndPaperIdAndWorkIdAndRandomSeqNew(markerId, paperId, workId, random);
|
|
|
|
+ if (result == 0 && random != Long.parseLong(examNumber.substring(3, examNumber.length()))) {
|
|
|
|
+ break;
|
|
|
|
+ } else {
|
|
|
|
+ count++;
|
|
|
|
+ }
|
|
|
|
+ if (count > 100) {
|
|
|
|
+ throw new Exception("重复几率较高,建议重新生成随机号");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return random;
|
|
|
|
+ }
|
|
}
|
|
}
|