工作流代码提交

This commit is contained in:
2023-04-14 15:03:13 +08:00
parent 4490758e8a
commit d7981936f2
26 changed files with 1170 additions and 47 deletions

View File

@@ -0,0 +1,95 @@
package com.njcn.process.controller.flowable;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.process.service.flowable.IFlowDefinitionService;
import com.njcn.process.service.flowable.IFlowTaskService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.flowable.common.engine.api.FlowableObjectNotFoundException;
import org.flowable.engine.HistoryService;
import org.flowable.engine.RepositoryService;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.repository.Deployment;
import org.flowable.engine.repository.ProcessDefinition;
import org.flowable.engine.runtime.ProcessInstance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
import java.util.Objects;
/**
* pqs
* 工作流
* @author cdf
* @date 2023/4/10
*/
@Slf4j
@Api(tags = "工作流")
@RestController
@RequestMapping("/flowable/definition")
@RequiredArgsConstructor
public class FlowDefinitionController extends BaseController {
private final IFlowDefinitionService flowDefinitionService;
private final RepositoryService repositoryService;
private final RuntimeService runtimeService;
private final TaskService taskService;
private final HistoryService historyService;
private final IFlowTaskService flowTaskService;
@GetMapping("deployment")
@ApiOperation(value = "工作流_部署流程")
public void createDeployment() {
Deployment deployment = repositoryService.createDeployment()
.addClasspathResource("aa.bpmn20.xml")
.name("技术监督预警流程").category("testCategory")
.deploy();
ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult();
repositoryService.setProcessDefinitionCategory(definition.getId(), "testCategory");
System.out.println(deployment.getId());
}
@ApiOperation(value = "工作流_发起流程")
@PostMapping("/start")
public HttpResult<String> start(@ApiParam(value = "流程定义id") @RequestParam(value = "procDefId") String procDefId,
@ApiParam(value = "监督单id") @RequestParam(value = "thsIndex") String thsIndex,
@ApiParam(value = "变量集合,json对象") @RequestBody Map<String, Object> variables) {
String methodDescribe = getMethodDescribe("start");
String res = flowDefinitionService.startProcessInstanceById(procDefId,thsIndex, variables);
if(Objects.nonNull(res)){
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe);
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
}
@ApiOperation(value = "工作流_定义删除")
@DeleteMapping(value = "delete/{deployIds}")
public HttpResult<Object> delete(@PathVariable String[] deployIds) {
String methodDescribe = getMethodDescribe("delete");
for (String deployId : deployIds) {
flowDefinitionService.delete(deployId);
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
}

View File

@@ -0,0 +1,74 @@
package com.njcn.process.controller.flowable;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.process.pojo.vo.flowable.FlowQueryVo;
import com.njcn.process.pojo.vo.flowable.FlowTaskVo;
import com.njcn.process.service.flowable.IFlowTaskService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Map;
/**
* <p>工作流任务管理<p>
*
* @author Tony
* @date 2021-04-03
*/
@Slf4j
@Api(tags = "工作流流程任务管理")
@RestController
@RequestMapping("/flowable/task")
@RequiredArgsConstructor
public class FlowTaskController extends BaseController {
private final IFlowTaskService flowTaskService;
@ApiOperation(value = "工作流_审批任务")
@PostMapping(value = "/complete")
public HttpResult complete(@RequestBody FlowTaskVo flowTaskVo) {
boolean res = flowTaskService.complete(flowTaskVo);
return null;
}
/**
* 流程节点信息
*
* @param procInsId 流程实例id
* @return
*/
@GetMapping("/flowXmlAndNode")
@ApiOperation(value = "工作流_流程节点信息")
public HttpResult flowXmlAndNode(@RequestParam(value = "procInsId", required = false) String procInsId,
@RequestParam(value = "deployId", required = false) String deployId) {
String methodDescribe = getMethodDescribe("flowXmlAndNode");
Map<String, Object> res = flowTaskService.flowXmlAndNode(procInsId, deployId);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe);
}
}