فهرست منبع

自定义流程接口-命题老师重启流程

wangliang 3 سال پیش
والد
کامیت
35ea25412d
16فایلهای تغییر یافته به همراه109 افزوده شده و 149 حذف شده
  1. 10 10
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExamTaskDetailCardDto.java
  2. 1 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/TFFlowApproveMapper.java
  3. 0 31
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/TFFlowJoinMapper.java
  4. 1 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TFFlowApproveService.java
  5. 1 9
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TFFlowJoinService.java
  6. 49 18
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ActivitiServiceImpl.java
  7. 12 8
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskDetailServiceImpl.java
  8. 10 6
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskServiceImpl.java
  9. 3 3
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/PrintCommonServiceServiceImpl.java
  10. 2 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TFFlowApproveServiceImpl.java
  11. 4 32
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TFFlowJoinServiceImpl.java
  12. 1 7
      distributed-print-business/src/main/resources/mapper/TFFlowApproveMapper.xml
  13. 0 15
      distributed-print-business/src/main/resources/mapper/TFFlowJoinMapper.xml
  14. 11 3
      distributed-print/src/main/java/com/qmth/distributed/print/api/ExamTaskController.java
  15. 1 0
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/contant/SystemConstant.java
  16. 3 1
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/enums/FlowApprovePassEnum.java

+ 10 - 10
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExamTaskDetailCardDto.java

