基于若依的ruoyi-nbcio流程管理系统自定义业务实现一种简单的动态任务标题需求

本文主要是介绍基于若依的ruoyi-nbcio流程管理系统自定义业务实现一种简单的动态任务标题需求,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

 更多ruoyi-nbcio功能请看演示系统

gitee源代码地址

前后端代码: https://gitee.com/nbacheng/ruoyi-nbcio

演示地址:RuoYi-Nbcio后台管理系统

更多nbcio-boot功能请看演示系统

gitee源代码地址

后端代码: https://gitee.com/nbacheng/nbcio-boot

前端代码:https://gitee.com/nbacheng/nbcio-vue.git

在线演示(包括H5) : http://122.227.135.243:9888

今天讲一个根据自定义业务表单的字段内容来动态修改发送标题。

1、全局任务创建监听如下修改

/*** 全局监听-工作流待办消息提醒** @author nbacheng*/
@Slf4j
@Component
@RequiredArgsConstructor
public class TaskCreateListener implements FlowableEventListener {private final TaskService taskService;@Resourceprivate CommonService commonService;@Resourceprotected RepositoryService repositoryService;@Resourceprotected HistoryService historyService;@Overridepublic void onEvent(FlowableEvent flowableEvent) {FlowableEventType type = flowableEvent.getType();if (type == FlowableEngineEventType.TASK_ASSIGNED) { if(flowableEvent instanceof org.flowable.engine.delegate.event.impl.FlowableEntityEventImpl ) {TaskEntity taskEntity = (TaskEntity) ((org.flowable.engine.delegate.event.impl.FlowableEntityEventImpl) flowableEvent).getEntity();String taskId = taskEntity.getId();String procInsId = taskEntity.getProcessInstanceId();HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(procInsId).singleResult();List<Task> listtask = taskService.createTaskQuery().processInstanceId(procInsId).active().list();String dataId =  historicProcessInstance.getBusinessKey();String deployId = historicProcessInstance.getDeploymentId();String startUserId = historicProcessInstance.getStartUserId();//获取任务接收人String receiver = taskEntity.getAssignee();if (StringUtils.isNotEmpty(receiver)) {//发送提醒消息String category = "";if(taskService.getVariables(taskId).get("category") != null) {category = taskService.getVariables(taskId).get("category").toString();}LoginUser loginUser = commonService.getLoginUser();String taskMessageUrl;if(StringUtils.isNotBlank(dataId)) {taskMessageUrl = "<a href=" + commonService.getBaseUrl() + procInsId + "?taskId="+ taskId + "&businessKey=" + dataId + "&category=" + category + "&processed=true"  + ">点击这个进行处理</a>" ;}else {taskMessageUrl = "<a href=" + commonService.getBaseUrl() + procInsId + "?taskId="+ taskId + "&businessKey" + "&category=" + category + "&processed=true" + ">点击这个进行处理</a>" ;}String msgContent = "流程待办通知" + taskMessageUrl;if(!StringUtils.equals((loginUser.getUserId()).toString(),receiver)) {//发起人或登录人自己不发送String taskTitle = "";if( ObjectUtils.isNotEmpty(listtask)) {String field = listtask.get(0).getDescription();field = field.substring(field.lastIndexOf("{") + 1, field.lastIndexOf("}"));taskTitle = commonService.getTaskTitle(dataId, field);}log.info("任务标题:" + taskTitle);log.info("流程待办通知给:" + receiver);commonService.sendSysNotice(loginUser.getUserId().toString(), receiver, taskTitle+"流程待办通知", msgContent, Constants.MSG_CATEGORY_3);//setMsgCategory=3是待办}}}}	}@Overridepublic boolean isFailOnException() {return false;}@Overridepublic boolean isFireOnTransactionLifecycleEvent() {return false;}@Overridepublic String getOnTransaction() {return null;}
}

2、其中上面的getTaskTitle如下:

public String getTaskTitle(String dataId, String field) {//设置自定义表单dataid的数据 WfMyBusiness flowmybusiness = wfMyBusinessServiceImpl.getByDataId(dataId);String serviceImplName = flowmybusiness.getServiceImplName();WfCallBackServiceI flowCallBackService = (WfCallBackServiceI) SpringContextUtils.getBean(serviceImplName);if (flowCallBackService!=null){return flowCallBackService.getFieldBydataId(dataId, field); }	return null;}

3、上面的getFieldBydataId调用了自定义业务的实际类

@Overridepublic String getFieldBydataId(String dataId, String field) {return baseMapper.getFieldBydataId(dataId, field);}
public interface WfDemoMapper extends BaseMapperPlus<WfDemoMapper, WfDemo, WfDemoVo> {Page<WfDemoVo> myPage(Page<WfDemoVo> page, @Param(Constants.WRAPPER) QueryWrapper<WfDemoVo> queryWrapper);@Select("select ${field} from wf_demo where demo_id = #{dataId}")String getFieldBydataId(@Param("dataId") String dataId, @Param("field") String field);}

4、流程定义

这里做了一个测试例子,用了wf_demo里的字段user_name

5、效果图

6、当然上面对于多实例并发,子流程等还没有进行测试,以后需要进一步修改确认。

7、对于待办任务的标题也需要进行后续动态更新。

这篇关于基于若依的ruoyi-nbcio流程管理系统自定义业务实现一种简单的动态任务标题需求的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/680383

相关文章

慢sql提前分析预警和动态sql替换-Mybatis-SQL

《慢sql提前分析预警和动态sql替换-Mybatis-SQL》为防止慢SQL问题而开发的MyBatis组件,该组件能够在开发、测试阶段自动分析SQL语句,并在出现慢SQL问题时通过Ducc配置实现动... 目录背景解决思路开源方案调研设计方案详细设计使用方法1、引入依赖jar包2、配置组件XML3、核心配

使用Python实现IP地址和端口状态检测与监控

《使用Python实现IP地址和端口状态检测与监控》在网络运维和服务器管理中,IP地址和端口的可用性监控是保障业务连续性的基础需求,本文将带你用Python从零打造一个高可用IP监控系统,感兴趣的小伙... 目录概述:为什么需要IP监控系统使用步骤说明1. 环境准备2. 系统部署3. 核心功能配置系统效果展

Python实现微信自动锁定工具

《Python实现微信自动锁定工具》在数字化办公时代,微信已成为职场沟通的重要工具,但临时离开时忘记锁屏可能导致敏感信息泄露,下面我们就来看看如何使用Python打造一个微信自动锁定工具吧... 目录引言:当微信隐私遇到自动化守护效果展示核心功能全景图技术亮点深度解析1. 无操作检测引擎2. 微信路径智能获

Python中pywin32 常用窗口操作的实现

《Python中pywin32常用窗口操作的实现》本文主要介绍了Python中pywin32常用窗口操作的实现,pywin32主要的作用是供Python开发者快速调用WindowsAPI的一个... 目录获取窗口句柄获取最前端窗口句柄获取指定坐标处的窗口根据窗口的完整标题匹配获取句柄根据窗口的类别匹配获取句

在 Spring Boot 中实现异常处理最佳实践

《在SpringBoot中实现异常处理最佳实践》本文介绍如何在SpringBoot中实现异常处理,涵盖核心概念、实现方法、与先前查询的集成、性能分析、常见问题和最佳实践,感兴趣的朋友一起看看吧... 目录一、Spring Boot 异常处理的背景与核心概念1.1 为什么需要异常处理?1.2 Spring B

Python位移操作和位运算的实现示例

《Python位移操作和位运算的实现示例》本文主要介绍了Python位移操作和位运算的实现示例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一... 目录1. 位移操作1.1 左移操作 (<<)1.2 右移操作 (>>)注意事项:2. 位运算2.1

如何在 Spring Boot 中实现 FreeMarker 模板

《如何在SpringBoot中实现FreeMarker模板》FreeMarker是一种功能强大、轻量级的模板引擎,用于在Java应用中生成动态文本输出(如HTML、XML、邮件内容等),本文... 目录什么是 FreeMarker 模板?在 Spring Boot 中实现 FreeMarker 模板1. 环

Qt实现网络数据解析的方法总结

《Qt实现网络数据解析的方法总结》在Qt中解析网络数据通常涉及接收原始字节流,并将其转换为有意义的应用层数据,这篇文章为大家介绍了详细步骤和示例,感兴趣的小伙伴可以了解下... 目录1. 网络数据接收2. 缓冲区管理(处理粘包/拆包)3. 常见数据格式解析3.1 jsON解析3.2 XML解析3.3 自定义

SpringMVC 通过ajax 前后端数据交互的实现方法

《SpringMVC通过ajax前后端数据交互的实现方法》:本文主要介绍SpringMVC通过ajax前后端数据交互的实现方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价... 在前端的开发过程中,经常在html页面通过AJAX进行前后端数据的交互,SpringMVC的controll

Spring Security自定义身份认证的实现方法

《SpringSecurity自定义身份认证的实现方法》:本文主要介绍SpringSecurity自定义身份认证的实现方法,下面对SpringSecurity的这三种自定义身份认证进行详细讲解,... 目录1.内存身份认证(1)创建配置类(2)验证内存身份认证2.JDBC身份认证(1)数据准备 (2)配置依