任务收回改派场景
-
任务收回改派场景
场景描述
假如活动A后面有活动B,活动B是多工作项,并且可以由A参与者选择活动B的执行者。比如选择了角色A(共包括5个人)中的3个人(a、b、c)执行B活动,但是当活动A结束后,发现分配的任务给a并不合理,想分配给5个人中的另外一个人d,需要收回a。这个时候需要在活动A上有一个任务去做收回a这个人的任务的场景。
案例简介
本例为了简化实现方案,整个流程只设置了一个活动。该活动是多工作项,且其参与者由流程启动者指定。流程启动后,若发现指派的工作有误,可以通过收回操作撤销分配命令。
场景实现
部署/运行
- 启动BPS Server。
- 在Myeclipse中把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目录覆盖同名文件。
- 打开浏览器,在地址栏中输入https://localhost:8080/default打开BPS客户端登录页面。
- 在BPS客户端登录器中输入tiger,以密码000000登录,如下图所示:

- 登录后进入”分配任务”菜单对应的界面,为表单填充测试数据并点击<提交>按钮,如下图所示:

- 登录后进入”查看已分配任务”菜单对应的界面:

- 在上述界面中点击链接”查看明细”:

- 选中micky的任务,点击<收回>按钮,返回结果为:

点击<改派>按钮,选择任务人为snoppy:

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

-
使用BPS自带的角色关系在EOS Studio的组织模型视图中点击<刷新>按钮,结果如下:

-
在项目bps_example_callback下新建包com.primeton.example.workflow.callback.flow。在该包下创建流程”prjplan”。
- 绘制业务流程com.primeton.samples.workflow.callback.prjplan。

-
流程属性,为方便调试把流程启动者设为”任意人员启动”,并设置一些相关数据。
- 流程启动者

- 相关数据

- 流程启动者
-
“多工作项任务”属性,参与者设为相关数据,并增加表单设置。
- 参与者

- 表单

- 参与者
-
为了辅助本流程的运行,一共设计了5个页面流,分别用来实现分配任务、收回任务、改派任务、流程查看、工作项查看。
-
分配任务
‘任务分配Action代码’
public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request, HttpServletResponse reponse) {String prjName = request.getParameter("prjName");String ptName = request.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 = request.getParameterNames();int count=0;while(names.hasMoreElements()){if(((String)names.nextElement()).startsWith("pts"))count++;}Object[] participants = new WFParticipant[count/3];String id,name,typeCode;for(int i = 1;i<=count/3;i++){id = request.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();for(int i = 0;i<selectedworks.length;i++)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;for(int i = 1;i<=count/3;i++){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();for(int i = 0;i<selectedworks.length;i++)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();List<WFWorkItem> worklist = client.getWorklistQueryManager().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 协议进行授权 | 嗅谱网
转载请注明:转自《任务收回改派场景》
本文地址:http://www.xiupu.net/archives-7045.html
关注公众号:
微信赞赏
支付宝赞赏
