소스 검색

新增自定义流程属性-功能修改

wangliang 3 년 전
부모
커밋
a13d03b0be
17개의 변경된 파일336개의 추가작업 그리고 114개의 파일을 삭제
  1. 0 12
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TFCustomFlow.java
  2. 80 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TFCustomFlowList.java
  3. 0 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TFFlowApprove.java
  4. 12 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TFFlowLog.java
  5. 16 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/TFCustomFlowListMapper.java
  6. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/TFCustomFlowMapper.java
  7. 3 3
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ActivitiService.java
  8. 31 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TFCustomFlowListService.java
  9. 1 9
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TFCustomFlowService.java
  10. 105 53
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ActivitiServiceImpl.java
  11. 46 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TFCustomFlowListServiceImpl.java
  12. 1 15
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TFCustomFlowServiceImpl.java
  13. 5 0
      distributed-print-business/src/main/resources/mapper/TFCustomFlowListMapper.xml
  14. 18 5
      distributed-print-business/src/main/resources/mapper/TFCustomFlowMapper.xml
  15. 15 12
      distributed-print/src/main/java/com/qmth/distributed/print/api/TFCustomFlowController.java
  16. 1 0
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/contant/SystemConstant.java
  17. 1 1
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/enums/FlowStatusEnum.java

+ 0 - 12
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TFCustomFlow.java

@@ -61,10 +61,6 @@ public class TFCustomFlow extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "流程过程变量数据")
     private String flowProcessVar;
 
-    @ApiModelProperty(value = "流程id")
-    @JsonSerialize(using = ToStringSerializer.class)
-    private Long flowId;
-
     public Long getSchoolId() {
         return schoolId;
     }
@@ -84,14 +80,6 @@ public class TFCustomFlow extends BaseEntity implements Serializable {
         insertInfo(userId);
     }
 
-    public Long getFlowId() {
-        return flowId;
-    }
-
-    public void setFlowId(Long flowId) {
-        this.flowId = flowId;
-    }
-
     public String getFlowProcessVar() {
         return flowProcessVar;
     }

+ 80 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TFCustomFlowList.java

@@ -0,0 +1,80 @@
+package com.qmth.distributed.print.business.entity;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.teachcloud.common.base.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 自定义流程列表
+ * </p>
+ *
+ * @author wangliang
+ * @since 2022-02-18
+ */
+@ApiModel(value = "TFCustomFlowList对象", description = "自定义流程列表")
+public class TFCustomFlowList extends BaseEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "自定义流程id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long tFCustomFlowId;
+
+    @ApiModelProperty(value = "流程id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long flowId;
+
+    @ApiModelProperty(value = "流程过程变量数据")
+    private String flowProcessVar;
+
+    public TFCustomFlowList() {
+
+    }
+
+    public TFCustomFlowList(Long tFCustomFlowId, Long userId) {
+        this.tFCustomFlowId = tFCustomFlowId;
+        this.insertInfo(userId);
+    }
+
+    public TFCustomFlowList(Long tFCustomFlowId, String flowProcessVar, Long userId) {
+        this.tFCustomFlowId = tFCustomFlowId;
+        this.flowProcessVar = flowProcessVar;
+        this.insertInfo(userId);
+    }
+
+    public TFCustomFlowList(Long tFCustomFlowId, Long flowId, String flowProcessVar, Long userId) {
+        this.tFCustomFlowId = tFCustomFlowId;
+        this.flowId = flowId;
+        this.flowProcessVar = flowProcessVar;
+        this.insertInfo(userId);
+    }
+
+    public Long gettFCustomFlowId() {
+        return tFCustomFlowId;
+    }
+
+    public void settFCustomFlowId(Long tFCustomFlowId) {
+        this.tFCustomFlowId = tFCustomFlowId;
+    }
+
+    public Long getFlowId() {
+        return flowId;
+    }
+
+    public void setFlowId(Long flowId) {
+        this.flowId = flowId;
+    }
+
+    public String getFlowProcessVar() {
+        return flowProcessVar;
+    }
+
+    public void setFlowProcessVar(String flowProcessVar) {
+        this.flowProcessVar = flowProcessVar;
+    }
+}

+ 0 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TFFlowApprove.java

@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.qmth.teachcloud.common.base.BaseEntity;
-import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.enums.FlowApproveSetupEnum;
 import com.qmth.teachcloud.common.enums.FlowStatusEnum;
 import io.swagger.annotations.ApiModel;
