Browse Source

流程调整

wangliang 1 year ago
parent
commit
0beb2c62a8

+ 10 - 33
sop-business/src/main/java/com/qmth/sop/business/bean/FormPropertyBean.java

@@ -1,18 +1,14 @@
 package com.qmth.sop.business.bean;
 package com.qmth.sop.business.bean;
 
 
 import com.fasterxml.jackson.annotation.JsonInclude;
 import com.fasterxml.jackson.annotation.JsonInclude;
-import com.qmth.sop.business.bean.result.FlowFormWidgetResult;
+import com.qmth.sop.business.bean.result.FlowTaskResult;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 
 
 import java.io.Serializable;
 import java.io.Serializable;
-import java.util.List;
 
 
 @JsonInclude(JsonInclude.Include.NON_NULL)
 @JsonInclude(JsonInclude.Include.NON_NULL)
 public class FormPropertyBean implements Serializable {
 public class FormPropertyBean implements Serializable {
 
 
-    @ApiModelProperty(value = "流程名称")
-    String flowName;
-
     @ApiModelProperty(value = "流程id")
     @ApiModelProperty(value = "流程id")
     String flowId;
     String flowId;
 
 
@@ -25,35 +21,24 @@ public class FormPropertyBean implements Serializable {
     @ApiModelProperty(value = "用户id")
     @ApiModelProperty(value = "用户id")
     String userId;
     String userId;
 
 
-    @ApiModelProperty(value = "taskKey")
-    String taskDefinitionKey;
-
     @ApiModelProperty(value = "动态表单")
     @ApiModelProperty(value = "动态表单")
-    List<FlowFormWidgetResult> formProperty;
+    FlowTaskResult setupMap;
 
 
     public FormPropertyBean() {
     public FormPropertyBean() {
 
 
     }
     }
 
 
-    public FormPropertyBean(String flowId, String taskId, List<FlowFormWidgetResult> formProperty) {
+    public FormPropertyBean(String flowId, String taskId, FlowTaskResult setupMap) {
         this.flowId = flowId;
         this.flowId = flowId;
         this.taskId = taskId;
         this.taskId = taskId;
-        this.formProperty = formProperty;
+        this.setupMap = setupMap;
     }
     }
 
 
-    public FormPropertyBean(String flowId, String taskId, String userId, List<FlowFormWidgetResult> formProperty) {
+    public FormPropertyBean(String flowId, String taskId, String userId, FlowTaskResult setupMap) {
         this.flowId = flowId;
         this.flowId = flowId;
         this.taskId = taskId;
         this.taskId = taskId;
         this.userId = userId;
         this.userId = userId;
-        this.formProperty = formProperty;
-    }
-
-    public String getFlowName() {
-        return flowName;
-    }
-
-    public void setFlowName(String flowName) {
-        this.flowName = flowName;
+        this.setupMap = setupMap;
     }
     }
 
 
     public String getSopId() {
     public String getSopId() {
@@ -64,14 +49,6 @@ public class FormPropertyBean implements Serializable {
         this.sopId = sopId;
         this.sopId = sopId;
     }
     }
 
 
-    public String getTaskDefinitionKey() {
-        return taskDefinitionKey;
-    }
-
-    public void setTaskDefinitionKey(String taskDefinitionKey) {
-        this.taskDefinitionKey = taskDefinitionKey;
-    }
-
     public String getUserId() {
     public String getUserId() {
         return userId;
         return userId;
     }
     }
@@ -96,11 +73,11 @@ public class FormPropertyBean implements Serializable {
         this.taskId = taskId;
         this.taskId = taskId;
     }
     }
 
 
-    public List<FlowFormWidgetResult> getFormProperty() {
-        return formProperty;
+    public FlowTaskResult getSetupMap() {
+        return setupMap;
     }
     }
 
 
-    public void setFormProperty(List<FlowFormWidgetResult> formProperty) {
-        this.formProperty = formProperty;
+    public void setSetupMap(FlowTaskResult setupMap) {
+        this.setupMap = setupMap;
     }
     }
 }
 }

+ 0 - 14
sop-business/src/main/java/com/qmth/sop/business/bean/result/FlowTaskResult.java

@@ -1,7 +1,5 @@
 package com.qmth.sop.business.bean.result;
 package com.qmth.sop.business.bean.result;
 
 
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.NotNull;
 
 
@@ -17,10 +15,6 @@ import java.util.List;
  */
  */
 public class FlowTaskResult implements Serializable, Comparable<FlowTaskResult> {
 public class FlowTaskResult implements Serializable, Comparable<FlowTaskResult> {
 
 
-    @ApiModelProperty(value = "流程id")
-    @JsonSerialize(using = ToStringSerializer.class)
-    private Long flowId;
-
     @ApiModelProperty(value = "流程节点名称")
     @ApiModelProperty(value = "流程节点名称")
     private String taskName;
     private String taskName;
 
 
@@ -44,14 +38,6 @@ public class FlowTaskResult implements Serializable, Comparable<FlowTaskResult>
         this.formProperty = formProperty;
         this.formProperty = formProperty;
     }
     }
 
 
-    public Long getFlowId() {
-        return flowId;
-    }
-
-    public void setFlowId(Long flowId) {
-        this.flowId = flowId;
-    }
-
     public String getTaskName() {
     public String getTaskName() {
         return taskName;
         return taskName;
     }
     }

+ 22 - 0
sop-business/src/main/java/com/qmth/sop/business/entity/TFCustomFlowEntity.java

@@ -32,6 +32,28 @@ public class TFCustomFlowEntity extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "流程过程变量")
     @ApiModelProperty(value = "流程过程变量")
     private String flowProcessVar;
     private String flowProcessVar;
 
 
