Browse Source

3.2.7 优化

xiaofei 1 năm trước cách đây
mục cha
commit
ad31815bcc

+ 50 - 45
distributed-print-business/src/main/java/com/qmth/distributed/print/business/activiti/custom/listener/ProcessEventListener.java

@@ -9,24 +9,29 @@ import com.qmth.distributed.print.business.entity.TFFlowLog;
 import com.qmth.distributed.print.business.enums.CustomFlowMultipleUserApproveTypeEnum;
 import com.qmth.distributed.print.business.service.ActivitiService;
 import com.qmth.distributed.print.business.service.BasicMessageService;
+import com.qmth.distributed.print.business.service.PrintCommonService;
 import com.qmth.teachcloud.common.bean.params.ApproveUserResult;
 import com.qmth.teachcloud.common.contant.SpringContextHolder;
 import com.qmth.teachcloud.common.contant.SystemConstant;
+import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import com.qmth.teachcloud.common.enums.FlowApproveOperationEnum;
 import com.qmth.teachcloud.common.enums.MessageEnum;
 import com.qmth.teachcloud.common.enums.TFCustomTypeEnum;
 import com.qmth.teachcloud.common.service.SysUserService;
 import com.qmth.teachcloud.common.util.RedisUtil;
+import org.activiti.engine.HistoryService;
 import org.activiti.engine.TaskService;
 import org.activiti.engine.delegate.event.ActivitiEvent;
 import org.activiti.engine.delegate.event.ActivitiEventListener;
 import org.activiti.engine.delegate.event.ActivitiProcessStartedEvent;
+import org.activiti.engine.history.HistoricVariableInstance;
 import org.activiti.engine.task.Task;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Component;
 
+import java.io.IOException;
 import java.io.Serializable;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -68,54 +73,54 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
             case PROCESS_COMPLETED:
                 // 流程结束
                 log.info("流程结束_PROCESS_COMPLETED:ProcessInstanceId:{},ExecutionId:{},ProcessDefinitionId:{}", event.getProcessInstanceId(), event.getExecutionId(), event.getProcessDefinitionId());
