本帖最后由 bess 于 2012-12-13 14:05 编辑
Q:批量回退实现方法:
A:- 1)增加一种新的操作(可参考批量提交)
- 2)实现批量操作的方法如下,函数名doBatchApprove:
- public int doBatchBack(String[] docIds, WebUser user, Environment evt, ParamsTable params,
- Collection<String> allowedList) throws Exception {
- System.out.println("batch back start...");
- if (docIds == null || docIds.length == 0) {
- throw new Exception("{*[Please choose one]*}");
- }
- // BillDefiVO flowVO = null;
- FlowStateRT instance = null;
- int successCount = 0;
- int failCount = 0;
- for (int i = 0; i < docIds.length; i++) {
- Document doc = (Document) doView(docIds);
- if (doc != null) {
- instance = doc.getState();
- if (instance != null) {
- try {
- IRunner runner = JavaScriptFactory.getInstance(params.getSessionid(), instance.getFlowVO()
- .getApplicationid());
- runner.initBSFManager(doc, params, user, new ArrayList<ValidateMessage>());
- String currNodeId = "";
- // FlowStateRT rt = doc.getState();
- if (instance != null) {
- NodeRT node = instance.getNodeRT(user);
- if (node != null)
- currNodeId = node.getNodeid();
- }
- //Node nextNode = StateMachine.getNextAllowedNode(allowedList, instance.getFlowVO(), currNodeId);
-
- StateMachineHelper sh = new StateMachineHelper();
- Node nextNode = sh.getBackToNodeList(doc, currNodeId, user).iterator().next();//这个是关键,获取流程回退的节点
- doc.setLastFlowOperation(FlowType.getActionCode(nextNode));
- doApprove(params, instance, currNodeId, new String[] { nextNode.id }, FlowType
- .getActionCode(nextNode), "", evt, user);
- successCount++;
- } catch (Exception e) {
- failCount++;
- }
- }
- }
- }
- System.out.println("batch back end...");
- log.info("Approve " + docIds.length + " document(s) with " + failCount + " fail(s)");
- return successCount;
- }
复制代码 |