jeecg + activiti 流程设计器

jeecg 3.4.3 + activiti 5.18.0


activiti 流程设计器 示例 源码

https://download.csdn.net/download/anysun7/10354206


项目pom文件添加activiti依赖:

            org.activiti

            activiti-engine

            ${activiti.version}

        

 

        

            org.activiti

            activiti-spring

            ${activiti.version}

            

                

                    commons-dbcp

                    commons-dbcp

                

            

        

 

        

            commons-dbcp

            commons-dbcp

            1.4

        

 

        

            org.mybatis

            mybatis

            3.2.5

        

 

        

 

        

            org.activiti

            activiti-bpmn-model

            ${activiti.version}

        

        

           org.activiti

           activiti-bpmn-converter

           ${activiti.version}

       

 

        

            org.activiti

            activiti-bpmn-layout

            ${activiti.version}

        

 

        

            org.activiti

            activiti-common-rest

            ${activiti.version}

        

 

        

            org.activiti

            activiti-crystalball

            ${activiti.version}

        

 

        

            org.activiti

            activiti-diagram-rest

            ${activiti.version}

        

 

        

            org.activiti

            activiti-explorer

            ${activiti.version}

        

 

        

            org.activiti

            activiti-image-generator

            ${activiti.version}

        

 

        

            org.activiti

            activiti-json-converter

            ${activiti.version}

        

 

        

            org.activiti

            activiti-modeler

            ${activiti.version}

        

 

        

            org.activiti

            activiti-simple-workflow

            ${activiti.version}

        

 

        

            org.vaadin.addons

            dcharts-widget

            0.10.0

        

 

        

            org.activiti

            activiti-process-validation

            ${activiti.version}

        

 

        

            org.apache.xmlgraphics

            xmlgraphics-commons

            1.2

        

 

        

            com.vaadin

            vaadin

            6.8.8

        

 

        

            org.imgscalr

            imgscalr-lib

            4.2

        

 

        

            org.apache.geronimo.specs

            geronimo-servlet_3.0_spec

            1.0

            provided

        

 

        

 

        

            joda-time

            joda-time

            2.1

        

 

        

        

            org.apache.xmlgraphics

            batik-transcoder

            1.7

        

 

        

            org.apache.xmlgraphics

            batik-dom

            1.7

        

 

        

            org.apache.xmlgraphics

            batik-bridge

            1.7

        

 

        

            org.apache.xmlgraphics

            batik-css

            1.7

        

 

        

            org.apache.xmlgraphics

            batik-anim

            1.7

        

 

        

            org.apache.xmlgraphics

            batik-codec

            1.7

        

 

        

            org.apache.xmlgraphics

            batik-ext

            1.7

        

 

        

            org.apache.xmlgraphics

            batik-gvt

            1.7

        

 

        

            org.apache.xmlgraphics

            batik-script

            1.7

        

 

        

            org.apache.xmlgraphics

            batik-js

            1.7

        

 

        

            org.apache.xmlgraphics

            batik-parser

            1.7

        

 

        

            org.apache.xmlgraphics

            batik-svg-dom

            1.7

        

 

        

            org.apache.xmlgraphics

            batik-svggen

            1.7

        

 

        

            org.apache.xmlgraphics

            batik-util

            1.7

        

 

        

            org.apache.xmlgraphics

            batik-xml

            1.7

        

 

        

            org.apache.xmlgraphics

            batik-js

            1.7

        

 

        

            xml-apis

            xml-apis-ext

            1.3.04

        

 

        

            xml-apis

            xml-apis

            1.3.04

        

 

        

            org.apache.xmlgraphics

            xmlgraphics-commons

            1.2

        

 

        

            org.apache.xmlgraphics

            batik-awt-util

            1.7

        

 

配置spring-activiti.xml文件

src/main/resources目录下新建spring-activiti.xml文件,向其中加入以下内容

xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"

       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

       xsi:schemaLocation="http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">

        <property name="dataSource" ref="dataSource" />

        <property name="transactionManager" ref="transactionManager" />

        <property name="databaseSchemaUpdate" value="true" />

        <property name="jobExecutorActivate" value="false" />

    bean>

    <bean id="objectMapper" class="com.fasterxml.jackson.databind.ObjectMapper"/>

    <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">

        <property name="processEngineConfiguration" ref="processEngineConfiguration" />

    bean>

    <bean id="repositoryService" factory-bean="processEngine"

          factory-method="getRepositoryService" />

    <bean id="runtimeService" factory-bean="processEngine"

          factory-method="getRuntimeService" />

    <bean id="taskService" factory-bean="processEngine"

          factory-method="getTaskService" />

    <bean id="historyService" factory-bean="processEngine"

          factory-method="getHistoryService" />

    <bean id="managementService" factory-bean="processEngine"

          factory-method="getManagementService" />

    <bean id="identityService" factory-bean="processEngine"

          factory-method="getIdentityService" />

    <bean id="transactionManager"

          class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

        <property name="dataSource" ref="dataSource" />

    bean>