-//                HistoryService historyService = SpringContextHolder.getBean(HistoryService.class);
-//                SysUserService sysUserService = SpringContextHolder.getBean(SysUserService.class);
-//                ActivitiService activitiService = SpringContextHolder.getBean(ActivitiService.class);
-//                PrintCommonService printCommonService = SpringContextHolder.getBean(PrintCommonService.class);
-//
-//                List<HistoricVariableInstance> historicVariableInstanceList = historyService.createHistoricVariableInstanceQuery().processInstanceId(event.getProcessInstanceId()).list();
-//                if (Objects.nonNull(historicVariableInstanceList) && historicVariableInstanceList.size() > 0) {
-//                    tfFlowLog = null;
-//                    tfFlowApprove = null;
-//                    Object object = null;
-//                    for (HistoricVariableInstance h : historicVariableInstanceList) {
-//                        if (Objects.equals(h.getVariableName(), SystemConstant.APPROVE_TF_FLOW_APPROVE)) {
-//                            tfFlowApprove = (TFFlowApprove) h.getValue();
-//                            Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程流转记录为空"));
-//                            log.info("tfFlowApprove.getStatus():{}", tfFlowApprove.getStatus());
-//                        }
-//                        if (Objects.equals(h.getVariableName(), SystemConstant.APPROVE_TF_FLOW_LOG)) {
-//                            tfFlowLog = (TFFlowLog) h.getValue();
-//                            Optional.ofNullable(tfFlowLog).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程审批日志为空"));
-//                            log.info("tfFlowLog.getApproveOperation():{}", tfFlowLog.getApproveOperation());
-//                        } else if (Objects.equals(h.getVariableName(), SystemConstant.OBJECT_DATA)) {
-//                            object = h.getValue();
-//                            Optional.ofNullable(object).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("实体数据为空"));
-//                        }
-//                        if (Objects.nonNull(object) && Objects.nonNull(tfFlowLog)) {
-//                            break;
-//                        }
-//                    }
-//                    if (Objects.nonNull(tfFlowLog.getObjectTable())) {
-//                        if (Objects.equals(tfFlowLog.getObjectTable(), TFCustomTypeEnum.ELECTRON_FLOW.getTable())) {//如果是命题任务交卷
-//                            //取命题老师ID
-//                            SysUser sysUser = sysUserService.getById(((ExamTask) object).getUserId());
-//                            try {
-//                                printCommonService.checkData(((ExamTask) object).getSchoolId(), ((ExamTask) object).getExamId(), ((ExamTask) object).getCourseCode(), ((ExamTask) object).getPaperNumber(), sysUser);
-//                            } catch (IOException e) {
-//                                throw ExceptionResultEnum.ERROR.exception("生成pdf失败");
-//                            }
-//                        }
-//                    }
-//                }
+                HistoryService historyService = SpringContextHolder.getBean(HistoryService.class);
+                SysUserService sysUserService = SpringContextHolder.getBean(SysUserService.class);
+                ActivitiService activitiService = SpringContextHolder.getBean(ActivitiService.class);
+                PrintCommonService printCommonService = SpringContextHolder.getBean(PrintCommonService.class);
+
+                List<HistoricVariableInstance> historicVariableInstanceList = historyService.createHistoricVariableInstanceQuery().processInstanceId(event.getProcessInstanceId()).list();
+                if (Objects.nonNull(historicVariableInstanceList) && historicVariableInstanceList.size() > 0) {
+                    tfFlowLog = null;
+                    tfFlowApprove = null;
+                    Object object = null;
+                    for (HistoricVariableInstance h : historicVariableInstanceList) {
+                        if (Objects.equals(h.getVariableName(), SystemConstant.APPROVE_TF_FLOW_APPROVE)) {
+                            tfFlowApprove = (TFFlowApprove) h.getValue();
+                            Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程流转记录为空"));
+                            log.info("tfFlowApprove.getStatus():{}", tfFlowApprove.getStatus());
+                        }
+                        if (Objects.equals(h.getVariableName(), SystemConstant.APPROVE_TF_FLOW_LOG)) {
+                            tfFlowLog = (TFFlowLog) h.getValue();
+                            Optional.ofNullable(tfFlowLog).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程审批日志为空"));
+                            log.info("tfFlowLog.getApproveOperation():{}", tfFlowLog.getApproveOperation());
+                        } else if (Objects.equals(h.getVariableName(), SystemConstant.OBJECT_DATA)) {
+                            object = h.getValue();
+                            Optional.ofNullable(object).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("实体数据为空"));
+                        }
+                        if (Objects.nonNull(object) && Objects.nonNull(tfFlowLog)) {
+                            break;
+                        }
+                    }
+                    if (Objects.nonNull(tfFlowLog.getObjectTable())) {
+                        if (Objects.equals(tfFlowLog.getObjectTable(), TFCustomTypeEnum.ELECTRON_FLOW.getTable())) {//如果是命题任务交卷
+                            //取命题老师ID
+                            SysUser sysUser = sysUserService.getById(((ExamTask) object).getUserId());
+                            try {
+                                printCommonService.checkData(((ExamTask) object).getSchoolId(), ((ExamTask) object).getExamId(), ((ExamTask) object).getCourseCode(), ((ExamTask) object).getPaperNumber(), sysUser);
+                            } catch (IOException e) {
+                                throw ExceptionResultEnum.ERROR.exception("生成pdf失败");
+                            }
+                        }
+                    }
+                }
                 break;
             case TASK_COMPLETED:
                 // 任务被完成了。它会在ENTITY_DELETE事件之前触发。当任务是流程一部分时,事件会在流程继续运行之前, 后续事件将是ACTIVITY_COMPLETE,对应着完成任务的节点。
                 log.info("流程任务完成_TASK_COMPLETED:ProcessInstanceId:{},ExecutionId:{},ProcessDefinitionId:{}", event.getProcessInstanceId(), event.getExecutionId(), event.getProcessDefinitionId());
                 TaskService taskService = SpringContextHolder.getBean(TaskService.class);
-                SysUserService sysUserService = SpringContextHolder.getBean(SysUserService.class);
+                SysUserService sysUserService1 = SpringContextHolder.getBean(SysUserService.class);
                 basicMessageService = SpringContextHolder.getBean(BasicMessageService.class);
-                ActivitiService activitiService = SpringContextHolder.getBean(ActivitiService.class);
+                ActivitiService activitiService1 = SpringContextHolder.getBean(ActivitiService.class);
                 RedisUtil redisUtil = SpringContextHolder.getBean(RedisUtil.class);
 
                 Task task = taskService.createTaskQuery().executionId(event.getExecutionId()).singleResult();
@@ -145,7 +150,7 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
                                 userIds.add(SystemConstant.convertIdToLong(s.trim()));
                             }
                             Gson gson = new Gson();
