|
@@ -12,23 +12,24 @@ import com.qmth.distributed.print.business.entity.*;
|
|
|
import com.qmth.distributed.print.business.enums.*;
|
|
|
import com.qmth.distributed.print.business.mapper.ExamTaskDetailMapper;
|
|
|
import com.qmth.distributed.print.business.service.*;
|
|
|
+import com.qmth.distributed.print.business.util.ExamTaskUtil;
|
|
|
import com.qmth.teachcloud.common.bean.dto.DataPermissionRule;
|
|
|
import com.qmth.teachcloud.common.bean.vo.PaperInfoVo;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
import com.qmth.teachcloud.common.entity.SysOrg;
|
|
|
import com.qmth.teachcloud.common.entity.SysUser;
|
|
|
-import com.qmth.teachcloud.common.enums.*;
|
|
|
+import com.qmth.teachcloud.common.enums.CreatePdfTypeEnum;
|
|
|
+import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
+import com.qmth.teachcloud.common.enums.FlowApprovePassEnum;
|
|
|
+import com.qmth.teachcloud.common.enums.TFCustomTypeEnum;
|
|
|
import com.qmth.teachcloud.common.service.BasicRoleDataPermissionService;
|
|
|
import com.qmth.teachcloud.common.service.CommonCacheService;
|
|
|
import com.qmth.teachcloud.common.service.SysUserService;
|
|
|
-import com.qmth.teachcloud.common.util.ExamTaskUtil;
|
|
|
import com.qmth.teachcloud.common.util.ServletUtil;
|
|
|
import com.qmth.teachcloud.mark.service.MarkService;
|
|
|
import com.qmth.teachcloud.mark.service.ScanPaperService;
|
|
|
import org.activiti.engine.TaskService;
|
|
|
-import org.activiti.engine.task.Task;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
-import org.apache.commons.lang3.ArrayUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -89,9 +90,9 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
|
|
|
|
|
|
@Transactional
|
|
|
@Override
|
|
|
- public boolean enable(ExamTaskDetail examTaskDetail) {
|
|
|
- ExamTask examTask = examTaskService.getById(examTaskDetail.getId());
|
|
|
- List<ExamDetail> examDetails = examDetailService.listExamDetailByExamIdAndCourseIdAndPaperNumber(examTask.getExamId(), examTask.getCourseId(), examTask.getPaperNumber());
|
|
|
+ public boolean enable(ExamTask examTask) {
|
|
|
+ ExamTask examTaskById = examTaskService.getById(examTask.getId());
|
|
|
+ List<ExamDetail> examDetails = examDetailService.listExamDetailByExamIdAndCourseIdAndPaperNumber(examTaskById.getExamId(), examTaskById.getCourseId(), examTaskById.getPaperNumber());
|
|
|
if (examDetails != null && examDetails.size() > 0) {
|
|
|
// 有考场提交打印,不能禁用启用
|
|
|
long count = examDetails.stream().filter(m -> !ExamDetailStatusEnum.NEW.name().equals(m.getStatus().name()) && !ExamDetailStatusEnum.READY.name().equals(m.getStatus().name())).count();
|
|
@@ -108,7 +109,7 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
|
|
|
}
|
|
|
}
|
|
|
// 禁用,解决试卷关联关系,并且解除生成pdf绑定
|
|
|
- if (!examTaskDetail.getEnable()) {
|
|
|
+ if (!examTask.getEnable()) {
|
|
|
// 正在生成pdf不能禁用
|
|
|
if (examDetails != null && examDetails.size() > 0) {
|
|
|
Map<Long, List<Long>> map = examDetails.stream().collect(Collectors.groupingBy(ExamDetail::getPrintPlanId, Collectors.mapping(ExamDetail::getId, Collectors.toList())));
|
|
@@ -143,9 +144,9 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- UpdateWrapper<ExamTaskDetail> updateWrapper = new UpdateWrapper<>();
|
|
|
- updateWrapper.lambda().set(ExamTaskDetail::getEnable, examTaskDetail.getEnable()).eq(ExamTaskDetail::getExamTaskId, examTaskDetail.getId());
|
|
|
- this.update(updateWrapper);
|
|
|
+ UpdateWrapper<ExamTask> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.lambda().set(ExamTask::getEnable, examTask.getEnable()).eq(ExamTask::getId, examTask.getId());
|
|
|
+ examTaskService.update(updateWrapper);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
@@ -265,107 +266,6 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- @Transactional
|
|
|
- public Map<String, Object> paperUpdate(ExamTaskDetail examTaskDetail) {
|
|
|
- SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
-
|
|
|
- validPaperUpdate(examTaskDetail);
|
|
|
- SysOrg sysOrg = commonCacheService.orgCache(requestUser.getOrgId());
|
|
|
-
|
|
|
- Map<String, Object> mapVar = new HashMap<>();
|
|
|
- ExamTaskDetail examTaskDetail1 = this.getByExamTaskId(examTaskDetail.getExamTaskId());
|
|
|
- String unexposedPaperType = examTaskDetail.getPaperType();
|
|
|
- if (StringUtils.isNotBlank(examTaskDetail1.getExposedPaperType())) {
|
|
|
- List<String> paperTypeAll = new ArrayList<>(Arrays.asList(examTaskDetail.getPaperType().split(",")));
|
|
|
- List<String> exposePaperTypes = Arrays.asList(examTaskDetail1.getExposedPaperType().split(","));
|
|
|
- for (String exposePaperType : exposePaperTypes) {
|
|
|
- if (paperTypeAll.contains(exposePaperType)) {
|
|
|
- paperTypeAll.remove(exposePaperType);
|
|
|
- }
|
|
|
- }
|
|
|
- unexposedPaperType = String.join(",", paperTypeAll);
|
|
|
- }
|
|
|
-
|
|
|
- UpdateWrapper<ExamTaskDetail> examTaskDetailUpdateWrapper = new UpdateWrapper<>();
|
|
|
- examTaskDetailUpdateWrapper.lambda().set(ExamTaskDetail::getPaperType, examTaskDetail.getPaperType())
|
|
|
- .set(ExamTaskDetail::getPaperAttachmentIds, examTaskDetail.getPaperAttachmentIds())
|
|
|
- .set(ExamTaskDetail::getUnexposedPaperType, unexposedPaperType)
|
|
|
- .set(ExamTaskDetail::getRelatePaperType, null)
|
|
|
- .eq(ExamTaskDetail::getExamTaskId, examTaskDetail.getExamTaskId());
|
|
|
- this.update(examTaskDetailUpdateWrapper);
|
|
|
-
|
|
|
-
|
|
|
- QueryWrapper<ExamTaskDetail> examTaskDetailQueryWrapper = new QueryWrapper<>();
|
|
|
- examTaskDetailQueryWrapper.lambda().eq(ExamTaskDetail::getExamTaskId, examTaskDetail.getExamTaskId());
|
|
|
- List<ExamTaskDetail> examTaskDetailList = this.list(examTaskDetailQueryWrapper);
|
|
|
- if (CollectionUtils.isNotEmpty(examTaskDetailList)) {
|
|
|
- for (ExamTaskDetail e : examTaskDetailList) {
|
|
|
- e.setPaperType(examTaskDetail.getPaperType());
|
|
|
- e.setPaperAttachmentIds(examTaskDetail.getPaperAttachmentIds());
|
|
|
- e.setUnexposedPaperType(unexposedPaperType);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- ExamTask examTask = examTaskService.getById(examTaskDetail.getExamTaskId());
|
|
|
- List<ExamDetail> examDetails = examDetailService.listExamDetailByExamIdAndCourseIdAndPaperNumber(examTask.getExamId(), examTask.getCourseId(), examTask.getPaperNumber());
|
|
|
- if (CollectionUtils.isNotEmpty(examDetails)) {
|
|
|
- StringJoiner stringJoiner = new StringJoiner("_");
|
|
|
- stringJoiner.add(String.valueOf(examDetails.get(0).getSchoolId()))
|
|
|
- .add(String.valueOf(examDetails.get(0).getExamStartTime()))
|
|
|
- .add(String.valueOf(examDetails.get(0).getExamEndTime()))
|
|
|
- .add(String.valueOf(examTask.getCourseId()))
|
|
|
- .add(examTask.getPaperNumber());
|
|
|
- String key = stringJoiner.toString();
|
|
|
- CreatePdfCacheUtil.deletePaperType(key);
|
|
|
-
|
|
|
- List<ExamDetail> examDetailList = examDetails.stream().filter(m -> m.getStatus().equals(ExamDetailStatusEnum.WAITING)).collect(Collectors.toList());
|
|
|
- for (ExamDetail examDetail : examDetailList) {
|
|
|
- examDetail.setStatus(ExamDetailStatusEnum.NEW);
|
|
|
- examDetailService.updateById(examDetail);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 不需要审核,直接更新,否则加入待审核列表(状态为不需要审核的或者为管理员身份的都不重新走审核流程)
|
|
|
- if ((Objects.nonNull(examTask.getReview()) && examTask.getReview()) || !sysUserService.isAdminDataAuth(requestUser.getId())) {
|
|
|
- // 发起新流程
|
|
|
- Map<String, Object> map = SystemConstant.buildFlowVar(examTask.getId(),
|
|
|
- examTask,
|
|
|
- TFCustomTypeEnum.ELECTRON_FLOW,
|
|
|
- examTask.getUserId(),
|
|
|
- false);
|
|
|
- map.computeIfAbsent(SystemConstant.OLD_FLOW_ID, v -> examTask.getFlowId());
|
|
|
- map.computeIfAbsent(SystemConstant.FLOW_JOIN_TYPE, v -> FlowJoinTypeEnum.RESTART);
|
|
|
- map = activitiService.customFlowStart(map);
|
|
|
- Long flowId = SystemConstant.convertIdToLong((String) map.get(SystemConstant.FLOW_ID));
|
|
|
- UpdateWrapper<ExamTask> updateWrapper = new UpdateWrapper<>();
|
|
|
- updateWrapper.lambda().set(ExamTask::getFlowId, flowId).eq(ExamTask::getId, examTaskDetail.getExamTaskId());
|
|
|
- examTaskService.update(updateWrapper);
|
|
|
- mapVar.putAll(map);
|
|
|
- mapVar.put(SystemConstant.SEND_FLOW_START_MQ, true);
|
|
|
-
|
|
|
- tfFlowJoinService.saveOrUpdate(map);
|
|
|
- if (Objects.nonNull(flowId)) {
|
|
|
- // 审核一级
|
|
|
- Task task = taskService.createTaskQuery().processInstanceId(String.valueOf(flowId)).singleResult();
|
|
|
- if (Objects.nonNull(task)) {
|
|
|
- Map<String, Object> approverMap = new HashMap<>();
|
|
|
- approverMap.computeIfAbsent(SystemConstant.FLOW_TASK_ID, v -> task.getId());
|
|
|
- approverMap.computeIfAbsent(SystemConstant.PAPAER_ATTACHMENT_IDS, v -> examTaskDetail.getPaperAttachmentIds());
|
|
|
- approverMap.computeIfAbsent(SystemConstant.APPROVE_OPERATION, v -> FlowApprovePassEnum.PASS);
|
|
|
- String remark = Objects.nonNull(sysOrg) ? sysOrg.getName() : "无机构";
|
|
|
- approverMap.computeIfAbsent(SystemConstant.APPROVE_REMARK, v -> requestUser.getRealName() + "(" + remark + ")" + FlowApprovePassEnum.RESTART.getTitle());
|
|
|
- activitiService.taskApprove(approverMap);
|
|
|
- mapVar.putAll(approverMap);
|
|
|
- mapVar.remove(SystemConstant.SEND_FLOW_START_MQ);
|
|
|
- mapVar.put(SystemConstant.SEND_FLOW_MQ, true);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- mapVar.put(SystemConstant.SUCCESS, true);
|
|
|
- return mapVar;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 重启流程
|
|
|
*
|
|
@@ -381,7 +281,6 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
|
|
|
ExamTask examTask = examTaskService.getById(examTaskDetail.getExamTaskId());
|
|
|
List<ExamDetail> examDetailList = examDetailService.listExamDetailByExamIdAndCourseIdAndPaperNumber(examTask.getExamId(), examTask.getCourseId(), examTask.getPaperNumber());
|
|
|
if (CollectionUtils.isNotEmpty(examDetailList)) {
|
|
|
- ExamTaskDetail taskDetail = this.getByExamTaskId(examTaskDetail.getExamTaskId());
|
|
|
List<Long> examDetailIds = examDetailList.stream().map(ExamDetail::getId).collect(Collectors.toList());
|
|
|
QueryWrapper<ExamDetailCourse> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.lambda().in(ExamDetailCourse::getExamDetailId, examDetailIds);
|
|
@@ -404,21 +303,13 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
|
|
|
throw ExceptionResultEnum.ERROR.exception("印刷任务有已打印或待印刷数据,不允许打回");
|
|
|
}
|
|
|
|
|
|
- // 修改已曝光和未曝光类型
|
|
|
- List<String> exposedPaperTypeList = StringUtils.isNotBlank(taskDetail.getExposedPaperType()) ? new ArrayList<>(Arrays.asList(taskDetail.getExposedPaperType().split(","))) : new ArrayList<>();
|
|
|
- List<String> unexposedPaperTypeList = StringUtils.isNotBlank(taskDetail.getUnexposedPaperType()) ? new ArrayList<>(Arrays.asList(taskDetail.getUnexposedPaperType().split(","))) : new ArrayList<>();
|
|
|
- for (String exposePaperType : paperTypeSet) {
|
|
|
- if (exposedPaperTypeList.contains(exposePaperType)) {
|
|
|
- exposedPaperTypeList.remove(exposePaperType);
|
|
|
- unexposedPaperTypeList.add(exposePaperType);
|
|
|
- }
|
|
|
- }
|
|
|
- exposedPaperTypeList.sort(Comparator.comparing(String::toString));
|
|
|
- unexposedPaperTypeList.sort(Comparator.comparing(String::toString));
|
|
|
- taskDetail.setExposedPaperType(CollectionUtils.isEmpty(exposedPaperTypeList) ? null : String.join(",", exposedPaperTypeList));
|
|
|
- taskDetail.setUnexposedPaperType(String.join(",", unexposedPaperTypeList));
|
|
|
- taskDetail.setRelatePaperType(null);
|
|
|
- this.updateById(taskDetail);
|
|
|
+ // 修改已曝光
|
|
|
+ UpdateWrapper<ExamTaskDetail> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.lambda().set(ExamTaskDetail::getExposed, false)
|
|
|
+ .set(ExamTaskDetail::getExposedExamId, null)
|
|
|
+ .eq(ExamTaskDetail::getExamTaskId, examTask.getId())
|
|
|
+ .eq(ExamTaskDetail::getExposedExamId, examTask.getExamId());
|
|
|
+ this.update(updateWrapper);
|
|
|
|
|
|
StringJoiner stringJoiner = new StringJoiner("_");
|
|
|
stringJoiner.add(String.valueOf(examTask.getExamId())).add(examTask.getPaperNumber()).add(String.valueOf(examDetailList.get(0).getExamStartTime())).add(String.valueOf(examDetailList.get(0).getExamEndTime()));
|
|
@@ -505,23 +396,6 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
|
|
|
return this.getOne(queryWrapper);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public ExamTaskDetail getByExamTaskId(Long examTaskId) {
|
|
|
- ExamTask examTask = examTaskService.getByIdIncludeCourse(examTaskId);
|
|
|
- if (examTask == null) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("命题任务不存在");
|
|
|
- }
|
|
|
- QueryWrapper<ExamTaskDetail> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.lambda().eq(ExamTaskDetail::getExamTaskId, examTaskId);
|
|
|
- ExamTaskDetail examTaskDetail = this.getOne(queryWrapper);
|
|
|
- if (examTaskDetail == null) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s]的命题任务未找到命题详情", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber()));
|
|
|
- } else if (!examTaskDetail.getEnable()) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s]的命题任务卷库已禁用", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber()));
|
|
|
- }
|
|
|
- return examTaskDetail;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 根据examTaskId下载pdf
|
|
|
*
|
|
@@ -561,50 +435,34 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
|
|
|
return commonPaperTypes;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public ExamTaskDetail findByExamIdAndCourseIdAndPaperNumber(Long examId, Long courseId, String number) {
|
|
|
- ExamTask examTask = examTaskService.getByExamIdAndCourseIdAndPaperNumber(examId, courseId, number);
|
|
|
- if (examTask == null) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- return this.getByExamTaskId(examTask.getId());
|
|
|
- }
|
|
|
-
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public boolean cancel(Long id, String cancelRemark) {
|
|
|
ExamTask examTask = examTaskService.getById(id);
|
|
|
String paperNumber = examTask.getPaperNumber();
|
|
|
|
|
|
- List<ExamDetail> examDetailList = examDetailService.listExamDetailByExamIdAndCourseIdAndPaperNumber(examTask.getExamId(), examTask.getCourseId(), examTask.getPaperNumber());
|
|
|
- if (CollectionUtils.isNotEmpty(examDetailList)) {
|
|
|
- ExamTaskDetail taskDetail = this.getByExamTaskId(id);
|
|
|
- if (StringUtils.isNotBlank(taskDetail.getExposedPaperType())) {
|
|
|
- List<Long> examDetailIds = examDetailList.stream().map(ExamDetail::getId).collect(Collectors.toList());
|
|
|
- QueryWrapper<ExamDetailCourse> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.lambda().in(ExamDetailCourse::getExamDetailId, examDetailIds);
|
|
|
- List<ExamDetailCourse> examDetailCourseList = examDetailCourseService.list(queryWrapper);
|
|
|
- for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
|
|
|
- // 考场内任一课程有扫描数据,不允许打回
|
|
|
- boolean isScanPaper = scanPaperService.isScanByExamIdAndPaperNumber(examTask.getExamId(), examDetailCourse.getPaperNumber());
|
|
|
- if (isScanPaper) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("课程已开始扫描,不允许作废");
|
|
|
- }
|
|
|
+ List<ExamDetailCourse> examDetailCourseList = examDetailCourseService.listByExamIdAndPaperNumber(examTask.getExamId(), examTask.getPaperNumber());
|
|
|
+ if (CollectionUtils.isNotEmpty(examDetailCourseList)) {
|
|
|
+ for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
|
|
|
+ // 考场内任一课程有扫描数据,不允许打回
|
|
|
+ if (scanPaperService.isScanByExamIdAndPaperNumber(examTask.getExamId(), examDetailCourse.getPaperNumber())) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("课程已开始扫描,不允许作废");
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- // 已打印任务,必须先作废,未打印任务,必须先撤回。才允许打回
|
|
|
- long count = examDetailList.stream().filter(m -> (ExamDetailStatusEnum.FINISH.equals(m.getStatus()) && m.getNormal()) || ExamDetailStatusEnum.WAITING.equals(m.getStatus())).count();
|
|
|
- if (count > 0) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("印刷任务有已打印且未作废或者未撤回数据,不允许作废");
|
|
|
- }
|
|
|
+ // 已打印任务,必须先作废,未打印任务,必须先撤回。才允许打回
|
|
|
+ List<Long> examDetailList = examDetailCourseList.stream().map(ExamDetailCourse::getExamDetailId).collect(Collectors.toList());
|
|
|
+ long count = examDetailService.listByIds(examDetailList).stream().filter(m -> (ExamDetailStatusEnum.FINISH.equals(m.getStatus()) && m.getNormal()) || ExamDetailStatusEnum.WAITING.equals(m.getStatus())).count();
|
|
|
+ if (count > 0) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("印刷任务有已打印且未作废或者未撤回数据,不允许作废");
|
|
|
}
|
|
|
|
|
|
- StringJoiner stringJoiner = new StringJoiner("_");
|
|
|
- stringJoiner.add(String.valueOf(examTask.getExamId())).add(examTask.getPaperNumber()).add(String.valueOf(examDetailList.get(0).getExamStartTime())).add(String.valueOf(examDetailList.get(0).getExamEndTime()));
|
|
|
- String key = stringJoiner.toString();
|
|
|
- CreatePdfCacheUtil.deletePaperType(key);
|
|
|
- for (ExamDetail examDetail : examDetailList) {
|
|
|
- examDetailService.resetExamDetail(examDetail.getId(), CreatePdfTypeEnum.ALL, ExamDetailStatusEnum.REJECT, true);
|
|
|
+// StringJoiner stringJoiner = new StringJoiner("_");
|
|
|
+// stringJoiner.add(String.valueOf(examTask.getExamId())).add(examTask.getPaperNumber()).add(String.valueOf(examDetailList.get(0).getExamStartTime())).add(String.valueOf(examDetailList.get(0).getExamEndTime()));
|
|
|
+// String key = stringJoiner.toString();
|
|
|
+// CreatePdfCacheUtil.deletePaperType(key);
|
|
|
+ for (Long examDetailId : examDetailList) {
|
|
|
+ examDetailService.resetExamDetail(examDetailId, CreatePdfTypeEnum.ALL, ExamDetailStatusEnum.REJECT, true);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -614,8 +472,6 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
|
|
|
examTask.setCancelRemark(cancelRemark);
|
|
|
examTaskService.updateById(examTask);
|
|
|
|
|
|
- // 作废后,考场状态改为作废,考务数据保留
|
|
|
- List<ExamDetailCourse> examDetailCourseList = examDetailCourseService.listExamDetailByExamIdAndPaperNumber(examTask.getSchoolId(), examTask.getExamId(), paperNumber);
|
|
|
// 考场状态改为作废
|
|
|
if (CollectionUtils.isNotEmpty(examDetailCourseList)) {
|
|
|
for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
|
|
@@ -663,17 +519,17 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ExamTaskDetail getByExamIdAndCourseIdAndPaperNumber(Long examId, Long courseId, String paperNumber) {
|
|
|
- ExamTask examTask = examTaskService.getByExamIdAndCourseIdAndPaperNumber(examId, courseId, paperNumber);
|
|
|
- if (examTask == null) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("未查询到试卷信息");
|
|
|
+ public ExamTaskDetail getByExamIdAndPaperNumberAndSerialNumber(Long examId, String paperNumber, Integer serialNumber) {
|
|
|
+ List<ExamTaskDetail> examTaskDetailList = this.listByExamIdAndPaperNumber(examId, paperNumber);
|
|
|
+ if (CollectionUtils.isEmpty(examTaskDetailList)) {
|
|
|
+ return null;
|
|
|
}
|
|
|
- return this.getByExamTaskId(examTask.getId());
|
|
|
+ return examTaskDetailList.stream().filter(m -> m.getSerialNumber().equals(serialNumber)).findFirst().orElse(null);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ExamTaskDetail getByExamIdAndPaperNumberAndSerialNumber(Long examId, String paperNumber, Integer serialNumber) {
|
|
|
- List<ExamTaskDetail> examTaskDetailList = this.listByExamIdAndPaperNumber(examId, paperNumber);
|
|
|
+ public ExamTaskDetail getByExamTaskIdAndSerialNumber(Long examTaskId, Integer serialNumber) {
|
|
|
+ List<ExamTaskDetail> examTaskDetailList = this.listByExamTaskId(examTaskId);
|
|
|
if (CollectionUtils.isEmpty(examTaskDetailList)) {
|
|
|
return null;
|
|
|
}
|
|
@@ -684,48 +540,30 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
|
|
|
public void updateExposePaperType(Long examId, List<ExamDetailCourse> examDetailCourses) {
|
|
|
// 更新曝光卷型、未曝光卷型
|
|
|
for (ExamDetailCourse examDetailCourse : examDetailCourses) {
|
|
|
- ExamTaskDetail examTaskDetail = this.getByExamIdAndCourseIdAndPaperNumber(examId, examDetailCourse.getCourseId(), examDetailCourse.getPaperNumber());
|
|
|
- // 考生使用卷型
|
|
|
- List<String> studentPaperTypes = examStudentService.listPaperTypeByExamDetailCourseId(String.valueOf(examDetailCourse.getId()));
|
|
|
- List<String> paperTypeList = Objects.isNull(examTaskDetail.getPaperType()) ? new ArrayList<>() : Arrays.asList(examTaskDetail.getPaperType().split(","));
|
|
|
- List<String> exposedPaperTypeList = Objects.isNull(examTaskDetail.getExposedPaperType()) ? new ArrayList<>() : Arrays.asList(examTaskDetail.getExposedPaperType().split(","));
|
|
|
- // 曝光卷型
|
|
|
- List<String> unionList = (List<String>) CollectionUtils.union(exposedPaperTypeList, studentPaperTypes);
|
|
|
- // 未曝光卷型
|
|
|
- List<String> subtractList = (List<String>) CollectionUtils.subtract(paperTypeList, unionList);
|
|
|
+ ExamTaskDetail examTaskDetail = this.getByExamIdAndPaperNumberAndSerialNumber(examId, examDetailCourse.getPaperNumber(), examDetailCourse.getSerialNumber());
|
|
|
+ // 更新曝光卷型
|
|
|
UpdateWrapper<ExamTaskDetail> examTaskDetailUpdateWrapper = new UpdateWrapper<>();
|
|
|
- String exposedPaper = String.join(",", unionList);
|
|
|
- String unexposedPaper = String.join(",", subtractList);
|
|
|
examTaskDetailUpdateWrapper.lambda()
|
|
|
- .set(ExamTaskDetail::getExposedPaperType, StringUtils.isBlank(exposedPaper) ? null : exposedPaper)
|
|
|
- .set(ExamTaskDetail::getUnexposedPaperType, StringUtils.isBlank(unexposedPaper) ? null : unexposedPaper)
|
|
|
- .eq(ExamTaskDetail::getExamTaskId, examTaskDetail.getExamTaskId());
|
|
|
+ .set(ExamTaskDetail::getExposed, true)
|
|
|
+ .set(ExamTaskDetail::getExposedExamId, examId)
|
|
|
+ .eq(ExamTaskDetail::getId, examTaskDetail.getId());
|
|
|
this.update(examTaskDetailUpdateWrapper);
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void updateUnexposePaperType(Long examId, String paperNumber, String exposePaperType) {
|
|
|
+ public void updateUnexposePaperType(Long examId, String paperNumber, Integer serialNumber) {
|
|
|
if (examTaskService.getByExamIdAndPaperNumber(examId, paperNumber) == null) {
|
|
|
return;
|
|
|
}
|
|
|
// 更新曝光卷型、未曝光卷型
|
|
|
- ExamTaskDetail examTaskDetail = this.getByExamIdAndCourseIdAndPaperNumber(examId, null, paperNumber);
|
|
|
- // 考生使用卷型
|
|
|
- List<String> studentPaperTypes = StringUtils.isBlank(exposePaperType) ? Arrays.asList(ArrayUtils.EMPTY_STRING_ARRAY) : Arrays.asList(exposePaperType.split(","));
|
|
|
- List<String> paperTypeList = Objects.isNull(examTaskDetail.getPaperType()) ? new ArrayList<>() : Arrays.asList(examTaskDetail.getPaperType().split(","));
|
|
|
- List<String> exposedPaperTypeList = Objects.isNull(examTaskDetail.getExposedPaperType()) ? new ArrayList<>() : Arrays.asList(examTaskDetail.getExposedPaperType().split(","));
|
|
|
-
|
|
|
- List<String> exposedList = (List<String>) CollectionUtils.subtract(exposedPaperTypeList, studentPaperTypes);
|
|
|
- // 未曝光卷型
|
|
|
- List<String> subtractList = (List<String>) CollectionUtils.subtract(paperTypeList, exposedList);
|
|
|
+ ExamTaskDetail examTaskDetail = this.getByExamIdAndPaperNumberAndSerialNumber(examId, paperNumber, serialNumber);
|
|
|
UpdateWrapper<ExamTaskDetail> examTaskDetailUpdateWrapper = new UpdateWrapper<>();
|
|
|
- String exposedPaper = String.join(",", exposedList);
|
|
|
- String unexposedPaper = String.join(",", subtractList);
|
|
|
examTaskDetailUpdateWrapper.lambda()
|
|
|
- .set(ExamTaskDetail::getExposedPaperType, StringUtils.isBlank(exposedPaper) ? null : exposedPaper)
|
|
|
- .set(ExamTaskDetail::getUnexposedPaperType, StringUtils.isBlank(unexposedPaper) ? null : unexposedPaper)
|
|
|
- .eq(ExamTaskDetail::getExamTaskId, examTaskDetail.getExamTaskId());
|
|
|
+ .set(ExamTaskDetail::getExposed, false)
|
|
|
+ .set(ExamTaskDetail::getExposedExamId, null)
|
|
|
+ .eq(ExamTaskDetail::getId, examTaskDetail.getId());
|
|
|
this.update(examTaskDetailUpdateWrapper);
|
|
|
}
|
|
|
|
|
@@ -764,93 +602,4 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
|
|
|
List<ExamTaskDetail> examTaskDetailList = this.listByExamIdAndPaperNumber(examId, paperNumber);
|
|
|
return examTaskDetailList.stream().filter(m -> m.getSerialNumber() != null && m.getSerialNumber().equals(serialNumber)).findFirst().orElse(null);
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * 卷库校验
|
|
|
- *
|
|
|
- * @param examTaskDetail
|
|
|
- */
|
|
|
- void validPaperUpdate(ExamTaskDetail examTaskDetail) {
|
|
|
- // 旧记录
|
|
|
- ExamTaskDetail examTaskDetailTemp = this.getByExamTaskId(examTaskDetail.getExamTaskId());
|
|
|
- if (examTaskDetailTemp == null) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("命题任务数据异常");
|
|
|
- }
|
|
|
-
|
|
|
- List<PaperInfoVo> oldPaperAttachmentIdsList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetailTemp.getPaperAttachmentIds());
|
|
|
- List<PaperInfoVo> newPaperAttachmentIdsList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetail.getPaperAttachmentIds());
|
|
|
- // 卷型、题卡没有变动,直接return
|
|
|
- if (oldPaperAttachmentIdsList.size() == newPaperAttachmentIdsList.size()) {
|
|
|
- String oldString = oldPaperAttachmentIdsList.stream().sorted(Comparator.comparing(m -> m.getName())).map(m -> m.getName() + m.getAttachmentId()).collect(Collectors.joining());
|
|
|
- String newString = newPaperAttachmentIdsList.stream().sorted(Comparator.comparing(m -> m.getName())).map(m -> m.getName() + m.getAttachmentId()).collect(Collectors.joining());
|
|
|
- if (oldString.equals(newString) && examTaskDetailTemp.getPaperAttachmentIds().equals(examTaskDetail.getPaperAttachmentIds())) {
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- ExamTask examTask = examTaskService.getById(examTaskDetail.getExamTaskId());
|
|
|
- // 是否审核中
|
|
|
- TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(examTask.getFlowId());
|
|
|
- if (!tfFlowApprove.getStatus().equals(FlowStatusEnum.FINISH)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("命题任务没有审核完成,不能修改卷库");
|
|
|
- }
|
|
|
-
|
|
|
- // 提交印刷的考场,不允许修改关联试卷
|
|
|
- List<ExamDetail> examDetails = examDetailService.listExamDetailByExamIdAndCourseIdAndPaperNumber(examTask.getExamId(), examTask.getCourseId(), examTask.getPaperNumber());
|
|
|
- if (CollectionUtils.isNotEmpty(examDetails)) {
|
|
|
- List<ExamDetail> examDetails1 = examDetails.stream().filter(m -> !ExamDetailStatusEnum.NEW.equals(m.getStatus())
|
|
|
- && !ExamDetailStatusEnum.READY.equals(m.getStatus())
|
|
|
- && !ExamDetailStatusEnum.WAITING.equals(m.getStatus())).collect(Collectors.toList());
|
|
|
- if (!examDetails1.isEmpty()) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("印刷任务已开始打印,不能修改卷库");
|
|
|
- }
|
|
|
- Map<Long, List<Long>> map = examDetails.stream().collect(Collectors.groupingBy(ExamDetail::getPrintPlanId, Collectors.mapping(ExamDetail::getId, Collectors.toList())));
|
|
|
- for (Map.Entry<Long, List<Long>> listEntry : map.entrySet()) {
|
|
|
- int countRunning = tbTaskPdfService.countRunningByExamDetailIds(listEntry.getValue());
|
|
|
- if (countRunning > 0) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("关联命题任务的考场正在生成打印文件,不能修改卷库");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 已曝光试卷不能修改
|
|
|
- String exposedPaperType = examTaskDetailTemp.getExposedPaperType();
|
|
|
- if (StringUtils.isNotBlank(exposedPaperType)) {
|
|
|
- Map<String, String> oldPaperAttachmentIdMap = oldPaperAttachmentIdsList.stream().collect(Collectors.toMap(m -> m.getName(), m -> String.valueOf(m.getAttachmentId())));
|
|
|
- String[] exposedPaperTypes = exposedPaperType.split(",");
|
|
|
- String newPaperAttachmentIds = examTaskDetail.getPaperAttachmentIds();
|
|
|
- if (StringUtils.isBlank(newPaperAttachmentIds)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("已曝光试卷不能删除");
|
|
|
- } else {
|
|
|
- Map<String, String> newPaperAttachmentIdMap = newPaperAttachmentIdsList.stream().collect(Collectors.toMap(m -> m.getName(), m -> String.valueOf(m.getAttachmentId())));
|
|
|
- for (String paperType : exposedPaperTypes) {
|
|
|
- if (!oldPaperAttachmentIdMap.containsKey(paperType)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("原试卷卷型[" + paperType + "]不存在");
|
|
|
- }
|
|
|
- if (!newPaperAttachmentIdMap.containsKey(paperType)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("已曝光卷型[" + paperType + "]不能删除");
|
|
|
- }
|
|
|
-
|
|
|
- String newAttachmentId = newPaperAttachmentIdMap.get(paperType);
|
|
|
- String oldAttachmentId = oldPaperAttachmentIdMap.get(paperType);
|
|
|
- if (!newAttachmentId.equals(oldAttachmentId)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("已曝光卷型[" + paperType + "]不能修改试卷文件");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 已有曝光卷型时,题卡不能修改
|
|
|
- if (!examTaskDetailTemp.getPaperAttachmentIds().equals(examTaskDetail.getPaperAttachmentIds())) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("已有试卷曝光,不能修改题卡");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 将旧题卡更新为未绑定
|
|
|
- List<PaperInfoVo> oldPaperAttachmentIdsJson = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetailTemp.getPaperAttachmentIds());
|
|
|
- examCardService.updateUsedById(oldPaperAttachmentIdsJson.stream().filter(m -> StringUtils.isNotBlank(m.getCardId())).map(m -> Long.parseLong(m.getCardId())).collect(Collectors.toList()));
|
|
|
-
|
|
|
- // 将新题卡更新为已绑定
|
|
|
- List<PaperInfoVo> newPaperAttachmentIdsJson = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetail.getPaperAttachmentIds());
|
|
|
- examCardService.updateUsedById(newPaperAttachmentIdsJson.stream().filter(m -> StringUtils.isNotBlank(m.getCardId())).map(m -> Long.valueOf(m.getCardId())).collect(Collectors.toList()));
|
|
|
- }
|
|
|
}
|