|
@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.qmth.distributed.print.business.bean.dto.*;
|
|
|
+import com.qmth.distributed.print.business.bean.params.ExamTaskApplyParam;
|
|
|
import com.qmth.distributed.print.business.bean.result.WorkResult;
|
|
|
import com.qmth.distributed.print.business.entity.*;
|
|
|
import com.qmth.distributed.print.business.enums.*;
|
|
@@ -30,7 +31,9 @@ import com.qmth.teachcloud.common.util.ResultUtil;
|
|
|
import com.qmth.teachcloud.common.util.ServletUtil;
|
|
|
import com.qmth.teachcloud.common.util.excel.ExcelError;
|
|
|
import org.activiti.engine.ActivitiObjectNotFoundException;
|
|
|
+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.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
@@ -134,6 +137,9 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
|
@Resource
|
|
|
TFFlowService tfFlowService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ TaskService taskService;
|
|
|
+
|
|
|
@Override
|
|
|
public List<ExamTask> listByCourseCode(Long schoolId, String code) {
|
|
|
QueryWrapper<ExamTask> queryWrapper = new QueryWrapper<>();
|
|
@@ -759,14 +765,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public IPage<ExamTaskDetailDto> listTaskPaper(String courseCode, String paperNumber, Long startTime, Long endTime, MakeMethodEnum makeMethod, String cardRuleName, Integer pageNumber, Integer pageSize) {
|
|
|
- if (SystemConstant.strNotNull(cardRuleName)) {
|
|
|
- if (cardRuleName.equals("全部通卡")) {
|
|
|
- cardRuleName = "-1";
|
|
|
- } else {
|
|
|
- cardRuleName = SystemConstant.translateSpecificSign(cardRuleName);
|
|
|
- }
|
|
|
- }
|
|
|
+ public IPage<ExamTaskDetailDto> listTaskPaper(String courseCode, String paperNumber, Long startTime, Long endTime, MakeMethodEnum makeMethod, Long cardRuleId, Integer pageNumber, Integer pageSize) {
|
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
// 查询用户角色是否包含命题老师
|
|
|
List<SysRole> list = sysUserRoleService.listRoleByUserId(sysUser.getId());
|
|
@@ -774,7 +773,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
|
Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
Set<Long> orgIds = teachcloudCommonService.listSubOrgIds(null);
|
|
|
Page<ExamTaskDetailDto> page = new Page<>(pageNumber, pageSize);
|
|
|
- IPage<ExamTaskDetailDto> examTaskDtoIPage = this.baseMapper.listTaskPaper(page, schoolId, courseCode, paperNumber, startTime, endTime, orgIds, containsQuestionTeacher, sysUser.getId(), makeMethod, cardRuleName);
|
|
|
+ IPage<ExamTaskDetailDto> examTaskDtoIPage = this.baseMapper.listTaskPaper(page, schoolId, courseCode, paperNumber, startTime, endTime, orgIds, containsQuestionTeacher, sysUser.getId(), makeMethod, cardRuleId);
|
|
|
return examTaskDtoIPage;
|
|
|
}
|
|
|
|
|
@@ -843,6 +842,10 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
|
if (StringUtils.isBlank(examTaskDetail.getPaperConfirmAttachmentIds())) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("入库审核ID不能为空");
|
|
|
}
|
|
|
+ String[] paperTypes = examTaskDetail.getPaperType().split(",");
|
|
|
+ if (paperTypes.length - examTaskDetail.getDrawCount().intValue() < 0) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("单次抽卷数量不能大于卷型数量");
|
|
|
+ }
|
|
|
|
|
|
// 校验题卡是否提交
|
|
|
ExamCard examCard = examCardService.getById(examTaskDetail.getCardId());
|
|
@@ -873,8 +876,17 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
|
|
|
|
// 更新examTask状态status
|
|
|
ExamTask examTask = this.getById(examTaskDetail.getExamTaskId());
|
|
|
- if (examTaskDetail.getOperateType().equals(ExamStatusEnum.SUBMIT.name()) && !examTask.getReview()) {
|
|
|
- examTask.setStatus(ExamStatusEnum.SUBMIT);
|
|
|
+ if (examTaskDetail.getOperateType().equals(ExamStatusEnum.SUBMIT.name())) {
|
|
|
+ if (Objects.isNull(examTask.getFlowId())) {
|
|
|
+ //TODO 这里以后要判断学校code来取流程key
|
|
|
+ examTask.setStatus(ExamStatusEnum.SUBMIT);
|
|
|
+ if (examTask.getReview()) {
|
|
|
+ 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);
|
|
|
+ examTask.setFlowId(Long.parseLong(processInstance.getId()));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
UpdateWrapper<ExamTask> updateWrapper = new UpdateWrapper<>();
|
|
@@ -883,6 +895,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
|
.set(ExamTask::getUpdateId, sysUser.getId())
|
|
|
.set(ExamTask::getUpdateTime, System.currentTimeMillis())
|
|
|
.set(ExamTask::getReviewStatus, null)
|
|
|
+ .set(ExamTask::getFlowId, examTask.getFlowId())
|
|
|
.eq(ExamTask::getId, examTask.getId());
|
|
|
this.update(updateWrapper);
|
|
|
|
|
@@ -1320,4 +1333,138 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
|
}
|
|
|
examTaskDetailService.removeById(examTaskDetail.getId());
|
|
|
}
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public ExamTask saveExamTaskAndExamTaskDetail(ExamTaskApplyParam examTaskApplyParam) {
|
|
|
+ Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
+ SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
+ ExamTask examTask = examTaskApplyParam.getExamTask();
|
|
|
+ ExamTaskDetail examTaskDetail = examTaskApplyParam.getExamTaskDetail();
|
|
|
+ try {
|
|
|
+ if (StringUtils.isNotBlank(examTask.getPaperNumber())) {
|
|
|
+ QueryWrapper<ExamTask> taskQueryWrapper = new QueryWrapper<>();
|
|
|
+ taskQueryWrapper.lambda().eq(ExamTask::getSchoolId, schoolId).eq(ExamTask::getPaperNumber, examTask.getPaperNumber());
|
|
|
+ ExamTask task = this.getOne(taskQueryWrapper);
|
|
|
+ if (task != null && Objects.nonNull(examTask.getId()) && examTask.getId().longValue() != task.getId().longValue()) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("试卷编号已存在");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 试卷编号生成规则:年月日(例如:20100419)+0000(例如:0001)顺序编号
|
|
|
+ String paperNumber = printCommonService.createPaperNumber(schoolId);
|
|
|
+ examTask.setPaperNumber(paperNumber);
|
|
|
+ }
|
|
|
+
|
|
|
+ BasicExamRule basicExamRule = basicExamRuleService.getBySchoolId();
|
|
|
+ if (basicExamRule == null) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("通用规则未设置");
|
|
|
+ }
|
|
|
+ examTask.setId(Objects.isNull(examTask.getId()) ? SystemConstant.getDbUuid() : examTask.getId());
|
|
|
+ examTask.setSchoolId(schoolId);
|
|
|
+ examTask.setOrgId(sysUser.getOrgId());
|
|
|
+ examTask.setCreateId(sysUser.getId());
|
|
|
+ examTask.setReview(basicExamRule.getReview());
|
|
|
+ examTask.setUserId(sysUser.getId());
|
|
|
+ if (examTask.getUserId() == null || !ExamStatusEnum.SUBMIT.name().equals(examTaskDetail.getOperateType())) {
|
|
|
+ examTask.setStatus(ExamStatusEnum.DRAFT);
|
|
|
+ } else {
|
|
|
+ if (Objects.isNull(examTask.getFlowId())) {
|
|
|
+ //TODO 这里以后要判断学校code来取流程key
|
|
|
+ examTask.setStatus(ExamStatusEnum.SUBMIT);
|
|
|
+ if (basicExamRule.getReview()) {
|
|
|
+ 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);
|
|
|
+ examTask.setFlowId(Long.parseLong(processInstance.getId()));
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.saveOrUpdate(examTask);
|
|
|
+
|
|
|
+ // 提交时,校验
|
|
|
+ if (ExamStatusEnum.SUBMIT.name().equals(examTaskDetail.getOperateType())) {
|
|
|
+
|
|
|
+ if(Objects.nonNull(examTask.getFlowId())){
|
|
|
+ // 审核一级
|
|
|
+ Task task = taskService.createTaskQuery().processInstanceId(String.valueOf(examTask.getFlowId())).singleResult();
|
|
|
+ if(Objects.nonNull(task)) {
|
|
|
+ Map<String, Object> map1 = new HashMap<>();
|
|
|
+ map1.computeIfAbsent(SystemConstant.FLOW_TASK_ID, v -> task.getId());
|
|
|
+ activitiService.taskApprove(map1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(examTaskDetail.getPaperType())) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("试卷类型不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(examTaskDetail.getPaperAttachmentIds())) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("试卷ID不能为空");
|
|
|
+ }
|
|
|
+ if (examTaskDetail.getCardId() == null) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("题卡ID不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(examTaskDetail.getPaperConfirmAttachmentIds())) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("入库审核ID不能为空");
|
|
|
+ }
|
|
|
+ String[] paperTypes = examTaskDetail.getPaperType().split(",");
|
|
|
+ if (paperTypes.length - examTaskDetail.getDrawCount().intValue() < 0) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("单次抽卷数量不能大于卷型数量");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 校验题卡是否提交
|
|
|
+ ExamCard examCard = examCardService.getById(examTaskDetail.getCardId());
|
|
|
+ if (!ExamCardStatusEnum.SUBMIT.name().equals(examCard.getStatus().name())) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("请先提交题卡");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 是否强制包含试卷
|
|
|
+
|
|
|
+ List<Map> paperAttachmentIds = JSONObject.parseArray(examTaskDetail.getPaperAttachmentIds(), Map.class);
|
|
|
+ // 未上传试卷的类型个数
|
|
|
+ long count = paperAttachmentIds.stream().filter(m -> StringUtils.isBlank(m.get("attachmentId").toString())).count();
|
|
|
+ if (basicExamRule.getIncludePaper()) {
|
|
|
+ if (StringUtils.isBlank(examTaskDetail.getPaperAttachmentIds())) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("试卷文件未上传");
|
|
|
+ }
|
|
|
+ if (count > 0) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("所有类型的试卷文件必须全部上传");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // count == 0为全部上传
|
|
|
+ if (count != 0 && paperAttachmentIds.size() != count) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("所有类型的试卷文件必须全部上传或全部不上传");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ QueryWrapper<ExamTaskDetail> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.lambda().eq(ExamTaskDetail::getExamTaskId, examTask.getId());
|
|
|
+ ExamTaskDetail detail = examTaskDetailService.getOne(queryWrapper);
|
|
|
+ if (detail != null) {
|
|
|
+ examTaskDetail.setId(detail.getId());
|
|
|
+ // 已曝光试卷和未曝光试卷赋值
|
|
|
+ examTaskDetail.setExposedPaperType(detail.getExposedPaperType());
|
|
|
+ examTaskDetail.setUnexposedPaperType(examTaskDetail.getPaperType());
|
|
|
+ } else {
|
|
|
+ // 已曝光试卷和未曝光试卷赋值(新增时,已曝光试卷为null,未曝光试卷为paper_type)
|
|
|
+ examTaskDetail.setUnexposedPaperType(examTaskDetail.getPaperType());
|
|
|
+ }
|
|
|
+ examTaskDetail.setExamTaskId(examTask.getId());
|
|
|
+ examTaskDetail.setUpdateId(sysUser.getId());
|
|
|
+ examTaskDetail.setUpdateTime(System.currentTimeMillis());
|
|
|
+
|
|
|
+ examTaskDetailService.saveOrUpdate(examTaskDetail);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("请求出错", e);
|
|
|
+ if (e instanceof ActivitiObjectNotFoundException) {
|
|
|
+ ResultUtil.error("流程不存在");
|
|
|
+ } else {
|
|
|
+ ResultUtil.error(e.getMessage());
|
|
|
+ }
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return examTask;
|
|
|
+ }
|
|
|
}
|