-                            List<ApproveUserResult> nextApproverPeopleList = sysUserService.findByIdsForResult(userIds);
+                            List<ApproveUserResult> nextApproverPeopleList = sysUserService1.findByIdsForResult(userIds);
                             if (Objects.nonNull(nextApproverPeopleList) && nextApproverPeopleList.size() > 0 && Objects.nonNull(tfFlowLog.getApproveUserApproveType()) && tfFlowLog.getApproveUserApproveType() == CustomFlowMultipleUserApproveTypeEnum.ORDER) {
                                 nextApproverPeopleList.removeAll(nextApproverPeopleList.subList(1, nextApproverPeopleList.size() - 0));
                             }
@@ -157,11 +162,11 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
                                 int currSetup = currFlowTaskResult.getSetup().intValue();
                                 currSetup = currSetup == setupMap.size() - 1 ? 0 : currSetup + 1;
 
-                                nextFlowTaskResult = activitiService.getNextFlowTaskResult(setupMap, gson, currSetup, nextFlowTaskResult);
+                                nextFlowTaskResult = activitiService1.getNextFlowTaskResult(setupMap, gson, currSetup, nextFlowTaskResult);
                                 CustomFlowVarDto customFlowVarDto = gson.fromJson(gson.toJson(agginessMap.get(nextFlowTaskResult.getTaskKey())), CustomFlowVarDto.class);
                                 if (Objects.nonNull(customFlowVarDto) && Objects.nonNull(customFlowVarDto.getCopyForUserIds()) && customFlowVarDto.getCopyForUserIds().size() > 0) {
                                     Set<String> copyUserSet = new LinkedHashSet(customFlowVarDto.getCopyForUserIds());
-                                    copyUsersList = sysUserService.findByIdsForResult(copyUserSet.stream().map(s -> SystemConstant.convertIdToLong(s)).collect(Collectors.toList()));
+                                    copyUsersList = sysUserService1.findByIdsForResult(copyUserSet.stream().map(s -> SystemConstant.convertIdToLong(s)).collect(Collectors.toList()));
                                 }
 
                                 //如果不是并行会签,则每个节点都发

+ 2 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamDetailService.java

@@ -240,4 +240,6 @@ public interface ExamDetailService extends IService<ExamDetail> {
     TBTask importData(String printPlanId, MultipartFile file);
 
     void startInitTask(Long schoolId) throws Exception;
+
+    void deleteExaminationDataByExamDetailIds(List<Long> examDetailIdList);
 }

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ActivitiServiceImpl.java

