别的应用系统调用F2流程服务为主实行流程流转的应用境况,越发轻量整合调用尤其有利

最近尤为多的公司框架结构消除方案越发趋向于基于http协议“微服务”访问跨系统调用,而不采用统传的WebService调用,即透过RESTfull方式进行相互,越发轻量整合调用越发有益于。本文书档案中全部F2BPM开发接口API都足以发布成RESTfull对外应用服务接口

1. 引言

图片 1

1.1. 采取背景

图片 2

无时无刻集团的IT系统建设进一步多,往往3个供销社中形成各个独立的系统,各系统相对独立,缺少流程支掌,为直达通过营造流程服务主导向各市应用系统提供流程服务,同时将次第独立的类别以流程基本为扭带链接起来。

流程基本仅是当做后台管理,对于用户来说并不供给登录此平台上做相关的作业操作管理。流程基本作为利用系统的服务端,应用系统作为客户端。流程基本相对前端的客户来说是2个黑盒方式。

F2BPM流程服务基本(简称:F2流程中央),是指将F2-BPM做为流程平台独立安排成流程中央的方法,别的应用系统调用F2流程服务核心举办流程流转的选用境况。

是因为每一种卖家自个儿的IT系统应用环境千差万别,本文书档案给出F2流程中央使用到商店中作为流程基本的科学普及应用化解方案。

当下越发多的店堂架构化解方案越发趋向于基于http协议“微服务”框架结构,即由此RESTfull形式进行相互,特别轻量整合调用更上方便。F2流程中央使用方案也是提议利用轻量级的RESTfull方案。

RESTfull参数情势

1接纳方案形式

由于店铺的IT建设的条件不心相同,塑造流程基本的方案也会迥然区别,由于单独布署面临的一个最大题材就:用户协会架构难点、登录授权身份难点。所以会有例外的商行IT环境会有区别的应用方案形式。

  • 方案方式一:流程基本和平运动用系统同步相同数据库,程序独立布署方式
  • 方案方式二:流程基本和使用类别的数据库和顺序都是单独布署格局
  • 方案形式三:有统1个人事系统用户认证服务器,流程基本和行使系统的数据库和程序都以独立安排

 

authorJson:主要是接口地方的证实相关参数,校验访问者的根源合法性

2. 共用数据库形式

 图片 3

 

共用数据库形式是指流程基本与行使系统利用同一的数码,将流程基本的有着表建包涵流程基本平台用户组织表都成立在利用系统所在的数据库中。

那会儿流程基本的用户组织架构管理仅是当做流程基本平台管理员使用的用户组织,用于登录维护管理流程基本相关的工作。流程基本的用户组织与利用种类的用户协会非亲非故。而当调用流程基本执行流程流转时用户组织是因而引擎的用户协会架构接入的计划读取应用系统的用户组织,仍旧选用的是行使种类本身的用户组织架构。流程引擎使用的是选拔系统本身的用户组织架构,用户组织架构的有限支撑管理仍然是由使用系统本人来治本。

RESTfull的数据交互机制详细见Oauth2.0接口交互授权。

 

parmJson:请求业务数据的参数,比如分页参数,查询参数等

3. 独立程序和数据库计划格局

图片 4

 

数据库和顺序都以独立布置方式是指流程基本与行使种类应用各自的数据库。

这会儿流程基本自己数据库中的用户组织架构管理仅是当做流程基本平台管理员使用的用户协会,用于登录维护管理流程基本相关的业务。流程基本的用户组织与利用类别的用户组织无关。

而当调用流程基本推行流程流转时用户协会是透过重写F2用户协会框架结构接口的落到实处读取应用连串的用户协会框架结构,依旧采纳的是行使系统本人的用户组织架构。流程引擎使用的是重写完成公司接口的行使系统本身的用户协会框架结构,用户组织架构的有限支撑管理照旧是由使用系统本人来治本。

 

 

 

 

 

 

 

4. 用到统1位事系统用户服务器形式

 图片 5

 

 

应用统一个人事用户系统形式是最复杂但也是欧洲经济共同体集团新闻化条件比较好的法子,一般选用于相比较大的公司集团,他们的特征是数据库和顺序都是单独安插,流程基本与行使系统使用分别的数据库,同时各使用种类都以联合行使H奥迪Q3系统的用户协会架构。

那时代时尚程基本本人数据库中的用户协会架构管理仅是用作流程基本平台管理员使用的用户组织,用于登录维护管理流程基本相关的事体。流程基本的用户协会与使用类别的用户协会非亲非故。

而当调用流程基本实施流程流转时用户社团是通过重写F2用户协会架构接口的兑现读取应用系列的用户组织框架结构,依然采取的是应用系统本人的用户协会架构。流程引擎使用的是重写达成集体接口的施用系统本身的用户组织架构,用户协会架构的珍惜管理依旧是由使用系统本身来管理。

因公司消息化条件差距大,此方案必要各方一起共同执行才能完毕相比较好的功效。大家能够合营实施。

全数RESTfull都统2头有那多个Json参数  

5. RESTfull接口的OAuth2.0地位授权

 

5.1. 什么是OAuth2.0

OAuth2.0是多少个关于授权(authorization)的绽开网络正式,在满世界获得广泛应用,近年来的版本是2.0版。本文是对OAuth
2.0的规划思路和周转原理应用到F2BPM平塞内加尔达喀尔,目的是为着防备接口被不安全选择,接口的调用必须有平安的身价验证机制。

API开发接口与RestFull API服务发表代码示例

SmartFormRESTfullApi 在线表单的RestFull API服务

package com.f2bpm.controller.restfullapi;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import com.f2bpm.base.core.entity.AuthorEntity;
import com.f2bpm.base.core.entity.MyInteger;
import com.f2bpm.base.core.entity.PageParams;
import com.f2bpm.base.core.enums.ExtensionValidateType;
import com.f2bpm.base.core.utils.AppUtil;
import com.f2bpm.base.core.utils.ExtensionValidate;
import com.f2bpm.base.core.utils.FileDownUtil;
import com.f2bpm.base.core.utils.FileUtil;
import com.f2bpm.base.core.utils.JsonHelper;
import com.f2bpm.base.core.utils.string.StringUtil;
import com.f2bpm.base.core.utils.time.DateUtil;
import com.f2bpm.system.admin.impl.model.Users;
import com.f2bpm.system.security.utils.LogUtil;
import com.f2bpm.system.security.web.WebHelper;
import com.f2bpm.workflow.engine.api.entity.WorkflowInstanceContext;
import com.f2bpm.workflow.engine.api.model.TaskInstance;
import com.f2bpm.workflow.engine.api.model.TaskInstanceInfo;
import com.f2bpm.workflow.engine.api.model.WorkflowForm;
import com.f2bpm.workflow.engine.api.wapi.IWorkflowWAPIService;
import com.f2bpm.workflow.engine.helper.WfWebHelper;
import com.f2bpm.workflow.org.api.imodel.IUser;
import com.f2bpm.workflow.org.api.iservice.IUserService;
import com.f2bpm.workflow.smartForm.api.entity.BusObjectData;

