新增 bpm 基于流程实例的详情 API 接口
parent
23eda6b1a9
commit
93e02b36dd
|
@ -23,7 +23,7 @@ Authorization: Bearer {{token}}
|
||||||
"reason": "我就取消"
|
"reason": "我就取消"
|
||||||
}
|
}
|
||||||
|
|
||||||
### 请求 /bpm/process-instance/my-page 接口 => 成功
|
### 请求 /bpm/process-instance/get 接口 => 成功
|
||||||
GET {{baseUrl}}/bpm/process-instance/my-page
|
GET {{baseUrl}}/bpm/process-instance/get?id=537cceb3-768c-11ec-afcd-a2380e71991a
|
||||||
tenant-id: 1
|
tenant-id: 1
|
||||||
Authorization: Bearer {{token}}
|
Authorization: Bearer {{token}}
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task;
|
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task;
|
||||||
|
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstanceCancelReqVO;
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.*;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstanceCreateReqVO;
|
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstanceMyPageReqVO;
|
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstancePageItemRespVO;
|
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmProcessInstanceService;
|
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmProcessInstanceService;
|
||||||
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 io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
@ -49,4 +47,11 @@ public class BpmProcessInstanceController {
|
||||||
return success(processInstanceService.getMyProcessInstancePage(getLoginUserId(), pageReqVO));
|
return success(processInstanceService.getMyProcessInstancePage(getLoginUserId(), pageReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@ApiOperation(value = "获得指定流程实例", notes = "在【流程详细】界面中,进行调用")
|
||||||
|
@ApiImplicitParam(name = "id", value = "流程实例的编号", required = true, dataTypeClass = String.class)
|
||||||
|
public CommonResult<BpmProcessInstanceRespVO> getProcessInstance(@RequestParam("id") String id) {
|
||||||
|
return success(processInstanceService.getProcessInstanceVO(id));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ 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.ApiImplicitParam;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
@ -57,7 +58,8 @@ public class BpmTaskController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/list-by-process-instance-id")
|
@GetMapping("/list-by-process-instance-id")
|
||||||
@ApiOperation(value = "获得指定流程实例的任务列表", notes = "包括完成的、未完成的") // TODO 芋艿:注解
|
@ApiOperation(value = "获得指定流程实例的任务列表", notes = "包括完成的、未完成的")
|
||||||
|
@ApiImplicitParam(name = "processInstanceId", value = "流程实例的编号", required = true, dataTypeClass = String.class)
|
||||||
public CommonResult<List<BpmTaskRespVO>> getTaskListByProcessInstanceId(
|
public CommonResult<List<BpmTaskRespVO>> getTaskListByProcessInstanceId(
|
||||||
@RequestParam("processInstanceId") String processInstanceId) {
|
@RequestParam("processInstanceId") String processInstanceId) {
|
||||||
return success(taskService.getTaskListByProcessInstanceId(processInstanceId));
|
return success(taskService.getTaskListByProcessInstanceId(processInstanceId));
|
||||||
|
|
|
@ -0,0 +1,94 @@
|
||||||
|
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ApiModel("流程实例的 Response VO")
|
||||||
|
@Data
|
||||||
|
public class BpmProcessInstanceRespVO {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "流程实例的编号", required = true, example = "1024")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "流程名称", required = true, example = "芋道")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "流程分类", required = true, notes = "参见 bpm_model_category 数据字典", example = "1")
|
||||||
|
private String category;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "流程实例的状态", required = true, notes = "参见 bpm_process_instance_status", example = "1")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "流程实例的结果", required = true, notes = "参见 bpm_process_instance_result", example = "2")
|
||||||
|
private Integer result;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "提交时间", required = true)
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "结束时间", required = true)
|
||||||
|
private Date endTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "提交的表单值", required = true)
|
||||||
|
private Map<String, Object> formVariables;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发起流程的用户
|
||||||
|
*/
|
||||||
|
private User startUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流程定义
|
||||||
|
*/
|
||||||
|
private ProcessDefinition processDefinition;
|
||||||
|
|
||||||
|
@ApiModel("用户信息")
|
||||||
|
@Data
|
||||||
|
public static class User {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "用户编号", required = true, example = "1")
|
||||||
|
private Long id;
|
||||||
|
@ApiModelProperty(value = "用户昵称", required = true, example = "芋艿")
|
||||||
|
private String nickname;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "部门编号", required = true, example = "1")
|
||||||
|
private Long deptId;
|
||||||
|
@ApiModelProperty(value = "部门名称", required = true, example = "研发部")
|
||||||
|
private String deptName;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiModel("流程定义信息")
|
||||||
|
@Data
|
||||||
|
public static class ProcessDefinition {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "编号", required = true, example = "1024")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "表单类型", notes = "参见 bpm_model_form_type 数据字典", example = "1")
|
||||||
|
private Integer formType;
|
||||||
|
@ApiModelProperty(value = "表单编号", example = "1024", notes = "在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空")
|
||||||
|
private Long formId;
|
||||||
|
@ApiModelProperty(value = "表单的配置", required = true,
|
||||||
|
notes = "JSON 字符串。在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空")
|
||||||
|
private String formConf;
|
||||||
|
@ApiModelProperty(value = "表单项的数组", required = true,
|
||||||
|
notes = "JSON 字符串的数组。在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空")
|
||||||
|
private List<String> formFields;
|
||||||
|
@ApiModelProperty(value = "自定义表单的提交路径,使用 Vue 的路由地址", example = "/bpm/oa/leave/create",
|
||||||
|
notes = "在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空")
|
||||||
|
private String formCustomCreatePath;
|
||||||
|
@ApiModelProperty(value = "自定义表单的查看路径,使用 Vue 的路由地址", example = "/bpm/oa/leave/view",
|
||||||
|
notes = "在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空")
|
||||||
|
private String formCustomViewPath;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "BPMN XML", required = true)
|
||||||
|
private String bpmnXml;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,13 +1,20 @@
|
||||||
package cn.iocoder.yudao.adminserver.modules.bpm.convert.task;
|
package cn.iocoder.yudao.adminserver.modules.bpm.convert.task;
|
||||||
|
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstancePageItemRespVO;
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstancePageItemRespVO;
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstanceRespVO;
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.BpmTaskRespVO;
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.task.BpmProcessInstanceExtDO;
|
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.task.BpmProcessInstanceExtDO;
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO;
|
||||||
|
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import org.activiti.engine.history.HistoricProcessInstance;
|
||||||
import org.activiti.engine.repository.ProcessDefinition;
|
import org.activiti.engine.repository.ProcessDefinition;
|
||||||
import org.activiti.engine.runtime.ProcessInstance;
|
import org.activiti.engine.runtime.ProcessInstance;
|
||||||
import org.activiti.engine.task.Task;
|
import org.activiti.engine.task.Task;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mapping;
|
import org.mapstruct.Mapping;
|
||||||
|
import org.mapstruct.MappingTarget;
|
||||||
import org.mapstruct.Mappings;
|
import org.mapstruct.Mappings;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
@ -26,15 +33,20 @@ public interface BpmProcessInstanceConvert {
|
||||||
|
|
||||||
BpmProcessInstanceConvert INSTANCE = Mappers.getMapper(BpmProcessInstanceConvert.class);
|
BpmProcessInstanceConvert INSTANCE = Mappers.getMapper(BpmProcessInstanceConvert.class);
|
||||||
|
|
||||||
|
default BpmProcessInstanceExtDO convert3(ProcessInstance instance, ProcessDefinition definition) {
|
||||||
|
BpmProcessInstanceExtDO ext = new BpmProcessInstanceExtDO();
|
||||||
|
copyTo(instance, ext);
|
||||||
|
copyTo(definition, ext);
|
||||||
|
return ext;
|
||||||
|
}
|
||||||
|
|
||||||
@Mappings({
|
@Mappings({
|
||||||
@Mapping(source = "instance.startUserId", target = "startUserId"),
|
@Mapping(source = "from.id", target = "id", ignore = true),
|
||||||
@Mapping(source = "instance.id", target = "processInstanceId"),
|
@Mapping(source = "from.startTime", target = "createTime"),
|
||||||
@Mapping(source = "instance.startTime", target = "createTime"),
|
|
||||||
@Mapping(source = "definition.id", target = "processDefinitionId"),
|
|
||||||
@Mapping(source = "definition.name", target = "name"),
|
|
||||||
@Mapping(source = "definition.category", target = "category")
|
|
||||||
})
|
})
|
||||||
BpmProcessInstanceExtDO convert(ProcessInstance instance, ProcessDefinition definition);
|
void copyTo(ProcessInstance from, @MappingTarget BpmProcessInstanceExtDO to);
|
||||||
|
@Mapping(source = "from.id", target = "id", ignore = true)
|
||||||
|
void copyTo(ProcessDefinition from, @MappingTarget BpmProcessInstanceExtDO to);
|
||||||
|
|
||||||
default PageResult<BpmProcessInstancePageItemRespVO> convertPage(PageResult<BpmProcessInstanceExtDO> page,
|
default PageResult<BpmProcessInstancePageItemRespVO> convertPage(PageResult<BpmProcessInstanceExtDO> page,
|
||||||
Map<String, List<Task>> taskMap) {
|
Map<String, List<Task>> taskMap) {
|
||||||
|
@ -58,4 +70,31 @@ public interface BpmProcessInstanceConvert {
|
||||||
})
|
})
|
||||||
BpmProcessInstanceExtDO convert(org.activiti.api.process.model.ProcessInstance bean);
|
BpmProcessInstanceExtDO convert(org.activiti.api.process.model.ProcessInstance bean);
|
||||||
|
|
||||||
|
default BpmProcessInstanceRespVO convert2(HistoricProcessInstance processInstance, BpmProcessInstanceExtDO processInstanceExt,
|
||||||
|
ProcessDefinition processDefinition, BpmProcessDefinitionExtDO processDefinitionExt,
|
||||||
|
String bpmnXml, SysUserDO startUser, SysDeptDO dept) {
|
||||||
|
BpmProcessInstanceRespVO respVO = convert2(processInstance);
|
||||||
|
copyTo(processInstanceExt, respVO);
|
||||||
|
// definition
|
||||||
|
respVO.setProcessDefinition(convert2(processDefinition));
|
||||||
|
copyTo(processDefinitionExt, respVO.getProcessDefinition());
|
||||||
|
respVO.getProcessDefinition().setBpmnXml(bpmnXml);
|
||||||
|
// user
|
||||||
|
if (startUser != null) {
|
||||||
|
respVO.setStartUser(convert2(startUser));
|
||||||
|
if (dept != null) {
|
||||||
|
respVO.getStartUser().setDeptName(dept.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return respVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
BpmProcessInstanceRespVO convert2(HistoricProcessInstance bean);
|
||||||
|
@Mapping(source = "from.id", target = "to.id", ignore = true)
|
||||||
|
void copyTo(BpmProcessInstanceExtDO from, @MappingTarget BpmProcessInstanceRespVO to);
|
||||||
|
BpmProcessInstanceRespVO.ProcessDefinition convert2(ProcessDefinition bean);
|
||||||
|
@Mapping(source = "from.id", target = "to.id", ignore = true)
|
||||||
|
void copyTo(BpmProcessDefinitionExtDO from, @MappingTarget BpmProcessInstanceRespVO.ProcessDefinition to);
|
||||||
|
BpmProcessInstanceRespVO.User convert2(SysUserDO bean);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceRes
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceStatusEnum;
|
import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceStatusEnum;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
@ -31,6 +32,11 @@ import java.util.Map;
|
||||||
//@AllArgsConstructor
|
//@AllArgsConstructor
|
||||||
public class BpmProcessInstanceExtDO extends BaseDO {
|
public class BpmProcessInstanceExtDO extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编号,自增
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
/**
|
/**
|
||||||
* 发起流程的用户编号
|
* 发起流程的用户编号
|
||||||
*
|
*
|
||||||
|
@ -82,7 +88,7 @@ public class BpmProcessInstanceExtDO extends BaseDO {
|
||||||
private Date endTime;
|
private Date endTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表单值
|
* 提交的表单值
|
||||||
*/
|
*/
|
||||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||||
private Map<String, Object> formVariables;
|
private Map<String, Object> formVariables;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.definition;
|
package cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.definition;
|
||||||
|
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO;
|
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
@ -9,10 +10,14 @@ import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface BpmProcessDefinitionExtMapper extends BaseMapper<BpmProcessDefinitionExtDO> {
|
public interface BpmProcessDefinitionExtMapper extends BaseMapperX<BpmProcessDefinitionExtDO> {
|
||||||
|
|
||||||
default List<BpmProcessDefinitionExtDO> selectListByProcessDefinitionIds(Collection<String> processDefinitionIds) {
|
default List<BpmProcessDefinitionExtDO> selectListByProcessDefinitionIds(Collection<String> processDefinitionIds) {
|
||||||
return selectList(new QueryWrapper<BpmProcessDefinitionExtDO>().in("process_definition_id", processDefinitionIds));
|
return selectList("process_definition_id", processDefinitionIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
default BpmProcessDefinitionExtDO selectByProcessDefinitionId(String processDefinitionId) {
|
||||||
|
return selectOne("process_definition_id", processDefinitionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,10 @@ public interface BpmProcessInstanceExtMapper extends BaseMapperX<BpmProcessInsta
|
||||||
.orderByDesc("id"));
|
.orderByDesc("id"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default BpmProcessInstanceExtDO selectByProcessInstanceId(String processDefinitionId) {
|
||||||
|
return selectOne("process_instance_id", processDefinitionId);
|
||||||
|
}
|
||||||
|
|
||||||
default void updateByProcessInstanceId(BpmProcessInstanceExtDO updateObj) {
|
default void updateByProcessInstanceId(BpmProcessInstanceExtDO updateObj) {
|
||||||
update(updateObj, new QueryWrapper<BpmProcessInstanceExtDO>()
|
update(updateObj, new QueryWrapper<BpmProcessInstanceExtDO>()
|
||||||
.eq("process_instance_id", updateObj.getProcessInstanceId()));
|
.eq("process_instance_id", updateObj.getProcessInstanceId()));
|
||||||
|
|
|
@ -4,6 +4,7 @@ import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.process
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.process.BpmProcessDefinitionPageItemRespVO;
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.process.BpmProcessDefinitionPageItemRespVO;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.process.BpmProcessDefinitionPageReqVO;
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.process.BpmProcessDefinitionPageReqVO;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.process.BpmProcessDefinitionRespVO;
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.process.BpmProcessDefinitionRespVO;
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO;
|
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO;
|
||||||
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.collection.CollectionUtils;
|
||||||
|
@ -74,6 +75,14 @@ public interface BpmProcessDefinitionService {
|
||||||
*/
|
*/
|
||||||
ProcessDefinition getProcessDefinition2(String id);
|
ProcessDefinition getProcessDefinition2(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得编号对应的 BpmProcessDefinitionExtDO
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 流程定义拓展
|
||||||
|
*/
|
||||||
|
BpmProcessDefinitionExtDO getProcessDefinitionExt(String id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得 id 对应的 Deployment
|
* 获得 id 对应的 Deployment
|
||||||
*
|
*
|
||||||
|
|
|
@ -13,6 +13,7 @@ import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.definition.BpmProcessD
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmProcessDefinitionService;
|
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmProcessDefinitionService;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO;
|
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmFormService;
|
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmFormService;
|
||||||
|
import cn.iocoder.yudao.framework.activiti.core.util.ActivitiUtils;
|
||||||
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.collection.CollectionUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.PageUtils;
|
import cn.iocoder.yudao.framework.common.util.object.PageUtils;
|
||||||
|
@ -51,8 +52,6 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
|
||||||
|
|
||||||
private static final String BPMN_FILE_SUFFIX = ".bpmn";
|
private static final String BPMN_FILE_SUFFIX = ".bpmn";
|
||||||
|
|
||||||
private static final BpmnXMLConverter BPMN_XML_CONVERTER = new BpmnXMLConverter();
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private RepositoryService repositoryService;
|
private RepositoryService repositoryService;
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -122,9 +121,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
|
||||||
if (bpmnModel == null) {
|
if (bpmnModel == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// TODO 芋艿:重构到 activi util 里
|
return ActivitiUtils.getBpmnXml(bpmnModel);
|
||||||
byte[] bpmnBytes = BPMN_XML_CONVERTER.convertToXML(bpmnModel);
|
|
||||||
return StrUtil.utf8Str(bpmnBytes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -142,6 +139,11 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
|
||||||
return repositoryService.createProcessDefinitionQuery().processDefinitionId(id).singleResult();
|
return repositoryService.createProcessDefinitionQuery().processDefinitionId(id).singleResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BpmProcessDefinitionExtDO getProcessDefinitionExt(String id) {
|
||||||
|
return processDefinitionMapper.selectByProcessDefinitionId(id);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Deployment getDeployment(String id) {
|
public Deployment getDeployment(String id) {
|
||||||
if (StrUtil.isEmpty(id)) {
|
if (StrUtil.isEmpty(id)) {
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
package cn.iocoder.yudao.adminserver.modules.bpm.service.task;
|
package cn.iocoder.yudao.adminserver.modules.bpm.service.task;
|
||||||
|
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstanceCancelReqVO;
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.*;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstanceCreateReqVO;
|
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstanceMyPageReqVO;
|
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstancePageItemRespVO;
|
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceDeleteReasonEnum;
|
import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceDeleteReasonEnum;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceResultEnum;
|
import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceResultEnum;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
@ -68,6 +65,14 @@ public interface BpmProcessInstanceService {
|
||||||
PageResult<BpmProcessInstancePageItemRespVO> getMyProcessInstancePage(Long userId,
|
PageResult<BpmProcessInstancePageItemRespVO> getMyProcessInstancePage(Long userId,
|
||||||
@Valid BpmProcessInstanceMyPageReqVO pageReqVO);
|
@Valid BpmProcessInstanceMyPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得流程实例 VO 信息
|
||||||
|
*
|
||||||
|
* @param id 流程实例的编号
|
||||||
|
* @return 流程实例
|
||||||
|
*/
|
||||||
|
BpmProcessInstanceRespVO getProcessInstanceVO(String id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得流程实例
|
* 获得流程实例
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
package cn.iocoder.yudao.adminserver.modules.bpm.service.task.impl;
|
package cn.iocoder.yudao.adminserver.modules.bpm.service.task.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstanceCancelReqVO;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstanceCreateReqVO;
|
import cn.hutool.core.util.NumberUtil;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstanceMyPageReqVO;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstancePageItemRespVO;
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.*;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.convert.task.BpmProcessInstanceConvert;
|
import cn.iocoder.yudao.adminserver.modules.bpm.convert.task.BpmProcessInstanceConvert;
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.task.BpmProcessInstanceExtDO;
|
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.task.BpmProcessInstanceExtDO;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.task.BpmProcessInstanceExtMapper;
|
import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.task.BpmProcessInstanceExtMapper;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceDeleteReasonEnum;
|
import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceDeleteReasonEnum;
|
||||||
|
@ -14,8 +15,12 @@ import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceSta
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmProcessDefinitionService;
|
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmProcessDefinitionService;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmProcessInstanceService;
|
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmProcessInstanceService;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmTaskService;
|
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmTaskService;
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO;
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysDeptService;
|
||||||
import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService;
|
import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService;
|
||||||
|
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.activiti.engine.HistoryService;
|
import org.activiti.engine.HistoryService;
|
||||||
import org.activiti.engine.RuntimeService;
|
import org.activiti.engine.RuntimeService;
|
||||||
|
@ -23,6 +28,7 @@ import org.activiti.engine.history.HistoricProcessInstance;
|
||||||
import org.activiti.engine.repository.ProcessDefinition;
|
import org.activiti.engine.repository.ProcessDefinition;
|
||||||
import org.activiti.engine.runtime.ProcessInstance;
|
import org.activiti.engine.runtime.ProcessInstance;
|
||||||
import org.activiti.engine.task.Task;
|
import org.activiti.engine.task.Task;
|
||||||
|
import org.mapstruct.ap.shaded.freemarker.template.utility.StringUtil;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -60,6 +66,8 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
||||||
@Resource
|
@Resource
|
||||||
private SysUserService userService;
|
private SysUserService userService;
|
||||||
@Resource
|
@Resource
|
||||||
|
private SysDeptService deptService;
|
||||||
|
@Resource
|
||||||
@Lazy // 解决循环依赖
|
@Lazy // 解决循环依赖
|
||||||
private BpmTaskService taskService;
|
private BpmTaskService taskService;
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -152,6 +160,37 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
||||||
return BpmProcessInstanceConvert.INSTANCE.convertPage(pageResult, taskMap);
|
return BpmProcessInstanceConvert.INSTANCE.convertPage(pageResult, taskMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BpmProcessInstanceRespVO getProcessInstanceVO(String id) {
|
||||||
|
// 获得流程实例
|
||||||
|
HistoricProcessInstance processInstance = getHistoricProcessInstance(id);
|
||||||
|
if (processInstance == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
BpmProcessInstanceExtDO processInstanceExt = processInstanceExtMapper.selectByProcessInstanceId(id);
|
||||||
|
Assert.notNull(processInstanceExt, "流程实例拓展({}) 不存在", id);
|
||||||
|
|
||||||
|
// 获得流程定义
|
||||||
|
ProcessDefinition processDefinition = processDefinitionService.getProcessDefinition(
|
||||||
|
processInstance.getProcessDefinitionId());
|
||||||
|
Assert.notNull(processDefinition, "流程定义({}) 不存在", processInstance.getProcessDefinitionId());
|
||||||
|
BpmProcessDefinitionExtDO processDefinitionExt = processDefinitionService.getProcessDefinitionExt(
|
||||||
|
processInstance.getProcessDefinitionId());
|
||||||
|
Assert.notNull(processDefinitionExt, "流程定义拓展({}) 不存在", id);
|
||||||
|
String bpmnXml = processDefinitionService.getProcessDefinitionBpmnXML(processInstance.getProcessDefinitionId());
|
||||||
|
|
||||||
|
// 获得 User
|
||||||
|
SysUserDO startUser = userService.getUser(NumberUtils.parseLong(processInstance.getStartUserId()));
|
||||||
|
SysDeptDO dept = null;
|
||||||
|
if (startUser != null) {
|
||||||
|
dept = deptService.getDept(startUser.getDeptId());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 拼接结果
|
||||||
|
return BpmProcessInstanceConvert.INSTANCE.convert2(processInstance, processInstanceExt,
|
||||||
|
processDefinition, processDefinitionExt, bpmnXml, startUser, dept);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ProcessInstance> getProcessInstances(Set<String> ids) {
|
public List<ProcessInstance> getProcessInstances(Set<String> ids) {
|
||||||
return runtimeService.createProcessInstanceQuery().processInstanceIds(ids).list();
|
return runtimeService.createProcessInstanceQuery().processInstanceIds(ids).list();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package cn.iocoder.yudao.framework.activiti.core.util;
|
package cn.iocoder.yudao.framework.activiti.core.util;
|
||||||
|
|
||||||
import cn.hutool.core.util.ReflectUtil;
|
import cn.hutool.core.util.ReflectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.ttl.TransmittableThreadLocal;
|
import com.alibaba.ttl.TransmittableThreadLocal;
|
||||||
import org.activiti.bpmn.converter.BpmnXMLConverter;
|
import org.activiti.bpmn.converter.BpmnXMLConverter;
|
||||||
import org.activiti.bpmn.model.BpmnModel;
|
import org.activiti.bpmn.model.BpmnModel;
|
||||||
|
@ -46,7 +47,6 @@ public class ActivitiUtils {
|
||||||
|
|
||||||
// ========== BPMN XML 相关 ==========
|
// ========== BPMN XML 相关 ==========
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建对应的 BPMN Model
|
* 构建对应的 BPMN Model
|
||||||
*
|
*
|
||||||
|
@ -59,6 +59,13 @@ public class ActivitiUtils {
|
||||||
return converter.convertToBpmnModel(new BytesStreamSource(bpmnBytes), true, true);
|
return converter.convertToBpmnModel(new BytesStreamSource(bpmnBytes), true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得 BPMN 流程中,指定的元素们
|
||||||
|
*
|
||||||
|
* @param model
|
||||||
|
* @param clazz 指定元素。例如说,{@link org.activiti.bpmn.model.UserTask}、{@link org.activiti.bpmn.model.Gateway} 等等
|
||||||
|
* @return 元素们
|
||||||
|
*/
|
||||||
public static <T extends FlowElement> List<T> getBpmnModelElements(BpmnModel model, Class<T> clazz) {
|
public static <T extends FlowElement> List<T> getBpmnModelElements(BpmnModel model, Class<T> clazz) {
|
||||||
List<T> result = new ArrayList<>();
|
List<T> result = new ArrayList<>();
|
||||||
model.getProcesses().forEach(process -> {
|
model.getProcesses().forEach(process -> {
|
||||||
|
@ -71,4 +78,12 @@ public class ActivitiUtils {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getBpmnXml(BpmnModel model) {
|
||||||
|
if (model == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
BpmnXMLConverter converter = new BpmnXMLConverter();
|
||||||
|
return StrUtil.utf8Str(converter.convertToXML(model));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue