|
@@ -10,6 +10,7 @@ import com.qmth.distributed.print.business.bean.dto.ExamTaskDetailDto;
|
|
import com.qmth.distributed.print.business.bean.params.RelatePaperParam;
|
|
import com.qmth.distributed.print.business.bean.params.RelatePaperParam;
|
|
import com.qmth.distributed.print.business.entity.*;
|
|
import com.qmth.distributed.print.business.entity.*;
|
|
import com.qmth.distributed.print.business.enums.ExamDetailStatusEnum;
|
|
import com.qmth.distributed.print.business.enums.ExamDetailStatusEnum;
|
|
|
|
+import com.qmth.distributed.print.business.enums.ExamStatusEnum;
|
|
import com.qmth.distributed.print.business.enums.PrintPlanStatusEnum;
|
|
import com.qmth.distributed.print.business.enums.PrintPlanStatusEnum;
|
|
import com.qmth.distributed.print.business.mapper.ExamTaskDetailMapper;
|
|
import com.qmth.distributed.print.business.mapper.ExamTaskDetailMapper;
|
|
import com.qmth.distributed.print.business.service.*;
|
|
import com.qmth.distributed.print.business.service.*;
|
|
@@ -18,12 +19,16 @@ import com.qmth.teachcloud.common.bean.dto.MqDto;
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
import com.qmth.teachcloud.common.entity.SysUser;
|
|
import com.qmth.teachcloud.common.entity.SysUser;
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
|
+import com.qmth.teachcloud.common.enums.FlowStatusEnum;
|
|
import com.qmth.teachcloud.common.enums.MqTagEnum;
|
|
import com.qmth.teachcloud.common.enums.MqTagEnum;
|
|
import com.qmth.teachcloud.common.enums.TaskTypeEnum;
|
|
import com.qmth.teachcloud.common.enums.TaskTypeEnum;
|
|
import com.qmth.teachcloud.common.service.TBTaskService;
|
|
import com.qmth.teachcloud.common.service.TBTaskService;
|
|
import com.qmth.teachcloud.common.service.TeachcloudCommonService;
|
|
import com.qmth.teachcloud.common.service.TeachcloudCommonService;
|
|
import com.qmth.teachcloud.common.util.RedisUtil;
|
|
import com.qmth.teachcloud.common.util.RedisUtil;
|
|
import com.qmth.teachcloud.common.util.ServletUtil;
|
|
import com.qmth.teachcloud.common.util.ServletUtil;
|
|
|
|
+import org.activiti.engine.TaskService;
|
|
|
|
+import org.activiti.engine.runtime.ProcessInstance;
|
|
|
|
+import org.activiti.engine.task.Task;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.context.annotation.Lazy;
|
|
@@ -33,10 +38,7 @@ import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
-import java.util.Arrays;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
-import java.util.Set;
|
|
|
|
|
|
+import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -84,6 +86,15 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
|
|
@Resource
|
|
@Resource
|
|
RedisUtil redisUtil;
|
|
RedisUtil redisUtil;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ ActivitiService activitiService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ TaskService taskService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ TFFlowApproveService tfFlowApproveService;
|
|
|
|
+
|
|
@Transactional
|
|
@Transactional
|
|
@Override
|
|
@Override
|
|
public boolean enable(ExamTaskDetail examTaskDetail) {
|
|
public boolean enable(ExamTaskDetail examTaskDetail) {
|
|
@@ -310,90 +321,150 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public boolean paperUpdate(ExamTaskDetail examTaskDetail) {
|
|
public boolean paperUpdate(ExamTaskDetail examTaskDetail) {
|
|
- SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
|
- // 提交印刷的考场,不允许修改关联试卷
|
|
|
|
|
|
+
|
|
|
|
+ validPaperUpdate(examTaskDetail);
|
|
|
|
+
|
|
|
|
+ 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::getCardId, examTaskDetail.getCardId())
|
|
|
|
+ .set(ExamTaskDetail::getUnexposedPaperType, unexposedPaperType)
|
|
|
|
+ .eq(ExamTaskDetail::getExamTaskId, examTaskDetail.getExamTaskId());
|
|
|
|
+ this.update(examTaskDetailUpdateWrapper);
|
|
|
|
+
|
|
ExamTask examTask = examTaskService.getById(examTaskDetail.getExamTaskId());
|
|
ExamTask examTask = examTaskService.getById(examTaskDetail.getExamTaskId());
|
|
List<ExamDetail> examDetails = examDetailService.listByCourseCodeAndPaperNumber(examTask.getSchoolId(), examTask.getCourseCode(), examTask.getPaperNumber());
|
|
List<ExamDetail> examDetails = examDetailService.listByCourseCodeAndPaperNumber(examTask.getSchoolId(), examTask.getCourseCode(), examTask.getPaperNumber());
|
|
- if (examDetails != null && examDetails.size() > 0) {
|
|
|
|
- List<ExamDetail> examDetails1 = examDetails.stream().filter(m -> !ExamDetailStatusEnum.NEW.equals(m.getStatus()) && !ExamDetailStatusEnum.READY.equals(m.getStatus())).collect(Collectors.toList());
|
|
|
|
|
|
+ if(!CollectionUtils.isEmpty(examDetails)) {
|
|
|
|
+ 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 (examTask.getReview()) {
|
|
|
|
+ // 发起新流程
|
|
|
|
+ //TODO 这里以后要判断学校code来取流程key
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+ map.computeIfAbsent(SystemConstant.APPROVE_ID, v -> String.valueOf(examTask.getUserId()));
|
|
|
|
+ ProcessInstance processInstance = activitiService.startActivity(SystemConstant.GDYKDX_FLOW_KEY, map);
|
|
|
|
+ Long flowId = Long.parseLong(processInstance.getId());
|
|
|
|
+ UpdateWrapper<ExamTask> updateWrapper = new UpdateWrapper<>();
|
|
|
|
+ updateWrapper.lambda().set(ExamTask::getFlowId, flowId).eq(ExamTask::getId, examTaskDetail.getExamTaskId());
|
|
|
|
+ examTaskService.update(updateWrapper);
|
|
|
|
+ if (Objects.nonNull(flowId)) {
|
|
|
|
+ // 审核一级
|
|
|
|
+ Task task = taskService.createTaskQuery().processInstanceId(String.valueOf(flowId)).singleResult();
|
|
|
|
+ if (Objects.nonNull(task)) {
|
|
|
|
+ Map<String, Object> map1 = new HashMap<>();
|
|
|
|
+ map1.computeIfAbsent(SystemConstant.FLOW_TASK_ID, v -> task.getId());
|
|
|
|
+ activitiService.taskApprove(map1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ExamTaskDetail getByExamTaskId(Long examTaskId) {
|
|
|
|
+ QueryWrapper<ExamTaskDetail> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.lambda().eq(ExamTaskDetail::getExamTaskId, examTaskId);
|
|
|
|
+ return this.getOne(queryWrapper);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 卷库校验
|
|
|
|
+ *
|
|
|
|
+ * @param examTaskDetail
|
|
|
|
+ */
|
|
|
|
+ void validPaperUpdate(ExamTaskDetail examTaskDetail) {
|
|
|
|
+ // 旧记录
|
|
|
|
+ ExamTaskDetail examTaskDetailTemp = this.getByExamTaskId(examTaskDetail.getExamTaskId());
|
|
|
|
+ if (examTaskDetailTemp == null) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("命题任务数据异常");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<Map> oldPaperAttachmentIdsList = JSONObject.parseArray(examTaskDetailTemp.getPaperAttachmentIds(), Map.class);
|
|
|
|
+ List<Map> newPaperAttachmentIdsList = JSONObject.parseArray(examTaskDetail.getPaperAttachmentIds(), Map.class);
|
|
|
|
+ // 卷型、题卡没有变动,直接return
|
|
|
|
+ if (oldPaperAttachmentIdsList.size() == newPaperAttachmentIdsList.size()) {
|
|
|
|
+ String oldString = oldPaperAttachmentIdsList.stream().sorted(Comparator.comparing(m -> m.get("name").toString())).map(m -> m.get("name").toString() + m.get("attachmentId").toString()).collect(Collectors.joining());
|
|
|
|
+ String newString = newPaperAttachmentIdsList.stream().sorted(Comparator.comparing(m -> m.get("name").toString())).map(m -> m.get("name").toString() + m.get("attachmentId").toString()).collect(Collectors.joining());
|
|
|
|
+ if (oldString.equals(newString) && examTaskDetailTemp.getCardId().equals(examTaskDetail.getCardId())) {
|
|
|
|
+ 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.listByCourseCodeAndPaperNumber(examTask.getSchoolId(), examTask.getCourseCode(), examTask.getPaperNumber());
|
|
|
|
+ if (!CollectionUtils.isEmpty(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()) {
|
|
if (!examDetails1.isEmpty()) {
|
|
- throw ExceptionResultEnum.ERROR.exception("有考场已开始打印,不能修改卷库");
|
|
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("印刷任务已开始打印,不能修改卷库");
|
|
}
|
|
}
|
|
Map<Long, List<Long>> map = examDetails.stream().collect(Collectors.groupingBy(ExamDetail::getPrintPlanId, Collectors.mapping(ExamDetail::getId, Collectors.toList())));
|
|
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()) {
|
|
for (Map.Entry<Long, List<Long>> listEntry : map.entrySet()) {
|
|
boolean b = tbTaskService.countByPrintPlanIdAndEntityId(examTask.getSchoolId(), listEntry.getKey(), listEntry.getValue());
|
|
boolean b = tbTaskService.countByPrintPlanIdAndEntityId(examTask.getSchoolId(), listEntry.getKey(), listEntry.getValue());
|
|
if (!b) {
|
|
if (!b) {
|
|
- throw ExceptionResultEnum.ERROR.exception("有关联该任务的考场正在生成打印pdf,不能修改卷库");
|
|
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("关联命题任务的考场正在生成打印文件,不能修改卷库");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- QueryWrapper<ExamTaskDetail> queryWrapper = new QueryWrapper<>();
|
|
|
|
- queryWrapper.lambda().eq(ExamTaskDetail::getExamTaskId, examTaskDetail.getExamTaskId());
|
|
|
|
- ExamTaskDetail examTaskDetailTemp = this.getOne(queryWrapper);
|
|
|
|
- if (examTaskDetailTemp == null) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("命题任务数据异常");
|
|
|
|
- }
|
|
|
|
// 已曝光试卷不能修改
|
|
// 已曝光试卷不能修改
|
|
String exposedPaperType = examTaskDetailTemp.getExposedPaperType();
|
|
String exposedPaperType = examTaskDetailTemp.getExposedPaperType();
|
|
if (StringUtils.isNotBlank(exposedPaperType)) {
|
|
if (StringUtils.isNotBlank(exposedPaperType)) {
|
|
- List<Map> oldPaperAttachmentIdsList = JSONObject.parseArray(examTaskDetailTemp.getPaperAttachmentIds(), Map.class);
|
|
|
|
Map<String, String> oldPaperAttachmentIdMap = oldPaperAttachmentIdsList.stream().collect(Collectors.toMap(m -> m.get("name").toString(), m -> m.get("attachmentId").toString()));
|
|
Map<String, String> oldPaperAttachmentIdMap = oldPaperAttachmentIdsList.stream().collect(Collectors.toMap(m -> m.get("name").toString(), m -> m.get("attachmentId").toString()));
|
|
String[] exposedPaperTypes = exposedPaperType.split(",");
|
|
String[] exposedPaperTypes = exposedPaperType.split(",");
|
|
String newPaperAttachmentIds = examTaskDetail.getPaperAttachmentIds();
|
|
String newPaperAttachmentIds = examTaskDetail.getPaperAttachmentIds();
|
|
if (StringUtils.isBlank(newPaperAttachmentIds)) {
|
|
if (StringUtils.isBlank(newPaperAttachmentIds)) {
|
|
throw ExceptionResultEnum.ERROR.exception("已曝光试卷不能删除");
|
|
throw ExceptionResultEnum.ERROR.exception("已曝光试卷不能删除");
|
|
} else {
|
|
} else {
|
|
- List<Map> newPaperAttachmentIdsList = JSONObject.parseArray(newPaperAttachmentIds, Map.class);
|
|
|
|
Map<String, String> newPaperAttachmentIdMap = newPaperAttachmentIdsList.stream().collect(Collectors.toMap(m -> m.get("name").toString(), m -> m.get("attachmentId").toString()));
|
|
Map<String, String> newPaperAttachmentIdMap = newPaperAttachmentIdsList.stream().collect(Collectors.toMap(m -> m.get("name").toString(), m -> m.get("attachmentId").toString()));
|
|
for (String paperType : exposedPaperTypes) {
|
|
for (String paperType : exposedPaperTypes) {
|
|
|
|
+ if (!oldPaperAttachmentIdMap.containsKey(paperType)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("原试卷卷型【" + paperType + "】不存在");
|
|
|
|
+ }
|
|
if (!newPaperAttachmentIdMap.containsKey(paperType)) {
|
|
if (!newPaperAttachmentIdMap.containsKey(paperType)) {
|
|
- throw ExceptionResultEnum.ERROR.exception("已曝光试卷不能删除");
|
|
|
|
- } else {
|
|
|
|
- if (!oldPaperAttachmentIdMap.containsKey(paperType)) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("原试卷卷型有误");
|
|
|
|
- }
|
|
|
|
- String newAttachmentId = newPaperAttachmentIdMap.get(paperType);
|
|
|
|
- String oldAttachmentId = oldPaperAttachmentIdMap.get(paperType);
|
|
|
|
- if (!newAttachmentId.equals(oldAttachmentId)) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("已曝光试卷不能修改");
|
|
|
|
- }
|
|
|
|
|
|
+ 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 (examTask.getReview()) {
|
|
|
|
- // 加入临时审核表
|
|
|
|
- ExamTaskPaperLog examTaskPaperLog = examTaskPaperLogService.getByExamTaskIdAndReview(examTaskDetail.getExamTaskId(), false);
|
|
|
|
- if (examTaskPaperLog == null) {
|
|
|
|
- examTaskPaperLog = new ExamTaskPaperLog();
|
|
|
|
- examTaskPaperLog.setId(SystemConstant.getDbUuid());
|
|
|
|
- examTaskPaperLog.setExamTaskId(examTaskDetail.getExamTaskId());
|
|
|
|
- examTaskPaperLog.setReview(false);
|
|
|
|
|
|
+ // 已有曝光卷型时,题卡不能修改
|
|
|
|
+ if (!examTaskDetailTemp.getCardId().equals(examTaskDetail.getCardId())) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("已有试卷曝光,不能修改题卡");
|
|
}
|
|
}
|
|
- examTaskPaperLog.setPaperType(examTaskDetail.getPaperType());
|
|
|
|
- examTaskPaperLog.setPaperAttachmentIds(examTaskDetail.getPaperAttachmentIds());
|
|
|
|
- examTaskPaperLog.setCardId(examTaskDetail.getCardId());
|
|
|
|
- examTaskPaperLog.setCreateId(sysUser.getId());
|
|
|
|
- examTaskPaperLog.setCreateTime(System.currentTimeMillis());
|
|
|
|
- examTaskPaperLogService.saveOrUpdate(examTaskPaperLog);
|
|
|
|
- } else {
|
|
|
|
- UpdateWrapper<ExamTaskDetail> updateWrapper = new UpdateWrapper<>();
|
|
|
|
- updateWrapper.lambda().set(ExamTaskDetail::getPaperAttachmentIds, examTaskDetail.getPaperAttachmentIds()).eq(ExamTaskDetail::getExamTaskId, examTaskDetail.getExamTaskId());
|
|
|
|
- this.update(updateWrapper);
|
|
|
|
}
|
|
}
|
|
- return true;
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public ExamTaskDetail getByExamTaskId(Long examTaskId) {
|
|
|
|
- QueryWrapper<ExamTaskDetail> queryWrapper = new QueryWrapper<>();
|
|
|
|
- queryWrapper.lambda().eq(ExamTaskDetail::getExamTaskId, examTaskId);
|
|
|
|
- return this.getOne(queryWrapper);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
}
|
|
}
|