基于若依的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;
    }
}


相关文章
|
19天前
|
移动开发 前端开发
基于若依的ruoyi-nbcio流程管理系统修复自定义业务表单的收回功能
基于若依的ruoyi-nbcio流程管理系统修复自定义业务表单的收回功能
14 1
|
19天前
基于若依的ruoyi-nbcio流程管理系统增加仿钉钉流程设计(六)
基于若依的ruoyi-nbcio流程管理系统增加仿钉钉流程设计(六)
15 0
|
19天前
|
XML JSON 数据格式
基于若依的ruoyi-nbcio流程管理系统增加仿钉钉流程设计(五)
基于若依的ruoyi-nbcio流程管理系统增加仿钉钉流程设计(五)
21 2
|
19天前
|
JSON API 数据格式
基于若依的ruoyi-nbcio流程管理系统增加仿钉钉流程设计(一)
基于若依的ruoyi-nbcio流程管理系统增加仿钉钉流程设计(一)
19 1
|
19天前
基于若依的ruoyi-nbcio流程管理系统增加仿钉钉流程设计(三)
基于若依的ruoyi-nbcio流程管理系统增加仿钉钉流程设计(三)
19 0
|
19天前
基于若依的ruoyi-nbcio流程管理系统增加仿钉钉流程设计(七)
基于若依的ruoyi-nbcio流程管理系统增加仿钉钉流程设计(七)
18 1
基于若依的ruoyi-nbcio流程管理系统增加仿钉钉流程设计(七)
|
19天前
基于若依的ruoyi-nbcio流程管理系统增加仿钉钉流程设计(二)
基于若依的ruoyi-nbcio流程管理系统增加仿钉钉流程设计(二)
15 1
|
19天前
|
移动开发 前端开发
基于若依的ruoyi-nbcio流程管理系统自定义业务流程出现多个时相应的流程选择问题(二)
基于若依的ruoyi-nbcio流程管理系统自定义业务流程出现多个时相应的流程选择问题(二)
22 3
|
19天前
|
移动开发 前端开发
基于若依的ruoyi-nbcio流程管理系统自定义业务撤回功能的修复
基于若依的ruoyi-nbcio流程管理系统自定义业务撤回功能的修复
24 0
|
19天前
|
前端开发
基于若依的ruoyi-nbcio流程管理系统增加流程设计器支持自定义表单的选择与处理
基于若依的ruoyi-nbcio流程管理系统增加流程设计器支持自定义表单的选择与处理
15 0