SpringBoot整合Activiti Explorer 5.22.0

记一次整合activity5.22.0

1、下载activiti-explorer

首先我们需要获取activiti-explorer.zip(目前使用activiti-5.22.0版本),压缩包可以在网络上下载,或者从官网下载Get started | Activiti 下载5.x版本

SpringBoot整合Activiti Explorer 5.22.0_第1张图片

2、项目中集成

2.1 前端相关放在static目录下

SpringBoot整合Activiti Explorer 5.22.0_第2张图片

2.2 调整app-cfg.js文件

SpringBoot整合Activiti Explorer 5.22.0_第3张图片

2.3 修改/editor-app/configuration/toolbar-default-actions.js请求方式

SpringBoot整合Activiti Explorer 5.22.0_第4张图片

 

 2.4 复制war里面的相关java文件(ModelEditorJsonRestResource.java、ModelSaveRestResource.java、StencilsetRestResource.java)并进行调整

 

SpringBoot整合Activiti Explorer 5.22.0_第5张图片

2.5 调整请求方式为POST 

SpringBoot整合Activiti Explorer 5.22.0_第6张图片

2.6 POM文件相关的依赖


			org.springframework.boot
			spring-boot-starter-web
		
		
			org.mybatis.spring.boot
			mybatis-spring-boot-starter
			2.1.0
		
		
            org.projectlombok
            lombok
            true
        
		
			mysql
			mysql-connector-java
			runtime
		
		
		    org.springframework.boot
		    spring-boot-starter-logging
		
		
		    com.alibaba
		    druid
		    1.0.7
		
		
			org.springframework.boot
			spring-boot-starter-test
			test
		
		
			commons-io
			commons-io
			2.5
		
		 
		 
			org.activiti
			activiti-spring-boot-starter-basic
			${activiti.version}
			
	        	
		            org.mybatis
		            mybatis
		        
		        
		         	org.springframework.boot
            		spring-boot-starter-security
		        
		    
		
		
		
		    org.activiti
		    activiti-diagram-rest
		    ${activiti.version}
		
		
		
			org.activiti
			activiti-modeler
			${activiti.version}
		

2.7 启动排除的类

@SpringBootApplication(exclude = {
        org.activiti.spring.boot.SecurityAutoConfiguration.class,
        org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class,
})
public class SpringbootActivitiApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringbootActivitiApplication.class, args);
    }

}

 2.8 编写创建审批流接口提供

@RequestMapping("/create")
    public void create(HttpServletRequest request, HttpServletResponse response) {
        try {
            ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();

            RepositoryService repositoryService = processEngine.getRepositoryService();

            ObjectMapper objectMapper = new ObjectMapper();
            ObjectNode editorNode = objectMapper.createObjectNode();
            editorNode.put("id", "canvas");
            editorNode.put("resourceId", "canvas");
            ObjectNode stencilSetNode = objectMapper.createObjectNode();
            stencilSetNode.put("namespace", "http://b3mn.org/stencilset/bpmn2.0#");
            editorNode.put("stencilset", stencilSetNode);
            Model modelData = repositoryService.newModel();

            ObjectNode modelObjectNode = objectMapper.createObjectNode();
            modelObjectNode.put(ModelDataJsonConstants.MODEL_NAME, "testactivity1");
            modelObjectNode.put(ModelDataJsonConstants.MODEL_REVISION, 1);
            String description = "自定义审批流测试1";
            modelObjectNode.put(ModelDataJsonConstants.MODEL_DESCRIPTION, description);
            modelData.setMetaInfo(modelObjectNode.toString());
            modelData.setName("自定义审批流测试1");
            modelData.setKey("74185296339");

            //保存模型
            repositoryService.saveModel(modelData);
            repositoryService.addModelEditorSource(modelData.getId(), editorNode.toString().getBytes("utf-8"));
            response.sendRedirect(request.getContextPath() + "/modeler/modeler.html?modelId=" + modelData.getId());
        } catch (Exception e) {
            System.out.println("创建模型失败:");
        }
    }

 2.9 访问http://localhost:8010/activity/approval/create 后进入审批流程配置中

 汉化文件stencilset.json可以通过网络下载,放在/src/main/resources/stencilset.json 

SpringBoot整合Activiti Explorer 5.22.0_第7张图片

3.0 启动会自动生成表

SpringBoot整合Activiti Explorer 5.22.0_第8张图片

 

你可能感兴趣的:(审批流整合过程,spring,boot,后端,java)