获取smartbi流程待办数据
package cn.com.smartbi.workflow; import smartbi.net.sf.json.JSONArray; import smartbi.net.sf.json.JSONObject; import smartbi.sdk.ClientConnector; import smartbi.sdk.InvokeResult; import smartbi.sdk.RemoteException; public class WorkflowAPITest { public static void main(String[] args) { String Smartbi_URL = "http://10.10.202.17:19700/smartbi"; ClientConnector conn = new ClientConnector(Smartbi_URL); InvokeResult result = null; try { // 先以指定用户登录smartbi boolean ret = conn.open("admin", "admin"); if (ret) { // 获取待办数量 // {"retCode":0,"result":{"startCount":31,"doneCount":11,"todoCount":14},"duration":10} result = conn.remoteInvoke("WorkflowModule", "allCount", new Object[] { null }); if ("0".equals(result.getOriginalResult().optString("retCode"))) { JSONObject json = (JSONObject) result.getResult(); System.out.println("待办数:" + json.optInt("todoCount")); System.out.println("已办数:" + json.optInt("doneCount")); System.out.println("我的发起数:" + json.optInt("startCount")); } // 搜索关键字 String keyword = ""; // 开始页码 int pageNo = 0; // 每页记录数 int pageSize = Integer.MAX_VALUE; // 获取待办列表 result = conn.remoteInvoke("WorkflowModule", "todoList", new Object[] { keyword, pageNo, pageSize }); if ("0".equals(result.getOriginalResult().optString("retCode"))) { JSONArray json = (JSONArray) result.getResult(); if (json.length() > 0) { System.out.println("待办:" + json.get(0).toString()); } } // 获取已办 result = conn.remoteInvoke("WorkflowModule", "doneList", new Object[] { keyword, pageNo, pageSize }); if ("0".equals(result.getOriginalResult().optString("retCode"))) { JSONArray json = (JSONArray) result.getResult(); if (json.length() > 0) { System.out.println("已办:" + json.get(0).toString()); } } // 获取我的发起 result = conn.remoteInvoke("WorkflowModule", "startList", new Object[] { keyword, pageNo, pageSize }); if ("0".equals(result.getOriginalResult().optString("retCode"))) { JSONArray json = (JSONArray) result.getResult(); if (json.length() > 0) { System.out.println("我的发起办:" + json.get(0).toString()); } } } } catch (RemoteException e) { e.printStackTrace(); } finally { conn.close(); } } }
// 待办数据返回结果 { "allAssignee": "", "activity": "用户任务", "endDate": "2021-06-08 10:35:45", "subject": "填报流程测试-管理员-2021-06-08 10:35:08", "modifyReport": false, "currentTask": null, "reportType": "", "path": "", "instanceId": "277727", "operations": null, "pageType": "", "ownerName": "管理员", "jumpNode": null, "processId": "", "processName": "", "draft": false, "define": "", "processKey": "Process1623119005447", "recallName": "", "reportInfo": null, "state": "", "createDate": "2021-06-08 10:35:08", "owner": "ADMIN", "currentUserName": "", "reportId": "", "canSave": false, "nodesState": null, "processDesc": "", "history": false, "nextTaskNeedToChooseHandle": false, "url": false, "currentUser": "", "subProcess": false, "hasRecallOperation": false, "commentRequired": false, "comment": "", "taskName": "", "assignee": "管理员", "nextTask": null, "taskId": "277816", "status": "用户任务" }
注意事项:
- 引入Smartbi SDK依赖包。二次开发#%E4%BA%8C%E6%AC%A1%E5%BC%80%E5%8F%91-_%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%AB%AFSDK
- 获取待办需要先以指定用户登录,但第三方系统往往没有Smartbi用户的密码,因此需要考虑单点登录问题。https://history.wiki.smartbi.com.cn/pages/viewpage.action?pageId=51942631