Prechádzať zdrojové kódy

自定义流程接口新增-流程节点信息

wangliang 3 rokov pred
rodič
commit
7bc69f9fbb

+ 44 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/result/TaskInfoResult.java

@@ -0,0 +1,44 @@
+package com.qmth.distributed.print.business.bean.result;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @Description: 流程节点result
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2021/8/6
+ */
+public class TaskInfoResult extends FlowTaskResult implements Serializable {
+
+    @ApiModelProperty(value = "驳回流程节点步骤")
+    private List<FlowTaskResult> rejectSetupList;
+
+    public TaskInfoResult() {
+
+    }
+
+    public TaskInfoResult(String taskName, String taskKey, Integer setup) {
+        setTaskName(taskName);
+        setTaskKey(taskKey);
+        setSetup(setup);
+    }
+
+    public TaskInfoResult(Long flowId, String taskName, String taskKey, Integer setup) {
+        setFlowId(flowId);
+        setTaskName(taskName);
+        setTaskKey(taskKey);
+        setSetup(setup);
+    }
+
+    public List<FlowTaskResult> getRejectSetupList() {
+        return rejectSetupList;
+    }
+
+    public void setRejectSetupList(List<FlowTaskResult> rejectSetupList) {
+        this.rejectSetupList = rejectSetupList;
+    }
+}

+ 9 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ActivitiService.java

@@ -4,6 +4,7 @@ import com.qmth.distributed.print.business.bean.flow.CustomFlowSaveDto;
 import com.qmth.distributed.print.business.bean.result.FlowTaskApprovePeopleAllResult;
 import com.qmth.distributed.print.business.bean.result.FlowTaskResult;
 import com.qmth.distributed.print.business.bean.result.FlowTaskSubmitPeopleAllResult;
+import com.qmth.distributed.print.business.bean.result.TaskInfoResult;
 import com.qmth.teachcloud.common.bean.params.ApproveUserResult;
 import org.activiti.engine.runtime.ProcessInstance;
 import org.springframework.web.multipart.MultipartFile;
@@ -158,4 +159,12 @@ public interface ActivitiService {
      * @param approveId
      */
     public void customFlowStart(Long taskId, Long approveId);
+
+    /**
+     * 获取当前流程节点信息
+     *
+     * @param taskId
+     * @return
+     */
+    public TaskInfoResult taskInfo(Long taskId);
 }

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

@@ -2,6 +2,7 @@ package com.qmth.distributed.print.business.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
 import com.qmth.boot.api.exception.ApiException;
 import com.qmth.distributed.print.business.activiti.custom.service.DefaultInstanceConvertToMultiInstance;
 import com.qmth.distributed.print.business.activiti.custom.service.MultiWorkFlow;
