任务收回改派场景

  1. 任务收回改派场景

场景描述

假如活动A后面有活动B,活动B是多工作项,并且可以由A参与者选择活动B的执行者。比如选择了角色A(共包括5个人)中的3个人(a、b、c)执行B活动,但是当活动A结束后,发现分配的任务给a并不合理,想分配给5个人中的另外一个人d,需要收回a。这个时候需要在活动A上有一个任务去做收回a这个人的任务的场景

案例简介

本例为了简化实现方案,整个流程只设置了一个活动。该活动是多工作项,且其参与者由流程启动者指定。流程启动后,若发现指派的工作有误,可以通过收回操作撤销分配命令。

场景实现

部署/运行

  1. 启动 Server。
  2. 中把bps_example_callback项目覆盖部署到tomcat的default应用中,选用Overwrite remote resources – add/replace only 。把webcontent目录下的top.jsp文件复制到%BPS_HOME%\apache-tomcat-5.5.20\webapps\default\workflow\wfclient\main目录覆盖同名文件。
  3. 打开浏览器,在地址栏中输入https://localhost:8080/default打开BPS客户端登录页面。
  4. 客户端登录器中输入tiger,以密码000000登录,如下图所示:

  5. 登录后进入”查看已分配任务”菜单对应的界面:
  6. 在上述界面中点击链接”查看明细”:



提交后,再查看工作项列表:

  1. 环境准备


  1. 在项目bps_example_callback下新建包com.primeton.example.workflow.callback.flow。在该包下创建流程”prjplan”。
    1. 流程开发

  • 绘制业务流程com.primeton.samples.workflow.callback.prjplan。

  • 流程属性,为方便调试把流程启动者设为”任意人员启动”,并设置一些相关数据。
    • 流程启动者
    • 相关数据
  • “多工作项任务”属性,参与者设为相关数据,并增加表单设置。
    • 参与者
    • 表单
  • 为了辅助本流程的运行,一共设计了5个页面流,分别用来实现分配任务、收回任务、改派任务、流程查看、工作项查看。
    • 分配任务

      ‘任务分配Action代码'

      public ActionForward execute(ActionMapping mapping,ActionForm form,
      
                  HttpServletRequest , HttpServletResponse reponse) {
      
          String prjName = .getParameter("prjName");
      
          String ptName = .getParameter("ptName");
      
          try {
      
              IBPSServiceClient client = BPSServiceClientFactory.getDefaultClient();
      
              IWFProcessInstManager processInstManager = client.getProcessInstManager();
      
              IWFRelativeDataManager relativeDataManger = client.getRelativeDataManager();
      
              //
      
              long processInstID = processInstManager.
      
                      createProcessInstance("com.primeton.samples.workflow.callback.prjplan.prjplan",    prjName,prjName);
      
                  //
      
              Enumeration names = .getParameterNames();
      
              int count=0;
      
              while(names.hasMoreElements()){
      
                  if(((String)names.nextElement()).startsWith("pts"))
      
                      count++;
      
              }
      
              Object[] participants = new WFParticipant[count/3];
      
              String id,name,typeCode;
      
                  id = .getParameter("pts["+i+"]/id");
      
                  name = request.getParameter("pts["+i+"]/name");
      
                  typeCode = request.getParameter("pts["+i+"]/typeCode");
      
                  participants[i-1] = new WFParticipant(id,name,typeCode);
      
              }
      
              relativeDataManger.setRelativeData(processInstID,"pts", participants);
      
              relativeDataManger.setRelativeData(processInstID, "prjName", prjName);
      
              //
      
              processInstManager.startProcessInstance(processInstID);
      
              //
      
              request.setAttribute("notifyMessage","任务分配成功,任务流水号为:"+processInstID);
      
          } catch (WFServiceException e) {
      
              e.printStackTrace();
      
              request.setAttribute("errorMsg", e.getMessage());
      
              return mapping.findForward("error");
      
          }
      
          return mapping.findForward("success");
      
      }
      
    • 收回任务

      ‘回收任务Action代码'

      public ActionForward execute(ActionMapping mapping,ActionForm form,
      
                  HttpServletRequest request, HttpServletResponse reponse) {
      
          String[] selectedworks= (String[])request.getParameterValues("selectedworks");
      
          try {
      
              IBPSServiceClient client = BPSServiceClientFactory.getDefaultClient();
      
                  client.getDelegateManager().
      
                      withdrawDelegatedWorkItem(Long.valueOf(selectedworks[i]));
      
          } catch (WFServiceException e) {
      
              e.printStackTrace();
      
              return mapping.findForward("error");
      
          }
      
          return mapping.findForward("success");
      
      }
      
    • 改派任务

      ‘改派任务Action代码'

      public ActionForward execute(ActionMapping mapping,ActionForm form,
      
                  HttpServletRequest request, HttpServletResponse reponse) {
      
          String[] selectedworks= (String[])request.getParameterValues("selectedworks");
      
          Enumeration names = request.getParameterNames();
      
          int count=0;
      
          while(names.hasMoreElements()){
      
              if(((String)names.nextElement()).startsWith("participants"))
      
                  count++;
      
          }
      
          WFParticipant[] participants = new WFParticipant[count/3];
      
          String id,name,typeCode;
      
              id = request.getParameter("participants["+i+"]/id");
      
              name = request.getParameter("participants["+i+"]/name");
      
              typeCode = request.getParameter("participants["+i+"]/typeCode");
      
              participants[i-1] = new WFParticipant(id,name,typeCode);
      
          }
      
          try {
      
              IBPSServiceClient client = BPSServiceClientFactory.getDefaultClient();
      
                  client.getDelegateManager().
      
                      delegateWorkItem(Long.valueOf(selectedworks[i]).longValue(), participants, "DELEG");
      
          } catch (WFServiceException e) {
      
              e.printStackTrace();
      
              return mapping.findForward("error");
      
          }
      
          request.setAttribute("notifyMessage", "操作成功");
      
          return mapping.findForward("success");
      
      }
      
  • 工作项查看

    ‘工作项查看Action代码'

    public ActionForward execute(ActionMapping mapping,ActionForm form,
    
                HttpServletRequest request, HttpServletResponse reponse) {
    
        UserInfo user = (UserInfo)request.getSession().getAttribute("userInfo");
    
        try {
    
            IBPSServiceClient client = BPSServiceClientFactory.getDefaultClient();
    
            queryPersonWorkItems(user.getUserID(), 
    
                                    "ALL", "ALL", 
    
                                    new PageCond(Integer.MAX_VALUE));
    
            request.setAttribute("list", worklist);
    
        } catch (WFServiceException e) {
    
            e.printStackTrace();
    
            return mapping.findForward("error");
    
        }
    
        return mapping.findForward("success");
    
    }
    

其他

  • 所有未作特殊说明的属性均保持默认设置。
  • 角色定义文件在的webcontent目录下。

声明: 除非转自他站(如有侵权,请联系处理)外,本文采用 BY-NC-SA 协议进行授权 | 智乐兔
转载请注明:转自《任务收回改派场景
本文地址:https://www.zhiletu.com/archives-7045.html
关注公众号:智乐兔

赞赏

wechat pay微信赞赏alipay pay支付宝赞赏

上一篇
下一篇

相关文章

在线留言

你必须 登录后 才能留言!

在线客服
在线客服 X

售前: 点击这里给我发消息
售后: 点击这里给我发消息

智乐兔官微