|
@@ -3,12 +3,14 @@
|
|
|
*/
|
|
|
package com.jeeplus.flowable.controller;
|
|
|
|
|
|
+import cn.hutool.extra.spring.SpringUtil;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Maps;
|
|
|
import com.jeeplus.common.TokenProvider;
|
|
|
import com.jeeplus.extension.domain.NodeSetting;
|
|
|
import com.jeeplus.extension.service.NodeSettingService;
|
|
|
+import com.jeeplus.flowable.model.ActRuTaskInfo;
|
|
|
import com.jeeplus.flowable.model.Flow;
|
|
|
import com.jeeplus.flowable.model.TaskComment;
|
|
|
import com.jeeplus.flowable.service.FlowTaskService;
|
|
@@ -19,8 +21,10 @@ import com.jeeplus.sys.feign.IUserApi;
|
|
|
import com.jeeplus.sys.service.dto.UserDTO;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.ibatis.annotations.Param;
|
|
|
+import org.flowable.bpmn.model.Process;
|
|
|
import org.flowable.common.engine.impl.identity.Authentication;
|
|
|
import org.flowable.engine.HistoryService;
|
|
|
+import org.flowable.engine.RepositoryService;
|
|
|
import org.flowable.engine.RuntimeService;
|
|
|
import org.flowable.engine.TaskService;
|
|
|
import org.flowable.engine.runtime.ProcessInstance;
|
|
@@ -149,13 +153,20 @@ public class FlowableTaskController {
|
|
|
*/
|
|
|
@PostMapping("start")
|
|
|
public ResponseEntity start(@RequestBody Flow flow) {
|
|
|
- String procInsId = flowTaskService.startProcess ( flow.getProcDefKey ( ), flow.getBusinessTable ( ), flow.getBusinessId ( ), flow.getTitle ( ) );
|
|
|
+ String procInsId = flowTaskService.startProcess ( flow.getProcDefKey ( ), flow.getBusinessTable ( ), flow.getBusinessId ( ), flow.getTitle ( ), flow.getProcDefId() );
|
|
|
|
|
|
//指定下一步处理人
|
|
|
if ( StringUtils.isNotBlank ( flow.getAssignee ( ) ) ) {
|
|
|
Task task = taskService.createTaskQuery ( ).processInstanceId ( procInsId ).active ( ).singleResult ( );
|
|
|
- if ( task != null ) {
|
|
|
- taskService.setAssignee ( task.getId ( ), flow.getAssignee ( ) );
|
|
|
+ if(task != null){
|
|
|
+ String[] split = flow.getAssignee().split(",");
|
|
|
+ if (split.length == 1) {
|
|
|
+ taskService.setAssignee(task.getId(), flow.getAssignee ());
|
|
|
+ } else {
|
|
|
+ for (String i : split) {
|
|
|
+ taskService.addCandidateUser(task.getId(),i);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return ResponseEntity.ok ( procInsId );
|
|
@@ -386,5 +397,70 @@ public class FlowableTaskController {
|
|
|
return flowTaskService.checkIsLastTask(procInsId);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取流程表单
|
|
|
+ */
|
|
|
+ @GetMapping("getTaskDefInfo")
|
|
|
+ public ResponseEntity getTaskDefInfo(Flow flow) {
|
|
|
+ if(StringUtils.isNotBlank(flow.getTaskId()) && StringUtils.isBlank(flow.getTaskName()) && StringUtils.isBlank(flow.getTaskDefKey())){
|
|
|
+ ActRuTaskInfo taskInfoByTaskId = flowTaskService.getTaskInfoByTaskId(flow.getTaskId());
|
|
|
+ if(null != taskInfoByTaskId){
|
|
|
+ flow.setTaskId(taskInfoByTaskId.getId());
|
|
|
+ flow.setProcInsId(taskInfoByTaskId.getProcInstId());
|
|
|
+ flow.setTaskName(taskInfoByTaskId.getName());
|
|
|
+ flow.setTaskDefKey(taskInfoByTaskId.getTaskDefKey());
|
|
|
+ }
|
|
|
+ //当前任务信息
|
|
|
+ Task task =taskService.createTaskQuery().processInstanceId(flow.getProcInsId()).active().singleResult();
|
|
|
+ if(null != task){
|
|
|
+ if(StringUtils.isNotBlank(task.getProcessDefinitionId())){
|
|
|
+ flow.setProcDefId(task.getProcessDefinitionId());
|
|
|
+ }
|
|
|
+ if(null != task.getProcessVariables ()){
|
|
|
+ String title = (String) task.getProcessVariables().get("title");
|
|
|
+ if(StringUtils.isNotBlank(title)){
|
|
|
+ flow.setTitle(title);
|
|
|
+ }else{
|
|
|
+ flow.setTitle("");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Process process = SpringUtil.getBean (RepositoryService.class).getBpmnModel (taskInfoByTaskId.getProcDefId ()).getMainProcess ();
|
|
|
+ if(null != process && StringUtils.isNotBlank(process.getId())){
|
|
|
+ flow.setProcDefKey(process.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 获取流程XML上的表单KEY
|
|
|
+ String formKey = flowTaskService.getFormKey(flow.getProcDefId(), flow.getTaskDefKey());
|
|
|
+
|
|
|
+ NodeSetting typeNode = nodeSettingService.queryByKey (flow.getProcDefKey(), flow.getTaskDefKey(), "formType");
|
|
|
+ NodeSetting ReadOnlyNode = nodeSettingService.queryByKey (flow.getProcDefKey(), flow.getTaskDefKey(), "formReadOnly");
|
|
|
+ String formType = "1";
|
|
|
+ boolean formReadOnly = false;
|
|
|
+ if(typeNode != null){
|
|
|
+ formType = typeNode.getValue ();
|
|
|
+ formReadOnly = "true".equals(ReadOnlyNode.getValue ());
|
|
|
+ }else{
|
|
|
+ if(StringUtils.isBlank(formKey)){
|
|
|
+ formType = "1";
|
|
|
+ }else if(formKey.indexOf("/")>=0){
|
|
|
+ formType = "2";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取流程实例对象
|
|
|
+ if (flow.getProcInsId() != null) {
|
|
|
+ if (flowTaskService.getProcIns(flow.getProcInsId()) != null) {
|
|
|
+ flow.setProcIns(flowTaskService.getProcIns(flow.getProcInsId()));
|
|
|
+ } else {
|
|
|
+ flow.setFinishedProcIns(flowTaskService.getFinishedProcIns(flow.getProcInsId()));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ flow.setFormUrl(formKey);
|
|
|
+ flow.setFormReadOnly(formReadOnly);
|
|
|
+ flow.setFormType(formType);
|
|
|
+ return ResponseEntity.ok (flow);
|
|
|
+ }
|
|
|
}
|