|
@@ -16,13 +16,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.qmth.boot.core.concurrent.service.ConcurrentService;
|
|
|
import com.qmth.boot.core.exception.ParameterException;
|
|
|
import com.qmth.teachcloud.common.entity.MarkQuestion;
|
|
|
-import com.qmth.teachcloud.common.entity.SysUser;
|
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
import com.qmth.teachcloud.common.enums.QuestionType;
|
|
|
import com.qmth.teachcloud.common.enums.ScanStatus;
|
|
@@ -32,12 +29,14 @@ import com.qmth.teachcloud.mark.bean.OmrTaskItem;
|
|
|
import com.qmth.teachcloud.mark.bean.OmrTaskPage;
|
|
|
import com.qmth.teachcloud.mark.dto.OmrTaskDto;
|
|
|
import com.qmth.teachcloud.mark.dto.OmrTaskPageDto;
|
|
|
+import com.qmth.teachcloud.mark.dto.ScanOmrStudent;
|
|
|
import com.qmth.teachcloud.mark.dto.ScanOmrTaskDto;
|
|
|
import com.qmth.teachcloud.mark.dto.ScanOmrTaskPageDto;
|
|
|
import com.qmth.teachcloud.mark.dto.ScanOmrTaskResultDto;
|
|
|
import com.qmth.teachcloud.mark.dto.ScanOmrTaskResultPageDto;
|
|
|
import com.qmth.teachcloud.mark.dto.ScanOmrTaskSaveDto;
|
|
|
import com.qmth.teachcloud.mark.dto.ScanOmrTaskStatusDto;
|
|
|
+import com.qmth.teachcloud.mark.dto.ScanStudentDto;
|
|
|
import com.qmth.teachcloud.mark.entity.MarkStudent;
|
|
|
import com.qmth.teachcloud.mark.entity.ScanOmrTask;
|
|
|
import com.qmth.teachcloud.mark.entity.ScanPaper;
|
|
@@ -52,8 +51,6 @@ import com.qmth.teachcloud.mark.service.ScanOmrTaskService;
|
|
|
import com.qmth.teachcloud.mark.service.ScanPaperPageService;
|
|
|
import com.qmth.teachcloud.mark.service.ScanPaperService;
|
|
|
import com.qmth.teachcloud.mark.service.ScanStudentPaperService;
|
|
|
-import com.qmth.teachcloud.mark.utils.TaskLock;
|
|
|
-import com.qmth.teachcloud.mark.utils.TaskLockUtil;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -337,213 +334,174 @@ public class ScanOmrTaskServiceImpl extends ServiceImpl<ScanOmrTaskMapper, ScanO
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ScanOmrTaskDto getTask(Long id, Long userId) {
|
|
|
-// int retry = 0;
|
|
|
-// ScanOmrTaskDto task = null;
|
|
|
-// while (task == null) {
|
|
|
-// List<ScanOmrTask> list = this.findUnMarked(examId, retry * 20, 20, OmrTaskStatus.WAITING);
|
|
|
-// if (list.isEmpty()) {
|
|
|
-// break;
|
|
|
-// }
|
|
|
-// for (ScanOmrTask t : list) {
|
|
|
-// if (this.apply(t, userId.toString())) {
|
|
|
-// task = toTaskVo(t, false);
|
|
|
-// break;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// if (task == null) {
|
|
|
-// retry++;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// if (task == null) {
|
|
|
-// throw ExceptionResultEnum.ERROR.exception("没有识别对照任务");
|
|
|
-// }
|
|
|
- ScanOmrTaskDto task = null;
|
|
|
- ScanOmrTask t = this.getById(id);
|
|
|
- if (t == null) {
|
|
|
+ public ScanOmrStudent getTask(Long studentId, Long userId) {
|
|
|
+ MarkStudent student = studentService.getById(studentId);
|
|
|
+ if(student==null) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("没有识别对照任务");
|
|
|
}
|
|
|
- if (this.apply(t, userId.toString())) {
|
|
|
- task = toTaskVo(t, false);
|
|
|
+ QueryWrapper<ScanOmrTask> wrapper = new QueryWrapper<>();
|
|
|
+ LambdaQueryWrapper<ScanOmrTask> lw = wrapper.lambda();
|
|
|
+ lw.eq(ScanOmrTask::getStudentId, studentId);
|
|
|
+ List<ScanOmrTask> list = baseMapper.selectList(wrapper);
|
|
|
+ if (list.isEmpty()) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("没有识别对照任务");
|
|
|
}
|
|
|
- return task;
|
|
|
+ ScanOmrStudent scanOmrStudent = new ScanOmrStudent();
|
|
|
+ scanOmrStudent.setCardNumber(student.getCardNumber());
|
|
|
+ scanOmrStudent.setStudentCode(student.getStudentCode());
|
|
|
+ scanOmrStudent.setStudentName(student.getStudentName());
|
|
|
+ scanOmrStudent.setCourseCode(student.getCourseCode());
|
|
|
+ scanOmrStudent.setCourseName(student.getCourseName());
|
|
|
+ scanOmrStudent.setCoursePaperId(student.getCoursePaperId());
|
|
|
+ scanOmrStudent.setCoursePaperNumber(student.getPaperNumber());
|
|
|
+ scanOmrStudent.setTasks(toTaskVo(list));
|
|
|
+ return scanOmrStudent;
|
|
|
}
|
|
|
|
|
|
- private ScanOmrTaskDto toTaskVo(ScanOmrTask task, boolean history) {
|
|
|
- ScanOmrTaskDto vo = new ScanOmrTaskDto();
|
|
|
- MarkStudent student = studentService.getById(task.getStudentId());
|
|
|
- vo.setCardNumber(task.getCardNumber());
|
|
|
- vo.setStudentCode(student.getStudentCode());
|
|
|
- vo.setId(task.getId());
|
|
|
- vo.setName(student.getStudentName());
|
|
|
- vo.setPaperId(task.getPaperId());
|
|
|
- vo.setPaperIndex(task.getPaperIndex());
|
|
|
- vo.setSubjectCode(student.getCourseCode());
|
|
|
- vo.setSubjectName(student.getCourseName());
|
|
|
- List<ScanOmrTaskPageDto> pages = new ArrayList<>();
|
|
|
- for (OmrTaskPage taskPage : task.getPages()) {
|
|
|
- ScanOmrTaskPageDto page = new ScanOmrTaskPageDto();
|
|
|
- Map<Integer, List<String>> question = new HashMap<>();
|
|
|
- Map<Integer, List<String>> selective = new HashMap<>();
|
|
|
- for (OmrTaskItem item : taskPage.getItems()) {
|
|
|
- if (OmrField.ABSENT.equals(item.getField())) {
|
|
|
- page.setAbsent(getBooleanItem(item, history));
|
|
|
- }
|
|
|
- if (OmrField.BREACH.equals(item.getField())) {
|
|
|
- page.setBreach(getBooleanItem(item, history));
|
|
|
+ private List<ScanOmrTaskDto> toTaskVo(List<ScanOmrTask> tasks) {
|
|
|
+ List<ScanOmrTaskDto> list = new ArrayList<ScanOmrTaskDto>();
|
|
|
+ for (ScanOmrTask task : tasks) {
|
|
|
+ ScanOmrTaskDto vo = new ScanOmrTaskDto();
|
|
|
+ vo.setId(task.getId());
|
|
|
+ vo.setPaperId(task.getPaperId());
|
|
|
+ vo.setPaperIndex(task.getPaperIndex());
|
|
|
+ vo.setConditions(task.getConditions());
|
|
|
+ List<ScanOmrTaskPageDto> pages = new ArrayList<>();
|
|
|
+ for (OmrTaskPage taskPage : task.getPages()) {
|
|
|
+ ScanOmrTaskPageDto page = new ScanOmrTaskPageDto();
|
|
|
+ Map<Integer, List<String>> question = new HashMap<>();
|
|
|
+ Map<Integer, List<String>> selective = new HashMap<>();
|
|
|
+ for (OmrTaskItem item : taskPage.getItems()) {
|
|
|
+ if (OmrField.ABSENT.equals(item.getField())) {
|
|
|
+ page.setAbsent(getBooleanItem(item));
|
|
|
+ }
|
|
|
+ if (OmrField.BREACH.equals(item.getField())) {
|
|
|
+ page.setBreach(getBooleanItem(item));
|
|
|
+ }
|
|
|
+ if (OmrField.PAPER_TYPE.equals(item.getField())) {
|
|
|
+ page.setPaperType(getStringItem(item));
|
|
|
+ }
|
|
|
+ if (OmrField.QUESTION.equals(item.getField())) {
|
|
|
+ List<String> content = getStringItem(item);
|
|
|
+ if (content != null) {
|
|
|
+ question.put(item.getIndex(), content);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (OmrField.SELECTIVE.equals(item.getField())) {
|
|
|
+ List<String> content = getStringItem(item);
|
|
|
+ if (content != null) {
|
|
|
+ selective.put(item.getIndex(), content);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- if (OmrField.PAPER_TYPE.equals(item.getField())) {
|
|
|
- page.setPaperType(getStringItem(item, history));
|
|
|
+ if (question.size() > 0) {
|
|
|
+ page.setQuestion(question);
|
|
|
}
|
|
|
- if (OmrField.QUESTION.equals(item.getField())) {
|
|
|
- List<String> content = getStringItem(item, history);
|
|
|
- if (content != null) {
|
|
|
- question.put(item.getIndex(), content);
|
|
|
- }
|
|
|
+ if (selective.size() > 0) {
|
|
|
+ page.setSelective(selective);
|
|
|
}
|
|
|
- if (OmrField.SELECTIVE.equals(item.getField())) {
|
|
|
- List<String> content = getStringItem(item, history);
|
|
|
- if (content != null) {
|
|
|
- selective.put(item.getIndex(), content);
|
|
|
- }
|
|
|
+ // 有需要仲裁的数据才返回结构
|
|
|
+ if (page.getAbsent() != null || page.getBreach() != null || page.getPaperType() != null
|
|
|
+ || page.getQuestion() != null || page.getSelective() != null) {
|
|
|
+ page.setIndex(taskPage.getIndex());
|
|
|
+ ScanPaperPage p = pageService.findPaperIdAndIndex(task.getPaperId(), taskPage.getIndex());
|
|
|
+ page.setRecogData(p.getRecogData());
|
|
|
+ page.setUri(p.getSheetPath());
|
|
|
+ pages.add(page);
|
|
|
}
|
|
|
}
|
|
|
- if (question.size() > 0) {
|
|
|
- page.setQuestion(question);
|
|
|
- }
|
|
|
- if (selective.size() > 0) {
|
|
|
- page.setSelective(selective);
|
|
|
- }
|
|
|
- // 有需要仲裁的数据才返回结构
|
|
|
- if (page.getAbsent() != null || page.getBreach() != null || page.getPaperType() != null
|
|
|
- || page.getQuestion() != null || page.getSelective() != null) {
|
|
|
- page.setIndex(taskPage.getIndex());
|
|
|
- ScanPaperPage p = pageService.findPaperIdAndIndex(task.getPaperId(), taskPage.getIndex());
|
|
|
- page.setRecogData(p.getRecogData());
|
|
|
- page.setUri(p.getSheetPath());
|
|
|
- pages.add(page);
|
|
|
- }
|
|
|
+ vo.setPages(pages);
|
|
|
+ list.add(vo);
|
|
|
}
|
|
|
- vo.setPages(pages);
|
|
|
- return vo;
|
|
|
+ return list;
|
|
|
}
|
|
|
|
|
|
- private List<String> getStringItem(OmrTaskItem item, boolean history) {
|
|
|
+ private List<String> getStringItem(OmrTaskItem item) {
|
|
|
List<String> value = new ArrayList<>();
|
|
|
value.add(item.getOmrResult());
|
|
|
- if (history && item.getFirstResult() != null && item.getSecondResult() == null) {
|
|
|
+ if (item.getFirstResult() != null && item.getSecondResult() == null) {
|
|
|
value.add(item.getFirstResult());
|
|
|
- } else if (history && item.getSecondResult() != null) {
|
|
|
+ } else if (item.getSecondResult() != null) {
|
|
|
value.add(item.getSecondResult());
|
|
|
}
|
|
|
return value;
|
|
|
}
|
|
|
|
|
|
- private List<Boolean> getBooleanItem(OmrTaskItem item, boolean history) {
|
|
|
+ private List<Boolean> getBooleanItem(OmrTaskItem item) {
|
|
|
List<Boolean> value = new ArrayList<>();
|
|
|
value.add(Boolean.valueOf(item.getOmrResult()));
|
|
|
- if (history && item.getFirstResult() != null && item.getSecondResult() == null) {
|
|
|
+ if (item.getFirstResult() != null && item.getSecondResult() == null) {
|
|
|
value.add(Boolean.valueOf(item.getFirstResult()));
|
|
|
- } else if (history && item.getSecondResult() != null) {
|
|
|
+ } else if (item.getSecondResult() != null) {
|
|
|
value.add(Boolean.valueOf(item.getSecondResult()));
|
|
|
}
|
|
|
return value;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public List<ScanOmrTask> findUnMarked(Long examId, int pageNumber, int pageSize, OmrTaskStatus status) {
|
|
|
- return this.baseMapper.findUnMarked(examId, pageNumber, pageSize, status);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean apply(ScanOmrTask t, String userId) {
|
|
|
- TaskLock taskLock = TaskLockUtil.getOmrTask(t.getExamId().toString());
|
|
|
- boolean lock = taskLock.add(t.getId(), 1, userId);
|
|
|
- // 上锁失败直接返回
|
|
|
- if (!lock) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- // 重复校验任务状态
|
|
|
- if (t.getStatus().equals(OmrTaskStatus.WAITING)) {
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- taskLock.remove(t.getId(), 1);
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean hasApplied(ScanOmrTask t, String userId) {
|
|
|
- TaskLock taskLock = TaskLockUtil.getOmrTask(t.getExamId().toString());
|
|
|
- return taskLock.exist(t.getId(), 1, userId);
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public ScanOmrTaskSaveDto submitTask(@NotNull ScanOmrTaskResultDto result, @NotNull SysUser user) {
|
|
|
- ScanOmrTask task = this.getById(result.getId());
|
|
|
- if (task == null) {
|
|
|
- throw new ParameterException("任务不存在");
|
|
|
- }
|
|
|
- // if (TaskStatus.PROCESSED.equals(task.getStatus())) {
|
|
|
- // throw new ParameterException("任务已处理");
|
|
|
- // }
|
|
|
- if (!task.getUserId().equals(user.getId())) {
|
|
|
- throw new ParameterException("任务非本人领取");
|
|
|
- }
|
|
|
- if (OmrTaskStatus.WAITING.equals(task.getStatus()) && !hasApplied(task, user.getId())) {
|
|
|
- throw new ParameterException("任务非本人领取");
|
|
|
- }
|
|
|
- concurrentService.getReadWriteLock(LockType.STUDENT + "-" + task.getStudentId()).writeLock().lock();
|
|
|
-
|
|
|
- for (OmrTaskPage page : task.getPages()) {
|
|
|
- ScanOmrTaskResultPageDto pageVo = result.findPage(page.getIndex());
|
|
|
- if (pageVo == null) {
|
|
|
- throw new ParameterException("page[" + page.getIndex() + "]不存在");
|
|
|
+ public ScanOmrTaskSaveDto submitTask(@NotNull List<ScanOmrTaskResultDto> results, @NotNull Long userId) {
|
|
|
+ Long studentId = null;
|
|
|
+ for (ScanOmrTaskResultDto result : results) {
|
|
|
+ ScanOmrTask task = this.getById(result.getId());
|
|
|
+ if (task == null) {
|
|
|
+ throw new ParameterException("任务不存在");
|
|
|
}
|
|
|
- for (OmrTaskItem item : page.getItems()) {
|
|
|
- if (OmrField.ABSENT.equals(item.getField())) {
|
|
|
- if (pageVo.getAbsent() == null) {
|
|
|
- throw new ParameterException("page[" + page.getIndex() + "].absent不存在");
|
|
|
- }
|
|
|
- item.setFirstResult(pageVo.getAbsent().toString());
|
|
|
+ if(studentId == null ) {
|
|
|
+ studentId = task.getStudentId();
|
|
|
+ }
|
|
|
+ if(studentId != task.getStudentId()) {
|
|
|
+ throw new ParameterException("任务非同一个学生");
|
|
|
+ }
|
|
|
+ concurrentService.getReadWriteLock(LockType.STUDENT + "-" + task.getStudentId()).writeLock().lock();
|
|
|
+
|
|
|
+ for (OmrTaskPage page : task.getPages()) {
|
|
|
+ ScanOmrTaskResultPageDto pageVo = result.findPage(page.getIndex());
|
|
|
+ if (pageVo == null) {
|
|
|
+ throw new ParameterException("page[" + page.getIndex() + "]不存在");
|
|
|
}
|
|
|
- if (OmrField.BREACH.equals(item.getField())) {
|
|
|
- if (pageVo.getBreach() == null) {
|
|
|
- throw new ParameterException("page[" + page.getIndex() + "].breach不存在");
|
|
|
+ for (OmrTaskItem item : page.getItems()) {
|
|
|
+ if (OmrField.ABSENT.equals(item.getField())) {
|
|
|
+ if (pageVo.getAbsent() == null) {
|
|
|
+ throw new ParameterException("page[" + page.getIndex() + "].absent不存在");
|
|
|
+ }
|
|
|
+ item.setFirstResult(pageVo.getAbsent().toString());
|
|
|
}
|
|
|
- item.setFirstResult(pageVo.getBreach().toString());
|
|
|
- }
|
|
|
- if (OmrField.QUESTION.equals(item.getField())) {
|
|
|
- String content = pageVo.getQuestion() != null ? pageVo.getQuestion().get(item.getIndex()) : null;
|
|
|
- if (content == null) {
|
|
|
- throw new ParameterException(
|
|
|
- "page[" + page.getIndex() + "].question[" + item.getIndex() + "]不存在");
|
|
|
+ if (OmrField.BREACH.equals(item.getField())) {
|
|
|
+ if (pageVo.getBreach() == null) {
|
|
|
+ throw new ParameterException("page[" + page.getIndex() + "].breach不存在");
|
|
|
+ }
|
|
|
+ item.setFirstResult(pageVo.getBreach().toString());
|
|
|
}
|
|
|
- item.setFirstResult(content);
|
|
|
- }
|
|
|
- if (OmrField.SELECTIVE.equals(item.getField())) {
|
|
|
- String content = pageVo.getSelective() != null ? pageVo.getSelective().get(item.getIndex()) : null;
|
|
|
- if (content == null) {
|
|
|
- throw new ParameterException(
|
|
|
- "page[" + page.getIndex() + "].selective[" + item.getIndex() + "]不存在");
|
|
|
+ if (OmrField.QUESTION.equals(item.getField())) {
|
|
|
+ String content = pageVo.getQuestion() != null ? pageVo.getQuestion().get(item.getIndex()) : null;
|
|
|
+ if (content == null) {
|
|
|
+ throw new ParameterException(
|
|
|
+ "page[" + page.getIndex() + "].question[" + item.getIndex() + "]不存在");
|
|
|
+ }
|
|
|
+ item.setFirstResult(content);
|
|
|
+ }
|
|
|
+ if (OmrField.SELECTIVE.equals(item.getField())) {
|
|
|
+ String content = pageVo.getSelective() != null ? pageVo.getSelective().get(item.getIndex()) : null;
|
|
|
+ if (content == null) {
|
|
|
+ throw new ParameterException(
|
|
|
+ "page[" + page.getIndex() + "].selective[" + item.getIndex() + "]不存在");
|
|
|
+ }
|
|
|
+ item.setFirstResult(content);
|
|
|
}
|
|
|
- item.setFirstResult(content);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- task.setStatus(OmrTaskStatus.PROCESSED);
|
|
|
+ task.setStatus(OmrTaskStatus.PROCESSED);
|
|
|
|
|
|
- updatePaperResult(result, task.getPaperId(), user.getId());
|
|
|
- task.setUserId(user.getId());
|
|
|
- task.setUpdateTime(System.currentTimeMillis());
|
|
|
- this.saveOrUpdate(task);
|
|
|
- this.releaseByTask(task);
|
|
|
- concurrentService.getReadWriteLock(LockType.STUDENT + "-" + task.getStudentId()).writeLock().unlock();
|
|
|
+ updatePaperResult(result, task.getPaperId(),userId);
|
|
|
+ task.setUserId(userId);
|
|
|
+ task.setUpdateTime(System.currentTimeMillis());
|
|
|
+ this.saveOrUpdate(task);
|
|
|
+ concurrentService.getReadWriteLock(LockType.STUDENT + "-" + task.getStudentId()).writeLock().unlock();
|
|
|
+ }
|
|
|
ScanOmrTaskSaveDto vo = new ScanOmrTaskSaveDto();
|
|
|
- vo.setId(result.getId());
|
|
|
+ vo.setStudentId(studentId);
|
|
|
vo.setUpdateTime(System.currentTimeMillis());
|
|
|
- vo.setStatus(this.getStatus(task.getExamId(), user.getId()));
|
|
|
return vo;
|
|
|
}
|
|
|
|
|
@@ -570,18 +528,6 @@ public class ScanOmrTaskServiceImpl extends ServiceImpl<ScanOmrTaskMapper, ScanO
|
|
|
studentService.updateStudentByPaper(userId, sp.getStudentId(), false);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public boolean hasApplied(ScanOmrTask t, Long userId) {
|
|
|
- TaskLock taskLock = TaskLockUtil.getOmrTask(t.getExamId().toString());
|
|
|
- return taskLock.exist(t.getId(), 1, userId.toString());
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void releaseByTask(ScanOmrTask t) {
|
|
|
- TaskLock taskLock = TaskLockUtil.getOmrTask(t.getExamId().toString());
|
|
|
- taskLock.remove(t.getId(), 1);
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public ScanOmrTaskStatusDto getStatus(Long examId, Long userId) {
|
|
|
ScanOmrTaskStatusDto status = new ScanOmrTaskStatusDto();
|
|
@@ -591,68 +537,22 @@ public class ScanOmrTaskServiceImpl extends ServiceImpl<ScanOmrTaskMapper, ScanO
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public int getCountByExamAndStatusAndUserId(Long examId, Long userId, OmrTaskStatus... status) {
|
|
|
+ public int getStudentCountByExamAndStatusAndUserId(Long examId, Long userId, OmrTaskStatus status) {
|
|
|
QueryWrapper<ScanOmrTask> wrapper = new QueryWrapper<>();
|
|
|
LambdaQueryWrapper<ScanOmrTask> lw = wrapper.lambda();
|
|
|
- lw.and(param -> {
|
|
|
- for (OmrTaskStatus taskStatus : status) {
|
|
|
- param.or().eq(ScanOmrTask::getStatus, taskStatus);
|
|
|
- }
|
|
|
- });
|
|
|
lw.eq(ScanOmrTask::getUserId, userId);
|
|
|
lw.eq(ScanOmrTask::getExamId, examId);
|
|
|
return this.count(wrapper);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public int getCountByExamAndStatus(Long examId, OmrTaskStatus... status) {
|
|
|
+ public int getStudentCountByExamAndStatus(Long examId, OmrTaskStatus status) {
|
|
|
QueryWrapper<ScanOmrTask> wrapper = new QueryWrapper<>();
|
|
|
LambdaQueryWrapper<ScanOmrTask> lw = wrapper.lambda();
|
|
|
- lw.and(param -> {
|
|
|
- for (OmrTaskStatus taskStatus : status) {
|
|
|
- param.or().eq(ScanOmrTask::getStatus, taskStatus);
|
|
|
- }
|
|
|
- });
|
|
|
lw.eq(ScanOmrTask::getExamId, examId);
|
|
|
return this.count(wrapper);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public void releaseByUser(Long examId, Long userId) {
|
|
|
- TaskLock taskLock = TaskLockUtil.getOmrTask(examId.toString());
|
|
|
- taskLock.clear(userId.toString());
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public ScanOmrTaskDto history(Long examId, Long taskId, Long userId, Boolean next) {
|
|
|
- ScanOmrTask cur = null;
|
|
|
- if (taskId != null) {
|
|
|
- cur = this.getById(taskId);
|
|
|
- }
|
|
|
- QueryWrapper<ScanOmrTask> wrapper = new QueryWrapper<>();
|
|
|
- LambdaQueryWrapper<ScanOmrTask> lw = wrapper.lambda();
|
|
|
- lw.eq(ScanOmrTask::getExamId, examId);
|
|
|
- lw.eq(ScanOmrTask::getUserId, userId);
|
|
|
- lw.eq(ScanOmrTask::getStatus, OmrTaskStatus.PROCESSED);
|
|
|
- if (next != null && next) {
|
|
|
- if (taskId != null) {
|
|
|
- lw.gt(ScanOmrTask::getId, cur.getId());
|
|
|
- }
|
|
|
- lw.orderByAsc(ScanOmrTask::getId);
|
|
|
- } else {
|
|
|
- if (taskId != null) {
|
|
|
- lw.lt(ScanOmrTask::getId, cur.getId());
|
|
|
- }
|
|
|
- lw.orderByDesc(ScanOmrTask::getId);
|
|
|
- }
|
|
|
- wrapper.last("LIMIT 1");
|
|
|
- ScanOmrTask task = this.baseMapper.selectOne(wrapper);
|
|
|
- if (task == null) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("没有识别对照任务");
|
|
|
- }
|
|
|
- return toTaskVo(task, true);
|
|
|
- }
|
|
|
-
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public void deleteByStudentId(Long examId, Long studentId) {
|
|
@@ -680,18 +580,10 @@ public class ScanOmrTaskServiceImpl extends ServiceImpl<ScanOmrTaskMapper, ScanO
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public IPage<ScanOmrTaskDto> list(Long examId, OmrTaskStatus status, Long userId) {
|
|
|
- QueryWrapper<ScanOmrTask> wrapper = new QueryWrapper<>();
|
|
|
- LambdaQueryWrapper<ScanOmrTask> lw = wrapper.lambda();
|
|
|
- lw.eq(ScanOmrTask::getExamId, examId);
|
|
|
- lw.eq(ScanOmrTask::getStatus, status);
|
|
|
- IPage<ScanOmrTask> list =this.baseMapper.selectPage(new Page<>(0, 20), null);
|
|
|
- IPage<ScanOmrTaskDto> result = new Page<ScanOmrTaskDto>();
|
|
|
- result.setCurrent(list.getCurrent());
|
|
|
- result.setPages(list.getPages());
|
|
|
- result.setRecords(null);
|
|
|
- result.setSize(list.getSize());
|
|
|
- result.setTotal(list.getTotal());
|
|
|
- return result;
|
|
|
+ public List<ScanStudentDto> list(Long examId, OmrTaskStatus status, Long userId) {
|
|
|
+ if(status.equals(OmrTaskStatus.WAITING)) {
|
|
|
+ userId = null;
|
|
|
+ }
|
|
|
+ return this.baseMapper.listByExamIdAndStatusAndUserId(examId,status,userId);
|
|
|
}
|
|
|
}
|