跳转至

一 . bpmn2.0

  1. 添加手工任务节点
  2. 名称 填写通知的标题
  3. 描述 填写需要通知的角色
  4. 如有多个需要逗号分割role1,role2
  5. 监听器
  6. 监听事件start
  7. 监听类com.jeeplus.modules.act.listener.TestNotifyListener

    这个类已经编写好了,这个类会给添加Notify的数据库记录

二 . 监听类

/**
 * @see 手工任务专用 测试知会供能
 */

@Component
public class NotifyListener implements JavaDelegate
{


    private static final String String = null;

    @Override
    public void execute(DelegateExecution execution) throws Exception
    {
        SystemService systemService = SpringContextHolder.getBean(SystemService.class);
        NotifyService notifyService = SpringContextHolder.getBean(NotifyService.class);
        // 获取流程id
        String procInsId = execution.getProcessInstanceId();
        // 通知名称
        String notifyName = execution.getCurrentActivityName();// 节点名称
        // 通知类型(流程key,通过对比key,才可以确认查询的数据类型)
        String processDefinitionId = execution.getProcessDefinitionId();
        /**
         * jeeplus/a/act/task/form?
         * taskDefKey=&
         * procInsId=426dc735210d4a2390d80e47027db173&
         * procDefId=finance_loan:1:4619ac0def5b46ad998af6b81795f887
         * 
         * taskDefKey不用写值表示,最终状态
         * 
         * */
        // 角色1,角色2(填写的内容是角色的“enmame”)
        String roles = (java.lang.String) ActUtils.getProperties(execution).get("documentation");// 手工任务中的描述填写角色(dep,emp)
        String[] ennames = roles.split(",");
        // 根据roles获取要通知的人
        HashSet<User> users = new HashSet<>();
        for (String enname : ennames)
        {
            Role role = systemService.getRoleByEnname(enname);
            User user = new User(role);
            List<User> findUser = systemService.findUser(user);
            for (User us : findUser)
            {
                users.add(us);// 因为set可以去重(但是这里的User类需要重写hashcode的方法)
            }
        }
        for (User user : users)
        {
            Notify notify = new Notify(notifyName, processDefinitionId, user, procInsId, "未读");
            // 保存通知单
            notifyService.save(notify);
            System.out.println();
        }
    }
}