/*
 * 在线表单RestFull API服务接口
 */
@Controller
@RequestMapping("/restfullapi/smartForm/")
public class SmartFormRESTfullApi {
    @Resource
    IUserService userService;
    public IWorkflowWAPIService WorkflowAPI = (IWorkflowWAPIService) AppUtil.getBean("WorkflowAPI");

    /**
     * 获取在线表单数据
     * 
     * @param parmJson
     * @param authorJson
     * @param response
     */
    @RequestMapping(value = "getOnlineFormData", method = RequestMethod.POST)
    public void getOnlineFormData(String parmJson, String authorJson, HttpServletResponse response) {
        String jsonResult = "";
        try {
            JSONObject jsonJSONObject = JSONObject.fromObject(parmJson);
            AuthorEntity authorEntity = JsonHelper.jsonToObject(authorJson, AuthorEntity.class);
            String loginAccount = authorEntity.getLoginAccount();
            // 流程实例ID
            String wiid = JsonHelper.getString(jsonJSONObject, "wiid");
            // 表单业务键
            String businessKey = JsonHelper.getString(jsonJSONObject, "businessKey");
            List<BusObjectData> data = WorkflowAPI.getSmartFormApiManager().getBusObjectListData(wiid, businessKey);
            jsonResult = JsonHelper.objectToJSON(data);
        } catch (Exception ex) {
            jsonResult = JsonHelper.outResult(false, ex.toString());
        }
        JsonHelper.write(response, jsonResult);
    }

    /**
     * 获取表单应用定义
     * 
     * @param parmJson
     * @param authorJson
     * @param response
     */
    @RequestMapping(value = "getWorkflowForm", method = RequestMethod.POST)
    public void getWorkflowForm(String parmJson, String authorJson, HttpServletResponse response) {
        String jsonResult = "";
        try {
            JSONObject jsonJSONObject = JSONObject.fromObject(parmJson);
            AuthorEntity authorEntity = JsonHelper.jsonToObject(authorJson, AuthorEntity.class);
            String loginAccount = authorEntity.getLoginAccount();
            String wid = JsonHelper.getString(jsonJSONObject, "wid");
            String appId = JsonHelper.getString(jsonJSONObject, "appId");
            WorkflowForm form = null;
            if (StringUtil.isEmpty(wid)) {
                // 启动时
                form = WorkflowAPI.getProcessDefManager().getWorkflowInfo(appId).getWorkflowFormRunned();
            } else {
                // 运行时
                form = WorkflowAPI.getProcessDefManager().getWorkflowInfo(wid, appId).getWorkflowFormRunned();

            }
            jsonResult = JsonHelper.objectToJSON(form);
        } catch (Exception ex) {
            jsonResult = JsonHelper.outResult(false, ex.toString());
        }
        JsonHelper.write(response, jsonResult);
    }

    /**
     * 获取表单手机端Html模板
     * 
     * @param parmJson wid:启动时可为空
     * @param authorJson
     * @param response
     */
    @RequestMapping(value = "getWorkflowFormMobileHtml", method = RequestMethod.POST)
    public void getWorkflowFormMobileHtml(String parmJson, String authorJson, HttpServletResponse response) {
        String jsonResult = "";
        try {
            JSONObject jsonJSONObject = JSONObject.fromObject(parmJson);
            AuthorEntity authorEntity = JsonHelper.jsonToObject(authorJson, AuthorEntity.class);
            String loginAccount = authorEntity.getLoginAccount();
            String wid = JsonHelper.getString(jsonJSONObject, "wid");//启用时可为空
            String appId = JsonHelper.getString(jsonJSONObject, "appId");
            String html= null;
            if (StringUtil.isEmpty(wid)) {
                // 启动时
                html = WorkflowAPI.getProcessDefManager().getWorkflowInfo(appId).getWorkflowFormRunned().getMobileTemplateContent();
            } else {
                // 运行时
                html = WorkflowAPI.getProcessDefManager().getWorkflowInfo(wid, appId).getWorkflowFormRunned().getMobileTemplateContent();

            }
            jsonResult = html;
        } catch (Exception ex) {
            jsonResult = JsonHelper.outResult(false, ex.toString());
        }
        JsonHelper.write(response, jsonResult);
    }
}

