基于若依的ruoyi-nbcio流程管理系统增加待办通知个性化设置

简介: 基于若依的ruoyi-nbcio流程管理系统增加待办通知个性化设置

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

gitee源代码地址

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

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

1、在每个节点可以设置扩展属性是todo的属性值,如下:

2、在需要审批或启动的时候获取这个扩展属性,同时赋值到变量里

如下:

/**
     * 完成任务
     *
     * @param taskBo 请求实体参数
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public 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;
    
    @Resource
    private CommonService commonService;
    
    @Resource
  protected RepositoryService repositoryService;
  
  @Resource
    protected HistoryService historyService;
     
    @Override
    public 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是待办
                }
              }
        }
      } 
    }
    @Override
    public boolean isFailOnException() {
        return false;
    }
    @Override
    public boolean isFireOnTransactionLifecycleEvent() {
        return false;
    }
    @Override
    public String getOnTransaction() {
        return null;
    }
}


相关文章
|
小程序
内网环境中ruoyi若依实现微信小程序授权登录解决办法
内网环境中ruoyi若依实现微信小程序授权登录解决办法
1193 0
|
移动开发 小程序 前端开发
uniapp开发小程序H5页面顶部导航栏navigationBar如何隐藏?三种解决办法
uniapp开发小程序H5页面顶部导航栏navigationBar如何隐藏?三种解决办法
|
API 开发者
工作日和节假日api
节假日api核心服务托管在阿里云之上,API天然分布式、高可用。
|
前端开发
基于若依ruoyi-nbcio增加flowable流程待办消息的提醒,并提供右上角的红字数字提醒(六)
基于若依ruoyi-nbcio增加flowable流程待办消息的提醒,并提供右上角的红字数字提醒(六)
927 0
|
前端开发
基于RuoYi-Flowable-Plus的若依ruoyi-nbcio支持自定义业务表单流程(二)
基于RuoYi-Flowable-Plus的若依ruoyi-nbcio支持自定义业务表单流程(二)
998 2
|
10月前
|
人工智能 Java API
MCP客户端调用看这一篇就够了(Java版)
本文详细介绍了MCP(Model Context Protocol)客户端的开发方法,包括在没有MCP时的痛点、MCP的作用以及如何通过Spring-AI框架和原生SDK调用MCP服务。文章首先分析了MCP协议的必要性,接着分别讲解了Spring-AI框架和自研SDK的使用方式,涵盖配置LLM接口、工具注入、动态封装工具等步骤,并提供了代码示例。此外,还记录了开发过程中遇到的问题及解决办法,如版本冲突、服务连接超时等。最后,文章探讨了框架与原生SDK的选择,认为框架适合快速构建应用,而原生SDK更适合平台级开发,强调了两者结合使用的价值。
13060 33
MCP客户端调用看这一篇就够了(Java版)
|
SQL JavaScript 前端开发
基于若依ruoyi-nbcio支持flowable流程增加自定义业务表单(一)
基于若依ruoyi-nbcio支持flowable流程增加自定义业务表单(一)
1213 2
|
SQL 前端开发
基于若依ruoyi-nbcio增加flowable流程待办消息的提醒,并提供右上角的红字数字提醒(五)
基于若依ruoyi-nbcio增加flowable流程待办消息的提醒,并提供右上角的红字数字提醒(五)
714 0
|
SQL 前端开发
基于若依ruoyi-nbcio增加flowable流程待办消息的提醒,并提供右上角的红字数字提醒(八)
基于若依ruoyi-nbcio增加flowable流程待办消息的提醒,并提供右上角的红字数字提醒(八)
695 0
基于若依ruoyi-nbcio支持flowable流程增加自定义业务表单(三)
基于若依ruoyi-nbcio支持flowable流程增加自定义业务表单(三)
761 1