Browse Source

自定义流程

huangjn 2 years ago
parent
commit
69b5c187fa

+ 5 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/FixedFlowLink.java

@@ -84,4 +84,9 @@ public class FixedFlowLink extends BaseEntity {
         this.setCreateTime(new Date());
     }
 
+    public FixedFlowLink(String fixedFlowLinkUserName, String fixedFlowLinkUser){
+        this.fixedFlowLinkUserName = fixedFlowLinkUserName;
+        this.fixedFlowLinkUser = Long.parseLong(fixedFlowLinkUser);
+    }
+
 }

+ 1 - 1
blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/FixedFlowVO.java

@@ -49,7 +49,7 @@ public class FixedFlowVO extends FixedFlow {
 	private Integer size;
 
 	@ApiModelProperty("是否可选")
-	private boolean disabled
+	private boolean disabled;
 
 	private Query query;
 

+ 24 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/StartTaskVO.java

@@ -3,6 +3,9 @@ package org.springblade.business.vo;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.util.ArrayList;
+import java.util.List;
+
 @Data
 public class StartTaskVO {
 
@@ -48,4 +51,25 @@ public class StartTaskVO {
     @ApiModelProperty("施工、监理分类(填报页上报必传)")
     private Integer classify;
 
+    @ApiModelProperty("自定义流程,所选的审批人ID和姓名集合")
+    private List<CustomUserTask> userTasks;
+
+    public void setUserTasks(String userId, String userName){
+        if(this.userTasks == null){
+            this.userTasks = new ArrayList<>();
+        }
+        this.userTasks.add(new CustomUserTask(userId, userName));
+    }
+
+    @Data
+    public class CustomUserTask {
+        private String userId;
+        private String userName;
+
+        public CustomUserTask(String userId, String userName){
+            this.userId = userId;
+            this.userName = userName;
+        }
+    }
+
 }

+ 21 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/TaskVO.java

@@ -50,6 +50,16 @@ public class TaskVO extends Task {
 	@ApiModelProperty("审批人集合")
 	private List<WaitingUser> waitingUserList = new ArrayList<>();
 
+	@ApiModelProperty("自定义流程,所选的审批人ID和姓名集合")
+	private List<CustomUserTask> userTasks;
+
+	public void setUserTasks(String userId, String userName){
+		if(this.userTasks == null){
+			this.userTasks = new ArrayList<>();
+		}
+		this.userTasks.add(new CustomUserTask(userId, userName));
+	}
+
 	public void setWaitingUserList(String waitingUserName, Integer status){
 		this.waitingUserList.add(new WaitingUser(waitingUserName, status));
 	}
@@ -60,6 +70,17 @@ public class TaskVO extends Task {
 		this.taskStatus = new TaskStatus(statusValue, status);
 	}
 
+	@Data
+	public class CustomUserTask {
+		private String userId;
+		private String userName;
+
+		public CustomUserTask(String userId, String userName){
+			this.userId = userId;
+			this.userName = userName;
+		}
+	}
+
 	@Data
 	private class TaskStatus {
 		@ApiModelProperty("状态类型")

+ 6 - 0
blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java

@@ -12,6 +12,7 @@ import lombok.AllArgsConstructor;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 
+import org.apache.commons.collections4.ListUtils;
 import org.apache.commons.lang.StringUtils;
 import org.jetbrains.annotations.NotNull;
 import org.springblade.business.entity.*;
@@ -661,6 +662,11 @@ public class InformationWriteQueryController extends BladeController {
 						//生成任务实体
 						TaskVO taskVO = new TaskVO();
 						BeanUtils.copyProperties(startTaskVO, taskVO);
+						if(taskVO.getUserTasks() != null && taskVO.getUserTasks().size() > 0){
+							//标记为自定义流程
+							taskVO.setFixedFlowId(Long.parseLong("0"));
+						}
+
 						//设置数据源指向
 						taskVO.setFormDataId(id);
 						//设置上报类型

+ 16 - 3
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TaskServiceImpl.java

@@ -560,10 +560,23 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
                 return false;
             }
             //获取选择的固定流程
-            List<FixedFlowLink> links = this.fixedFlowLinkService.selectFixedFlowLink(vo.getFixedFlowId().toString());
-            if(links == null || links.size() == 0){
-                return false;
+            List<FixedFlowLink> links;
+            if(Long.valueOf("0").equals(vo.getFixedFlowId())){
+                //自定义流程
+                links = new ArrayList<>();
+                //获取自定义流程
+                List<TaskVO.CustomUserTask> userTasks = vo.getUserTasks();
+                //设置人员及姓名
+                userTasks.forEach(userTask -> links.add(new FixedFlowLink(userTask.getUserName(), userTask.getUserId())));
+
+            } else {
+                //预设流程
+                links = this.fixedFlowLinkService.selectFixedFlowLink(vo.getFixedFlowId().toString());
+                if(links == null || links.size() == 0){
+                    return false;
+                }
             }
+
             //启动主流程
             R<BladeFlow> result = this.flowClient.startProcessInstanceById(taskFlowId, FlowUtil.getBusinessKey(businessTable, String.valueOf(vo.getId())),
                     Kv.create().set(ProcessConstant.TASK_VARIABLE_CREATE_USER, AuthUtil.getUserName()).set("taskUser", TaskUtil.getTaskUser("")));