WorkflowBusinessRESTfullApi 流程运转相关的劳务接口

  1 package com.f2bpm.controller.restfullapi;
  2 
  3 import java.io.File;
  4 import java.io.FileInputStream;
  5 import java.io.IOException;
  6 import java.io.InputStream;
  7 import java.io.OutputStream;
  8 import java.util.List;
  9 
 10 import javax.annotation.Resource;
 11 import javax.servlet.http.HttpServletRequest;
 12 import javax.servlet.http.HttpServletResponse;
 13 
 14 import net.sf.json.JSONObject;
 15 
 16 import org.springframework.stereotype.Controller;
 17 import org.springframework.web.bind.annotation.RequestMapping;
 18 import org.springframework.web.bind.annotation.RequestMethod;
 19 import org.springframework.web.bind.annotation.ResponseBody;
 20 import org.springframework.web.multipart.MultipartFile;
 21 import org.springframework.web.multipart.MultipartHttpServletRequest;
 22 
 23 import com.f2bpm.base.core.entity.AuthorEntity;
 24 import com.f2bpm.base.core.entity.MyInteger;
 25 import com.f2bpm.base.core.entity.PageParams;
 26 import com.f2bpm.base.core.enums.ExtensionValidateType;
 27 import com.f2bpm.base.core.utils.AppUtil;
 28 import com.f2bpm.base.core.utils.ExtensionValidate;
 29 import com.f2bpm.base.core.utils.FileDownUtil;
 30 import com.f2bpm.base.core.utils.FileUtil;
 31 import com.f2bpm.base.core.utils.JsonHelper;
 32 import com.f2bpm.base.core.utils.string.StringUtil;
 33 import com.f2bpm.base.core.utils.time.DateUtil;
 34 import com.f2bpm.system.admin.impl.model.Users;
 35 import com.f2bpm.system.security.utils.LogUtil;
 36 import com.f2bpm.system.security.web.WebHelper;
 37 import com.f2bpm.workflow.engine.api.entity.WorkflowInstanceContext;
 38 import com.f2bpm.workflow.engine.api.model.ActivityInfo;
 39 import com.f2bpm.workflow.engine.api.model.TaskInstance;
 40 import com.f2bpm.workflow.engine.api.model.TaskInstanceInfo;
 41 import com.f2bpm.workflow.engine.api.wapi.IWorkflowWAPIService;
 42 import com.f2bpm.workflow.engine.helper.WfWebHelper;
 43 import com.f2bpm.workflow.org.api.imodel.IUser;
 44 import com.f2bpm.workflow.org.api.iservice.IUserService;
 45 /*
 46  * 流程运行相关 RestFull API服务接口
 47  */
 48 @Controller
 49 @RequestMapping("/restfullapi/workflowBusiness/")
 50 public class WorkflowBusinessRESTfullApi {
 51     @Resource
 52     IUserService userService;
 53 
 54     public IWorkflowWAPIService WorkflowAPI = (IWorkflowWAPIService) AppUtil.getBean("WorkflowAPI");
 55 
 56     /**
 57      * 查找任务实例
 58      * @param id
 59      * @param request
 60      * @param response
 61      * @return
 62      * @throws IOException
 63      */
 64     @ResponseBody
 65     @RequestMapping(value = "getTask", method = RequestMethod.GET)
 66     public TaskInstance getTask(String id, HttpServletRequest request, HttpServletResponse response) throws IOException {
 67         TaskInstance task = new TaskInstance();
 68         id = "031d2404-94d1-4566-8ade-21126b620904";
 69         task = WorkflowAPI.getWorkTaskManager().getTaskInstanceByTaskId(id);
 70         return task;
 71     }
 72 
 73     /**
 74      *  获取待办列表
 75      * @param authorJson
 76      * @param parmJson
 77      * @param request
 78      * @param response
 79      * @throws Exception
 80      */
 81     @RequestMapping(value = "getTodoList", method = RequestMethod.GET)
 82     public void getTodoList(String authorJson, String parmJson, HttpServletRequest request, HttpServletResponse response) throws Exception {
 83         JSONObject jsonJSONObject = JSONObject.fromObject(parmJson);
 84         PageParams pageParams = JsonHelper.jsonToObject(parmJson, PageParams.class);
 85         AuthorEntity authorEntity = JsonHelper.jsonToObject(authorJson, AuthorEntity.class);
 86         String loginAccount = authorEntity.getLoginAccount();
 87         MyInteger recordCount = new MyInteger(0);
 88         MyInteger pageCount = new MyInteger(0);
 89         String whereStr = JsonHelper.getString(jsonJSONObject, "whereStr");
 90         IUser user = userService.getUserByAccount(loginAccount);
 91         List<TaskInstanceInfo> list = WorkflowAPI.getWorkTaskManager().getTodoList(user.getUserId(), whereStr.toString(), pageParams.getOrderBy(), pageParams.getPageIndex(), pageParams.getPageSize(), pageCount, recordCount, true);
 92         String jsonString = JsonHelper.listToJSON(list);
 93         String jsonResult = JsonHelper.convertToEasyUIJsonResult(jsonString, pageParams.getPageSize(), pageParams.getPageIndex(), recordCount.getValue(), pageCount.getValue());
 94         JsonHelper.write(response, jsonResult);
 95     }
 96 
 97     /**
 98      *  已办列表
 99      * @param authorJson
100      * @param parmJson
101      * @param request
102      * @param response
103      * @throws Exception
104      */
105     @RequestMapping(value = "getDoneList", method = RequestMethod.POST)
106     public void getDoneList(String authorJson, String parmJson, HttpServletRequest request, HttpServletResponse response) throws Exception {
107         JSONObject jsonJSONObject = JSONObject.fromObject(parmJson);
108         PageParams pageParams = JsonHelper.jsonToObject(parmJson, PageParams.class);
109         AuthorEntity authorEntity = JsonHelper.jsonToObject(authorJson, AuthorEntity.class);
110         String loginAccount = authorEntity.getLoginAccount();
111         MyInteger recordCount = new MyInteger(0);
112         MyInteger pageCount = new MyInteger(0);
113         String whereStr = JsonHelper.getString(jsonJSONObject, "whereStr");
114         int isHistory = JsonHelper.getInt(jsonJSONObject, "isHistory");
115         IUser user = userService.getUserByAccount(loginAccount);
116         List<TaskInstanceInfo> list = null;
117         if (isHistory == 1) {
118             // 归档中的列表
119             list = WorkflowAPI.getHistoryDataManager().getHistoryDoneList(user.getUserId(), whereStr.toString(), pageParams.getOrderBy(), pageParams.getPageIndex(), pageParams.getPageSize(), pageCount, recordCount, true);
120         } else {
121             // 进行中的已办
122             list = WorkflowAPI.getWorkTaskManager().getDoneList(user.getUserId(), whereStr.toString(), pageParams.getOrderBy(), pageParams.getPageIndex(), pageParams.getPageSize(), pageCount, recordCount, true);
123         }
124 
125         String jsonString = JsonHelper.listToJSON(list);
126         String jsonResult = JsonHelper.convertToEasyUIJsonResult(jsonString, pageParams.getPageSize(), pageParams.getPageIndex(), recordCount.getValue(), pageCount.getValue());
127         JsonHelper.write(response, jsonResult);
128     }
129 
130     /**
131      * 响应发起流程
132      * @param authorJson
133      * @param parmJson
134      * @param request
135      * @param response
136      * @throws IOException
137      */
138     @RequestMapping(value = "startWorkflow", method = RequestMethod.POST)
139     public void startWorkflow(String authorJson, String parmJson, HttpServletRequest request, HttpServletResponse response) throws IOException {
140         JSONObject jsonJSONObject = JSONObject.fromObject(parmJson);
141         AuthorEntity authorEntity = JsonHelper.jsonToObject(authorJson, AuthorEntity.class);
142         String loginAccount = authorEntity.getLoginAccount();
143         // IUser user = userService.getUserByAccount(loginAccount);
144         String appId = JsonHelper.getString(jsonJSONObject, "appId");
145         String wiid = JsonHelper.getString(jsonJSONObject, "wiid");
146         String businessKey = JsonHelper.getString(jsonJSONObject, "businessKey");
147         String title = JsonHelper.getString(jsonJSONObject, "title");
148         String opinion = JsonHelper.getString(jsonJSONObject, "opinion");
149         String jsonFormData = JsonHelper.getString(jsonJSONObject, "jsonFormData");
150         StringBuilder message = new StringBuilder();
151         boolean success = WorkflowAPI.getWorkflowEnactmentManager().startWorkflow(appId, wiid, businessKey, title, opinion, loginAccount, null, message, jsonFormData, null, 0, 0);
152         String jsonResult = JsonHelper.outResult(success, message.toString());
153         JsonHelper.write(response, jsonResult);
154     }
155 
156     /**
157      *  驳回流程
158      * @param parmJson
159      * @param authorJson
160      * @param response
161      */
162     @RequestMapping(value = "rejectFlow", method = RequestMethod.POST)
163     public void rejectFlow(String parmJson, String authorJson, HttpServletResponse response) {
164         JSONObject jsonJSONObject = JSONObject.fromObject(parmJson);
165         AuthorEntity authorEntity = JsonHelper.jsonToObject(authorJson, AuthorEntity.class);
166         String loginAccount = authorEntity.getLoginAccount();
167         String taskId = JsonHelper.getString(jsonJSONObject, "taskId");
168         String opinion = JsonHelper.getString(jsonJSONObject, "opinion");
169         StringBuilder message = new StringBuilder();
170         boolean success = WorkflowAPI.getWorkflowEnactmentManager().rejectWorkflow(taskId, loginAccount, opinion, true, null, message);
171         String jsonResult = JsonHelper.outResult(success, message.toString());
172         JsonHelper.write(response, jsonResult);
173     }
174 
175     /**
176      * 作废流程实例
177      * 
178      * @param parmJson
179      * @param authorJson
180      * @param response
181      */
182     @RequestMapping(value = "invalidFlow", method = RequestMethod.POST)
183     public void invalidFlow(String parmJson, String authorJson, HttpServletResponse response) {
184         JSONObject jsonJSONObject = JSONObject.fromObject(parmJson);
185         AuthorEntity authorEntity = JsonHelper.jsonToObject(authorJson, AuthorEntity.class);
186         String loginAccount = authorEntity.getLoginAccount();
187         String taskId = JsonHelper.getString(jsonJSONObject, "taskId");
188         String opinion = JsonHelper.getString(jsonJSONObject, "opinion");
189         TaskInstance taskInstance = WorkflowAPI.getWorkTaskManager().getTaskInstanceByTaskId(taskId);
190         String wiid = taskInstance.getWorkflowInstanceId();
191         StringBuilder message = new StringBuilder();
192         IUser user = WorkflowAPI.getOrgEngineManager().getUserService().getUserByAccount(loginAccount);
193         boolean success = WorkflowAPI.getWorkflowEnactmentManager().invalidWorkflowInstance(wiid, opinion, user);
194         String jsonResult = JsonHelper.outResult(success, message.toString());
195         JsonHelper.write(response, jsonResult);
196     }
197 
198 
199     
200     /**
201      * 审批执行代办任务
202      * @param authorJson
203      * @param parmJson
204      * @param response
205      */
206     @RequestMapping(value = "approvalTask", method = RequestMethod.POST)
207     public void approvalTask(String authorJson, String parmJson, HttpServletResponse response) {
208         JSONObject jsonJSONObject = JSONObject.fromObject(parmJson);
209         AuthorEntity authorEntity = JsonHelper.jsonToObject(authorJson, AuthorEntity.class);
210         String loginAccount = authorEntity.getLoginAccount();
211         String taskId = JsonHelper.getString(jsonJSONObject, "taskId");
212         String opinion = JsonHelper.getString(jsonJSONObject, "opinion");
213         StringBuilder message = new StringBuilder();
214         boolean success = WorkflowAPI.getWorkflowEnactmentManager().sendWorkflowByTaskId(taskId, loginAccount, opinion, message);
215         String jsonResult = JsonHelper.outResult(success, message.toString());
216         JsonHelper.write(response, jsonResult);
217     }
218 
219     /**
220      * 获取任务指定节点的供选择人(计算出节点参与者)
221      * @param authorJson
222      * @param parmJson
223      * @param response
224      */
225     @RequestMapping(value = "getActivityUsers", method = RequestMethod.POST)
226     public void getActivityUsers(String authorJson, String parmJson, HttpServletResponse response) {
227         JSONObject jsonJSONObject = JSONObject.fromObject(parmJson);
228         AuthorEntity authorEntity = JsonHelper.jsonToObject(authorJson, AuthorEntity.class);
229         String loginAccount = authorEntity.getLoginAccount();
230         String taskId = JsonHelper.getString(jsonJSONObject, "taskId");
231         String activityId = JsonHelper.getString(jsonJSONObject, "activityId");
232         StringBuilder message = new StringBuilder();
233         WorkflowInstanceContext wfContext=WorkflowAPI.getWorkflowEnactmentManager().getWorkflowInstanceContextOnTodo(taskId, loginAccount);
234         TaskInstance  task = WorkflowAPI.getWorkTaskManager().getTaskInstanceByTaskId(taskId);
235         ActivityInfo activityInfo=WorkflowAPI.getProcessDefManager().getActivityInfo(task.getWorkflowId(), activityId);
236         List<IUser> list= WorkflowAPI.getWorkflowEnactmentManager().getListActorUserResultByActivityInfo(wfContext,activityInfo);
237         String jsonResult =JsonHelper.objectToJSON(list);
238         JsonHelper.write(response, jsonResult);
239     }
240     
241     /**
242      * 上传在线表单附件 上传在线表单附件, 返回字段值单个附件值,表单附件的字段值格式:
243      * [{filePathName:"/attachments/workflow/files/20170714215409547.txt"
244      * ,fileName:"TestClient.txt"}]
245      * 
246      * @param request
247      * @param response
248      */
249     @RequestMapping("uploadFile")
250     public void uploadFile(HttpServletRequest request, HttpServletResponse response) {
251         String jsonResult = "";
252         MultipartHttpServletRequest mRequest = (MultipartHttpServletRequest) request;
253         MultipartFile fileUpload = mRequest.getFile("FileUpload");
254         if (!fileUpload.isEmpty()) {
255 
256             try {
257                 String uploadType = WfWebHelper.query("UploadType", "");
258 
259                 String path = FileDownUtil.getWorkflowFilePath();
260                 String uploadFileName = fileUpload.getOriginalFilename();
261                 String fileExtension = uploadFileName.substring(uploadFileName.lastIndexOf("."));
262 
263                 if (!StringUtil.isNullOrWhiteSpace(uploadType)) {
264                     path = path + uploadType + "/";
265                     if (!FileUtil.isExistDirectory(path)) {
266                         FileUtil.createFolder(path);
267                     }
268                 }
269 
270                 if (!ExtensionValidate.validateExtension(fileExtension, ExtensionValidateType.FileExtension)) {
271                     jsonResult = JsonHelper.outResult(false, fileExtension + ",文件类型不允许上传!");
272                     JsonHelper.write(response, jsonResult);
273                     return;
274                 }
275                 uploadFileName = DateUtil.getCurrentDateTime("yyyyMMddHHmmssSSS") + fileExtension;
276                 String filePathName = path + uploadFileName;
277                 if (FileUtil.isExistFile(filePathName)) {
278                     FileUtil.deleteFile(filePathName);
279                 }
280                 File filePath = new File(filePathName);// 上传地址
281                 fileUpload.transferTo(filePath);
282 
283                 int index = filePathName.indexOf("attachments");
284                 String downfielNamePath = filePathName.substring(index);
285                 jsonResult = JsonHelper.outResult(true, "{filePathName:\"/" + downfielNamePath + "\",fileName:\"" + fileUpload.getOriginalFilename() + "\"}");
286 
287             } catch (RuntimeException | IOException ex) {
288                 jsonResult = JsonHelper.outResult(false, "上传失败");
289                 LogUtil.writeLog(ex.toString());
290             }
291         } else {
292             jsonResult = JsonHelper.outResult(false, "请选择要上传的文件");
293         }
294         JsonHelper.write(response, jsonResult);
295     }
296 
297     /**
298      * 附件下载
299      * @param authorJson
300      * @param parmJson
301      * @param request
302      * @param response
303      */
304     @RequestMapping("downloadFile")
305     public void downloadFile(String authorJson, String parmJson, HttpServletRequest request, HttpServletResponse response) {
306         try {
307             JSONObject jsonJSONObject = JSONObject.fromObject(parmJson);
308             AuthorEntity authorEntity = JsonHelper.jsonToObject(authorJson, AuthorEntity.class);
309             // String fileName = JsonHelper.getString(jsonJSONObject,
310             // "fileName");
311             String filePath = JsonHelper.getString(jsonJSONObject, "filePath");
312             String path = AppUtil.getWebRootPath() + filePath;
313             String fileName = new String(path.getBytes("iso8859-1"), "UTF-8");
314             File file = new File(fileName);
315             if (!file.exists()) {
316                 response.setStatus(404);
317                 String jsonResult = JsonHelper.outResult(false, "404 file not found!");
318                 JsonHelper.write(response, jsonResult);
319                 return;
320             }
321             // response.setCharacterEncoding("utf-8");
322             // response.setContentType("multipart/form-data");
323             // response.setHeader("Content-Disposition", "attachment;fileName="
324             // + fileName);
325             InputStream inputStream = new FileInputStream(file);
326             OutputStream os = response.getOutputStream();
327             byte[] b = new byte[1024];
328             int length;
329             while ((length = inputStream.read(b)) > 0) {
330                 os.write(b, 0, length);
331             }
332             inputStream.close();
333         } catch (Exception ex) {
334             LogUtil.writeLog(ex.toString());
335             response.setStatus(500);
336             ex.printStackTrace();
337             String jsonResult = JsonHelper.outResult(false, "500 err "+ex.getMessage());
338             JsonHelper.write(response, jsonResult);
339         }
340     }
341 }

