Browse Source

卷库查询加入重启流程

wangliang 1 year ago
parent
commit
7978e54d50

+ 9 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamTaskDetailService.java

@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.distributed.print.business.bean.dto.ExamTaskDetailDto;
 import com.qmth.distributed.print.business.bean.dto.ExamTaskDetailPdfDownloadDto;
 import com.qmth.distributed.print.business.bean.params.RelatePaperParam;
-import com.qmth.distributed.print.business.entity.ExamCard;
 import com.qmth.distributed.print.business.entity.ExamTaskDetail;
 
 import java.io.IOException;
@@ -26,6 +25,7 @@ public interface ExamTaskDetailService extends IService<ExamTaskDetail> {
     boolean updatePaper(RelatePaperParam paperParam) throws IOException;
 
     List<ExamTaskDetailDto> list(Long semesterId, Long examId, String relateType, List<Long> printPlanId, String courseCode, String paperNumber, String userName, Long cardRuleId);
+
     Map listTotal(Long semesterId, Long examId, String relateType, List<Long> printPlanId, String courseCode, String paperNumber, String userName, Long cardRuleId);
 
     void resetCardId(Long id);
@@ -34,6 +34,14 @@ public interface ExamTaskDetailService extends IService<ExamTaskDetail> {
 
     Map<String, Object> paperUpdate(ExamTaskDetail examTaskDetail);
 
+    /**
+     * 重启流程
+     *
+     * @param examTaskDetail
+     * @return
+     */
+    Map<String, Object> taskRestart(ExamTaskDetail examTaskDetail);
+
     ExamTaskDetail getByExamTaskId(Long examTaskId);
 
     /**

+ 69 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskDetailServiceImpl.java

@@ -446,7 +446,76 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
                     mapVar.putAll(approverMap);
                     mapVar.remove(SystemConstant.SEND_FLOW_START_MQ);
                     mapVar.put(SystemConstant.SEND_FLOW_MQ, true);
+                }
+            }
+        }
+        mapVar.put(SystemConstant.SUCCESS, true);
+        return mapVar;
+    }
+
+    /**
+     * 重启流程
+     * @param examTaskDetail
+     * @return
+     */
+    @Override
+    public Map<String, Object> taskRestart(ExamTaskDetail examTaskDetail) {
+        SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
+        SysOrg sysOrg = commonCacheService.orgCache(requestUser.getOrgId());
+
+        Map<String, Object> mapVar = new HashMap<>();
+        ExamTask examTask = examTaskService.getById(examTaskDetail.getExamTaskId());
+        List<ExamDetail> examDetails = examDetailService.listByCourseCodeAndPaperNumber(examTask.getSchoolId(), examTask.getExamId(), examTask.getCourseCode(), examTask.getPaperNumber());
+        if (!CollectionUtils.isEmpty(examDetails)) {
+            StringJoiner stringJoiner = new StringJoiner("_");
+            stringJoiner.add(String.valueOf(examDetails.get(0).getSchoolId()))
+                    .add(String.valueOf(examDetails.get(0).getExamStartTime()))
+                    .add(String.valueOf(examDetails.get(0).getExamEndTime()))
+                    .add(examTask.getCourseCode())
+                    .add(examTask.getPaperNumber());
+            String key = stringJoiner.toString();
+            CreatePdfCacheUtil.deletePaperType(key);
+
+            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 ((Objects.nonNull(examTask.getReview()) && examTask.getReview()) || !sysUserService.isAdminDataAuth(requestUser.getId())) {
+            // 发起新流程
+            Map<String, Object> map = SystemConstant.buildFlowVar(examTask.getId(),
+                    examTask,
+                    TFCustomTypeEnum.ELECTRON_FLOW,
+                    examTask.getUserId(),
+                    false);
+            map.computeIfAbsent(SystemConstant.OLD_FLOW_ID, v -> examTask.getFlowId());
+            map.computeIfAbsent(SystemConstant.FLOW_JOIN_TYPE, v -> FlowJoinTypeEnum.RESTART);
+            map = activitiService.customFlowStart(map);
+            Long flowId = SystemConstant.convertIdToLong((String) map.get(SystemConstant.FLOW_ID));
+            UpdateWrapper<ExamTask> updateWrapper = new UpdateWrapper<>();
+            updateWrapper.lambda().set(ExamTask::getFlowId, flowId).eq(ExamTask::getId, examTaskDetail.getExamTaskId());
+            examTaskService.update(updateWrapper);
+            mapVar.putAll(map);
+            mapVar.put(SystemConstant.SEND_FLOW_START_MQ, true);
+
+            tfFlowJoinService.saveOrUpdate(map);
+            if (Objects.nonNull(flowId)) {
+                // 审核一级
+                Task task = taskService.createTaskQuery().processInstanceId(String.valueOf(flowId)).singleResult();
+                if (Objects.nonNull(task)) {
+                    Map<String, Object> approverMap = new HashMap<>();
+                    approverMap.computeIfAbsent(SystemConstant.FLOW_TASK_ID, v -> task.getId());
+                    approverMap.computeIfAbsent(SystemConstant.PAPAER_ATTACHMENT_IDS, v -> examTaskDetail.getPaperAttachmentIds());
+                    approverMap.computeIfAbsent(SystemConstant.APPROVE_OPERATION, v -> FlowApprovePassEnum.PASS);
+                    String remark = Objects.nonNull(sysOrg) ? sysOrg.getName() : "无机构";
+                    approverMap.computeIfAbsent(SystemConstant.APPROVE_REMARK, v -> requestUser.getRealName() + "(" + remark + ")" + FlowApprovePassEnum.RESTART.getTitle());
+                    activitiService.taskApprove(approverMap);
+                    mapVar.putAll(approverMap);
+                    mapVar.remove(SystemConstant.SEND_FLOW_START_MQ);
+                    mapVar.put(SystemConstant.SEND_FLOW_MQ, true);
                 }
             }
         }

+ 8 - 0
distributed-print-business/src/main/resources/db/log/脚本-wangl.sql

@@ -69,3 +69,11 @@ UPDATE sys_config SET config_value='true' WHERE config_key='custom.thread.pool.c
 INSERT INTO `sys_config` VALUES (401752651068346368, 135, NULL, 'open.flow.message.push', '是否开启消息推送', 'true', NULL, 1, 5, 1, 1686726096298, NULL, 1686726096298);
 INSERT INTO `sys_config` VALUES (401752651068346369, 135, NULL, 'flow.message.type', '消息类型', 'OFF_STANDARD', NULL, 1, 6, 1, 1686726096303, NULL, 1686726096303);
 INSERT INTO `sys_config` VALUES (401752651068346370, 135, NULL, 'mq.host.url', '消息中心地址', 'http://exam.gdpu.edu.cn:7400?code=gdpu', NULL, 1, 7, 1, 1686726096309, NULL, 1686726096309);
+
+-----------------------3.2.7 start 优化需求 2023-06-20----------------------
+INSERT INTO sys_privilege
+(id, name, url, `type`, parent_id, `sequence`, property, related, enable, default_auth, front_display)
+VALUES(880, '重启流程', '/api/admin/exam/task/restart', 'URL', 42, 9, 'AUTH', NULL, 1, 1, 1);
+INSERT INTO sys_privilege
+(id, name, url, `type`, parent_id, `sequence`, property, related, enable, default_auth, front_display)
+VALUES(881, '取消', 'Restart', 'LINK', 42, 6, 'AUTH', '880', 1, 0, 1);

+ 7 - 0
distributed-print-business/src/main/resources/db/upgrade/3.2.7.sql

@@ -161,3 +161,10 @@ CREATE TABLE `sys_role_privilege_custom` (
 
 ALTER TABLE `sys_role_privilege`
     ADD COLUMN `school_id` BIGINT(20) NULL COMMENT '内置角色,按学校自定义的权限' AFTER `enable`;
+
+INSERT INTO sys_privilege
+(id, name, url, `type`, parent_id, `sequence`, property, related, enable, default_auth, front_display)
+VALUES(880, '重启流程', '/api/admin/exam/task/restart', 'URL', 42, 9, 'AUTH', NULL, 1, 1, 1);
+INSERT INTO sys_privilege
+(id, name, url, `type`, parent_id, `sequence`, property, related, enable, default_auth, front_display)
+VALUES(881, '取消', 'Restart', 'LINK', 42, 6, 'AUTH', '880', 1, 0, 1);

+ 31 - 0
distributed-print/src/main/java/com/qmth/distributed/print/api/ExamTaskQueryController.java

@@ -191,5 +191,36 @@ public class ExamTaskQueryController {
         boolean isSuccess = examTaskDetailService.cancel(id, cancelRemark);
         return ResultUtil.ok(isSuccess);
     }
+
+    @ApiOperation(value = "卷库查询-重启流程")
+    @RequestMapping(value = "/restart", method = RequestMethod.POST)
+    @OperationLogDetail(customizedOperationType = CustomizedOperationTypeEnum.UPDATE)
+    public Result taskFlowRestart(@RequestBody ExamTaskDetail examTaskDetail) throws IOException {
+        Map<String, Object> map = examTaskDetailService.taskRestart(examTaskDetail);
+        Boolean isSuccess = (Boolean) map.get(SystemConstant.SUCCESS);
+        if (isSuccess) {
+            ExamTask examTask = examTaskService.getById(examTaskDetail.getExamTaskId());
+            if (Objects.nonNull(examTask.getReview()) && examTask.getReview()) {
+                // 发送短信
+                basicMessageService.sendNoticeTaskAuditCreateOrReview(examTask, MessageEnum.NOTICE_OF_AUDIT_REVIEW);
+            } else {
+               /* SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+                // 校验课程关联考场,是否已经提交打印
+                Boolean isCreate = printCommonService.checkExamDetailStatus(examTask.getSchoolId(), null, examTask.getCourseCode(), examTask.getPaperNumber());
+                // 校验是否可以提交打印状态
+                if (isCreate) {
+                    printCommonService.checkData(examTask.getSchoolId(), examTask.getExamId(), examTask.getCourseCode(), examTask.getPaperNumber(), sysUser);
+                }*/
+            }
+            Boolean sendFlowStartMq = (Boolean) map.get(SystemConstant.SEND_FLOW_START_MQ);
+            Boolean sendFlowMq = (Boolean) map.get(SystemConstant.SEND_FLOW_MQ);
+            if (Objects.nonNull(sendFlowStartMq) && sendFlowStartMq) {
+                activitiService.sendFlowStartMsg(examTask.getFlowId());
+            } else if (Objects.nonNull(sendFlowMq) && sendFlowMq) {
+                activitiService.sendFlowTaskApproveMsg(map);
+            }
+        }
+        return ResultUtil.ok(isSuccess);
+    }
 }
 

+ 7 - 7
teachcloud-report/src/main/java/com/qmth/teachcloud/report/api/BasicDatasourceController.java

@@ -13,6 +13,7 @@ import com.qmth.teachcloud.common.entity.BasicCourse;
 import com.qmth.teachcloud.common.entity.SysOrg;
 import com.qmth.teachcloud.common.entity.SysRole;
 import com.qmth.teachcloud.common.entity.SysUser;
+import com.qmth.teachcloud.common.enums.AssignEnum;
 import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import com.qmth.teachcloud.common.enums.RoleTypeEnum;
 import com.qmth.teachcloud.common.service.BasicCourseService;
@@ -25,7 +26,6 @@ import com.qmth.teachcloud.report.business.bean.dto.excel.*;
 import com.qmth.teachcloud.report.business.bean.dto.query.*;
 import com.qmth.teachcloud.report.business.bean.params.CollegeCombineParams;
 import com.qmth.teachcloud.report.business.entity.*;
-import com.qmth.teachcloud.common.enums.AssignEnum;
 import com.qmth.teachcloud.report.business.enums.ExamCloudDataEnum;
 import com.qmth.teachcloud.report.business.enums.NumberTypeEnum;
 import com.qmth.teachcloud.report.business.enums.PublishStatusEnum;
@@ -128,7 +128,7 @@ public class BasicDatasourceController {
                 throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
             }
             return finalExcelList;
-        });
+        }, 2);
 
         //保存到数据库
         Map<String, Long> paperMap = new HashMap<>();
