|
@@ -8,8 +8,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
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.ApprovalForm.*;
|
|
|
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 +22,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 +32,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,9 +142,18 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
|
@Resource
|
|
|
BasicCardRuleService basicCardRuleService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ ExamPrintPlanService examPrintPlanService;
|
|
|
+
|
|
|
@Resource
|
|
|
RedisUtil redisUtil;
|
|
|
|
|
|
+ @Resource
|
|
|
+ SysOrgService sysOrgService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ BasicClazzService basicClazzService;
|
|
|
+
|
|
|
@Override
|
|
|
public List<ExamTask> listByCourseCode(Long schoolId, String code) {
|
|
|
QueryWrapper<ExamTask> queryWrapper = new QueryWrapper<>();
|
|
@@ -1500,6 +1511,278 @@ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ExamTaskApprovalFormDto findExamTaskApprovalForm(Long examTaskId) {
|
|
|
+// Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
+ // 1.basicInfo 部分
|
|
|
+ ExamTask examTask = this.getById(examTaskId);
|
|
|
+ if (Objects.isNull(examTask)){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("命题任务不存在");
|
|
|
+ }
|
|
|
+ String paperNumber = examTask.getPaperNumber();
|
|
|
+ String paperName = examTask.getPaperName();
|
|
|
+ Long teachingRoomId = examTask.getTeachingRoomId();
|
|
|
+ SysOrg teachingRoom = sysOrgService.getOne(new QueryWrapper<SysOrg>().lambda().eq(SysOrg::getId,teachingRoomId).eq(SysOrg::getType,OrgTypeEnum.TEACHING_ROOM));
|
|
|
+ if (Objects.isNull(teachingRoom)){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("找不到教研室");
|
|
|
+ }
|
|
|
+ String teachingRoomName = teachingRoom.getName();
|
|
|
+ Long examStartTime = null;
|
|
|
+ Long examEndTime = null;
|
|
|
+ // 流程id
|
|
|
+ Long flowId = examTask.getFlowId();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // 2.ExamRoomInfo 部分
|
|
|
+ List<ExamRoomInfo> examRoomInfoList = new ArrayList<>();
|
|
|
+ List<ExamPackageDetail> examPackageDetailDatasource = this.baseMapper.findExamPackageDetailByPaperNumber(paperNumber);
|
|
|
+ if (examPackageDetailDatasource.size() > 0){
|
|
|
+ Set<Long> examDetailIdSet = examPackageDetailDatasource.stream().map(ExamPackageDetail::getExamDetailId).collect(Collectors.toSet());
|
|
|
+ for (Long examDetailId : examDetailIdSet) {
|
|
|
+ // 一个考场下
|
|
|
+ // 班级
|
|
|
+ String classNames = "";
|
|
|
+ int studentCount = 0;
|
|
|
+ String printCount = "";
|
|
|
+
|
|
|
+ List<ExamPackageDetail> examPackageDetailCell = examPackageDetailDatasource.stream()
|
|
|
+ .filter(e -> examDetailId.equals(e.getExamDetailId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<BackupMethodEnum> backupMethodEnums = examPackageDetailCell.stream().map(ExamPackageDetail::getBackupMethod).distinct().collect(Collectors.toList());
|
|
|
+ if (backupMethodEnums.size() != 1 && backupMethodEnums.get(0) != BackupMethodEnum.ROOM){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("印刷计划试卷备份方式必须按考场");
|
|
|
+ }
|
|
|
+ List<Integer> backupCountList = examPackageDetailCell.stream().map(ExamPackageDetail::getBackupCount).distinct().collect(Collectors.toList());
|
|
|
+ if (backupCountList.size() != 1){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("印刷计划试卷备份数量异常");
|
|
|
+ }
|
|
|
+ // 试卷该考场备份数量
|
|
|
+ Integer backupCount = backupCountList.get(0);
|
|
|
+ // 班级主键','隔开
|
|
|
+ String clazzIds = "";
|
|
|
+ final String separator = ",";
|
|
|
+ for (ExamPackageDetail examPackageDetail : examPackageDetailCell) {
|
|
|
+ // 处理考试开始结束时间
|
|
|
+ Long cellStartTime = examPackageDetail.getExamStartTime();
|
|
|
+ Long cellEndTime = examPackageDetail.getExamEndTime();
|
|
|
+ if (examStartTime == null || cellStartTime < examStartTime){
|
|
|
+ examStartTime = cellStartTime;
|
|
|
+ }
|
|
|
+ if (examEndTime == null || cellEndTime > examEndTime){
|
|
|
+ examEndTime = cellEndTime;
|
|
|
+ }
|
|
|
+ // 处理班级和数量
|
|
|
+ Integer studentCellCount = examPackageDetail.getExamDetailCourseTotalSubjects();
|
|
|
+ String clazzIdCell = examPackageDetail.getClazzIds();
|
|
|
+ studentCount = studentCount + studentCellCount;
|
|
|
+ clazzIds = clazzIds + clazzIdCell + separator;
|
|
|
+ }
|
|
|
+ clazzIds = clazzIds.substring(0,clazzIds.length() - separator.length());
|
|
|
+ classNames = basicClazzService.findClazzNamesByClazzIds(clazzIds,separator);
|
|
|
+ printCount = studentCount + " + " + backupCount;
|
|
|
+
|
|
|
+ // 组装examRoom
|
|
|
+ ExamRoomInfo examRoomInfo = new ExamRoomInfo();
|
|
|
+ examRoomInfo.setClazzNames(classNames);
|
|
|
+ examRoomInfo.setStudentCount(studentCount);
|
|
|
+ examRoomInfo.setPrintCount(printCount);
|
|
|
+ examRoomInfoList.add(examRoomInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3.ApprovalInfo部分
|
|
|
+ List<ApprovalInfo> approvalInfoList = new ArrayList<>();
|
|
|
+ ApprovalInfo second = examTaskReviewLogService.findOnePassBySetUp(flowId,2);
|
|
|
+ if (Objects.isNull(second)){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("未找到主任级审核记录");
|
|
|
+ }
|
|
|
+ ApprovalInfo third = examTaskReviewLogService.findOnePassBySetUp(flowId,3);
|
|
|
+ if (Objects.isNull(third)){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("未找到院长级审核记录");
|
|
|
+ }
|
|
|
+ second.setRemark("通过," + second.getRemark());
|
|
|
+ third.setRemark("通过," + third.getRemark());
|
|
|
+ approvalInfoList.add(second);
|
|
|
+ approvalInfoList.add(third);
|
|
|
+
|
|
|
+
|
|
|
+ // ---- 组装Dto
|
|
|
+ ExamTaskApprovalFormDto examTaskApprovalFormDto = new ExamTaskApprovalFormDto();
|
|
|
+ BasicInfo basicInfo = new BasicInfo();
|
|
|
+ basicInfo.setTeachingRoomId(teachingRoomId);
|
|
|
+ basicInfo.setTeachingRoomName(teachingRoomName);
|
|
|
+ basicInfo.setPaperName(paperName);
|
|
|
+ basicInfo.setPaperNumber(paperNumber);
|
|
|
+ basicInfo.setTeacherName(examTask.getTeacherName());
|
|
|
+ basicInfo.setExamStartTime(examStartTime);
|
|
|
+ basicInfo.setExamEndTime(examEndTime);
|
|
|
+
|
|
|
+
|
|
|
+ examTaskApprovalFormDto.setBasicInfo(basicInfo);
|
|
|
+ examTaskApprovalFormDto.setExamRoomInfoList(examRoomInfoList);
|
|
|
+ examTaskApprovalFormDto.setApprovalInfoList(approvalInfoList);
|
|
|
+
|
|
|
+ return examTaskApprovalFormDto;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 简单校验提交参数
|
|
|
*
|