客户端调用示例

  1 package com.f2bpm.restfullapi;
  2 
  3 import java.util.HashMap;
  4 import java.util.Map;
  5 
  6 import org.apache.http.client.HttpClient;
  7 import org.apache.http.client.methods.HttpPost;
  8 import org.apache.http.impl.client.DefaultHttpClient;
  9 
 10 import com.f2bpm.base.core.utils.Guid;
 11 import com.f2bpm.base.core.utils.HttpClientUtil;
 12 import com.f2bpm.base.core.utils.string.StringUtil;
 13 
 14 public class WorkflowBusinessTestClient {
 15 
 16     String webApiUrl = "http://localhost:8081/f2bpm/restfullapi";
 17     
 18     /**
 19      * get请求 get只适合参数相对简单的请求,如果参数过长或参数字符复杂,则使用Post 来传参请求
 20      * 这里仅是一个get示例,不建议使用get统一使用Post来做 不建议使用get统一使用Post来做 不建议使用get统一使用Post来做
 21      * 不建议使用get统一使用Post来做
 22      */
 23     public void getTask() {
 24         String url = webApiUrl + "/workflowBusiness/getTask?";
 25         String queryString="id=123";
 26         String param = HttpClientUtil.urlEncode(queryString.toString()); // 特殊字符进行转义
 27         url = url + param;
 28         String jsonRes = HttpClientUtil.get(url);
 29         System.out.println(jsonRes);
 30     }
 31 
 32 
 33 //    public void getTodoList() {
 34 //        String urlString = webApiUrl + "/workflowBusiness/getTodoList/?";
 35 //        StringBuilder queryString = new StringBuilder();
 36 //        queryString.append(StringUtil.format("authorJson={loginAccount:\"{0}\"}", "admin"));
 37 //        queryString.append(StringUtil.format("&parmJson={pageIndex:{0},pageSize:{1},sort:\"{2}\",order:\"{3}\"}", 1, 2, "CreatedTime", "desc"));
 38 //        String param = HttpClientUtil.urlEncode(queryString.toString()); // 特殊字符进行转义
 39 //        urlString = urlString + param;
 40 //        String jsonRes = HttpClientUtil.get(urlString);
 41 //        System.out.println(jsonRes);
 42 //    }
 43     
 44     /**
 45      * 获取待办列表
 46      */
 47     public void getTodoList() {
 48         String  url= webApiUrl + "/workflowBusiness/getTodoList/";
 49         Map<String, String> params = new HashMap<String, String>();
 50         StringBuilder queryString = new StringBuilder();
 51         params.put("authorJson", StringUtil.format("{loginAccount:\"{0}\"}", "admin"));
 52         params.put("parmJson", StringUtil.format("{pageIndex:{0},pageSize:{1},sort:\"{2}\",order:\"{3}\",whereStr:\"{4}\",}", 1, 2, "CreatedTime", "desc", ""));
 53         String jsonRes = HttpClientUtil.post(url, params);
 54         System.out.println(jsonRes);
 55     }
 56     /**
 57      * 获取已办列表
 58      */
 59     public void getDoneList() {
 60         String urlString = webApiUrl + "/workflowBusiness/getDoneList/";
 61         Map<String, String> params = new HashMap<String, String>();
 62         StringBuilder queryString = new StringBuilder();
 63         params.put("authorJson", StringUtil.format("{loginAccount:\"{0}\"}", "admin"));
 64         // isHistory:0 进行中的已办,isHistory:1流程已结束并归档的已办
 65         params.put("parmJson", StringUtil.format("{isHistory:0,pageIndex:{0},pageSize:{1},sort:\"{2}\",order:\"{3}\",whereStr:\"{4}\",}", 1, 2, "CreatedTime", "desc", ""));
 66         String jsonRes = HttpClientUtil.post(urlString, params);
 67         System.out.println(jsonRes);
 68     }
 69 
 70     /**
 71      * 发起流程
 72      */
 73     public void startWorkflow() {
 74         String urlString = webApiUrl + "/workflowBusiness/startWorkflow/";
 75         Map<String, String> params = new HashMap<String, String>();
 76         String onlineFormData = StringUtil.format("[{\"mainTable\":\"csb\",\"data\":[{\"name\":\"csb.nl\",\"value\":\"22\"},{\"name\":\"csb.MyId\",\"value\":\"\"},{\"name\":\"csb.zz\",\"value\":\"RestFull测试\"},{\"name\":\"csb.xm\",\"value\":\"RestFull姓名\"}],\"subTables\":[]}]");
 77         params.put("authorJson", StringUtil.format("{loginAccount:\"{0}\"}", "admin"));
 78         params.put("parmJson", StringUtil.format("{appId:\"{0}\",wiid:\"{1}\",businessKey:\"{2}\",title:\"{3}\",opinion:\"{4}\",jsonFormData:{5}}", "ZX", Guid.getGuid(), Guid.getGuid(), "应用端RestFull请求测试", "同意", onlineFormData));
 79         // String param = HttpClientUtil.urlEncode(queryString.toString());
 80         // //特殊字符进行转义
 81         String jsonRes = HttpClientUtil.post(urlString, params);
 82         System.out.println(jsonRes);
 83     }
 84 
 85     /**
 86      * 驳回到提单
 87      */
 88     public void rejectFlow() {
 89         String urlString = webApiUrl + "/workflowBusiness/rejectFlow/";
 90         Map<String, String> params = new HashMap<String, String>();
 91         params.put("authorJson", StringUtil.format("{loginAccount:\"{0}\"}", "admin"));
 92         params.put("parmJson", StringUtil.format("{taskId:\"{0}\",opinion:\"{1}\"}", "d212c718-b6ea-481e-b7cc-1f44a9d47fd0", "驳回"));
 93         String jsonRes = HttpClientUtil.post(urlString, params);
 94         System.out.println(jsonRes);
 95     }
 96 
 97     /**
 98      * 作废工单
 99      */
100     public void invalidFlow() {
101         String urlString = webApiUrl + "/workflowBusiness/invalidFlow/";
102         Map<String, String> params = new HashMap<String, String>();
103         params.put("authorJson", StringUtil.format("{loginAccount:\"{0}\"}", "admin"));
104         params.put("parmJson", StringUtil.format("{taskId:\"{0}\",opinion:\"{1}\"}", "eac4e893-822c-46ec-9ba6-a1c028a1cef3", "作废"));
105         String jsonRes = HttpClientUtil.post(urlString, params);
106         System.out.println(jsonRes);
107     }
108 
109     /**
110      * 审批执行代办任务
111      */
112     public void approvalTask() {
113         String urlString = webApiUrl + "/workflowBusiness/approvalTask/";
114         Map<String, String> params = new HashMap<String, String>();
115         params.put("authorJson", StringUtil.format("{loginAccount:\"{0}\"}", "admin"));
116         params.put("parmJson", StringUtil.format("{taskId:\"{0}\",opinion:\"{1}\"}", "5f267057-ddd4-470a-bca4-a797caac3e09", "原则同意"));
117         String jsonRes = HttpClientUtil.post(urlString, params);
118         System.out.println(jsonRes);
119     }
120 
121 
122     /**
123      *上传在线表单附件,返回字段值单个附件值
124     /表单附件的字段值格式:
125     /#[{"value":"/attachments/workflow/files/20170714215204767.txt","text":"TestClient.txt"}]#
126     */
127     public void uploadFormFile() {
128         String urlString = webApiUrl + "/workflowBusiness/uploadFile/?loginAccount=admin";
129         String filepath = "C:\\Users\\Administrator\\Desktop\\TestClient.txt";
130         String jsonRes = HttpClientUtil.postFile(urlString, filepath);
131         System.out.println(jsonRes);
132     }
133     /**
134      * 下载表单附件
135      */
136     public void downLoadFile() {
137         String urlString = webApiUrl + "/workflowBusiness/downloadFile/";
138         //保存到本地的地址
139         String filepath = "C:\\Users\\Administrator\\Desktop\\TestClient.txt";
140         
141         Map<String, String> params = new HashMap<String, String>();
142         params.put("authorJson", StringUtil.format("{login Account:\"{0}\"}", "admin"));
143         params.put("parmJson", StringUtil.format("{filePath:\"{0}\"}", "/attachments/workflow/files/20170714215204767.txt"));
144         String jsonRes = HttpClientUtil.downLoadFile(urlString,filepath, params);
145         System.out.println(jsonRes);
146         
147     }
148     
149     public static void main(String[] args) {
150         WorkflowBusinessTestClient client = new WorkflowBusinessTestClient();
151         client.downLoadFile();
152         System.out.print("结束");
153     }
154 
155 }

 

