mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-23 07:41:53 +08:00
增加流程定义的 VO
This commit is contained in:
parent
a0c7692c3c
commit
dc7a434380
@ -1,15 +1,15 @@
|
|||||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.model;
|
package cn.iocoder.yudao.adminserver.modules.bpm.controller.model;
|
||||||
|
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp;
|
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.ModelPageReqVO;
|
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelCreateReqVO;
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelCreateReqVO;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.workflow.BpmModelService;
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelRespVO;
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.ModelPageReqVO;
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp;
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.service.model.BpmModelService;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.activiti.engine.repository.Model;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ public class BpmModelController {
|
|||||||
|
|
||||||
@GetMapping ("/page")
|
@GetMapping ("/page")
|
||||||
@ApiOperation(value = "分页数据")
|
@ApiOperation(value = "分页数据")
|
||||||
public CommonResult<PageResult<Model>> getModelPage(ModelPageReqVO pageVO) {
|
public CommonResult<PageResult<BpmModelRespVO>> getModelPage(ModelPageReqVO pageVO) {
|
||||||
return success(bpmModelService.getModelPage(pageVO));
|
return success(bpmModelService.getModelPage(pageVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 流程定义 Base VO,提供给添加、修改、详细的子 VO 使用
|
* 流程定义 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||||
@ -12,6 +13,10 @@ import javax.validation.constraints.NotEmpty;
|
|||||||
@Data
|
@Data
|
||||||
public class BpmModelBaseVO {
|
public class BpmModelBaseVO {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "流程标识", required = true, example = "process_yudao")
|
||||||
|
@NotEmpty(message = "流程标识不能为空")
|
||||||
|
private String key;
|
||||||
|
|
||||||
@ApiModelProperty(value = "流程名称", required = true, example = "芋道")
|
@ApiModelProperty(value = "流程名称", required = true, example = "芋道")
|
||||||
@NotEmpty(message = "流程名称不能为空")
|
@NotEmpty(message = "流程名称不能为空")
|
||||||
private String name;
|
private String name;
|
||||||
@ -20,4 +25,12 @@ public class BpmModelBaseVO {
|
|||||||
@NotEmpty(message = "流程描述不能为空")
|
@NotEmpty(message = "流程描述不能为空")
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "流程分类", notes = "参见 bpm_model_category 数据字典", example = "1")
|
||||||
|
@NotEmpty(message = "流程分类不能为空")
|
||||||
|
private String category;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "表单编号", example = "1024")
|
||||||
|
@NotNull(message = "表单编号不能为空")
|
||||||
|
private Long formId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,10 +14,6 @@ import javax.validation.constraints.NotEmpty;
|
|||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
public class BpmModelCreateReqVO extends BpmModelBaseVO {
|
public class BpmModelCreateReqVO extends BpmModelBaseVO {
|
||||||
|
|
||||||
@ApiModelProperty(value = "流程标识", required = true, example = "process_yudao")
|
|
||||||
@NotEmpty(message = "流程标识不能为空")
|
|
||||||
private String key;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "BPMN XML", required = true)
|
@ApiModelProperty(value = "BPMN XML", required = true)
|
||||||
@NotEmpty(message = "BPMN XML 不能为空")
|
@NotEmpty(message = "BPMN XML 不能为空")
|
||||||
private String bpmnXml;
|
private String bpmnXml;
|
||||||
|
@ -6,6 +6,8 @@ import lombok.Data;
|
|||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
@ApiModel("流程定义 Response VO")
|
@ApiModel("流程定义 Response VO")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@ -15,4 +17,13 @@ public class BpmModelRespVO extends BpmModelBaseVO {
|
|||||||
@ApiModelProperty(value = "编号", required = true, example = "1024")
|
@ApiModelProperty(value = "编号", required = true, example = "1024")
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "版本", required = true, example = "1")
|
||||||
|
private Integer revision;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "表单名字", example = "请假表单")
|
||||||
|
private String formName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建时间", required = true)
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,72 @@
|
|||||||
|
package cn.iocoder.yudao.adminserver.modules.bpm.convert.model;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelCreateReqVO;
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelRespVO;
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO;
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.service.model.dto.BpmModelMetaInfoRespDTO;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||||
|
import org.activiti.engine.impl.persistence.entity.ModelEntity;
|
||||||
|
import org.activiti.engine.repository.Model;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流程定义 Convert
|
||||||
|
*
|
||||||
|
* @author yunlongn
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface ModelConvert {
|
||||||
|
|
||||||
|
ModelConvert INSTANCE = Mappers.getMapper(ModelConvert.class);
|
||||||
|
|
||||||
|
default List<BpmModelRespVO> convertList(List<Model> list, Map<Long, BpmFormDO> formMap) {
|
||||||
|
return CollectionUtils.convertList(list, model -> {
|
||||||
|
BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class);
|
||||||
|
BpmFormDO form = metaInfo != null ? formMap.get(metaInfo.getFormId()) : null;
|
||||||
|
return convert(model, form);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
default BpmModelRespVO convert(Model model, BpmFormDO form) {
|
||||||
|
BpmModelRespVO modelRespVO = new BpmModelRespVO();
|
||||||
|
modelRespVO.setId(model.getId());
|
||||||
|
modelRespVO.setName(model.getName());
|
||||||
|
modelRespVO.setKey(model.getKey());
|
||||||
|
modelRespVO.setCategory(model.getCategory());
|
||||||
|
modelRespVO.setCreateTime(model.getCreateTime());
|
||||||
|
BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class);
|
||||||
|
if (metaInfo != null) {
|
||||||
|
modelRespVO.setDescription(metaInfo.getDescription());
|
||||||
|
}
|
||||||
|
if (form != null) {
|
||||||
|
modelRespVO.setFormId(form.getId());
|
||||||
|
modelRespVO.setFormName(form.getName());
|
||||||
|
}
|
||||||
|
if (model instanceof ModelEntity) {
|
||||||
|
ModelEntity modelEntity = (ModelEntity) model;
|
||||||
|
modelRespVO.setRevision(modelEntity.getRevision());
|
||||||
|
}
|
||||||
|
return modelRespVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
default void copy(Model model, BpmModelCreateReqVO bean) {
|
||||||
|
model.setName(bean.getName());
|
||||||
|
model.setKey(bean.getKey());
|
||||||
|
model.setCategory(bean.getCategory());
|
||||||
|
model.setMetaInfo(JsonUtils.toJsonString(this.buildMetaInfo(bean.getDescription(), bean.getFormId())));
|
||||||
|
}
|
||||||
|
|
||||||
|
default BpmModelMetaInfoRespDTO buildMetaInfo(String description, Long formId) {
|
||||||
|
BpmModelMetaInfoRespDTO metaInfo = new BpmModelMetaInfoRespDTO();
|
||||||
|
metaInfo.setDescription(description);
|
||||||
|
metaInfo.setFormId(formId);
|
||||||
|
return metaInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,17 +0,0 @@
|
|||||||
package cn.iocoder.yudao.adminserver.modules.bpm.convert.workflow;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelRespVO;
|
|
||||||
import org.activiti.engine.repository.Model;
|
|
||||||
import org.mapstruct.Mapper;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author yunlongn
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface ModelConvert {
|
|
||||||
ModelConvert INSTANCE = Mappers.getMapper(ModelConvert.class);
|
|
||||||
|
|
||||||
BpmModelRespVO convert(Model model);
|
|
||||||
}
|
|
@ -5,32 +5,34 @@ import cn.iocoder.yudao.framework.common.exception.ErrorCode;
|
|||||||
/**
|
/**
|
||||||
* 工作流 错误码枚举类
|
* 工作流 错误码枚举类
|
||||||
*
|
*
|
||||||
* 工作流系统,使用 1-003-000-000 段
|
* 工作流系统,使用 1-009-000-000 段
|
||||||
*/
|
*/
|
||||||
public interface BpmErrorCodeConstants {
|
public interface BpmErrorCodeConstants {
|
||||||
|
|
||||||
// ========== 通用流程处理 模块 1-003-000-000 ==========
|
// ========== 通用流程处理 模块 1-009-000-000 ==========
|
||||||
ErrorCode PROCESS_INSTANCE_NOT_EXISTS = new ErrorCode(1003000001, "流程实例不存在");
|
ErrorCode PROCESS_INSTANCE_NOT_EXISTS = new ErrorCode(1009000001, "流程实例不存在");
|
||||||
ErrorCode HIGHLIGHT_IMG_ERROR = new ErrorCode(1003000002, "获取高亮流程图异常");
|
ErrorCode HIGHLIGHT_IMG_ERROR = new ErrorCode(1009000002, "获取高亮流程图异常");
|
||||||
|
|
||||||
|
|
||||||
// ========== OA 流程模块 1-003-001-000 ==========
|
// ========== OA 流程模块 1-009-001-000 ==========
|
||||||
ErrorCode OA_LEAVE_NOT_EXISTS = new ErrorCode(1003001001, "请假申请不存在");
|
ErrorCode OA_LEAVE_NOT_EXISTS = new ErrorCode(1009001001, "请假申请不存在");
|
||||||
ErrorCode OA_PM_POST_NOT_EXISTS = new ErrorCode(1003001002, "项目经理岗位未设置");
|
ErrorCode OA_PM_POST_NOT_EXISTS = new ErrorCode(1009001002, "项目经理岗位未设置");
|
||||||
ErrorCode OA_DEPART_PM_POST_NOT_EXISTS = new ErrorCode(1003001003, "部门的项目经理不存在");
|
ErrorCode OA_DEPART_PM_POST_NOT_EXISTS = new ErrorCode(1009001009, "部门的项目经理不存在");
|
||||||
ErrorCode OA_BM_POST_NOT_EXISTS = new ErrorCode(1003001004, "部门经理岗位未设置");
|
ErrorCode OA_BM_POST_NOT_EXISTS = new ErrorCode(1009001004, "部门经理岗位未设置");
|
||||||
ErrorCode OA_DEPART_BM_POST_NOT_EXISTS = new ErrorCode(1003001005, "部门的部门经理不存在");
|
ErrorCode OA_DEPART_BM_POST_NOT_EXISTS = new ErrorCode(1009001005, "部门的部门经理不存在");
|
||||||
ErrorCode OA_HR_POST_NOT_EXISTS = new ErrorCode(1003001006, "HR岗位未设置");
|
ErrorCode OA_HR_POST_NOT_EXISTS = new ErrorCode(1009001006, "HR岗位未设置");
|
||||||
ErrorCode OA_DAY_LEAVE_ERROR = new ErrorCode(1003001007, "请假天数必须>=1");
|
ErrorCode OA_DAY_LEAVE_ERROR = new ErrorCode(1009001007, "请假天数必须>=1");
|
||||||
|
|
||||||
|
// ========== OA 工作流模块 1-009-002-000 ==========
|
||||||
|
ErrorCode BPM_MODEL_KEY_EXISTS = new ErrorCode(1009002000, "已经存在流程标识为【{}】的流程");
|
||||||
|
|
||||||
// ========== OA 工作流模块 1-003-002-000 ==========
|
|
||||||
ErrorCode BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS = new ErrorCode(1004001001, "模型数据为空,请先成功设计流程并保存");
|
ErrorCode BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS = new ErrorCode(1004001001, "模型数据为空,请先成功设计流程并保存");
|
||||||
ErrorCode BPMN_MODEL_ERROR = new ErrorCode(1004001002, "工作流模型异常");
|
ErrorCode BPMN_MODEL_ERROR = new ErrorCode(1004001002, "工作流模型异常");
|
||||||
ErrorCode BPMN_MODEL_PROCESS_NOT_EXISTS = new ErrorCode(1004001003, "流程数据为空");
|
ErrorCode BPMN_MODEL_PROCESS_NOT_EXISTS = new ErrorCode(1004001009, "流程数据为空");
|
||||||
ErrorCode BPMN_PROCESS_DEFINITION_NOT_EXISTS = new ErrorCode(1004001004, "流程定义不存在");
|
ErrorCode BPMN_PROCESS_DEFINITION_NOT_EXISTS = new ErrorCode(1004001004, "流程定义不存在");
|
||||||
|
|
||||||
// ========== 动态表单模块 1-003-003-000 ==========
|
// ========== 动态表单模块 1-009-003-000 ==========
|
||||||
ErrorCode BPM_FORM_NOT_EXISTS = new ErrorCode(1003003000, "动态表单不存在");
|
ErrorCode BPM_FORM_NOT_EXISTS = new ErrorCode(1009003000, "动态表单不存在");
|
||||||
ErrorCode BPM_FORM_FIELD_REPEAT = new ErrorCode(1003003000, "表单项({}) 和 ({}) 使用了相同的字段名({})");
|
ErrorCode BPM_FORM_FIELD_REPEAT = new ErrorCode(1009003000, "表单项({}) 和 ({}) 使用了相同的字段名({})");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,18 @@
|
|||||||
package cn.iocoder.yudao.adminserver.modules.bpm.service.form;
|
package cn.iocoder.yudao.adminserver.modules.bpm.service.form;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormCreateReqVO;
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormCreateReqVO;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormPageReqVO;
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormPageReqVO;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormUpdateReqVO;
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormUpdateReqVO;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO;
|
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,6 +60,19 @@ public interface BpmFormService {
|
|||||||
*/
|
*/
|
||||||
List<BpmFormDO> getFormList(Collection<Long> ids);
|
List<BpmFormDO> getFormList(Collection<Long> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得动态表单 Map
|
||||||
|
*
|
||||||
|
* @param ids 编号
|
||||||
|
* @return 动态表单 Map
|
||||||
|
*/
|
||||||
|
default Map<Long, BpmFormDO> getFormMap(Collection<Long> ids) {
|
||||||
|
if (CollUtil.isEmpty(ids)) {
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
|
return CollectionUtils.convertMap(this.getFormList(ids), BpmFormDO::getId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得动态表单分页
|
* 获得动态表单分页
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package cn.iocoder.yudao.adminserver.modules.bpm.service.workflow;
|
package cn.iocoder.yudao.adminserver.modules.bpm.service.model;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelRespVO;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp;
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.ModelPageReqVO;
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.ModelPageReqVO;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelCreateReqVO;
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelCreateReqVO;
|
||||||
@ -20,7 +21,7 @@ public interface BpmModelService {
|
|||||||
* @param pageVO 分页查询
|
* @param pageVO 分页查询
|
||||||
* @return 流程定义分页
|
* @return 流程定义分页
|
||||||
*/
|
*/
|
||||||
PageResult<Model> getModelPage(ModelPageReqVO pageVO);
|
PageResult<BpmModelRespVO> getModelPage(ModelPageReqVO pageVO);
|
||||||
|
|
||||||
// TODO @Li:不用返回 CommonResult
|
// TODO @Li:不用返回 CommonResult
|
||||||
// TODO @Li:createBpmModal。
|
// TODO @Li:createBpmModal。
|
@ -0,0 +1,23 @@
|
|||||||
|
package cn.iocoder.yudao.adminserver.modules.bpm.service.model.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BPM 流程 MetaInfo Response DTO
|
||||||
|
* 主要用于 {@link org.activiti.engine.repository.Model#setMetaInfo(String)} 的存储
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class BpmModelMetaInfoRespDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流程描述
|
||||||
|
*/
|
||||||
|
private String description;
|
||||||
|
/**
|
||||||
|
* 表单编号
|
||||||
|
*/
|
||||||
|
private Long formId;
|
||||||
|
|
||||||
|
}
|
@ -2,13 +2,18 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.workflow.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelCreateReqVO;
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelCreateReqVO;
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelRespVO;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.ModelPageReqVO;
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.ModelPageReqVO;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp;
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp;
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.convert.model.ModelConvert;
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants;
|
import cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.workflow.BpmModelService;
|
import cn.iocoder.yudao.adminserver.modules.bpm.service.form.BpmFormService;
|
||||||
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
|
import cn.iocoder.yudao.adminserver.modules.bpm.service.model.BpmModelService;
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.service.model.dto.BpmModelMetaInfoRespDTO;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.PageUtils;
|
import cn.iocoder.yudao.framework.common.util.object.PageUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -20,6 +25,7 @@ import org.activiti.engine.repository.Model;
|
|||||||
import org.activiti.engine.repository.ModelQuery;
|
import org.activiti.engine.repository.ModelQuery;
|
||||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
@ -30,7 +36,12 @@ import java.io.ByteArrayInputStream;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.BPM_MODEL_KEY_EXISTS;
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 流程定义实现
|
* 流程定义实现
|
||||||
@ -44,9 +55,11 @@ public class BpmModelServiceImpl implements BpmModelService {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private RepositoryService repositoryService;
|
private RepositoryService repositoryService;
|
||||||
|
@Resource
|
||||||
|
private BpmFormService bpmFormService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<Model> getModelPage(ModelPageReqVO pageVO) {
|
public PageResult<BpmModelRespVO> getModelPage(ModelPageReqVO pageVO) {
|
||||||
ModelQuery modelQuery = repositoryService.createModelQuery();
|
ModelQuery modelQuery = repositoryService.createModelQuery();
|
||||||
if (StrUtil.isNotBlank(pageVO.getName())) {
|
if (StrUtil.isNotBlank(pageVO.getName())) {
|
||||||
modelQuery.modelNameLike("%" + pageVO.getName() + "%"); // 模糊匹配
|
modelQuery.modelNameLike("%" + pageVO.getName() + "%"); // 模糊匹配
|
||||||
@ -55,18 +68,29 @@ public class BpmModelServiceImpl implements BpmModelService {
|
|||||||
List<Model> models = modelQuery.orderByCreateTime().desc()
|
List<Model> models = modelQuery.orderByCreateTime().desc()
|
||||||
.listPage(PageUtils.getStart(pageVO), pageVO.getPageSize());
|
.listPage(PageUtils.getStart(pageVO), pageVO.getPageSize());
|
||||||
long modelCount = modelQuery.count();
|
long modelCount = modelQuery.count();
|
||||||
return new PageResult<>(models, modelCount);
|
|
||||||
|
// 获得 Form Map
|
||||||
|
Set<Long> formIds = CollectionUtils.convertSet(models, model -> {
|
||||||
|
BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class);
|
||||||
|
return metaInfo != null ? metaInfo.getFormId() : null;
|
||||||
|
});
|
||||||
|
Map<Long, BpmFormDO> formMap = bpmFormService.getFormMap(formIds);
|
||||||
|
// 拼接结果
|
||||||
|
return new PageResult<>(ModelConvert.INSTANCE.convertList(models, formMap), modelCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class) // 因为进行多个 activiti 操作,所以开启事务
|
||||||
public String createModel(BpmModelCreateReqVO createReqVO) {
|
public String createModel(BpmModelCreateReqVO createReqVO) {
|
||||||
// TODO 芋艿:校验 key 是否重复
|
// 校验流程标识已经存在
|
||||||
|
Model keyModel = this.getModelByKey(createReqVO.getKey());
|
||||||
|
if (keyModel != null) {
|
||||||
|
throw exception(BPM_MODEL_KEY_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
// 创建流程定义
|
// 创建流程定义
|
||||||
Model model = repositoryService.newModel();
|
Model model = repositoryService.newModel();
|
||||||
model.setName(createReqVO.getName());
|
ModelConvert.INSTANCE.copy(model, createReqVO);
|
||||||
model.setKey(createReqVO.getKey());
|
|
||||||
// TODO 芋艿:metaInfo,description、category、formId
|
|
||||||
model.setMetaInfo(JsonUtils.toJsonString(createReqVO));
|
|
||||||
// 保存流程定义
|
// 保存流程定义
|
||||||
repositoryService.saveModel(model);
|
repositoryService.saveModel(model);
|
||||||
// 添加 BPMN XML
|
// 添加 BPMN XML
|
||||||
@ -109,11 +133,11 @@ public class BpmModelServiceImpl implements BpmModelService {
|
|||||||
try {
|
try {
|
||||||
Model modelData = repositoryService.getModel(modelId);
|
Model modelData = repositoryService.getModel(modelId);
|
||||||
if (ObjectUtils.isEmpty(modelData)) {
|
if (ObjectUtils.isEmpty(modelData)) {
|
||||||
throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS);
|
throw exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
byte[] bytes = repositoryService.getModelEditorSource(modelData.getId());
|
byte[] bytes = repositoryService.getModelEditorSource(modelData.getId());
|
||||||
if (bytes == null) {
|
if (bytes == null) {
|
||||||
throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS);
|
throw exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
// 将xml转换为流
|
// 将xml转换为流
|
||||||
// TODO @Li:这里是标准逻辑,看看 hutool 有没工具类提供。如果没有,咱自己封装一个
|
// TODO @Li:这里是标准逻辑,看看 hutool 有没工具类提供。如果没有,咱自己封装一个
|
||||||
@ -124,7 +148,7 @@ public class BpmModelServiceImpl implements BpmModelService {
|
|||||||
// 流数据转化为 model
|
// 流数据转化为 model
|
||||||
BpmnModel model = new BpmnXMLConverter().convertToBpmnModel(xtr);
|
BpmnModel model = new BpmnXMLConverter().convertToBpmnModel(xtr);
|
||||||
if(ObjectUtils.isEmpty(model.getProcesses())){
|
if(ObjectUtils.isEmpty(model.getProcesses())){
|
||||||
throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_PROCESS_NOT_EXISTS);
|
throw exception(BpmErrorCodeConstants.BPMN_MODEL_PROCESS_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
byte[] bpmnBytes = new BpmnXMLConverter().convertToXML(model);
|
byte[] bpmnBytes = new BpmnXMLConverter().convertToXML(model);
|
||||||
// 部署发布模型流程
|
// 部署发布模型流程
|
||||||
@ -137,7 +161,7 @@ public class BpmModelServiceImpl implements BpmModelService {
|
|||||||
return CommonResult.success(deployment.getId());
|
return CommonResult.success(deployment.getId());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.info("模型部署失败!modelId = {} e = {} ", modelId, ExceptionUtils.getStackTrace(e));
|
log.info("模型部署失败!modelId = {} e = {} ", modelId, ExceptionUtils.getStackTrace(e));
|
||||||
throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_ERROR);
|
throw exception(BpmErrorCodeConstants.BPMN_MODEL_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +170,7 @@ public class BpmModelServiceImpl implements BpmModelService {
|
|||||||
try {
|
try {
|
||||||
Model modelData = repositoryService.getModel(modelId);
|
Model modelData = repositoryService.getModel(modelId);
|
||||||
if (ObjectUtils.isEmpty(modelData)) {
|
if (ObjectUtils.isEmpty(modelData)) {
|
||||||
throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS);
|
throw exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
byte[] bytes = repositoryService.getModelEditorSource(modelData.getId());
|
byte[] bytes = repositoryService.getModelEditorSource(modelData.getId());
|
||||||
FileResp fileResp = new FileResp();
|
FileResp fileResp = new FileResp();
|
||||||
@ -155,7 +179,7 @@ public class BpmModelServiceImpl implements BpmModelService {
|
|||||||
return fileResp;
|
return fileResp;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.info("模型部署失败!modelId = {} e = {} ", modelId, ExceptionUtils.getStackTrace(e));
|
log.info("模型部署失败!modelId = {} e = {} ", modelId, ExceptionUtils.getStackTrace(e));
|
||||||
throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_ERROR);
|
throw exception(BpmErrorCodeConstants.BPMN_MODEL_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,4 +190,8 @@ public class BpmModelServiceImpl implements BpmModelService {
|
|||||||
return CommonResult.success("删除成功");
|
return CommonResult.success("删除成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Model getModelByKey(String key) {
|
||||||
|
return repositoryService.createModelQuery().modelKey(key).singleResult();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
|
|
||||||
|
<!-- 搜索工作栏 -->
|
||||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
<el-form-item label="模型名字" prop="name">
|
<el-form-item label="模型名字" prop="name">
|
||||||
<el-input v-model="queryParams.name" placeholder="请输入模型名字" clearable style="width: 240px;" size="small"
|
<el-input v-model="queryParams.name" placeholder="请输入模型名字" clearable style="width: 240px;" size="small"
|
||||||
@ -10,36 +12,31 @@
|
|||||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
|
<!-- 操作工具栏 -->
|
||||||
<el-row :gutter="10" class="mb8">
|
<el-row :gutter="10" class="mb8">
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button type="primary" icon="el-icon-plus" size="mini" @click="openBpmn"
|
||||||
type="primary"
|
v-hasPermi="['infra:config:create']">新建流程</el-button>
|
||||||
icon="el-icon-plus"
|
|
||||||
size="mini"
|
|
||||||
@click="openBpmn"
|
|
||||||
v-hasPermi="['infra:config:create']"
|
|
||||||
>新建流程</el-button>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
|
<!-- 列表 -->
|
||||||
<el-table v-loading="loading" :data="list">
|
<el-table v-loading="loading" :data="list">
|
||||||
<el-table-column label="ID" align="center" prop="id" />
|
<el-table-column label="流程编号" align="center" prop="id" :show-overflow-tooltip="true" />
|
||||||
<el-table-column label="name" align="center" prop="metaInfo" >
|
<el-table-column label="流程标识" align="center" prop="key" />
|
||||||
<template slot-scope="scope">
|
<el-table-column label="流程名称" align="center" prop="name" />
|
||||||
<span>{{ scope.row.metaInfo ? JSON.parse(scope.row.metaInfo).name : "" }}</span>
|
<el-table-column label="流程分类" align="center" prop="category" />
|
||||||
</template>
|
<el-table-column label="表单信息" align="center" prop="formName" />
|
||||||
</el-table-column>
|
<el-table-column label="流程版本" align="center" prop="revision" />
|
||||||
<el-table-column label="description" align="center" prop="metaInfo" >
|
<el-table-column label="状态" align="center" prop="rversion" />
|
||||||
<template slot-scope="scope">
|
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||||
<span>{{ JSON.parse(scope.row.metaInfo).description }}</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" >
|
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<span>{{ parseTime(scope.row.createTime) }}</span>
|
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" align="center" >
|
<el-table-column label="操作" align="center" width="240">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button size="mini" type="text" icon="el-icon-setting" @click="change(scope.row)">设计流程</el-button>
|
<el-button size="mini" type="text" icon="el-icon-setting" @click="change(scope.row)">设计流程</el-button>
|
||||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="modelDelete(scope.row)">删除</el-button>
|
<el-button size="mini" type="text" icon="el-icon-delete" @click="modelDelete(scope.row)">删除</el-button>
|
||||||
|
Loading…
Reference in New Issue
Block a user