|
@@ -9,7 +9,10 @@ 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.ExamDetailList;
|
|
|
+import com.qmth.distributed.print.business.bean.params.ExamDetailParams;
|
|
|
import com.qmth.distributed.print.business.bean.params.ExamTaskApplyParam;
|
|
|
+import com.qmth.distributed.print.business.bean.params.SerialNumberParams;
|
|
|
import com.qmth.distributed.print.business.bean.result.WorkResult;
|
|
|
import com.qmth.distributed.print.business.entity.*;
|
|
|
import com.qmth.distributed.print.business.enums.*;
|
|
@@ -18,7 +21,6 @@ import com.qmth.distributed.print.business.service.*;
|
|
|
import com.qmth.distributed.print.business.templete.execute.AsyncCreatePdfTempleteService;
|
|
|
import com.qmth.distributed.print.business.templete.execute.AsyncPaperReviewPdfExportService;
|
|
|
import com.qmth.teachcloud.common.bean.dto.BlurryUserDto;
|
|
|
-import com.qmth.teachcloud.common.bean.dto.CourseInfoDto;
|
|
|
import com.qmth.teachcloud.common.bean.dto.MqDto;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
import com.qmth.teachcloud.common.entity.*;
|
|
@@ -29,7 +31,6 @@ import com.qmth.teachcloud.common.util.RedisUtil;
|
|
|
import com.qmth.teachcloud.common.util.ResultUtil;
|
|
|
import com.qmth.teachcloud.common.util.ServletUtil;
|
|
|
import com.qmth.teachcloud.common.util.excel.ExcelError;
|
|
|
-import javafx.beans.binding.ObjectExpression;
|
|
|
import org.activiti.engine.ActivitiObjectNotFoundException;
|
|
|
import org.activiti.engine.TaskService;
|
|
|
import org.activiti.engine.runtime.ProcessInstance;
|
|
@@ -140,6 +141,9 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
|
@Resource
|
|
|
BasicCardRuleService basicCardRuleService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ ExamPrintPlanService examPrintPlanService;
|
|
|
+
|
|
|
@Resource
|
|
|
RedisUtil redisUtil;
|
|
|
|
|
@@ -1500,6 +1504,162 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
|
return examTaskMapper.findFlowIdToNotMySelf(currentUserId);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public ExamTask submitTaskApply(ExamTaskApplyTemp examTaskApplyTemp) {
|
|
|
+ Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
+ SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
+
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(examTaskApplyTemp.getExamTaskContent());
|
|
|
+
|
|
|
+ // 新建命题任务
|
|
|
+ ExamTask examTask = JSONObject.parseObject(String.valueOf(jsonObject.get("examTask")), ExamTask.class);
|
|
|
+ try {
|
|
|
+ BasicExamRule basicExamRule = basicExamRuleService.getBySchoolId();
|
|
|
+ if (basicExamRule == null) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("通用规则未设置");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(examTask.getPaperNumber())) {
|
|
|
+ QueryWrapper<ExamTask> taskQueryWrapper = new QueryWrapper<>();
|
|
|
+ taskQueryWrapper.lambda().eq(ExamTask::getSchoolId, schoolId).eq(ExamTask::getPaperNumber, examTask.getPaperNumber());
|
|
|
+ if (Objects.nonNull(examTask.getId())) {
|
|
|
+ taskQueryWrapper.lambda().ne(ExamTask::getId, examTask.getId());
|
|
|
+ }
|
|
|
+ ExamTask task = this.getOne(taskQueryWrapper);
|
|
|
+ if (task != null) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("试卷编号已存在");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 试卷编号生成规则:年月日(例如:20100419)+0000(例如:0001)顺序编号
|
|
|
+ String paperNumber = printCommonService.createPaperNumber(schoolId);
|
|
|
+ examTask.setPaperNumber(paperNumber);
|
|
|
+ }
|
|
|
+
|
|
|
+ examTask.setId(SystemConstant.getDbUuid());
|
|
|
+ examTask.setSchoolId(schoolId);
|
|
|
+ examTask.setOrgId(basicCourseService.getOrgIdBySchoolIdAndCourseCode(schoolId, examTask.getCourseCode()));
|
|
|
+ examTask.setReview(basicExamRule.getReview());
|
|
|
+ examTask.setUserId(sysUser.getId());
|
|
|
+ examTask.setStatus(ExamStatusEnum.SUBMIT);
|
|
|
+ examTask.setCreateId(sysUser.getId());
|
|
|
+ examTask.setCreateTime(System.currentTimeMillis());
|
|
|
+
|
|
|
+ if (Objects.isNull(examTask.getFlowId())) {
|
|
|
+ //TODO 这里以后要判断学校code来取流程key
|
|
|
+ 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.save(examTask);
|
|
|
+
|
|
|
+ // 新建试卷
|
|
|
+ ExamTaskDetail examTaskDetail = JSONObject.parseObject(String.valueOf(jsonObject.get("examTaskDetail")), ExamTaskDetail.class);
|
|
|
+ validSubmitParam(examTaskDetail);
|
|
|
+ // 已曝光试卷和未曝光试卷赋值(新增时,已曝光试卷为null,未曝光试卷为paper_type)
|
|
|
+ examTaskDetail.setId(SystemConstant.getDbUuid());
|
|
|
+ examTaskDetail.setUnexposedPaperType(examTaskDetail.getPaperType());
|
|
|
+ examTaskDetail.setExamTaskId(examTask.getId());
|
|
|
+ examTaskDetail.setCreateId(sysUser.getId());
|
|
|
+ examTaskDetail.setCreateTime(System.currentTimeMillis());
|
|
|
+
|
|
|
+ examTaskDetailService.save(examTaskDetail);
|
|
|
+
|
|
|
+ ExamPrintPlan examPrintPlan = JSONObject.parseObject(String.valueOf(jsonObject.get("examPrintPlan")), ExamPrintPlan.class);
|
|
|
+
|
|
|
+ ExamDetailParams examDetailParams = JSONObject.parseObject(String.valueOf(jsonObject.get("examDetail")), ExamDetailParams.class);
|
|
|
+ List<String> printContentList = JSONObject.parseArray(examPrintPlan.getPrintContent(), String.class);
|
|
|
+ examPrintPlan.setId(SystemConstant.getDbUuid());
|
|
|
+ examPrintPlan.setSchoolId(schoolId);
|
|
|
+ examPrintPlan.setOrgId(sysUser.getOrgId());
|
|
|
+ examPrintPlan.setPrintContent(String.join(",", printContentList));
|
|
|
+ examPrintPlan.setExamStartTime(Long.valueOf(examDetailParams.getExamStartTime()));
|
|
|
+ examPrintPlan.setExamEndTime(Long.valueOf(examDetailParams.getExamEndTime()));
|
|
|
+ // 课程+试卷编号
|
|
|
+ examPrintPlan.setName(examTask.getCourseName() + examTask.getPaperNumber());
|
|
|
+ examPrintPlan.setStatus(PrintPlanStatusEnum.READY);
|
|
|
+ examPrintPlan.setCreateId(sysUser.getId());
|
|
|
+ examPrintPlanService.save(examPrintPlan);
|
|
|
+
|
|
|
+ List<ExamDetailList> examDetailLists = JSONObject.parseArray(String.valueOf(examDetailParams.getList()), ExamDetailList.class);
|
|
|
+
|
|
|
+ int i = 1;
|
|
|
+ for (ExamDetailList examDetailList : examDetailLists) {
|
|
|
+ SerialNumberParams serialNumberParams = new SerialNumberParams("packageCode-" + schoolId, "1", 6);
|
|
|
+ ExamDetail examDetail = new ExamDetail();
|
|
|
+ examDetail.setId(SystemConstant.getDbUuid());
|
|
|
+ examDetail.setPackageCode(printCommonService.createTempNumber(serialNumberParams));
|
|
|
+ examDetail.setSchoolId(schoolId);
|
|
|
+ examDetail.setOrgId(sysUser.getOrgId());
|
|
|
+ examDetail.setPrintPlanId(examPrintPlan.getId());
|
|
|
+ examDetail.setPrintPlanName(examPrintPlan.getName());
|
|
|
+ examDetail.setExamPlace("考场" + i);
|
|
|
+ examDetail.setExamRoom("考点" + i);
|
|
|
+ examDetail.setStatus(ExamDetailStatusEnum.NEW);
|
|
|
+ examDetail.setExamStartTime(examDetailParams.getExamStartTime());
|
|
|
+ examDetail.setExamEndTime(examDetailParams.getExamEndTime());
|
|
|
+ examDetail.setTotalSubjects(examDetailList.getStudentCount());
|
|
|
+ examDetail.setExamDataSource(ExamDataSourceEnum.EXAM_TASK);
|
|
|
+ examDetail.setNormal(true);
|
|
|
+ examDetail.setPrintHouseId(Long.valueOf(examDetailList.getPrintHouseId()));
|
|
|
+ examDetail.setCreateId(sysUser.getId());
|
|
|
+ examDetail.setCreateTime(System.currentTimeMillis());
|
|
|
+ examDetailService.save(examDetail);
|
|
|
+
|
|
|
+ List<String> classIds = Arrays.asList(examDetailList.getClassId().split(","));
|
|
|
+ ExamDetailCourse examDetailCourse = new ExamDetailCourse();
|
|
|
+ examDetailCourse.setId(SystemConstant.getDbUuid());
|
|
|
+ examDetailCourse.setSchoolId(schoolId);
|
|
|
+ examDetailCourse.setOrgId(sysUser.getOrgId());
|
|
|
+ examDetailCourse.setExamDetailId(examDetail.getId());
|
|
|
+ examDetailCourse.setCourseCode(examTask.getCourseCode());
|
|
|
+ examDetailCourse.setCourseName(examTask.getCourseName());
|
|
|
+ examDetailCourse.setPaperNumber(examTask.getPaperNumber());
|
|
|
+ examDetailCourse.setClazzId(examDetailList.getClassId());
|
|
|
+ examDetailCourse.setTotalSubjects(examDetailList.getStudentCount());
|
|
|
+ examDetailCourse.setCreateId(sysUser.getId());
|
|
|
+ examDetailCourseService.save(examDetailCourse);
|
|
|
+
|
|
|
+ // 更新实际考生数量
|
|
|
+ int studentCount = printCommonService.saveBatchStudent(schoolId, examDetailList.getExtendFields(), classIds, examDetailCourse.getId(), sysUser);
|
|
|
+ if (studentCount - examDetail.getTotalSubjects().intValue() != 0) {
|
|
|
+ UpdateWrapper<ExamDetail> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.lambda().set(ExamDetail::getTotalSubjects, studentCount).eq(ExamDetail::getId, examDetail.getId());
|
|
|
+ examDetailService.update(updateWrapper);
|
|
|
+ }
|
|
|
+ if (studentCount - examDetailCourse.getTotalSubjects().intValue() != 0) {
|
|
|
+ UpdateWrapper<ExamDetailCourse> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.lambda().set(ExamDetailCourse::getTotalSubjects, studentCount).eq(ExamDetailCourse::getId, examDetailCourse.getId());
|
|
|
+ examDetailCourseService.update(updateWrapper);
|
|
|
+ }
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return examTask;
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("请求出错", e);
|
|
|
+ if (e instanceof ActivitiObjectNotFoundException) {
|
|
|
+ ResultUtil.error("流程不存在");
|
|
|
+ } else {
|
|
|
+ ResultUtil.error(e.getMessage());
|
|
|
+ }
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 简单校验提交参数
|
|
|
*
|