5.2. OAuth2.0与F2-BPM平台

因为要将F2-BPM平台做为流程服务中央,那么F2-BPM平台就会与七个使用类别打交道,五个应该系统经过调用RESTfull接口来驱动流程照旧取得流程相关数据时索要安全认证后才方可实行接口影响重临正确的数码结果。

F2-BPM流程基本创设了OAuth2.0的身价验证机制,此身份的印证是应当系统级别的,目标验证是还是不是来自官方注册的应该系统调用了工艺流程基本的RESTfull接口。(数据涉嫌的用户是行使系统开发调用流程基本接口时间控制制)。

本流程主题的OAuthor并非用于用户的第2方登录认证,当然也能扩张出来,但出于F2-BPM并非人事系统的相会用户管理宗旨。

5.3. F2-BPM流水生产线大旨OAUTH2.0身份验证时序图

 图片 6

各类接口必须传递的数额:{token:,corpId:,timeStamp:,nonce:,signature:,loginAccount:}

参数名

值示例

说明

token

oa_token

系统令牌,在流程中心配置的固定值

corpId

app255e7feb2645dd23

应用系统的ID,在流程中心增加应用接入时生成的ID

timeStamp

1706261844

时间戳,传递时由客户端生成,格式:yymmddHHmm,客户端时间与F2-PBM流程中心系统时间误差充许在10分钟以内

