list = sysExpressionService.selectSysExpressionList(sysExpression);
+ return AjaxResult.success(list);
+ }
+
+}
\ No newline at end of file
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowInstanceController.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowInstanceController.java
new file mode 100644
index 00000000..89fde4cc
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowInstanceController.java
@@ -0,0 +1,66 @@
+package com.yanzhu.flowable.controller;
+
+import com.yanzhu.common.core.web.controller.BaseController;
+import com.yanzhu.common.core.web.domain.AjaxResult;
+import com.yanzhu.common.log.annotation.Log;
+import com.yanzhu.common.log.enums.BusinessType;
+import com.yanzhu.flowable.domain.vo.FlowTaskVo;
+import com.yanzhu.flowable.service.IFlowInstanceService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Map;
+
+/**
+ * 工作流流程实例管理
+ *
+ * @author Tony
+ * @date 2021-04-03
+ */
+@Slf4j
+@Api(tags = "工作流流程实例管理")
+@RestController
+@RequestMapping("/instance")
+public class FlowInstanceController extends BaseController {
+
+ @Autowired
+ private IFlowInstanceService flowInstanceService;
+
+ @ApiOperation(value = "根据流程定义id启动流程实例")
+ @PostMapping("/startBy/{procDefId}")
+ public AjaxResult startById(@ApiParam(value = "流程定义id") @PathVariable(value = "procDefId") String procDefId,
+ @ApiParam(value = "变量集合,json对象") @RequestBody Map variables) {
+ return flowInstanceService.startProcessInstanceById(procDefId, variables);
+
+ }
+
+ @ApiOperation(value = "激活或挂起流程实例")
+ @PostMapping(value = "/updateState")
+ public AjaxResult updateState(@ApiParam(value = "1:激活,2:挂起", required = true) @RequestParam Integer state,
+ @ApiParam(value = "流程实例ID", required = true) @RequestParam String instanceId) {
+ flowInstanceService.updateState(state,instanceId);
+ return AjaxResult.success();
+ }
+
+ @ApiOperation("结束流程实例")
+ @PostMapping(value = "/stopProcessInstance")
+ public AjaxResult stopProcessInstance(@RequestBody FlowTaskVo flowTaskVo) {
+ flowInstanceService.stopProcessInstance(flowTaskVo);
+ return AjaxResult.success();
+ }
+
+ @ApiOperation(value = "删除流程实例")
+ @Log(title = "删除任务", businessType = BusinessType.DELETE)
+ @DeleteMapping(value = "/delete/{instanceIds}")
+ public AjaxResult delete(@ApiParam(value = "流程实例ID", required = true) @PathVariable String[] instanceIds,
+ @ApiParam(value = "删除原因") @RequestParam(required = false) String deleteReason) {
+ for (String instanceId : instanceIds) {
+ flowInstanceService.delete(instanceId,deleteReason);
+ }
+ return AjaxResult.success();
+ }
+}
\ No newline at end of file
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowTaskController.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowTaskController.java
new file mode 100644
index 00000000..ffd3d5d0
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowTaskController.java
@@ -0,0 +1,281 @@
+package com.yanzhu.flowable.controller;
+
+import com.github.pagehelper.PageInfo;
+import com.yanzhu.common.core.web.controller.BaseController;
+import com.yanzhu.common.core.web.domain.AjaxResult;
+import com.yanzhu.common.core.web.page.TableDataInfo;
+import com.yanzhu.common.log.annotation.Log;
+import com.yanzhu.common.log.enums.BusinessType;
+import com.yanzhu.flowable.domain.dto.FlowTaskDto;
+import com.yanzhu.flowable.domain.vo.FlowQueryVo;
+import com.yanzhu.flowable.domain.vo.FlowTaskVo;
+import com.yanzhu.flowable.service.IFlowTaskService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+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;
+
+/**
+ * 工作流任务管理
+ *
+ * @author Tony
+ * @date 2021-04-03
+ */
+@Slf4j
+@Api(tags = "工作流流程任务管理")
+@RestController
+@RequestMapping("/task")
+public class FlowTaskController extends BaseController {
+
+ @Autowired
+ private IFlowTaskService flowTaskService;
+
+ @ApiOperation(value = "我发起的流程", response = FlowTaskDto.class)
+ @GetMapping(value = "/myProcess")
+ public TableDataInfo myProcess(FlowQueryVo queryVo) {
+ PageInfo list = flowTaskService.myProcess(queryVo);
+ return getDataTable(list);
+ }
+
+ @ApiOperation(value = "取消申请", response = FlowTaskDto.class)
+ @Log(title = "取消申请", businessType = BusinessType.UPDATE)
+ @PostMapping(value = "/stopProcess")
+ public AjaxResult stopProcess(@RequestBody FlowTaskVo flowTaskVo) {
+ return flowTaskService.stopProcess(flowTaskVo);
+ }
+
+ @ApiOperation(value = "撤回流程", response = FlowTaskDto.class)
+ @Log(title = "撤回流程", businessType = BusinessType.UPDATE)
+ @PostMapping(value = "/revokeProcess")
+ public AjaxResult revokeProcess(@RequestBody FlowTaskVo flowTaskVo) {
+ return flowTaskService.revokeProcess(flowTaskVo);
+ }
+
+ @ApiOperation(value = "获取待办列表", response = FlowTaskDto.class)
+ @GetMapping(value = "/todoList")
+ public TableDataInfo todoList(FlowQueryVo queryVo) {
+ PageInfo list = flowTaskService.todoList(queryVo);
+ return getDataTable(list);
+ }
+
+ @ApiOperation(value = "获取已办任务", response = FlowTaskDto.class)
+ @GetMapping(value = "/finishedList")
+ public TableDataInfo finishedList(FlowQueryVo queryVo) {
+ PageInfo list = flowTaskService.finishedList(queryVo);
+ return getDataTable(list);
+ }
+
+
+ @ApiOperation(value = "流程历史流转记录", response = FlowTaskDto.class)
+ @GetMapping(value = "/flowRecord")
+ public AjaxResult flowRecord(String procInsId, String deployId) {
+ return flowTaskService.flowRecord(procInsId, deployId);
+ }
+
+ @ApiOperation(value = "根据任务ID查询挂载的表单信息")
+ @GetMapping(value = "/getTaskForm")
+ public AjaxResult getTaskForm(String taskId) {
+ return flowTaskService.getTaskForm(taskId);
+ }
+
+
+ @ApiOperation(value = "流程初始化表单", response = FlowTaskDto.class)
+ @GetMapping(value = "/flowFormData")
+ public AjaxResult flowFormData(String deployId) {
+ return flowTaskService.flowFormData(deployId);
+ }
+
+ @ApiOperation(value = "获取流程变量", response = FlowTaskDto.class)
+ @GetMapping(value = "/processVariables/{taskId}")
+ public AjaxResult processVariables(@ApiParam(value = "流程任务Id") @PathVariable(value = "taskId") String taskId) {
+ return flowTaskService.processVariables(taskId);
+ }
+
+ @ApiOperation(value = "审批任务")
+ @Log(title = "审批任务", businessType = BusinessType.UPDATE)
+ @PostMapping(value = "/complete")
+ public AjaxResult complete(@RequestBody FlowTaskVo flowTaskVo) {
+ return flowTaskService.complete(flowTaskVo);
+ }
+
+ @ApiOperation(value = "驳回任务")
+ @Log(title = "驳回任务", businessType = BusinessType.UPDATE)
+ @PostMapping(value = "/reject")
+ public AjaxResult taskReject(@RequestBody FlowTaskVo flowTaskVo) {
+ flowTaskService.taskReject(flowTaskVo);
+ return AjaxResult.success();
+ }
+
+ @ApiOperation(value = "退回任务")
+ @Log(title = "退回任务", businessType = BusinessType.UPDATE)
+ @PostMapping(value = "/return")
+ public AjaxResult taskReturn(@RequestBody FlowTaskVo flowTaskVo) {
+ flowTaskService.taskReturn(flowTaskVo);
+ return AjaxResult.success();
+ }
+
+ @ApiOperation(value = "获取所有可回退的节点")
+ @PostMapping(value = "/returnList")
+ public AjaxResult findReturnTaskList(@RequestBody FlowTaskVo flowTaskVo) {
+ return flowTaskService.findReturnTaskList(flowTaskVo);
+ }
+
+ @ApiOperation(value = "删除任务")
+ @Log(title = "删除任务", businessType = BusinessType.DELETE)
+ @DeleteMapping(value = "/delete")
+ public AjaxResult delete(@RequestBody FlowTaskVo flowTaskVo) {
+ flowTaskService.deleteTask(flowTaskVo);
+ return AjaxResult.success();
+ }
+
+ @ApiOperation(value = "认领/签收任务")
+ @PostMapping(value = "/claim")
+ public AjaxResult claim(@RequestBody FlowTaskVo flowTaskVo) {
+ flowTaskService.claim(flowTaskVo);
+ return AjaxResult.success();
+ }
+
+ @ApiOperation(value = "取消认领/签收任务")
+ @PostMapping(value = "/unClaim")
+ public AjaxResult unClaim(@RequestBody FlowTaskVo flowTaskVo) {
+ flowTaskService.unClaim(flowTaskVo);
+ return AjaxResult.success();
+ }
+
+ @ApiOperation(value = "委派任务")
+ @PostMapping(value = "/delegateTask")
+ public AjaxResult delegate(@RequestBody FlowTaskVo flowTaskVo) {
+ flowTaskService.delegateTask(flowTaskVo);
+ return AjaxResult.success();
+ }
+
+ @ApiOperation(value = "任务归还")
+ @PostMapping(value = "/resolveTask")
+ public AjaxResult resolveTask(@RequestBody FlowTaskVo flowTaskVo) {
+ flowTaskService.resolveTask(flowTaskVo);
+ return AjaxResult.success();
+ }
+
+ @ApiOperation(value = "转办任务")
+ @PostMapping(value = "/assignTask")
+ public AjaxResult assign(@RequestBody FlowTaskVo flowTaskVo) {
+ flowTaskService.assignTask(flowTaskVo);
+ return AjaxResult.success();
+ }
+
+ @PostMapping(value = "/addMultiInstanceExecution")
+ @ApiOperation(value = "多实例加签")
+ public AjaxResult addMultiInstanceExecution(@RequestBody FlowTaskVo flowTaskVo) {
+ flowTaskService.addMultiInstanceExecution(flowTaskVo);
+ return AjaxResult.success("加签成功");
+ }
+
+ @PostMapping(value = "/deleteMultiInstanceExecution")
+ @ApiOperation(value = "多实例减签")
+ public AjaxResult deleteMultiInstanceExecution(@RequestBody FlowTaskVo flowTaskVo) {
+ flowTaskService.deleteMultiInstanceExecution(flowTaskVo);
+ return AjaxResult.success("减签成功");
+ }
+
+ @ApiOperation(value = "获取下一节点")
+ @PostMapping(value = "/nextFlowNode")
+ public AjaxResult getNextFlowNode(@RequestBody FlowTaskVo flowTaskVo) {
+ return flowTaskService.getNextFlowNode(flowTaskVo);
+ }
+
+ @ApiOperation(value = "流程发起时获取下一节点")
+ @PostMapping(value = "/nextFlowNodeByStart")
+ public AjaxResult getNextFlowNodeByStart(@RequestBody FlowTaskVo flowTaskVo) {
+ return flowTaskService.getNextFlowNodeByStart(flowTaskVo);
+ }
+
+ /**
+ * 生成流程图
+ *
+ * @param processId 任务ID
+ */
+ @GetMapping("/diagram/{processId}")
+ public void genProcessDiagram(HttpServletResponse response,
+ @PathVariable("processId") String processId) {
+ InputStream inputStream = flowTaskService.diagram(processId);
+ OutputStream os = null;
+ BufferedImage image = null;
+ try {
+ image = ImageIO.read(inputStream);
+ response.setContentType("image/png");
+ os = response.getOutputStream();
+ if (image != null) {
+ ImageIO.write(image, "png", os);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ if (os != null) {
+ os.flush();
+ os.close();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * 获取流程执行节点
+ *
+ * @param procInsId 流程实例编号
+ * @param procInsId 任务执行编号
+ */
+ @GetMapping("/flowViewer/{procInsId}/{executionId}")
+ public AjaxResult getFlowViewer(@PathVariable("procInsId") String procInsId,
+ @PathVariable("executionId") String executionId) {
+ return flowTaskService.getFlowViewer(procInsId, executionId);
+ }
+
+ /**
+ * 流程节点信息
+ *
+ * @param procInsId 流程实例id
+ * @return
+ */
+ @GetMapping("/flowXmlAndNode")
+ public AjaxResult flowXmlAndNode(@RequestParam(value = "procInsId", required = false) String procInsId,
+ @RequestParam(value = "deployId", required = false) String deployId) {
+ return flowTaskService.flowXmlAndNode(procInsId, deployId);
+ }
+
+ /**
+ * 流程节点表单
+ *
+ * @param taskId 流程任务编号
+ * @return
+ */
+ @GetMapping("/flowTaskForm")
+ public AjaxResult flowTaskForm(@RequestParam(value = "taskId", required = false) String taskId) throws Exception {
+ return flowTaskService.flowTaskForm(taskId);
+ }
+
+ /**
+ * 流程节点信息
+ *
+ * @param procInsId 流程实例编号
+ * @param elementId 流程节点编号
+ * @return
+ */
+ @GetMapping("/flowTaskInfo")
+ public AjaxResult flowTaskInfo(@RequestParam(value = "procInsId") String procInsId,
+ @RequestParam(value = "elementId") String elementId) {
+ return flowTaskService.flowTaskInfo(procInsId, elementId);
+ }
+
+}
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowableCategoryController.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowableCategoryController.java
deleted file mode 100644
index 5dbd2ee9..00000000
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowableCategoryController.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package com.yanzhu.flowable.controller;
-
-import com.yanzhu.common.core.utils.poi.ExcelUtil;
-import com.yanzhu.common.core.web.controller.BaseController;
-import com.yanzhu.common.core.web.domain.AjaxResult;
-import com.yanzhu.common.core.web.page.TableDataInfo;
-import com.yanzhu.common.log.annotation.Log;
-import com.yanzhu.common.log.enums.BusinessType;
-import com.yanzhu.common.security.annotation.RequiresPermissions;
-import com.yanzhu.flowable.domain.FlowableCategory;
-import com.yanzhu.flowable.service.IFlowableCategoryService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-
-import javax.servlet.http.HttpServletResponse;
-import java.util.List;
-
-/**
- * 流程分类Controller
- *
- * @author ruoyi
- * @date 2023-11-27
- */
-@RestController
-@RequestMapping("/category")
-public class FlowableCategoryController extends BaseController
-{
- @Autowired
- private IFlowableCategoryService flowableCategoryService;
-
- /**
- * 查询流程分类列表
- */
- @RequiresPermissions("flow:flow_classify:list")
- @GetMapping("/list")
- public TableDataInfo list(FlowableCategory flowableCategory)
- {
- startPage();
- List list = flowableCategoryService.selectFlowableCategoryList(flowableCategory);
- return getDataTable(list);
- }
-
- /**
- * 导出流程分类列表
- */
- @RequiresPermissions("flow:flow_classify:export")
- @Log(title = "流程分类", businessType = BusinessType.EXPORT)
- @PostMapping("/export")
- public void export(HttpServletResponse response, FlowableCategory flowableCategory)
- {
- List list = flowableCategoryService.selectFlowableCategoryList(flowableCategory);
- ExcelUtil util = new ExcelUtil(FlowableCategory.class);
- util.exportExcel(response, list, "流程分类数据");
- }
-
- /**
- * 获取流程分类详细信息
- */
- @RequiresPermissions("flow:flow_classify:query")
- @GetMapping(value = "/{id}")
- public AjaxResult getInfo(@PathVariable("id") Long id)
- {
- return success(flowableCategoryService.selectFlowableCategoryById(id));
- }
-
- /**
- * 新增流程分类
- */
- @RequiresPermissions("flow:flow_classify:add")
- @Log(title = "流程分类", businessType = BusinessType.INSERT)
- @PostMapping
- public AjaxResult add(@RequestBody FlowableCategory flowableCategory)
- {
- return toAjax(flowableCategoryService.insertFlowableCategory(flowableCategory));
- }
-
- /**
- * 修改流程分类
- */
- @RequiresPermissions("flow:flow_classify:update")
- @Log(title = "流程分类", businessType = BusinessType.UPDATE)
- @PutMapping
- public AjaxResult edit(@RequestBody FlowableCategory flowableCategory)
- {
- return toAjax(flowableCategoryService.updateFlowableCategory(flowableCategory));
- }
-
- /**
- * 删除流程分类
- */
- @RequiresPermissions("flow:flow_classify:delete")
- @Log(title = "流程分类", businessType = BusinessType.DELETE)
- @DeleteMapping("/{ids}")
- public AjaxResult remove(@PathVariable Long[] ids)
- {
- return toAjax(flowableCategoryService.deleteFlowableCategoryByIds(ids));
- }
-}
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowableDeployController.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowableDeployController.java
deleted file mode 100644
index 9604ac18..00000000
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowableDeployController.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package com.yanzhu.flowable.controller;
-
-import com.yanzhu.common.core.web.controller.BaseController;
-import com.yanzhu.common.core.web.domain.AjaxResult;
-import com.yanzhu.common.core.web.page.TableDataInfo;
-import com.yanzhu.common.log.annotation.Log;
-import com.yanzhu.common.log.enums.BusinessType;
-import com.yanzhu.common.security.annotation.RequiresPermissions;
-import com.yanzhu.flowable.domain.FlowableDeploy;
-import com.yanzhu.flowable.service.IFlowableDeployService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.List;
-
-/**
- * 流程部署Controller
- *
- * @author ruoyi
- * @date 2023-12-18
- */
-@RestController
-@RequestMapping("/deploy")
-public class FlowableDeployController extends BaseController
-{
- @Autowired
- private IFlowableDeployService flowableDeployService;
-
- /**
- * 查询流程部署列表
- */
- @RequiresPermissions("flowable:deploy:list")
- @GetMapping("/list")
- public TableDataInfo list(FlowableDeploy flowableDeploy)
- {
- startPage();
- List list = flowableDeployService.selectFlowableDeployList(flowableDeploy);
- return getDataTable(list);
- }
-
- /**
- * 获取流程部署详细信息
- */
- @RequiresPermissions("flowable:deploy:query")
- @GetMapping(value = "/{definitionId}")
- public AjaxResult getInfo(@PathVariable("definitionId") String definitionId)
- {
- return success(flowableDeployService.selectFlowableDeployByDefinitionId(definitionId));
- }
-
-
- /**
- * 删除流程部署
- */
- @RequiresPermissions("flowable:deploy:remove")
- @Log(title = "流程部署", businessType = BusinessType.DELETE)
- @DeleteMapping("/{definitionIds}")
- public AjaxResult remove(@PathVariable String[] definitionIds)
- {
- return toAjax(flowableDeployService.deleteFlowableDeployByDefinitionIds(definitionIds));
- }
- /**
- * 查询流程部署版本列表
- */
- @RequiresPermissions("flowable:deploy:publishList")
- @GetMapping("/publishList")
- public TableDataInfo publishList(@RequestParam String processKey) {
- startPage();
-
- List list = flowableDeployService.queryPublishList(processKey);
- return getDataTable(list);
- }
-
- /**
- * 激活或挂起流程
- *
- * @param state 状态(active:激活 suspended:挂起)
- * @param definitionId 流程定义ID
- */
- @RequiresPermissions("flowable:deploy:state")
- @PutMapping(value = "/changeState")
- public AjaxResult changeState(@RequestParam String state, @RequestParam String definitionId) {
- flowableDeployService.updateState(definitionId,state);
- return success();
- }
-
- /**
- * 读取xml文件
- * @param definitionId 流程定义ID
- * @return
- */
- @RequiresPermissions("flowable:deploy:bpmnXml")
- @GetMapping("/bpmnXml/{definitionId}")
- public AjaxResult getBpmnXml(@PathVariable(value = "definitionId") String definitionId) {
- return AjaxResult.success("查询成功", flowableDeployService.queryBpmnXmlById(definitionId));
- }
-}
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowableFieldDefController.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowableFieldDefController.java
deleted file mode 100644
index 43a830fc..00000000
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowableFieldDefController.java
+++ /dev/null
@@ -1,109 +0,0 @@
-package com.yanzhu.flowable.controller;
-
-import com.yanzhu.common.core.utils.poi.ExcelUtil;
-import com.yanzhu.common.core.web.controller.BaseController;
-import com.yanzhu.common.core.web.domain.AjaxResult;
-import com.yanzhu.common.core.web.page.TableDataInfo;
-import com.yanzhu.common.log.annotation.Log;
-import com.yanzhu.common.log.enums.BusinessType;
-import com.yanzhu.common.security.annotation.RequiresPermissions;
-import com.yanzhu.flowable.domain.FlowableFieldDef;
-import com.yanzhu.flowable.service.IFlowableFieldDefService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-
-import javax.servlet.http.HttpServletResponse;
-import java.util.List;
-
-/**
- * 流程字段定义Controller
- *
- * @author ruoyi
- * @date 2023-12-26
- */
-@RestController
-@RequestMapping("/def")
-public class FlowableFieldDefController extends BaseController
-{
- @Autowired
- private IFlowableFieldDefService flowableFieldDefService;
-
- /**
- * 查询流程字段定义列表
- */
- @RequiresPermissions("flowable:def:list")
- @GetMapping("/list")
- public TableDataInfo list(FlowableFieldDef flowableFieldDef)
- {
- startPage();
- List list = flowableFieldDefService.selectFlowableFieldDefList(flowableFieldDef);
- return getDataTable(list);
- }
-
- /**
- * 导出流程字段定义列表
- */
- @RequiresPermissions("flowable:def:export")
- @Log(title = "流程字段定义", businessType = BusinessType.EXPORT)
- @PostMapping("/export")
- public void export(HttpServletResponse response, FlowableFieldDef flowableFieldDef)
- {
- List list = flowableFieldDefService.selectFlowableFieldDefList(flowableFieldDef);
- ExcelUtil util = new ExcelUtil(FlowableFieldDef.class);
- util.exportExcel(response, list, "流程字段定义数据");
- }
-
- /**
- * 获取流程字段定义详细信息
- */
- @RequiresPermissions("flowable:def:query")
- @GetMapping(value = "/{id}")
- public AjaxResult getInfo(@PathVariable("id") String id)
- {
- return success(flowableFieldDefService.selectFlowableFieldDefById(id));
- }
-
- /**
- * 新增流程字段定义
- */
- @RequiresPermissions("flowable:def:add")
- @Log(title = "流程字段定义", businessType = BusinessType.INSERT)
- @PostMapping
- public AjaxResult add(@RequestBody FlowableFieldDef flowableFieldDef)
- {
- return toAjax(flowableFieldDefService.insertFlowableFieldDef(flowableFieldDef));
- }
-
- /**
- * 修改流程字段定义
- */
- @RequiresPermissions("flowable:def:edit")
- @Log(title = "流程字段定义", businessType = BusinessType.UPDATE)
- @PutMapping
- public AjaxResult edit(@RequestBody FlowableFieldDef flowableFieldDef)
- {
- return toAjax(flowableFieldDefService.updateFlowableFieldDef(flowableFieldDef));
- }
-
- /**
- * 删除流程字段定义
- */
- @RequiresPermissions("flowable:def:remove")
- @Log(title = "流程字段定义", businessType = BusinessType.DELETE)
- @DeleteMapping("/{ids}")
- public AjaxResult remove(@PathVariable String[] ids)
- {
- return toAjax(flowableFieldDefService.deleteFlowableFieldDefByIds(ids));
- }
- /**
- * 查询流程字段定义列表(不翻页)
- */
- @RequiresPermissions("flowable:def:listAll")
- @GetMapping("/listAll")
- public AjaxResult listAll(FlowableFieldDef flowableFieldDef)
- {
- List list = flowableFieldDefService.selectFlowableFieldDefList(flowableFieldDef);
- return success(list);
- }
-
-}
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowableFieldRefController.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowableFieldRefController.java
deleted file mode 100644
index 2d7faf9a..00000000
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowableFieldRefController.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package com.yanzhu.flowable.controller;
-
-import com.yanzhu.common.core.utils.poi.ExcelUtil;
-import com.yanzhu.common.core.web.controller.BaseController;
-import com.yanzhu.common.core.web.domain.AjaxResult;
-import com.yanzhu.common.core.web.page.TableDataInfo;
-import com.yanzhu.common.log.annotation.Log;
-import com.yanzhu.common.log.enums.BusinessType;
-import com.yanzhu.common.security.annotation.RequiresPermissions;
-import com.yanzhu.flowable.domain.FlowableFieldDef;
-import com.yanzhu.flowable.domain.FlowableFieldRef;
-import com.yanzhu.flowable.domain.FlowableFieldSearch;
-import com.yanzhu.flowable.service.IFlowableFieldDefService;
-import com.yanzhu.flowable.service.IFlowableFieldRefService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-
-import javax.servlet.http.HttpServletResponse;
-import java.util.List;
-
-/**
- * 流程字段引用关系Controller
- *
- * @author ruoyi
- * @date 2023-12-26
- */
-@RestController
-@RequestMapping("/ref")
-public class FlowableFieldRefController extends BaseController
-{
- @Autowired
- private IFlowableFieldRefService flowableFieldRefService;
-
- @Autowired
- private IFlowableFieldDefService flowableFieldDefService;
- /**
- * 查询流程字段引用关系列表
- */
- @RequiresPermissions("flowable:ref:list")
- @GetMapping("/list")
- public TableDataInfo list(FlowableFieldRef flowableFieldRef)
- {
- startPage();
- List list = flowableFieldRefService.selectFlowableFieldRefList(flowableFieldRef);
- return getDataTable(list);
- }
-
- /**
- * 导出流程字段引用关系列表
- */
- @RequiresPermissions("flowable:ref:export")
- @Log(title = "流程字段引用关系", businessType = BusinessType.EXPORT)
- @PostMapping("/export")
- public void export(HttpServletResponse response, FlowableFieldRef flowableFieldRef)
- {
- List list = flowableFieldRefService.selectFlowableFieldRefList(flowableFieldRef);
- ExcelUtil util = new ExcelUtil(FlowableFieldRef.class);
- util.exportExcel(response, list, "流程字段引用关系数据");
- }
-
- /**
- * 获取流程字段引用关系详细信息
- */
- @RequiresPermissions("flowable:ref:query")
- @GetMapping(value = "/{id}")
- public AjaxResult getInfo(@PathVariable("id") String id)
- {
- return success(flowableFieldRefService.selectFlowableFieldRefById(id));
- }
-
- /**
- * 新增流程字段引用关系
- */
- @RequiresPermissions("flowable:ref:add")
- @Log(title = "流程字段引用关系", businessType = BusinessType.INSERT)
- @PostMapping
- public AjaxResult add(@RequestBody FlowableFieldRef flowableFieldRef)
- {
- return toAjax(flowableFieldRefService.insertFlowableFieldRef(flowableFieldRef));
- }
-
- /**
- * 修改流程字段引用关系
- */
- @RequiresPermissions("flowable:ref:edit")
- @Log(title = "流程字段引用关系", businessType = BusinessType.UPDATE)
- @PutMapping
- public AjaxResult edit(@RequestBody FlowableFieldRef flowableFieldRef)
- {
- return toAjax(flowableFieldRefService.updateFlowableFieldRef(flowableFieldRef));
- }
-
- /**
- * 删除流程字段引用关系
- */
- @RequiresPermissions("flowable:ref:remove")
- @Log(title = "流程字段引用关系", businessType = BusinessType.DELETE)
- @DeleteMapping("/{ids}")
- public AjaxResult remove(@PathVariable String[] ids)
- {
- return toAjax(flowableFieldRefService.deleteFlowableFieldRefByIds(ids));
- }
- /**
- * 查询流程字段引用关系列表(不翻页,关联字段定义表查询)
- */
- @RequiresPermissions("flowable:ref:listCombination")
- @GetMapping("/listCombination")
- public AjaxResult listCombination(FlowableFieldSearch flowableFieldSearch)
- {
- List list = flowableFieldDefService.listCombination(flowableFieldSearch);
- return success(list);
- }
-}
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowableModelController.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowableModelController.java
deleted file mode 100644
index 60312c88..00000000
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowableModelController.java
+++ /dev/null
@@ -1,172 +0,0 @@
-package com.yanzhu.flowable.controller;
-
-import com.yanzhu.common.core.utils.poi.ExcelUtil;
-import com.yanzhu.common.core.web.controller.BaseController;
-import com.yanzhu.common.core.web.domain.AjaxResult;
-import com.yanzhu.common.core.web.page.TableDataInfo;
-import com.yanzhu.common.log.annotation.Log;
-import com.yanzhu.common.log.enums.BusinessType;
-import com.yanzhu.common.security.annotation.RequiresPermissions;
-import com.yanzhu.flowable.domain.FlowableModel;
-import com.yanzhu.flowable.domain.bo.FlowableModelBo;
-import com.yanzhu.flowable.service.IFlowableModelService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-
-import javax.servlet.http.HttpServletResponse;
-import javax.validation.constraints.NotNull;
-import java.io.UnsupportedEncodingException;
-import java.util.List;
-
-/**
- * 流程模型Controller
- *
- * @author ruoyi
- * @date 2023-11-28
- */
-@RestController
-@RequestMapping("/model")
-@Slf4j
-public class FlowableModelController extends BaseController
-{
- @Autowired
- private IFlowableModelService flowableModelService;
-
- /**
- * 查询流程模型列表
- */
- @RequiresPermissions("flow:flow_model:list")
- @GetMapping("/list")
- public TableDataInfo list(FlowableModelBo flowableModelBo)
- {
- startPage();
- List list = flowableModelService.selectFlowableModelList(flowableModelBo);
- return getDataTable(list);
- }
-
- /**
- * 导出流程模型列表
- */
- @RequiresPermissions("flow:flow_model:export")
- @Log(title = "流程模型", businessType = BusinessType.EXPORT)
- @PostMapping("/export")
- public void export(HttpServletResponse response, FlowableModelBo flowableModel)
- {
- List list = flowableModelService.selectFlowableModelList(flowableModel);
- ExcelUtil util = new ExcelUtil(FlowableModel.class);
- util.exportExcel(response, list, "流程模型数据");
- }
-
- /**
- * 获取流程模型详细信息
- */
- @RequiresPermissions("flow:flow_model:query")
- @GetMapping(value = "/{modelId}")
- public AjaxResult getInfo(@PathVariable("modelId") String modelId)
- {
- return success(flowableModelService.selectFlowableModelByModelId(modelId));
- }
-
- /**
- * 新增流程模型
- */
- @RequiresPermissions("flow:flow_model:add")
- @Log(title = "流程模型", businessType = BusinessType.INSERT)
- @PostMapping
- public AjaxResult add(@RequestBody FlowableModel flowableModel)
- {
- return toAjax(flowableModelService.insertFlowableModel(flowableModel));
- }
-
- /**
- * 修改流程模型
- */
- @RequiresPermissions("flow:flow_model:update")
- @Log(title = "流程模型", businessType = BusinessType.UPDATE)
- @PutMapping
- public AjaxResult edit(@RequestBody FlowableModel flowableModel)
- {
- return toAjax(flowableModelService.updateFlowableModel(flowableModel));
- }
-
- /**
- * 删除流程模型
- */
- @RequiresPermissions("flow:flow_model:delete")
- @Log(title = "流程模型", businessType = BusinessType.DELETE)
- @DeleteMapping("/{modelIds}")
- public AjaxResult remove(@PathVariable String[] modelIds)
- {
- return toAjax(flowableModelService.deleteFlowableModelByModelIds(modelIds));
- }
- /**
- * 部署流程模型
- *
- * @param modelId 流程模型主键
- */
- @RequiresPermissions("flow:flow_model:deploy")
- @Log(title = "部署流程模型", businessType = BusinessType.OTHER)
- @PostMapping("/deploy")
- public AjaxResult deployModel(@RequestParam String modelId) {
- try {
- flowableModelService.deployModel(modelId);
- } catch (UnsupportedEncodingException e) {
- log.error("部署失败!",e);
- }
- return success();
- }
- /**
- * 获取流程表单详细信息
- *
- * @param modelId 模型id
- */
- @RequiresPermissions("flow:flow_model:queryXml")
- @GetMapping(value = "/getBpmnXml/{modelId}")
- public AjaxResult getBpmnXml(@NotNull(message = "主键不能为空") @PathVariable("modelId") String modelId) {
- try {
- return AjaxResult.success("查询成功",flowableModelService.queryBpmnXmlById(modelId));
- } catch (UnsupportedEncodingException e) {
- log.error("获取模型xml失败!模型id:"+modelId,e);
- return AjaxResult.error("获取模型xml失败!");
- }
- }
- /**
- * 查询流程模型版本历史列表
- *
- * @param modelBo 流程模型对象
- */
- @RequiresPermissions("flow:flow_model:historyList")
- @GetMapping("/historyList")
- public TableDataInfo historyList(FlowableModelBo modelBo) {
- startPage();
- List list = flowableModelService.historyList(modelBo);
- return getDataTable(list);
- }
- /**
- * 保存(更新或插入新版本)流程模型
- */
- @RequiresPermissions("flow:flow_model::save")
- @PostMapping("/save")
- public AjaxResult save(@RequestBody FlowableModelBo modelBo) {
- flowableModelService.saveModel(modelBo);
- return success();
- }
- /**
- * 设为最新流程模型
- * @param modelId
- * @return
- */
- @RequiresPermissions("flow:flow_model:lastest")
- @PostMapping("/latest/")
- public AjaxResult latest(@RequestParam String modelId) {
- try {
- flowableModelService.latestModel(modelId);
- return success();
- } catch (UnsupportedEncodingException e) {
- log.error("设置最新版本失败!",e);
- return error("设置最新版本失败!");
- }
-
- }
-}
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowableModelPageController.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowableModelPageController.java
deleted file mode 100644
index 74056f87..00000000
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowableModelPageController.java
+++ /dev/null
@@ -1,152 +0,0 @@
-package com.yanzhu.flowable.controller;
-
-import com.yanzhu.common.core.utils.poi.ExcelUtil;
-import com.yanzhu.common.core.web.controller.BaseController;
-import com.yanzhu.common.core.web.domain.AjaxResult;
-import com.yanzhu.common.core.web.page.TableDataInfo;
-import com.yanzhu.common.log.annotation.Log;
-import com.yanzhu.common.log.enums.BusinessType;
-import com.yanzhu.common.security.annotation.RequiresPermissions;
-import com.yanzhu.flowable.domain.FlowableModelPage;
-import com.yanzhu.flowable.service.IFlowableModelPageService;
-import io.jsonwebtoken.lang.Collections;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-
-import javax.servlet.http.HttpServletResponse;
-import java.util.List;
-
-/**
- * 建模页面绑定Controller
- *
- * @author ruoyi
- * @date 2023-12-25
- */
-@RestController
-@RequestMapping("/page")
-public class FlowableModelPageController extends BaseController
-{
- @Autowired
- private IFlowableModelPageService flowableModelPageService;
-
- /**
- * 查询建模页面绑定列表
- */
- @RequiresPermissions("flowable:page:list")
- @GetMapping("/list")
- public TableDataInfo list(FlowableModelPage flowableModelPage)
- {
- startPage();
- List list = flowableModelPageService.selectFlowableModelPageList(flowableModelPage);
- return getDataTable(list);
- }
-
- /**
- * 导出建模页面绑定列表
- */
- @RequiresPermissions("flowable:page:export")
- @Log(title = "建模页面绑定", businessType = BusinessType.EXPORT)
- @PostMapping("/export")
- public void export(HttpServletResponse response, FlowableModelPage flowableModelPage)
- {
- List list = flowableModelPageService.selectFlowableModelPageList(flowableModelPage);
- ExcelUtil util = new ExcelUtil(FlowableModelPage.class);
- util.exportExcel(response, list, "建模页面绑定数据");
- }
-
- /**
- * 获取建模页面绑定详细信息
- */
- @RequiresPermissions("flowable:page:query")
- @GetMapping(value = "/{id}")
- public AjaxResult getInfo(@PathVariable("id") String id)
- {
- return success(flowableModelPageService.selectFlowableModelPageById(id));
- }
-
- /**
- * 新增建模页面绑定
- */
- @RequiresPermissions("flowable:page:add")
- @Log(title = "建模页面绑定", businessType = BusinessType.INSERT)
- @PostMapping
- public AjaxResult add(@RequestBody FlowableModelPage flowableModelPage)
- {
- return toAjax(flowableModelPageService.insertFlowableModelPage(flowableModelPage));
- }
-
- /**
- * 修改建模页面绑定
- */
- @RequiresPermissions("flowable:page:edit")
- @Log(title = "建模页面绑定", businessType = BusinessType.UPDATE)
- @PutMapping
- public AjaxResult edit(@RequestBody FlowableModelPage flowableModelPage)
- {
- return toAjax(flowableModelPageService.updateFlowableModelPage(flowableModelPage));
- }
-
- /**
- * 删除建模页面绑定
- */
- @RequiresPermissions("flowable:page:remove")
- @Log(title = "建模页面绑定", businessType = BusinessType.DELETE)
- @DeleteMapping("/{ids}")
- public AjaxResult remove(@PathVariable String[] ids)
- {
- return toAjax(flowableModelPageService.deleteFlowableModelPageByIds(ids));
- }
- /**
- * 建模页面绑定
- */
- @RequiresPermissions("flowable:page:bind")
- @Log(title = "建模页面绑定", businessType = BusinessType.UPDATE)
- @PutMapping(value="/bind")
- public AjaxResult bind(@RequestBody FlowableModelPage flowableModelPage)
- {
- List list = flowableModelPageService.selectFlowableModelPageListByBind(flowableModelPage);
- if(Collections.isEmpty(list)){
- return toAjax(flowableModelPageService.insertFlowableModelPage(flowableModelPage));
- }else {
- flowableModelPage.setId(list.get(0).getId());
- return toAjax(flowableModelPageService.updateFlowableModelPage(flowableModelPage));
- }
- }
- /**
- * 建模页面单页面查询(根据模块,流程标识,页面名称查询)
- */
- @RequiresPermissions("flowable:page:findPage")
- @Log(title = "建模页面单页面查询", businessType = BusinessType.UPDATE)
- @PostMapping(value="/findPage")
- public AjaxResult findPage(@RequestBody FlowableModelPage flowableModelPage)
- {
- FlowableModelPage page = flowableModelPageService.selectFlowableModelPageSingle(flowableModelPage);
- return success(page);
- }
- /**
- * 建模页面模块页面查询(按模块,流程标识查询)
- */
- @RequiresPermissions("flowable:page:findModulePage")
- @Log(title = "建模页面模块页面查询", businessType = BusinessType.UPDATE)
- @PostMapping(value="/findModulePage")
- public AjaxResult findModulePage(@RequestBody FlowableModelPage flowableModelPage)
- {
- List list = flowableModelPageService.selectFlowableModelPage(flowableModelPage);
- return success(list);
- }
- /**
- * 建模页面解绑
- */
- @RequiresPermissions("flowable:page:unbind")
- @Log(title = "建模页面解绑", businessType = BusinessType.UPDATE)
- @PutMapping(value="/unbind")
- public AjaxResult unbind(@RequestBody FlowableModelPage flowableModelPage)
- {
- List list = flowableModelPageService.selectFlowableModelPageListByBind(flowableModelPage);
- if(Collections.isEmpty(list)){
- return error("页面没找到!");
- }else {
- return toAjax(flowableModelPageService.deleteFlowableModelPageById(list.get(0).getId()));
- }
- }
-}
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/SysExpressionController.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/SysExpressionController.java
new file mode 100644
index 00000000..fa362f54
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/SysExpressionController.java
@@ -0,0 +1,92 @@
+package com.yanzhu.flowable.controller;
+
+import com.yanzhu.common.core.utils.poi.ExcelUtil;
+import com.yanzhu.common.core.web.controller.BaseController;
+import com.yanzhu.common.core.web.domain.AjaxResult;
+import com.yanzhu.common.core.web.page.TableDataInfo;
+import com.yanzhu.common.log.annotation.Log;
+import com.yanzhu.common.log.enums.BusinessType;
+import com.yanzhu.common.security.annotation.RequiresPermissions;
+import com.yanzhu.flowable.domain.SysExpression;
+import com.yanzhu.flowable.service.ISysExpressionService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+/**
+ * 流程达式Controller
+ *
+ * @author yanzhu
+ * @date 2022-12-12
+ */
+@RestController
+@RequestMapping("/expression")
+public class SysExpressionController extends BaseController {
+ @Autowired
+ private ISysExpressionService sysExpressionService;
+ private Long id;
+
+ /**
+ * 查询流程达式列表
+ */
+ @RequiresPermissions("system:expression:list")
+ @GetMapping("/list")
+ public TableDataInfo list(SysExpression sysExpression) {
+ startPage();
+ List list = sysExpressionService.selectSysExpressionList(sysExpression);
+ return getDataTable(list);
+ }
+
+ /**
+ * 导出流程达式列表
+ */
+ @RequiresPermissions("system:expression:export")
+ @Log(title = "流程达式", businessType = BusinessType.EXPORT)
+ @PostMapping("/export")
+ public void export(HttpServletResponse response, SysExpression sysExpression) {
+ List list = sysExpressionService.selectSysExpressionList(sysExpression);
+ ExcelUtil util = new ExcelUtil(SysExpression.class);
+ util.exportExcel(response, list, "流程达式数据");
+ }
+
+ /**
+ * 获取流程达式详细信息
+ */
+ @RequiresPermissions("system:expression:query")
+ @GetMapping(value = "/{id}")
+ public AjaxResult getInfo(@PathVariable("id") Long id) {
+ return success(sysExpressionService.selectSysExpressionById(id));
+ }
+
+ /**
+ * 新增流程达式
+ */
+ @RequiresPermissions("system:expression:add")
+ @Log(title = "流程达式", businessType = BusinessType.INSERT)
+ @PostMapping
+ public AjaxResult add(@RequestBody SysExpression sysExpression) {
+ return toAjax(sysExpressionService.insertSysExpression(sysExpression));
+ }
+
+ /**
+ * 修改流程达式
+ */
+ @RequiresPermissions("system:expression:edit")
+ @Log(title = "流程达式", businessType = BusinessType.UPDATE)
+ @PutMapping
+ public AjaxResult edit(@RequestBody SysExpression sysExpression) {
+ return toAjax(sysExpressionService.updateSysExpression(sysExpression));
+ }
+
+ /**
+ * 删除流程达式
+ */
+ @RequiresPermissions("system:expression:remove")
+ @Log(title = "流程达式", businessType = BusinessType.DELETE)
+ @DeleteMapping("/{ids}")
+ public AjaxResult remove(@PathVariable Long[] ids) {
+ return toAjax(sysExpressionService.deleteSysExpressionByIds(ids));
+ }
+}
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/SysFormController.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/SysFormController.java
new file mode 100644
index 00000000..09611cba
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/SysFormController.java
@@ -0,0 +1,112 @@
+package com.yanzhu.flowable.controller;
+
+import com.yanzhu.common.core.utils.poi.ExcelUtil;
+import com.yanzhu.common.core.web.controller.BaseController;
+import com.yanzhu.common.core.web.domain.AjaxResult;
+import com.yanzhu.common.core.web.page.TableDataInfo;
+import com.yanzhu.common.log.annotation.Log;
+import com.yanzhu.common.log.enums.BusinessType;
+import com.yanzhu.common.security.annotation.RequiresPermissions;
+import com.yanzhu.flowable.domain.SysDeployForm;
+import com.yanzhu.flowable.domain.SysForm;
+import com.yanzhu.flowable.service.ISysDeployFormService;
+import com.yanzhu.flowable.service.ISysFormService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+/**
+ * 流程表单Controller
+ *
+ * @author Tony
+ * @date 2021-04-03
+ */
+@RestController
+@RequestMapping("/form")
+public class SysFormController extends BaseController {
+ @Autowired
+ private ISysFormService SysFormService;
+
+ @Autowired
+ private ISysDeployFormService sysDeployFormService;
+
+ /**
+ * 查询流程表单列表
+ */
+ @RequiresPermissions("flowable:form:list")
+ @GetMapping("/list")
+ public TableDataInfo list(SysForm sysForm) {
+ startPage();
+ List list = SysFormService.selectSysFormList(sysForm);
+ return getDataTable(list);
+ }
+
+ @GetMapping("/formList")
+ public AjaxResult formList(SysForm sysForm) {
+ List list = SysFormService.selectSysFormList(sysForm);
+ return AjaxResult.success(list);
+ }
+
+ /**
+ * 导出流程表单列表
+ */
+ @RequiresPermissions("flowable:form:export")
+ @Log(title = "流程表单", businessType = BusinessType.EXPORT)
+ @GetMapping("/export")
+ public void export(HttpServletResponse response, SysForm sysForm) {
+ List list = SysFormService.selectSysFormList(sysForm);
+ ExcelUtil util = new ExcelUtil<>(SysForm.class);
+ util.exportExcel(response, list, "form");
+ }
+
+ /**
+ * 获取流程表单详细信息
+ */
+ @RequiresPermissions("flowable:form:query")
+ @GetMapping(value = "/{formId}")
+ public AjaxResult getInfo(@PathVariable("formId") Long formId) {
+ return AjaxResult.success(SysFormService.selectSysFormById(formId));
+ }
+
+ /**
+ * 新增流程表单
+ */
+ @RequiresPermissions("flowable:form:add")
+ @Log(title = "流程表单", businessType = BusinessType.INSERT)
+ @PostMapping
+ public AjaxResult add(@RequestBody SysForm sysForm) {
+ return toAjax(SysFormService.insertSysForm(sysForm));
+ }
+
+ /**
+ * 修改流程表单
+ */
+ @RequiresPermissions("flowable:form:edit")
+ @Log(title = "流程表单", businessType = BusinessType.UPDATE)
+ @PutMapping
+ public AjaxResult edit(@RequestBody SysForm sysForm) {
+ return toAjax(SysFormService.updateSysForm(sysForm));
+ }
+
+ /**
+ * 删除流程表单
+ */
+ @RequiresPermissions("flowable:form:remove")
+ @Log(title = "流程表单", businessType = BusinessType.DELETE)
+ @DeleteMapping("/{formIds}")
+ public AjaxResult remove(@PathVariable Long[] formIds) {
+ return toAjax(SysFormService.deleteSysFormByIds(formIds));
+ }
+
+
+ /**
+ * 挂载流程表单
+ */
+ @Log(title = "流程表单", businessType = BusinessType.INSERT)
+ @PostMapping("/addDeployForm")
+ public AjaxResult addDeployForm(@RequestBody SysDeployForm sysDeployForm) {
+ return toAjax(sysDeployFormService.insertSysDeployForm(sysDeployForm));
+ }
+}
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/SysListenerController.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/SysListenerController.java
new file mode 100644
index 00000000..5dec062b
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/SysListenerController.java
@@ -0,0 +1,98 @@
+package com.yanzhu.flowable.controller;
+
+import com.yanzhu.common.core.utils.poi.ExcelUtil;
+import com.yanzhu.common.core.web.controller.BaseController;
+import com.yanzhu.common.core.web.domain.AjaxResult;
+import com.yanzhu.common.core.web.page.TableDataInfo;
+import com.yanzhu.common.log.annotation.Log;
+import com.yanzhu.common.log.enums.BusinessType;
+import com.yanzhu.common.security.annotation.RequiresPermissions;
+import com.yanzhu.flowable.domain.SysListener;
+import com.yanzhu.flowable.service.ISysListenerService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+/**
+ * 流程监听Controller
+ *
+ * @author Tony
+ * @date 2022-12-25
+ */
+@RestController
+@RequestMapping("/listener")
+public class SysListenerController extends BaseController
+{
+ @Autowired
+ private ISysListenerService sysListenerService;
+
+ /**
+ * 查询流程监听列表
+ */
+ @RequiresPermissions("system:listener:list")
+ @GetMapping("/list")
+ public TableDataInfo list(SysListener sysListener)
+ {
+ startPage();
+ List list = sysListenerService.selectSysListenerList(sysListener);
+ return getDataTable(list);
+ }
+
+ /**
+ * 导出流程监听列表
+ */
+ @RequiresPermissions("system:listener:export")
+ @Log(title = "流程监听", businessType = BusinessType.EXPORT)
+ @PostMapping("/export")
+ public void export(HttpServletResponse response, SysListener sysListener)
+ {
+ List list = sysListenerService.selectSysListenerList(sysListener);
+ ExcelUtil util = new ExcelUtil(SysListener.class);
+ util.exportExcel(response, list, "流程监听数据");
+ }
+
+ /**
+ * 获取流程监听详细信息
+ */
+ @RequiresPermissions("system:listener:query")
+ @GetMapping(value = "/{id}")
+ public AjaxResult getInfo(@PathVariable("id") Long id)
+ {
+ return success(sysListenerService.selectSysListenerById(id));
+ }
+
+ /**
+ * 新增流程监听
+ */
+ @RequiresPermissions("system:listener:add")
+ @Log(title = "流程监听", businessType = BusinessType.INSERT)
+ @PostMapping
+ public AjaxResult add(@RequestBody SysListener sysListener)
+ {
+ return toAjax(sysListenerService.insertSysListener(sysListener));
+ }
+
+ /**
+ * 修改流程监听
+ */
+ @RequiresPermissions("system:listener:edit")
+ @Log(title = "流程监听", businessType = BusinessType.UPDATE)
+ @PutMapping
+ public AjaxResult edit(@RequestBody SysListener sysListener)
+ {
+ return toAjax(sysListenerService.updateSysListener(sysListener));
+ }
+
+ /**
+ * 删除流程监听
+ */
+ @RequiresPermissions("system:listener:remove")
+ @Log(title = "流程监听", businessType = BusinessType.DELETE)
+ @DeleteMapping("/{ids}")
+ public AjaxResult remove(@PathVariable Long[] ids)
+ {
+ return toAjax(sysListenerService.deleteSysListenerByIds(ids));
+ }
+}
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/flow/CustomProcessDiagramCanvas.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/flow/CustomProcessDiagramCanvas.java
index c84766ca..7a0baca5 100644
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/flow/CustomProcessDiagramCanvas.java
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/flow/CustomProcessDiagramCanvas.java
@@ -135,6 +135,7 @@ public class CustomProcessDiagramCanvas extends DefaultProcessDiagramCanvas {
SHELL_TASK_IMAGE = ImageIO.read(ReflectUtil.getResource("org/flowable/icons/shellTask.png", this.customClassLoader));
DMN_TASK_IMAGE = ImageIO.read(ReflectUtil.getResource("org/flowable/icons/dmnTask.png", this.customClassLoader));
CAMEL_TASK_IMAGE = ImageIO.read(ReflectUtil.getResource("org/flowable/icons/camelTask.png", this.customClassLoader));
+ MULE_TASK_IMAGE = ImageIO.read(ReflectUtil.getResource("org/flowable/icons/muleTask.png", this.customClassLoader));
HTTP_TASK_IMAGE = ImageIO.read(ReflectUtil.getResource("org/flowable/icons/httpTask.png", this.customClassLoader));
TIMER_IMAGE = ImageIO.read(ReflectUtil.getResource("org/flowable/icons/timer.png", this.customClassLoader));
COMPENSATE_THROW_IMAGE = ImageIO.read(ReflectUtil.getResource("org/flowable/icons/compensate-throw.png", this.customClassLoader));
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/flow/FindNextNodeUtil.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/flow/FindNextNodeUtil.java
index a4bd2442..ac886e3f 100644
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/flow/FindNextNodeUtil.java
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/flow/FindNextNodeUtil.java
@@ -159,13 +159,13 @@ public class FindNextNodeUtil {
/**
* 判断是否是多实例子流程并且需要设置集合类型变量
*/
- public static boolean checkSubProcess(String Id, Collection flowElements, List nextUser) {
+ public static boolean checkSubProcess(String id, Collection flowElements, List nextUser) {
for (FlowElement flowElement1 : flowElements) {
- if (flowElement1 instanceof SubProcess && flowElement1.getId().equals(Id)) {
+ if (flowElement1 instanceof SubProcess && flowElement1.getId().equals(id)) {
SubProcess sp = (SubProcess) flowElement1;
if (sp.getLoopCharacteristics() != null) {
- String inputDataItem = sp.getLoopCharacteristics().getInputDataItem();
+// String inputDataItem = sp.getLoopCharacteristics().getInputDataItem();
UserTask userTask = new UserTask();
userTask.setId(sp.getId());
userTask.setLoopCharacteristics(sp.getLoopCharacteristics());
@@ -251,7 +251,7 @@ public class FindNextNodeUtil {
*/
public static boolean expressionResult(Map map, String expression) {
Expression exp = AviatorEvaluator.compile(expression);
- final Object execute = exp.execute(map);
- return Boolean.parseBoolean(String.valueOf(execute));
+ return (Boolean)exp.execute(map);
+// return true;
}
}
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/flow/ModelHelper.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/flow/ModelHelper.java
deleted file mode 100644
index 5636c39b..00000000
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/flow/ModelHelper.java
+++ /dev/null
@@ -1,143 +0,0 @@
-package com.yanzhu.flowable.flow;
-
-import org.flowable.bpmn.converter.BpmnXMLConverter;
-import org.flowable.bpmn.model.Process;
-import org.flowable.bpmn.model.*;
-import org.flowable.common.engine.impl.util.io.StringStreamSource;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-/**
- * @author ruoyi
- * @createTime 2023/11/29 19:04
- */
-public class ModelHelper {
-
- private static final BpmnXMLConverter bpmnXMLConverter = new BpmnXMLConverter();
-
- /**
- * xml转bpmnModel对象
- *
- * @param xml xml
- * @return bpmnModel对象
- */
- public static BpmnModel getBpmnModel(String xml) {
- return bpmnXMLConverter.convertToBpmnModel(new StringStreamSource(xml), false, false);
- }
-
- /**
- * bpmnModel转xml对象
- *
- * @param bpmnModel bpmnModel对象
- * @return xml
- */
- public static byte[] getBpmnXml(BpmnModel bpmnModel) {
- return bpmnXMLConverter.convertToXML(bpmnModel);
- }
-
- /**
- * 获取开始节点
- *
- * @param model bpmnModel对象
- * @return 开始节点(未找到开始节点,返回null)
- */
- public static StartEvent getStartEvent(BpmnModel model) {
- Process process = model.getMainProcess();
- FlowElement startElement = process.getInitialFlowElement();
- if (startElement instanceof StartEvent) {
- return (StartEvent) startElement;
- }
- return getStartEvent(process.getFlowElements());
- }
-
- /**
- * 获取开始节点
- *
- * @param flowElements 流程元素集合
- * @return 开始节点(未找到开始节点,返回null)
- */
- public static StartEvent getStartEvent(Collection flowElements) {
- for (FlowElement flowElement : flowElements) {
- if (flowElement instanceof StartEvent) {
- return (StartEvent) flowElement;
- }
- }
- return null;
- }
-
- /**
- * 获取结束节点
- *
- * @param model bpmnModel对象
- * @return 结束节点(未找到开始节点,返回null)
- */
- public static EndEvent getEndEvent(BpmnModel model) {
- Process process = model.getMainProcess();
- return getEndEvent(process.getFlowElements());
- }
-
- /**
- * 获取结束节点
- *
- * @param flowElements 流程元素集合
- * @return 结束节点(未找到开始节点,返回null)
- */
- public static EndEvent getEndEvent(Collection flowElements) {
- for (FlowElement flowElement : flowElements) {
- if (flowElement instanceof EndEvent) {
- return (EndEvent) flowElement;
- }
- }
- return null;
- }
-
- public static UserTask getUserTaskByKey(BpmnModel model, String taskKey) {
- Process process = model.getMainProcess();
- FlowElement flowElement = process.getFlowElement(taskKey);
- if (flowElement instanceof UserTask) {
- return (UserTask) flowElement;
- }
- return null;
- }
-
- public static boolean isMultiInstance(BpmnModel model, String taskKey) {
- UserTask userTask = getUserTaskByKey(model, taskKey);
- if (userTask==null) {
- return userTask.hasMultiInstanceLoopCharacteristics();
- }
- return false;
- }
-
- /**
- * 获取所有用户任务节点
- *
- * @param model bpmnModel对象
- * @return 用户任务节点列表
- */
- public static Collection getAllUserTaskEvent(BpmnModel model) {
- Process process = model.getMainProcess();
- Collection flowElements = process.getFlowElements();
- return getAllUserTaskEvent(flowElements, null);
- }
-
- /**
- * 获取所有用户任务节点
- * @param flowElements 流程元素集合
- * @param allElements 所有流程元素集合
- * @return 用户任务节点列表
- */
- public static Collection getAllUserTaskEvent(Collection flowElements, Collection allElements) {
- allElements = allElements == null ? new ArrayList<>() : allElements;
- for (FlowElement flowElement : flowElements) {
- if (flowElement instanceof UserTask) {
- allElements.add((UserTask) flowElement);
- }
- if (flowElement instanceof SubProcess) {
- // 继续深入子流程,进一步获取子流程
- allElements = getAllUserTaskEvent(((SubProcess) flowElement).getFlowElements(), allElements);
- }
- }
- return allElements;
- }
-}
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/flow/ModelUtils.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/flow/ModelUtils.java
deleted file mode 100644
index 1a81e6ad..00000000
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/flow/ModelUtils.java
+++ /dev/null
@@ -1,372 +0,0 @@
-package com.yanzhu.flowable.flow;
-
-import com.yanzhu.common.core.utils.StringUtils;
-import org.flowable.bpmn.converter.BpmnXMLConverter;
-import org.flowable.bpmn.model.*;
-import org.flowable.bpmn.model.Process;
-import org.flowable.common.engine.impl.util.io.StringStreamSource;
-
-import java.util.*;
-
-/**
- * @author KonBAI
- * @createTime 2022/3/26 19:04
- */
-public class ModelUtils {
-
- private static final BpmnXMLConverter bpmnXMLConverter = new BpmnXMLConverter();
-
- /**
- * xml转bpmnModel对象
- *
- * @param xml xml
- * @return bpmnModel对象
- */
- public static BpmnModel getBpmnModel(String xml) {
- return bpmnXMLConverter.convertToBpmnModel(new StringStreamSource(xml), false, false);
- }
-
- /**
- * bpmnModel转xml字符串
- *
- * @deprecated 存在会丢失 bpmn 连线问题
- * @param bpmnModel bpmnModel对象
- * @return xml字符串
- */
- @Deprecated
- public static String getBpmnXmlStr(BpmnModel bpmnModel) {
- return StringUtils.utf8Str(getBpmnXml(bpmnModel));
- }
-
- /**
- * bpmnModel转xml对象
- *
- * @deprecated 存在丢失 bpmn 连线问题
- * @param bpmnModel bpmnModel对象
- * @return xml
- */
- @Deprecated
- public static byte[] getBpmnXml(BpmnModel bpmnModel) {
- return bpmnXMLConverter.convertToXML(bpmnModel);
- }
-
- /**
- * 根据节点,获取入口连线
- *
- * @param source 起始节点
- * @return 入口连线列表
- */
- public static List getElementIncomingFlows(FlowElement source) {
- List sequenceFlows = new ArrayList<>();
- if (source instanceof FlowNode) {
- sequenceFlows = ((FlowNode) source).getIncomingFlows();
- }
- return sequenceFlows;
- }
-
-
- /**
- * 根据节点,获取出口连线
- *
- * @param source 起始节点
- * @return 出口连线列表
- */
- public static List getElementOutgoingFlows(FlowElement source) {
- List sequenceFlows = new ArrayList<>();
- if (source instanceof FlowNode) {
- sequenceFlows = ((FlowNode) source).getOutgoingFlows();
- }
- return sequenceFlows;
- }
-
- /**
- * 获取开始节点
- *
- * @param model bpmnModel对象
- * @return 开始节点(未找到开始节点,返回null)
- */
- public static StartEvent getStartEvent(BpmnModel model) {
- Process process = model.getMainProcess();
- FlowElement startElement = process.getInitialFlowElement();
- if (startElement instanceof StartEvent) {
- return (StartEvent) startElement;
- }
- return getStartEvent(process.getFlowElements());
- }
-
- /**
- * 获取开始节点
- *
- * @param flowElements 流程元素集合
- * @return 开始节点(未找到开始节点,返回null)
- */
- public static StartEvent getStartEvent(Collection flowElements) {
- for (FlowElement flowElement : flowElements) {
- if (flowElement instanceof StartEvent) {
- return (StartEvent) flowElement;
- }
- }
- return null;
- }
-
- /**
- * 获取结束节点
- *
- * @param model bpmnModel对象
- * @return 结束节点(未找到开始节点,返回null)
- */
- public static EndEvent getEndEvent(BpmnModel model) {
- Process process = model.getMainProcess();
- return getEndEvent(process.getFlowElements());
- }
-
- /**
- * 获取结束节点
- *
- * @param flowElements 流程元素集合
- * @return 结束节点(未找到开始节点,返回null)
- */
- public static EndEvent getEndEvent(Collection flowElements) {
- for (FlowElement flowElement : flowElements) {
- if (flowElement instanceof EndEvent) {
- return (EndEvent) flowElement;
- }
- }
- return null;
- }
-
- public static UserTask getUserTaskByKey(BpmnModel model, String taskKey) {
- Process process = model.getMainProcess();
- FlowElement flowElement = process.getFlowElement(taskKey);
- if (flowElement instanceof UserTask) {
- return (UserTask) flowElement;
- }
- return null;
- }
-
- /**
- * 获取流程元素信息
- *
- * @param model bpmnModel对象
- * @param flowElementId 元素ID
- * @return 元素信息
- */
- public static FlowElement getFlowElementById(BpmnModel model, String flowElementId) {
- Process process = model.getMainProcess();
- return process.getFlowElement(flowElementId);
- }
-
- /**
- * 获取元素表单Key(限开始节点和用户节点可用)
- *
- * @param flowElement 元素
- * @return 表单Key
- */
- public static String getFormKey(FlowElement flowElement) {
- if (flowElement != null) {
- if (flowElement instanceof StartEvent) {
- return ((StartEvent) flowElement).getFormKey();
- } else if (flowElement instanceof UserTask) {
- return ((UserTask) flowElement).getFormKey();
- }
- }
- return null;
- }
-
- /**
- * 获取开始节点属性值
- * @param model bpmnModel对象
- * @param name 属性名
- * @return 属性值
- */
- public static String getStartEventAttributeValue(BpmnModel model, String name) {
- StartEvent startEvent = getStartEvent(model);
- return getElementAttributeValue(startEvent, name);
- }
-
- /**
- * 获取结束节点属性值
- * @param model bpmnModel对象
- * @param name 属性名
- * @return 属性值
- */
- public static String getEndEventAttributeValue(BpmnModel model, String name) {
- EndEvent endEvent = getEndEvent(model);
- return getElementAttributeValue(endEvent, name);
- }
-
- /**
- * 获取用户任务节点属性值
- * @param model bpmnModel对象
- * @param taskKey 任务Key
- * @param name 属性名
- * @return 属性值
- */
- public static String getUserTaskAttributeValue(BpmnModel model, String taskKey, String name) {
- UserTask userTask = getUserTaskByKey(model, taskKey);
- return getElementAttributeValue(userTask, name);
- }
-
- /**
- * 获取元素属性值
- * @param baseElement 流程元素
- * @param name 属性名
- * @return 属性值
- */
- public static String getElementAttributeValue(BaseElement baseElement, String name) {
- if (baseElement != null) {
- List attributes = baseElement.getAttributes().get(name);
- if (attributes != null && !attributes.isEmpty()) {
- attributes.iterator().next().getValue();
- Iterator attrIterator = attributes.iterator();
- if(attrIterator.hasNext()) {
- ExtensionAttribute attribute = attrIterator.next();
- return attribute.getValue();
- }
- }
- }
- return null;
- }
-
- public static boolean isMultiInstance(BpmnModel model, String taskKey) {
- UserTask userTask = getUserTaskByKey(model, taskKey);
- if (!Objects.isNull(userTask)) {
- return userTask.hasMultiInstanceLoopCharacteristics();
- }
- return false;
- }
-
- /**
- * 获取所有用户任务节点
- *
- * @param model bpmnModel对象
- * @return 用户任务节点列表
- */
- public static Collection getAllUserTaskEvent(BpmnModel model) {
- Process process = model.getMainProcess();
- Collection flowElements = process.getFlowElements();
- return getAllUserTaskEvent(flowElements, null);
- }
-
- /**
- * 获取所有用户任务节点
- * @param flowElements 流程元素集合
- * @param allElements 所有流程元素集合
- * @return 用户任务节点列表
- */
- public static Collection getAllUserTaskEvent(Collection flowElements, Collection allElements) {
- allElements = allElements == null ? new ArrayList<>() : allElements;
- for (FlowElement flowElement : flowElements) {
- if (flowElement instanceof UserTask) {
- allElements.add((UserTask) flowElement);
- }
- if (flowElement instanceof SubProcess) {
- // 继续深入子流程,进一步获取子流程
- allElements = getAllUserTaskEvent(((SubProcess) flowElement).getFlowElements(), allElements);
- }
- }
- return allElements;
- }
-
- /**
- * 查找起始节点下一个用户任务列表列表
- * @param source 起始节点
- * @return 结果
- */
- public static List findNextUserTasks(FlowElement source) {
- return findNextUserTasks(source, null, null);
- }
-
- /**
- * 查找起始节点下一个用户任务列表列表
- * @param source 起始节点
- * @param hasSequenceFlow 已经经过的连线的 ID,用于判断线路是否重复
- * @param userTaskList 用户任务列表
- * @return 结果
- */
- public static List findNextUserTasks(FlowElement source, Set hasSequenceFlow, List userTaskList) {
- hasSequenceFlow = Optional.ofNullable(hasSequenceFlow).orElse(new HashSet<>());
- userTaskList = Optional.ofNullable(userTaskList).orElse(new ArrayList<>());
- // 获取出口连线
- List sequenceFlows = getElementOutgoingFlows(source);
- if (!sequenceFlows.isEmpty()) {
- for (SequenceFlow sequenceFlow : sequenceFlows) {
- // 如果发现连线重复,说明循环了,跳过这个循环
- if (hasSequenceFlow.contains(sequenceFlow.getId())) {
- continue;
- }
- // 添加已经走过的连线
- hasSequenceFlow.add(sequenceFlow.getId());
- FlowElement targetFlowElement = sequenceFlow.getTargetFlowElement();
- if (targetFlowElement instanceof UserTask) {
- // 若节点为用户任务,加入到结果列表中
- userTaskList.add((UserTask) targetFlowElement);
- } else {
- // 若节点非用户任务,继续递归查找下一个节点
- findNextUserTasks(targetFlowElement, hasSequenceFlow, userTaskList);
- }
- }
- }
- return userTaskList;
- }
-
- /**
- * 迭代从后向前扫描,判断目标节点相对于当前节点是否是串行
- * 不存在直接回退到子流程中的情况,但存在从子流程出去到父流程情况
- * @param source 起始节点
- * @param target 目标节点
- * @param visitedElements 已经经过的连线的 ID,用于判断线路是否重复
- * @return 结果
- */
- public static boolean isSequentialReachable(FlowElement source, FlowElement target, Set visitedElements) {
- visitedElements = visitedElements == null ? new HashSet<>() : visitedElements;
- if (source instanceof StartEvent && isInEventSubprocess(source)) {
- return false;
- }
-
- // 根据类型,获取入口连线
- List sequenceFlows = getElementIncomingFlows(source);
- if (sequenceFlows != null && sequenceFlows.size() > 0) {
- // 循环找到目标元素
- for (SequenceFlow sequenceFlow: sequenceFlows) {
- // 如果发现连线重复,说明循环了,跳过这个循环
- if (visitedElements.contains(sequenceFlow.getId())) {
- continue;
- }
- // 添加已经走过的连线
- visitedElements.add(sequenceFlow.getId());
- FlowElement sourceFlowElement = sequenceFlow.getSourceFlowElement();
- // 这条线路存在目标节点,这条线路完成,进入下个线路
- if (target.getId().equals(sourceFlowElement.getId())) {
- continue;
- }
- // 如果目标节点为并行网关,则不继续
- if (sourceFlowElement instanceof ParallelGateway) {
- return false;
- }
- // 否则就继续迭代
- boolean isSequential = isSequentialReachable(sourceFlowElement, target, visitedElements);
- if (!isSequential) {
- return false;
- }
- }
- }
- return true;
- }
-
- protected static boolean isInEventSubprocess(FlowElement flowElement) {
- FlowElementsContainer flowElementsContainer = flowElement.getParentContainer();
- while (flowElementsContainer != null) {
- if (flowElementsContainer instanceof EventSubProcess) {
- return true;
- }
-
- if (flowElementsContainer instanceof FlowElement) {
- flowElementsContainer = ((FlowElement) flowElementsContainer).getParentContainer();
- } else {
- flowElementsContainer = null;
- }
- }
- return false;
- }
-}
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/rpc/IRemoteSystemService.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/rpc/IRemoteSystemService.java
new file mode 100644
index 00000000..5b72cb52
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/rpc/IRemoteSystemService.java
@@ -0,0 +1,35 @@
+package com.yanzhu.flowable.rpc;
+
+import com.yanzhu.common.core.constant.SecurityConstants;
+import com.yanzhu.common.core.constant.ServiceNameConstants;
+import com.yanzhu.common.core.domain.R;
+import com.yanzhu.system.api.domain.SysRole;
+import com.yanzhu.system.api.domain.SysUser;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * system rpc接口调用
+ */
+@FeignClient(value = ServiceNameConstants.SYSTEM_SERVICE)
+public interface IRemoteSystemService {
+
+ @GetMapping("/rpc/user/list")
+ R> getUsers(@RequestParam Map paraMap, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
+
+ @GetMapping("/rpc/user/{userId}")
+ R getUserById(@PathVariable(value = "userId") Long userId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
+
+ @GetMapping("/rpc/role/list")
+ R> getRoles(@RequestParam Map paraMap, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
+
+ @GetMapping("/rpc/role/{roleId}")
+ R getRoleById(@PathVariable(value = "roleId") Long userId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
+
+}
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/rpc/RemoteSystemService.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/rpc/RemoteSystemService.java
new file mode 100644
index 00000000..8cb190cc
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/rpc/RemoteSystemService.java
@@ -0,0 +1,72 @@
+package com.yanzhu.flowable.rpc;
+
+import com.yanzhu.common.core.constant.SecurityConstants;
+import com.yanzhu.common.core.domain.R;
+import com.yanzhu.common.core.exception.ServiceException;
+import com.yanzhu.common.core.utils.bean.BeanUtils;
+import com.yanzhu.common.core.web.domain.BaseEntity;
+import com.yanzhu.system.api.domain.SysRole;
+import com.yanzhu.system.api.domain.SysUser;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class RemoteSystemService {
+
+ @Autowired
+ private IRemoteSystemService remoteSystemService;
+
+ private List resultToList(R> dataResult) {
+ if (R.FAIL == dataResult.getCode()) {
+ throw new ServiceException(dataResult.getMsg());
+ }
+ return dataResult.getData();
+ }
+
+ private T resultToBean(R dataResult) {
+ if (R.FAIL == dataResult.getCode()) {
+ throw new ServiceException(dataResult.getMsg());
+ }
+ return dataResult.getData();
+ }
+
+ public List getUsers(SysUser sysUser) {
+ //远程调用system接口获取所有电站信息
+ R> dataResult = remoteSystemService.getUsers(beanToMap(sysUser), SecurityConstants.INNER);
+ return resultToList(dataResult);
+ }
+
+ public List getRoles(SysRole sysRole) {
+ //远程调用system接口获取所有电站信息
+ R> dataResult = remoteSystemService.getRoles(beanToMap(sysRole), SecurityConstants.INNER);
+ return resultToList(dataResult);
+ }
+
+ private Map beanToMap(Object obj) {
+ try {
+ Map paraMap = BeanUtils.beanToMap(obj);
+ if (obj instanceof BaseEntity) {
+ paraMap.remove("params");
+ }
+ return paraMap;
+ }catch (Exception e){
+ throw new ServiceException(e.getMessage());
+ }
+ }
+
+ public SysUser getUserById(Long userId) {
+ //远程调用system接口获取所有电站信息
+ R dataResult = remoteSystemService.getUserById(userId, SecurityConstants.INNER);
+ return resultToBean(dataResult);
+ }
+
+ public SysRole getRoleById(Long roleId) {
+ //远程调用system接口获取所有电站信息
+ R dataResult = remoteSystemService.getRoleById(roleId, SecurityConstants.INNER);
+ return resultToBean(dataResult);
+ }
+
+}
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowDefinitionService.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowDefinitionService.java
new file mode 100644
index 00000000..d93585c6
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowDefinitionService.java
@@ -0,0 +1,78 @@
+package com.yanzhu.flowable.service;
+
+import com.yanzhu.common.core.web.domain.AjaxResult;
+import com.yanzhu.flowable.domain.dto.FlowProcDefDto;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Tony
+ * @date 2021-04-03 14:41
+ */
+public interface IFlowDefinitionService {
+
+ boolean exist(String processDefinitionKey);
+
+
+ /**
+ * 流程定义列表
+ *
+ * @return 流程定义分页列表数据
+ */
+ List list(String name);
+
+ /**
+ * 导入流程文件
+ * 当每个key的流程第一次部署时,指定版本为1。对其后所有使用相同key的流程定义,
+ * 部署时版本会在该key当前已部署的最高版本号基础上加1。key参数用于区分流程定义
+ * @param name
+ * @param category
+ * @param in
+ */
+ void importFile(String name, String category, InputStream in);
+
+ /**
+ * 读取xml
+ * @param deployId
+ * @return
+ */
+ AjaxResult readXml(String deployId) throws IOException;
+
+ /**
+ * 根据流程定义ID启动流程实例
+ *
+ * @param procDefId
+ * @param variables
+ * @return
+ */
+
+ AjaxResult startProcessInstanceById(String procDefId, Map variables);
+
+
+ /**
+ * 激活或挂起流程定义
+ *
+ * @param state 状态
+ * @param deployId 流程部署ID
+ */
+ void updateState(Integer state, String deployId);
+
+
+ /**
+ * 删除流程定义
+ *
+ * @param deployId 流程部署ID act_ge_bytearray 表中 deployment_id值
+ */
+ void delete(String deployId);
+
+
+ /**
+ * 读取图片文件
+ * @param deployId
+ * @return
+ */
+ InputStream readImage(String deployId);
+}
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowInstanceService.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowInstanceService.java
new file mode 100644
index 00000000..acc69698
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowInstanceService.java
@@ -0,0 +1,54 @@
+package com.yanzhu.flowable.service;
+
+import com.yanzhu.common.core.web.domain.AjaxResult;
+import com.yanzhu.flowable.domain.vo.FlowTaskVo;
+import org.flowable.engine.history.HistoricProcessInstance;
+
+import java.util.Map;
+
+/**
+ * @author Tony
+ * @date 2021-04-03 14:40
+ */
+public interface IFlowInstanceService {
+
+ /**
+ * 结束流程实例
+ *
+ * @param vo
+ */
+ void stopProcessInstance(FlowTaskVo vo);
+
+ /**
+ * 激活或挂起流程实例
+ *
+ * @param state 状态
+ * @param instanceId 流程实例ID
+ */
+ void updateState(Integer state, String instanceId);
+
+ /**
+ * 删除流程实例ID
+ *
+ * @param instanceId 流程实例ID
+ * @param deleteReason 删除原因
+ */
+ void delete(String instanceId, String deleteReason);
+
+ /**
+ * 根据实例ID查询历史实例数据
+ *
+ * @param processInstanceId
+ * @return
+ */
+ HistoricProcessInstance getHistoricProcessInstanceById(String processInstanceId);
+
+ /**
+ * 根据流程定义ID启动流程实例
+ *
+ * @param procDefId 流程定义Id
+ * @param variables 流程变量
+ * @return
+ */
+ AjaxResult startProcessInstanceById(String procDefId, Map variables);
+}
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowTaskService.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowTaskService.java
new file mode 100644
index 00000000..05022155
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowTaskService.java
@@ -0,0 +1,217 @@
+package com.yanzhu.flowable.service;
+
+import com.github.pagehelper.PageInfo;
+import com.yanzhu.common.core.web.domain.AjaxResult;
+import com.yanzhu.flowable.domain.dto.FlowTaskDto;
+import com.yanzhu.flowable.domain.vo.FlowQueryVo;
+import com.yanzhu.flowable.domain.vo.FlowTaskVo;
+
+import java.io.InputStream;
+
+/**
+ * @author Tony
+ * @date 2021-04-03 14:42
+ */
+public interface IFlowTaskService {
+
+ /**
+ * 审批任务
+ *
+ * @param task 请求实体参数
+ */
+ AjaxResult complete(FlowTaskVo task);
+
+ /**
+ * 驳回任务
+ *
+ * @param flowTaskVo
+ */
+ void taskReject(FlowTaskVo flowTaskVo);
+
+
+ /**
+ * 退回任务
+ *
+ * @param flowTaskVo 请求实体参数
+ */
+ void taskReturn(FlowTaskVo flowTaskVo);
+
+ /**
+ * 获取所有可回退的节点
+ *
+ * @param flowTaskVo
+ * @return
+ */
+ AjaxResult findReturnTaskList(FlowTaskVo flowTaskVo);
+
+ /**
+ * 删除任务
+ *
+ * @param flowTaskVo 请求实体参数
+ */
+ void deleteTask(FlowTaskVo flowTaskVo);
+
+ /**
+ * 认领/签收任务
+ *
+ * @param flowTaskVo 请求实体参数
+ */
+ void claim(FlowTaskVo flowTaskVo);
+
+ /**
+ * 取消认领/签收任务
+ *
+ * @param flowTaskVo 请求实体参数
+ */
+ void unClaim(FlowTaskVo flowTaskVo);
+
+ /**
+ * 委派任务
+ *
+ * @param flowTaskVo 请求实体参数
+ */
+ void delegateTask(FlowTaskVo flowTaskVo);
+
+ /**
+ * 任务归还
+ *
+ * @param flowTaskVo 请求实体参数
+ */
+ void resolveTask(FlowTaskVo flowTaskVo);
+
+
+ /**
+ * 转办任务
+ *
+ * @param flowTaskVo 请求实体参数
+ */
+ void assignTask(FlowTaskVo flowTaskVo);
+
+
+ /**
+ * 多实例加签
+ * @param flowTaskVo
+ */
+ void addMultiInstanceExecution(FlowTaskVo flowTaskVo);
+
+ /**
+ * 多实例减签
+ * @param flowTaskVo
+ */
+ void deleteMultiInstanceExecution(FlowTaskVo flowTaskVo);
+
+ /**
+ * 我发起的流程
+ * @param queryVo 请求参数
+ * @return
+ */
+ PageInfo myProcess(FlowQueryVo queryVo);
+
+ /**
+ * 取消申请
+ * 目前实现方式: 直接将当前流程变更为已完成
+ * @param flowTaskVo
+ * @return
+ */
+ AjaxResult stopProcess(FlowTaskVo flowTaskVo);
+
+ /**
+ * 撤回流程
+ * @param flowTaskVo
+ * @return
+ */
+ AjaxResult revokeProcess(FlowTaskVo flowTaskVo);
+
+
+ /**
+ * 代办任务列表
+ *
+ * @param queryVo 请求参数
+ * @return
+ */
+ PageInfo todoList(FlowQueryVo queryVo);
+
+
+ /**
+ * 已办任务列表
+ *
+ * @param queryVo 请求参数
+ * @return
+ */
+ PageInfo finishedList(FlowQueryVo queryVo);
+
+ /**
+ * 流程历史流转记录
+ *
+ * @param procInsId 流程实例Id
+ * @return
+ */
+ AjaxResult flowRecord(String procInsId,String deployId);
+
+ /**
+ * 根据任务ID查询挂载的表单信息
+ *
+ * @param taskId 任务Id
+ * @return
+ */
+ AjaxResult getTaskForm(String taskId);
+
+ /**
+ * 获取流程过程图
+ * @param processId
+ * @return
+ */
+ InputStream diagram(String processId);
+
+ /**
+ * 获取流程执行节点
+ * @param procInsId
+ * @return
+ */
+ AjaxResult getFlowViewer(String procInsId,String executionId);
+
+ /**
+ * 获取流程变量
+ * @param taskId
+ * @return
+ */
+ AjaxResult processVariables(String taskId);
+
+ /**
+ * 获取下一节点
+ * @param flowTaskVo 任务
+ * @return
+ */
+ AjaxResult getNextFlowNode(FlowTaskVo flowTaskVo);
+
+ AjaxResult getNextFlowNodeByStart(FlowTaskVo flowTaskVo);
+
+ /**
+ * 流程初始化表单
+ * @param deployId
+ * @return
+ */
+ AjaxResult flowFormData(String deployId);
+
+ /**
+ * 流程节点信息
+ * @param procInsId
+ * @return
+ */
+ AjaxResult flowXmlAndNode(String procInsId,String deployId);
+
+ /**
+ * 流程节点表单
+ * @param taskId 流程任务编号
+ * @return
+ */
+ AjaxResult flowTaskForm(String taskId) throws Exception;
+
+ /**
+ * 流程节点信息
+ * @param procInsId
+ * @param elementId
+ * @return
+ */
+ AjaxResult flowTaskInfo(String procInsId, String elementId);
+}
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowableCategoryService.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowableCategoryService.java
deleted file mode 100644
index 6cd98a46..00000000
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowableCategoryService.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package com.yanzhu.flowable.service;
-
-import com.yanzhu.flowable.domain.FlowableCategory;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * 流程分类Service接口
- *
- * @author ruoyi
- * @date 2023-11-27
- */
-public interface IFlowableCategoryService
-{
- /**
- * 查询流程分类
- *
- * @param id 流程分类主键
- * @return 流程分类
- */
- public FlowableCategory selectFlowableCategoryById(Long id);
-
- /**
- * 查询流程分类列表
- *
- * @param flowableCategory 流程分类
- * @return 流程分类集合
- */
- public List selectFlowableCategoryList(FlowableCategory flowableCategory);
-
- /**
- * 新增流程分类
- *
- * @param flowableCategory 流程分类
- * @return 结果
- */
- public int insertFlowableCategory(FlowableCategory flowableCategory);
-
- /**
- * 修改流程分类
- *
- * @param flowableCategory 流程分类
- * @return 结果
- */
- public int updateFlowableCategory(FlowableCategory flowableCategory);
-
- /**
- * 批量删除流程分类
- *
- * @param ids 需要删除的流程分类主键集合
- * @return 结果
- */
- public int deleteFlowableCategoryByIds(Long[] ids);
-
- /**
- * 删除流程分类信息
- *
- * @param id 流程分类主键
- * @return 结果
- */
- public int deleteFlowableCategoryById(Long id);
-
- /**
- * 更新缓存
- * @param flowableCategories
- */
- public Map updateRedis(List flowableCategories);
-}
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowableDeployService.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowableDeployService.java
deleted file mode 100644
index 735452d1..00000000
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowableDeployService.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package com.yanzhu.flowable.service;
-
-import com.yanzhu.flowable.domain.FlowableDeploy;
-
-import java.util.List;
-
-/**
- * 流程部署Service接口
- *
- * @author ruoyi
- * @date 2023-12-18
- */
-public interface IFlowableDeployService
-{
- /**
- * 查询流程部署
- *
- * @param definitionId 流程部署主键
- * @return 流程部署
- */
- public FlowableDeploy selectFlowableDeployByDefinitionId(String definitionId);
-
- /**
- * 查询流程部署列表
- *
- * @param flowableDeploy 流程部署
- * @return 流程部署集合
- */
- public List selectFlowableDeployList(FlowableDeploy flowableDeploy);
-
-
- /**
- * 批量删除流程部署
- *
- * @param definitionIds 需要删除的流程部署主键集合
- * @return 结果
- */
- public int deleteFlowableDeployByDefinitionIds(String[] definitionIds);
-
- /**
- * 删除流程部署信息
- *
- * @param definitionId 流程部署主键
- * @return 结果
- */
- public int deleteFlowableDeployByDefinitionId(String definitionId);
-
- /**
- * 查询所有部署的历史版本
- * @param processKey 流程key
- * @return
- */
- public List queryPublishList(String processKey);
-
- /**
- * 改变部署状态
- * @param definitionId
- * @param stateCode
- */
- public void updateState(String definitionId, String stateCode);
-
- /**
- * 查询流程图
- * @param definitionId
- * @return
- */
- public String queryBpmnXmlById(String definitionId);
-}
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowableFieldDefService.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowableFieldDefService.java
deleted file mode 100644
index 91044591..00000000
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowableFieldDefService.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package com.yanzhu.flowable.service;
-
-import com.yanzhu.flowable.domain.FlowableFieldDef;
-import com.yanzhu.flowable.domain.FlowableFieldSearch;
-
-import java.util.List;
-
-/**
- * 流程字段定义Service接口
- *
- * @author ruoyi
- * @date 2023-12-26
- */
-public interface IFlowableFieldDefService
-{
- /**
- * 查询流程字段定义
- *
- * @param id 流程字段定义主键
- * @return 流程字段定义
- */
- public FlowableFieldDef selectFlowableFieldDefById(String id);
-
- /**
- * 查询流程字段定义列表
- *
- * @param flowableFieldDef 流程字段定义
- * @return 流程字段定义集合
- */
- public List selectFlowableFieldDefList(FlowableFieldDef flowableFieldDef);
-
- /**
- * 新增流程字段定义
- *
- * @param flowableFieldDef 流程字段定义
- * @return 结果
- */
- public int insertFlowableFieldDef(FlowableFieldDef flowableFieldDef);
-
- /**
- * 修改流程字段定义
- *
- * @param flowableFieldDef 流程字段定义
- * @return 结果
- */
- public int updateFlowableFieldDef(FlowableFieldDef flowableFieldDef);
-
- /**
- * 批量删除流程字段定义
- *
- * @param ids 需要删除的流程字段定义主键集合
- * @return 结果
- */
- public int deleteFlowableFieldDefByIds(String[] ids);
-
- /**
- * 删除流程字段定义信息
- *
- * @param id 流程字段定义主键
- * @return 结果
- */
- public int deleteFlowableFieldDefById(String id);
-
- /**
- * 查询流程字段引用关系列表(不翻页,关联字段定义表查询)
- * @param flowableFieldSearch
- * @return
- */
- List listCombination(FlowableFieldSearch flowableFieldSearch);
-}
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowableFieldRefService.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowableFieldRefService.java
deleted file mode 100644
index 1edcb29b..00000000
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowableFieldRefService.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package com.yanzhu.flowable.service;
-
-import com.yanzhu.flowable.domain.FlowableFieldRef;
-
-import java.util.List;
-
-/**
- * 流程字段引用关系Service接口
- *
- * @author ruoyi
- * @date 2023-12-26
- */
-public interface IFlowableFieldRefService
-{
- /**
- * 查询流程字段引用关系
- *
- * @param id 流程字段引用关系主键
- * @return 流程字段引用关系
- */
- public FlowableFieldRef selectFlowableFieldRefById(String id);
-
- /**
- * 查询流程字段引用关系列表
- *
- * @param flowableFieldRef 流程字段引用关系
- * @return 流程字段引用关系集合
- */
- public List selectFlowableFieldRefList(FlowableFieldRef flowableFieldRef);
-
- /**
- * 新增流程字段引用关系
- *
- * @param flowableFieldRef 流程字段引用关系
- * @return 结果
- */
- public int insertFlowableFieldRef(FlowableFieldRef flowableFieldRef);
-
- /**
- * 修改流程字段引用关系
- *
- * @param flowableFieldRef 流程字段引用关系
- * @return 结果
- */
- public int updateFlowableFieldRef(FlowableFieldRef flowableFieldRef);
-
- /**
- * 批量删除流程字段引用关系
- *
- * @param ids 需要删除的流程字段引用关系主键集合
- * @return 结果
- */
- public int deleteFlowableFieldRefByIds(String[] ids);
-
- /**
- * 删除流程字段引用关系信息
- *
- * @param id 流程字段引用关系主键
- * @return 结果
- */
- public int deleteFlowableFieldRefById(String id);
-}
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowableModelPageService.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowableModelPageService.java
deleted file mode 100644
index 5dfa47e1..00000000
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowableModelPageService.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package com.yanzhu.flowable.service;
-
-import com.yanzhu.flowable.domain.FlowableModelPage;
-
-import java.util.List;
-
-/**
- * 建模页面绑定Service接口
- *
- * @author ruoyi
- * @date 2023-12-25
- */
-public interface IFlowableModelPageService
-{
- /**
- * 查询建模页面绑定
- *
- * @param id 建模页面绑定主键
- * @return 建模页面绑定
- */
- public FlowableModelPage selectFlowableModelPageById(String id);
-
- /**
- * 查询建模页面绑定列表
- *
- * @param flowableModelPage 建模页面绑定
- * @return 建模页面绑定集合
- */
- public List selectFlowableModelPageList(FlowableModelPage flowableModelPage);
-
- /**
- * 新增建模页面绑定
- *
- * @param flowableModelPage 建模页面绑定
- * @return 结果
- */
- public int insertFlowableModelPage(FlowableModelPage flowableModelPage);
-
- /**
- * 修改建模页面绑定
- *
- * @param flowableModelPage 建模页面绑定
- * @return 结果
- */
- public int updateFlowableModelPage(FlowableModelPage flowableModelPage);
-
- /**
- * 批量删除建模页面绑定
- *
- * @param ids 需要删除的建模页面绑定主键集合
- * @return 结果
- */
- public int deleteFlowableModelPageByIds(String[] ids);
-
- /**
- * 删除建模页面绑定信息
- *
- * @param id 建模页面绑定主键
- * @return 结果
- */
- public int deleteFlowableModelPageById(String id);
-
- /**
- * 查询需要绑定的建模页面
- * @param flowableModelPage
- * @return
- */
- List selectFlowableModelPageListByBind(FlowableModelPage flowableModelPage);
-
- /***
- * 建模页面单页面查询(根据模块,流程标识,页面名称查询)
- * @param flowableModelPage
- * @return
- */
- FlowableModelPage selectFlowableModelPageSingle(FlowableModelPage flowableModelPage);
-
- /**
- * 建模页面模块页面查询(按模块,流程标识查询)
- * @param flowableModelPage
- * @return
- */
- List selectFlowableModelPage(FlowableModelPage flowableModelPage);
-}
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowableModelService.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowableModelService.java
deleted file mode 100644
index 99deea99..00000000
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowableModelService.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package com.yanzhu.flowable.service;
-
-import com.yanzhu.flowable.domain.FlowableModel;
-import com.yanzhu.flowable.domain.bo.FlowableModelBo;
-
-import java.io.UnsupportedEncodingException;
-import java.util.List;
-
-/**
- * 流程模型Service接口
- *
- * @author ruoyi
- * @date 2023-11-28
- */
-public interface IFlowableModelService
-{
- /**
- * 查询流程模型
- *
- * @param modelId 流程模型主键
- * @return 流程模型
- */
- public FlowableModel selectFlowableModelByModelId(String modelId);
-
- /**
- * 查询流程模型列表
- *
- * @param flowableModel 流程模型
- * @return 流程模型集合
- */
- public List selectFlowableModelList(FlowableModelBo flowableModel);
-
- /**
- * 新增流程模型
- *
- * @param flowableModel 流程模型
- * @return
- */
- public int insertFlowableModel(FlowableModel flowableModel);
-
- /**
- * 修改流程模型
- *
- * @param flowableModel 流程模型
- * @return
- */
- public int updateFlowableModel(FlowableModel flowableModel);
-
- /**
- * 批量删除流程模型
- *
- * @param modelIds 需要删除的流程模型主键集合
- * @return
- */
- public int deleteFlowableModelByModelIds(String[] modelIds);
-
- /**
- * 删除流程模型信息
- *
- * @param modelId 流程模型主键
- */
- public void deleteFlowableModelByModelId(String modelId);
-
- /**
- * 部署流程
- * @param modelId 模型id
- */
- public void deployModel(String modelId) throws UnsupportedEncodingException;
-
- /**
- * 获取模型xml
- * @param modelId
- * @return
- * @throws UnsupportedEncodingException
- */
- public String queryBpmnXmlById(String modelId) throws UnsupportedEncodingException;
-
- /**
- * 查询模型历史版本
- * @param modelBo
- * @return
- */
- List historyList(FlowableModelBo modelBo);
-
- /**
- * 新增或更新模型xml
- * @param modelBo
- */
- void saveModel(FlowableModelBo modelBo);
-
- /**
- * 设置为最新版本
- * @param modelId
- */
- void latestModel(String modelId) throws UnsupportedEncodingException;
-}
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/ISysDeployFormService.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/ISysDeployFormService.java
new file mode 100644
index 00000000..01ff72bc
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/ISysDeployFormService.java
@@ -0,0 +1,70 @@
+package com.yanzhu.flowable.service;
+
+import com.yanzhu.flowable.domain.SysDeployForm;
+import com.yanzhu.flowable.domain.SysForm;
+
+import java.util.List;
+
+/**
+ * 流程实例关联表单Service接口
+ *
+ * @author Tony
+ * @date 2021-04-03
+ */
+public interface ISysDeployFormService
+{
+ /**
+ * 查询流程实例关联表单
+ *
+ * @param id 流程实例关联表单ID
+ * @return 流程实例关联表单
+ */
+ public SysDeployForm selectSysDeployFormById(Long id);
+
+ /**
+ * 查询流程实例关联表单列表
+ *
+ * @param sysDeployForm 流程实例关联表单
+ * @return 流程实例关联表单集合
+ */
+ public List selectSysDeployFormList(SysDeployForm sysDeployForm);
+
+ /**
+ * 新增流程实例关联表单
+ *
+ * @param sysDeployForm 流程实例关联表单
+ * @return 结果
+ */
+ public int insertSysDeployForm(SysDeployForm sysDeployForm);
+
+ /**
+ * 修改流程实例关联表单
+ *
+ * @param sysDeployForm 流程实例关联表单
+ * @return 结果
+ */
+ public int updateSysDeployForm(SysDeployForm sysDeployForm);
+
+ /**
+ * 批量删除流程实例关联表单
+ *
+ * @param ids 需要删除的流程实例关联表单ID
+ * @return 结果
+ */
+ public int deleteSysDeployFormByIds(Long[] ids);
+
+ /**
+ * 删除流程实例关联表单信息
+ *
+ * @param id 流程实例关联表单ID
+ * @return 结果
+ */
+ public int deleteSysDeployFormById(Long id);
+
+ /**
+ * 查询流程挂着的表单
+ * @param deployId
+ * @return
+ */
+ SysForm selectSysDeployFormByDeployId(String deployId);
+}
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/ISysExpressionService.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/ISysExpressionService.java
new file mode 100644
index 00000000..be744bbb
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/ISysExpressionService.java
@@ -0,0 +1,62 @@
+package com.yanzhu.flowable.service;
+
+import com.yanzhu.flowable.domain.SysExpression;
+
+import java.util.List;
+
+/**
+ * 流程达式Service接口
+ *
+ * @author ruoyi
+ * @date 2022-12-12
+ */
+public interface ISysExpressionService
+{
+ /**
+ * 查询流程达式
+ *
+ * @param id 流程达式主键
+ * @return 流程达式
+ */
+ public SysExpression selectSysExpressionById(Long id);
+
+ /**
+ * 查询流程达式列表
+ *
+ * @param sysExpression 流程达式
+ * @return 流程达式集合
+ */
+ public List selectSysExpressionList(SysExpression sysExpression);
+
+ /**
+ * 新增流程达式
+ *
+ * @param sysExpression 流程达式
+ * @return 结果
+ */
+ public int insertSysExpression(SysExpression sysExpression);
+
+ /**
+ * 修改流程达式
+ *
+ * @param sysExpression 流程达式
+ * @return 结果
+ */
+ public int updateSysExpression(SysExpression sysExpression);
+
+ /**
+ * 批量删除流程达式
+ *
+ * @param ids 需要删除的流程达式主键集合
+ * @return 结果
+ */
+ public int deleteSysExpressionByIds(Long[] ids);
+
+ /**
+ * 删除流程达式信息
+ *
+ * @param id 流程达式主键
+ * @return 结果
+ */
+ public int deleteSysExpressionById(Long id);
+}
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/ISysFormService.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/ISysFormService.java
new file mode 100644
index 00000000..98a844ad
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/ISysFormService.java
@@ -0,0 +1,61 @@
+package com.yanzhu.flowable.service;
+
+import com.yanzhu.flowable.domain.SysForm;
+
+import java.util.List;
+
+/**
+ * 表单
+ * @author Tony
+ * @date 2021-04-03
+ */
+public interface ISysFormService
+{
+ /**
+ * 查询流程表单
+ *
+ * @param formId 流程表单ID
+ * @return 流程表单
+ */
+ public SysForm selectSysFormById(Long formId);
+
+ /**
+ * 查询流程表单列表
+ *
+ * @param sysForm 流程表单
+ * @return 流程表单集合
+ */
+ public List selectSysFormList(SysForm sysForm);
+
+ /**
+ * 新增流程表单
+ *
+ * @param sysForm 流程表单
+ * @return 结果
+ */
+ public int insertSysForm(SysForm sysForm);
+
+ /**
+ * 修改流程表单
+ *
+ * @param sysForm 流程表单
+ * @return 结果
+ */
+ public int updateSysForm(SysForm sysForm);
+
+ /**
+ * 批量删除流程表单
+ *
+ * @param formIds 需要删除的流程表单ID
+ * @return 结果
+ */
+ public int deleteSysFormByIds(Long[] formIds);
+
+ /**
+ * 删除流程表单信息
+ *
+ * @param formId 流程表单ID
+ * @return 结果
+ */
+ public int deleteSysFormById(Long formId);
+}
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/ISysListenerService.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/ISysListenerService.java
new file mode 100644
index 00000000..4b11a78f
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/ISysListenerService.java
@@ -0,0 +1,62 @@
+package com.yanzhu.flowable.service;
+
+import com.yanzhu.flowable.domain.SysListener;
+
+import java.util.List;
+
+/**
+ * 流程监听Service接口
+ *
+ * @author Tony
+ * @date 2022-12-25
+ */
+public interface ISysListenerService
+{
+ /**
+ * 查询流程监听
+ *
+ * @param id 流程监听主键
+ * @return 流程监听
+ */
+ public SysListener selectSysListenerById(Long id);
+
+ /**
+ * 查询流程监听列表
+ *
+ * @param sysListener 流程监听
+ * @return 流程监听集合
+ */
+ public List selectSysListenerList(SysListener sysListener);
+
+ /**
+ * 新增流程监听
+ *
+ * @param sysListener 流程监听
+ * @return 结果
+ */
+ public int insertSysListener(SysListener sysListener);
+
+ /**
+ * 修改流程监听
+ *
+ * @param sysListener 流程监听
+ * @return 结果
+ */
+ public int updateSysListener(SysListener sysListener);
+
+ /**
+ * 批量删除流程监听
+ *
+ * @param ids 需要删除的流程监听主键集合
+ * @return 结果
+ */
+ public int deleteSysListenerByIds(Long[] ids);
+
+ /**
+ * 删除流程监听信息
+ *
+ * @param id 流程监听主键
+ * @return 结果
+ */
+ public int deleteSysListenerById(Long id);
+}
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/ISysTaskFormService.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/ISysTaskFormService.java
new file mode 100644
index 00000000..c269e24b
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/ISysTaskFormService.java
@@ -0,0 +1,62 @@
+package com.yanzhu.flowable.service;
+
+import com.yanzhu.flowable.domain.SysTaskForm;
+
+import java.util.List;
+
+/**
+ * 流程任务关联单Service接口
+ *
+ * @author Tony
+ * @date 2021-04-03
+ */
+@Deprecated
+public interface ISysTaskFormService {
+ /**
+ * 查询流程任务关联单
+ *
+ * @param id 流程任务关联单ID
+ * @return 流程任务关联单
+ */
+ public SysTaskForm selectSysTaskFormById(Long id);
+
+ /**
+ * 查询流程任务关联单列表
+ *
+ * @param sysTaskForm 流程任务关联单
+ * @return 流程任务关联单集合
+ */
+ public List selectSysTaskFormList(SysTaskForm sysTaskForm);
+
+ /**
+ * 新增流程任务关联单
+ *
+ * @param sysTaskForm 流程任务关联单
+ * @return 结果
+ */
+ public int insertSysTaskForm(SysTaskForm sysTaskForm);
+
+ /**
+ * 修改流程任务关联单
+ *
+ * @param sysTaskForm 流程任务关联单
+ * @return 结果
+ */
+ public int updateSysTaskForm(SysTaskForm sysTaskForm);
+
+ /**
+ * 批量删除流程任务关联单
+ *
+ * @param ids 需要删除的流程任务关联单ID
+ * @return 结果
+ */
+ public int deleteSysTaskFormByIds(Long[] ids);
+
+ /**
+ * 删除流程任务关联单信息
+ *
+ * @param id 流程任务关联单ID
+ * @return 结果
+ */
+ public int deleteSysTaskFormById(Long id);
+}
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowDefinitionServiceImpl.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowDefinitionServiceImpl.java
new file mode 100644
index 00000000..505a5740
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowDefinitionServiceImpl.java
@@ -0,0 +1,232 @@
+package com.yanzhu.flowable.service.impl;
+
+import com.yanzhu.common.core.web.domain.AjaxResult;
+import com.yanzhu.common.security.utils.SecurityUtils;
+import com.yanzhu.flowable.common.constant.ProcessConstants;
+import com.yanzhu.flowable.domain.SysForm;
+import com.yanzhu.flowable.domain.dto.FlowProcDefDto;
+import com.yanzhu.flowable.factory.FlowServiceFactory;
+import com.yanzhu.flowable.mapper.FlowDeployMapper;
+import com.yanzhu.flowable.service.IFlowDefinitionService;
+import com.yanzhu.flowable.service.ISysDeployFormService;
+import com.yanzhu.system.api.domain.SysUser;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.io.IOUtils;
+import org.flowable.bpmn.model.BpmnModel;
+import org.flowable.engine.repository.Deployment;
+import org.flowable.engine.repository.ProcessDefinition;
+import org.flowable.engine.repository.ProcessDefinitionQuery;
+import org.flowable.image.impl.DefaultProcessDiagramGenerator;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * 流程定义
+ *
+ * @author Tony
+ * @date 2021-04-03
+ */
+@Service
+@Slf4j
+public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFlowDefinitionService {
+
+ @Resource
+ private ISysDeployFormService sysDeployFormService;
+
+ @Resource
+ private FlowDeployMapper flowDeployMapper;
+
+ private static final String BPMN_FILE_SUFFIX = ".bpmn";
+
+ @Override
+ public boolean exist(String processDefinitionKey) {
+ ProcessDefinitionQuery processDefinitionQuery
+ = repositoryService.createProcessDefinitionQuery().processDefinitionKey(processDefinitionKey);
+ long count = processDefinitionQuery.count();
+ return count > 0 ? true : false;
+ }
+
+
+ /**
+ * 流程定义列表
+ *
+ * @return 流程定义分页列表数据
+ */
+ @Override
+ public List list(String name) {
+
+ final List dataList = flowDeployMapper.selectDeployList(name);
+ // 加载挂表单
+ for (FlowProcDefDto procDef : dataList) {
+ SysForm sysForm = sysDeployFormService.selectSysDeployFormByDeployId(procDef.getDeploymentId());
+ if (Objects.nonNull(sysForm)) {
+ procDef.setFormName(sysForm.getFormName());
+ procDef.setFormId(sysForm.getFormId());
+ }
+ }
+ return dataList;
+ }
+
+ /**
+ * 列表转换
+ * @param name
+ * @return
+ public Page list(String name) {
+ Page page = new Page<>();
+
+ PageHelper.startPage(pageNum, pageSize);
+ final List dataList = flowDeployMapper.selectDeployList(name);
+ // 加载挂表单
+ for (FlowProcDefDto procDef : dataList) {
+ SysForm sysForm = sysDeployFormService.selectSysDeployFormByDeployId(procDef.getDeploymentId());
+ if (Objects.nonNull(sysForm)) {
+ procDef.setFormName(sysForm.getFormName());
+ procDef.setFormId(sysForm.getFormId());
+ }
+ }
+ page.setTotal(new PageInfo(dataList).getTotal());
+ // todo page.setRecords(dataList);
+ return page;
+ }
+ */
+
+ /**
+ * 导入流程文件
+ *
+ * 当每个key的流程第一次部署时,指定版本为1。对其后所有使用相同key的流程定义,
+ * 部署时版本会在该key当前已部署的最高版本号基础上加1。key参数用于区分流程定义
+ * @param name
+ * @param category
+ * @param in
+ */
+ @Override
+ public void importFile(String name, String category, InputStream in) {
+ Deployment deploy = repositoryService.createDeployment().addInputStream(name + BPMN_FILE_SUFFIX, in).name(name).category(category).deploy();
+ ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().deploymentId(deploy.getId()).singleResult();
+ repositoryService.setProcessDefinitionCategory(definition.getId(), category);
+
+ }
+
+ /**
+ * 读取xml
+ *
+ * @param deployId
+ * @return
+ */
+ @Override
+ public AjaxResult readXml(String deployId) throws IOException {
+ ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().deploymentId(deployId).singleResult();
+ InputStream inputStream = repositoryService.getResourceAsStream(definition.getDeploymentId(), definition.getResourceName());
+ String result = IOUtils.toString(inputStream, StandardCharsets.UTF_8.name());
+ return AjaxResult.success("", result);
+ }
+
+ /**
+ * 读取xml
+ *
+ * @param deployId
+ * @return
+ */
+ @Override
+ public InputStream readImage(String deployId) {
+ ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deployId).singleResult();
+ //获得图片流
+ DefaultProcessDiagramGenerator diagramGenerator = new DefaultProcessDiagramGenerator();
+ BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId());
+ //输出为图片
+ return diagramGenerator.generateDiagram(
+ bpmnModel,
+ "png",
+ Collections.emptyList(),
+ Collections.emptyList(),
+ "宋体",
+ "宋体",
+ "宋体",
+ null,
+ 1.0,
+ false);
+
+ }
+
+ /**
+ * 根据流程定义ID启动流程实例
+ *
+ * @param procDefId 流程模板ID
+ * @param variables 流程变量
+ * @return
+ */
+ @Override
+ public AjaxResult startProcessInstanceById(String procDefId, Map variables) {
+ try {
+ ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(procDefId)
+ .latestVersion().singleResult();
+ if (Objects.nonNull(processDefinition) && processDefinition.isSuspended()) {
+ return AjaxResult.error("流程已被挂起,请先激活流程");
+ }
+ // 设置流程发起人Id到流程中
+ SysUser sysUser = SecurityUtils.getLoginUser().getSysUser();
+ identityService.setAuthenticatedUserId(sysUser.getUserId().toString());
+ variables.put(ProcessConstants.PROCESS_INITIATOR, sysUser.getUserId());
+ runtimeService.startProcessInstanceById(procDefId, variables);
+
+ // 流程发起时 跳过发起人节点
+// SysUser sysUser = SecurityUtils.getLoginUser().getUser();
+// identityService.setAuthenticatedUserId(sysUser.getUserId().toString());
+// variables.put(ProcessConstants.PROCESS_INITIATOR, "");
+// ProcessInstance processInstance = runtimeService.startProcessInstanceById(procDefId, variables);
+// // 给第一步申请人节点设置任务执行人和意见
+// Task task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).singleResult();
+// if (Objects.nonNull(task)) {
+// taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.NORMAL.getType(), sysUser.getNickName() + "发起流程申请");
+//// taskService.setAssignee(task.getId(), sysUser.getUserId().toString());
+// taskService.complete(task.getId(), variables);
+// }
+ return AjaxResult.success("流程启动成功");
+ } catch (Exception e) {
+ e.printStackTrace();
+ return AjaxResult.error("流程启动错误");
+ }
+ }
+
+
+ /**
+ * 激活或挂起流程定义
+ *
+ * @param state 状态
+ * @param deployId 流程部署ID
+ */
+ @Override
+ public void updateState(Integer state, String deployId) {
+ ProcessDefinition procDef = repositoryService.createProcessDefinitionQuery().deploymentId(deployId).singleResult();
+ // 激活
+ if (state == 1) {
+ repositoryService.activateProcessDefinitionById(procDef.getId(), true, null);
+ }
+ // 挂起
+ if (state == 2) {
+ repositoryService.suspendProcessDefinitionById(procDef.getId(), true, null);
+ }
+ }
+
+
+ /**
+ * 删除流程定义
+ *
+ * @param deployId 流程部署ID act_ge_bytearray 表中 deployment_id值
+ */
+ @Override
+ public void delete(String deployId) {
+ // true 允许级联删除 ,不设置会导致数据库外键关联异常
+ repositoryService.deleteDeployment(deployId, true);
+ }
+
+
+}
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowInstanceServiceImpl.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowInstanceServiceImpl.java
new file mode 100644
index 00000000..6727b5f8
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowInstanceServiceImpl.java
@@ -0,0 +1,118 @@
+package com.yanzhu.flowable.service.impl;
+
+import com.yanzhu.common.core.web.domain.AjaxResult;
+import com.yanzhu.common.security.utils.SecurityUtils;
+import com.yanzhu.flowable.domain.vo.FlowTaskVo;
+import com.yanzhu.flowable.factory.FlowServiceFactory;
+import com.yanzhu.flowable.service.IFlowInstanceService;
+import lombok.extern.slf4j.Slf4j;
+import org.flowable.common.engine.api.FlowableObjectNotFoundException;
+import org.flowable.engine.history.HistoricProcessInstance;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * 工作流流程实例管理
+ *
+ * @author Tony
+ * @date 2021-04-03
+ */
+@Service
+@Slf4j
+public class FlowInstanceServiceImpl extends FlowServiceFactory implements IFlowInstanceService {
+
+ /**
+ * 结束流程实例
+ *
+ * @param vo
+ */
+ @Override
+ public void stopProcessInstance(FlowTaskVo vo) {
+ String taskId = vo.getTaskId();
+
+ }
+
+ /**
+ * 激活或挂起流程实例
+ *
+ * @param state 状态
+ * @param instanceId 流程实例ID
+ */
+ @Override
+ public void updateState(Integer state, String instanceId) {
+
+ // 激活
+ if (state == 1) {
+ runtimeService.activateProcessInstanceById(instanceId);
+ }
+ // 挂起
+ if (state == 2) {
+ runtimeService.suspendProcessInstanceById(instanceId);
+ }
+ }
+
+ /**
+ * 删除流程实例ID
+ *
+ * @param instanceId 流程实例ID
+ * @param deleteReason 删除原因
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void delete(String instanceId, String deleteReason) {
+
+ // 查询历史数据
+ HistoricProcessInstance historicProcessInstance = getHistoricProcessInstanceById(instanceId);
+ if (historicProcessInstance.getEndTime() != null) {
+ historyService.deleteHistoricProcessInstance(historicProcessInstance.getId());
+ return;
+ }
+ // 删除流程实例
+ runtimeService.deleteProcessInstance(instanceId, deleteReason);
+ // 删除历史流程实例
+ historyService.deleteHistoricProcessInstance(instanceId);
+ }
+
+ /**
+ * 根据实例ID查询历史实例数据
+ *
+ * @param processInstanceId
+ * @return
+ */
+ @Override
+ public HistoricProcessInstance getHistoricProcessInstanceById(String processInstanceId) {
+ HistoricProcessInstance historicProcessInstance =
+ historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
+ if (Objects.isNull(historicProcessInstance)) {
+ throw new FlowableObjectNotFoundException("流程实例不存在: " + processInstanceId);
+ }
+ return historicProcessInstance;
+ }
+
+ /**
+ * 根据流程定义ID启动流程实例
+ *
+ * @param procDefId 流程定义Id
+ * @param variables 流程变量
+ * @return
+ */
+ @Override
+ public AjaxResult startProcessInstanceById(String procDefId, Map variables) {
+
+ try {
+ // 设置流程发起人Id到流程中
+ Long userId = SecurityUtils.getLoginUser().getSysUser().getUserId();
+// identityService.setAuthenticatedUserId(userId.toString());
+ variables.put("initiator",userId);
+ variables.put("_FLOWABLE_SKIP_EXPRESSION_ENABLED", true);
+ runtimeService.startProcessInstanceById(procDefId, variables);
+ return AjaxResult.success("流程启动成功");
+ } catch (Exception e) {
+ e.printStackTrace();
+ return AjaxResult.error("流程启动错误");
+ }
+ }
+}
\ No newline at end of file
diff --git a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowTaskServiceImpl.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowTaskServiceImpl.java
new file mode 100644
index 00000000..519709bb
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowTaskServiceImpl.java
@@ -0,0 +1,1308 @@
+package com.yanzhu.flowable.service.impl;
+
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;
+import com.alibaba.fastjson2.TypeReference;
+import com.github.pagehelper.PageInfo;
+import com.yanzhu.common.core.exception.base.BaseException;
+import com.yanzhu.common.core.web.domain.AjaxResult;
+import com.yanzhu.common.security.utils.SecurityUtils;
+import com.yanzhu.flowable.common.constant.ProcessConstants;
+import com.yanzhu.flowable.common.enums.FlowComment;
+import com.yanzhu.flowable.domain.SysForm;
+import com.yanzhu.flowable.domain.dto.FlowCommentDto;
+import com.yanzhu.flowable.domain.dto.FlowNextDto;
+import com.yanzhu.flowable.domain.dto.FlowTaskDto;
+import com.yanzhu.flowable.domain.dto.FlowViewerDto;
+import com.yanzhu.flowable.domain.vo.FlowQueryVo;
+import com.yanzhu.flowable.domain.vo.FlowTaskVo;
+import com.yanzhu.flowable.factory.FlowServiceFactory;
+import com.yanzhu.flowable.flow.CustomProcessDiagramGenerator;
+import com.yanzhu.flowable.flow.FindNextNodeUtil;
+import com.yanzhu.flowable.flow.FlowableUtils;
+import com.yanzhu.flowable.rpc.RemoteSystemService;
+import com.yanzhu.flowable.service.IFlowTaskService;
+import com.yanzhu.flowable.service.ISysDeployFormService;
+import com.yanzhu.flowable.service.ISysFormService;
+import com.yanzhu.flowable.util.WorkflowUtil;
+import com.yanzhu.system.api.domain.SysRole;
+import com.yanzhu.system.api.domain.SysUser;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.flowable.bpmn.model.Process;
+import org.flowable.bpmn.model.*;
+import org.flowable.common.engine.api.FlowableException;
+import org.flowable.common.engine.api.FlowableObjectNotFoundException;
+import org.flowable.engine.ProcessEngineConfiguration;
+import org.flowable.engine.history.HistoricActivityInstance;
+import org.flowable.engine.history.HistoricProcessInstance;
+import org.flowable.engine.history.HistoricProcessInstanceQuery;
+import org.flowable.engine.impl.cmd.AddMultiInstanceExecutionCmd;
+import org.flowable.engine.impl.cmd.DeleteMultiInstanceExecutionCmd;
+import org.flowable.engine.repository.ProcessDefinition;
+import org.flowable.engine.runtime.Execution;
+import org.flowable.engine.runtime.ProcessInstance;
+import org.flowable.engine.task.Comment;
+import org.flowable.identitylink.api.history.HistoricIdentityLink;
+import org.flowable.image.ProcessDiagramGenerator;
+import org.flowable.task.api.DelegationState;
+import org.flowable.task.api.Task;
+import org.flowable.task.api.TaskQuery;
+import org.flowable.task.api.history.HistoricTaskInstance;
+import org.flowable.task.api.history.HistoricTaskInstanceQuery;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.nio.charset.StandardCharsets;
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+/**
+ * @author Tony
+ * @date 2021-04-03
+ **/
+@Service
+@Slf4j
+public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTaskService {
+
+ @Resource
+ private RemoteSystemService remoteSystemService;
+ @Resource
+ private ISysDeployFormService sysInstanceFormService;
+ @Resource
+ private ISysFormService sysFormService;
+
+ /**
+ * 完成任务
+ *
+ * @param taskVo 请求实体参数
+ */
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public AjaxResult complete(FlowTaskVo taskVo) {
+ Task task = taskService.createTaskQuery().taskId(taskVo.getTaskId()).singleResult();
+ if (Objects.isNull(task)) {
+ return AjaxResult.error("任务不存在");
+ }
+ if (DelegationState.PENDING.equals(task.getDelegationState())) {
+ taskService.addComment(taskVo.getTaskId(), taskVo.getInstanceId(), FlowComment.DELEGATE.getType(), taskVo.getComment());
+ taskService.resolveTask(taskVo.getTaskId(), taskVo.getVariables());
+ } else {
+ taskService.addComment(taskVo.getTaskId(), taskVo.getInstanceId(), FlowComment.NORMAL.getType(), taskVo.getComment());
+ Long userId = SecurityUtils.getLoginUser().getUserid();
+ taskService.setAssignee(taskVo.getTaskId(), userId.toString());
+ taskService.complete(taskVo.getTaskId(), taskVo.getVariables());
+ }
+ return AjaxResult.success();
+ }
+
+ /**
+ * 驳回任务
+ *
+ * @param flowTaskVo
+ */
+ @Override
+ public void taskReject(FlowTaskVo flowTaskVo) {
+ if (taskService.createTaskQuery().taskId(flowTaskVo.getTaskId()).singleResult().isSuspended()) {
+ throw new RuntimeException("任务处于挂起状态!");
+ }
+ // 当前任务 task
+ Task task = taskService.createTaskQuery().taskId(flowTaskVo.getTaskId()).singleResult();
+ // 获取流程定义信息
+ ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(task.getProcessDefinitionId()).singleResult();
+ // 获取所有节点信息
+ Process process = repositoryService.getBpmnModel(processDefinition.getId()).getProcesses().get(0);
+ // 获取全部节点列表,包含子节点
+ Collection allElements = FlowableUtils.getAllElements(process.getFlowElements(), null);
+ // 获取当前任务节点元素
+ FlowElement source = null;
+ if (allElements != null) {
+ for (FlowElement flowElement : allElements) {
+ // 类型为用户节点
+ if (flowElement.getId().equals(task.getTaskDefinitionKey())) {
+ // 获取节点信息
+ source = flowElement;
+ }
+ }
+ }
+
+ // 目的获取所有跳转到的节点 targetIds
+ // 获取当前节点的所有父级用户任务节点
+ // 深度优先算法思想:延边迭代深入
+ List parentUserTaskList = FlowableUtils.iteratorFindParentUserTasks(source, null, null);
+ if (parentUserTaskList == null || parentUserTaskList.size() == 0) {
+ throw new RuntimeException("当前节点为初始任务节点,不能驳回");
+ }
+ // 获取活动 ID 即节点 Key
+ List parentUserTaskKeyList = new ArrayList<>();
+ parentUserTaskList.forEach(item -> parentUserTaskKeyList.add(item.getId()));
+ // 获取全部历史节点活动实例,即已经走过的节点历史,数据采用开始时间升序
+ List historicTaskInstanceList = historyService.createHistoricTaskInstanceQuery().processInstanceId(task.getProcessInstanceId()).orderByHistoricTaskInstanceStartTime().asc().list();
+ // 数据清洗,将回滚导致的脏数据清洗掉
+ List lastHistoricTaskInstanceList = FlowableUtils.historicTaskInstanceClean(allElements, historicTaskInstanceList);
+ // 此时历史任务实例为倒序,获取最后走的节点
+ List targetIds = new ArrayList<>();
+ // 循环结束标识,遇到当前目标节点的次数
+ int number = 0;
+ StringBuilder parentHistoricTaskKey = new StringBuilder();
+ for (String historicTaskInstanceKey : lastHistoricTaskInstanceList) {
+ // 当会签时候会出现特殊的,连续都是同一个节点历史数据的情况,这种时候跳过
+ if (parentHistoricTaskKey.toString().equals(historicTaskInstanceKey)) {
+ continue;
+ }
+ parentHistoricTaskKey = new StringBuilder(historicTaskInstanceKey);
+ if (historicTaskInstanceKey.equals(task.getTaskDefinitionKey())) {
+ number++;
+ }
+ // 在数据清洗后,历史节点就是唯一一条从起始到当前节点的历史记录,理论上每个点只会出现一次
+ // 在流程中如果出现循环,那么每次循环中间的点也只会出现一次,再出现就是下次循环
+ // number == 1,第一次遇到当前节点
+ // number == 2,第二次遇到,代表最后一次的循环范围
+ if (number == 2) {
+ break;
+ }
+ // 如果当前历史节点,属于父级的节点,说明最后一次经过了这个点,需要退回这个点
+ if (parentUserTaskKeyList.contains(historicTaskInstanceKey)) {
+ targetIds.add(historicTaskInstanceKey);
+ }
+ }
+
+
+ // 目的获取所有需要被跳转的节点 currentIds
+ // 取其中一个父级任务,因为后续要么存在公共网关,要么就是串行公共线路
+ UserTask oneUserTask = parentUserTaskList.get(0);
+ // 获取所有正常进行的任务节点 Key,这些任务不能直接使用,需要找出其中需要撤回的任务
+ List runTaskList = taskService.createTaskQuery().processInstanceId(task.getProcessInstanceId()).list();
+ List runTaskKeyList = new ArrayList<>();
+ runTaskList.forEach(item -> runTaskKeyList.add(item.getTaskDefinitionKey()));
+ // 需驳回任务列表
+ List currentIds = new ArrayList<>();
+ // 通过父级网关的出口连线,结合 runTaskList 比对,获取需要撤回的任务
+ List currentUserTaskList = FlowableUtils.iteratorFindChildUserTasks(oneUserTask, runTaskKeyList, null, null);
+ currentUserTaskList.forEach(item -> currentIds.add(item.getId()));
+
+
+ // 规定:并行网关之前节点必须需存在唯一用户任务节点,如果出现多个任务节点,则并行网关节点默认为结束节点,原因为不考虑多对多情况
+ if (targetIds.size() > 1 && currentIds.size() > 1) {
+ throw new RuntimeException("任务出现多对多情况,无法撤回");
+ }
+
+ // 循环获取那些需要被撤回的节点的ID,用来设置驳回原因
+ List currentTaskIds = new ArrayList<>();
+ currentIds.forEach(currentId -> runTaskList.forEach(runTask -> {
+ if (currentId.equals(runTask.getTaskDefinitionKey())) {
+ currentTaskIds.add(runTask.getId());
+ }
+ }));
+ // 设置驳回意见
+ currentTaskIds.forEach(item -> taskService.addComment(item, task.getProcessInstanceId(), FlowComment.REJECT.getType(), flowTaskVo.getComment()));
+
+ try {
+ // 如果父级任务多于 1 个,说明当前节点不是并行节点,原因为不考虑多对多情况
+ if (targetIds.size() > 1) {
+ // 1 对 多任务跳转,currentIds 当前节点(1),targetIds 跳转到的节点(多)
+ runtimeService.createChangeActivityStateBuilder()
+ .processInstanceId(task.getProcessInstanceId()).
+ moveSingleActivityIdToActivityIds(currentIds.get(0), targetIds).changeState();
+ }
+ // 如果父级任务只有一个,因此当前任务可能为网关中的任务
+ if (targetIds.size() == 1) {
+ // 1 对 1 或 多 对 1 情况,currentIds 当前要跳转的节点列表(1或多),targetIds.get(0) 跳转到的节点(1)
+ runtimeService.createChangeActivityStateBuilder()
+ .processInstanceId(task.getProcessInstanceId())
+ .moveActivityIdsToSingleActivityId(currentIds, targetIds.get(0)).changeState();
+ }
+ } catch (FlowableObjectNotFoundException e) {
+ throw new BaseException("未找到流程实例,流程可能已发生变化");
+ } catch (FlowableException e) {
+ throw new BaseException("无法取消或开始活动");
+ }
+
+ }
+
+ /**
+ * 退回任务
+ *
+ * @param flowTaskVo 请求实体参数
+ */
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public void taskReturn(FlowTaskVo flowTaskVo) {
+ if (taskService.createTaskQuery().taskId(flowTaskVo.getTaskId()).singleResult().isSuspended()) {
+ throw new BaseException("任务处于挂起状态");
+ }
+ // 当前任务 task
+ Task task = taskService.createTaskQuery().taskId(flowTaskVo.getTaskId()).singleResult();
+ // 获取流程定义信息
+ ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(task.getProcessDefinitionId()).singleResult();
+ // 获取所有节点信息
+ Process process = repositoryService.getBpmnModel(processDefinition.getId()).getProcesses().get(0);
+ // 获取全部节点列表,包含子节点
+ Collection allElements = FlowableUtils.getAllElements(process.getFlowElements(), null);
+ // 获取当前任务节点元素
+ FlowElement source = null;
+ // 获取跳转的节点元素
+ FlowElement target = null;
+ if (allElements != null) {
+ for (FlowElement flowElement : allElements) {
+ // 当前任务节点元素
+ if (flowElement.getId().equals(task.getTaskDefinitionKey())) {
+ source = flowElement;
+ }
+ // 跳转的节点元素
+ if (flowElement.getId().equals(flowTaskVo.getTargetKey())) {
+ target = flowElement;
+ }
+ }
+ }
+
+ // 从当前节点向前扫描
+ // 如果存在路线上不存在目标节点,说明目标节点是在网关上或非同一路线上,不可跳转
+ // 否则目标节点相对于当前节点,属于串行
+ Boolean isSequential = FlowableUtils.iteratorCheckSequentialReferTarget(source, flowTaskVo.getTargetKey(), null, null);
+ if (!isSequential) {
+ throw new BaseException("当前节点相对于目标节点,不属于串行关系,无法回退");
+ }
+
+
+ // 获取所有正常进行的任务节点 Key,这些任务不能直接使用,需要找出其中需要撤回的任务
+ List runTaskList = taskService.createTaskQuery().processInstanceId(task.getProcessInstanceId()).list();
+ List runTaskKeyList = new ArrayList<>();
+ runTaskList.forEach(item -> runTaskKeyList.add(item.getTaskDefinitionKey()));
+ // 需退回任务列表
+ List currentIds = new ArrayList<>();
+ // 通过父级网关的出口连线,结合 runTaskList 比对,获取需要撤回的任务
+ List currentUserTaskList = FlowableUtils.iteratorFindChildUserTasks(target, runTaskKeyList, null, null);
+ currentUserTaskList.forEach(item -> currentIds.add(item.getId()));
+
+ // 循环获取那些需要被撤回的节点的ID,用来设置驳回原因
+ List currentTaskIds = new ArrayList<>();
+ currentIds.forEach(currentId -> runTaskList.forEach(runTask -> {
+ if (currentId.equals(runTask.getTaskDefinitionKey())) {
+ currentTaskIds.add(runTask.getId());
+ }
+ }));
+ // 设置回退意见
+ currentTaskIds.forEach(currentTaskId -> taskService.addComment(currentTaskId, task.getProcessInstanceId(), FlowComment.REBACK.getType(), flowTaskVo.getComment()));
+
+ try {
+ // 1 对 1 或 多 对 1 情况,currentIds 当前要跳转的节点列表(1或多),targetKey 跳转到的节点(1)
+ runtimeService.createChangeActivityStateBuilder()
+ .processInstanceId(task.getProcessInstanceId())
+ .moveActivityIdsToSingleActivityId(currentIds, flowTaskVo.getTargetKey()).changeState();
+ } catch (FlowableObjectNotFoundException e) {
+ throw new BaseException("未找到流程实例,流程可能已发生变化");
+ } catch (FlowableException e) {
+ throw new BaseException("无法取消或开始活动");
+ }
+ }
+
+
+ /**
+ * 获取所有可回退的节点
+ *
+ * @param flowTaskVo
+ * @return
+ */
+ @Override
+ public AjaxResult findReturnTaskList(FlowTaskVo flowTaskVo) {
+// // 当前任务 task
+// Task task = taskService.createTaskQuery().taskId(flowTaskVo.getTaskId()).singleResult();
+// // 从流程历史任务中获取可退回节点
+//// List hisActIns = historyService.createHistoricActivityInstanceQuery()
+//// .executionId(task.getExecutionId())
+//// .activityType("userTask")
+//// .orderByHistoricActivityInstanceStartTime()
+//// .finished()
+//// .desc()
+//// .list();
+////
+//// // 可回退的节点列表
+//// List returnTaskNodeList = new ArrayList<>();
+//// ReturnTaskNodeVo returnTaskNodeVo;
+//// for (HistoricActivityInstance activityInstance : hisActIns) {
+//// returnTaskNodeVo = new ReturnTaskNodeVo();
+//// returnTaskNodeVo.setId(activityInstance.getActivityId());
+//// // 根据流程节点处理时间校验改节点是否已完成
+//// returnTaskNodeVo.setName(activityInstance.getActivityName());
+//// returnTaskNodeList.add(returnTaskNodeVo);
+//// }
+// List userTaskList = new ArrayList<>();
+// // 获取流程定义信息
+// ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(task.getProcessDefinitionId()).singleResult();
+// // 获取所有节点信息,暂不考虑子流程情况
+// Process process = repositoryService.getBpmnModel(processDefinition.getId()).getProcesses().get(0);
+// Collection flowElements = process.getFlowElements();
+// // 获取当前任务节点元素
+// UserTask source = null;
+// if (flowElements != null) {
+// for (FlowElement flowElement : flowElements) {
+// // 类型为用户节点
+// if (flowElement.getId().equals(task.getTaskDefinitionKey())) {
+// source = (UserTask) flowElement;
+// }
+// }
+// }
+// // 获取节点的所有路线
+// List> roads = FlowableUtils.findRoad(source, null, null, null);
+//
+// for (List road : roads) {
+// if (userTaskList.size() == 0) {
+// // 还没有可回退节点直接添加
+// userTaskList = road;
+// } else {
+// // 如果已有回退节点,则比对取交集部分
+// userTaskList.retainAll(road);
+// }
+// }
+// return AjaxResult.success(userTaskList);
+ // 当前任务 task
+ Task task = taskService.createTaskQuery().taskId(flowTaskVo.getTaskId()).singleResult();
+ // 获取流程定义信息
+ ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(task.getProcessDefinitionId()).singleResult();
+ // 获取所有节点信息,暂不考虑子流程情况
+ Process process = repositoryService.getBpmnModel(processDefinition.getId()).getProcesses().get(0);
+ Collection flowElements = process.getFlowElements();
+ // 获取当前任务节点元素
+ UserTask source = null;
+ if (flowElements != null) {
+ for (FlowElement flowElement : flowElements) {
+ // 类型为用户节点
+ if (flowElement.getId().equals(task.getTaskDefinitionKey())) {
+ source = (UserTask) flowElement;
+ }
+ }
+ }
+ // 获取节点的所有路线
+ List> roads = FlowableUtils.findRoad(source, null, null, null);
+ // 可回退的节点列表
+ List userTaskList = new ArrayList<>();
+ for (List road : roads) {
+ if (userTaskList.size() == 0) {
+ // 还没有可回退节点直接添加
+ userTaskList = road;
+ } else {
+ // 如果已有回退节点,则比对取交集部分
+ userTaskList.retainAll(road);
+ }
+ }
+ return AjaxResult.success(userTaskList);
+ }
+
+ /**
+ * 删除任务
+ *
+ * @param flowTaskVo 请求实体参数
+ */
+ @Override
+ public void deleteTask(FlowTaskVo flowTaskVo) {
+ // todo 待确认删除任务是物理删除任务 还是逻辑删除,让这个任务直接通过?
+ taskService.deleteTask(flowTaskVo.getTaskId(), flowTaskVo.getComment());
+ }
+
+ /**
+ * 认领/签收任务
+ * 认领以后,这个用户就会成为任务的执行人,任务会从其他成员的任务列表中消失
+ *
+ * @param flowTaskVo 请求实体参数
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void claim(FlowTaskVo flowTaskVo) {
+ taskService.claim(flowTaskVo.getTaskId(), flowTaskVo.getUserId());
+ }
+
+ /**
+ * 取消认领/签收任务
+ *
+ * @param flowTaskVo 请求实体参数
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void unClaim(FlowTaskVo flowTaskVo) {
+ taskService.unclaim(flowTaskVo.getTaskId());
+ }
+
+ /**
+ * 委派任务
+ * 任务委派只是委派人将当前的任务交给被委派人进行审批,处理任务后又重新回到委派人身上。
+ *
+ * @param flowTaskVo 请求实体参数
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void delegateTask(FlowTaskVo flowTaskVo) {
+ taskService.delegateTask(flowTaskVo.getTaskId(), flowTaskVo.getAssignee());
+ }
+
+ /**
+ * 任务归还
+ * 被委派人完成任务之后,将任务归还委派人
+ *
+ * @param flowTaskVo 请求实体参数
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void resolveTask(FlowTaskVo flowTaskVo) {
+ taskService.resolveTask(flowTaskVo.getTaskId());
+ }
+
+
+ /**
+ * 转办任务
+ * 直接将办理人换成别人,这时任务的拥有者不再是转办人
+ *
+ * @param flowTaskVo 请求实体参数
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void assignTask(FlowTaskVo flowTaskVo) {
+ // 直接转派就可以覆盖掉之前的
+ taskService.setAssignee(flowTaskVo.getTaskId(), flowTaskVo.getAssignee());
+// // 删除指派人重新指派
+// taskService.deleteCandidateUser(flowTaskVo.getTaskId(),flowTaskVo.getAssignee());
+// taskService.addCandidateUser(flowTaskVo.getTaskId(),flowTaskVo.getAssignee());
+// // 如果要查询转给他人处理的任务,可以同时将OWNER进行设置:
+// taskService.setOwner(flowTaskVo.getTaskId(), flowTaskVo.getAssignee());
+
+ }
+
+ /**
+ * 多实例加签
+ * act_ru_task、act_ru_identitylink各生成一条记录
+ *
+ * @param flowTaskVo
+ */
+ @Override
+ public void addMultiInstanceExecution(FlowTaskVo flowTaskVo) {
+ managementService.executeCommand(new AddMultiInstanceExecutionCmd(flowTaskVo.getDefId(), flowTaskVo.getInstanceId(), flowTaskVo.getVariables()));
+ }
+
+ /**
+ * 多实例减签
+ * act_ru_task减1、act_ru_identitylink不变
+ *
+ * @param flowTaskVo
+ */
+ @Override
+ public void deleteMultiInstanceExecution(FlowTaskVo flowTaskVo) {
+ managementService.executeCommand(new DeleteMultiInstanceExecutionCmd(flowTaskVo.getCurrentChildExecutionId(), flowTaskVo.getFlag()));
+ }
+
+ /**
+ * 我发起的流程
+ *
+ * @param queryVo 请求参数
+ * @return
+ */
+ @Override
+ public PageInfo myProcess(FlowQueryVo queryVo) {
+ Long userId = SecurityUtils.getLoginUser().getUserid();
+ HistoricProcessInstanceQuery historicProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery()
+ .startedBy(userId.toString())
+ .orderByProcessInstanceStartTime()
+ .desc();
+ List historicProcessInstances = historicProcessInstanceQuery.listPage(queryVo.getPageSize() * (queryVo.getPageNum() - 1), queryVo.getPageSize());
+ List flowList = new ArrayList<>();
+ for (HistoricProcessInstance hisIns : historicProcessInstances) {
+ FlowTaskDto flowTask = new FlowTaskDto();
+ flowTask.setCreateTime(hisIns.getStartTime());
+ flowTask.setFinishTime(hisIns.getEndTime());
+ flowTask.setProcInsId(hisIns.getId());
+
+ // 计算耗时
+ if (Objects.nonNull(hisIns.getEndTime())) {
+ long time = hisIns.getEndTime().getTime() - hisIns.getStartTime().getTime();
+ flowTask.setDuration(getDate(time));
+ } else {
+ long time = System.currentTimeMillis() - hisIns.getStartTime().getTime();
+ flowTask.setDuration(getDate(time));
+ }
+ // 流程定义信息
+ ProcessDefinition pd = repositoryService.createProcessDefinitionQuery()
+ .processDefinitionId(hisIns.getProcessDefinitionId())
+ .singleResult();
+ flowTask.setDeployId(pd.getDeploymentId());
+ flowTask.setProcDefName(pd.getName());
+ flowTask.setProcDefVersion(pd.getVersion());
+ flowTask.setCategory(pd.getCategory());
+ flowTask.setProcDefVersion(pd.getVersion());
+ // 当前所处流程
+ List taskList = taskService.createTaskQuery().processInstanceId(hisIns.getId()).list();
+ if (CollectionUtils.isNotEmpty(taskList)) {
+ flowTask.setTaskId(taskList.get(0).getId());
+ flowTask.setTaskName(taskList.get(0).getName());
+ if (StringUtils.isNotBlank(taskList.get(0).getAssignee())) {
+ // 当前任务节点办理人信息
+ SysUser sysUser = remoteSystemService.getUserById(Long.parseLong(taskList.get(0).getAssignee()));
+ if (Objects.nonNull(sysUser)) {
+ flowTask.setAssigneeId(sysUser.getUserId());
+ flowTask.setAssigneeName(sysUser.getNickName());
+ flowTask.setAssigneeDeptName(Objects.nonNull(sysUser.getDept()) ? sysUser.getDept().getDeptName() : "");
+ }
+ }
+ } else {
+ List historicTaskInstance = historyService.createHistoricTaskInstanceQuery().processInstanceId(hisIns.getId()).orderByHistoricTaskInstanceEndTime().desc().list();
+ flowTask.setTaskId(historicTaskInstance.get(0).getId());
+ flowTask.setTaskName(historicTaskInstance.get(0).getName());
+ if (StringUtils.isNotBlank(historicTaskInstance.get(0).getAssignee())) {
+ // 当前任务节点办理人信息
+ SysUser sysUser = remoteSystemService.getUserById(Long.parseLong(historicTaskInstance.get(0).getAssignee()));
+ if (Objects.nonNull(sysUser)) {
+ flowTask.setAssigneeId(sysUser.getUserId());
+ flowTask.setAssigneeName(sysUser.getNickName());
+ flowTask.setAssigneeDeptName(Objects.nonNull(sysUser.getDept()) ? sysUser.getDept().getDeptName() : "");
+ }
+ }
+ }
+ flowList.add(flowTask);
+ }
+ return WorkflowUtil.toPageInfo(historicProcessInstanceQuery.count(), flowList);
+ }
+
+ /**
+ * 取消申请
+ * 目前实现方式: 直接将当前流程变更为已完成
+ *
+ * @param flowTaskVo
+ * @return
+ */
+ @Override
+ public AjaxResult stopProcess(FlowTaskVo flowTaskVo) {
+ List task = taskService.createTaskQuery().processInstanceId(flowTaskVo.getInstanceId()).list();
+ if (CollectionUtils.isEmpty(task)) {
+ throw new BaseException("流程未启动或已执行完成,取消申请失败");
+ }
+ // 获取当前流程实例
+ ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
+ .processInstanceId(flowTaskVo.getInstanceId())
+ .singleResult();
+ BpmnModel bpmnModel = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId());
+ if (Objects.nonNull(bpmnModel)) {
+ Process process = bpmnModel.getMainProcess();
+ List endNodes = process.findFlowElementsOfType(EndEvent.class, false);
+ if (CollectionUtils.isNotEmpty(endNodes)) {
+ // TODO 取消流程为什么要设置流程发起人?
+// SysUser loginUser = SecurityUtils.getLoginUser().getUser();
+// Authentication.setAuthenticatedUserId(loginUser.getUserId().toString());
+
+// taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.STOP.getType(),
+// StringUtils.isBlank(flowTaskVo.getComment()) ? "取消申请" : flowTaskVo.getComment());
+ // 获取当前流程最后一个节点
+ String endId = endNodes.get(0).getId();
+ List executions = runtimeService.createExecutionQuery()
+ .parentId(processInstance.getProcessInstanceId()).list();
+ List executionIds = new ArrayList<>();
+ executions.forEach(execution -> executionIds.add(execution.getId()));
+ // 变更流程为已结束状态
+ runtimeService.createChangeActivityStateBuilder()
+ .moveExecutionsToSingleActivityId(executionIds, endId).changeState();
+ }
+ }
+
+ return AjaxResult.success();
+ }
+
+ /**
+ * 撤回流程 目前存在错误
+ *
+ * @param flowTaskVo
+ * @return
+ */
+ @Override
+ public AjaxResult revokeProcess(FlowTaskVo flowTaskVo) {
+ Task task = taskService.createTaskQuery()
+ .processInstanceId(flowTaskVo.getInstanceId())
+ .singleResult();
+ if (task == null) {
+ throw new BaseException("流程未启动或已执行完成,无法撤回");
+ }
+
+ SysUser loginUser = SecurityUtils.getLoginUser().getSysUser();
+ List htiList = historyService.createHistoricTaskInstanceQuery()
+ .processInstanceId(task.getProcessInstanceId())
+ .orderByTaskCreateTime()
+ .asc()
+ .list();
+ String myTaskId = null;
+ for (HistoricTaskInstance hti : htiList) {
+ if (loginUser.getUserId().toString().equals(hti.getAssignee())) {
+ myTaskId = hti.getId();
+ break;
+ }
+ }
+ if (null == myTaskId) {
+ throw new BaseException("该任务非当前用户提交,无法撤回");
+ }
+ List historicTaskInstanceList = historyService
+ .createHistoricTaskInstanceQuery()
+ .processInstanceId(task.getProcessInstanceId())
+ .orderByHistoricTaskInstanceStartTime()
+ .asc()
+ .list();
+ Iterator it = historicTaskInstanceList.iterator();
+ //循环节点,获取当前节点的上一节点的key
+ String tarKey = "";
+ while (it.hasNext()) {
+ HistoricTaskInstance his = it.next();
+ if (!task.getTaskDefinitionKey().equals(his.getTaskDefinitionKey())) {
+ tarKey = his.getTaskDefinitionKey();
+ }
+ }
+ // 跳转节点
+ runtimeService.createChangeActivityStateBuilder()
+ .processInstanceId(flowTaskVo.getInstanceId())
+ .moveActivityIdTo(task.getTaskDefinitionKey(), tarKey)
+ .changeState();
+
+ return AjaxResult.success();
+ }
+
+ /**
+ * 代办任务列表
+ *
+ * @param queryVo 请求参数
+ * @return
+ */
+ @Override
+ public PageInfo todoList(FlowQueryVo queryVo) {
+ // 只查看自己的数据
+ SysUser sysUser = SecurityUtils.getLoginUser().getSysUser();
+ TaskQuery taskQuery = taskService.createTaskQuery()
+ .active()
+ .includeProcessVariables()
+ .taskCandidateGroupIn(sysUser.getRoles().stream().map(role -> role.getRoleId().toString()).collect(Collectors.toList()))
+ .taskCandidateOrAssigned(sysUser.getUserId().toString())
+ .orderByTaskCreateTime().desc();
+
+// TODO 传入名称查询不到数据?
+// if (StringUtils.isNotBlank(queryVo.getName())){
+// taskQuery.processDefinitionNameLike(queryVo.getName());
+// }
+ List taskList = taskQuery.listPage(queryVo.getPageSize() * (queryVo.getPageNum() - 1), queryVo.getPageSize());
+ List flowList = new ArrayList<>();
+ for (Task task : taskList) {
+ FlowTaskDto flowTask = new FlowTaskDto();
+ // 当前流程信息
+ flowTask.setTaskId(task.getId());
+ flowTask.setTaskDefKey(task.getTaskDefinitionKey());
+ flowTask.setCreateTime(task.getCreateTime());
+ flowTask.setProcDefId(task.getProcessDefinitionId());
+ flowTask.setExecutionId(task.getExecutionId());
+ flowTask.setTaskName(task.getName());
+ // 流程定义信息
+ ProcessDefinition pd = repositoryService.createProcessDefinitionQuery()
+ .processDefinitionId(task.getProcessDefinitionId())
+ .singleResult();
+ flowTask.setDeployId(pd.getDeploymentId());
+ flowTask.setProcDefName(pd.getName());
+ flowTask.setProcDefVersion(pd.getVersion());
+ flowTask.setProcInsId(task.getProcessInstanceId());
+
+ // 流程发起人信息
+ HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery()
+ .processInstanceId(task.getProcessInstanceId())
+ .singleResult();
+ SysUser startUser = remoteSystemService.getUserById(Long.parseLong(historicProcessInstance.getStartUserId()));
+ if (null != startUser) {
+ flowTask.setStartUserId(startUser.getUserId().toString());
+ flowTask.setStartUserName(startUser.getNickName());
+ flowTask.setStartDeptName(Objects.nonNull(startUser.getDept()) ? startUser.getDept().getDeptName() : "");
+ }
+ flowList.add(flowTask);
+ }
+
+ return WorkflowUtil.toPageInfo(taskQuery.count(), flowList);
+ }
+
+
+ /**
+ * 已办任务列表
+ *
+ * @param queryVo 请求参数
+ * @return
+ */
+ @Override
+ public PageInfo finishedList(FlowQueryVo queryVo) {
+ Long userId = SecurityUtils.getLoginUser().getUserid();
+ HistoricTaskInstanceQuery taskInstanceQuery = historyService.createHistoricTaskInstanceQuery()
+ .includeProcessVariables()
+ .finished()
+ .taskAssignee(userId.toString())
+ .orderByHistoricTaskInstanceEndTime()
+ .desc();
+ List historicTaskInstanceList = taskInstanceQuery.listPage(queryVo.getPageSize() * (queryVo.getPageNum() - 1), queryVo.getPageSize());
+ List hisTaskList = new ArrayList<>();
+ for (HistoricTaskInstance histTask : historicTaskInstanceList) {
+ FlowTaskDto flowTask = new FlowTaskDto();
+ // 当前流程信息
+ flowTask.setTaskId(histTask.getId());
+ // 审批人员信息
+ flowTask.setCreateTime(histTask.getCreateTime());
+ flowTask.setFinishTime(histTask.getEndTime());
+ flowTask.setDuration(getDate(histTask.getDurationInMillis()));
+ flowTask.setProcDefId(histTask.getProcessDefinitionId());
+ flowTask.setTaskDefKey(histTask.getTaskDefinitionKey());
+ flowTask.setTaskName(histTask.getName());
+
+ // 流程定义信息
+ ProcessDefinition pd = repositoryService.createProcessDefinitionQuery()
+ .processDefinitionId(histTask.getProcessDefinitionId())
+ .singleResult();
+ flowTask.setDeployId(pd.getDeploymentId());
+ flowTask.setProcDefName(pd.getName());
+ flowTask.setProcDefVersion(pd.getVersion());
+ flowTask.setProcInsId(histTask.getProcessInstanceId());
+ flowTask.setHisProcInsId(histTask.getProcessInstanceId());
+
+ // 流程发起人信息
+ HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery()
+ .processInstanceId(histTask.getProcessInstanceId())
+ .singleResult();
+ SysUser startUser = remoteSystemService.getUserById(Long.parseLong(historicProcessInstance.getStartUserId()));
+ if (null != startUser) {
+ flowTask.setStartUserId(startUser.getNickName());
+ flowTask.setStartUserName(startUser.getNickName());
+ flowTask.setStartDeptName(Objects.nonNull(startUser.getDept()) ? startUser.getDept().getDeptName() : "");
+ }
+ hisTaskList.add(flowTask);
+ }
+ return WorkflowUtil.toPageInfo(taskInstanceQuery.count(), hisTaskList);
+ }
+
+ private static Predicate distinctByKey(Function super T, ?> keyExtractor) {
+ Set