@@ -73,7 +72,6 @@ public class TFFlowApprove extends BaseEntity implements Serializable {
     }
 
     public TFFlowApprove(Long schoolId, Long orgId, Long flowId, Long approveId, FlowStatusEnum status, Long userId) {
-        setId(SystemConstant.getDbUuid());
         this.schoolId = schoolId;
         this.orgId = orgId;
         this.flowId = flowId;

+ 12 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TFFlowLog.java

@@ -79,7 +79,6 @@ public class TFFlowLog extends BaseEntity implements Serializable {
     }
 
     public TFFlowLog(Long schoolId, Long orgId, Long flowId, Long taskId, Long approveId, Long userId, String approveRemark) {
-        setId(SystemConstant.getDbUuid());
         this.schoolId = schoolId;
         this.orgId = orgId;
         this.flowId = flowId;
@@ -89,6 +88,18 @@ public class TFFlowLog extends BaseEntity implements Serializable {
         insertInfo(userId);
     }
 
+    public TFFlowLog(Long schoolId, Long orgId, Long flowId, Long taskId, Long approveId, Long userId, String approveRemark, String pendApproveId, FlowApproveOperationEnum approveOperation) {
+        this.schoolId = schoolId;
+        this.orgId = orgId;
+        this.flowId = flowId;
+        this.approveId = approveId;
+        this.taskId = taskId;
+        this.approveRemark = approveRemark;
+        this.pendApproveId = pendApproveId;
+        this.approveOperation = approveOperation;
+        insertInfo(userId);
+    }
+
     public TFFlowLog(Long schoolId, Long orgId, Long flowId, Long taskId, Long userId, String approveRemark, FlowApproveOperationEnum approveOperation, Long approveId, String pendApproveId) {
         setId(SystemConstant.getDbUuid());
         this.schoolId = schoolId;

+ 16 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/TFCustomFlowListMapper.java

@@ -0,0 +1,16 @@
+package com.qmth.distributed.print.business.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.qmth.distributed.print.business.entity.TFCustomFlowList;
+
+/**
+ * <p>
+ * 自定义流程列表 Mapper 接口
+ * </p>
+ *
+ * @author wangliang
+ * @since 2022-02-18
+ */
+public interface TFCustomFlowListMapper extends BaseMapper<TFCustomFlowList> {
+
+}

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

@@ -22,5 +22,5 @@ public interface TFCustomFlowMapper extends BaseMapper<TFCustomFlow> {
      * @param type
      * @return
      */
-    Integer findMaxVersion(@Param("schoolId") Long schoolId, @Param("orgId") Long orgId, @Param("type") String type);
+    TFCustomFlow findMaxVersion(@Param("schoolId") Long schoolId, @Param("orgId") Long orgId, @Param("type") String type);
 }

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

@@ -151,10 +151,10 @@ public interface ActivitiService {
     public Map<String, Object> dynamicBuildBpmn(CustomFlowSaveDto customFlowSaveDto, String id) throws IOException;
 
     /**
-     * 修改启动流程候选人
+     * 启动自定义流程
      *
-     * @param customFlowId
+     * @param taskId
      * @param approveId
      */
-    public void customFlowStartUpdateApproveId(Long customFlowId, Long approveId);
+    public void customFlowStart(Long taskId, Long approveId);
 }

+ 31 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TFCustomFlowListService.java

@@ -0,0 +1,31 @@
+package com.qmth.distributed.print.business.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.distributed.print.business.entity.TFCustomFlowList;
+
+/**
+ * <p>
+ * 自定义流程列表 服务类
+ * </p>
+ *
+ * @author wangliang
+ * @since 2022-02-18
+ */
+public interface TFCustomFlowListService extends IService<TFCustomFlowList> {
+
+    /**
+     * 根据自定义流程id查找
+     *
+     * @param customFlowId
+     * @return
+     */
+    TFCustomFlowList findByCustomFlowId(Long customFlowId);
+
+    /**
+     * 根据流程id查找
+     *
+     * @param flowId
+     * @return
+     */
+    TFCustomFlowList findByFlowId(Long flowId);
+}

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

@@ -22,13 +22,5 @@ public interface TFCustomFlowService extends IService<TFCustomFlow> {
      * @param type
      * @return
      */
-    Integer findMaxVersion(Long schoolId, Long orgId, TFCustomTypeEnum type);
-
-    /**
-     * 根据流程id查找
-     *
-     * @param flowId
-     * @return
-     */
-    TFCustomFlow findByFlowId(Long flowId);
+    TFCustomFlow findMaxVersion(Long schoolId, Long orgId, TFCustomTypeEnum type);
 }

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

@@ -10,10 +10,7 @@ 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;
@@ -116,6 +113,9 @@ public class ActivitiServiceImpl implements ActivitiService {
     @Resource
     TFCustomFlowService tfCustomFlowService;
 
+    @Resource
+    TFCustomFlowListService tfCustomFlowListService;
+
     /**
      * 注册流程
      *
@@ -184,48 +184,69 @@ public class ActivitiServiceImpl implements ActivitiService {
     @Override
     public ProcessInstance flowStart(Map<String, Object> map) {
         String id = (String) map.get(SystemConstant.ID);
-        BpmnModel model = (BpmnModel) map.get(SystemConstant.MODEL);
         Map flowProcessVarMap = (Map) map.get(SystemConstant.FLOW_PROCESS_VAR_MAP);
         Map<String, CustomFlowVarDto> agginessMap = (Map<String, CustomFlowVarDto>) flowProcessVarMap.get(SystemConstant.AGGINESS_MAP);
         Map<String, Object> varMap = new HashMap<>();
-        agginessMap.forEach((k, v) -> {
-            if (v instanceof CustomFlowVarDto) {
-                CustomFlowVarDto customFlowVarDto = (CustomFlowVarDto) v;
-                varMap.computeIfAbsent(customFlowVarDto.getFlowTaskVar(), s -> customFlowVarDto.getApproveIds().size() == 1 ? customFlowVarDto.getApproveIds().get(0) : customFlowVarDto.getApproveIds());
-            }
-        });
-
-        //部署流程
-        String bpmnName = id + DefaultInstanceConvertToMultiInstance.FLOW_BPMN_MODEL_NAME;
-        String bpmnPngName = id + DefaultInstanceConvertToMultiInstance.FLOW_BPMN_PNG_NAME;
-        String bpmnProcessName = id + DefaultInstanceConvertToMultiInstance.FLOW_BPMN_PROCESS_NAME;
-        String bpmnDeploymentName = id + DefaultInstanceConvertToMultiInstance.FLOW_BPMN_DEPLOYMENT_NAME;
-        Deployment deployment = repositoryService.createDeployment().addBpmnModel(bpmnName, model).name(bpmnDeploymentName).deploy();
-
+        Gson gson = new Gson();
+        for (Map.Entry<String, CustomFlowVarDto> entry : agginessMap.entrySet()) {
+            CustomFlowVarDto customFlowVarDto = gson.fromJson(gson.toJson(entry.getValue()), CustomFlowVarDto.class);
+            varMap.computeIfAbsent(customFlowVarDto.getFlowTaskVar(), s -> customFlowVarDto.getApproveIds().size() == 1 ? customFlowVarDto.getApproveIds().get(0) : customFlowVarDto.getApproveIds());
+        }
         //启动流程
         ProcessInstance processInstance = varMap.size() > 0 ? runtimeService.startProcessInstanceByKey(id, varMap) : runtimeService.startProcessInstanceByKey(id);
+        map.computeIfAbsent(SystemConstant.PROCESS_DEFINITION_ID, v -> processInstance.getProcessDefinitionId());
+        map.computeIfAbsent(SystemConstant.FLOW_ID, v -> processInstance.getProcessInstanceId());
+        map.computeIfAbsent(SystemConstant.FLOW_STATUS, v -> FlowStatusEnum.START);
+        this.createFlowPicture(map);
+        this.flowApproveStart(map);
+        return processInstance;
+    }
+
+    /**
+     * 创建流程图片
+     *
+     * @param map
+     */
+    protected void createFlowPicture(Map<String, Object> map) {
+        String id = (String) map.get(SystemConstant.FLOW_LIST_ID);
+        String processDefinitionId = (String) map.get(SystemConstant.PROCESS_DEFINITION_ID);
+        String bpmnPngName = id + DefaultInstanceConvertToMultiInstance.FLOW_BPMN_PNG_NAME;
 
-        //保存png图片和xml文件(这一步可做可不做)
-        InputStream processDiagram = repositoryService.getProcessDiagram(processInstance.getProcessDefinitionId());
+        //保存png图片(这一步可做可不做)
+        InputStream processDiagram = repositoryService.getProcessDiagram(processDefinitionId);
         try {
             FileUtils.copyInputStreamToFile(processDiagram, new File(SystemConstant.TEMP_FILES_DIR + File.separator + DefaultInstanceConvertToMultiInstance.BPMN_NAME + File.separator + bpmnPngName));
         } catch (IOException e) {
             e.printStackTrace();
         }
+    }
+
+    /**
+     * 部署流程
+     *
+     * @param map
+     * @return
+     */
+    protected Deployment flowDeployment(Map<String, Object> map) {
+        String id = (String) map.get(SystemConstant.ID);
+        BpmnModel model = (BpmnModel) map.get(SystemConstant.MODEL);
 
-//        InputStream processBpmn = repositoryService.getResourceAsStream(deployment.getId(), bpmnName);
-//        FileUtils.copyInputStreamToFile(processBpmn, new File(SystemConstant.TEMP_FILES_DIR + File.separator + DefaultInstanceConvertToMultiInstance.BPMN_NAME + File.separator + id + "-multiple-process.bpmn20.xml"));
+        //部署流程
+        String bpmnName = id + DefaultInstanceConvertToMultiInstance.FLOW_BPMN_MODEL_NAME;
+        String bpmnDeploymentName = id + DefaultInstanceConvertToMultiInstance.FLOW_BPMN_DEPLOYMENT_NAME;
+        String bpmnProcessName = id + DefaultInstanceConvertToMultiInstance.FLOW_BPMN_PROCESS_NAME;
+
+        Deployment deployment = repositoryService.createDeployment().addBpmnModel(bpmnName, model).name(bpmnDeploymentName).deploy();
+        map.remove(SystemConstant.MODEL);
 
+        //保存xml文件(这一步可做可不做)
         InputStream processBpmn = repositoryService.getResourceAsStream(deployment.getId(), bpmnName);
         try {
             FileUtils.copyInputStreamToFile(processBpmn, new File(SystemConstant.TEMP_FILES_DIR + File.separator + DefaultInstanceConvertToMultiInstance.BPMN_NAME + File.separator + bpmnProcessName));
         } catch (IOException e) {
             e.printStackTrace();
         }
-        map.computeIfAbsent(SystemConstant.PROCESS_DEFINITION_ID, v -> processInstance.getProcessDefinitionId());
-        map.computeIfAbsent(SystemConstant.FLOW_ID, v -> processInstance.getProcessInstanceId());
-        map.remove(SystemConstant.MODEL);
-        return processInstance;
+        return deployment;
     }
 
     /**
@@ -306,8 +327,20 @@ public class ActivitiServiceImpl implements ActivitiService {
         Optional.ofNullable(map.get(SystemConstant.FLOW_STATUS)).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程状态不能为空"));
         FlowStatusEnum flowStatusEnum = (FlowStatusEnum) map.get(SystemConstant.FLOW_STATUS);
 
-        Long approveId = Objects.nonNull(map.get(SystemConstant.APPROVE_ID)) ? (Long) map.get(SystemConstant.APPROVE_ID) : null;
-        tfFlowApproveService.save(new TFFlowApprove(sysUser.getSchoolId(), sysUser.getOrgId(), SystemConstant.convertIdToLong(flowId), approveId, flowStatusEnum, sysUser.getId()));
+        String approveId = Objects.nonNull(map.get(SystemConstant.APPROVE_ID)) ? (String) map.get(SystemConstant.APPROVE_ID) : null;
+        tfFlowApproveService.save(new TFFlowApprove(sysUser.getSchoolId(), sysUser.getOrgId(), SystemConstant.convertIdToLong(flowId), sysUser.getId(), flowStatusEnum, sysUser.getId()));
+
+        Long examTaskId = (Long) map.get(SystemConstant.EXAM_TASK_ID);
+        //TODO 测试用
+        ExamTask examTask = examTaskService.getById(examTaskId);
+        examTask.setFlowId(SystemConstant.convertIdToLong(flowId));
+        examTaskService.updateById(examTask);
+
+        TExamTaskFlow tExamTaskFlow = tExamTaskFlowService.findByFlowLevel(examTaskId);
+        tExamTaskFlow.setFlowId(SystemConstant.convertIdToLong(flowId));
+        tExamTaskFlowService.updateById(tExamTaskFlow);
+
+        tfFlowLogService.save(new TFFlowLog(sysUser.getSchoolId(), sysUser.getOrgId(), SystemConstant.convertIdToLong(flowId), examTaskId, sysUser.getId(), sysUser.getId(), "提交流程", approveId, FlowApproveOperationEnum.SUBMIT));
     }
 
     /**
@@ -345,8 +378,8 @@ public class ActivitiServiceImpl implements ActivitiService {
             Map<String, Object> objectMap = new HashMap<>();
             TFFlowLog tfFlowLog = null;
 
-            TFCustomFlow tfCustomFlow = tfCustomFlowService.findByFlowId(flowId);
-            Map<String, Object> flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlow);
+            TFCustomFlowList tfCustomFlowList = tfCustomFlowListService.findByFlowId(flowId);
+            Map<String, Object> flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlowList);
 
             String remark = null;
             FlowTaskResult currFlowTaskResult = null, nextFlowTaskResult = null;
@@ -1091,8 +1124,8 @@ public class ActivitiServiceImpl implements ActivitiService {
             multiInstance = true;
         }
 
-        TFCustomFlow tfCustomFlow = tfCustomFlowService.findByFlowId(tfFlowApprove.getFlowId());
-        Map<String, Object> flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlow);
+        TFCustomFlowList tfCustomFlowList = tfCustomFlowListService.findByFlowId(tfFlowApprove.getFlowId());
+        Map<String, Object> flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlowList);
         Map<String, CustomFlowVarDto> agginessMap = (Map<String, CustomFlowVarDto>) flowProcessVarMap.get(SystemConstant.AGGINESS_MAP);
         if (Objects.nonNull(tfFlowApprove.getTransferAssignee())) {
             agginessMap = JacksonUtil.readJson(tfFlowApprove.getTransferAssignee(), Map.class);
@@ -2041,7 +2074,7 @@ public class ActivitiServiceImpl implements ActivitiService {
         map.computeIfAbsent(SystemConstant.ID, v -> id);
         map.computeIfAbsent(SystemConstant.MODEL, v -> model);
         map.computeIfAbsent(SystemConstant.FLOW_PROCESS_VAR_MAP, v -> flowProcessVarMap);
-        this.flowStart(map);
+        this.flowDeployment(map);
         return map;
     }
 
@@ -2173,42 +2206,61 @@ public class ActivitiServiceImpl implements ActivitiService {
     }
 
     /**
-     * 修改启动流程候选人
+     * 启动自定义流程
      *
-     * @param customFlowId
+     * @param taskId
      * @param approveId
      */
     @Override
     @Transactional
-    public void customFlowStartUpdateApproveId(Long customFlowId, Long approveId) {
-        TFCustomFlow tfCustomFlow = tfCustomFlowService.getById(customFlowId);
+    public void customFlowStart(Long taskId, Long approveId) {
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        TFCustomFlow tfCustomFlow = tfCustomFlowService.findMaxVersion(sysUser.getSchoolId(), sysUser.getOrgId(), TFCustomTypeEnum.ELECTRON_FLOW);
+        Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到自定义流程数据"));
+
+        TFCustomFlowList tfCustomFlowList = new TFCustomFlowList(tfCustomFlow.getId(), sysUser.getId());
         Map<String, Object> flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlow);
-        Task task = taskService.createTaskQuery().processInstanceId(String.valueOf(tfCustomFlow.getFlowId())).singleResult();
-        task.setAssignee(String.valueOf(approveId));
-        taskService.saveTask(task);
-        Map<String, Object> map = JacksonUtil.readJson(tfCustomFlow.getFlowProcessVar(), Map.class);
         Map<String, CustomFlowVarDto> agginessMap = (Map<String, CustomFlowVarDto>) flowProcessVarMap.get(SystemConstant.AGGINESS_MAP);
         agginessMap.put(CustomFlowTypeEnum.USER_TASK.getId() + DefaultInstanceConvertToMultiInstance.DEFAULT_USER_TASK, new CustomFlowVarDto(SystemConstant.APPROVE_ID, new ArrayList(Arrays.asList(String.valueOf(approveId)))));
         flowProcessVarMap.put(SystemConstant.AGGINESS_MAP, agginessMap);
-        map.put(SystemConstant.FLOW_PROCESS_VAR_MAP, flowProcessVarMap);
-        tfCustomFlow.setFlowProcessVar(JacksonUtil.parseJson(map));
-        tfCustomFlowService.updateById(tfCustomFlow);
 
-        map.put(SystemConstant.FLOW_ID, String.valueOf(tfCustomFlow.getFlowId()));
-        map.put(SystemConstant.FLOW_STATUS, FlowStatusEnum.START);
-        map.put(SystemConstant.APPROVE_ID, approveId);
-        this.flowApproveStart(map);
+        Map<String, Object> map = new HashMap<>();
+        map.computeIfAbsent(SystemConstant.ID, v -> tfCustomFlow.getFlowKey());
+        map.computeIfAbsent(SystemConstant.FLOW_PROCESS_VAR_MAP, v -> flowProcessVarMap);
+        map.computeIfAbsent(SystemConstant.FLOW_LIST_ID, v -> String.valueOf(tfCustomFlowList.getId()));
+        map.computeIfAbsent(SystemConstant.APPROVE_ID, v -> String.valueOf(approveId));
+        map.computeIfAbsent(SystemConstant.EXAM_TASK_ID, v -> taskId);
+        this.flowStart(map);
+
+        tfCustomFlow.setActFlowId((String) map.get(SystemConstant.PROCESS_DEFINITION_ID));
+        tfCustomFlowList.setFlowId(SystemConstant.convertIdToLong((String) map.get(SystemConstant.FLOW_ID)));
+
+        map.remove(SystemConstant.APPROVE_ID);
+        map.remove(SystemConstant.FLOW_LIST_ID);
+        map.remove(SystemConstant.PROCESS_DEFINITION_ID);
+        map.remove(SystemConstant.FLOW_STATUS);
+        tfCustomFlowList.setFlowProcessVar(JacksonUtil.parseJson(map));
+        tfCustomFlow.setUpdateId(sysUser.getId());
+        tfCustomFlowListService.save(tfCustomFlowList);
+        tfCustomFlowService.updateById(tfCustomFlow);
     }
 
     /**
      * 获取流程变量
      *
-     * @param tfCustomFlow
+     * @param o
      * @return
      */
-    protected Map<String, Object> getFlowProcessVarMap(TFCustomFlow tfCustomFlow) {
-        Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到自定义流程数据"));
-        Map<String, Object> varMap = JacksonUtil.readJson(tfCustomFlow.getFlowProcessVar(), Map.class);
+    protected Map<String, Object> getFlowProcessVarMap(Object o) {
+        Optional.ofNullable(o).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到自定义流程数据"));
+        Map<String, Object> varMap = null;
+        if (o instanceof TFCustomFlow) {
+            o = (TFCustomFlow) o;
+            varMap = JacksonUtil.readJson(((TFCustomFlow) o).getFlowProcessVar(), Map.class);
+        } else if (o instanceof TFCustomFlowList) {
+            o = (TFCustomFlowList) o;
+            varMap = JacksonUtil.readJson(((TFCustomFlowList) o).getFlowProcessVar(), Map.class);
+        }
         Optional.ofNullable(varMap).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("自定义流程变量数据为空"));
         Map<String, Object> flowProcessVarMap = (Map<String, Object>) varMap.get(SystemConstant.FLOW_PROCESS_VAR_MAP);
         Optional.ofNullable(flowProcessVarMap).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("自定义流程节点变量数据为空"));

+ 46 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TFCustomFlowListServiceImpl.java

@@ -0,0 +1,46 @@
+package com.qmth.distributed.print.business.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.distributed.print.business.entity.TFCustomFlowList;
+import com.qmth.distributed.print.business.mapper.TFCustomFlowListMapper;
+import com.qmth.distributed.print.business.service.TFCustomFlowListService;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 自定义流程列表 服务实现类
+ * </p>
+ *
+ * @author wangliang
+ * @since 2022-02-18
+ */
+@Service
+public class TFCustomFlowListServiceImpl extends ServiceImpl<TFCustomFlowListMapper, TFCustomFlowList> implements TFCustomFlowListService {
+
+    /**
+     * 根据自定义流程id查找
+     *
+     * @param customFlowId
+     * @return
+     */
+    @Override
+    public TFCustomFlowList findByCustomFlowId(Long customFlowId) {
+        QueryWrapper<TFCustomFlowList> tfCustomFlowListQueryWrapper = new QueryWrapper<>();
+        tfCustomFlowListQueryWrapper.lambda().eq(TFCustomFlowList::gettFCustomFlowId, customFlowId);
+        return this.getOne(tfCustomFlowListQueryWrapper);
+    }
+
+    /**
+     * 根据流程id查找
+     *
+     * @param flowId
+     * @return
+     */
+    @Override
+    public TFCustomFlowList findByFlowId(Long flowId) {
+        QueryWrapper<TFCustomFlowList> tfCustomFlowListQueryWrapper = new QueryWrapper<>();
+        tfCustomFlowListQueryWrapper.lambda().eq(TFCustomFlowList::getFlowId, flowId);
+        return this.getOne(tfCustomFlowListQueryWrapper);
+    }
+}

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

@@ -1,6 +1,5 @@
 package com.qmth.distributed.print.business.service.impl;
 
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.distributed.print.business.entity.TFCustomFlow;
 import com.qmth.distributed.print.business.enums.TFCustomTypeEnum;
@@ -34,20 +33,7 @@ public class TFCustomFlowServiceImpl extends ServiceImpl<TFCustomFlowMapper, TFC
      * @return
      */
     @Override
-    public Integer findMaxVersion(Long schoolId, Long orgId, TFCustomTypeEnum type) {
+    public TFCustomFlow findMaxVersion(Long schoolId, Long orgId, TFCustomTypeEnum type) {
         return tfCustomFlowMapper.findMaxVersion(schoolId, orgId, Objects.nonNull(type) ? type.name() : null);
     }
-
-    /**
-     * 根据流程id查找
-     *
-     * @param flowId
-     * @return
-     */
-    @Override
-    public TFCustomFlow findByFlowId(Long flowId) {
-        QueryWrapper<TFCustomFlow> tfCustomFlowQueryWrapper = new QueryWrapper<>();
-        tfCustomFlowQueryWrapper.lambda().eq(TFCustomFlow::getFlowId, flowId);
-        return this.getOne(tfCustomFlowQueryWrapper);
-    }
 }

+ 5 - 0
distributed-print-business/src/main/resources/mapper/TFCustomFlowListMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!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.TFCustomFlowListMapper">
+
+</mapper>

+ 18 - 5
distributed-print-business/src/main/resources/mapper/TFCustomFlowMapper.xml

@@ -2,17 +2,30 @@
 <!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.TFCustomFlowMapper">
 
-    <select id="findMaxVersion" resultType="java.lang.Integer">
-        select max(t.version) from t_f_custom_flow t
+    <select id="findMaxVersion" resultType="com.qmth.distributed.print.business.entity.TFCustomFlow">
+        select * from t_f_custom_flow tfcf
         <where>
+            1 = 1 and tfcf.version =
+            (select max(t.version) from t_f_custom_flow t
+            <where>
+                <if test="schoolId != null and schoolId != ''">
+                    and t.school_id = #{schoolId}
+                </if>
+                <if test="orgId != null and orgId != ''">
+                    and t.org_id = #{orgId}
+                </if>
+                <if test="type != null and type != ''">
+                    and t.type = #{type}
+                </if>
+            </where>)
             <if test="schoolId != null and schoolId != ''">
-                and t.school_id = #{schoolId}
+                and tfcf.school_id = #{schoolId}
             </if>
             <if test="orgId != null and orgId != ''">
-                and t.org_id = #{orgId}
+                and tfcf.org_id = #{orgId}
             </if>
             <if test="type != null and type != ''">
-                and t.type = #{type}
+                and tfcf.type = #{type}
             </if>
         </where>
     </select>

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

@@ -13,11 +13,13 @@ import com.qmth.distributed.print.business.bean.result.FlowTaskApprovePeopleAllR
 import com.qmth.distributed.print.business.bean.result.FlowTaskResult;
 import com.qmth.distributed.print.business.entity.TFCustomFlow;
 import com.qmth.distributed.print.business.service.ActivitiService;
+import com.qmth.distributed.print.business.service.TFCustomFlowListService;
 import com.qmth.distributed.print.business.service.TFCustomFlowService;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.BasicSchool;
 import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
+import com.qmth.teachcloud.common.enums.FlowStatusEnum;
 import com.qmth.teachcloud.common.service.CommonCacheService;
 import com.qmth.teachcloud.common.util.*;
 import io.swagger.annotations.*;
@@ -66,6 +68,9 @@ public class TFCustomFlowController {
     @Resource
     CommonCacheService commonCacheService;
 
+    @Resource
+    TFCustomFlowListService tfCustomFlowListService;
+
     @ApiOperation(value = "保存和发布流程")
     @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = ResultUtil.class)})
     @RequestMapping(value = "/save", method = RequestMethod.POST)
@@ -84,21 +89,19 @@ public class TFCustomFlowController {
             throw ExceptionResultEnum.ERROR.exception("正在发布中,请稍候再试!");
         }
         try {
-            Integer dbVersion = tfCustomFlowService.findMaxVersion(customFlowSaveDto.getSchoolId(), customFlowSaveDto.getOrgId(), customFlowSaveDto.getType());
+            TFCustomFlow dbTfCustomFlow = tfCustomFlowService.findMaxVersion(customFlowSaveDto.getSchoolId(), customFlowSaveDto.getOrgId(), customFlowSaveDto.getType());
             TFCustomFlow tfCustomFlow = new TFCustomFlow(customFlowSaveDto.getSchoolId(), customFlowSaveDto.getOrgId(), customFlowSaveDto.getName(), customFlowSaveDto.getType(), customFlowSaveDto.getPublish(), JacksonUtil.parseJson(customFlowSaveDto.getCustomFlowLists()), sysUser.getId(), flowBpmnId);
             AtomicInteger atomicInteger = null;
-            if (Objects.isNull(dbVersion)) {//新增
+            if (Objects.isNull(dbTfCustomFlow)) {//新增
                 atomicInteger = new AtomicInteger(1);
                 tfCustomFlow.setVersion(atomicInteger.get());
             } else {//版本号递增
-                atomicInteger = new AtomicInteger(dbVersion);
+                atomicInteger = new AtomicInteger(dbTfCustomFlow.getVersion());
                 tfCustomFlow.setVersion(atomicInteger.incrementAndGet());
             }
             //自定义流程处理开始
             Map<String, Object> map = activitiService.dynamicBuildBpmn(customFlowSaveDto, flowBpmnId);
             tfCustomFlow.setFlowProcessVar(JacksonUtil.parseJson(map));
-            tfCustomFlow.setActFlowId((String) map.get(SystemConstant.PROCESS_DEFINITION_ID));
-            tfCustomFlow.setFlowId(SystemConstant.convertIdToLong((String) map.get(SystemConstant.FLOW_ID)));
             tfCustomFlowService.save(tfCustomFlow);
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
@@ -117,9 +120,9 @@ public class TFCustomFlowController {
     @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = ResultUtil.class)})
     @RequestMapping(value = "/testStart", method = RequestMethod.POST)
     @Transactional
-    public Result testStart(@ApiParam(value = "流程id", required = true) @RequestParam String id) {
-        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-        activitiService.customFlowStartUpdateApproveId(SystemConstant.convertIdToLong(id), sysUser.getId());
+    public Result testStart(@ApiParam(value = "命题任务id", required = true) @RequestParam String taskId,
+                            @ApiParam(value = "命题老师id", required = true) @RequestParam String approveId) {
+        activitiService.customFlowStart(SystemConstant.convertIdToLong(taskId), SystemConstant.convertIdToLong(approveId));
         return ResultUtil.ok(true);
     }
 
@@ -177,11 +180,11 @@ public class TFCustomFlowController {
     @ApiOperation(value = "流程审批记录列表")
     @ApiResponses({@ApiResponse(code = 200, message = "流程审批记录信息", response = ResultUtil.class)})
     @RequestMapping(value = "/approve/list", method = RequestMethod.POST)
-    public Result taskApproveList(@ApiParam(value = "状态", required = false) @RequestParam(required = false) String status,
-                                  @ApiParam(value = "发起人名称", required = false) @RequestParam(required = false) String startName,
+    public Result taskApproveList(@ApiParam(value = "状态", required = false) @RequestParam(required = false) FlowStatusEnum status,
+                                  @ApiParam(value = "提交人名称", required = false) @RequestParam(required = false) String createUserName,
                                   @ApiParam(value = "教研室", required = false) @RequestParam(required = false) Long teachingRoomId,
-                                  @ApiParam(value = "提交开始时间", required = false) @RequestParam(required = false) Long createStartTime,
-                                  @ApiParam(value = "提交结束时间", required = false) @RequestParam(required = false) Long createEndTime,
+                                  @ApiParam(value = "提交开始时间", required = false) @RequestParam(required = false) Long startTime,
+                                  @ApiParam(value = "提交结束时间", required = false) @RequestParam(required = false) Long endTime,
                                   @ApiParam(value = "页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
                                   @ApiParam(value = "数量", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
         return ResultUtil.ok(true);

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

@@ -57,6 +57,7 @@ public class SystemConstant {
     public static final String HTTP = "http://";
     public static final String ID = "id";
     public static final String MODEL = "model";
+    public static final String FLOW_LIST_ID = "flowListId";
     public static final String FLOW_PROCESS_VAR_MAP = "flowProcessVarMap";
     public static final String PROCESS_DEFINITION_ID = "processDefinitionId";
     public static final String FILE = "file";

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

@@ -11,7 +11,7 @@ import java.util.Objects;
  */
 public enum FlowStatusEnum {
 
-    START("已开始"),
+    START("待审批"),
 
     AUDITING("审核中"),