@@ -30,16 +30,16 @@ public class ExamTaskDetailCardDto {
     private String examName;
     private String semesterName;
 
-    @ApiModelProperty(value = "是否是子流程驳回")
-    private boolean subFlowReject;
-
-    public boolean isSubFlowReject() {
-        return subFlowReject;
-    }
-
-    public void setSubFlowReject(boolean subFlowReject) {
-        this.subFlowReject = subFlowReject;
-    }
+//    @ApiModelProperty(value = "是否是子流程驳回")
+//    private boolean subFlowReject;
+
+//    public boolean isSubFlowReject() {
+//        return subFlowReject;
+//    }
+//
+//    public void setSubFlowReject(boolean subFlowReject) {
+//        this.subFlowReject = subFlowReject;
+//    }
 
     public String getExamTaskId() {
         return examTaskId;

+ 1 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/TFFlowApproveMapper.java

@@ -22,10 +22,9 @@ public interface TFFlowApproveMapper extends BaseMapper<TFFlowApprove> {
      * 根据流程id查询流程状态
      *
      * @param flowId
-     * @param schoolId
      * @return
      */
-    TFFlowApprove findByFlowId(@Param("flowId") Long flowId, @Param("schoolId") Long schoolId);
+    TFFlowApprove findByFlowId(@Param("flowId") Long flowId);
 
     /**
      * 查找流程审批记录列表

+ 0 - 31
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/TFFlowJoinMapper.java

@@ -14,35 +14,4 @@ import org.apache.ibatis.annotations.Param;
  */
 public interface TFFlowJoinMapper extends BaseMapper<TFFlowJoin> {
 
-    /**
-     * 根据实体id查找
-     *
-     * @param objectId
-     * @return
-     */
-    Integer findByFlowLevel(@Param("objectId") Long objectId);
-
-    /**
-     * 根据流程id查找
-     *
-     * @param flowId
-     * @return
-     */
-    Long findByRootLevel(@Param("flowId") Long flowId);
-
-    /**
-     * 根据实体id查找
-     *
-     * @param objectId
-     * @return
-     */
-    Integer findByRootLevelByObjectId(@Param("objectId") Long objectId);
-
-    /**
-     * 根据实体id查找最大流程号
-     *
-     * @param objectId
-     * @return
-     */
-    Long selectMaxFlowIdByObjectId(@Param("objectId") Long objectId);
 }

+ 1 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TFFlowApproveService.java

@@ -22,10 +22,9 @@ public interface TFFlowApproveService extends IService<TFFlowApprove> {
      * 根据流程id查询流程状态
      *
      * @param flowId
-     * @param schoolId
      * @return
      */
-    TFFlowApprove findByFlowId(Long flowId, Long schoolId);
+    TFFlowApprove findByFlowId(Long flowId);
 
     /**
      * 查找流程审批记录列表

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

@@ -23,14 +23,6 @@ public interface TFFlowJoinService extends IService<TFFlowJoin> {
      */
     public boolean saveOrUpdate(Map<String, Object> map);
 
-    /**
-     * 根据实体id查找
-     *
-     * @param objectId
-     * @return
-     */
-    public TFFlowJoin findByFlowLevel(Long objectId);
-
     /**
      * 根据实体id查找
      *
@@ -45,7 +37,7 @@ public interface TFFlowJoinService extends IService<TFFlowJoin> {
      * @param flowId
      * @return
      */
-    public TFFlowJoin findByRootLevel(Long flowId);
+    public TFFlowJoin findByFlowId(Long flowId);
 
     /**
      * 根据自定义流程实体id查询

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

@@ -10,15 +10,14 @@ import com.qmth.distributed.print.business.bean.flow.link.FlowTaskLink;
 import com.qmth.distributed.print.business.bean.flow.link.FlowTaskNode;
 import com.qmth.distributed.print.business.bean.result.*;
 import com.qmth.distributed.print.business.entity.*;
-import com.qmth.distributed.print.business.enums.CustomFlowMultipleUserApproveTypeEnum;
-import com.qmth.distributed.print.business.enums.CustomFlowRejectResubmitTypeEnum;
-import com.qmth.distributed.print.business.enums.CustomFlowTypeEnum;
-import com.qmth.distributed.print.business.enums.ExamStatusEnum;
+import com.qmth.distributed.print.business.enums.*;
 import com.qmth.distributed.print.business.service.*;
 import com.qmth.teachcloud.common.bean.params.ApproveUserResult;
 import com.qmth.teachcloud.common.contant.SystemConstant;
+import com.qmth.teachcloud.common.entity.SysOrg;
 import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.common.enums.*;
+import com.qmth.teachcloud.common.service.CommonCacheService;
 import com.qmth.teachcloud.common.service.SysUserService;
 import com.qmth.teachcloud.common.util.JacksonUtil;
 import com.qmth.teachcloud.common.util.RedisUtil;
@@ -98,6 +97,9 @@ public class ActivitiServiceImpl implements ActivitiService {
     @Resource
     TFCustomFlowEntityService tfCustomFlowEntityService;
 
+    @Resource
+    CommonCacheService commonCacheService;
+
     /**
      * 启动流程
      *
@@ -202,8 +204,8 @@ public class ActivitiServiceImpl implements ActivitiService {
             SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
             ExamTask examTask = examTaskService.findByFlowId(SystemConstant.convertIdToLong(flowId));
             //流程审批
-            TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(SystemConstant.convertIdToLong(flowId), examTask.getSchoolId());
-            TFFlowJoin tfFlowJoin = tfFlowJoinService.findByRootLevel(SystemConstant.convertIdToLong(flowId));
+            TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(SystemConstant.convertIdToLong(flowId));
+            TFFlowJoin tfFlowJoin = tfFlowJoinService.findByFlowId(SystemConstant.convertIdToLong(flowId));
             if (Objects.isNull(tfFlowApprove)) {
                 tfFlowApprove = new TFFlowApprove(sysUser.getSchoolId(), sysUser.getOrgId(), SystemConstant.convertIdToLong(flowId), sysUser.getId(), FlowStatusEnum.END, sysUser.getId());
             } else {
@@ -252,7 +254,21 @@ public class ActivitiServiceImpl implements ActivitiService {
         FlowStatusEnum flowStatusEnum = (FlowStatusEnum) map.get(SystemConstant.FLOW_STATUS);
 
         String approveId = Objects.nonNull(map.get(SystemConstant.APPROVE_ID)) ? String.valueOf((Long) map.get(SystemConstant.APPROVE_ID)) : null;
-        tfFlowApproveService.save(new TFFlowApprove(sysUser.getSchoolId(), sysUser.getOrgId(), SystemConstant.convertIdToLong(flowId), sysUser.getId(), flowStatusEnum, sysUser.getId()));
+
+        TFFlowApprove tfFlowApprove = null;
+        FlowJoinTypeEnum flowJoinTypeEnum = (FlowJoinTypeEnum) map.get(SystemConstant.FLOW_JOIN_TYPE);
+        if (Objects.nonNull(flowJoinTypeEnum) && flowJoinTypeEnum == FlowJoinTypeEnum.RESTART) {//重新提交
+            Long oldFlowId = (Long) map.get(SystemConstant.OLD_FLOW_ID);
+            tfFlowApprove = tfFlowApproveService.findByFlowId(oldFlowId);
+            tfFlowApprove.insertInfo(sysUser.getId());
+            tfFlowApprove.updateInfo(sysUser.getId());
+            tfFlowApprove.setFlowId(SystemConstant.convertIdToLong(flowId));
+            tfFlowApprove.setStatus(flowStatusEnum);
+            tfFlowApprove.setSetup(FlowApproveSetupEnum.SUBMIT.getSetup());
+        } else {
+            tfFlowApprove = new TFFlowApprove(sysUser.getSchoolId(), sysUser.getOrgId(), SystemConstant.convertIdToLong(flowId), sysUser.getId(), flowStatusEnum, sysUser.getId());
+        }
+        tfFlowApproveService.save(tfFlowApprove);
 
         Long objectId = (Long) map.get(SystemConstant.OBJECT_ID);
         tfFlowLogService.save(new TFFlowLog(sysUser.getSchoolId(), sysUser.getOrgId(), SystemConstant.convertIdToLong(flowId), objectId, sysUser.getId(), sysUser.getId(), "提交流程", approveId, FlowApproveOperationEnum.SUBMIT, flowType.getTable()));
@@ -286,7 +302,7 @@ public class ActivitiServiceImpl implements ActivitiService {
             FlowNode currFlow = (FlowNode) bpmnModel.getMainProcess().getFlowElement(currActivityId);
 
             //流程审批
-            TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(flowId, examTask.getSchoolId());
+            TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(flowId);
             tfFlowApprove = Objects.isNull(tfFlowApprove) ? new TFFlowApprove(sysUser.getSchoolId(), sysUser.getOrgId(), flowId, sysUser.getId(), FlowStatusEnum.FINISH, sysUser.getId()) : tfFlowApprove;
 
             TFFlowLog tfFlowLog = null;
@@ -294,7 +310,7 @@ public class ActivitiServiceImpl implements ActivitiService {
             TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.findByFlowId(flowId);
             Map<String, Object> flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlowEntity);
 
-            TFFlowJoin tfFlowJoin = tfFlowJoinService.findByRootLevel(flowId);
+            TFFlowJoin tfFlowJoin = tfFlowJoinService.findByFlowId(flowId);
 
             String remark = null;
             FlowTaskResult currFlowTaskResult = null, nextFlowTaskResult = null;
@@ -730,13 +746,14 @@ public class ActivitiServiceImpl implements ActivitiService {
     @Transactional
     public boolean taskApproverExchange(String userId, String taskId) {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        SysOrg sysOrg = commonCacheService.orgCache(sysUser.getOrgId());
         if (Objects.equals(String.valueOf(sysUser.getId()), userId)) {
             throw ExceptionResultEnum.ERROR.exception("不能转给自己");
         }
         Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
         Optional.ofNullable(task).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程任务为空或该流程已被他人审核,请刷新再试!"));
         String flowId = task.getProcessInstanceId();
-        TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(SystemConstant.convertIdToLong(flowId), sysUser.getSchoolId());
+        TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(SystemConstant.convertIdToLong(flowId));
         Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到流程状态记录"));
         if (tfFlowApprove.getSetup() <= 0) {
             throw ExceptionResultEnum.ERROR.exception("流程已结束或已终止");
@@ -783,11 +800,14 @@ public class ActivitiServiceImpl implements ActivitiService {
 
         ExamTask examTask = examTaskService.findByFlowId(SystemConstant.convertIdToLong(flowId));
         SysUser exchangeUser = sysUserService.getById(userId);
+        SysOrg exchangeSysOrg = commonCacheService.orgCache(exchangeUser.getOrgId());
 
-        TFFlowJoin tfFlowJoin = tfFlowJoinService.findByRootLevel(SystemConstant.convertIdToLong(flowId));
+        TFFlowJoin tfFlowJoin = tfFlowJoinService.findByFlowId(SystemConstant.convertIdToLong(flowId));
 
+        String remark = Objects.nonNull(sysOrg) ? sysOrg.getName() : "无机构";
+        String exchangeRemark = Objects.nonNull(exchangeSysOrg) ? exchangeSysOrg.getName() : "无机构";
         //流程流水日志
-        TFFlowLog tfFlowLog = new TFFlowLog(sysUser.getSchoolId(), sysUser.getOrgId(), examTask.getFlowId(), examTask.getId(), sysUser.getId(), sysUser.getRealName() + "转" + exchangeUser.getRealName() + "审批", FlowApproveOperationEnum.EXCHANGE, sysUser.getId(), String.valueOf(exchangeUser.getId()), tfFlowJoin.getObjectTable());
+        TFFlowLog tfFlowLog = new TFFlowLog(sysUser.getSchoolId(), sysUser.getOrgId(), examTask.getFlowId(), examTask.getId(), sysUser.getId(), sysUser.getRealName() + "(" + remark + ")转" + exchangeUser.getRealName() + "(" + exchangeRemark + ")审批", FlowApproveOperationEnum.EXCHANGE, sysUser.getId(), String.valueOf(exchangeUser.getId()), tfFlowJoin.getObjectTable());
         CustomFlowVarDto customFlowVarDto = gson.fromJson(gson.toJson(agginessMap.get(userTask.getId())), CustomFlowVarDto.class);
         if (customFlowVarDto.getApproveIds().size() == 1) {
             customFlowVarDto.setApproveIds(new ArrayList<>(Arrays.asList(userId)));
@@ -1244,8 +1264,19 @@ public class ActivitiServiceImpl implements ActivitiService {
         TFCustomFlow tfCustomFlow = tfCustomFlowService.findMaxVersion(sysUser.getSchoolId(), null, TFCustomTypeEnum.ELECTRON_FLOW);
         Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到自定义流程数据"));
 
-        TFCustomFlowEntity tfCustomFlowEntity = new TFCustomFlowEntity(tfCustomFlow.getId(), sysUser.getId());
-        Map<String, Object> flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlow);
+        TFCustomFlowEntity tfCustomFlowEntity = null;
+        Map<String, Object> flowProcessVarMap = null;
+        FlowJoinTypeEnum flowJoinTypeEnum = (FlowJoinTypeEnum) map.get(SystemConstant.FLOW_JOIN_TYPE);
+        if (Objects.nonNull(flowJoinTypeEnum) && flowJoinTypeEnum == FlowJoinTypeEnum.RESTART) {//重新提交
+            Long oldFlowId = (Long) map.get(SystemConstant.OLD_FLOW_ID);
+            tfCustomFlowEntity = tfCustomFlowEntityService.findByFlowId(oldFlowId);
+            tfCustomFlowEntity.insertInfo(sysUser.getId());
+            tfCustomFlowEntity.updateInfo(sysUser.getId());
+            flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlowEntity);
+        } else {//否则新增
+            tfCustomFlowEntity = new TFCustomFlowEntity(tfCustomFlow.getId(), sysUser.getId());
+            flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlow);
+        }
         Map<String, CustomFlowVarDto> agginessMap = (Map<String, CustomFlowVarDto>) flowProcessVarMap.get(SystemConstant.AGGINESS_MAP);
         List<String> approveUserIds = new ArrayList(Arrays.asList(String.valueOf(approveId)));
         ApproveUserResult approveUserResult = sysUserService.findByIds(approveUserIds.stream().map(x -> SystemConstant.convertIdToLong(x)).collect(Collectors.toList()));
@@ -1253,8 +1284,8 @@ public class ActivitiServiceImpl implements ActivitiService {
         flowProcessVarMap.put(SystemConstant.AGGINESS_MAP, agginessMap);
 
         map.computeIfAbsent(SystemConstant.ID, v -> tfCustomFlow.getFlowKey());
-        map.computeIfAbsent(SystemConstant.FLOW_PROCESS_VAR_MAP, v -> flowProcessVarMap);
-        map.computeIfAbsent(SystemConstant.FLOW_ENTITY_ID, v -> String.valueOf(tfCustomFlowEntity.getId()));
+        map.put(SystemConstant.FLOW_PROCESS_VAR_MAP, flowProcessVarMap);
+        map.put(SystemConstant.FLOW_ENTITY_ID, String.valueOf(tfCustomFlowEntity.getId()));
         map.computeIfAbsent(SystemConstant.CUSTOM_FLOW_ID, v -> tfCustomFlow.getId());
         map.computeIfAbsent(SystemConstant.VERSION, v -> tfCustomFlow.getVersion());
         this.flowStart(map);
@@ -1295,7 +1326,7 @@ public class ActivitiServiceImpl implements ActivitiService {
         FlowTaskResult currFlowTaskResult = gson.fromJson(gson.toJson(setupMap.get(task.getTaskDefinitionKey())), FlowTaskResult.class);
 
         //获取当前流程节点
-        TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(flowId, sysUser.getSchoolId());
+        TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(flowId);
 
         //获取流程待审批人
         Map<String, CustomFlowVarDto> agginessMap = (Map<String, CustomFlowVarDto>) flowProcessVarMap.get(SystemConstant.AGGINESS_MAP);
@@ -1338,7 +1369,7 @@ public class ActivitiServiceImpl implements ActivitiService {
         Optional.ofNullable(tfFlowJoinList).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程数据为空"));
 
         //获取当前流程节点
-        TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(flowId, sysUser.getSchoolId());
+        TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(flowId);
         Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程审核数据为空"));
 
         Map<String, Object> flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlowEntity);

+ 12 - 8
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskDetailServiceImpl.java

@@ -14,11 +14,12 @@ import com.qmth.distributed.print.business.enums.FlowJoinTypeEnum;
 import com.qmth.distributed.print.business.enums.PrintPlanStatusEnum;
 import com.qmth.distributed.print.business.mapper.ExamTaskDetailMapper;
 import com.qmth.distributed.print.business.service.*;
-import com.qmth.distributed.print.business.templete.execute.AsyncCreatePdfTempleteService;
 import com.qmth.teachcloud.common.bean.dto.MqDto;
 import com.qmth.teachcloud.common.contant.SystemConstant;
+import com.qmth.teachcloud.common.entity.SysOrg;
 import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.common.enums.*;
+import com.qmth.teachcloud.common.service.CommonCacheService;
 import com.qmth.teachcloud.common.service.SysUserService;
 import com.qmth.teachcloud.common.service.TBTaskService;
 import com.qmth.teachcloud.common.service.TeachcloudCommonService;
@@ -65,9 +66,6 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
     @Lazy
     private PrintCommonService printCommonService;
 
-    @Resource
-    private AsyncCreatePdfTempleteService asyncCreatePdfTempleteService;
-
     @Autowired
     private ExamPrintPlanService examPrintPlanService;
 
@@ -95,6 +93,9 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
     @Resource
     SysUserService sysUserService;
 
+    @Resource
+    CommonCacheService commonCacheService;
+
     @Transactional
     @Override
     public boolean enable(ExamTaskDetail examTaskDetail) {
@@ -336,6 +337,7 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
 
         validPaperUpdate(examTaskDetail);
+        SysOrg sysOrg = commonCacheService.orgCache(requestUser.getOrgId());
 
         ExamTaskDetail examTaskDetail1 = this.getByExamTaskId(examTaskDetail.getExamTaskId());
         String unexposedPaperType = examTaskDetail.getPaperType();
@@ -375,14 +377,15 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
                     examTask,
                     TFCustomTypeEnum.ELECTRON_FLOW,
                     examTask.getUserId(),
-                    true);
+                    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);
 
-            map.computeIfAbsent(SystemConstant.FLOW_JOIN_TYPE, v -> FlowJoinTypeEnum.RESTART);
             tfFlowJoinService.saveOrUpdate(map);
             if (Objects.nonNull(flowId)) {
                 // 审核一级
@@ -392,11 +395,12 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
                     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);
                 }
             }
         }
-        int i = 1 / 0;
         return true;
     }
 
@@ -432,7 +436,7 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
 
         ExamTask examTask = examTaskService.getById(examTaskDetail.getExamTaskId());
         // 是否审核中
-        TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(examTask.getFlowId(), examTask.getSchoolId());
+        TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(examTask.getFlowId());
         if (!tfFlowApprove.getStatus().equals(FlowStatusEnum.FINISH)) {
             throw ExceptionResultEnum.ERROR.exception("命题任务没有审核完成,不能修改卷库");
         }

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

@@ -146,9 +146,6 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
     @Resource
     SysOrgService sysOrgService;
 
-    @Resource
-    BasicClazzService basicClazzService;
-
     @Resource
     FileStoreUtil fileStoreUtil;
 
@@ -169,9 +166,13 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
 
     @Resource
     BasicPrintConfigService basicPrintConfigService;
+
     @Resource
     TFFlowLogService tfFlowLogService;
 
+    @Resource
+    CommonCacheService commonCacheService;
+
     @Override
     public List<ExamTask> listByCourseCode(Long schoolId, String code) {
         QueryWrapper<ExamTask> queryWrapper = new QueryWrapper<>();
@@ -320,7 +321,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
 
         ExamTask task = this.getById(examTask.getId());
         if (Objects.nonNull(task.getFlowId())) {
-            TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(task.getFlowId(), task.getSchoolId());
+            TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(task.getFlowId());
             if (tfFlowApprove.getStatus().equals(FlowStatusEnum.FINISH) ||
                     tfFlowApprove.getStatus().equals(FlowStatusEnum.END)) {
                 throw ExceptionResultEnum.ERROR.exception("流程状态为已结束或已终止,不能启用/禁用操作");
@@ -1040,18 +1041,21 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
         }
         Optional.ofNullable(task.getFlowId()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("审核流程有误,不能撤回"));
 
-        TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(task.getFlowId(), task.getSchoolId());
+        TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(task.getFlowId());
         Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("审核流程进度丢失,不能撤回"));
 
         if (tfFlowApprove.getSetup().intValue() != 2) {
             throw ExceptionResultEnum.ERROR.exception("当前审核节点不能撤回");
         }
 
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        SysOrg sysOrg = commonCacheService.orgCache(sysUser.getOrgId());
         List<Task> flowTaskList = taskService.createTaskQuery().processInstanceId(String.valueOf(task.getFlowId())).list();
         Map<String, Object> map = new HashMap<>();
         map.computeIfAbsent(SystemConstant.FLOW_TASK_ID, v -> flowTaskList.get(0).getId());
         map.computeIfAbsent(SystemConstant.APPROVE_OPERATION, v -> FlowApprovePassEnum.CANCEL);
-        map.computeIfAbsent(SystemConstant.APPROVE_REMARK, v -> "命题" + FlowApprovePassEnum.CANCEL.getTitle());
+        String remark = Objects.nonNull(sysOrg) ? sysOrg.getName() : "无机构";
+        map.computeIfAbsent(SystemConstant.APPROVE_REMARK, v -> sysUser.getRealName() + "(" + remark + ")" + FlowApprovePassEnum.CANCEL.getTitle());
         map.computeIfAbsent(SystemConstant.APPROVE_SETUP, v -> FlowApproveSetupEnum.SUBMIT.getSetup());
         activitiService.taskApprove(map);
         return true;

+ 3 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/PrintCommonServiceServiceImpl.java

@@ -188,7 +188,7 @@ public class PrintCommonServiceServiceImpl implements PrintCommonService {
             }
             if (flowSchoolCodeMap.get(SystemConstant.GDYKDX_FLOW_KEY).contains(basicSchool.getCode())) {
                 HtmlToPdfUtil.convert(htmlFile.getPath(), destUrl, PageSizeEnum.A3);
-            } else if(flowSchoolCodeMap.get(SystemConstant.JXZYY_FLOW_KEY).contains(basicSchool.getCode())){
+            } else if (flowSchoolCodeMap.get(SystemConstant.JXZYY_FLOW_KEY).contains(basicSchool.getCode())) {
                 HtmlToPdfUtil.convert(htmlFile.getPath(), destUrl, PageSizeEnum.A4);
             }
 
@@ -228,7 +228,7 @@ public class PrintCommonServiceServiceImpl implements PrintCommonService {
             for (int i = 0; i < printCount; i++) {
                 if (flowSchoolCodeMap.get(SystemConstant.GDYKDX_FLOW_KEY).contains(basicSchool.getCode())) {
                     pdfList.add(new PdfDto(pdfFile.getPath(), PageSizeEnum.A3, pdfDto.getPageCount(), sequence));
-                } else if(flowSchoolCodeMap.get(SystemConstant.JXZYY_FLOW_KEY).contains(basicSchool.getCode())){
+                } else if (flowSchoolCodeMap.get(SystemConstant.JXZYY_FLOW_KEY).contains(basicSchool.getCode())) {
                     pdfList.add(new PdfDto(pdfFile.getPath(), PageSizeEnum.A4, pdfDto.getPageCount(), sequence));
                 }
             }
@@ -1004,7 +1004,7 @@ public class PrintCommonServiceServiceImpl implements PrintCommonService {
             log.info("卷库已禁用");
             return;
         }
-        TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(examTask.getFlowId(), examTask.getSchoolId());
+        TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(examTask.getFlowId());
         // 1.命题任务已完成
         if (tfFlowApprove != null && tfFlowApprove.getStatus() == FlowStatusEnum.FINISH) {
             // 2.校验考务数据是否导入

+ 2 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TFFlowApproveServiceImpl.java

@@ -34,8 +34,8 @@ public class TFFlowApproveServiceImpl extends ServiceImpl<TFFlowApproveMapper, T
      * @return
      */
     @Override
-    public TFFlowApprove findByFlowId(Long flowId, Long schoolId) {
-        return tfFlowApproveMapper.findByFlowId(flowId, schoolId);
+    public TFFlowApprove findByFlowId(Long flowId) {
+        return tfFlowApproveMapper.findByFlowId(flowId);
     }
 
     /**

+ 4 - 32
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TFFlowJoinServiceImpl.java

@@ -36,9 +36,6 @@ public class TFFlowJoinServiceImpl extends ServiceImpl<TFFlowJoinMapper, TFFlowJ
     @Resource
     RedisUtil redisUtil;
 
-    @Resource
-    TFFlowJoinMapper taskFlowMapper;
-
     /**
      * 保存TExamTaskFlow
      *
@@ -89,22 +86,6 @@ public class TFFlowJoinServiceImpl extends ServiceImpl<TFFlowJoinMapper, TFFlowJ
         return true;
     }
 
-    /**
-     * 根据实体id查找
-     *
-     * @param objectId
-     * @return
-     */
-    @Override
-    public TFFlowJoin findByFlowLevel(Long objectId) {
-        Integer level = taskFlowMapper.findByFlowLevel(objectId);
-        Optional.ofNullable(level).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到子流程信息"));
-        QueryWrapper<TFFlowJoin> tfFlowJoinQueryWrapper = new QueryWrapper<>();
-        tfFlowJoinQueryWrapper.lambda().eq(TFFlowJoin::getObjectId, objectId)
-                .eq(TFFlowJoin::getLevel, level);
-        return this.getOne(tfFlowJoinQueryWrapper);
-    }
-
     /**
      * 根据实体id查找
      *
@@ -113,7 +94,7 @@ public class TFFlowJoinServiceImpl extends ServiceImpl<TFFlowJoinMapper, TFFlowJ
      */
     @Override
     public List<TFFlowJoin> findByObjectId(Long objectId) {
-        return this.list(new QueryWrapper<TFFlowJoin>().lambda().eq(TFFlowJoin::getObjectId, objectId));
+        return this.list(new QueryWrapper<TFFlowJoin>().lambda().eq(TFFlowJoin::getObjectId, objectId).orderByAsc(TFFlowJoin::getCreateTime));
     }
 
     /**
@@ -123,15 +104,8 @@ public class TFFlowJoinServiceImpl extends ServiceImpl<TFFlowJoinMapper, TFFlowJ
      * @return
      */
     @Override
-    public TFFlowJoin findByRootLevel(Long flowId) {
-        Long objectId = taskFlowMapper.findByRootLevel(flowId);
-        Optional.ofNullable(objectId).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到实体id信息"));
-        Integer level = taskFlowMapper.findByRootLevelByObjectId(objectId);
-        Optional.ofNullable(level).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到主流程信息"));
-        QueryWrapper<TFFlowJoin> tfFlowJoinQueryWrapper = new QueryWrapper<>();
-        tfFlowJoinQueryWrapper.lambda().eq(TFFlowJoin::getObjectId, objectId)
-                .eq(TFFlowJoin::getLevel, level);
-        return this.getOne(tfFlowJoinQueryWrapper);
+    public TFFlowJoin findByFlowId(Long flowId) {
+        return this.getOne(new QueryWrapper<TFFlowJoin>().lambda().eq(TFFlowJoin::getFlowId, flowId));
     }
 
     /**
@@ -142,8 +116,6 @@ public class TFFlowJoinServiceImpl extends ServiceImpl<TFFlowJoinMapper, TFFlowJ
      */
     @Override
     public List<TFFlowJoin> findByFlowEntityId(Long flowEntityId) {
-        QueryWrapper<TFFlowJoin> tfFlowJoinQueryWrapper = new QueryWrapper<>();
-        tfFlowJoinQueryWrapper.lambda().eq(TFFlowJoin::getFlowEntityId, flowEntityId);
-        return this.list(tfFlowJoinQueryWrapper);
+        return this.list(new QueryWrapper<TFFlowJoin>().lambda().eq(TFFlowJoin::getFlowEntityId, flowEntityId));
     }
 }

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

@@ -3,13 +3,7 @@
 <mapper namespace="com.qmth.distributed.print.business.mapper.TFFlowApproveMapper">
 
     <select id="findByFlowId" resultType="com.qmth.distributed.print.business.entity.TFFlowApprove">
-        select * from t_f_flow_approve tffa
-        where EXISTS(
-            select t.flow_id from t_f_flow_join t
-            where EXISTS (select tffj.object_id from t_f_flow_join tffj
-            where tffj.flow_id = #{flowId} and t.object_id = tffj.object_id)
-            and t.`level` = 1 and tffa.school_id = #{schoolId} and tffa.flow_id = t.flow_id
-            )
+        select * from t_f_flow_approve tffa where tffa.flow_id = #{flowId}
     </select>
 
     <select id="findApproveList" resultType="com.qmth.distributed.print.business.bean.result.FlowApproveListResult">

+ 0 - 15
distributed-print-business/src/main/resources/mapper/TFFlowJoinMapper.xml

@@ -2,19 +2,4 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.qmth.distributed.print.business.mapper.TFFlowJoinMapper">
 
-    <select id="findByFlowLevel" resultType="java.lang.Integer">
-        SELECT max(t.level) FROM t_f_flow_join t WHERE t.object_id = #{objectId}
-    </select>
-
-    <select id="findByRootLevel" resultType="java.lang.Long">
-        SELECT t.object_id FROM t_f_flow_join t WHERE t.flow_id = #{flowId}
-    </select>
-
-    <select id="findByRootLevelByObjectId" resultType="java.lang.Integer">
-        SELECT min(t.level) FROM t_f_flow_join t WHERE t.object_id = #{objectId}
-    </select>
-
-    <select id="selectMaxFlowIdByObjectId" resultType="java.lang.Long">
-        select max(flow_id) from t_f_flow_join t where t.object_id = #{objectId}
-    </select>
 </mapper>

+ 11 - 3
distributed-print/src/main/java/com/qmth/distributed/print/api/ExamTaskController.java

@@ -293,13 +293,21 @@ public class ExamTaskController {
             if (Objects.nonNull(task)) {
                 detail.setFlowTaskId(task.getId());
             } else {
-                TFFlowJoin tfFlowJoin = tfFlowJoinService.findByFlowLevel(Long.parseLong(detail.getExamTaskId()));
+                List<TFFlowJoin> tfFlowJoinList = tfFlowJoinService.findByObjectId(Long.parseLong(detail.getExamTaskId()));
+                String flowId = null;
+                TFFlowJoin tfFlowJoin = null;
+                if (Objects.nonNull(tfFlowJoinList) && tfFlowJoinList.size() > 1) {
+                    tfFlowJoin = tfFlowJoinList.get(tfFlowJoinList.size() - 1);
+                } else if (Objects.nonNull(tfFlowJoinList) && tfFlowJoinList.size() == 1) {
+                    tfFlowJoin = tfFlowJoinList.get(0);
+                }
+                flowId = Objects.nonNull(tfFlowJoin) ? String.valueOf(tfFlowJoin.getFlowId()) : flowId;
                 task = taskService.createTaskQuery().processInstanceId(detail.getFlowId())
                         .taskCandidateOrAssigned(String.valueOf(sysUser.getId())).singleResult();
                 if (Objects.nonNull(task)) {
-                    detail.setSubFlowReject(true);
+//                    detail.setSubFlowReject(true);
                     detail.setFlowTaskId(task.getId());
-                    detail.setFlowId(String.valueOf(tfFlowJoin.getFlowId()));
+                    detail.setFlowId(flowId);
                 }
             }
         }

+ 1 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/contant/SystemConstant.java

@@ -211,6 +211,7 @@ public class SystemConstant {
     public static final String FLOW_SUBMIT = "flowSubmit";//命题提交申请
     public static final String EXAM_TASK = "examTask";//命题提交申请
     public static final String FLOW_JOIN_TYPE = "flowJoinType";//流程关联类型
+    public static final String OLD_FLOW_ID = "oldFlowId";//旧流程id
     public static final String FLOW_TYPE = "flowType";//流程类型
     public static final String FLOW_ID = "flowId";//流程id
     public static final String FLOW_TASK_ID = "flowTaskId";//流程任务id

+ 3 - 1
teachcloud-common/src/main/java/com/qmth/teachcloud/common/enums/FlowApprovePassEnum.java

@@ -15,7 +15,9 @@ public enum FlowApprovePassEnum {
 
     REJECT("驳回"),
 
-    CANCEL("撤销");
+    CANCEL("撤销"),
+
+    RESTART("重启流程");
 
     private String title;