nonce

6723

随时数,由客户端生成一个至少4位的随时数

signature

ZDlUMYZeJKXrAZ3ofbZQnXgSPqjHw9xw2lZhj0hPwF5VUG0yMhknJ-8Ql8zK8tXK

签名加密字符串,由客户端将timeStamp和nonce进行加密得到此签名加密字符串

loginAccount

zs

当前登录者的账号,用于作为调用RESTfull接口流程引擎将以此账号作为流程引擎运行中的当前登录人身份

 

客户端与流程基本接口交互参数表明:

authorJson:首借使接口地方的注明相关参数,校验访问者的发源合法性

parmJson:请求业务数据的参数,比如分页参数,查询参数等
全部RESTfull都统一头有这三个Json参数 一般景观

 

get只适合参数相对简便易行的央求,如若参数过长或参数字符复杂,则动用Post
来传参请求。

 

F2BPM接口强大的特性:服务端能够动用F2BPM万分丰盛的流水生产线引擎WAPI举行揭露成RESTfull服务接口供应用端系统调用。而且接口能够是无状态的呼吁

客户端Get请求  

/**
     * get请求 get只适合参数相对简单的请求,如果参数过长或参数字符复杂,则使用Post 来传参请求
     */
    public void getTodoList() {
        String urlString = webApiUrl + "/workflowBusiness/getTodoList/?";
        StringBuilder queryString = new StringBuilder();
        queryString.append(StringUtil.format("authorJson={loginAccount:\"{0}\"}", "admin"));
        queryString.append(StringUtil.format("&parmJson={pageIndex:{0},pageSize:{1},sort:\"{2}\",order:\"{3}\"}", 1, 2, "CreatedTime", "desc"));
        String param = HttpClientUtil.urlEncode(queryString.toString()); // 特殊字符进行转义
        urlString = urlString + param;
        String jsonRes = HttpClientUtil.get(urlString);
        System.out.println(jsonRes);
    } 

