xm
2024-06-14 722af26bc6fec32bb289b1df51a9016a4935610f
提交 | 用户 | 时间
722af2 1 package com.dl.web.controller.workflow;
X 2
3 import cn.dev33.satoken.annotation.SaCheckPermission;
4 import com.dl.common.annotation.Log;
5 import com.dl.common.core.controller.BaseController;
6 import com.dl.common.core.domain.PageQuery;
7 import com.dl.common.core.domain.R;
8 import com.dl.common.core.page.TableDataInfo;
9 import com.dl.common.enums.BusinessType;
10 import com.dl.common.utils.JsonUtils;
11 import com.dl.flowable.core.domain.ProcessQuery;
12 import com.dl.workflow.domain.vo.WfDeployVo;
13 import com.dl.workflow.domain.vo.WfFormVo;
14 import com.dl.workflow.service.IWfDeployFormService;
15 import com.dl.workflow.service.IWfDeployService;
16 import lombok.RequiredArgsConstructor;
17 import lombok.extern.slf4j.Slf4j;
18 import org.springframework.web.bind.annotation.*;
19
20 import javax.validation.constraints.NotEmpty;
21 import java.util.Arrays;
22 import java.util.Map;
23 import java.util.Objects;
24
25 /**
26  * 流程部署
27  *
28  * @author KonBAI
29  * @createTime 2022/3/24 20:57
30  */
31 @Slf4j
32 @RequiredArgsConstructor
33 @RestController
34 @RequestMapping("/workflow/deploy")
35 public class WfDeployController extends BaseController {
36
37     private final IWfDeployService deployService;
38     private final IWfDeployFormService deployFormService;
39
40     /**
41      * 查询流程部署列表
42      */
43     @SaCheckPermission("workflow:deploy:list")
44     @GetMapping("/list")
45     public TableDataInfo<WfDeployVo> list(ProcessQuery processQuery, PageQuery pageQuery) {
46         return deployService.queryPageList(processQuery, pageQuery);
47     }
48
49     /**
50      * 查询流程部署版本列表
51      */
52     @SaCheckPermission("workflow:deploy:list")
53     @GetMapping("/publishList")
54     public TableDataInfo<WfDeployVo> publishList(@RequestParam String processKey, PageQuery pageQuery) {
55         return deployService.queryPublishList(processKey, pageQuery);
56     }
57
58     /**
59      * 激活或挂起流程
60      *
61      * @param state 状态(active:激活 suspended:挂起)
62      * @param definitionId 流程定义ID
63      */
64     @SaCheckPermission("workflow:deploy:state")
65     @PutMapping(value = "/changeState")
66     public R<Void> changeState(@RequestParam String state, @RequestParam String definitionId) {
67         deployService.updateState(definitionId, state);
68         return R.ok();
69     }
70
71     /**
72      * 读取xml文件
73      * @param definitionId 流程定义ID
74      * @return
75      */
76     @SaCheckPermission("workflow:deploy:query")
77     @GetMapping("/bpmnXml/{definitionId}")
78     public R<String> getBpmnXml(@PathVariable(value = "definitionId") String definitionId) {
79         return R.ok(null, deployService.queryBpmnXmlById(definitionId));
80     }
81
82     /**
83      * 删除流程模型
84      * @param deployIds 流程部署ids
85      */
86     @SaCheckPermission("workflow:deploy:remove")
87     @Log(title = "删除流程部署", businessType = BusinessType.DELETE)
88     @DeleteMapping("/{deployIds}")
89     public R<String> remove(@NotEmpty(message = "主键不能为空") @PathVariable String[] deployIds) {
90         deployService.deleteByIds(Arrays.asList(deployIds));
91         return R.ok();
92     }
93
94     /**
95      * 查询流程部署关联表单信息
96      *
97      * @param deployId 流程部署id
98      */
99     @GetMapping("/form/{deployId}")
100     public R<?> start(@PathVariable(value = "deployId") String deployId) {
101         WfFormVo formVo = deployFormService.selectDeployFormByDeployId(deployId);
102         if (Objects.isNull(formVo)) {
103             return R.fail("请先配置流程表单");
104         }
105         return R.ok(JsonUtils.parseObject(formVo.getContent(), Map.class));
106     }
107 }