mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-17 16:56:39 +08:00
add 增加流程业务扩展
This commit is contained in:
parent
0f0a3a181e
commit
0fcf77e2ed
@ -88,4 +88,8 @@ public interface FlowConstant {
|
||||
*/
|
||||
String AUTO_PASS = "autoPass";
|
||||
|
||||
/**
|
||||
* 业务编码
|
||||
*/
|
||||
String BUSINESS_CODE = "businessCode";
|
||||
}
|
||||
|
@ -0,0 +1,59 @@
|
||||
package org.dromara.workflow.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.dromara.common.tenant.core.TenantEntity;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 流程实例业务扩展对象 flow_instance_biz_ext
|
||||
*
|
||||
* @author may
|
||||
* @date 2025-08-05
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("flow_instance_biz_ext")
|
||||
public class FlowInstanceBizExt extends TenantEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 流程实例ID
|
||||
*/
|
||||
private Long instanceId;
|
||||
|
||||
/**
|
||||
* 业务ID
|
||||
*/
|
||||
private String businessId;
|
||||
|
||||
/**
|
||||
* 业务编码
|
||||
*/
|
||||
private String businessCode;
|
||||
|
||||
/**
|
||||
* 业务标题
|
||||
*/
|
||||
private String businessTitle;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表存在 1代表删除)
|
||||
*/
|
||||
@TableLogic
|
||||
private String delFlag;
|
||||
|
||||
|
||||
}
|
@ -29,6 +29,11 @@ public class TestLeave extends BaseEntity {
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 申请编号
|
||||
*/
|
||||
private String applyCode;
|
||||
|
||||
/**
|
||||
* 请假类型
|
||||
*/
|
||||
|
@ -0,0 +1,46 @@
|
||||
package org.dromara.workflow.domain.bo;
|
||||
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.workflow.domain.FlowInstanceBizExt;
|
||||
|
||||
/**
|
||||
* 流程实例业务扩展业务对象 flow_instance_biz_ext
|
||||
*
|
||||
* @author may
|
||||
* @date 2025-08-05
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = FlowInstanceBizExt.class, reverseConvertGenerate = false)
|
||||
public class FlowInstanceBizExtBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 流程实例ID
|
||||
*/
|
||||
private Long instanceId;
|
||||
|
||||
/**
|
||||
* 业务ID
|
||||
*/
|
||||
private String businessId;
|
||||
|
||||
/**
|
||||
* 业务编码
|
||||
*/
|
||||
private String businessCode;
|
||||
|
||||
/**
|
||||
* 业务标题
|
||||
*/
|
||||
private String businessTitle;
|
||||
|
||||
|
||||
}
|
@ -44,6 +44,11 @@ public class StartProcessBo implements Serializable {
|
||||
*/
|
||||
private Map<String, Object> variables;
|
||||
|
||||
/**
|
||||
* 流程业务扩展信息
|
||||
*/
|
||||
private FlowInstanceBizExtBo flowInstanceBizExtBo;
|
||||
|
||||
public Map<String, Object> getVariables() {
|
||||
if (variables == null) {
|
||||
return new HashMap<>(16);
|
||||
|
@ -36,6 +36,11 @@ public class TestLeaveBo extends BaseEntity {
|
||||
*/
|
||||
private String flowCode;
|
||||
|
||||
/**
|
||||
* 申请编号
|
||||
*/
|
||||
private String applyCode;
|
||||
|
||||
/**
|
||||
* 请假类型
|
||||
*/
|
||||
|
@ -203,6 +203,18 @@ public class FlowHisTaskVo implements Serializable {
|
||||
*/
|
||||
private String runDuration;
|
||||
|
||||
//业务扩展信息开始
|
||||
/**
|
||||
* 业务编码
|
||||
*/
|
||||
private String businessCode;
|
||||
|
||||
/**
|
||||
* 业务标题
|
||||
*/
|
||||
private String businessTitle;
|
||||
//业务扩展信息结束
|
||||
|
||||
/**
|
||||
* 设置创建时间并计算任务运行时长
|
||||
*
|
||||
|
@ -0,0 +1,58 @@
|
||||
package org.dromara.workflow.domain.vo;
|
||||
|
||||
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import org.dromara.workflow.domain.FlowInstanceBizExt;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* 流程实例业务扩展视图对象 flow_instance_biz_ext
|
||||
*
|
||||
* @author may
|
||||
* @date 2025-08-05
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = FlowInstanceBizExt.class)
|
||||
public class FlowInstanceBizExtVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@ExcelProperty(value = "主键")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 流程实例ID
|
||||
*/
|
||||
@ExcelProperty(value = "流程实例ID")
|
||||
private Long instanceId;
|
||||
|
||||
/**
|
||||
* 业务ID
|
||||
*/
|
||||
@ExcelProperty(value = "业务ID")
|
||||
private String businessId;
|
||||
|
||||
/**
|
||||
* 业务编码
|
||||
*/
|
||||
@ExcelProperty(value = "业务编码")
|
||||
private String businessCode;
|
||||
|
||||
/**
|
||||
* 业务标题
|
||||
*/
|
||||
@ExcelProperty(value = "业务标题")
|
||||
private String businessTitle;
|
||||
|
||||
|
||||
}
|
@ -134,4 +134,16 @@ public class FlowInstanceVo {
|
||||
@Translation(type = FlowConstant.CATEGORY_ID_TO_NAME, mapper = "category")
|
||||
private String categoryName;
|
||||
|
||||
//业务扩展信息开始
|
||||
/**
|
||||
* 业务编码
|
||||
*/
|
||||
private String businessCode;
|
||||
|
||||
/**
|
||||
* 业务标题
|
||||
*/
|
||||
private String businessTitle;
|
||||
//业务扩展信息结束
|
||||
|
||||
}
|
||||
|
@ -185,4 +185,16 @@ public class FlowTaskVo implements Serializable {
|
||||
*/
|
||||
private List<ButtonPermissionVo> buttonList;
|
||||
|
||||
//业务扩展信息开始
|
||||
/**
|
||||
* 业务编码
|
||||
*/
|
||||
private String businessCode;
|
||||
|
||||
/**
|
||||
* 业务标题
|
||||
*/
|
||||
private String businessTitle;
|
||||
//业务扩展信息结束
|
||||
|
||||
}
|
||||
|
@ -32,6 +32,12 @@ public class TestLeaveVo implements Serializable {
|
||||
@ExcelProperty(value = "主键")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 申请编号
|
||||
*/
|
||||
@ExcelProperty(value = "申请编号")
|
||||
private String applyCode;
|
||||
|
||||
/**
|
||||
* 请假类型
|
||||
*/
|
||||
|
@ -0,0 +1,15 @@
|
||||
package org.dromara.workflow.mapper;
|
||||
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.dromara.workflow.domain.FlowInstanceBizExt;
|
||||
import org.dromara.workflow.domain.vo.FlowInstanceBizExtVo;
|
||||
|
||||
/**
|
||||
* 流程实例业务扩展Mapper接口
|
||||
*
|
||||
* @author may
|
||||
* @date 2025-08-05
|
||||
*/
|
||||
public interface FlwInstanceBizExtMapper extends BaseMapperPlus<FlowInstanceBizExt, FlowInstanceBizExtVo> {
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package org.dromara.workflow.service;
|
||||
|
||||
import org.dromara.workflow.domain.bo.FlowInstanceBizExtBo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 流程实例业务扩展Service接口
|
||||
*
|
||||
* @author may
|
||||
* @date 2025-08-05
|
||||
*/
|
||||
public interface IFlwInstanceBizExtService {
|
||||
|
||||
/**
|
||||
* 新增/修改流程实例业务扩展
|
||||
*
|
||||
* @param bo 流程实例业务扩展
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean saveOrUpdate(FlowInstanceBizExtBo bo);
|
||||
|
||||
/**
|
||||
* 按照流程实例ID批量删除
|
||||
*
|
||||
* @param instanceIds 流程实例ID
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteByInstIds(List<Long> instanceIds);
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package org.dromara.workflow.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.workflow.domain.FlowInstanceBizExt;
|
||||
import org.dromara.workflow.domain.bo.FlowInstanceBizExtBo;
|
||||
import org.dromara.workflow.mapper.FlwInstanceBizExtMapper;
|
||||
import org.dromara.workflow.service.IFlwInstanceBizExtService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 流程实例业务扩展Service业务层处理
|
||||
*
|
||||
* @author may
|
||||
* @date 2025-08-05
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class FlwInstanceBizExtServiceImpl implements IFlwInstanceBizExtService {
|
||||
|
||||
private final FlwInstanceBizExtMapper baseMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 新增/修改流程实例业务扩展
|
||||
*
|
||||
* @param bo 流程实例业务扩展
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean saveOrUpdate(FlowInstanceBizExtBo bo) {
|
||||
FlowInstanceBizExt convert = MapstructUtils.convert(bo, FlowInstanceBizExt.class);
|
||||
FlowInstanceBizExt flowInstanceBizExt = baseMapper.selectOne(new LambdaQueryWrapper<FlowInstanceBizExt>()
|
||||
.eq(FlowInstanceBizExt::getInstanceId, bo.getInstanceId()));
|
||||
if (flowInstanceBizExt != null) {
|
||||
flowInstanceBizExt.setBusinessTitle(convert.getBusinessTitle());
|
||||
return baseMapper.insertOrUpdate(convert);
|
||||
}
|
||||
return baseMapper.insertOrUpdate(convert);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按照流程实例ID批量删除
|
||||
*
|
||||
* @param instanceIds 流程实例ID
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteByInstIds(List<Long> instanceIds) {
|
||||
return baseMapper.delete(new LambdaQueryWrapper<FlowInstanceBizExt>().in(FlowInstanceBizExt::getInstanceId, instanceIds)) > 0;
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
|
||||
@ -46,10 +47,7 @@ import org.dromara.workflow.domain.vo.FlowHisTaskVo;
|
||||
import org.dromara.workflow.domain.vo.FlowTaskVo;
|
||||
import org.dromara.workflow.mapper.FlwCategoryMapper;
|
||||
import org.dromara.workflow.mapper.FlwTaskMapper;
|
||||
import org.dromara.workflow.service.IFlwCommonService;
|
||||
import org.dromara.workflow.service.IFlwNodeExtService;
|
||||
import org.dromara.workflow.service.IFlwTaskAssigneeService;
|
||||
import org.dromara.workflow.service.IFlwTaskService;
|
||||
import org.dromara.workflow.service.*;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@ -86,6 +84,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
private final IFlwCommonService flwCommonService;
|
||||
private final IFlwNodeExtService flwNodeExtService;
|
||||
private final FlowDefinitionMapper flowDefinitionMapper;
|
||||
private final IFlwInstanceBizExtService flowInstanceBizExtService;
|
||||
|
||||
/**
|
||||
* 启动任务
|
||||
@ -117,14 +116,30 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
StartProcessReturnDTO dto = new StartProcessReturnDTO();
|
||||
dto.setProcessInstanceId(taskList.get(0).getInstanceId());
|
||||
dto.setTaskId(taskList.get(0).getId());
|
||||
// 保存流程实例业务信息
|
||||
buildFlowInstanceBizExt(flowInstance, startProcessBo.getFlowInstanceBizExtBo());
|
||||
return dto;
|
||||
}
|
||||
FlowInstanceBizExtBo extBo = startProcessBo.getFlowInstanceBizExtBo();
|
||||
String businessCode;
|
||||
if (ObjectUtil.isEmpty(extBo)) {
|
||||
extBo = new FlowInstanceBizExtBo();
|
||||
startProcessBo.setFlowInstanceBizExtBo(extBo);
|
||||
}
|
||||
// 生成业务编号
|
||||
if (StringUtils.isBlank(extBo.getBusinessCode())) {
|
||||
//todo 按照自己业务自行修改
|
||||
businessCode = System.currentTimeMillis()+ StrUtil.EMPTY;
|
||||
extBo.setBusinessCode(businessCode);
|
||||
} else {
|
||||
businessCode = extBo.getBusinessCode();
|
||||
}
|
||||
// 将流程定义内的扩展参数设置到变量中
|
||||
Definition definition = FlowEngine.defService().getPublishByFlowCode(startProcessBo.getFlowCode());
|
||||
Dict dict = JsonUtils.parseMap(definition.getExt());
|
||||
boolean autoPass = !ObjectUtil.isNull(dict) && dict.getBool(FlowConstant.AUTO_PASS);
|
||||
variables.put(FlowConstant.AUTO_PASS, autoPass);
|
||||
|
||||
variables.put(FlowConstant.BUSINESS_CODE, businessCode);
|
||||
FlowParams flowParams = FlowParams.build()
|
||||
.handler(startProcessBo.getHandler())
|
||||
.flowCode(startProcessBo.getFlowCode())
|
||||
@ -136,6 +151,8 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
// 保存流程实例业务信息
|
||||
buildFlowInstanceBizExt(instance, startProcessBo.getFlowInstanceBizExtBo());
|
||||
// 申请人执行流程
|
||||
List<Task> taskList = taskService.list(new FlowTask().setInstanceId(instance.getId()));
|
||||
if (taskList.size() > 1) {
|
||||
@ -147,6 +164,19 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
return dto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建流程实例业务信息
|
||||
*
|
||||
* @param instance 流程实例
|
||||
* @param flowInstanceBizExtBo 业务扩展信息
|
||||
*/
|
||||
private void buildFlowInstanceBizExt(Instance instance, FlowInstanceBizExtBo flowInstanceBizExtBo) {
|
||||
flowInstanceBizExtBo.setInstanceId(instance.getId());
|
||||
flowInstanceBizExtBo.setBusinessId(instance.getBusinessId());
|
||||
flowInstanceBizExtBo.setBusinessCode(flowInstanceBizExtBo.getBusinessCode());
|
||||
flowInstanceBizExtService.saveOrUpdate(flowInstanceBizExtBo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 办理任务
|
||||
*
|
||||
|
@ -4,6 +4,7 @@ import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@ -109,6 +110,7 @@ public class TestLeaveServiceImpl implements ITestLeaveService {
|
||||
TestLeave add = MapstructUtils.convert(bo, TestLeave.class);
|
||||
if (StringUtils.isBlank(add.getStatus())) {
|
||||
add.setStatus(BusinessStatusEnum.DRAFT.getStatus());
|
||||
add.setApplyCode(System.currentTimeMillis() + StrUtil.EMPTY);
|
||||
}
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
@ -188,6 +190,10 @@ public class TestLeaveServiceImpl implements ITestLeaveService {
|
||||
String message = Convert.toStr(params.get("message"));
|
||||
}
|
||||
if (processEvent.getSubmit()) {
|
||||
if(StringUtils.isBlank(testLeave.getApplyCode())){
|
||||
String businessCode = MapUtil.getStr(params, "businessCode",StrUtil.EMPTY);
|
||||
testLeave.setApplyCode(businessCode);
|
||||
}
|
||||
testLeave.setStatus(BusinessStatusEnum.WAITING.getStatus());
|
||||
}
|
||||
baseMapper.updateById(testLeave);
|
||||
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.workflow.mapper.FlwInstanceBizExtMapper">
|
||||
|
||||
</mapper>
|
@ -27,9 +27,12 @@
|
||||
fd.version,
|
||||
fd.form_custom,
|
||||
fd.form_path,
|
||||
fd.category
|
||||
fd.category,
|
||||
biz.business_code,
|
||||
biz.business_title
|
||||
from flow_instance fi
|
||||
left join flow_definition fd on fi.definition_id = fd.id
|
||||
left join flow_instance_biz_ext biz on biz.instance_id = fi.id
|
||||
${ew.getCustomSqlSegment}
|
||||
</select>
|
||||
|
||||
|
@ -30,11 +30,14 @@
|
||||
COALESCE(t.form_path, d.form_path) as form_path,
|
||||
d.version,
|
||||
uu.processed_by,
|
||||
uu.type
|
||||
uu.type,
|
||||
biz.business_code,
|
||||
biz.business_title
|
||||
from flow_task t
|
||||
left join flow_user uu on uu.associated = t.id
|
||||
left join flow_definition d on t.definition_id = d.id
|
||||
left join flow_instance i on t.instance_id = i.id
|
||||
left join flow_instance_biz_ext biz on biz.instance_id = i.id
|
||||
where t.node_type = 1
|
||||
and t.del_flag = '0'
|
||||
and uu.del_flag = '0'
|
||||
@ -71,10 +74,13 @@
|
||||
c.flow_name,
|
||||
c.flow_code,
|
||||
c.category,
|
||||
c.version
|
||||
c.version,
|
||||
biz.business_code,
|
||||
biz.business_title
|
||||
from flow_his_task a
|
||||
left join flow_instance b on a.instance_id = b.id
|
||||
left join flow_definition c on a.definition_id = c.id
|
||||
left join flow_instance_biz_ext biz on biz.instance_id = b.id
|
||||
where a.del_flag ='0'
|
||||
and b.del_flag = '0'
|
||||
and c.del_flag = '0'
|
||||
@ -100,11 +106,14 @@
|
||||
d.flow_name,
|
||||
d.flow_code,
|
||||
d.category,
|
||||
d.version
|
||||
d.version,
|
||||
biz.business_code,
|
||||
biz.business_title
|
||||
from flow_user a
|
||||
left join flow_his_task b on a.associated = b.task_id
|
||||
left join flow_instance c on b.instance_id = c.id
|
||||
left join flow_definition d on c.definition_id=d.id
|
||||
left join flow_instance_biz_ext biz on biz.instance_id = c.id
|
||||
where a.type = '4'
|
||||
and a.del_flag = '0'
|
||||
and b.del_flag = '0'
|
||||
|
Loading…
Reference in New Issue
Block a user