list = sysExpressionService.selectSysExpressionList(sysExpression);
- return AjaxResult.success(list);
- }
-
-}
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
deleted file mode 100644
index 4e53b163..00000000
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowInstanceController.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package com.yanzhu.flowable.controller;
-
-import com.yanzhu.common.core.web.domain.AjaxResult;
-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 {
-
- @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 = "删除流程实例")
- @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
deleted file mode 100644
index 1d897d17..00000000
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowTaskController.java
+++ /dev/null
@@ -1,268 +0,0 @@
-package com.yanzhu.flowable.controller;
-
-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.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 {
-
- @Autowired
- private IFlowTaskService flowTaskService;
-
- @ApiOperation(value = "我发起的流程", response = FlowTaskDto.class)
- @GetMapping(value = "/myProcess")
- public AjaxResult myProcess(FlowQueryVo queryVo) {
- return flowTaskService.myProcess(queryVo);
- }
-
- @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 AjaxResult todoList(FlowQueryVo queryVo) {
- return flowTaskService.todoList(queryVo);
- }
-
- @ApiOperation(value = "获取已办任务", response = FlowTaskDto.class)
- @GetMapping(value = "/finishedList")
- public AjaxResult finishedList(FlowQueryVo queryVo) {
- return flowTaskService.finishedList(queryVo);
- }
-
-
- @ApiOperation(value = "流程历史流转记录", response = FlowTaskDto.class)
- @GetMapping(value = "/flowRecord")
- public AjaxResult flowRecord(String procInsId, String deployId) {
- return flowTaskService.flowRecord(procInsId, deployId);
- }
-
-
- @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 = "/completeAndModify")
- public AjaxResult completeAndModify(@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 = "认领/签收任务")
- @Log(title = "认领/签收流程", businessType = BusinessType.INSERT)
- @PostMapping(value = "/claim")
- public AjaxResult claim(@RequestBody FlowTaskVo flowTaskVo) {
- flowTaskService.claim(flowTaskVo);
- return AjaxResult.success();
- }
-
- @ApiOperation(value = "取消认领/签收任务")
- @Log(title = "取消认领/签收流程", businessType = BusinessType.UPDATE)
- @PostMapping(value = "/unClaim")
- public AjaxResult unClaim(@RequestBody FlowTaskVo flowTaskVo) {
- flowTaskService.unClaim(flowTaskVo);
- return AjaxResult.success();
- }
-
- @ApiOperation(value = "委派任务")
- @Log(title = "委派流程", businessType = BusinessType.UPDATE)
- @PostMapping(value = "/delegateTask")
- public AjaxResult delegate(@RequestBody FlowTaskVo flowTaskVo) {
- flowTaskService.delegateTask(flowTaskVo);
- return AjaxResult.success();
- }
-
- @ApiOperation(value = "任务归还")
- @Log(title = "归还流程", businessType = BusinessType.UPDATE)
- @PostMapping(value = "/resolveTask")
- public AjaxResult resolveTask(@RequestBody FlowTaskVo flowTaskVo) {
- flowTaskService.resolveTask(flowTaskVo);
- return AjaxResult.success();
- }
-
- @ApiOperation(value = "转办任务")
- @Log(title = "转办流程", businessType = BusinessType.UPDATE)
- @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);
- }
-
-}
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
new file mode 100644
index 00000000..5dbd2ee9
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowableCategoryController.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.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
new file mode 100644
index 00000000..9604ac18
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowableDeployController.java
@@ -0,0 +1,97 @@
+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
new file mode 100644
index 00000000..43a830fc
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowableFieldDefController.java
@@ -0,0 +1,109 @@
+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
new file mode 100644
index 00000000..2d7faf9a
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowableFieldRefController.java
@@ -0,0 +1,113 @@
+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
new file mode 100644
index 00000000..60312c88
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowableModelController.java
@@ -0,0 +1,172 @@
+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
new file mode 100644
index 00000000..74056f87
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/FlowableModelPageController.java
@@ -0,0 +1,152 @@
+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/SysFormController.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/SysFormController.java
deleted file mode 100644
index 3c819b30..00000000
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/controller/SysFormController.java
+++ /dev/null
@@ -1,111 +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.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("@ss.hasPermi('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("@ss.hasPermi('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("@ss.hasPermi('flowable:form:query')")
- @GetMapping(value = "/{formId}")
- public AjaxResult getInfo(@PathVariable("formId") Long formId) {
- return AjaxResult.success(SysFormService.selectSysFormById(formId));
- }
-
- /**
- * 新增流程表单
- */
- @RequiresPermissions("@ss.hasPermi('flowable:form:add')")
- @Log(title = "流程表单", businessType = BusinessType.INSERT)
- @PostMapping
- public AjaxResult add(@RequestBody SysForm sysForm) {
- return toAjax(SysFormService.insertSysForm(sysForm));
- }
-
- /**
- * 修改流程表单
- */
- @RequiresPermissions("@ss.hasPermi('flowable:form:edit')")
- @Log(title = "流程表单", businessType = BusinessType.UPDATE)
- @PutMapping
- public AjaxResult edit(@RequestBody SysForm sysForm) {
- return toAjax(SysFormService.updateSysForm(sysForm));
- }
-
- /**
- * 删除流程表单
- */
- @RequiresPermissions("@ss.hasPermi('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/flow/CustomProcessDiagramCanvas.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/flow/CustomProcessDiagramCanvas.java
index 7a0baca5..c84766ca 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,7 +135,6 @@ 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/ModelHelper.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/flow/ModelHelper.java
new file mode 100644
index 00000000..5636c39b
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/flow/ModelHelper.java
@@ -0,0 +1,143 @@
+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/service/IFlowBusinessKeyService.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowBusinessKeyService.java
index 1e6f1f7d..79358592 100644
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowBusinessKeyService.java
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowBusinessKeyService.java
@@ -1,6 +1,6 @@
package com.yanzhu.flowable.service;
-import com.yanzhu.flowable.domain.FlowTaskEntity;
+import com.yanzhu.flowable.domain.my.FlowTaskEntity;
import java.util.List;
import java.util.Map;
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
deleted file mode 100644
index 80258211..00000000
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowDefinitionService.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package com.yanzhu.flowable.service;
-
-import com.yanzhu.common.core.web.domain.AjaxResult;
-import com.yanzhu.common.core.web.page.TableDataInfo;
-import com.yanzhu.flowable.domain.vo.FlowQueryVo;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Map;
-
-/**
- * @author Tony
- * @date 2021-04-03 14:41
- */
-public interface IFlowDefinitionService {
-
- boolean exist(String processDefinitionKey);
-
- /**
- * 流程定义列表
- *
- * @param flowQueryVo 流程查询
- * @return 流程定义分页列表数据
- */
- TableDataInfo list(FlowQueryVo flowQueryVo);
-
- /**
- * 导入流程文件
- * 当每个key的流程第一次部署时,指定版本为1。对其后所有使用相同key的流程定义,
- * 部署时版本会在该key当前已部署的最高版本号基础上加1。key参数用于区分流程定义
- * @param name
- * @param category
- * @param prtype 流程定义类型
- * @param OwnerDeptId 流程单位
- * @param OwnerProjectId 流程项目
- * @param in
- */
- void importFile(String name, String category, String prtype, String OwnerDeptId, String OwnerProjectId, InputStream in);
-
- /**
- * 读取xml
- * @param deployId
- * @return
- */
- AjaxResult readXml(String deployId) throws IOException;
-
- /**
- * 根据流程定义ID启动流程实例
- *
- * @param procDefId 流程ID
- * @param applyInfos 申请表单
- * @return
- */
- AjaxResult startProcessInstanceById(String procDefId, Map applyInfos);
-
-
- /**
- * 激活或挂起流程定义
- *
- * @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
deleted file mode 100644
index acc69698..00000000
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowInstanceService.java
+++ /dev/null
@@ -1,54 +0,0 @@
-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
deleted file mode 100644
index c23dd4ec..00000000
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowTaskService.java
+++ /dev/null
@@ -1,208 +0,0 @@
-package com.yanzhu.flowable.service;
-
-import com.yanzhu.common.core.web.domain.AjaxResult;
-import com.yanzhu.flowable.domain.vo.FlowQueryVo;
-import com.yanzhu.flowable.domain.vo.FlowTaskVo;
-import org.flowable.task.api.Task;
-
-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
- */
- AjaxResult myProcess(FlowQueryVo queryVo);
-
- /**
- * 取消申请
- * 目前实现方式: 直接将当前流程变更为已完成
- * @param flowTaskVo
- * @return
- */
- AjaxResult stopProcess(FlowTaskVo flowTaskVo);
-
- /**
- * 撤回流程
- * @param flowTaskVo
- * @return
- */
- AjaxResult revokeProcess(FlowTaskVo flowTaskVo);
-
-
- /**
- * 代办任务列表
- *
- * @param queryVo 请求参数
- * @return
- */
- AjaxResult todoList(FlowQueryVo queryVo);
-
-
- /**
- * 已办任务列表
- *
- * @param queryVo 请求参数
- * @return
- */
- AjaxResult finishedList(FlowQueryVo queryVo);
-
- /**
- * 流程历史流转记录
- *
- * @param procInsId 流程实例Id
- * @return
- */
- AjaxResult flowRecord(String procInsId,String deployId);
-
- /**
- * 根据任务ID查询挂载的表单信息
- *
- * @param taskId 任务Id
- * @return
- */
- Task 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;
-}
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
new file mode 100644
index 00000000..6cd98a46
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowableCategoryService.java
@@ -0,0 +1,69 @@
+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
new file mode 100644
index 00000000..735452d1
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowableDeployService.java
@@ -0,0 +1,68 @@
+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
new file mode 100644
index 00000000..91044591
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowableFieldDefService.java
@@ -0,0 +1,70 @@
+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
new file mode 100644
index 00000000..1edcb29b
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowableFieldRefService.java
@@ -0,0 +1,62 @@
+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
new file mode 100644
index 00000000..5dfa47e1
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowableModelPageService.java
@@ -0,0 +1,83 @@
+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
new file mode 100644
index 00000000..99deea99
--- /dev/null
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/IFlowableModelService.java
@@ -0,0 +1,96 @@
+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
deleted file mode 100644
index 01ff72bc..00000000
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/ISysDeployFormService.java
+++ /dev/null
@@ -1,70 +0,0 @@
-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
deleted file mode 100644
index 4f230788..00000000
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/ISysExpressionService.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package com.yanzhu.flowable.service;
-
-import com.yanzhu.flowable.domain.SysExpression;
-
-import java.util.List;
-
-/**
- * 流程达式Service接口
- *
- * @author yanZhu
- * @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
deleted file mode 100644
index 98a844ad..00000000
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/ISysFormService.java
+++ /dev/null
@@ -1,61 +0,0 @@
-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/ISysTaskFormService.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/ISysTaskFormService.java
deleted file mode 100644
index c269e24b..00000000
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/ISysTaskFormService.java
+++ /dev/null
@@ -1,62 +0,0 @@
-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/FlowBusinessKeyServiceImpl.java b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowBusinessKeyServiceImpl.java
index f5150cbb..d826912a 100644
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowBusinessKeyServiceImpl.java
+++ b/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowBusinessKeyServiceImpl.java
@@ -1,7 +1,7 @@
package com.yanzhu.flowable.service.impl;
import com.yanzhu.common.core.text.Convert;
-import com.yanzhu.flowable.domain.FlowTaskEntity;
+import com.yanzhu.flowable.domain.my.FlowTaskEntity;
import com.yanzhu.flowable.mapper.FlowBusinessKeyMapper;
import com.yanzhu.flowable.service.IFlowBusinessKeyService;
import lombok.extern.slf4j.Slf4j;
@@ -25,6 +25,7 @@ public class FlowBusinessKeyServiceImpl implements IFlowBusinessKeyService {
@Resource
private FlowBusinessKeyMapper flowBusinessKeyMapper;
+
/**
* 根据条件查询所有流任务
* @param flowTaskEntity
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
deleted file mode 100644
index 0d9f656f..00000000
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowDefinitionServiceImpl.java
+++ /dev/null
@@ -1,279 +0,0 @@
-package com.yanzhu.flowable.service.impl;
-
-import com.github.pagehelper.PageHelper;
-import com.github.pagehelper.PageInfo;
-import com.yanzhu.common.core.constant.HttpStatus;
-import com.yanzhu.common.core.constant.SecurityConstants;
-import com.yanzhu.common.core.domain.R;
-import com.yanzhu.common.core.enums.FlowableEnums;
-import com.yanzhu.common.core.exception.ServiceException;
-import com.yanzhu.common.core.text.Convert;
-import com.yanzhu.common.core.utils.StringUtils;
-import com.yanzhu.common.core.web.domain.AjaxResult;
-import com.yanzhu.common.core.web.page.TableDataInfo;
-import com.yanzhu.common.redis.service.RedisService;
-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.FlowProcDefDto;
-import com.yanzhu.flowable.domain.SysExpression;
-import com.yanzhu.flowable.domain.vo.FlowDeptVo;
-import com.yanzhu.flowable.domain.vo.FlowQueryVo;
-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.RemoteFlowService;
-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.engine.runtime.ProcessInstance;
-import org.flowable.image.impl.DefaultProcessDiagramGenerator;
-import org.flowable.task.api.Task;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import javax.annotation.Resource;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
-import java.util.*;
-
-/**
- * 流程定义
- *
- * @author Tony
- * @date 2021-04-03
- */
-@Service
-@Slf4j
-public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFlowDefinitionService {
-
- @Autowired
- private RedisService redisService;
-
- @Resource
- private FlowDeployMapper flowDeployMapper;
-
- @Autowired
- private RemoteFlowService remoteFlowService;
-
- @Resource
- private ISysDeployFormService sysDeployFormService;
-
- 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;
- }
-
-
- /**
- * 流程定义列表
- *
- * @param flowQueryVo 流程查询
- * @return 流程定义分页列表数据
- */
- @Override
- public TableDataInfo list(FlowQueryVo flowQueryVo) {
- TableDataInfo rspData = new TableDataInfo();
- PageHelper.startPage(flowQueryVo.getPageNum(), flowQueryVo.getPageSize());
- List list = flowDeployMapper.selectDeployList(flowQueryVo);
- rspData.setCode(HttpStatus.SUCCESS);
- rspData.setMsg("查询成功");
- rspData.setRows(list);
- rspData.setTotal(new PageInfo(list).getTotal());
- return rspData;
- }
-
-
- /**
- * 导入流程文件
- *
- * 当每个key的流程第一次部署时,指定版本为1。对其后所有使用相同key的流程定义,
- * 部署时版本会在该key当前已部署的最高版本号基础上加1。key参数用于区分流程定义
- * @param name 流程名称
- * @param category 流程类型
- * @param prtype 流程定义类型
- * @param OwnerDeptId 流程单位
- * @param OwnerProjectId 流程项目
- * @param in 流程文件流
- */
- @Override
- @Transactional
- public void importFile(String name, String category, String prtype, String OwnerDeptId, String OwnerProjectId, InputStream in) {
- if(SecurityUtils.isAdmin(SecurityUtils.getUserId())){
- throw new ServiceException("请选择项目后导入流程文件...");
- }
- 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);
- /**新增流程单位关系**/
- FlowDeptVo flowDeptVo = new FlowDeptVo();
- flowDeptVo.setProcdefId(definition.getId());
- //超管不能导入流程文件
- if(SecurityUtils.isGSAdmin()){
- if(StringUtils.isNotEmpty(OwnerDeptId)){
- // OwnerDeptId转换Long失败...默认返回null
- flowDeptVo.setDeptId(Convert.toLong(OwnerDeptId));
- }
- if(StringUtils.isNotEmpty(OwnerDeptId)){
- // OwnerDeptId转换Long失败...默认返回null
- flowDeptVo.setProjId(Convert.toLong(OwnerProjectId));
- }
- }else{
- // 从用户信息中获取项目单位信息...
- flowDeptVo.setPrtype(prtype);
- flowDeptVo.setProjId(SecurityUtils.getLoginUser().getProjectId());
- flowDeptVo.setDeptId(SecurityUtils.getLoginUser().getProjectDeptId());
- }
- if(flowDeptVo.getDeptId()!=null){
- flowDeployMapper.insertActReProcdefDept(flowDeptVo);
- }
- }
-
- /**
- * 读取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 applyInfos 流程表单
- * @return
- */
- @Override
- public AjaxResult startProcessInstanceById(String procDefId, Map applyInfos) {
- try {
- /**保存流程表单**/
- Map procDefData = redisService.getCacheObject(FlowableEnums.FLOW_KEY_CACHE+procDefId);
- R res;
- if(StringUtils.isNotNull(procDefData)){
- String procType = Convert.toStr(procDefData.get("TYPE_"));
- if(StringUtils.isNotNull(procType)){
- if(Objects.equals(procType,FlowableEnums.SUB_DEPTS.getCode())){
- res = remoteFlowService.addSubdeptsEntity(applyInfos, SecurityConstants.INNER);
- }else if(Objects.equals(procType,FlowableEnums.SUB_DEPTS.getCode())){
- res = remoteFlowService.addSubdeptsGroupEntity(applyInfos, SecurityConstants.INNER);
- }else if(Objects.equals(procType,FlowableEnums.SUB_DEPTS.getCode())){
- res = remoteFlowService.addSubdeptsUsersEntity(applyInfos, SecurityConstants.INNER);
- }else{
- return AjaxResult.error("审批流程配置异常,请联系管理员配置");
- }
- }else{
- return AjaxResult.error("审批流程配置异常,请联系管理员配置");
- }
- }else{
- return AjaxResult.error("未配置审批流程信息,请联系管理员配置");
- }
- if(StringUtils.isNotNull(res.getData())){
- Map variables = new HashMap<>();
- ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(procDefId)
- .latestVersion().singleResult();
- if (Objects.nonNull(processDefinition) && processDefinition.isSuspended()) {
- return AjaxResult.error("流程已被挂起,请联系管理员激活流程");
- }
- SysUser sysUser = SecurityUtils.getLoginUser().getSysUser();
- String userId = Convert.toStr(sysUser.getUserId());
- // 设置流程发起人Id到流程中
- identityService.setAuthenticatedUserId(userId);
- variables.put(ProcessConstants.PROCESS_INITIATOR, userId);
- variables.put("businessKey", res.getData());
- ProcessInstance processInstance;
- processInstance = runtimeService.startProcessInstanceById(procDefId, Convert.toStr(res.getData()),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(), Convert.toStr(userId));
- taskService.complete(task.getId(), variables);
- }
- return AjaxResult.success("流程启动成功");
- }else{
- return AjaxResult.error("流程表单保存失败");
- }
- } 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
deleted file mode 100644
index 4facc05d..00000000
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowInstanceServiceImpl.java
+++ /dev/null
@@ -1,117 +0,0 @@
-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.getUserId();
- 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
deleted file mode 100644
index 50208812..00000000
--- a/yanzhu-modules/yanzhu-flowable/src/main/java/com/yanzhu/flowable/service/impl/FlowTaskServiceImpl.java
+++ /dev/null
@@ -1,1307 +0,0 @@
-package com.yanzhu.flowable.service.impl;
-
-import com.alibaba.fastjson2.JSON;
-import com.alibaba.fastjson2.JSONObject;
-import com.alibaba.fastjson2.TypeReference;
-import com.yanzhu.common.core.constant.SecurityConstants;
-import com.yanzhu.common.core.domain.R;
-import com.yanzhu.common.core.enums.FlowableEnums;
-import com.yanzhu.common.core.exception.CustomException;
-import com.yanzhu.common.core.text.Convert;
-import com.yanzhu.common.core.utils.StringUtils;
-import com.yanzhu.common.core.web.domain.AjaxResult;
-import com.yanzhu.common.core.web.page.TableDataInfo;
-import com.yanzhu.common.redis.service.RedisService;
-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.*;
-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.flow.ModelUtils;
-import com.yanzhu.flowable.service.IFlowTaskService;
-import com.yanzhu.flowable.service.ISysDeployFormService;
-import com.yanzhu.flowable.service.ISysFormService;
-import com.yanzhu.system.api.RemoteFlowService;
-import com.yanzhu.system.api.RemoteRoleService;
-import com.yanzhu.system.api.RemoteUserService;
-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.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.common.engine.impl.identity.Authentication;
-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.beans.factory.annotation.Autowired;
-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 {
-
- @Autowired
- private RedisService redisService;
-
- @Resource
- private ISysFormService sysFormService;
-
- @Autowired
- private RemoteFlowService remoteFlowService;
-
- @Resource
- private RemoteUserService remoteUserService;
-
- @Resource
- private RemoteRoleService remoteRoleService;
-
- @Resource
- private ISysDeployFormService sysInstanceFormService;
-
- /**
- * 完成任务
- *
- * @param taskVo 请求实体参数
- */
- @Transactional(rollbackFor = Exception.class)
- @Override
- public AjaxResult complete(FlowTaskVo taskVo) {
- Task task = taskService.createTaskQuery().taskId(taskVo.getTaskId()).singleResult();
- /**表单不为空时,重新修改表单**/
- if(StringUtils.isNotNull(taskVo.getApplyInfos())){
- Map procDefData = redisService.getCacheObject(FlowableEnums.FLOW_KEY_CACHE+task.getProcessDefinitionId());
- if(StringUtils.isNotNull(procDefData)){
- String procType = Convert.toStr(procDefData.get("TYPE_"));
- if(StringUtils.isNotNull(procType)){
- if(Objects.equals(procType,FlowableEnums.SUB_DEPTS.getCode())){
- remoteFlowService.addSubdeptsEntity(taskVo.getApplyInfos(), SecurityConstants.INNER);
- }else if(Objects.equals(procType,FlowableEnums.SUB_DEPTS.getCode())){
- remoteFlowService.addSubdeptsGroupEntity(taskVo.getApplyInfos(), SecurityConstants.INNER);
- }else if(Objects.equals(procType,FlowableEnums.SUB_DEPTS.getCode())){
- remoteFlowService.addSubdeptsUsersEntity(taskVo.getApplyInfos(), SecurityConstants.INNER);
- }else{
- return AjaxResult.error("审批流程配置异常,请联系管理员配置");
- }
- }else{
- return AjaxResult.error("审批流程配置异常,请联系管理员配置");
- }
- }else{
- return AjaxResult.error("未配置审批流程信息,请联系管理员配置");
- }
- }
- 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());
- } else {
- Long userId = SecurityUtils.getUserId();
- taskService.addComment(taskVo.getTaskId(), taskVo.getInstanceId(), FlowComment.NORMAL.getType(), taskVo.getComment());
- taskService.setAssignee(taskVo.getTaskId(), Convert.toStr(userId));
- taskService.complete(taskVo.getTaskId());
- }
- return AjaxResult.success();
- }
-
- /**
- * 驳回任务
- *
- * @param flowTaskVo
- */
- @Override
- public void taskReject(FlowTaskVo flowTaskVo) {
- if (taskService.createTaskQuery().taskId(flowTaskVo.getTaskId()).singleResult().isSuspended()) {
- throw new CustomException("任务处于挂起状态!");
- }
- // 当前任务 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 CustomException("当前节点为初始任务节点,不能驳回");
- }
- // 获取活动 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 CustomException("任务出现多对多情况,无法撤回");
- }
-
- // 循环获取那些需要被撤回的节点的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 CustomException("未找到流程实例,流程可能已发生变化");
- } catch (FlowableException e) {
- throw new CustomException("无法取消或开始活动");
- }
-
- }
-
- /**
- * 退回任务
- *
- * @param flowTaskVo 请求实体参数
- */
- @Transactional(rollbackFor = Exception.class)
- @Override
- public void taskReturn(FlowTaskVo flowTaskVo) {
- if (taskService.createTaskQuery().taskId(flowTaskVo.getTaskId()).singleResult().isSuspended()) {
- throw new CustomException("任务处于挂起状态");
- }
- // 当前任务 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 CustomException("当前节点相对于目标节点,不属于串行关系,无法回退");
- }
-
-
- // 获取所有正常进行的任务节点 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 CustomException("未找到流程实例,流程可能已发生变化");
- } catch (FlowableException e) {
- throw new CustomException("无法取消或开始活动");
- }
- }
-
-
- /**
- * 获取所有可回退的节点
- *
- * @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.addComment(flowTaskVo.getTaskId(), flowTaskVo.getInstanceId(), FlowComment.DELEGATE.getType(), flowTaskVo.getComment());
- 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.addComment(flowTaskVo.getTaskId(), flowTaskVo.getInstanceId(), FlowComment.ASSIGN.getType(), flowTaskVo.getComment());
- // 直接转派就可以覆盖掉之前的
- 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 AjaxResult myProcess(FlowQueryVo queryVo) {
- TableDataInfo page = new TableDataInfo();
- Long userId = SecurityUtils.getUserId();
- HistoricProcessInstanceQuery historicProcessInstanceQuery;
- //超管查询所有数据据
- if(SecurityUtils.isAdmin(userId)){
- historicProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery()
- .orderByProcessInstanceStartTime()
- .desc();
- }else{
- historicProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery()
- .startedBy(userId.toString())
- .orderByProcessInstanceStartTime()
- .desc();
- }
- List historicProcessInstances = historicProcessInstanceQuery.listPage(queryVo.getPageSize() * (queryVo.getPageNum() - 1), queryVo.getPageSize());
- page.setTotal(historicProcessInstanceQuery.count());
- 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())) {
- // 当前任务节点办理人信息
- R userResult = remoteUserService.getSysUserInfo(Long.parseLong(taskList.get(0).getAssignee()), SecurityConstants.INNER);
- if (Objects.nonNull(userResult)) {
- SysUser sysUser = userResult.getData();
- 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())) {
- // 当前任务节点办理人信息
- R userResult = remoteUserService.getSysUserInfo(Long.parseLong(historicTaskInstance.get(0).getAssignee()), SecurityConstants.INNER);
- if (Objects.nonNull(userResult)) {
- SysUser sysUser = userResult.getData();
- flowTask.setAssigneeId(sysUser.getUserId());
- flowTask.setAssigneeName(sysUser.getNickName());
- flowTask.setAssigneeDeptName(Objects.nonNull(sysUser.getDept()) ? sysUser.getDept().getDeptName() : "");
- }
- }
- }
- flowList.add(flowTask);
- }
- page.setRows(flowList);
- return AjaxResult.success(page);
- }
-
- /**
- * 取消申请
- * 目前实现方式: 直接将当前流程变更为已完成
- *
- * @param flowTaskVo
- * @return
- */
- @Override
- @Transactional
- public AjaxResult stopProcess(FlowTaskVo flowTaskVo) {
- List task = taskService.createTaskQuery().processInstanceId(flowTaskVo.getInstanceId()).list();
- if (CollectionUtils.isEmpty(task)) {
- throw new CustomException("流程未启动或已执行完成,取消申请失败");
- }
- // 获取当前流程实例
- 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)) {
- String userIdStr = Convert.toStr(SecurityUtils.getUserId());
- if(StringUtils.isNotEmpty(userIdStr)){
- Authentication.setAuthenticatedUserId(userIdStr);
- taskService.addComment(task.get(0).getId(), processInstance.getProcessInstanceId(), FlowComment.STOP.getType(),
- StringUtils.isBlank(flowTaskVo.getComment()) ? "取消申请" : flowTaskVo.getComment());
- // 设置流程经办人为当前登录人员
- taskService.setAssignee(task.get(0).getId(), userIdStr);
- // 获取当前流程最后一个节点
- 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();
- }
- }
- }
- return AjaxResult.error();
- }
-
- /**
- * 撤回流程 目前存在错误
- *
- * @param flowTaskVo
- * @return
- */
- @Override
- @Transactional
- public AjaxResult revokeProcess(FlowTaskVo flowTaskVo) {
- String procInsId = flowTaskVo.getInstanceId();
- String taskId = flowTaskVo.getTaskId();
- // 校验流程是否结束
- ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
- .processInstanceId(procInsId)
- .active()
- .singleResult();
- if(Objects.isNull(processInstance)) {
- throw new RuntimeException("流程已结束或已挂起,无法执行撤回操作");
- }
- // 获取待撤回任务实例
- HistoricTaskInstance currTaskIns = historyService.createHistoricTaskInstanceQuery()
- .taskId(taskId)
- .taskAssignee(flowTaskVo.getUserId())
- .singleResult();
- if (Objects.isNull(currTaskIns)) {
- throw new RuntimeException("当前任务不存在,无法执行撤回操作");
- }
- // 获取 bpmn 模型
- BpmnModel bpmnModel = repositoryService.getBpmnModel(currTaskIns.getProcessDefinitionId());
- UserTask currUserTask = ModelUtils.getUserTaskByKey(bpmnModel, currTaskIns.getTaskDefinitionKey());
- // 查找下一级用户任务列表
- List nextUserTaskList = ModelUtils.findNextUserTasks(currUserTask);
- List nextUserTaskKeys = nextUserTaskList.stream().map(UserTask::getId).collect(Collectors.toList());
-
- // 获取当前节点之后已完成的流程历史节点
- List finishedTaskInsList = historyService.createHistoricTaskInstanceQuery()
- .processInstanceId(procInsId)
- .taskCreatedAfter(currTaskIns.getEndTime())
- .finished()
- .list();
- for (HistoricTaskInstance finishedTaskInstance : finishedTaskInsList) {
- // 检查已完成流程历史节点是否存在下一级中
- if (StringUtils.contains(nextUserTaskKeys, finishedTaskInstance.getTaskDefinitionKey())) {
- throw new RuntimeException("下一流程已处理,无法执行撤回操作");
- }
- }
- // 获取所有激活的任务节点,找到需要撤回的任务
- List activateTaskList = taskService.createTaskQuery().processInstanceId(procInsId).list();
- List revokeExecutionIds = new ArrayList<>();
- for (Task task : activateTaskList) {
- // 检查激活的任务节点是否存在下一级中,如果存在,则加入到需要撤回的节点
- if (StringUtils.contains(nextUserTaskKeys, task.getTaskDefinitionKey())) {
- // 添加撤回审批信息
- taskService.setAssignee(task.getId(), flowTaskVo.getUserId());
- taskService.addComment(task.getId(), task.getProcessInstanceId(), FlowComment.REVOKE.getType(), flowTaskVo.getAssignee() + "撤回流程审批");
- revokeExecutionIds.add(task.getExecutionId());
- }
- }
- try {
- runtimeService.createChangeActivityStateBuilder()
- .processInstanceId(procInsId)
- .moveExecutionsToSingleActivityId(revokeExecutionIds, currTaskIns.getTaskDefinitionKey()).changeState();
- } catch (FlowableObjectNotFoundException e) {
- throw new RuntimeException("未找到流程实例,流程可能已发生变化");
- } catch (FlowableException e) {
- throw new RuntimeException("执行撤回操作失败");
- }
- return AjaxResult.success();
- }
-
- /**
- * 代办任务列表
- *
- * @param queryVo 请求参数
- * @return
- */
- @Override
- public AjaxResult todoList(FlowQueryVo queryVo) {
- TableDataInfo page = new TableDataInfo();
- // 只查看自己的数据
- 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();
-
- page.setTotal(taskQuery.count());
- 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();
- R userResult = remoteUserService.getSysUserInfo(Long.parseLong(historicProcessInstance.getStartUserId()), SecurityConstants.INNER);
- if(Objects.nonNull(userResult)){
- SysUser startUser = userResult.getData();
- flowTask.setStartUserId(startUser.getUserId().toString());
- flowTask.setStartUserName(startUser.getNickName());
- flowTask.setStartDeptName(Objects.nonNull(startUser.getDept()) ? startUser.getDept().getDeptName() : "");
- flowList.add(flowTask);
- }
- }
-
- page.setRows(flowList);
- return AjaxResult.success(page);
- }
-
-
- /**
- * 已办任务列表
- *
- * @param queryVo 请求参数
- * @return
- */
- @Override
- public AjaxResult finishedList(FlowQueryVo queryVo) {
- TableDataInfo page = new TableDataInfo();
- Long userId = SecurityUtils.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();
- R userResult = remoteUserService.getSysUserInfo(Long.parseLong(historicProcessInstance.getStartUserId()), SecurityConstants.INNER);
- SysUser startUser = userResult.getData();
- flowTask.setStartUserId(startUser.getNickName());
- flowTask.setStartUserName(startUser.getNickName());
- flowTask.setStartDeptName(startUser.getDept().getDeptName());
- hisTaskList.add(flowTask);
- }
- page.setTotal(taskInstanceQuery.count());
- page.setRows(hisTaskList);
- return AjaxResult.success(page);
- }
-
- private static Predicate distinctByKey(Function super T, ?> keyExtractor) {
- Set