相应的流程基本服务端

// 获取待办列表
    @RequestMapping(value = "getTodoList", method = RequestMethod.GET)
    public void getTodoList(String authorJson, String parmJson, HttpServletRequest request, HttpServletResponse response) throws Exception {
        JSONObject jsonJSONObject = JSONObject.fromObject(parmJson);
        PageParams pageParams = JsonHelper.jsonToObject(parmJson, PageParams.class);
        AuthorEntity authorEntity = JsonHelper.jsonToObject(authorJson, AuthorEntity.class);
        String loginAccount = authorEntity.getLoginAccount();
        MyInteger recordCount = new MyInteger(0);
        MyInteger pageCount = new MyInteger(0);
        String whereStr = JsonHelper.getString(jsonJSONObject, "whereStr");
        IUser user = userService.getUserByAccount(loginAccount);
        List<TaskInstanceInfo> list = WorkflowAPI.getWorkTaskManager().getTodoList(user.getUserId(), whereStr.toString(), pageParams.getOrderBy(), pageParams.getPageIndex(), pageParams.getPageSize(), pageCount, recordCount, true);
        String jsonString = JsonHelper.listToJSON(list);
        String jsonResult = JsonHelper.convertToEasyUIJsonResult(jsonString, pageParams.getPageSize(), pageParams.getPageIndex(), recordCount.getValue(), pageCount.getValue());
        JsonHelper.write(response, jsonResult);
    }

 

Post请求来得到已办列表

   /**
     * post请求,参数复杂的建议使用Post来请求
     */
    public void getDoneList() {
        String urlString = webApiUrl + "/workflowBusiness/getDoneList/";
        Map<String, String> params = new HashMap<String, String>();
        StringBuilder queryString = new StringBuilder();
        params.put("authorJson", StringUtil.format("{loginAccount:\"{0}\"}", "admin"));
        // isHistory:0 进行中的已办,isHistory:1流程已结束并归档的已办
        params.put("parmJson", StringUtil.format("{isHistory:0,pageIndex:{0},pageSize:{1},sort:\"{2}\",order:\"{3}\",whereStr:\"{4}\",}", 1, 2, "CreatedTime", "desc", ""));
        String jsonRes = HttpClientUtil.post(urlString, params);
        System.out.println(jsonRes);
    }

// 流程中心服务-已办列表
    @RequestMapping(value = "getDoneList", method = RequestMethod.POST)
    public void getDoneList(String authorJson, String parmJson, HttpServletRequest request, HttpServletResponse response) throws Exception {
        JSONObject jsonJSONObject = JSONObject.fromObject(parmJson);
        PageParams pageParams = JsonHelper.jsonToObject(parmJson, PageParams.class);
        AuthorEntity authorEntity = JsonHelper.jsonToObject(authorJson, AuthorEntity.class);
        String loginAccount = authorEntity.getLoginAccount();
        MyInteger recordCount = new MyInteger(0);
        MyInteger pageCount = new MyInteger(0);
        String whereStr = JsonHelper.getString(jsonJSONObject, "whereStr");
        int isHistory = JsonHelper.getInt(jsonJSONObject, "isHistory");
        IUser user = userService.getUserByAccount(loginAccount);
        List<TaskInstanceInfo> list =null;
        if(isHistory==1){
            //归档中的列表
              list = WorkflowAPI.getHistoryDataManager().getHistoryDoneList(user.getUserId(), whereStr.toString(), pageParams.getOrderBy(), pageParams.getPageIndex(), pageParams.getPageSize(), pageCount, recordCount, true);
        }else {
            //进行中的已办
             list = WorkflowAPI.getWorkTaskManager().getDoneList(user.getUserId(), whereStr.toString(), pageParams.getOrderBy(), pageParams.getPageIndex(), pageParams.getPageSize(), pageCount, recordCount, true);
        }

        String jsonString = JsonHelper.listToJSON(list);
        String jsonResult = JsonHelper.convertToEasyUIJsonResult(jsonString, pageParams.getPageSize(), pageParams.getPageIndex(), recordCount.getValue(), pageCount.getValue());
        JsonHelper.write(response, jsonResult);
    }

 输出响应结果到客户端