@@ -259,7 +259,7 @@ public class BasicDatasourceController {
                         throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
                     }
                     return finalExcelList;
-                });
+                }, 2);
         //保存到数据库
 
         // 模块二级考查点维度熟练度配置,及模块简要描述表
@@ -415,7 +415,7 @@ public class BasicDatasourceController {
                 throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
             }
             return finalExcelList;
-        });
+        }, 2);
         //保存到数据库
         List<TBDimension> tbDimensionList = new ArrayList<>();
         if (Objects.nonNull(finalList) && finalList.size() > 0) {
@@ -900,7 +900,7 @@ public class BasicDatasourceController {
                 throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
             }
             return finalExcelList;
-        });
+        }, 2);
 
         //保存到数据库
         List<TAExamCourseRecord> willUpdate = new ArrayList<>();
@@ -987,7 +987,7 @@ public class BasicDatasourceController {
                 throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
             }
             return finalExcelList;
-        });
+        }, 2);
 
         List<TBExamination> tbExaminationList = new ArrayList<>();
         if (Objects.nonNull(finalList) && finalList.size() > 0) {
@@ -1409,7 +1409,7 @@ public class BasicDatasourceController {
                 throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
             }
             return finalExcelList;
-        });
+        }, 2);
 
         //保存到数据库
         if (Objects.nonNull(finalList) && finalList.size() > 0) {