@@ -2051,7 +2051,7 @@ public class ActivitiServiceImpl implements ActivitiService {
                 if (Objects.nonNull(sysConfigOpenFlowMsgPush)) {
                     flowMsgDto.setOpenFlowMsgPush(Boolean.valueOf(sysConfigOpenFlowMsgPush.getConfigValue()));
                 }
-                if (Objects.nonNull(sysConfigFlowMsgType)) {
+                if (Objects.nonNull(sysConfigFlowMsgType) && StringUtils.isNotBlank(sysConfigFlowMsgType.getConfigValue())) {
                     flowMsgDto.setFlowMsgType(FlowMsgTypeEnum.valueOf(sysConfigFlowMsgType.getConfigValue()));
                 }
                 if (Objects.nonNull(sysConfigMqHostUrl)) {

+ 5 - 5
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamCardServiceImpl.java

@@ -96,14 +96,14 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
         Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
         SysUser user = (SysUser) ServletUtil.getRequestUser();
 
-        validateCardData(examCardParams);
-
         // 新增
         ExamCard examCard;
         if (examCardParams.getTitle().getBytes().length > 80) {
             throw ExceptionResultEnum.ERROR.exception("标题最长只能输入80个字符");
         }
         if (examCardParams.getId() == null) {
+            validateCardData(examCardParams);
+
             QueryWrapper<ExamCard> queryWrapper = new QueryWrapper<>();
             queryWrapper.lambda().eq(ExamCard::getSchoolId, schoolId)
                     .eq(ExamCard::getCourseCode, examCardParams.getCourseCode())
@@ -561,9 +561,9 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
             throw ExceptionResultEnum.ERROR.exception("通用规则未设置");
         }
 
-        if (Objects.isNull(examCardParams.getMakeMethod())) {
-            throw ExceptionResultEnum.ERROR.exception("题卡制作方式不能为空");
-        }
+//        if (Objects.isNull(examCardParams.getMakeMethod())) {
+//            throw ExceptionResultEnum.ERROR.exception("题卡制作方式不能为空");
+//        }
         if (examCardParams.getStatus() == null) {
             throw ExceptionResultEnum.ERROR.exception("提交方式不能为空");
         }

+ 28 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamDetailServiceImpl.java

@@ -1105,6 +1105,34 @@ public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailMapper, ExamDet
 
     }
 
+    @Transactional
+    @Override
+    public void deleteExaminationDataByExamDetailIds(List<Long> examDetailIdList) {
+        if (CollectionUtils.isEmpty(examDetailIdList)) {
+            return;
+        }
+        // 删除exam_detail 表数据
+        this.remove(new QueryWrapper<ExamDetail>().lambda().in(ExamDetail::getId, examDetailIdList));
+
+        // 准备删除的考务-科目表id
+        List<Long> examDetailCourseIds = examDetailCourseService.list(new QueryWrapper<ExamDetailCourse>().lambda().in(ExamDetailCourse::getExamDetailId, examDetailIdList))
+                .stream().map(ExamDetailCourse::getId).collect(Collectors.toList());
+        if (CollectionUtils.isEmpty(examDetailCourseIds)) {
+            return;
+        }
+        // 删除exam_detail_course 表数据
+        examDetailCourseService.remove(new QueryWrapper<ExamDetailCourse>().lambda().in(ExamDetailCourse::getId, examDetailCourseIds));
+
+        // 准备删除的考务-考生表id
+        List<Long> examStudentIds = examStudentService.list(new QueryWrapper<ExamStudent>().lambda().in(ExamStudent::getExamDetailCourseId, examDetailCourseIds))
+                .stream().map(ExamStudent::getId).collect(Collectors.toList());
+        if (CollectionUtils.isEmpty(examStudentIds)) {
+            return;
+        }
+        // 删除exam_student 表数据
+        examStudentService.remove(new QueryWrapper<ExamStudent>().lambda().in(ExamStudent::getId, examStudentIds));
+    }
+
     @Transactional(rollbackFor = Exception.class)
     @Override
     public void deleteExaminationData(Long printPlanId, ExamDataSourceEnum source) {

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskServiceImpl.java

@@ -2028,7 +2028,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
             BasicExam basicExam = basicExamService.getById(examTask.getExamId());
             String examName = basicExam == null ? "-" : basicExam.getName();
             String courseName = examTask.getCourseName() + "(" + examTask.getCourseCode() + ")";
-            basicOperationLog.setDetail(String.format("考试[%s],课程[%s],试卷编号[%s],题卡或试卷[%s],卷型[%s]", examName, courseName, examTask.getPaperNumber(), type, paperType));
+            basicOperationLog.setDetail(String.format("考试[%s],课程[%s],试卷编号[%s],题卡或试卷[%s],卷型[%s]", examName, courseName, examTask.getPaperNumber(), type.equals("paper") ? "试卷" : "题卡", paperType));
             basicOperationLog.setLevel(LevelEnum.SECONDARY);
             basicOperationLog.setCustomizedOperationType(CustomizedOperationTypeEnum.PREVIEW);
             basicOperationLog.setOperationType(OperationTypeEnum.UN_KNOW);

+ 10 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/AsyncExaminationImportTemplateService.java

@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.qmth.boot.api.exception.ApiException;
 import com.qmth.distributed.print.business.bean.dto.ExaminationImportDto;
 import com.qmth.distributed.print.business.bean.dto.FieldsDto;
+import com.qmth.distributed.print.business.service.ExamDetailService;
 import com.qmth.distributed.print.business.service.ExamTaskService;
 import com.qmth.distributed.print.business.templete.importData.AsyncImportTaskTemplete;
 import com.qmth.distributed.print.business.templete.service.TaskLogicService;
@@ -53,6 +54,9 @@ public class AsyncExaminationImportTemplateService extends AsyncImportTaskTemple
     @Resource
     private ExamTaskService examTaskService;
 
+    @Resource
+    private ExamDetailService examDetailService;
+
     private final static Logger log = LoggerFactory.getLogger(AsyncExaminationImportTemplateService.class);
 
     public static final String OBJ_TITLE = "考务数据";
@@ -68,6 +72,7 @@ public class AsyncExaminationImportTemplateService extends AsyncImportTaskTemple
         tbTask.setStatus(TaskStatusEnum.RUNNING);
         TBTaskService tbTaskService = SpringContextHolder.getBean(TBTaskService.class);
         tbTaskService.updateById(tbTask);
+        List<Long> examDetailIdList = null;
         try {
             TaskLogicService taskLogicService = SpringContextHolder.getBean(TaskLogicService.class);
 
@@ -89,7 +94,7 @@ public class AsyncExaminationImportTemplateService extends AsyncImportTaskTemple
             if (Objects.isNull(map.get("examDetailIdList"))) {
                 throw ExceptionResultEnum.ERROR.exception("导入考务数据失败,数据未正确保存");
             }
-            List<Long> examDetailIdList = (List<Long>) map.get("examDetailIdList");
+            examDetailIdList = (List<Long>) map.get("examDetailIdList");
             // 按照考场检验命题任务是否全部完成,完成生成pdf
             SysUser user = (SysUser) map.get(SystemConstant.USER);
             for (Long examDetailId : examDetailIdList) {
@@ -107,6 +112,9 @@ public class AsyncExaminationImportTemplateService extends AsyncImportTaskTemple
             } else {
                 ResultUtil.error(e.getMessage());
             }
+
+            // 有异常,删除考务数据
+            examDetailService.deleteExaminationDataByExamDetailIds(examDetailIdList);
         } finally {//生成txt文件
             tbTask.setSummary(stringJoinerSummary.toString());
             super.createTxt(tbTask);
@@ -207,7 +215,7 @@ public class AsyncExaminationImportTemplateService extends AsyncImportTaskTemple
             }
             // 补充错误信息
             String errorMessage = examinationImportDto.getErrorMessage();
-            if (SystemConstant.strNotNull(errorMessage)){
+            if (SystemConstant.strNotNull(errorMessage)) {
                 XSSFCell cell = row.createCell(cellCount - 1);
                 cell.setCellValue(errorMessage);
                 cell.setCellStyle(exampleStyle);

+ 1 - 1
distributed-print-business/src/main/resources/mapper/ExamPaperStructureMapper.xml

@@ -30,7 +30,7 @@
             ets.third_relate_id thirdRelateId,
             ets.sync_start_time syncStartTime,
             tsse.exam_name thirdRelateName,
-            IFNULL(eps.status, 'INIT') status
+            IFNULL(eps.status, '{}') status
         FROM
             exam_detail ed
                 left join exam_detail_course edc on

+ 1 - 1
distributed-print/src/main/java/com/qmth/distributed/print/api/ExamPaperStructureController.java

@@ -99,7 +99,7 @@ public class ExamPaperStructureController {
         ExamPaperStructure examPaperStructure = examPaperStructureService.submitExamPaperParams(evaluationParameters, sysUser);
         // 异步同步到云阅卷
         asyncCloudMarkingTaskService.syncPaperStructureAndGroup(examPaperStructure);
-        return ResultUtil.ok();
+        return ResultUtil.ok(String.valueOf(examPaperStructure.getId()), null);
     }
 
     /**

+ 22 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/result/TaskListResult.java

@@ -27,10 +27,16 @@ public class TaskListResult implements Serializable {
     @ApiModelProperty(value = "学期ID")
     Long semesterId;
 
+    @ApiModelProperty(value = "学期名称")
+    String semesterName;
+
     @JsonSerialize(using = ToStringSerializer.class)
     @ApiModelProperty(value = "考试ID")
     Long examId;
 
+    @ApiModelProperty(value = "考试名称")
+    String examName;
+
     @ApiModelProperty(value = "课程代码")
     String courseCode;
 
@@ -99,10 +105,26 @@ public class TaskListResult implements Serializable {
         this.semesterId = semesterId;
     }
 
+    public String getSemesterName() {
+        return semesterName;
+    }
+
+    public void setSemesterName(String semesterName) {
+        this.semesterName = semesterName;
+    }
+
     public Long getExamId() {
         return examId;
     }
 
+    public String getExamName() {
+        return examName;
+    }
+
+    public void setExamName(String examName) {
+        this.examName = examName;
+    }
+
     public void setExamId(Long examId) {
         this.examId = examId;
     }

+ 4 - 0
teachcloud-common/src/main/resources/mapper/TBTaskMapper.xml

@@ -6,7 +6,9 @@
         select
         tbt.id,
         tbt.semester_id semesterId,
+        bs.name semesterName,
         tbt.exam_id examId,
+        be.name examName,
         tbt.course_code courseCode,
         tbt.course_name courseName,
         tbt.paper_number paperNumber,
@@ -29,6 +31,8 @@
         left join exam_print_plan epp on
         epp.id = tbt.print_plan_id
         left join sys_user su on su.id = tbt.create_id
+        left join basic_semester bs on tbt.semester_id = bs.id
+        left join basic_exam be on tbt.exam_id = be.id
         <where>
             <if test="schoolId != null and schoolId != ''">
                 and tbt.school_id = #{schoolId}