+    public TFCustomFlowEntity() {
+
+    }
+
+    public TFCustomFlowEntity(Long tFCustomFlowId, Long userId) {
+        this.tFCustomFlowId = tFCustomFlowId;
+        this.insertInfo(userId);
+    }
+
+    public TFCustomFlowEntity(Long tFCustomFlowId, String flowProcessVar, Long userId) {
+        this.tFCustomFlowId = tFCustomFlowId;
+        this.flowProcessVar = flowProcessVar;
+        this.insertInfo(userId);
+    }
+
+    public TFCustomFlowEntity(Long tFCustomFlowId, Long flowId, String flowProcessVar, Long userId) {
+        this.tFCustomFlowId = tFCustomFlowId;
+        this.flowId = flowId;
+        this.flowProcessVar = flowProcessVar;
+        this.insertInfo(userId);
+    }
+
     public Long gettFCustomFlowId() {
     public Long gettFCustomFlowId() {
         return tFCustomFlowId;
         return tFCustomFlowId;
     }
     }

+ 13 - 0
sop-business/src/main/java/com/qmth/sop/business/entity/TFFlowApprove.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.qmth.sop.common.base.BaseEntity;
 import com.qmth.sop.common.base.BaseEntity;
+import com.qmth.sop.common.enums.FlowApproveSetupEnum;
 import com.qmth.sop.common.enums.FlowStatusEnum;
 import com.qmth.sop.common.enums.FlowStatusEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
@@ -64,6 +65,18 @@ public class TFFlowApprove extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "是否启用,0:停用,1:启用")
     @ApiModelProperty(value = "是否启用,0:停用,1:启用")
     private Boolean enable;
     private Boolean enable;
 
 
+    public TFFlowApprove() {
+
+    }
+
+    public TFFlowApprove(Long orgId, Long approveId, FlowStatusEnum status, Long userId) {
+        this.orgId = orgId;
+        this.approveId = approveId;
+        this.status = status;
+        insertInfo(userId);
+        this.setup = FlowApproveSetupEnum.START.getSetup();
+    }
+
     public Long getOrgId() {
     public Long getOrgId() {
         return orgId;
         return orgId;
     }
     }

+ 14 - 0
sop-business/src/main/java/com/qmth/sop/business/entity/TFFlowLog.java