{"success":true,"msg":"","total":4,"pageCount":2,"pageSize":2,"pageIndex":1, "rows":[{"isDelegateDone":false,"workflowTitle":"[系统管理员费用报销申请","directBackAct":"","expectFinishedTime":
{"time":0,"minutes":0,"seconds":0,"hours":8,"month":0,"year":70,"timezoneOffset":-480,"day":4,"date":1},"businessKey":"","delegatorUserId":"","respondType":"","delegatorRealName":"",
"wiState":0,"taskExpireTime":null,"mainActivityInstanceId":"","urgency":1,"activityId":"","extStr":"","formId":"bdd11478-97ab-4612-beb9-575a3b3d9e83","description":"","userId":"3c1df0b3-a4d9-4731-b143-02e81bce17ce",
"delegatorName":"","userName":"","opinion":"","taskDealHours":0,"appType":"表单规则2.0","isCirculated":false,"isContainDelegator":false,"currentActors":"","fromCreatorID":"","taskCreateType":"","currentActivityName":"",
"openBizDate":"","isReferred":false,"delegatorMobile":"","importance":1,"workflowInstanceState":2,"activityShowName":"","userMobile":"","creatorRealName":"系统管理员","userDpId":"","taskState":0,"isValid":false,"userDpName":"",
"appId":"AI","formType":"","workflowInstanceId":"5e2cfc5b-3fcb-4ae5-ae1d-fbdb27b4980e","creatorDepartId":"ZhiBoRuanJian","fromTaskId":"","activityInstanceId":"","taskSeq":"","creator":"admin","realTime":null,
"isCompleter":false,"completedType":"","delegatorDpName":"","finishedTime":null,"isMobileApproval":true,"stepId":0,"delegatorDpId":"","isMobileStart":true,"taskId":"","requirement":"",
"createdTime":{"time":1499268876000,"minutes":34,"seconds":36,"hours":23,"month":6,"year":117,"timezoneOffset":-480,"day":3,"date":5},"logs":"","creatorId":"3c1df0b3-a4d9-4731-b143-02e81bce17ce",
"taskRemark":"","secrecy":0,"commentCount":0,"mainWorkflowInstanceId":"","appName":"费用报销申请","sheetId":"AI20170705233435818","completedTime":null,"isDelegatorCompleted":false,"workflowId":"3944ea6b-0c56-4c74-8b0e-af82d128f772",
"urgeTimes":0,"creatorDpName":"致博软件","fromCreator":"","realName":"","activityName":"","startedTime":{"time":1499268876000,"minutes":34,"seconds":36,"hours":23,"month":6,"year":117,
"timezoneOffset":-480,"day":3,"date":5}},{"isDelegateDone":false,"workflowTitle":"系统管理员请假申请","directBackAct":"","expectFinishedTime":{"time":0,"minutes":0,"seconds":0,"hours":8,"month":0,"year":70,"timezoneOffset":-480,"day":4,"date":1},"businessKey":"","delegatorUserId":"","respondType":"","delegatorRealName":"",
"wiState":0,"taskExpireTime":null,"mainActivityInstanceId":"","urgency":1,"activityId":"","extStr":"","formId":"26eaad7d-ccfb-4b6a-96c0-4efc796f5d47","description":"","userId":"3c1df0b3-a4d9-4731-b143-02e81bce17ce","delegatorName":"","userName":"","opinion":"","taskDealHours":0,"appType":"表单规则2.0","isCirculated":false,"isContainDelegator":false,"currentActors":"","fromCreatorID":"","taskCreateType":"","currentActivityName":"","openBizDate":"","isReferred":false,"delegatorMobile":"","importance":1,"workflowInstanceState":2,"activityShowName":"","userMobile":"",
"creatorRealName":"系统管理员","userDpId":"","taskState":0,"isValid":false,"userDpName":"",
"appId":"AB","formType":"","workflowInstanceId":"a4d02561-7dc0-4a01-9368-687363081395","creatorDepartId":"ZhiBoRuanJian","fromTaskId":"",
"activityInstanceId":"","taskSeq":"","creator":"admin","realTime":null,"isCompleter":false,"completedType":"","delegatorDpName":"","finishedTime":null,"isMobileApproval":true,"stepId":0,"delegatorDpId":"","isMobileStart":true,"taskId":"","requirement":"","createdTime":{"time":1499268669000,"minutes":31,"seconds":9,"hours":23,"month":6,"year":117,"timezoneOffset":-480,"day":3,"date":5},"logs":"","creatorId":"3c1df0b3-a4d9-4731-b143-02e81bce17ce","taskRemark":"","secrecy":0,"commentCount":0,"mainWorkflowInstanceId":"",
"appName":"请假申请","sheetId":"AB20170705233109293","completedTime":null,"isDelegatorCompleted":false,
"workflowId":"4ae848a4-70f7-4e76-bd35-8f33f5bbac1e","urgeTimes":0,"creatorDpName":"致博软件","fromCreator":"","realName":"","activityName":"",
"startedTime":{"time":1499268669000,"minutes":31,"seconds":9,"hours":23,"month":6,"year":117,"timezoneOffset":-480,"day":3,"date":5}}]}

 

提倡流程示例:

客户端

/**
     * post请求
     */
    public void startWorkflow() {
        String urlString = webApiUrl + "/workflowBusiness/startWorkflow/";
        Map<String, String> params = new HashMap<String, String>();
        StringBuilder queryString = new StringBuilder();
        String onlineFormData = StringUtil.format("[{\"mainTable\":\"csb\",\"data\":[{\"name\":\"csb.nl\",\"value\":\"22\"},{\"name\":\"csb.MyId\",\"value\":\"\"},{\"name\":\"csb.zz\",\"value\":\"RestFull测试\"},{\"name\":\"csb.xm\",\"value\":\"RestFull姓名\"}],\"subTables\":[]}]");
        params.put("authorJson", StringUtil.format("{loginAccount:\"{0}\"}", "admin"));
        params.put("parmJson", StringUtil.format("{appId:\"{0}\",wiid:\"{1}\",businessKey:\"{2}\",title:\"{3}\",opinion:\"{4}\",jsonFormData:{5}}", "ZX", Guid.getGuid(), Guid.getGuid(), "应用端RestFull请求测试", "同意", onlineFormData));
        // String param = HttpClientUtil.urlEncode(queryString.toString());
        // //特殊字符进行转义
        String jsonRes = HttpClientUtil.post(urlString, params);
        System.out.println(jsonRes);
    }

 

流程基本拍卖发起呼吁

    //响应发起流程
    @RequestMapping(value = "startWorkflow", method = RequestMethod.POST)
    public void startWorkflow(String authorJson, String parmJson, HttpServletRequest request, HttpServletResponse response) throws IOException {
        JSONObject jsonJSONObject = JSONObject.fromObject(parmJson);
        AuthorEntity authorEntity = JsonHelper.jsonToObject(authorJson, AuthorEntity.class);
        String loginAccount = authorEntity.getLoginAccount();
        // IUser user = userService.getUserByAccount(loginAccount);
        String appId = JsonHelper.getString(jsonJSONObject, "appId");
        String wiid = JsonHelper.getString(jsonJSONObject, "wiid");
        String businessKey = JsonHelper.getString(jsonJSONObject, "businessKey");
        String title = JsonHelper.getString(jsonJSONObject, "title");
        String opinion = JsonHelper.getString(jsonJSONObject, "opinion");
        String jsonFormData = JsonHelper.getString(jsonJSONObject, "jsonFormData");
        StringBuilder message = new StringBuilder();
        boolean success = WorkflowAPI.getWorkflowEnactmentManager().startWorkflow(appId, wiid, businessKey, title, opinion, loginAccount, null, message, jsonFormData, null, 0, 0);
        String jsonResult = JsonHelper.outResult(success, message.toString());
        JsonHelper.write(response, jsonResult);
    }