本文主要是介绍基于若依的ruoyi-nbcio流程管理系统增加待办通知个性化设置,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
更多ruoyi-nbcio功能请看演示系统
gitee源代码地址
前后端代码: https://gitee.com/nbacheng/ruoyi-nbcio
演示地址:RuoYi-Nbcio后台管理系统
1、在每个节点可以设置扩展属性是todo的属性值,如下:
2、在需要审批或启动的时候获取这个扩展属性,同时赋值到变量里
如下:
/*** 完成任务** @param taskBo 请求实体参数*/@Transactional(rollbackFor = Exception.class)@Overridepublic void complete(WfTaskBo taskBo) {Task task = taskService.createTaskQuery().taskId(taskBo.getTaskId()).singleResult();if (Objects.isNull(task)) {throw new ServiceException("任务不存在");}//获取流程当前节点设置的扩展属性值,需要的时候可以使用Map<String, Object> flowProperties = getFlowProperties(taskBo.getProcInsId());Map<String, Object> newVariables = new HashMap<String, Object>();if(Objects.nonNull(taskBo.getVariables())) {newVariables = taskBo.getVariables();}log.info("flowProperties="+flowProperties.get("todo"));newVariables.put("todo", flowProperties.get("todo"));// 获取 bpmn 模型BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());if (DelegationState.PENDING.equals(task.getDelegationState())) {taskService.addComment(taskBo.getTaskId(), taskBo.getProcInsId(), FlowComment.DELEGATE.getType(), taskBo.getComment());taskService.resolveTask(taskBo.getTaskId());} else {taskService.addComment(taskBo.getTaskId(), taskBo.getProcInsId(), FlowComment.NORMAL.getType(), taskBo.getComment());taskService.setAssignee(taskBo.getTaskId(), TaskUtils.getUserName());if (ObjectUtil.isNotEmpty(newVariables)) {// 获取模型信息String localScopeValue = ModelUtils.getUserTaskAttributeValue(bpmnModel, task.getTaskDefinitionKey(), ProcessConstants.PROCESS_FORM_LOCAL_SCOPE);boolean localScope = Convert.toBool(localScopeValue, false);taskService.complete(taskBo.getTaskId(), newVariables, localScope);} else {taskService.complete(taskBo.getTaskId());}}
同时在创建待办的时候就可以获取这个变量来动态修改标题
@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();String businessKey = 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(businessKey)) {taskMessageUrl = "<a href=" + commonService.getBaseUrl() + procInsId + "?taskId="+ taskId + "&businessKey=" + businessKey + "&category=" + category + "&processed=true" + ">点击这个进行处理</a>" ;}else {taskMessageUrl = "<a href=" + commonService.getBaseUrl() + procInsId + "?taskId="+ taskId + "&businessKey" + "&category=" + category + "&processed=true" + ">点击这个进行处理</a>" ;}String title="";if(taskService.getVariables(taskId).get("todo") != null) {title = taskService.getVariables(taskId).get("todo").toString();log.info("title="+title);}String msgContent ="流程待办通知" + taskMessageUrl;if(!StringUtils.equals((loginUser.getUserId()).toString(),receiver)) {//发起人或登录人自己不发送log.info("流程待办通知给:" + receiver);commonService.sendSysNotice(loginUser.getUserId().toString(), receiver, title+"流程待办通知", msgContent, Constants.MSG_CATEGORY_3);//setMsgCategory=3是待办}}}} }@Overridepublic boolean isFailOnException() {return false;}@Overridepublic boolean isFireOnTransactionLifecycleEvent() {return false;}@Overridepublic String getOnTransaction() {return null;}
}
这篇关于基于若依的ruoyi-nbcio流程管理系统增加待办通知个性化设置的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!