@@ -75,6 +75,20 @@ public class TFFlowLog extends BaseEntity implements Serializable {
     @JsonSerialize(using = ToStringSerializer.class)
     @JsonSerialize(using = ToStringSerializer.class)
     private Long taskId;
     private Long taskId;
 
 
+
+    public TFFlowLog() {
+
+    }
+
+    public TFFlowLog(Long orgId, Long approveId, Long userId, FlowApproveOperationEnum approveOperation, Integer approveSetup, String approveRemark) {
+        this.orgId = orgId;
+        this.approveId = approveId;
+        insertInfo(userId);
+        this.approveOperation = approveOperation;
+        this.approveSetup = approveSetup;
+        this.approveRemark = approveRemark;
+    }
+
     public Long getOrgId() {
     public Long getOrgId() {
         return orgId;
         return orgId;
     }
     }

+ 4 - 0
sop-common/src/main/java/com/qmth/sop/common/enums/FlowApproveOperationEnum.java

@@ -11,8 +11,12 @@ import java.util.Objects;
  */
  */
 public enum FlowApproveOperationEnum {
 public enum FlowApproveOperationEnum {
 
 
+    START("开始", "start"),
+
     SUBMIT("提交", "submit"),
     SUBMIT("提交", "submit"),
 
 
+    DRAFT("草稿", "draft"),
+
     APPROVE("审批", "approve"),
     APPROVE("审批", "approve"),
 
 
     REJECT("驳回", "reject"),
     REJECT("驳回", "reject"),

+ 48 - 0
sop-common/src/main/java/com/qmth/sop/common/enums/FlowApprovePassEnum.java

@@ -0,0 +1,48 @@
+package com.qmth.sop.common.enums;
+
+import java.util.Objects;
+
+/**
+ * @Description: 流程审批操作 enum
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2021/8/2
+ */
+public enum FlowApprovePassEnum {
+
+    PASS("通过"),
+
+    REJECT("驳回"),
+
+    CANCEL("撤销"),
+
+    DRAFT("草稿"),
+
+    RESTART("重启流程");
+
+    private String title;
+
+    private FlowApprovePassEnum(String title) {
+        this.title = title;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    /**
+     * 状态转换 toName
+     *
+     * @param title
+     * @return
+     */
+    public static String convertToName(String title) {
+        for (FlowApprovePassEnum e : FlowApprovePassEnum.values()) {
+            if (Objects.equals(title, e.getTitle())) {
+                return e.name();
+            }
+        }
+        return null;
+    }
+}

+ 99 - 0
sop-common/src/main/java/com/qmth/sop/common/enums/FlowApproveSetupEnum.java

@@ -0,0 +1,99 @@
+package com.qmth.sop.common.enums;
+
+import java.util.Objects;
+
+/**
+ * @Description: 广东医科大学流程审批步骤 enum
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2021/8/2
+ */
+public enum FlowApproveSetupEnum {
+
+    START("开始", "start", 1, "开始节点"),
+
+    DRAFT("草稿", "start", 1, "暂存"),
+
+    END("已终止", null, -1, "终止"),
+
+    FINISH("已结束", null, 0, "结束节点"),
+
+    APPROVE("审批中", null, null, "审批节点");
+
+    private String title;
+
+    private String id;
+
+    private Integer setup;
+
+    private String remark;
+
+    private FlowApproveSetupEnum(String title, String id, Integer setup, String remark) {
+        this.title = title;
+        this.id = id;
+        this.setup = setup;
+        this.remark = remark;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public Integer getSetup() {
+        return setup;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    /**
+     * 状态转换 toName
+     *
+     * @param title
+     * @return
+     */
+    public static String convertToName(String title) {
+        for (FlowApproveSetupEnum e : FlowApproveSetupEnum.values()) {
+            if (Objects.equals(title, e.getTitle())) {
+                return e.name();
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 状态转换 ToInstance
+     *
+     * @param id
+     * @return
+     */
+    public static FlowApproveSetupEnum convertToInstance(String id) {
+        for (FlowApproveSetupEnum e : FlowApproveSetupEnum.values()) {
+            if (Objects.equals(id, e.getId())) {
+                return e;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 状态转换 ToRemark
+     *
+     * @param setup
+     * @return
+     */
+    public static String convertToRemark(int setup) {
+        for (FlowApproveSetupEnum e : FlowApproveSetupEnum.values()) {
+            if (e.getSetup() == setup) {
+                return e.getRemark();
+            }
+        }
+        return null;
+    }
+}

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

@@ -11,7 +11,9 @@ import java.util.Objects;
  */
  */
 public enum FlowStatusEnum {
 public enum FlowStatusEnum {
 
 
-    START("待审核"),
+    START("提交"),
+
+    DRAFT("草稿"),
 
 
     AUDITING("审核中"),
     AUDITING("审核中"),
 
 

+ 10 - 3
sop-common/src/main/java/com/qmth/sop/common/enums/TFCustomTypeEnum.java

@@ -11,17 +11,20 @@ import java.util.Objects;
  */
  */
 public enum TFCustomTypeEnum {
 public enum TFCustomTypeEnum {
 
 
-    OFFICE_SOP_FLOW("教务处SOP", null),
+    OFFICE_SOP_FLOW("教务处SOP", null, "officeSopFlow"),
 
 
-    CLOUD_MARK_SOP_FLOW("云阅卷SOP", null);
+    CLOUD_MARK_SOP_FLOW("云阅卷SOP", null, "cloudMarkSopFlow");
 
 
     private String title;
     private String title;
 
 
     private String table;
     private String table;
 
 
-    private TFCustomTypeEnum(String title, String table) {
+    private String code;
+
+    private TFCustomTypeEnum(String title, String table, String code) {
         this.title = title;
         this.title = title;
         this.table = table;
         this.table = table;
+        this.code = code;
     }
     }
 
 
     public String getTable() {
     public String getTable() {
@@ -32,6 +35,10 @@ public enum TFCustomTypeEnum {
         return title;
         return title;
     }
     }
 
 
+    public String getCode() {
+        return code;
+    }
+
     /**
     /**
      * 状态转换 toName
      * 状态转换 toName
      *
      *

+ 59 - 44
sop-server/src/main/java/com/qmth/sop/server/api/ActivitiFromHtmlController.java

@@ -8,14 +8,20 @@ import com.qmth.sop.business.bean.result.FlowFormWidgetResult;
 import com.qmth.sop.business.bean.result.FlowResult;
 import com.qmth.sop.business.bean.result.FlowResult;
 import com.qmth.sop.business.bean.result.FlowTaskResult;
 import com.qmth.sop.business.bean.result.FlowTaskResult;
 import com.qmth.sop.business.entity.TFCustomFlow;
 import com.qmth.sop.business.entity.TFCustomFlow;
-import com.qmth.sop.business.service.ActivitiConsumerService;
-import com.qmth.sop.business.service.TFCustomFlowService;
+import com.qmth.sop.business.entity.TFCustomFlowEntity;
+import com.qmth.sop.business.entity.TFFlowApprove;
+import com.qmth.sop.business.entity.TFFlowLog;
+import com.qmth.sop.business.service.*;
 import com.qmth.sop.common.enums.ExceptionResultEnum;
 import com.qmth.sop.common.enums.ExceptionResultEnum;
+import com.qmth.sop.common.enums.FlowApproveOperationEnum;
+import com.qmth.sop.common.enums.FlowApproveSetupEnum;
+import com.qmth.sop.common.enums.FlowStatusEnum;
 import com.qmth.sop.common.util.GsonUtil;
 import com.qmth.sop.common.util.GsonUtil;
 import com.qmth.sop.common.util.JacksonUtil;
 import com.qmth.sop.common.util.JacksonUtil;
 import io.swagger.annotations.*;
 import io.swagger.annotations.*;
 import org.activiti.engine.FormService;
 import org.activiti.engine.FormService;
 import org.activiti.engine.RepositoryService;
 import org.activiti.engine.RepositoryService;
+import org.activiti.engine.RuntimeService;
 import org.activiti.engine.TaskService;
 import org.activiti.engine.TaskService;
 import org.activiti.engine.repository.DeploymentBuilder;
 import org.activiti.engine.repository.DeploymentBuilder;
 import org.activiti.engine.runtime.ProcessInstance;
 import org.activiti.engine.runtime.ProcessInstance;
@@ -23,6 +29,7 @@ import org.activiti.engine.task.Task;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.core.io.ClassPathResource;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestMethod;
@@ -43,10 +50,10 @@ public class ActivitiFromHtmlController {
     private final static Logger log = LoggerFactory.getLogger(ActivitiFromHtmlController.class);
     private final static Logger log = LoggerFactory.getLogger(ActivitiFromHtmlController.class);
 
 
     @Resource
     @Resource
-    private ActivitiConsumerService activitiConsumerService;
+    ActivitiConsumerService activitiConsumerService;
 
 
     @Resource
     @Resource
-    private RepositoryService repositoryService;
+    RepositoryService repositoryService;
 
 
     @Resource
     @Resource
     FormService formService;
     FormService formService;
@@ -57,6 +64,18 @@ public class ActivitiFromHtmlController {
     @Resource
     @Resource
     TFCustomFlowService tfCustomFlowService;
     TFCustomFlowService tfCustomFlowService;
 
 
+    @Resource
+    RuntimeService runtimeService;
+
+    @Resource
+    TFCustomFlowEntityService tfCustomFlowEntityService;
+
+    @Resource
+    TFFlowApproveService tfFlowApproveService;
+
+    @Resource
+    TFFlowLogService tfFlowLogService;
+
     /**
     /**
      * 注册流程
      * 注册流程
      *
      *
@@ -64,6 +83,7 @@ public class ActivitiFromHtmlController {
      */
      */
     @ApiOperation(value = "创建流程接口")
     @ApiOperation(value = "创建流程接口")
     @RequestMapping(value = "/createDeployment", method = RequestMethod.POST)
     @RequestMapping(value = "/createDeployment", method = RequestMethod.POST)
+    @Transactional
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
     public Map<String, Object> createDeployment() throws IOException {
     public Map<String, Object> createDeployment() throws IOException {
         DeploymentBuilder builder = repositoryService.createDeployment();
         DeploymentBuilder builder = repositoryService.createDeployment();
@@ -82,41 +102,13 @@ public class ActivitiFromHtmlController {
 
 
     @ApiOperation(value = "获取流程提交表单属性接口")
     @ApiOperation(value = "获取流程提交表单属性接口")
     @RequestMapping(value = "/flow/start", method = RequestMethod.POST)
     @RequestMapping(value = "/flow/start", method = RequestMethod.POST)
+    @Transactional
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
     public Map<String, Object> flowStart(@ApiParam(value = "部署流程id", required = true) @RequestParam String deploymentId) {
     public Map<String, Object> flowStart(@ApiParam(value = "部署流程id", required = true) @RequestParam String deploymentId) {
         Map<String, Object> map = new HashMap<>();
         Map<String, Object> map = new HashMap<>();
         String processDefinitionId = null;
         String processDefinitionId = null;
-//        ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult();
-//        boolean hasStartFormKey = processDefinition.hasStartFormKey();
-//        //获得流程模型
-//        BpmnModel model = repositoryService.getBpmnModel(processDefinitionId);
-//        //获得流程模型的所有节点
-//        Collection<FlowElement> flowElements = model.getMainProcess().getFlowElements();
-//        List<FormPropertyBean> formPropertyBeanList = new LinkedList<>();
-//        for (FlowElement e : flowElements) {
-//            // 判断节点类型
-//            if (e instanceof UserTask) {
-//                UserTask userTask = (UserTask) e;
-//                if (Objects.nonNull(userTask.getFormKey())) {
-////                    Object o = formService.getRenderedTaskForm(processDefinitionId, userTask.getId());
-////                    log.info("task formProperties:{}", JacksonUtil.parseJson(o));
-//                }
-//            } else if (e instanceof StartEvent) {
-//                StartEvent startEvent = (StartEvent) e;
-//                if (Objects.nonNull(startEvent.getFormKey())) {
-//                    Object o = formService.getRenderedStartForm(processDefinitionId);
-//                    log.info("start formProperties:{}", JacksonUtil.parseJson(o));
-//                }
-//            }
-//        }
         TFCustomFlow tfCustomFlow = tfCustomFlowService.getOne(new QueryWrapper<TFCustomFlow>().lambda().eq(TFCustomFlow::getActFlowId, deploymentId));
         TFCustomFlow tfCustomFlow = tfCustomFlowService.getOne(new QueryWrapper<TFCustomFlow>().lambda().eq(TFCustomFlow::getActFlowId, deploymentId));
         Optional.ofNullable(tfCustomFlow.getFlowProcessVar()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有部署数据!"));
         Optional.ofNullable(tfCustomFlow.getFlowProcessVar()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有部署数据!"));
-//        Object o = formService.getRenderedStartForm(processDefinitionId);
-//        if (Objects.nonNull(o)) {
-//            log.info("start formProperties:{}", JacksonUtil.parseJson(o));
-//            List<FlowFormWidgetResult> list = JSONArray.parseArray(o.toString(), FlowFormWidgetResult.class);
-//            map.put("FormProperty", new FormPropertyBean(null, null, list));
-//        }
         if (Objects.isNull(tfCustomFlow.getFlowKey())) {
         if (Objects.isNull(tfCustomFlow.getFlowKey())) {
             processDefinitionId = activitiConsumerService.findProcessDefinitionIdByDeploymentId(deploymentId);
             processDefinitionId = activitiConsumerService.findProcessDefinitionIdByDeploymentId(deploymentId);
             tfCustomFlow.setFlowKey(processDefinitionId);
             tfCustomFlow.setFlowKey(processDefinitionId);
@@ -136,6 +128,7 @@ public class ActivitiFromHtmlController {
         }
         }
         map.put("processDefinitionId", processDefinitionId);
         map.put("processDefinitionId", processDefinitionId);
         map.put("deploymentId", deploymentId);
         map.put("deploymentId", deploymentId);
+        map.put("id", tfCustomFlow.getId());
         return map;
         return map;
     }
     }
 
 
@@ -172,8 +165,9 @@ public class ActivitiFromHtmlController {
 
 
     @ApiOperation(value = "启动流程接口")
     @ApiOperation(value = "启动流程接口")
     @RequestMapping(value = "/startActivityDemo", method = RequestMethod.POST)
     @RequestMapping(value = "/startActivityDemo", method = RequestMethod.POST)
+    @Transactional
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
-    public Map<String, Object> startActivityDemo(@ApiParam(value = "流程定义id", required = true) @RequestParam String processDefinitionId,
+    public Map<String, Object> startActivityDemo(@ApiParam(value = "流程定义id", required = true) @RequestParam Long id,
                                                  @ApiParam(value = "审批人id", required = true) @RequestParam String approveId,
                                                  @ApiParam(value = "审批人id", required = true) @RequestParam String approveId,
                                                  @ApiParam(value = "上传文件") @RequestParam(required = false) MultipartFile file,
                                                  @ApiParam(value = "上传文件") @RequestParam(required = false) MultipartFile file,
                                                  HttpServletRequest request) {
                                                  HttpServletRequest request) {
@@ -188,24 +182,45 @@ public class ActivitiFromHtmlController {
         }
         }
         varMap.putAll(formDataMap);
         varMap.putAll(formDataMap);
 
 
-        ProcessInstance processInstance = formService.submitStartFormData(processDefinitionId, formDataMap);
+        TFCustomFlow tfCustomFlow = tfCustomFlowService.getById(id);
+        Optional.ofNullable(tfCustomFlow.getFlowProcessVar()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有部署数据!"));
+        ProcessInstance processInstance = runtimeService.startProcessInstanceById(tfCustomFlow.getFlowKey(), varMap);
+//        ProcessInstance processInstance = formService.submitStartFormData(tfCustomFlow.getFlowKey(), varMap);
         if (Objects.nonNull(processInstance)) {
         if (Objects.nonNull(processInstance)) {
+            TFCustomFlowEntity tfCustomFlowEntity = new TFCustomFlowEntity(tfCustomFlow.getId(), null);
+            TFFlowApprove tfFlowApprove = new TFFlowApprove(null, Long.parseLong(approveId), FlowStatusEnum.START, null);
+            TFFlowLog tfFlowLog = new TFFlowLog(null, tfFlowApprove.getApproveId(), null, FlowApproveOperationEnum.START, FlowApproveSetupEnum.START.getSetup(), FlowApproveSetupEnum.START.getTitle());
             List<Task> taskList = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();
             List<Task> taskList = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();
             if (!CollectionUtils.isEmpty(taskList)) {
             if (!CollectionUtils.isEmpty(taskList)) {
+                FlowResult flowResult = JSONObject.parseObject(tfCustomFlow.getFlowProcessVar(), FlowResult.class);
+                Map<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
+                tfCustomFlowEntity.setFlowProcessVar(tfCustomFlow.getFlowProcessVar());
                 List<FormPropertyBean> formPropertyList = new LinkedList<>();
                 List<FormPropertyBean> formPropertyList = new LinkedList<>();
                 for (Task t : taskList) {
                 for (Task t : taskList) {
                     String flowTaskId = t.getId();
                     String flowTaskId = t.getId();
-                    String processInstanceId = t.getProcessInstanceId();
-                    Object o = formService.getRenderedTaskForm(flowTaskId);
-                    log.info("flowTaskId:{},flowId:{}", flowTaskId, processInstanceId);
-                    if (Objects.nonNull(o)) {
-                        log.info("task formProperties:{}", JacksonUtil.parseJson(o));
-                        List<FlowFormWidgetResult> list = JSONArray.parseArray(o.toString(), FlowFormWidgetResult.class);
-                        formPropertyList.add(new FormPropertyBean(processInstanceId, flowTaskId, list));
+                    Long flowId = Long.parseLong(t.getProcessInstanceId());
+                    varMap.put("flowId", t.getProcessInstanceId());
+                    varMap.put("taskId", flowTaskId);
+                    tfCustomFlowEntity.setFlowId(flowId);
+                    tfFlowApprove.setFlowId(flowId);
+                    tfFlowApprove.setApproveMaxSetup(setupMap.size());
+                    tfFlowLog.setFlowId(flowId);
+                    tfFlowLog.setTaskId(Long.parseLong(flowTaskId));
+                    tfFlowLog.setPendApproveId(Arrays.asList(approveId).toString().replaceAll("\\[", "").replaceAll("\\]", ""));
+                    log.info("flowTaskId:{},flowId:{}", flowTaskId, flowId);
+//                    Object o = formService.getRenderedTaskForm(flowTaskId);
+                    FlowTaskResult currFlowTaskResult = GsonUtil.fromJson(GsonUtil.toJson(setupMap.get(t.getTaskDefinitionKey())), FlowTaskResult.class);
+                    if (Objects.nonNull(currFlowTaskResult)) {
+                        log.info("task formProperties:{}", JacksonUtil.parseJson(currFlowTaskResult));
+                        formPropertyList.add(new FormPropertyBean(t.getProcessInstanceId(), flowTaskId, currFlowTaskResult));
                     }
                     }
                 }
                 }
                 varMap.put("formProperties", formPropertyList);
                 varMap.put("formProperties", formPropertyList);
             }
             }
+            tfCustomFlowEntityService.save(tfCustomFlowEntity);
+            tfFlowLog.setObjectId(tfCustomFlowEntity.getId());
+            tfFlowApproveService.save(tfFlowApprove);
+            tfFlowLogService.save(tfFlowLog);
         }
         }
         return varMap;
         return varMap;
     }
     }
@@ -228,7 +243,7 @@ public class ActivitiFromHtmlController {
                     if (Objects.nonNull(o)) {
                     if (Objects.nonNull(o)) {
                         log.info("task formProperties:{}", JacksonUtil.parseJson(o));
                         log.info("task formProperties:{}", JacksonUtil.parseJson(o));
                         List<FlowFormWidgetResult> list = JSONArray.parseArray(o.toString(), FlowFormWidgetResult.class);
                         List<FlowFormWidgetResult> list = JSONArray.parseArray(o.toString(), FlowFormWidgetResult.class);
-                        formPropertyList.add(new FormPropertyBean(processInstanceId, flowTaskId, userId, list));
+                        formPropertyList.add(new FormPropertyBean(processInstanceId, flowTaskId, userId, null));
                     }
                     }
                 }
                 }
                 varMap.put("formProperties", formPropertyList);
                 varMap.put("formProperties", formPropertyList);
@@ -267,7 +282,7 @@ public class ActivitiFromHtmlController {
                 if (Objects.nonNull(o)) {
                 if (Objects.nonNull(o)) {
                     log.info("task formProperties:{}", JacksonUtil.parseJson(o));
                     log.info("task formProperties:{}", JacksonUtil.parseJson(o));
                     List<FlowFormWidgetResult> list = JSONArray.parseArray(o.toString(), FlowFormWidgetResult.class);
                     List<FlowFormWidgetResult> list = JSONArray.parseArray(o.toString(), FlowFormWidgetResult.class);
-                    formPropertyList.add(new FormPropertyBean(processInstanceId, flowTaskId, t.getAssignee(), list));
+                    formPropertyList.add(new FormPropertyBean(processInstanceId, flowTaskId, t.getAssignee(), null));
                 }
                 }
                 varMap.put("formProperties", formPropertyList);
                 varMap.put("formProperties", formPropertyList);
             }
             }

+ 18 - 18
sop-server/src/main/resources/testform1.bpmn

@@ -1,24 +1,18 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="http://www.activiti.org/test" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test" id="m1626068475250" name="">
 <definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="http://www.activiti.org/test" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test" id="m1626068475250" name="">
   <process id="OFFICE_SOP_FLOW" isExecutable="true" isClosed="false" processType="None">
   <process id="OFFICE_SOP_FLOW" isExecutable="true" isClosed="false" processType="None">
-    <startEvent id="start" name="开始"></startEvent>
-    <userTask id="f_usertask_jwc_start" name="新增sop" activiti:assignee="${approveId}" activiti:formKey="start_1.form"></userTask>
     <userTask id="f_usertask_jwc_inside_approve" name="教务处sop_内审" activiti:assignee="${approveId}" activiti:formKey="inside_approve_3.form"></userTask>
     <userTask id="f_usertask_jwc_inside_approve" name="教务处sop_内审" activiti:assignee="${approveId}" activiti:formKey="inside_approve_3.form"></userTask>
     <endEvent id="f_usertask_jwc_end" name="结束"></endEvent>
     <endEvent id="f_usertask_jwc_end" name="结束"></endEvent>
     <sequenceFlow id="_8" sourceRef="f_usertask_jwc_inside_approve" targetRef="f_usertask_jwc_end"></sequenceFlow>
     <sequenceFlow id="_8" sourceRef="f_usertask_jwc_inside_approve" targetRef="f_usertask_jwc_end"></sequenceFlow>
-    <sequenceFlow id="flow1" sourceRef="start" targetRef="start"></sequenceFlow>
     <userTask id="f_usertask_jwc_project" name="教务处sop_项目关键信息" activiti:assignee="${approveId}" activiti:formKey="project_2.form"></userTask>
     <userTask id="f_usertask_jwc_project" name="教务处sop_项目关键信息" activiti:assignee="${approveId}" activiti:formKey="project_2.form"></userTask>
-    <sequenceFlow id="flow2" sourceRef="f_usertask_jwc_start" targetRef="f_usertask_jwc_project"></sequenceFlow>
     <sequenceFlow id="flow3" sourceRef="f_usertask_jwc_project" targetRef="f_usertask_jwc_inside_approve"></sequenceFlow>
     <sequenceFlow id="flow3" sourceRef="f_usertask_jwc_project" targetRef="f_usertask_jwc_inside_approve"></sequenceFlow>
+    <startEvent id="startevent1" name="Start"></startEvent>
+    <userTask id="f_usertask_jwc_start" name="新增sop" activiti:assignee="${approveId}" activiti:formKey="start_1.form"></userTask>
+    <sequenceFlow id="flow6" sourceRef="startevent1" targetRef="f_usertask_jwc_start"></sequenceFlow>
+    <sequenceFlow id="flow7" sourceRef="f_usertask_jwc_start" targetRef="f_usertask_jwc_project"></sequenceFlow>
   </process>
   </process>
   <bpmndi:BPMNDiagram id="BPMNDiagram_OFFICE_SOP_FLOW">
   <bpmndi:BPMNDiagram id="BPMNDiagram_OFFICE_SOP_FLOW">
     <bpmndi:BPMNPlane bpmnElement="OFFICE_SOP_FLOW" id="BPMNPlane_OFFICE_SOP_FLOW">
     <bpmndi:BPMNPlane bpmnElement="OFFICE_SOP_FLOW" id="BPMNPlane_OFFICE_SOP_FLOW">
-      <bpmndi:BPMNShape bpmnElement="start" id="BPMNShape_start">
-        <omgdc:Bounds height="35.0" width="35.0" x="240.0" y="15.0"></omgdc:Bounds>
-      </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape bpmnElement="f_usertask_jwc_start" id="BPMNShape_f_usertask_jwc_start">
-        <omgdc:Bounds height="55.0" width="85.0" x="215.0" y="135.0"></omgdc:Bounds>
-      </bpmndi:BPMNShape>
       <bpmndi:BPMNShape bpmnElement="f_usertask_jwc_inside_approve" id="BPMNShape_f_usertask_jwc_inside_approve">
       <bpmndi:BPMNShape bpmnElement="f_usertask_jwc_inside_approve" id="BPMNShape_f_usertask_jwc_inside_approve">
         <omgdc:Bounds height="55.0" width="85.0" x="215.0" y="360.0"></omgdc:Bounds>
         <omgdc:Bounds height="55.0" width="85.0" x="215.0" y="360.0"></omgdc:Bounds>
       </bpmndi:BPMNShape>
       </bpmndi:BPMNShape>
@@ -28,22 +22,28 @@
       <bpmndi:BPMNShape bpmnElement="f_usertask_jwc_project" id="BPMNShape_f_usertask_jwc_project">
       <bpmndi:BPMNShape bpmnElement="f_usertask_jwc_project" id="BPMNShape_f_usertask_jwc_project">
         <omgdc:Bounds height="55.0" width="85.0" x="215.0" y="240.0"></omgdc:Bounds>
         <omgdc:Bounds height="55.0" width="85.0" x="215.0" y="240.0"></omgdc:Bounds>
       </bpmndi:BPMNShape>
       </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
+        <omgdc:Bounds height="35.0" width="35.0" x="240.0" y="80.0"></omgdc:Bounds>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape bpmnElement="f_usertask_jwc_start" id="BPMNShape_f_usertask_jwc_start">
+        <omgdc:Bounds height="55.0" width="85.0" x="215.0" y="150.0"></omgdc:Bounds>
+      </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge bpmnElement="_8" id="BPMNEdge__8">
       <bpmndi:BPMNEdge bpmnElement="_8" id="BPMNEdge__8">
         <omgdi:waypoint x="257.0" y="415.0"></omgdi:waypoint>
         <omgdi:waypoint x="257.0" y="415.0"></omgdi:waypoint>
         <omgdi:waypoint x="257.0" y="480.0"></omgdi:waypoint>
         <omgdi:waypoint x="257.0" y="480.0"></omgdi:waypoint>
       </bpmndi:BPMNEdge>
       </bpmndi:BPMNEdge>
-      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
-        <omgdi:waypoint x="275.0" y="32.0"></omgdi:waypoint>
-        <omgdi:waypoint x="275.0" y="32.0"></omgdi:waypoint>
-      </bpmndi:BPMNEdge>
-      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
-        <omgdi:waypoint x="257.0" y="190.0"></omgdi:waypoint>
-        <omgdi:waypoint x="257.0" y="240.0"></omgdi:waypoint>
-      </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
       <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
         <omgdi:waypoint x="257.0" y="295.0"></omgdi:waypoint>
         <omgdi:waypoint x="257.0" y="295.0"></omgdi:waypoint>
         <omgdi:waypoint x="257.0" y="360.0"></omgdi:waypoint>
         <omgdi:waypoint x="257.0" y="360.0"></omgdi:waypoint>
       </bpmndi:BPMNEdge>
       </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
+        <omgdi:waypoint x="257.0" y="115.0"></omgdi:waypoint>
+        <omgdi:waypoint x="257.0" y="150.0"></omgdi:waypoint>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7">
+        <omgdi:waypoint x="257.0" y="205.0"></omgdi:waypoint>
+        <omgdi:waypoint x="257.0" y="240.0"></omgdi:waypoint>
+      </bpmndi:BPMNEdge>
     </bpmndi:BPMNPlane>
     </bpmndi:BPMNPlane>
   </bpmndi:BPMNDiagram>
   </bpmndi:BPMNDiagram>
 </definitions>
 </definitions>

BIN
sop-server/src/main/resources/testform1.zip