解决 activiti部署流程时没有对ACT_RE_PROCDEF表进行插入操作

1.首先通过bpmnjs进行工作流绘制,目前bpmnjs支持camunda工作流绘制,但对activiti工作流绘制不支持,这没关系,修改一下生成的bpmn文件就好了,这不是重点,就不介绍了,工作流绘制如下图:


2.将生成的bpmn内容上传到后台进行发布,生成的内容如下。

<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="sample-diagram" targetNamespace="http://bpmn.io/schema/bpmn" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
  <bpmn2:process id="Process_1">
    <bpmn2:startEvent id="StartEvent_1" name="开始">
      <bpmn2:outgoing>SequenceFlow_1ti5duf</bpmn2:outgoing>
    </bpmn2:startEvent>
    <bpmn2:sequenceFlow id="SequenceFlow_1ti5duf" sourceRef="StartEvent_1" targetRef="Task_1lkbvmi" />
    <bpmn2:userTask id="Task_1lkbvmi" name="经理" camunda:candidateUsers="001">
      <bpmn2:incoming>SequenceFlow_1ti5duf</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_19vhqzf</bpmn2:outgoing>
    </bpmn2:userTask>
    <bpmn2:sequenceFlow id="SequenceFlow_19vhqzf" sourceRef="Task_1lkbvmi" targetRef="Task_1ovmlm4" />
    <bpmn2:userTask id="Task_1ovmlm4" name="老板" camunda:candidateUsers="002">
      <bpmn2:incoming>SequenceFlow_19vhqzf</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_1939xgb</bpmn2:outgoing>
    </bpmn2:userTask>
    <bpmn2:endEvent id="EndEvent_1qezs37" name="结束">
      <bpmn2:incoming>SequenceFlow_1939xgb</bpmn2:incoming>
    </bpmn2:endEvent>
    <bpmn2:sequenceFlow id="SequenceFlow_1939xgb" sourceRef="Task_1ovmlm4" targetRef="EndEvent_1qezs37" />
  </bpmn2:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
        <dc:Bounds x="304" y="226" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="311" y="262" width="22" height="13" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_1ti5duf_di" bpmnElement="SequenceFlow_1ti5duf">
        <di:waypoint x="340" y="244" />
        <di:waypoint x="390" y="244" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="365" y="222.5" width="0" height="13" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="UserTask_0yjpmnb_di" bpmnElement="Task_1lkbvmi">
        <dc:Bounds x="390" y="204" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_19vhqzf_di" bpmnElement="SequenceFlow_19vhqzf">
        <di:waypoint x="490" y="244" />
        <di:waypoint x="540" y="244" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="515" y="222.5" width="0" height="13" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="UserTask_16nqnrv_di" bpmnElement="Task_1ovmlm4">
        <dc:Bounds x="540" y="204" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="EndEvent_1qezs37_di" bpmnElement="EndEvent_1qezs37">
        <dc:Bounds x="690" y="226" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="697" y="265" width="22" height="13" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_1939xgb_di" bpmnElement="SequenceFlow_1939xgb">
        <di:waypoint x="640" y="244" />
        <di:waypoint x="690" y="244" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="665" y="222" width="0" height="13" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn2:definitions>

3.后台对数据进行修改保存。

import javax.annotation.Resource;

import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.repository.DeploymentBuilder;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.goldenbridge.recognizesystem.service.IActivitiService;

/**
*@author		create by pengweikang
*@date		2018年4月4日--下午7:19:09
*@problem
*@answer
*@action
*/

public class ActivitiService implements IActivitiService{

	
	@Resource private RepositoryService repositoryService;
	@Resource private RuntimeService runtimeService;
	@Resource private TaskService taskService;
	
	/* (non-Javadoc)
	 * @see com.goldenbridge.recognizesystem.service.IActivitiService#create()
	 */
	@Override
	@Transactional(propagation=Propagation.REQUIRED)
	public void create(String bpmn) {
		String sourceReplace = "xmlns:activiti=\"http://activiti.org/bpmn";
		String oldReplace = "xmlns:camunda=\"http://camunda.org/schema/1.0/bpmn";
		int index = bpmn.indexOf(oldReplace);
		String result = "";
		if(index > -1) {
			result = bpmn.replace(oldReplace, sourceReplace);
		}
		result = result.replaceAll("camunda", "activiti");
			String name = System.currentTimeMillis()+"";
			DeploymentBuilder builder =  repositoryService.createDeployment();
				builder.name(name);
				builder.addString(name, bpmn);
				builder.deploy();
	}
}

4.发现问题,打印日志如下图,只对部署单元(ACT_RE_DEPLOYMENT)和资源(ACT_GE_BYTEARRAY)进行插入,没有去部署流程(ACT_RE_PROCDEF)。


5.进行调试源码,发现源码会对resourceName进行校验,需要以bpmn或者bpmn20.xml结尾的资源内容才会去部署流程,如下图,而我的resourceName时通过当前时间获取的一串数字,因此才没有去部署流程。


6.解决问题。


7.运行结果。




                
  • 8
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 24
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 24
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值