@@ -341,15 +342,14 @@ public class ActivitiServiceImpl implements ActivitiService {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         Optional.ofNullable(map.get(SystemConstant.FLOW_TASK_ID)).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程任务id不能为空"));
         flowTaskId = (String) map.get(SystemConstant.FLOW_TASK_ID);
-        boolean lock = redisUtil.lock(SystemConstant.REDIS_LOCK_FLOW_TASK_PREFIX + flowTaskId, SystemConstant.REDIS_LOCK_FLOW_TASK_TIME_OUT);
+        Task task = taskService.createTaskQuery().taskId(flowTaskId).singleResult();
+        Optional.ofNullable(task).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程任务为空或该流程已被他人审核,请刷新再试!"));
+        Long flowId = SystemConstant.convertIdToLong(task.getProcessInstanceId());
+        boolean lock = redisUtil.lock(SystemConstant.REDIS_LOCK_FLOW_TASK_PREFIX + flowId, SystemConstant.REDIS_LOCK_FLOW_TASK_TIME_OUT);
         if (!lock) {
             throw ExceptionResultEnum.ERROR.exception("正在审批中,请稍候再试!");
         }
         try {
-            Task task = taskService.createTaskQuery().taskId(flowTaskId).singleResult();
-            Optional.ofNullable(task).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程任务为空或该流程已被他人审核,请刷新再试!"));
-            String processInstanceId = task.getProcessInstanceId();
-            Long flowId = SystemConstant.convertIdToLong(processInstanceId);
             ExamTask examTask = examTaskService.findByFlowId(flowId);
 
             //获取当前流程节点
@@ -359,7 +359,7 @@ public class ActivitiServiceImpl implements ActivitiService {
 
             //流程审批
             TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(flowId, examTask.getSchoolId());
-            tfFlowApprove = Objects.isNull(tfFlowApprove) ? new TFFlowApprove(sysUser.getSchoolId(), sysUser.getOrgId(), SystemConstant.convertIdToLong(processInstanceId), sysUser.getId(), FlowStatusEnum.FINISH, sysUser.getId()) : tfFlowApprove;
+            tfFlowApprove = Objects.isNull(tfFlowApprove) ? new TFFlowApprove(sysUser.getSchoolId(), sysUser.getOrgId(), flowId, sysUser.getId(), FlowStatusEnum.FINISH, sysUser.getId()) : tfFlowApprove;
 
             Map<String, Object> objectMap = new HashMap<>();
             TFFlowLog tfFlowLog = null;
@@ -387,7 +387,7 @@ public class ActivitiServiceImpl implements ActivitiService {
                 }
                 remark = Objects.nonNull(map.get(SystemConstant.APPROVE_REMARK)) ? map.get(SystemConstant.APPROVE_REMARK).toString() : null;
                 //流程流水日志
-                tfFlowLog = new TFFlowLog(sysUser.getSchoolId(), sysUser.getOrgId(), SystemConstant.convertIdToLong(processInstanceId), examTask.getId(), sysUser.getId(), sysUser.getId(), remark);
+                tfFlowLog = new TFFlowLog(sysUser.getSchoolId(), sysUser.getOrgId(), flowId, examTask.getId(), sysUser.getId(), sysUser.getId(), remark);
                 //判断流程审批是通过还是驳回
                 FlowApprovePassEnum approvePass = (FlowApprovePassEnum) map.get(SystemConstant.APPROVE_OPERATION);
                 Map<String, FlowTaskResult> setupMap = (Map<String, FlowTaskResult>) flowProcessVarMap.get(SystemConstant.SETUP_MAP);
@@ -485,7 +485,7 @@ public class ActivitiServiceImpl implements ActivitiService {
                 ResultUtil.error(e.getMessage());
             }
         } finally {
-            redisUtil.releaseLock(SystemConstant.REDIS_LOCK_FLOW_TASK_PREFIX + flowTaskId);
+            redisUtil.releaseLock(SystemConstant.REDIS_LOCK_FLOW_TASK_PREFIX + flowId);
         }
         return map;
     }
@@ -759,6 +759,8 @@ public class ActivitiServiceImpl implements ActivitiService {
         TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.findByFlowId(SystemConstant.convertIdToLong(flowId));
         Map<String, Object> flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlowEntity);
         Map<String, FlowTaskResult> setupMap = (Map<String, FlowTaskResult>) flowProcessVarMap.get(SystemConstant.SETUP_MAP);
+        Optional.ofNullable(setupMap).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有步骤数据!"));
+
         List<FlowTaskResult> flowTaskResultList = new ArrayList<>(setupMap.size());
         Gson gson = new Gson();
         for (Map.Entry<String, FlowTaskResult> entry : setupMap.entrySet()) {
@@ -2189,6 +2191,43 @@ public class ActivitiServiceImpl implements ActivitiService {
         tfCustomFlowService.updateById(tfCustomFlow);
     }
 
+    /**
+     * 获取当前流程节点信息
+     *
+     * @param taskId
+     * @return
+     */
+    @Override
+    public TaskInfoResult taskInfo(Long taskId) {
+        Task task = taskService.createTaskQuery().taskId(String.valueOf(taskId)).singleResult();
+        Optional.ofNullable(task).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程任务为空或该流程已被他人审核,请刷新再试!"));
+        Long flowId = SystemConstant.convertIdToLong(task.getProcessInstanceId());
+        TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.findByFlowId(flowId);
+        Map<String, Object> flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlowEntity);
+        Map<String, List<CustomFlowSequenceDto>> approveRejectMap = (Map<String, List<CustomFlowSequenceDto>>) flowProcessVarMap.get(SystemConstant.APPROVE_REJECT_MAP);
+        Optional.ofNullable(approveRejectMap).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有驳回数据!"));
+        Map<String, FlowTaskResult> setupMap = (Map<String, FlowTaskResult>) flowProcessVarMap.get(SystemConstant.SETUP_MAP);
+        Optional.ofNullable(setupMap).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有步骤数据!"));
+
+        Gson gson = new Gson();
+        FlowTaskResult currFlowTaskResult = gson.fromJson(gson.toJson(setupMap.get(task.getTaskDefinitionKey())), FlowTaskResult.class);
+
+        TaskInfoResult taskInfoResult = new TaskInfoResult(flowId, task.getName(), task.getTaskDefinitionKey(), currFlowTaskResult.getSetup());
+        List<FlowTaskResult> flowTaskResultList = null;
+        if (Objects.nonNull(approveRejectMap.get(task.getTaskDefinitionKey()))) {
+            flowTaskResultList = new ArrayList<>();
+            List<CustomFlowSequenceDto> customFlowSequenceDtoList = gson.fromJson(gson.toJson(approveRejectMap.get(task.getTaskDefinitionKey())), new TypeToken<List<CustomFlowSequenceDto>>() {
+            }.getType());
+            for (CustomFlowSequenceDto c : customFlowSequenceDtoList) {
+                FlowTaskResult flowTaskResult = gson.fromJson(gson.toJson(setupMap.get(c.getAfterFlowTaskId())), FlowTaskResult.class);
+                flowTaskResult.setFlowId(flowId);
+                flowTaskResultList.add(flowTaskResult);
+            }
+        }
+        taskInfoResult.setRejectSetupList(flowTaskResultList);
+        return taskInfoResult;
+    }
+
     /**
      * 获取流程变量
      *

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

@@ -325,6 +325,6 @@ public class TFCustomFlowController {
     @ApiResponses({@ApiResponse(code = 200, message = "流程提交记录", response = FlowTaskApprovePeopleAllResult.class)})
     @RequestMapping(value = "/task/info", method = RequestMethod.POST)
     public Result taskInfo(@ApiParam(value = "流程节点id", required = true) @RequestParam String taskId) {
-        return ResultUtil.ok(true);
+        return ResultUtil.ok(activitiService.taskInfo(SystemConstant.convertIdToLong(taskId)));
     }
 }