|
@@ -7,11 +7,13 @@ import cn.com.qmth.stmms.ms.core.domain.user.MarkerGroup;
|
|
|
import cn.com.qmth.stmms.ms.core.domain.user.Role;
|
|
|
import cn.com.qmth.stmms.ms.core.repository.*;
|
|
|
import cn.com.qmth.stmms.ms.core.vo.Subject;
|
|
|
+import cn.com.qmth.stmms.ms.marking.dto.LevleProgressDTO;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.Hashtable;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -56,16 +58,21 @@ public class StageControlService {
|
|
|
* @param markSubject
|
|
|
*/
|
|
|
@Transactional
|
|
|
- public void goNext(MarkSubject markSubject) throws Exception {
|
|
|
+ public void goNext(MarkSubject markSubject, int taskCount) throws Exception {
|
|
|
if (statusMap.get(markSubject.getId()) != null && statusMap.get(markSubject.getId())) {
|
|
|
return;
|
|
|
}
|
|
|
statusMap.put(markSubject.getId(), true);
|
|
|
MarkStage markStage = markSubject.getStage();
|
|
|
+ //是否还有未投放的试卷
|
|
|
+ int waitCount =paperRepo.countByWorkIdAndSubjectAndIsMissingFalseAndActiveFalseAndBatchNoIsNull(markSubject.getWorkId(), markSubject.getSubject());
|
|
|
+ if(waitCount > 0 && markStage.equals(MarkStage.LEVEL)){
|
|
|
+ markStage = MarkStage.INIT;
|
|
|
+ }
|
|
|
switch (markStage) {
|
|
|
case INIT:
|
|
|
markSubject.setStage(MarkStage.LEVEL);
|
|
|
- enterLevelStage(markSubject);
|
|
|
+ enterLevelStage(markSubject, taskCount);
|
|
|
break;
|
|
|
case LEVEL:
|
|
|
markSubject.setStage(MarkStage.SCORE);
|
|
@@ -93,7 +100,7 @@ public class StageControlService {
|
|
|
*
|
|
|
* @param markSubject
|
|
|
*/
|
|
|
- private void enterLevelStage(MarkSubject markSubject) throws Exception {
|
|
|
+ private void enterLevelStage(MarkSubject markSubject, int taskCount) throws Exception {
|
|
|
Long workId = markSubject.getWorkId();
|
|
|
Subject subject = markSubject.getSubject();
|
|
|
List<Level> levels = levelRepo.findByWorkId(workId);
|
|
@@ -101,7 +108,7 @@ public class StageControlService {
|
|
|
statusMap.put(markSubject.getId(), false);
|
|
|
throw new RuntimeException("没有设定档位");
|
|
|
}
|
|
|
- List<Paper> papers = paperRepo.findByWorkIdAndSubjectAndIsMissingAndTest(workId, subject, false, markSubject.getTest());
|
|
|
+
|
|
|
List<MarkUser> markers = markUserRepo.findByWorkIdAndSubjectAndRole(workId, subject, Role.MARKER);
|
|
|
List<MarkUser> levelMarkers = markers.stream().filter(m -> m.getMarkRight() == MarkRight.ALLOW_ALL || m.getMarkRight() == MarkRight.ALLOW_LEVELING).collect(Collectors.toList());
|
|
|
if (levelMarkers.size() == 0) {
|
|
@@ -118,6 +125,34 @@ public class StageControlService {
|
|
|
statusMap.put(markSubject.getId(), false);
|
|
|
throw new RuntimeException("评卷员没有进行分组");
|
|
|
}
|
|
|
+
|
|
|
+ if(markSubject.getTest() != 1) {
|
|
|
+ //是否有未结束的分档任务
|
|
|
+ int count = paperRepo.countByWorkIdAndSubjectAndLevelIsNullAndIsMissingFalseAndActiveTrueAndBatchNoNotNull(workId, subject);
|
|
|
+ if (count > 0) {
|
|
|
+ statusMap.put(markSubject.getId(), false);
|
|
|
+ throw new RuntimeException("没有分档完成");
|
|
|
+ }
|
|
|
+
|
|
|
+ //任务数量大于0,小于等于待评数量
|
|
|
+ if (taskCount == 0) {
|
|
|
+ statusMap.put(markSubject.getId(), false);
|
|
|
+ throw new RuntimeException("请输入正确的分配任务数量");
|
|
|
+ }
|
|
|
+ int waitCount = paperRepo.countByWorkIdAndSubjectAndIsMissingFalseAndActiveFalseAndBatchNoIsNull(workId, subject);
|
|
|
+ if (taskCount - waitCount > 0) {
|
|
|
+ statusMap.put(markSubject.getId(), false);
|
|
|
+ throw new RuntimeException("分配任务数量不能大于待评数量");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Paper> papers = null;
|
|
|
+ if(markSubject.getTest() == 1) {
|
|
|
+ papers = paperRepo.findByWorkIdAndSubjectAndIsMissingAndTest(workId, subject, false, markSubject.getTest());
|
|
|
+ } else {
|
|
|
+ List<Paper> papersList = paperRepo.findByWorkIdAndSubjectAndIsMissingFalseAndActiveFalse(workId, subject);
|
|
|
+ papers = papersList.subList(0, taskCount);
|
|
|
+ }
|
|
|
assignTaskService.assignForGrouping(papers, markerGroups, markSubject);
|
|
|
}
|
|
|
|
|
@@ -137,14 +172,14 @@ public class StageControlService {
|
|
|
statusMap.put(markSubject.getId(), false);
|
|
|
throw new RuntimeException("没有设定评卷员");
|
|
|
}
|
|
|
- Long count = paperRepo.countByWorkIdAndSubjectAndTestAndLevelIsNull(workId, subject, markSubject.getTest());
|
|
|
+ int count = paperRepo.countByWorkIdAndSubjectAndLevelIsNullAndIsMissingFalseAndActiveTrueAndBatchNoNotNull(workId, subject);
|
|
|
if (count > 0) {
|
|
|
statusMap.put(markSubject.getId(), false);
|
|
|
throw new RuntimeException("没有分档完成");
|
|
|
}
|
|
|
this.isPtFull(workId, markSubject);
|
|
|
Sort sort = new Sort("questionId");
|
|
|
- List<Paper> papers = paperRepo.findByWorkIdAndSubject(workId, subject, sort);
|
|
|
+ List<Paper> papers = paperRepo.findByWorkIdAndSubjectAndIsMissingFalseAndActiveTrueAndBatchNoNotNull(workId, subject, sort);
|
|
|
List<MarkerGroup> markerGroups = markerGroupRepo.findByWorkIdAndSubject(workId, subject);
|
|
|
if (markerGroups.size() == 0) {
|
|
|
statusMap.put(markSubject.getId(), false);
|
|
@@ -216,4 +251,30 @@ public class StageControlService {
|
|
|
markSubjectRepo.save(markSubject);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 分档进度查询
|
|
|
+ *
|
|
|
+ * @param markSubject
|
|
|
+ */
|
|
|
+ public LevleProgressDTO progress(MarkSubject markSubject) {
|
|
|
+ Long workId = markSubject.getWorkId();
|
|
|
+ Subject subject = markSubject.getSubject();
|
|
|
+ //已评任务数
|
|
|
+ int successCount = paperRepo.countByWorkIdAndSubjectAndLevelNotNullAndIsMissingFalseAndActiveTrue(workId, subject);
|
|
|
+ //所有任务数(查询所有有效试卷)
|
|
|
+ int totalCount = paperRepo.countByWorkIdAndSubjectAndIsMissingFalse(workId, subject);
|
|
|
+
|
|
|
+ BigDecimal waitTotal = BigDecimal.valueOf(totalCount).subtract(BigDecimal.valueOf(successCount));
|
|
|
+ //进度
|
|
|
+ BigDecimal progress = BigDecimal.ZERO.compareTo(BigDecimal.valueOf(totalCount)) == 0 ? BigDecimal.ZERO :BigDecimal.valueOf(successCount).divide(BigDecimal.valueOf(totalCount), 4, BigDecimal.ROUND_HALF_UP);
|
|
|
+
|
|
|
+ LevleProgressDTO progressDTO = new LevleProgressDTO();
|
|
|
+ progressDTO.setSuccessCount(successCount);
|
|
|
+ progressDTO.setTotalCount(totalCount);
|
|
|
+ progressDTO.setWaitCount(waitTotal.intValue());
|
|
|
+ progressDTO.setProgress(progress.doubleValue() * 100);
|
|
|
+
|
|
|
+ return progressDTO;
|
|
|
+ }
|
|
|
+
|
|
|
}
|