3.9K Star 18.3K Fork 5.3K

卓源软件 / JeeSite 4.x and 5.x

 / 详情

BpmUtils中的多个方法有这个参数DelegateExecution execution,但这参数怎么快捷获取呢?

Done
Opened this issue  
2022-06-30 14:15

是什么问题、该问题是怎么引起的?

  1. BpmUtils中的多个方法有这个参数DelegateExecution execution,但这参数怎么快捷获取呢?

例如:想在Service层调用,但execution参数怎样从实体类或工具类获取呢?
public static void updateStatus(DelegateExecution execution, String serviceBeanName, String status);

环境版本:

  • JDK版本:1.8
  • 浏览器版本:Chrome
  • 平台版本:JeeSite 4.3.x(pom.xml里查看)

Comments (1)

lintn created任务

在事件脚本代码中写Java代码,把execution作为参数传进Java代码,事件脚本代码参考(BpmMsgUtil是自己定义的一个类):
输入图片说明
BpmMsgUtil代码示例(请自行调整):

package com.jeesite.modules.util;

import com.jeesite.common.entity.Page;
import com.jeesite.common.lang.StringUtils;
import com.jeesite.common.service.ServiceException;
import com.jeesite.common.web.http.ServletUtils;
import com.jeesite.modules.bpm.entity.BpmTask;
import com.jeesite.modules.bpm.service.BpmTaskService;
import com.jeesite.modules.bpm.utils.BpmUtils;
import com.jeesite.modules.msg.entity.content.PcMsgContent;
import com.jeesite.modules.msg.utils.MsgPushUtils;
import org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * bpm流程消息提醒工具类
 *
 * @author ya_jun
 */
@Component
public class BpmMsgUtil {

    /**
     * 给某人发消息提醒
     */
    public static void remindSomeBody(ExecutionEntityImpl execution) {
        // ExecutionEntityImpl是DelegateExecution的实现类
        BpmTask task = getBpmTask(getBusinessKey(execution));
        String nextUserCodes = ServletUtils.getParameter("nextUserCodes");
        for (String userCode : nextUserCodes.split(",")) {
            PcMsgContent msgContent = new PcMsgContent();
            msgContent.setTitle("提示信息");
            msgContent.setContent("您有1条新的任务被退回");
            msgContent.addButton("去办理", "/a/pro/approval/index?procIns.name=" + task.getProcIns().getName());
            // 即时推送消息
            MsgPushUtils.push(msgContent, getBizKey(execution), "bpm_msg", userCode);
        }
    }

    /**
     * 获取businessKey,格式:fornKey:bizKey
     *
     * @param execution
     * @return
     */
    private static String getBusinessKey(ExecutionEntityImpl execution) {
        String businessKey = execution.getProcessInstance().getBusinessKey();
        return businessKey;
    }

    private static String getBizKey(ExecutionEntityImpl execution) {
        String[] split = getBusinessKey(execution).split(":");
        return split[1];
    }

    /**
     * 根据businessKey查询流程任务,businessKey格式为:formKey:bizKey
     *
     * @param businessKey
     * @return
     */
    public static BpmTask getBpmTask(String businessKey) {
        if (StringUtils.isBlank(businessKey)) {
            throw new ServiceException("businessKey不可为空!");
        }
        BpmTask bpmTask = new BpmTask();
        bpmTask.setStatus(BpmTask.STATUS_UNFINISHED);
        bpmTask.getProcIns().setBusinessKey(businessKey);
        BpmTaskService bpmTaskService = BpmUtils.getBpmTaskService();
        Page<BpmTask> taskPage = bpmTaskService.findTaskPage(bpmTask);

        List<BpmTask> taskPageList = taskPage.getList();
        // 按照businesskey查询,应该只查询到一条数据
        if (taskPageList != null && taskPageList.size() != 1) {
            return null;
        }
        BpmTask task = taskPageList.get(0);
        return task;
    }

}

卓源软件 changed issue state from 待办的 to 已完成

Sign in to comment

Status
Assignees
Milestones
Pull Requests
Successfully merging a pull request will close this issue.
Branches
Planed to start   -   Planed to end
-
Top level
Priority
参与者(2)
8668781 ya   jun 1612489146
Java
1
https://gitee.com/thinkgem/jeesite4.git
git@gitee.com:thinkgem/jeesite4.git
thinkgem
jeesite4
JeeSite 4.x and 5.x

Search