天翎MyApps技术社区 - 低代码平台 | 流程管理系统 | BPM软件

 找回密码
 注册成为天翎用户
查看: 1949|回复: 0

[源码] 批量回退实现方法【源码-批量回退】

[复制链接]
bess 发表于 2012-7-26 09:40:08 | 显示全部楼层 |阅读模式
本帖最后由 bess 于 2012-12-13 14:05 编辑

Q:批量回退实现方法:
A:
  1. 1)增加一种新的操作(可参考批量提交)
  2. 2)实现批量操作的方法如下,函数名doBatchApprove:

  3.                     public int doBatchBack(String[] docIds, WebUser user, Environment evt, ParamsTable params,
  4.                         Collection<String> allowedList) throws Exception {
  5.                 System.out.println("batch back start...");
  6.                 if (docIds == null || docIds.length == 0) {
  7.                         throw new Exception("{*[Please choose one]*}");
  8.                 }

  9.                 // BillDefiVO flowVO = null;
  10.                 FlowStateRT instance = null;

  11.                 int successCount = 0;
  12.                 int failCount = 0;

  13.                 for (int i = 0; i < docIds.length; i++) {
  14.                         Document doc = (Document) doView(docIds);

  15.                         if (doc != null) {
  16.                                 instance = doc.getState();

  17.                                 if (instance != null) {
  18.                                         try {
  19.                                                 IRunner runner = JavaScriptFactory.getInstance(params.getSessionid(), instance.getFlowVO()
  20.                                                                 .getApplicationid());
  21.                                                 runner.initBSFManager(doc, params, user, new ArrayList<ValidateMessage>());

  22.                                                 String currNodeId = "";
  23.                                                 // FlowStateRT rt = doc.getState();
  24.                                                 if (instance != null) {
  25.                                                         NodeRT node = instance.getNodeRT(user);
  26.                                                         if (node != null)
  27.                                                                 currNodeId = node.getNodeid();
  28.                                                 }

  29.                                                 //Node nextNode = StateMachine.getNextAllowedNode(allowedList, instance.getFlowVO(), currNodeId);
  30.                                                 
  31.                                                 StateMachineHelper sh = new StateMachineHelper();
  32.                                                 Node nextNode = sh.getBackToNodeList(doc, currNodeId, user).iterator().next();//这个是关键,获取流程回退的节点

  33.                                                 doc.setLastFlowOperation(FlowType.getActionCode(nextNode));

  34.                                                 doApprove(params, instance, currNodeId, new String[] { nextNode.id }, FlowType
  35.                                                                 .getActionCode(nextNode), "", evt, user);

  36.                                                 successCount++;
  37.                                         } catch (Exception e) {
  38.                                                 failCount++;
  39.                                         }
  40.                                 }
  41.                         }
  42.                 }
  43.                 System.out.println("batch back end...");
  44.                 log.info("Approve " + docIds.length + " document(s) with " + failCount + " fail(s)");
  45.                 return successCount;
  46.         }
复制代码

本版积分规则

QQ|手机版|天翎MyApps技术社区 ( 粤ICP备11093750号 )

GMT+8, 2026-8-12 14:30

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表