activiti7和activiti5相比較而言,個人認為是增加了些api,還有優化了流程節點操作( PVM,ActivitiImpl,PvmTransition ,ExecutionImpl, TransitionImpl 可以通過bpmnModel和process獲取)
關於在線流程設計器,activiti5官網有提供相應的editor-app、diagram-viewer文件,其實也可以去http://bpmn.io 上去下載。
在了解activiti之前,首先應該充分了解這二十五張表,網上這些教學視頻關於表結構都講的很粗略,其實只有表結構掌握完全后,才能更好的去用activiti。
從某種程度上講,activiti其實就是這二十五張表的表單操作。相關api也就是教會我們如何更好的對這些進行增刪改查。
網上講述的都是基礎的使用案例,只是告訴你怎么用。如果說要你給公司搭一個activiti底層架子,跟公司業務結合起來(功能權限、數據權限、部門角色關系、短信等其他業務),
還是有些難度的,一般都要自己建些輔助表來優化這些操作。
相關表
https://www.devdoc.cn/activiti-table-summary.html
流程定義數據表 ( act_re_procdef )
流程設計模型部署表 ( act_re_model )
部署信息表 ( act_re_deployment )
進制數據表,存儲通用的流程定義和流程資源。(act_ge_bytearray)
屬性數據表 (act_ge_property)
運行時流程執行實例表 ( act_ru_execution )
act_ru_event_subscr
運行時流程人員表 ( act_ru_identitylink )
運行時定時任務數據表 ( act_ru_job )
運行時任務節點表 ( act_ru_task )
運行時流程變量數據表 ( act_ru_variable )
歷史節點表 (act_hi_actinst)
歷史附件表 ( act_hi_attachment )
歷史意見表 ( act_hi_comment )
歷史詳情表 ( act_hi_detail )
歷史流程人員表 ( act_ru_identitylink )
歷史流程實例表 (act_hi_procinst)
歷史任務實例表 ( act_hi_taskinst )
歷史變量表 ( act_hi_varinst )
用戶組信息表 ( act_id_group )
用戶擴展信息表 ( act_id_info )
用戶與分組對應信息表 ( act_id_membership )
用戶信息表 ( act_id_user )
在線流程設計器設計好后,可以用此來保存模型
流程模型:
- 通過RepositoryService的saveModel方法將模型的元數據存入數據庫的ACT_RE_MODEL表
- 通過RepositoryService的addModelEditorSource方法將模型JSON數據UTF8字符串存入數據庫的ACT_GE_BYTEARRAY表
- 通過Apache™ Batik SVG Toolkit將模型的SVG圖像數據轉換成PNG格式,通過RepositoryService的addModelEditorSource
和 addModelEditorSourceExtra方法將PNG圖像存入數據庫的ACT_GE_BYTEARRAY表
package com.hainei.service.workflow; import com.alibaba.fastjson.JSON; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; import org.activiti.engine.RepositoryService; import org.activiti.engine.repository.Model; import org.apache.batik.transcoder.TranscoderInput; import org.apache.batik.transcoder.TranscoderOutput; import org.apache.commons.io.IOUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import static org.activiti.editor.constants.ModelDataJsonConstants.MODEL_ID; import static org.activiti.editor.constants.ModelDataJsonConstants.MODEL_NAME; /** * FileName: EditorService * Author: Administrator * Date: 2019/4/18 9:48 * Description: */ @Service public class EditorService { @Autowired private RepositoryService repositoryService; @Autowired private ObjectMapper objectMapper; public Object getStencilset() throws IOException { InputStream stencilsetStream = this.getClass().getClassLoader().getResourceAsStream("stencilset.json"); String s= IOUtils.toString(stencilsetStream, "utf-8"); return com.alibaba.fastjson.JSON.parse(s); } /** * 在線流程設計器查看返參 * @param modelId * @return * @throws IOException */ public Object getEditorJson(String modelId) throws IOException { ObjectNode modelNode = null; Model model = repositoryService.getModel(modelId); if (model != null) { // if (StringUtils.isNotEmpty(model.getMetaInfo())) { // modelNode = (ObjectNode) objectMapper.readTree(model.getMetaInfo()); // } else { modelNode = objectMapper.createObjectNode(); modelNode.put(MODEL_NAME, model.getName()); // } byte[] source = repositoryService.getModelEditorSource(model.getId()); modelNode.put(MODEL_ID, model.getId()); if(source !=null) { ObjectNode editorJsonNode = (ObjectNode) objectMapper.readTree(new String(source, "utf-8")); modelNode.set("model", editorJsonNode); } else{ modelNode.set("model", null); } return com.alibaba.fastjson.JSON.parse(modelNode.toString()); } return null; } /** * 在線流程設計器保存模型 * * @param modelId * @param name * @param description * @param json_xml * @param svg_xml * @throws IOException */ //保存模型 public void saveModel(String modelId, String name, String description, String json_xml, String svg_xml) throws IOException{ Model model = repositoryService.getModel(modelId); String metaInfo = model.getMetaInfo(); // ObjectNode modelJson = null; // if(metaInfo ==null || metaInfo.length() == 0){ // modelJson = objectMapper.createObjectNode(); // }else { // modelJson = (ObjectNode) objectMapper.readTree(metaInfo); // } // modelJson.put(MODEL_NAME, name); // modelJson.put(MODEL_DESCRIPTION, description); // model.setMetaInfo(modelJson.toString()); model.setMetaInfo(metaInfo); model.setName(name); repositoryService.saveModel(model); repositoryService.addModelEditorSource(model.getId(), json_xml.getBytes("utf-8")); InputStream svgStream = new ByteArrayInputStream(svg_xml.getBytes("utf-8")); TranscoderInput input = new TranscoderInput(svgStream); // Setup output ByteArrayOutputStream outStream = new ByteArrayOutputStream(); TranscoderOutput output = new TranscoderOutput(outStream); // PNGTranscoder transcoder = new PNGTranscoder(); // Do the transformation // transcoder.transcode(input, output); final byte[] result = outStream.toByteArray(); repositoryService.addModelEditorSourceExtra(model.getId(), result); outStream.close(); } }
我司 工作流流程:
1.流程模型act_re_model新增信息,接着 流程設計器在線繪制流程圖 根據 modelId,以及xml 保存流程圖到 act_ge_bytearray表中。
2.部署流程模型后,會在act_re_deployment保存部署信息,接着在流程定義表中 act_re_procdef上 留下記錄。
3.接着初始化流程實例,提交businessKey ,選擇相應的processDefinitionKey。會生成流程實例。
相關問題:
1.若用戶節點 執行人為空,有候選人、候選組,任務執行到當前節點時,候選人審批需要簽收當前任務。
11111