beans>

 

web.xml文件,修改context-param添加了classpath:spring-activiti.xml

 

复制设计器文件

下载activiti-webapp-explorer2的源代码,

1. activiti-explorer工程中的diagram-viewereditor-appmodeler.html复制到工程的src/main/webapp目录下

 jeecg + activiti 流程设计器_第1张图片

2. activiti-explorer工程中WEB-INF/classes文件下的stencilset.jsonui.propertiesui.properties.alfresco复制到工程的src/main/resources目录下

 jeecg + activiti 流程设计器_第2张图片

3.modules/目录中找到org\activiti\rest\diagramorg\activiti\rest\editor这两个包,将他们整个复制到工程的src/main/java目录下

 jeecg + activiti 流程设计器_第3张图片

4.修改spring-mvc.xml文件,在其中加入以下内容,使spring在扫描controller类的时候,也扫描这些包里面的类

 

5.向工程的web.xml文件中添加以下内容,让spring也管理起来带/service/的链接

    <servlet-mapping>

        <servlet-name>springMvcservlet-name>

        <url-pattern>/service/*url-pattern>

    servlet-mapping>

 

6.打开editor-app/app-cfg.js, 将其中的activiti-explorer”修改为“jeecg”。当然,具体项目中这里可能会经常变化,我们可以写一个js函数来自动获取工程的名字,这样以后将设计器集成到其他工程的时候,就不需要修改这里的内容了

 

7.工程的src\main\java\org\activiti\rest\editor目录下新建一个java文件,命名为ModuleController

package org.activiti.rest.editor;

 

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

 

import org.activiti.editor.constants.ModelDataJsonConstants;

import org.activiti.engine.RepositoryService;

import org.activiti.engine.repository.Model;

import org.apache.commons.lang3.StringUtils;

import org.jeecgframework.core.common.controller.BaseController;

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;

 

import com.fasterxml.jackson.databind.ObjectMapper;

import com.fasterxml.jackson.databind.node.ObjectNode;

 

@Controller

@RequestMapping("/model")

public class ModuleController extends BaseController{

private Logger logger = LoggerFactory.getLogger(ModuleController.class);

@Autowired

private RepositoryService repositoryService;

@RequestMapping(params = "create")

  public void create(HttpServletRequest request, HttpServletResponse response) {

    try {

          String name = "test";

          String key = "test";

          String description = "testModel";

 

          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, name);

      modelObjectNode.put(ModelDataJsonConstants.MODEL_REVISION, 1);

      description = StringUtils.defaultString(description);

      modelObjectNode.put(ModelDataJsonConstants.MODEL_DESCRIPTION, description);

      modelData.setMetaInfo(modelObjectNode.toString());

      modelData.setName(name);

      modelData.setKey(StringUtils.defaultString(key));

 

      repositoryService.saveModel(modelData);

      repositoryService.addModelEditorSource(modelData.getId(), editorNode.toString().getBytes("utf-8"));

 

      response.sendRedirect(request.getContextPath() + "/modeler.html?modelId=" + modelData.getId());

    } catch (Exception e) {

      logger.error("创建模型失败:", e);

    }

  }

}

 

8. 访问:http://localhost:8080/jeecg/model.do?create

 jeecg + activiti 流程设计器_第4张图片

 

注:

新版(3.7.2jeecgresponse的处理,添加了org.jeecgframework.core.aop.Wrapper,导致json数据返回解析出错。整合时,需处理。

Jeecg修改pom内容

Maven版本改为 5.18.0

添加:

<dependency> 

<groupId>com.fasterxml.jackson.coregroupId> 

<artifactId>jackson-databindartifactId> 

<version>2.2.3version> 

dependency>

Springmvc添加 (rest请求数据 /jeecg/service/model/5001/json


中途bug:

jeecg + activiti 流程设计器_第5张图片

TypeError: Cannot read property 'split' of undefined

    at Object.ORYX.Core.StencilSet.stencilSet (oryx.debug.js:8647)
    at oryx.debug.js:8625
    at prototype-1.5.1.js:446
    at Array._each (prototype-1.5.1.js:672)
    at Array.each (prototype-1.5.1.js:445)
    at Object.ORYX.Core.StencilSet.stencilSets (oryx.debug.js:8624)
    at classDef.getStencilSets (oryx.debug.js:11715)
    at classDef._createCanvas (oryx.debug.js:11201)
    at classDef.construct (oryx.debug.js:10930)
    at new classDef (oryx.debug.js:1747)

解决思路:遇到该错误,主要原因是后台返回json数据时,格式存在问题,请查看response中最终返回到页面之前的数据。查看是否是框架对数据做了处理,寻找相应解决方法。






另转:

activiti-modeler 工作流设计器代码分析

https://blog.csdn.net/fgstudent/article/details/50668086

你可能感兴趣的:(jeecg,activiti,流程设计器,工作流,可视化,activiti)