add -- 添加流程模型和部署管理模块
This commit is contained in:
@@ -1,19 +1,22 @@
|
||||
package com.ruoyi.web.controller.workflow;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.utils.JsonUtils;
|
||||
import com.ruoyi.workflow.domain.bo.WfProcessBo;
|
||||
import com.ruoyi.workflow.domain.vo.WfDeployVo;
|
||||
import com.ruoyi.workflow.domain.vo.WfFormVo;
|
||||
import com.ruoyi.workflow.service.IWfDeployFormService;
|
||||
import com.ruoyi.workflow.service.IWfDeployService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -29,8 +32,50 @@ import java.util.Objects;
|
||||
@RequestMapping("/workflow/deploy")
|
||||
public class WfDeployController extends BaseController {
|
||||
|
||||
private final IWfDeployService deployService;
|
||||
private final IWfDeployFormService deployFormService;
|
||||
|
||||
/**
|
||||
* 查询流程部署列表
|
||||
*/
|
||||
@SaCheckPermission("workflow:deploy:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<WfDeployVo> list(WfProcessBo processBo, PageQuery pageQuery) {
|
||||
return deployService.queryPageList(processBo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询流程部署版本列表
|
||||
*/
|
||||
@SaCheckPermission("workflow:deploy:list")
|
||||
@GetMapping("/publishList")
|
||||
public TableDataInfo<WfDeployVo> publishList(@ApiParam(value = "流程定义Key", required = true) @RequestParam String processKey,
|
||||
PageQuery pageQuery) {
|
||||
return deployService.queryPublishList(processKey, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param state
|
||||
* @param definitionId
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "激活或挂起流程")
|
||||
@SaCheckPermission("workflow:deploy:state")
|
||||
@PutMapping(value = "/changeState")
|
||||
public R<Void> changeState(@ApiParam(value = "状态(active:激活 suspended:挂起)", required = true) @RequestParam String state,
|
||||
@ApiParam(value = "流程定义ID", required = true) @RequestParam String definitionId) {
|
||||
deployService.updateState(definitionId, state);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "读取xml文件")
|
||||
@SaCheckPermission("workflow:deploy:query")
|
||||
@GetMapping("/bpmnXml/{definitionId}")
|
||||
public R<String> getBpmnXml(@ApiParam(value = "流程定义ID") @PathVariable(value = "definitionId") String definitionId) {
|
||||
return R.ok(null, deployService.queryBpmnXmlById(definitionId));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param deployId
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.ruoyi.web.controller.workflow;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.annotation.RepeatSubmit;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.workflow.domain.bo.WfModelBo;
|
||||
import com.ruoyi.workflow.domain.vo.WfModelVo;
|
||||
import com.ruoyi.workflow.service.IWfModelService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author KonBAI
|
||||
* @createTime 2022/6/21 9:09
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "工作流流程模型管理")
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/workflow/model")
|
||||
public class WfModelController extends BaseController {
|
||||
|
||||
private final IWfModelService modelService;
|
||||
|
||||
@ApiOperation(value = "查询流程模型列表")
|
||||
@SaCheckPermission("workflow:model:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<WfModelVo> list(WfModelBo modelBo, PageQuery pageQuery) {
|
||||
return modelService.list(modelBo, pageQuery);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询流程模型列表")
|
||||
@SaCheckPermission("workflow:model:list")
|
||||
@GetMapping("/historyList")
|
||||
public TableDataInfo<WfModelVo> historyList(WfModelBo modelBo, PageQuery pageQuery) {
|
||||
return modelService.historyList(modelBo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取流程模型详细信息
|
||||
*/
|
||||
@ApiOperation(value = "查询流程模型详情信息")
|
||||
@SaCheckPermission("workflow:model:query")
|
||||
@GetMapping(value = "/{modelId}")
|
||||
public R<WfModelVo> getInfo(@ApiParam("主键") @NotNull(message = "主键不能为空") @PathVariable("modelId") String modelId) {
|
||||
return R.ok(modelService.getModel(modelId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取流程表单详细信息
|
||||
*/
|
||||
@SaCheckPermission("workflow:model:query")
|
||||
@GetMapping(value = "/bpmnXml/{modelId}")
|
||||
public R<String> getBpmnXml(@ApiParam("主键") @NotNull(message = "主键不能为空") @PathVariable("modelId") String modelId) {
|
||||
return R.ok("操作成功", modelService.queryBpmnXmlById(modelId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存流程模型
|
||||
*/
|
||||
@ApiOperation("保存流程模型")
|
||||
@SaCheckPermission("workflow:model:save")
|
||||
@Log(title = "保存流程模型", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<String> save(@RequestBody WfModelBo modelBo) {
|
||||
modelService.saveModel(modelBo);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@ApiOperation("设为最新流程模型")
|
||||
@SaCheckPermission("workflow:model:save")
|
||||
@Log(title = "设为最新流程模型", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/latest")
|
||||
public R<?> latest(@RequestParam String modelId) {
|
||||
modelService.latestModel(modelId);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除流程模型
|
||||
*/
|
||||
@ApiOperation("删除流程模型")
|
||||
@SaCheckPermission("workflow:model:remove")
|
||||
@Log(title = "删除流程模型", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{modelIds}")
|
||||
public R<String> remove(@ApiParam("主键串") @NotEmpty(message = "主键不能为空") @PathVariable String[] modelIds) {
|
||||
modelService.deleteByIds(Arrays.asList(modelIds));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@ApiOperation("部署流程模型")
|
||||
@SaCheckPermission("workflow:model:deploy")
|
||||
@Log(title = "部署流程模型", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/deploy")
|
||||
public R<Void> deployModel(@RequestParam String modelId) {
|
||||
modelService.deployModel(modelId);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,6 +8,8 @@ package com.ruoyi.flowable.common.constant;
|
||||
*/
|
||||
public class ProcessConstants {
|
||||
|
||||
public static final String SUFFIX = ".bpmn";
|
||||
|
||||
/**
|
||||
* 动态数据
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.ruoyi.flowable.common.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author KonBAI
|
||||
* @createTime 2022/6/28 9:51
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum FormType {
|
||||
|
||||
/**
|
||||
* 流程表单
|
||||
*/
|
||||
PROCESS(0),
|
||||
|
||||
/**
|
||||
* 外置表单
|
||||
*/
|
||||
EXTERNAL(1),
|
||||
|
||||
/**
|
||||
* 节点独立表单
|
||||
*/
|
||||
INDEPENDENT(2);
|
||||
|
||||
/**
|
||||
* 表单类型
|
||||
*/
|
||||
private final Integer type;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.ruoyi.flowable.utils;
|
||||
|
||||
import org.flowable.bpmn.converter.BpmnXMLConverter;
|
||||
import org.flowable.bpmn.model.BpmnModel;
|
||||
import org.flowable.bpmn.model.FlowElement;
|
||||
import org.flowable.bpmn.model.Process;
|
||||
import org.flowable.bpmn.model.StartEvent;
|
||||
import org.flowable.common.engine.impl.util.io.StringStreamSource;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author KonBAI
|
||||
* @createTime 2022/3/26 19:04
|
||||
*/
|
||||
public class ModelUtils {
|
||||
|
||||
private static final BpmnXMLConverter bpmnXMLConverter = new BpmnXMLConverter();
|
||||
|
||||
/**
|
||||
* xml转bpmnModel对象
|
||||
*
|
||||
* @param xml xml
|
||||
* @return bpmnModel对象
|
||||
*/
|
||||
public static BpmnModel getBpmnModel(String xml) {
|
||||
return bpmnXMLConverter.convertToBpmnModel(new StringStreamSource(xml), false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取开始节点
|
||||
*
|
||||
* @param model bpmnModel对象
|
||||
* @return 开始节点(未找到开始节点,返回null)
|
||||
*/
|
||||
public static StartEvent getStartEvent(BpmnModel model) {
|
||||
Process process = model.getMainProcess();
|
||||
Collection<FlowElement> elements = process.getFlowElements();
|
||||
return (StartEvent) elements.stream()
|
||||
.filter(flowElement -> flowElement instanceof StartEvent)
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,5 @@
|
||||
package com.ruoyi.workflow.domain;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
@@ -22,13 +19,25 @@ public class WfDeployForm {
|
||||
/**
|
||||
* 流程定义主键
|
||||
*/
|
||||
@TableId(type = IdType.INPUT)
|
||||
@ExcelProperty(value = "流程定义主键")
|
||||
private String deployId;
|
||||
|
||||
/**
|
||||
* 表单主键
|
||||
*/
|
||||
@ExcelProperty(value = "表单主键")
|
||||
private Long formId;
|
||||
|
||||
/**
|
||||
* 节点Key
|
||||
*/
|
||||
private String nodeKey;
|
||||
|
||||
/**
|
||||
* 节点名称
|
||||
*/
|
||||
private String nodeName;
|
||||
|
||||
/**
|
||||
* 表单内容
|
||||
*/
|
||||
private String content;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.ruoyi.workflow.domain.bo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author KonBAI
|
||||
* @createTime 2022/6/21 9:16
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("流程模型对象")
|
||||
public class WfModelBo {
|
||||
|
||||
@ApiModelProperty(value = "模型主键")
|
||||
private String modelId;
|
||||
|
||||
@ApiModelProperty(value = "模型名称", required = true)
|
||||
@NotNull(message = "模型名称不能为空")
|
||||
private String modelName;
|
||||
|
||||
@ApiModelProperty(value = "模型Key", required = true)
|
||||
@NotNull(message = "模型Key不能为空")
|
||||
private String modelKey;
|
||||
|
||||
@ApiModelProperty(value = "流程分类", required = true)
|
||||
@NotBlank(message = "流程分类不能为空")
|
||||
private String category;
|
||||
|
||||
@ApiModelProperty(value = "描述")
|
||||
private String description;
|
||||
|
||||
@ApiModelProperty(value = "表单类型", required = true)
|
||||
@NotBlank(message = "表单类型不能为空")
|
||||
private Integer formType;
|
||||
|
||||
@ApiModelProperty(value = "表单主键", required = true)
|
||||
@NotBlank(message = "表单不能为空")
|
||||
private Long formId;
|
||||
|
||||
@ApiModelProperty(value = "流程xml", required = true)
|
||||
@NotBlank(message = "流程xml不能为空")
|
||||
private String bpmnXml;
|
||||
|
||||
@ApiModelProperty(value = "是否保存为新版本", required = true)
|
||||
private Boolean newVersion;
|
||||
}
|
||||
@@ -14,6 +14,15 @@ import lombok.Data;
|
||||
@ApiModel("流程业务对象")
|
||||
public class WfProcessBo {
|
||||
|
||||
@ApiModelProperty("流程标识")
|
||||
private String processKey;
|
||||
|
||||
@ApiModelProperty("流程名称")
|
||||
private String processName;
|
||||
|
||||
@ApiModelProperty("流程分类")
|
||||
private String category;
|
||||
|
||||
@ApiModelProperty("状态")
|
||||
private String state;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.ruoyi.workflow.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author KonBAI
|
||||
* @createTime 2022/6/21 9:16
|
||||
*/
|
||||
@Data
|
||||
public class WfMetaInfoDto {
|
||||
|
||||
/**
|
||||
* 流程描述
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* 表单类型
|
||||
*/
|
||||
private Integer formType;
|
||||
/**
|
||||
* 表单编号
|
||||
*/
|
||||
private Long formId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.ruoyi.workflow.domain.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 流程部署视图对象
|
||||
*
|
||||
* @author KonBAI
|
||||
* @date 2022-06-30
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("流程部署视图对象")
|
||||
@ExcelIgnoreUnannotated
|
||||
public class WfDeployVo {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 流程定义ID
|
||||
*/
|
||||
@ExcelProperty(value = "流程定义ID")
|
||||
@ApiModelProperty("流程定义ID")
|
||||
private String definitionId;
|
||||
|
||||
/**
|
||||
* 流程名称
|
||||
*/
|
||||
@ExcelProperty(value = "流程名称")
|
||||
@ApiModelProperty("流程名称")
|
||||
private String processName;
|
||||
|
||||
/**
|
||||
* 流程Key
|
||||
*/
|
||||
@ExcelProperty(value = "流程Key")
|
||||
@ApiModelProperty("流程Key")
|
||||
private String processKey;
|
||||
|
||||
/**
|
||||
* 分类编码
|
||||
*/
|
||||
@ExcelProperty(value = "分类编码")
|
||||
@ApiModelProperty("分类编码")
|
||||
private String category;
|
||||
|
||||
@ApiModelProperty("版本")
|
||||
private Integer version;
|
||||
|
||||
/**
|
||||
* 表单ID
|
||||
*/
|
||||
@ExcelProperty(value = "表单ID")
|
||||
@ApiModelProperty("表单ID")
|
||||
private Long formId;
|
||||
|
||||
/**
|
||||
* 表单名称
|
||||
*/
|
||||
@ExcelProperty(value = "表单名称")
|
||||
@ApiModelProperty("表单名称")
|
||||
private String formName;
|
||||
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
@ExcelProperty(value = "部署ID")
|
||||
@ApiModelProperty("部署ID")
|
||||
private String deploymentId;
|
||||
|
||||
/**
|
||||
* 流程定义状态: 1:激活 , 2:中止
|
||||
*/
|
||||
@ExcelProperty(value = "流程定义状态: 1:激活 , 2:中止")
|
||||
@ApiModelProperty("流程定义状态: 1:激活 , 2:中止")
|
||||
private Boolean suspended;
|
||||
|
||||
/**
|
||||
* 部署时间
|
||||
*/
|
||||
@ExcelProperty(value = "部署时间")
|
||||
@ApiModelProperty("部署时间")
|
||||
private Date deploymentTime;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.ruoyi.workflow.domain.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author KonBAI
|
||||
* @createTime 2022/6/21 9:16
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("流程模型视图对象")
|
||||
@ExcelIgnoreUnannotated
|
||||
public class WfModelVo {
|
||||
|
||||
@ExcelProperty(value = "模型ID")
|
||||
@ApiModelProperty("模型ID")
|
||||
private String modelId;
|
||||
|
||||
@ExcelProperty(value = "模型名称")
|
||||
@ApiModelProperty("模型名称")
|
||||
private String modelName;
|
||||
|
||||
@ExcelProperty(value = "模型Key")
|
||||
@ApiModelProperty("模型Key")
|
||||
private String modelKey;
|
||||
|
||||
@ExcelProperty(value = "分类编码")
|
||||
@ApiModelProperty("分类编码")
|
||||
private String category;
|
||||
|
||||
@ExcelProperty(value = "版本")
|
||||
@ApiModelProperty("版本")
|
||||
private Integer version;
|
||||
|
||||
@ExcelProperty(value = "表单类型")
|
||||
@ApiModelProperty("表单类型")
|
||||
private Integer formType;
|
||||
|
||||
@ExcelProperty(value = "表单ID")
|
||||
@ApiModelProperty("表单ID")
|
||||
private Long formId;
|
||||
|
||||
@ExcelProperty(value = "模型描述")
|
||||
@ApiModelProperty("模型描述")
|
||||
private String description;
|
||||
|
||||
@ExcelProperty(value = "创建时间")
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ExcelProperty(value = "流程xml")
|
||||
@ApiModelProperty("流程xml")
|
||||
private String bpmnXml;
|
||||
|
||||
@ExcelProperty(value = "表单内容")
|
||||
@ApiModelProperty("表单内容")
|
||||
private String content;
|
||||
}
|
||||
@@ -19,6 +19,14 @@ public interface IWfDeployFormService {
|
||||
*/
|
||||
int insertWfDeployForm(WfDeployForm wfDeployForm);
|
||||
|
||||
/**
|
||||
* 保存流程实例关联表单
|
||||
* @param deployId
|
||||
* @param formId
|
||||
* @return
|
||||
*/
|
||||
int saveInternalDeployForm(String deployId, Long formId);
|
||||
|
||||
/**
|
||||
* 查询流程挂着的表单
|
||||
*
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.ruoyi.workflow.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.workflow.domain.bo.WfProcessBo;
|
||||
import com.ruoyi.workflow.domain.vo.WfDeployVo;
|
||||
|
||||
/**
|
||||
* @author KonBAI
|
||||
* @createTime 2022/6/30 9:03
|
||||
*/
|
||||
public interface IWfDeployService {
|
||||
|
||||
TableDataInfo<WfDeployVo> queryPageList(WfProcessBo processBo, PageQuery pageQuery);
|
||||
|
||||
TableDataInfo<WfDeployVo> queryPublishList(String processKey, PageQuery pageQuery);
|
||||
|
||||
void updateState(String definitionId, String stateCode);
|
||||
|
||||
String queryBpmnXmlById(String definitionId);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.ruoyi.workflow.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.workflow.domain.bo.WfModelBo;
|
||||
import com.ruoyi.workflow.domain.vo.WfModelVo;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author KonBAI
|
||||
* @createTime 2022/6/21 9:11
|
||||
*/
|
||||
public interface IWfModelService {
|
||||
|
||||
TableDataInfo<WfModelVo> list(WfModelBo modelBo, PageQuery pageQuery);
|
||||
|
||||
TableDataInfo<WfModelVo> historyList(WfModelBo modelBo, PageQuery pageQuery);
|
||||
|
||||
WfModelVo getModel(String modelId);
|
||||
|
||||
String queryBpmnXmlById(String modelId);
|
||||
|
||||
void saveModel(WfModelBo modelBo);
|
||||
|
||||
void latestModel(String modelId);
|
||||
|
||||
void deleteByIds(Collection<String> ids);
|
||||
|
||||
void deployModel(String modelId);
|
||||
}
|
||||
@@ -46,6 +46,20 @@ public class WfDeployFormServiceImpl implements IWfDeployFormService {
|
||||
return baseMapper.insert(deployForm);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int saveInternalDeployForm(String deployId, Long formId) {
|
||||
WfDeployForm deployForm = new WfDeployForm();
|
||||
deployForm.setDeployId(deployId);
|
||||
deployForm.setFormId(formId);
|
||||
WfForm wfForm = formMapper.selectById(formId);
|
||||
if (ObjectUtil.isNotNull(wfForm)) {
|
||||
deployForm.setContent(wfForm.getContent());
|
||||
}
|
||||
// 新增部署流程和表单关系
|
||||
return baseMapper.insert(deployForm);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询流程挂着的表单
|
||||
*
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
package com.ruoyi.workflow.service.impl;
|
||||
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.workflow.domain.bo.WfProcessBo;
|
||||
import com.ruoyi.workflow.domain.vo.WfDeployVo;
|
||||
import com.ruoyi.workflow.service.IWfDeployService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.flowable.common.engine.impl.db.SuspensionState;
|
||||
import org.flowable.engine.RepositoryService;
|
||||
import org.flowable.engine.repository.Deployment;
|
||||
import org.flowable.engine.repository.ProcessDefinition;
|
||||
import org.flowable.engine.repository.ProcessDefinitionQuery;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author KonBAI
|
||||
* @createTime 2022/6/30 9:04
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class WfDeployServiceImpl implements IWfDeployService {
|
||||
|
||||
private final RepositoryService repositoryService;
|
||||
|
||||
@Override
|
||||
public TableDataInfo<WfDeployVo> queryPageList(WfProcessBo processBo, PageQuery pageQuery) {
|
||||
// 流程定义列表数据查询
|
||||
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery()
|
||||
.latestVersion()
|
||||
.orderByProcessDefinitionKey()
|
||||
.asc();
|
||||
if (StringUtils.isNotBlank(processBo.getProcessKey())) {
|
||||
processDefinitionQuery.processDefinitionKeyLike("%" + processBo.getProcessKey() + "%");
|
||||
}
|
||||
if (StringUtils.isNotBlank(processBo.getProcessName())) {
|
||||
processDefinitionQuery.processDefinitionNameLike("%" + processBo.getProcessName() + "%");
|
||||
}
|
||||
if (StringUtils.isNotBlank(processBo.getCategory())) {
|
||||
processDefinitionQuery.processDefinitionCategory(processBo.getCategory());
|
||||
}
|
||||
if (StringUtils.isNotBlank(processBo.getState())) {
|
||||
if (SuspensionState.ACTIVE.toString().equals(processBo.getState())) {
|
||||
processDefinitionQuery.active();
|
||||
} else if (SuspensionState.SUSPENDED.toString().equals(processBo.getState())) {
|
||||
processDefinitionQuery.suspended();
|
||||
}
|
||||
}
|
||||
// SuspensionState.ACTIVE
|
||||
long pageTotal = processDefinitionQuery.count();
|
||||
if (pageTotal <= 0) {
|
||||
return TableDataInfo.build();
|
||||
}
|
||||
int offset = pageQuery.getPageSize() * (pageQuery.getPageNum() - 1);
|
||||
List<ProcessDefinition> definitionList = processDefinitionQuery.listPage(offset, pageQuery.getPageSize());
|
||||
|
||||
List<WfDeployVo> deployVoList = new ArrayList<>(definitionList.size());
|
||||
for (ProcessDefinition processDefinition : definitionList) {
|
||||
String deploymentId = processDefinition.getDeploymentId();
|
||||
Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
|
||||
WfDeployVo vo = new WfDeployVo();
|
||||
vo.setDefinitionId(processDefinition.getId());
|
||||
vo.setProcessKey(processDefinition.getKey());
|
||||
vo.setProcessName(processDefinition.getName());
|
||||
vo.setVersion(processDefinition.getVersion());
|
||||
vo.setCategory(processDefinition.getCategory());
|
||||
vo.setDeploymentId(processDefinition.getDeploymentId());
|
||||
vo.setSuspended(processDefinition.isSuspended());
|
||||
// 流程部署信息
|
||||
vo.setCategory(deployment.getCategory());
|
||||
vo.setDeploymentTime(deployment.getDeploymentTime());
|
||||
deployVoList.add(vo);
|
||||
}
|
||||
Page<WfDeployVo> page = new Page<>();
|
||||
page.setRecords(deployVoList);
|
||||
page.setTotal(pageTotal);
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo<WfDeployVo> queryPublishList(String processKey, PageQuery pageQuery) {
|
||||
// 创建查询条件
|
||||
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery()
|
||||
.processDefinitionKey(processKey)
|
||||
.orderByProcessDefinitionVersion()
|
||||
.desc();
|
||||
long pageTotal = processDefinitionQuery.count();
|
||||
if (pageTotal <= 0) {
|
||||
return TableDataInfo.build();
|
||||
}
|
||||
// 根据查询条件,查询所有版本
|
||||
int offset = pageQuery.getPageSize() * (pageQuery.getPageNum() - 1);
|
||||
List<ProcessDefinition> processDefinitionList = processDefinitionQuery
|
||||
.listPage(offset, pageQuery.getPageSize());
|
||||
List<WfDeployVo> deployVoList = processDefinitionList.stream().map(item -> {
|
||||
WfDeployVo vo = new WfDeployVo();
|
||||
vo.setDefinitionId(item.getId());
|
||||
vo.setProcessKey(item.getKey());
|
||||
vo.setProcessName(item.getName());
|
||||
vo.setVersion(item.getVersion());
|
||||
vo.setCategory(item.getCategory());
|
||||
vo.setDeploymentId(item.getDeploymentId());
|
||||
vo.setSuspended(item.isSuspended());
|
||||
return vo;
|
||||
}).collect(Collectors.toList());
|
||||
Page<WfDeployVo> page = new Page<>();
|
||||
page.setRecords(deployVoList);
|
||||
page.setTotal(pageTotal);
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 激活或挂起流程
|
||||
*
|
||||
* @param state 状态
|
||||
* @param definitionId 流程定义ID
|
||||
*/
|
||||
@Override
|
||||
public void updateState(String definitionId, String state) {
|
||||
if (SuspensionState.ACTIVE.toString().equals(state)) {
|
||||
// 激活
|
||||
repositoryService.activateProcessDefinitionById(definitionId, true, null);
|
||||
} else if (SuspensionState.SUSPENDED.toString().equals(state)) {
|
||||
// 挂起
|
||||
repositoryService.suspendProcessDefinitionById(definitionId, true, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String queryBpmnXmlById(String definitionId) {
|
||||
InputStream inputStream = repositoryService.getProcessModel(definitionId);
|
||||
try {
|
||||
return IoUtil.readUtf8(inputStream);
|
||||
} catch (IORuntimeException exception) {
|
||||
throw new RuntimeException("加载xml文件异常");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
package com.ruoyi.workflow.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.utils.JsonUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.flowable.common.constant.ProcessConstants;
|
||||
import com.ruoyi.flowable.common.enums.FormType;
|
||||
import com.ruoyi.flowable.factory.FlowServiceFactory;
|
||||
import com.ruoyi.flowable.utils.ModelUtils;
|
||||
import com.ruoyi.workflow.domain.bo.WfModelBo;
|
||||
import com.ruoyi.workflow.domain.dto.WfMetaInfoDto;
|
||||
import com.ruoyi.workflow.domain.vo.WfFormVo;
|
||||
import com.ruoyi.workflow.domain.vo.WfModelVo;
|
||||
import com.ruoyi.workflow.service.IWfDeployFormService;
|
||||
import com.ruoyi.workflow.service.IWfFormService;
|
||||
import com.ruoyi.workflow.service.IWfModelService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.bpmn.model.BpmnModel;
|
||||
import org.flowable.engine.repository.Deployment;
|
||||
import org.flowable.engine.repository.Model;
|
||||
import org.flowable.engine.repository.ModelQuery;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author KonBAI
|
||||
* @createTime 2022/6/21 9:11
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
@Slf4j
|
||||
public class WfModelServiceImpl extends FlowServiceFactory implements IWfModelService {
|
||||
|
||||
private final IWfFormService formService;
|
||||
private final IWfDeployFormService deployFormService;
|
||||
|
||||
@Override
|
||||
public TableDataInfo<WfModelVo> list(WfModelBo modelBo, PageQuery pageQuery) {
|
||||
ModelQuery modelQuery = repositoryService.createModelQuery().latestVersion().orderByCreateTime().desc();
|
||||
// 构建查询条件
|
||||
if (StringUtils.isNotBlank(modelBo.getModelKey())) {
|
||||
modelQuery.modelKey(modelBo.getModelKey());
|
||||
}
|
||||
if (StringUtils.isNotBlank(modelBo.getModelName())) {
|
||||
modelQuery.modelNameLike("%" + modelBo.getModelName() + "%");
|
||||
}
|
||||
if (StringUtils.isNotBlank(modelBo.getCategory())) {
|
||||
modelQuery.modelCategory(modelBo.getCategory());
|
||||
}
|
||||
// 执行查询
|
||||
long pageTotal = modelQuery.count();
|
||||
if (pageTotal <= 0) {
|
||||
return TableDataInfo.build();
|
||||
}
|
||||
int offset = pageQuery.getPageSize() * (pageQuery.getPageNum() - 1);
|
||||
List<Model> modelList = modelQuery.listPage(offset, pageQuery.getPageSize());
|
||||
List<WfModelVo> modelVoList = new ArrayList<>(modelList.size());
|
||||
modelList.forEach(model -> {
|
||||
WfModelVo modelVo = new WfModelVo();
|
||||
modelVo.setModelId(model.getId());
|
||||
modelVo.setModelName(model.getName());
|
||||
modelVo.setModelKey(model.getKey());
|
||||
modelVo.setCategory(model.getCategory());
|
||||
modelVo.setCreateTime(model.getCreateTime());
|
||||
modelVo.setVersion(model.getVersion());
|
||||
WfMetaInfoDto metaInfo = JsonUtils.parseObject(model.getMetaInfo(), WfMetaInfoDto.class);
|
||||
if (metaInfo != null) {
|
||||
modelVo.setDescription(metaInfo.getDescription());
|
||||
modelVo.setFormType(metaInfo.getFormType());
|
||||
modelVo.setFormId(metaInfo.getFormId());
|
||||
}
|
||||
modelVoList.add(modelVo);
|
||||
});
|
||||
Page<WfModelVo> page = new Page<>();
|
||||
page.setRecords(modelVoList);
|
||||
page.setTotal(pageTotal);
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo<WfModelVo> historyList(WfModelBo modelBo, PageQuery pageQuery) {
|
||||
ModelQuery modelQuery = repositoryService.createModelQuery()
|
||||
.modelKey(modelBo.getModelKey())
|
||||
.orderByModelVersion()
|
||||
.desc();
|
||||
// 执行查询(不显示最新版,-1)
|
||||
long pageTotal = modelQuery.count() - 1;
|
||||
if (pageTotal <= 0) {
|
||||
return TableDataInfo.build();
|
||||
}
|
||||
// offset+1,去掉最新版
|
||||
int offset = 1 + pageQuery.getPageSize() * (pageQuery.getPageNum() - 1);
|
||||
List<Model> modelList = modelQuery.listPage(offset, pageQuery.getPageSize());
|
||||
List<WfModelVo> modelVoList = new ArrayList<>(modelList.size());
|
||||
modelList.forEach(model -> {
|
||||
WfModelVo modelVo = new WfModelVo();
|
||||
modelVo.setModelId(model.getId());
|
||||
modelVo.setModelName(model.getName());
|
||||
modelVo.setModelKey(model.getKey());
|
||||
modelVo.setCategory(model.getCategory());
|
||||
modelVo.setCreateTime(model.getCreateTime());
|
||||
modelVo.setVersion(model.getVersion());
|
||||
WfMetaInfoDto metaInfo = JsonUtils.parseObject(model.getMetaInfo(), WfMetaInfoDto.class);
|
||||
if (metaInfo != null) {
|
||||
modelVo.setDescription(metaInfo.getDescription());
|
||||
modelVo.setFormType(metaInfo.getFormType());
|
||||
modelVo.setFormId(metaInfo.getFormId());
|
||||
}
|
||||
modelVoList.add(modelVo);
|
||||
});
|
||||
Page<WfModelVo> page = new Page<>();
|
||||
page.setRecords(modelVoList);
|
||||
page.setTotal(pageTotal);
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WfModelVo getModel(String modelId) {
|
||||
// 获取流程模型
|
||||
Model model = repositoryService.getModel(modelId);
|
||||
if (ObjectUtil.isNull(model)) {
|
||||
throw new RuntimeException("流程模型不存在!");
|
||||
}
|
||||
// 获取流程图
|
||||
String bpmnXml = queryBpmnXmlById(modelId);
|
||||
WfModelVo modelVo = new WfModelVo();
|
||||
modelVo.setModelId(model.getId());
|
||||
modelVo.setModelName(model.getName());
|
||||
modelVo.setModelKey(model.getKey());
|
||||
modelVo.setCategory(model.getCategory());
|
||||
modelVo.setCreateTime(model.getCreateTime());
|
||||
modelVo.setVersion(model.getVersion());
|
||||
modelVo.setBpmnXml(bpmnXml);
|
||||
WfMetaInfoDto metaInfo = JsonUtils.parseObject(model.getMetaInfo(), WfMetaInfoDto.class);
|
||||
if (metaInfo != null) {
|
||||
modelVo.setDescription(metaInfo.getDescription());
|
||||
modelVo.setFormType(metaInfo.getFormType());
|
||||
modelVo.setFormId(metaInfo.getFormId());
|
||||
if (FormType.PROCESS.getType().equals(metaInfo.getFormType())) {
|
||||
WfFormVo wfFormVo = formService.queryById(metaInfo.getFormId());
|
||||
modelVo.setContent(wfFormVo.getContent());
|
||||
}
|
||||
}
|
||||
return modelVo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String queryBpmnXmlById(String modelId) {
|
||||
byte[] bpmnBytes = repositoryService.getModelEditorSource(modelId);
|
||||
if (ObjectUtil.isNull(bpmnBytes)) {
|
||||
throw new RuntimeException("流程图不存在!");
|
||||
}
|
||||
return StrUtil.utf8Str(bpmnBytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveModel(WfModelBo modelBo) {
|
||||
// 根据模型Key查询模型信息
|
||||
Model model = repositoryService.createModelQuery().modelKey(modelBo.getModelKey()).singleResult();
|
||||
Model newModel;
|
||||
if (ObjectUtil.isNull(model)) {
|
||||
newModel = repositoryService.newModel();
|
||||
} else {
|
||||
if (modelBo.getNewVersion() != null && modelBo.getNewVersion()) {
|
||||
newModel = repositoryService.newModel();
|
||||
newModel.setVersion(model.getVersion() + 1);
|
||||
} else {
|
||||
newModel = model;
|
||||
}
|
||||
}
|
||||
newModel.setName(modelBo.getModelName());
|
||||
newModel.setKey(modelBo.getModelKey());
|
||||
newModel.setCategory(modelBo.getCategory());
|
||||
newModel.setMetaInfo(buildMetaInfo(modelBo));
|
||||
// 保存流程模型
|
||||
repositoryService.saveModel(newModel);
|
||||
// 保存 BPMN XML
|
||||
saveModelBpmnXml(newModel.getId(), modelBo.getBpmnXml());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void latestModel(String modelId) {
|
||||
// 获取流程模型
|
||||
Model model = repositoryService.getModel(modelId);
|
||||
if (ObjectUtil.isNull(model)) {
|
||||
throw new RuntimeException("流程模型不存在!");
|
||||
}
|
||||
String bpmnXml = queryBpmnXmlById(modelId);
|
||||
Integer latestVersion = repositoryService.createModelQuery()
|
||||
.modelKey(model.getKey())
|
||||
.latestVersion()
|
||||
.singleResult()
|
||||
.getVersion();
|
||||
if (model.getVersion().equals(latestVersion)) {
|
||||
throw new RuntimeException("当前版本已是最新版!");
|
||||
}
|
||||
Model newModel = repositoryService.newModel();
|
||||
newModel.setName(model.getName());
|
||||
newModel.setKey(model.getKey());
|
||||
newModel.setCategory(model.getCategory());
|
||||
newModel.setMetaInfo(model.getMetaInfo());
|
||||
newModel.setVersion(latestVersion + 1);
|
||||
// 保存流程模型
|
||||
repositoryService.saveModel(newModel);
|
||||
// 保存 BPMN XML
|
||||
saveModelBpmnXml(newModel.getId(), bpmnXml);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteByIds(Collection<String> ids) {
|
||||
ids.forEach(id -> {
|
||||
Model model = repositoryService.getModel(id);
|
||||
if (ObjectUtil.isNull(model)) {
|
||||
throw new RuntimeException("流程模型不存在!");
|
||||
}
|
||||
repositoryService.deleteModel(id);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deployModel(String modelId) {
|
||||
// 获取流程模型
|
||||
Model model = repositoryService.getModel(modelId);
|
||||
if (ObjectUtil.isNull(model)) {
|
||||
throw new RuntimeException("流程模型不存在!");
|
||||
}
|
||||
WfMetaInfoDto metaInfo = getMetaInfo(model.getMetaInfo());
|
||||
// 获取流程图
|
||||
String bpmnXml = queryBpmnXmlById(modelId);
|
||||
BpmnModel bpmnModel = ModelUtils.getBpmnModel(bpmnXml);
|
||||
String processName = model.getName() + ProcessConstants.SUFFIX;
|
||||
Deployment deployment = repositoryService.createDeployment()
|
||||
.name(model.getName())
|
||||
.key(model.getKey())
|
||||
.addBpmnModel(processName, bpmnModel)
|
||||
.category(model.getCategory())
|
||||
.deploy();
|
||||
// 保存部署表单
|
||||
if (FormType.PROCESS.getType().equals(metaInfo.getFormType())) {
|
||||
deployFormService.saveInternalDeployForm(deployment.getId(), metaInfo.getFormId());
|
||||
}
|
||||
}
|
||||
|
||||
private String buildMetaInfo(WfModelBo modelBo) {
|
||||
WfMetaInfoDto metaInfo = new WfMetaInfoDto();
|
||||
// 只有非空,才进行设置,避免更新时的覆盖
|
||||
if (StringUtils.isNotEmpty(modelBo.getDescription())) {
|
||||
metaInfo.setDescription(modelBo.getDescription());
|
||||
}
|
||||
if (ObjectUtil.isNotNull(modelBo.getFormType())) {
|
||||
metaInfo.setFormType(modelBo.getFormType());
|
||||
metaInfo.setFormId(modelBo.getFormId());
|
||||
}
|
||||
return JsonUtils.toJsonString(metaInfo);
|
||||
}
|
||||
|
||||
private WfMetaInfoDto getMetaInfo(String metaInfoJson) {
|
||||
WfMetaInfoDto metaInfo = JsonUtils.parseObject(metaInfoJson, WfMetaInfoDto.class);
|
||||
if (ObjectUtil.isNull(metaInfo) || ObjectUtil.hasNull(metaInfo.getFormType(), metaInfo.getFormId())) {
|
||||
throw new RuntimeException("未配置表单信息!");
|
||||
}
|
||||
return metaInfo;
|
||||
}
|
||||
|
||||
private void saveModelBpmnXml(String modelId, String bpmnXml) {
|
||||
if (StringUtils.isBlank(modelId)) {
|
||||
throw new RuntimeException("模板主键不能为空!");
|
||||
}
|
||||
if (StringUtils.isNotEmpty(bpmnXml)) {
|
||||
repositoryService.addModelEditorSource(modelId, StrUtil.utf8Bytes(bpmnXml));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,40 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询流程部署列表
|
||||
export function listDeploy(query) {
|
||||
return request({
|
||||
url: '/workflow/deploy/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function listPublish(query) {
|
||||
return request({
|
||||
url: '/workflow/deploy/publishList',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 获取流程模型流程图
|
||||
export function getBpmnXml(definitionId) {
|
||||
return request({
|
||||
url: '/workflow/deploy/bpmnXml/' + definitionId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 修改流程状态
|
||||
export function changeState(params) {
|
||||
return request({
|
||||
url: '/workflow/deploy/changeState',
|
||||
method: 'put',
|
||||
params: params
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 查询流程部署关联表单信息
|
||||
export function getFormByDeployId(deployId) {
|
||||
return request({
|
||||
|
||||
66
ruoyi-ui/src/api/workflow/model.js
Normal file
66
ruoyi-ui/src/api/workflow/model.js
Normal file
@@ -0,0 +1,66 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询流程模型信息
|
||||
export function listModel(query) {
|
||||
return request({
|
||||
url: '/workflow/model/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询流程模型信息
|
||||
export function historyModel(query) {
|
||||
return request({
|
||||
url: '/workflow/model/historyList',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function getModel(modelId) {
|
||||
return request({
|
||||
url: '/workflow/model/' + modelId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 保存流程模型
|
||||
export function saveModel(data) {
|
||||
return request({
|
||||
url: '/workflow/model',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function latestModel(params) {
|
||||
return request({
|
||||
url: '/workflow/model/latest',
|
||||
method: 'post',
|
||||
params: params
|
||||
})
|
||||
}
|
||||
|
||||
export function delModel(modelIds) {
|
||||
return request({
|
||||
url: '/workflow/model/' + modelIds,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
export function deployModel(params) {
|
||||
return request({
|
||||
url: '/workflow/model/deploy',
|
||||
method: 'post',
|
||||
params: params
|
||||
})
|
||||
}
|
||||
|
||||
// 获取流程模型流程图
|
||||
export function getBpmnXml(modelId) {
|
||||
return request({
|
||||
url: '/workflow/model/bpmnXml/' + modelId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
302
ruoyi-ui/src/views/workflow/deploy/index.vue
Normal file
302
ruoyi-ui/src/views/workflow/deploy/index.vue
Normal file
@@ -0,0 +1,302 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="流程标识" prop="processKey">
|
||||
<el-input
|
||||
v-model="queryParams.processKey"
|
||||
placeholder="请输入流程标识"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="流程名称" prop="processName">
|
||||
<el-input
|
||||
v-model="queryParams.processName"
|
||||
placeholder="请输入流程名称"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="流程分类" prop="category">
|
||||
<el-select v-model="queryParams.category" clearable placeholder="请选择" size="small">
|
||||
<el-option
|
||||
v-for="item in categoryOptions"
|
||||
:key="item.categoryId"
|
||||
:label="item.categoryName"
|
||||
:value="item.code">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="state">
|
||||
<el-select v-model="queryParams.state" size="small" clearable placeholder="请选择状态">
|
||||
<el-option :key="1" label="激活" value="active" />
|
||||
<el-option :key="2" label="挂起" value="suspended" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-table v-loading="loading" fit :data="deployList">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="流程标识" align="center" prop="processKey" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="流程名称" align="center" :show-overflow-tooltip="true">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" @click="handleProcessView(scope.row)">
|
||||
<span>{{ scope.row.processName }}</span>
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="流程分类" align="center" prop="categoryName" :formatter="categoryFormat" />
|
||||
<el-table-column label="流程版本" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-tag size="medium" >v{{ scope.row.version }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-tag type="success" v-if="!scope.row.suspended">激活</el-tag>
|
||||
<el-tag type="warning" v-if="scope.row.suspended">挂起</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="部署时间" align="center" prop="deploymentTime" width="180"/>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
type="text"
|
||||
size="mini"
|
||||
icon="el-icon-price-tag"
|
||||
@click.native="handlePublish(scope.row)"
|
||||
v-hasPermi="['workflow:deploy:list']"
|
||||
>版本管理</el-button>
|
||||
<el-button
|
||||
type="text"
|
||||
size="mini"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['workflow:deploy:remove']"
|
||||
>删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</el-row>
|
||||
|
||||
<!-- 流程图 -->
|
||||
<el-dialog :title="processView.title" :visible.sync="processView.open" width="70%" append-to-body>
|
||||
<process-viewer :key="`designer-${processView.index}`" :xml="processView.xmlData" :style="{height: '400px'}" />
|
||||
</el-dialog>
|
||||
|
||||
<!-- 版本管理 -->
|
||||
<el-dialog title="版本管理" :visible.sync="publish.open" width="50%" append-to-body>
|
||||
<el-table v-loading="publish.loading" :data="publish.dataList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="流程标识" align="center" prop="processKey" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="流程名称" align="center" :show-overflow-tooltip="true">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" @click="handleProcessView(scope.row)">
|
||||
<span>{{ scope.row.processName }}</span>
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="流程版本" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-tag size="medium" >v{{ scope.row.version }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-tag type="success" v-if="!scope.row.suspended">激活</el-tag>
|
||||
<el-tag type="warning" v-if="scope.row.suspended">挂起</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
type="text"
|
||||
size="mini"
|
||||
icon="el-icon-video-pause"
|
||||
v-if="!scope.row.suspended"
|
||||
@click.native="handleChangeState(scope.row, 'suspended')"
|
||||
v-hasPermi="['workflow:deploy:status']"
|
||||
>挂起</el-button>
|
||||
<el-button
|
||||
type="text"
|
||||
size="mini"
|
||||
icon="el-icon-video-play"
|
||||
v-if="scope.row.suspended"
|
||||
@click.native="handleChangeState(scope.row, 'active')"
|
||||
v-hasPermi="['workflow:deploy:status']"
|
||||
>激活</el-button>
|
||||
<el-button
|
||||
type="text"
|
||||
size="mini"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['workflow:deploy:remove']"
|
||||
>删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination
|
||||
v-show="publishTotal > 0"
|
||||
:total="publishTotal"
|
||||
:page.sync="publishQueryParams.pageNum"
|
||||
:limit.sync="publishQueryParams.pageSize"
|
||||
@pagination="getPublishList"
|
||||
/>
|
||||
</el-dialog>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listAllCategory } from '@/api/workflow/category'
|
||||
import { listDeploy, listPublish, getBpmnXml, changeState } from '@/api/workflow/deploy'
|
||||
import ProcessViewer from '@/components/ProcessViewer'
|
||||
|
||||
export default {
|
||||
name: 'Deploy',
|
||||
components: {
|
||||
ProcessViewer
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
processKey: null,
|
||||
processName: null,
|
||||
category: null,
|
||||
state: null
|
||||
},
|
||||
deployList: [],
|
||||
categoryOptions: [],
|
||||
processView: {
|
||||
title: '',
|
||||
open: false,
|
||||
index: undefined,
|
||||
xmlData:"",
|
||||
},
|
||||
publish: {
|
||||
open: false,
|
||||
loading: false,
|
||||
dataList: []
|
||||
},
|
||||
publishTotal: 0,
|
||||
publishQueryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
processKey: ""
|
||||
},
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getCategoryList();
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询流程分类列表 */
|
||||
getCategoryList() {
|
||||
listAllCategory().then(response => this.categoryOptions = response.data);
|
||||
},
|
||||
/** 查询流程部署列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listDeploy(this.queryParams).then(response => {
|
||||
this.deployList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
id: null,
|
||||
processKey: null,
|
||||
processName: null,
|
||||
category: null,
|
||||
state: null
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
/** 查看流程图 */
|
||||
handleProcessView(row) {
|
||||
let definitionId = row.definitionId;
|
||||
this.processView.title = "流程图";
|
||||
this.processView.index = definitionId;
|
||||
// 发送请求,获取xml
|
||||
getBpmnXml(definitionId).then(response => {
|
||||
this.processView.xmlData = response.data;
|
||||
})
|
||||
this.processView.open = true;
|
||||
},
|
||||
getPublishList() {
|
||||
this.publish.loading = true;
|
||||
listPublish(this.publishQueryParams).then(response => {
|
||||
this.publish.dataList = response.rows;
|
||||
this.publishTotal = response.total;
|
||||
this.publish.loading = false;
|
||||
})
|
||||
},
|
||||
handlePublish(row) {
|
||||
this.publishQueryParams.processKey = row.processKey;
|
||||
this.publish.open = true;
|
||||
this.getPublishList();
|
||||
},
|
||||
/** 挂起/激活流程 */
|
||||
handleChangeState(row, state) {
|
||||
const params = {
|
||||
definitionId: row.definitionId,
|
||||
state: state
|
||||
}
|
||||
changeState(params).then(res => {
|
||||
this.$modal.msgSuccess(res.msg)
|
||||
this.getPublishList();
|
||||
});
|
||||
},
|
||||
categoryFormat(row, column) {
|
||||
return this.categoryOptions.find(k => k.code === row.category)?.categoryName ?? '';
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
295
ruoyi-ui/src/views/workflow/model/designer.vue
Normal file
295
ruoyi-ui/src/views/workflow/model/designer.vue
Normal file
@@ -0,0 +1,295 @@
|
||||
<template>
|
||||
<div class="workflow-designer">
|
||||
<el-container>
|
||||
<el-header height="70px">
|
||||
<el-row type="flex" align="middle">
|
||||
<el-col :span="3">
|
||||
<div style="display:flex;justify-content:center;">
|
||||
<el-button type="danger" @click="onClose()">关闭</el-button>
|
||||
<el-button type="primary" @click="onPrevious()" :disabled="activeStep <= 0">上一步</el-button>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :offset="1" :span="16">
|
||||
<el-steps :active="activeStep" finish-status="success" align-center>
|
||||
<el-step title="基础设置"></el-step>
|
||||
<el-step title="流程设计"></el-step>
|
||||
<el-step title="完成"></el-step>
|
||||
</el-steps>
|
||||
</el-col>
|
||||
<el-col :offset="1" :span="3">
|
||||
<div style="display:flex;justify-content:center;">
|
||||
<el-button type="primary" @click="onNext()" :disabled="activeStep >= 1">下一步</el-button>
|
||||
<el-button type="success" @click="onSave()" :disabled="activeStep !== 1">保存</el-button>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-header>
|
||||
<el-main>
|
||||
<div v-if="activeStep === 0">
|
||||
<div class="app-container">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="10">
|
||||
<el-divider content-position="left">
|
||||
<span style="font-size: 18px">基础信息</span>
|
||||
</el-divider>
|
||||
<el-form :model="designerForm" ref="designerForm" size="small" label-width="80px" :rules="rules">
|
||||
<el-form-item label="模型标识" prop="processKey">
|
||||
<el-input v-model="designerForm.processKey" clearable disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="模型名称" prop="processName">
|
||||
<el-input v-model="designerForm.processName" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="分类" prop="category">
|
||||
<el-select v-model="designerForm.category" placeholder="请选择分类" clearable style="width:100%">
|
||||
<el-option v-for="item in categoryOptions" :key="item.categoryId" :label="item.categoryName" :value="item.code" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="描述" prop="description">
|
||||
<el-input v-model="designerForm.description" type="textarea" placeholder="请输入内容" maxlength="200" show-word-limit/>
|
||||
</el-form-item>
|
||||
<el-form-item label="表单类型" prop="formType">
|
||||
<el-radio-group v-model="designerForm.formType">
|
||||
<el-radio :label="0">内置表单</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="表单" prop="formId">
|
||||
<el-select v-model="designerForm.formId" placeholder="请选择表单" @change="handleFormChange(designerForm.formId)" clearable style="width:100%">
|
||||
<el-option v-for="item in formOptions" :key="item.formId" :label="item.formName" :value="item.formId" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-col>
|
||||
<el-col :span="13" :offset="1">
|
||||
<el-divider content-position="left">
|
||||
<span style="font-size: 18px">表单预览</span>
|
||||
</el-divider>
|
||||
<parser v-if="formShow" :form-conf="formContent" />
|
||||
<el-empty v-else description="暂无数据" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="activeStep === 1">
|
||||
<process-designer
|
||||
ref="modelDesigner"
|
||||
v-loading="loading"
|
||||
:bpmnXml="bpmnXml"
|
||||
:designerForm="designerForm"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="activeStep === 2">
|
||||
<el-result :icon="result.icon" :title="result.title" :subTitle="result.describe">
|
||||
<template slot="extra">
|
||||
<el-button type="primary" size="medium" @click="onClose()">关闭</el-button>
|
||||
</template>
|
||||
</el-result>
|
||||
</div>
|
||||
|
||||
</el-main>
|
||||
<el-footer>
|
||||
</el-footer>
|
||||
</el-container>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getModel, getBpmnXml, saveModel } from "@/api/workflow/model";
|
||||
import { getForm, listForm } from "@/api/workflow/form";
|
||||
import ProcessDesigner from '@/components/ProcessDesigner';
|
||||
import Parser from '@/utils/generator/parser'
|
||||
import { listAllCategory } from '@/api/workflow/category';
|
||||
|
||||
export default {
|
||||
name: 'Designer',
|
||||
components: { ProcessDesigner, Parser },
|
||||
props: {
|
||||
modelId: {
|
||||
type: String
|
||||
},
|
||||
processName: {
|
||||
type: String
|
||||
},
|
||||
processKey: {
|
||||
type: String
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
activeStep: 0,
|
||||
designerForm: {},
|
||||
rules: {
|
||||
modelKey: [
|
||||
{ required: true, message: '请输入模型标识', trigger: 'blur' }
|
||||
],
|
||||
modelName: [
|
||||
{ required: true, message: '请输入模型名称', trigger: 'blur' }
|
||||
],
|
||||
category: [
|
||||
{ required: true, message: '请选择分类', trigger: 'change' }
|
||||
],
|
||||
formType: [
|
||||
{ required: true, message: '请选择表单类型', trigger: 'change' }
|
||||
],
|
||||
formId: [
|
||||
{ required: true, message: '请选择表单', trigger: 'change' }
|
||||
]
|
||||
},
|
||||
categoryOptions: [],
|
||||
formOptions: [],
|
||||
formShow: false,
|
||||
formContent: {},
|
||||
loadIndex: 0,
|
||||
loading: false,
|
||||
bpmnXml: '',
|
||||
result: {
|
||||
icon: 'info',
|
||||
title: null,
|
||||
describe: null
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.onLoad();
|
||||
},
|
||||
methods: {
|
||||
onClose () {
|
||||
this.$emit('close');
|
||||
},
|
||||
onPrevious() {
|
||||
this.activeStep--;
|
||||
},
|
||||
onNext() {
|
||||
this.activeStep++;
|
||||
},
|
||||
/**
|
||||
* 初始化加载
|
||||
*/
|
||||
onLoad() {
|
||||
this.getCategoryList();
|
||||
this.getFormList();
|
||||
if (this.modelId) {
|
||||
getModel(this.modelId).then(response => {
|
||||
const data = response.data
|
||||
this.designerForm = {
|
||||
processName: data.modelName,
|
||||
processKey: data.modelKey,
|
||||
category: data.category,
|
||||
description: data.description,
|
||||
formType: data.formType,
|
||||
formId: data.formId
|
||||
}
|
||||
if (data.bpmnXml) {
|
||||
this.bpmnXml = data.bpmnXml
|
||||
}
|
||||
if (data.content) {
|
||||
this.formContent = JSON.parse(data.content)
|
||||
this.formShow = true
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.designerForm = {
|
||||
processName: this.processName,
|
||||
processKey: this.processKey,
|
||||
formType: 0
|
||||
}
|
||||
}
|
||||
},
|
||||
/** 查询流程分类列表 */
|
||||
getCategoryList() {
|
||||
listAllCategory().then(response => this.categoryOptions = response.data)
|
||||
},
|
||||
/** 查询流程分类列表 */
|
||||
getFormList() {
|
||||
listForm().then(response => this.formOptions = response.rows)
|
||||
},
|
||||
handleFormChange(formId) {
|
||||
this.formShow = false
|
||||
if (formId) {
|
||||
getForm(formId).then(res =>{
|
||||
this.formContent = JSON.parse(res.data.content)
|
||||
this.formShow = true
|
||||
})
|
||||
}
|
||||
},
|
||||
onSave() {
|
||||
|
||||
let refProcessDesigner = this.$refs.modelDesigner.$refs.processDesigner;
|
||||
refProcessDesigner.onSave().then(xml => {
|
||||
this.bpmnXml = xml;
|
||||
let dataBody = {
|
||||
modelName: this.designerForm.processName,
|
||||
modelKey: this.designerForm.processKey,
|
||||
category: this.designerForm.category,
|
||||
description: this.designerForm.description,
|
||||
formType: this.designerForm.formType,
|
||||
formId: this.designerForm.formId,
|
||||
bpmnXml: this.bpmnXml
|
||||
}
|
||||
this.$confirm("是否将此模型保存为新版本?", "提示", {
|
||||
distinguishCancelAndClose: true,
|
||||
confirmButtonText: '是',
|
||||
cancelButtonText: '否'
|
||||
}).then(() => {
|
||||
this.confirmSave(dataBody, true)
|
||||
}).catch(action => {
|
||||
if (action === 'cancel') {
|
||||
this.confirmSave(dataBody, false)
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
confirmSave(body, newVersion) {
|
||||
this.loading = true;
|
||||
saveModel(Object.assign(body, {
|
||||
newVersion: newVersion
|
||||
})).then(res => {
|
||||
this.result.icon = 'success';
|
||||
this.result.title = '成功';
|
||||
this.result.describe = res.msg;
|
||||
}).catch(res => {
|
||||
this.result.icon = 'error';
|
||||
this.result.title = '失败';
|
||||
this.result.describe = res.msg;
|
||||
}).finally(() => {
|
||||
this.loading = false;
|
||||
this.onNext();
|
||||
this.$emit('save');
|
||||
})
|
||||
},
|
||||
/** xml 文件 */
|
||||
getModelDetail(modelId) {
|
||||
this.loading = true;
|
||||
// 发送请求,获取xml
|
||||
getBpmnXml(modelId).then(res => {
|
||||
this.bpmnXml = res.data;
|
||||
this.loadIndex = modelId;
|
||||
this.loading = false;
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.workflow-designer {
|
||||
position: fixed;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background: #ebeef5;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 1010;
|
||||
padding: 10px;
|
||||
}
|
||||
.workflow-designer >>> .el-header {
|
||||
padding: 10px;
|
||||
background: #ffffff;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.workflow-designer >>> .el-main {
|
||||
background: #ffffff;
|
||||
padding: 0;
|
||||
}
|
||||
</style>
|
||||
525
ruoyi-ui/src/views/workflow/model/index.vue
Normal file
525
ruoyi-ui/src/views/workflow/model/index.vue
Normal file
@@ -0,0 +1,525 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="模型标识" prop="modelKey">
|
||||
<el-input
|
||||
v-model="queryParams.modelKey"
|
||||
placeholder="请输入模型标识"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="模型名称" prop="modelName">
|
||||
<el-input
|
||||
v-model="queryParams.modelName"
|
||||
placeholder="请输入模型名称"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="流程分类" prop="category">
|
||||
<el-select v-model="queryParams.category" clearable placeholder="请选择" size="small">
|
||||
<el-option
|
||||
v-for="item in categoryOptions"
|
||||
:key="item.categoryId"
|
||||
:label="item.categoryName"
|
||||
:value="item.code">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-upload"
|
||||
size="mini"
|
||||
@click="handleImport"
|
||||
v-hasPermi="['workflow:model:import']"
|
||||
>导入</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['workflow:model:add']"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="el-icon-delete"
|
||||
size="mini"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['workflow:model:remove']"
|
||||
>删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="el-icon-download"
|
||||
size="mini"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['workflow:model:export']"
|
||||
>导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" fit :data="modelList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="模型标识" align="center" prop="modelKey" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="模型名称" align="center" :show-overflow-tooltip="true">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" @click="handleProcessView(scope.row)">
|
||||
<span>{{ scope.row.modelName }}</span>
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="流程分类" align="center" prop="categoryName" :formatter="categoryFormat" />
|
||||
<el-table-column label="模型版本" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-tag size="medium" >v{{ scope.row.version }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="描述" align="center" prop="description" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180"/>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
type="text"
|
||||
size="mini"
|
||||
icon="el-icon-brush"
|
||||
@click="handleDesigner(scope.row)"
|
||||
v-hasPermi="['workflow:model:designer']"
|
||||
>设计</el-button>
|
||||
<el-button
|
||||
type="text"
|
||||
size="mini"
|
||||
icon="el-icon-video-play"
|
||||
v-hasPermi="['workflow:model:deploy']"
|
||||
@click.native="handleDeploy(scope.row)"
|
||||
>部署</el-button>
|
||||
<el-dropdown>
|
||||
<span class="el-dropdown-link">
|
||||
<i class="el-icon-d-arrow-right el-icon--right"></i>更多
|
||||
</span>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item
|
||||
icon="el-icon-view"
|
||||
@click.native="handleProcessView(scope.row)"
|
||||
v-hasPermi="['workflow:model:view']"
|
||||
>流程图</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
icon="el-icon-price-tag"
|
||||
@click.native="handleHistory(scope.row)"
|
||||
v-hasPermi="['workflow:model:list']"
|
||||
>历史</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
icon="el-icon-delete"
|
||||
@click.native="handleDelete(scope.row)"
|
||||
v-hasPermi="['workflow:model:remove']"
|
||||
>删除</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- bpmn20.xml导入对话框 -->
|
||||
<el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body @close="cancel('uploadForm')">
|
||||
<el-upload
|
||||
ref="upload"
|
||||
:limit="1"
|
||||
accept=".xml"
|
||||
:headers="upload.headers"
|
||||
:action="upload.url + '?name=' + upload.name+'&category='+ upload.category"
|
||||
:disabled="upload.isUploading"
|
||||
:on-progress="handleFileUploadProgress"
|
||||
:on-success="handleFileSuccess"
|
||||
:auto-upload="false"
|
||||
drag
|
||||
>
|
||||
<i class="el-icon-upload"></i>
|
||||
<div class="el-upload__text">
|
||||
将文件拖到此处,或
|
||||
<em>点击上传</em>
|
||||
</div>
|
||||
<div class="el-upload__tip" slot="tip">
|
||||
<el-form ref="uploadForm" :model="upload" size="mini" :rules="rules" label-width="80px">
|
||||
<el-form-item label="流程名称" prop="name">
|
||||
<el-input v-model="upload.name" clearable/>
|
||||
</el-form-item>
|
||||
<el-form-item label="流程分类" prop="category">
|
||||
<el-select v-model="upload.category" placeholder="请选择" clearable style="width:100%">
|
||||
<el-option v-for="item in categoryOptions" :key="item.categoryId" :label="item.categoryName"
|
||||
:value="item.code"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“bpmn20.xml”格式文件!</div>
|
||||
</el-upload>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitFileForm">确 定</el-button>
|
||||
<el-button @click="cancel('uploadForm')">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 流程图 -->
|
||||
<el-dialog :title="processView.title" :visible.sync="processView.open" width="70%" append-to-body>
|
||||
<process-viewer :key="`designer-${processView.index}`" :xml="processView.xmlData" :style="{height: '400px'}" />
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog title="模型历史" :visible.sync="history.open" width="70%" >
|
||||
<el-table v-loading="history.loading" fit :data="historyList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="模型标识" align="center" prop="modelKey" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="模型名称" align="center" :show-overflow-tooltip="true">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" @click="handleProcessView(scope.row)">
|
||||
<span>{{ scope.row.modelName }}</span>
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="流程分类" align="center" prop="categoryName" :formatter="categoryFormat" />
|
||||
<el-table-column label="模型版本" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-tag size="medium" >v{{ scope.row.version }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="描述" align="center" prop="description" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180"/>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
type="text"
|
||||
size="mini"
|
||||
icon="el-icon-video-play"
|
||||
v-hasPermi="['workflow:model:designer']"
|
||||
@click.native="handleDeploy(scope.row)"
|
||||
>部署</el-button>
|
||||
<el-button
|
||||
type="text"
|
||||
size="mini"
|
||||
icon="el-icon-star-off"
|
||||
v-hasPermi="['workflow:model:designer']"
|
||||
@click.native="handleLatest(scope.row)"
|
||||
>设为最新</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="historyTotal > 0"
|
||||
:total="historyTotal"
|
||||
:page.sync="queryHistoryParams.pageNum"
|
||||
:limit.sync="queryHistoryParams.pageSize"
|
||||
@pagination="getHistoryList"
|
||||
/>
|
||||
</el-dialog>
|
||||
|
||||
<designer
|
||||
v-if="designerOpen"
|
||||
:modelId="designerData.modelId"
|
||||
:processName="designerData.processName"
|
||||
:processKey="designerData.processKey"
|
||||
@save="submitSave()"
|
||||
@close="designerOpen = false"
|
||||
/>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { exportDeployment, definitionStart } from "@/api/workflow/definition";
|
||||
import { getBpmnXml, listModel, historyModel, latestModel, delModel, deployModel } from "@/api/workflow/model";
|
||||
import { listCategory } from '@/api/workflow/category'
|
||||
import Parser from '@/utils/generator/parser'
|
||||
import ProcessViewer from '@/components/ProcessViewer'
|
||||
import Designer from './designer'
|
||||
import { getToken } from "@/utils/auth";
|
||||
|
||||
export default {
|
||||
name: "Model",
|
||||
components: {
|
||||
Parser,
|
||||
ProcessViewer,
|
||||
Designer
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 流程模型表格数据
|
||||
modelList: [],
|
||||
categoryOptions: [],
|
||||
designerOpen: false,
|
||||
designerData: {
|
||||
modelId: null,
|
||||
processName: null,
|
||||
processKey: null
|
||||
},
|
||||
designerModelId: null,
|
||||
processView: {
|
||||
title: '',
|
||||
open: false,
|
||||
index: undefined,
|
||||
xmlData:"",
|
||||
},
|
||||
// bpmn.xml 导入
|
||||
upload: {
|
||||
// 是否显示弹出层(xml导入)
|
||||
open: false,
|
||||
// 弹出层标题(xml导入)
|
||||
title: "",
|
||||
// 是否禁用上传
|
||||
isUploading: false,
|
||||
name: null,
|
||||
category: null,
|
||||
// 设置上传的请求头部
|
||||
headers: { Authorization: "Bearer " + getToken() },
|
||||
// 上传的地址
|
||||
url: process.env.VUE_APP_BASE_API + "/workflow/definition/import"
|
||||
},
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
modelKey: null,
|
||||
modelName: null,
|
||||
category: null
|
||||
},
|
||||
currentRow: null,
|
||||
// 表单校验
|
||||
rules: {
|
||||
name: [
|
||||
{ required: true, message: "流程定义名称不能为空", trigger: "blur" }
|
||||
],
|
||||
category: [{
|
||||
required: true,
|
||||
message: '请选择任意一项',
|
||||
trigger: 'change'
|
||||
}],
|
||||
},
|
||||
history: {
|
||||
open: false,
|
||||
loading: false
|
||||
},
|
||||
historyList: [],
|
||||
historyTotal: 0,
|
||||
queryHistoryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
modelKey: null
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getCategoryList();
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询流程分类列表 */
|
||||
getCategoryList() {
|
||||
listCategory().then(response => this.categoryOptions = response.rows)
|
||||
},
|
||||
/** 查询流程模型列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listModel(this.queryParams).then(response => {
|
||||
this.modelList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 点击取消时关闭dialog并且清空form表格的数据
|
||||
cancel (form) {
|
||||
// 重置form表单
|
||||
this.$refs['upload'].clearFiles()
|
||||
// 关闭dialog
|
||||
this.upload.open = false
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.modelId)
|
||||
this.single = selection.length !== 1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 启动流程 */
|
||||
handleDefinitionStart(row){
|
||||
definitionStart(row.id).then(response =>{
|
||||
this.$modal.msgSuccess(response.msg);
|
||||
})
|
||||
},
|
||||
/** 部署流程 */
|
||||
handleDeploy(row) {
|
||||
this.loading = true;
|
||||
deployModel({
|
||||
modelId: row.modelId
|
||||
}).then(response => {
|
||||
this.$modal.msgSuccess(response.msg)
|
||||
}).finally(() => {
|
||||
this.loading = false;
|
||||
})
|
||||
},
|
||||
/** 查看流程图 */
|
||||
handleProcessView(row) {
|
||||
let modelId = row.modelId;
|
||||
this.processView.title = "流程图";
|
||||
this.processView.index = modelId;
|
||||
// 发送请求,获取xml
|
||||
getBpmnXml(modelId).then(response => {
|
||||
this.processView.xmlData = response.data;
|
||||
})
|
||||
this.processView.open = true;
|
||||
},
|
||||
getHistoryList() {
|
||||
this.history.loading = true;
|
||||
historyModel(this.queryHistoryParams).then(response => {
|
||||
this.historyTotal = response.total;
|
||||
this.historyList = response.rows;
|
||||
this.history.loading = false;
|
||||
})
|
||||
},
|
||||
handleHistory(row) {
|
||||
this.history.open = true;
|
||||
this.queryHistoryParams.modelKey = row.modelKey;
|
||||
this.getHistoryList();
|
||||
},
|
||||
/** 设为最新版 */
|
||||
handleLatest(row) {
|
||||
this.$modal.confirm('是否确认将此版本设为最新?').then(() => {
|
||||
this.history.loading = true;
|
||||
latestModel({
|
||||
modelId: row.modelId
|
||||
}).then(response => {
|
||||
this.history.open = false;
|
||||
this.getList();
|
||||
this.$modal.msgSuccess(response.msg);
|
||||
}).finally(() => {
|
||||
this.history.loading = false;
|
||||
})
|
||||
})
|
||||
},
|
||||
handleCurrentChange(data) {
|
||||
if (data) {
|
||||
this.currentRow = JSON.parse(data.content);
|
||||
}
|
||||
},
|
||||
handleAdd() {
|
||||
const dateTime = new Date().getTime();
|
||||
this.designerData = {
|
||||
processKey: `Process_${dateTime}`,
|
||||
processName: `业务流程_${dateTime}`
|
||||
}
|
||||
this.designerOpen = true;
|
||||
},
|
||||
/** 设计按钮操作 */
|
||||
handleDesigner(row) {
|
||||
this.designerData.modelId = row.modelId;
|
||||
this.designerOpen = true;
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const modelIds = row.modelId || this.ids;
|
||||
this.$modal.confirm('是否确认删除模型编号为"' + modelIds + '"的数据项?').then(() => {
|
||||
this.loading = true;
|
||||
return delModel(modelIds);
|
||||
}).then(() => {
|
||||
this.loading = false;
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).finally(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
const queryParams = this.queryParams;
|
||||
this.$confirm('是否确认导出所有流程定义数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function() {
|
||||
return exportDeployment(queryParams);
|
||||
}).then(response => {
|
||||
this.download(response.msg);
|
||||
})
|
||||
},
|
||||
/** 导入bpmn.xml文件 */
|
||||
handleImport() {
|
||||
this.upload.title = "bpmn20.xml文件导入";
|
||||
this.upload.open = true;
|
||||
},
|
||||
// 文件上传中处理
|
||||
handleFileUploadProgress(event, file, fileList) {
|
||||
this.upload.isUploading = true;
|
||||
},
|
||||
// 文件上传成功处理
|
||||
handleFileSuccess(response, file, fileList) {
|
||||
this.upload.open = false;
|
||||
this.upload.isUploading = false;
|
||||
this.$refs.upload.clearFiles();
|
||||
this.$message.success(response.msg);
|
||||
this.getList();
|
||||
},
|
||||
// 提交上传文件
|
||||
submitFileForm() {
|
||||
this.$refs.uploadForm.validate(valid => {
|
||||
if (valid) {
|
||||
this.$refs.upload.submit();
|
||||
}
|
||||
});
|
||||
},
|
||||
categoryFormat(row, column) {
|
||||
return this.categoryOptions.find(k => k.code === row.category)?.categoryName ?? '';
|
||||
},
|
||||
submitSave() {
|
||||
this.getList();
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user