最近开发项目管理系统,项目最近开发完毕,分享一些系统用到的东西,也算一个总结,系统用到了管理系统的常用的审批流程 并且在审批流程中自己控制流程走向。该项目管理系统基于Spring+spring mvc+mybatis .
spring-activiti.xml spring集成acitiviti
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <description>activiti工作流配置文件</description> <!-- 自动扫描且只扫描@Controller --> <context:component-scan base-package="org.activiti.rest.editor,org.activiti.rest.diagram"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" /> </context:component-scan> <!-- 自动扫描且只扫描@Controller--> <context:component-scan base-package="org.activiti.rest"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" /> </context:component-scan> <!-- 集成REST服务需要的bean --> <bean id="restResponseFactory" class="org.activiti.rest.service.api.RestResponseFactory" /> <bean id="contentTypeResolver" class="org.activiti.rest.common.application.DefaultContentTypeResolver" /> <!-- 单例json对象 --> <bean id="objectMapper" class="com.fasterxml.jackson.databind.ObjectMapper"/> <!-- 引擎内部提供的UUID生成器,依赖fastxml的java-uuid-generator模块 --> <bean id="uuidGenerator" class="org.activiti.engine.impl.persistence.StrongUuidGenerator" /> <!-- <context:property-placeholder location="classpath*:/config/config.properties" /> --> <!-- 创建一个流程引擎的配置对象 --> <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration"> <property name="dataSource" ref="dataSource" /> <property name="transactionManager" ref="transactionManager" /> <!-- 设置数据库schema的更新方式 --> <property name="databaseSchemaUpdate" value="true" /> <!-- <property name="databaseSchema" value="ACT"/> --> <!-- 是否启动jobExecutor --> <property name="jobExecutorActivate" value="false" /> <!-- 从5.12版本开始支持设置字体名称,把字改为本地的中文字体即可 --> <!-- 生成流程图的字体 --> <!-- <property name="activityFontName" value="${diagram.activityFontName}"/> <property name="labelFontName" value="${diagram.labelFontName}"/> --> <property name="activityFontName" value="宋体"/> <property name="labelFontName" value="宋体"/> <!-- 自动资源部署 --> <property name="deploymentResources" value="classpath*:/diagrams/my/leave.bpmn" /> <!-- 取消系统自带的用户系统 --> <property name="dbIdentityUsed" value="false"/> <!-- 开启全局事件日志功能 --> <!-- <property name="enableDatabaseEventLogging" value="true"/> --> </bean> <!-- 创建一个流程引擎bean --> <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean"> <property name="processEngineConfiguration" ref="processEngineConfiguration" /> </bean> <!-- 创建activiti提供的各种服务 --> <!-- 工作流仓储服务 --> <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="formService" factory-bean="processEngine" factory-method="getFormService" /> </beans>
项目审批流程图 流程图需要自己在编辑器中集成activiti插件
其中 会签环节中会有多人会签,多人同步会签,一人不通过退回至审批发起人相关配置
<?xml version="1.0" encoding="UTF-8"?> <definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test"> <process id="checkProjectProcess" name="My process" isExecutable="true"> <startEvent id="startevent1" name="Start"></startEvent> <userTask id="usertask1" name="提交申请"> <extensionElements> <activiti:taskListener event="create" delegateExpression="${managerTaskHandler}"></activiti:taskListener> </extensionElements> </userTask> <userTask id="usertask2" name="部门领导审批" activiti:assignee="${checkUser}"></userTask> <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow> <sequenceFlow id="flow2" sourceRef="usertask1" targetRef="usertask2"></sequenceFlow> <exclusiveGateway id="exclusivegateway1" name="Exclusive Gateway"></exclusiveGateway> <sequenceFlow id="flow3" sourceRef="usertask2" targetRef="exclusivegateway1"></sequenceFlow> <userTask id="usertask3" name="会签" activiti:assignee="${assignee}"> <multiInstanceLoopCharacteristics isSequential="false" activiti:collection="counterList" activiti:elementVariable="assignee"> <completionCondition>${signCompleteService.isComplete(execution)}</completionCondition> </multiInstanceLoopCharacteristics> </userTask> <userTask id="usertask4" name="行领导审批" activiti:assignee="${bankleader}"></userTask> <userTask id="usertask5" name="实施部门审批" activiti:assignee="${implementation}"></userTask> <exclusiveGateway id="exclusivegateway2" name="Exclusive Gateway"></exclusiveGateway> <sequenceFlow id="flow4" name="部门领导审批不通过" sourceRef="exclusivegateway1" targetRef="usertask1"> <conditionExpression xsi:type="tFormalExpression"><![CDATA[${pass==0}]]></conditionExpression> </sequenceFlow> <sequenceFlow id="flow5" name="部门领导审批通过并且需要会签" sourceRef="exclusivegateway1" targetRef="usertask3"> <conditionExpression xsi:type="tFormalExpression"><![CDATA[${(pass==1&&counterSign==1&&bankCheck==2)||(pass==1&&counterSign==1&&bankCheck==1)}]]></conditionExpression> </sequenceFlow> <sequenceFlow id="flow6" sourceRef="usertask3" targetRef="exclusivegateway2"></sequenceFlow> <sequenceFlow id="flow7" name="部门领导审批通过不需要会签需要行领导审批" sourceRef="exclusivegateway1" targetRef="usertask4"> <conditionExpression xsi:type="tFormalExpression"><![CDATA[${pass==1&&bankCheck==1&&counterSign==2}]]></conditionExpression> </sequenceFlow> <sequenceFlow id="flow8" name="会签审批通过并且需要行领导审批" sourceRef="exclusivegateway2" targetRef="usertask4"> <conditionExpression xsi:type="tFormalExpression"><![CDATA[${signPass==1&&bankCheck==1}]]></conditionExpression> </sequenceFlow> <exclusiveGateway id="exclusivegateway3" name="Exclusive Gateway"></exclusiveGateway> <sequenceFlow id="flow9" sourceRef="usertask4" targetRef="exclusivegateway3"></sequenceFlow> <sequenceFlow id="flow10" name="会签审批不通过" sourceRef="exclusivegateway2" targetRef="usertask1"> <conditionExpression xsi:type="tFormalExpression"><![CDATA[${signPass==0}]]></conditionExpression> </sequenceFlow> <sequenceFlow id="flow11" name="行领导审批不通过" sourceRef="exclusivegateway3" targetRef="usertask1"> <conditionExpression xsi:type="tFormalExpression"><![CDATA[${pass==0}]]></conditionExpression> </sequenceFlow> <sequenceFlow id="flow12" name="行领导审批通过" sourceRef="exclusivegateway3" targetRef="usertask5"> <conditionExpression xsi:type="tFormalExpression"><![CDATA[${pass==1}]]></conditionExpression> </sequenceFlow> <sequenceFlow id="flow13" name="会签审批通过并且不需要行领导审批" sourceRef="exclusivegateway2" targetRef="usertask5"> <conditionExpression xsi:type="tFormalExpression"><![CDATA[${signPass==1&&bankCheck==2}]]></conditionExpression> </sequenceFlow> <endEvent id="endevent1" name="End"></endEvent> <sequenceFlow id="flow15" name="部门领导审批通过不需要会签和行领导领导审批" sourceRef="exclusivegateway1" targetRef="usertask5"> <conditionExpression xsi:type="tFormalExpression"><![CDATA[${pass==1&&bankCheck==2&&counterSign==2}]]></conditionExpression> </sequenceFlow> <exclusiveGateway id="exclusivegateway4" name="Exclusive Gateway"></exclusiveGateway> <sequenceFlow id="flow16" sourceRef="usertask5" targetRef="exclusivegateway4"></sequenceFlow> <sequenceFlow id="flow17" name="实施部门审批不通过" sourceRef="exclusivegateway4" targetRef="usertask1"> <conditionExpression xsi:type="tFormalExpression"><![CDATA[${pass==0}]]></conditionExpression> </sequenceFlow> <sequenceFlow id="flow18" name="实施部门审批通过" sourceRef="exclusivegateway4" targetRef="endevent1"> <conditionExpression xsi:type="tFormalExpression"><![CDATA[${pass==1}]]></conditionExpression> </sequenceFlow> </process> <bpmndi:BPMNDiagram id="BPMNDiagram_checkProjectProcess"> <bpmndi:BPMNPlane bpmnElement="checkProjectProcess" id="BPMNPlane_checkProjectProcess"> <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1"> <omgdc:Bounds height="35.0" width="35.0" x="10.0" y="120.0"></omgdc:Bounds> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1"> <omgdc:Bounds height="55.0" width="105.0" x="120.0" y="110.0"></omgdc:Bounds> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="usertask2" id="BPMNShape_usertask2"> <omgdc:Bounds height="55.0" width="105.0" x="320.0" y="110.0"></omgdc:Bounds> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="exclusivegateway1" id="BPMNShape_exclusivegateway1"> <omgdc:Bounds height="40.0" width="40.0" x="520.0" y="117.0"></omgdc:Bounds> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="usertask3" id="BPMNShape_usertask3"> <omgdc:Bounds height="55.0" width="105.0" x="700.0" y="110.0"></omgdc:Bounds> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="usertask4" id="BPMNShape_usertask4"> <omgdc:Bounds height="55.0" width="105.0" x="487.0" y="240.0"></omgdc:Bounds> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="usertask5" id="BPMNShape_usertask5"> <omgdc:Bounds height="55.0" width="105.0" x="308.0" y="400.0"></omgdc:Bounds> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="exclusivegateway2" id="BPMNShape_exclusivegateway2"> <omgdc:Bounds height="40.0" width="40.0" x="940.0" y="117.0"></omgdc:Bounds> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="exclusivegateway3" id="BPMNShape_exclusivegateway3"> <omgdc:Bounds height="40.0" width="40.0" x="340.0" y="247.0"></omgdc:Bounds> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1"> <omgdc:Bounds height="35.0" width="35.0" x="10.0" y="410.0"></omgdc:Bounds> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="exclusivegateway4" id="BPMNShape_exclusivegateway4"> <omgdc:Bounds height="40.0" width="40.0" x="152.0" y="407.0"></omgdc:Bounds> </bpmndi:BPMNShape> <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1"> <omgdi:waypoint x="45.0" y="137.0"></omgdi:waypoint> <omgdi:waypoint x="120.0" y="137.0"></omgdi:waypoint> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2"> <omgdi:waypoint x="225.0" y="137.0"></omgdi:waypoint> <omgdi:waypoint x="320.0" y="137.0"></omgdi:waypoint> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3"> <omgdi:waypoint x="425.0" y="137.0"></omgdi:waypoint> <omgdi:waypoint x="520.0" y="137.0"></omgdi:waypoint> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4"> <omgdi:waypoint x="540.0" y="117.0"></omgdi:waypoint> <omgdi:waypoint x="539.0" y="85.0"></omgdi:waypoint> <omgdi:waypoint x="222.0" y="85.0"></omgdi:waypoint> <omgdi:waypoint x="173.0" y="85.0"></omgdi:waypoint> <omgdi:waypoint x="172.0" y="110.0"></omgdi:waypoint> <bpmndi:BPMNLabel> <omgdc:Bounds height="42.0" width="100.0" x="351.0" y="61.0"></omgdc:Bounds> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5"> <omgdi:waypoint x="560.0" y="137.0"></omgdi:waypoint> <omgdi:waypoint x="700.0" y="137.0"></omgdi:waypoint> <bpmndi:BPMNLabel> <omgdc:Bounds height="42.0" width="100.0" x="579.0" y="138.0"></omgdc:Bounds> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6"> <omgdi:waypoint x="805.0" y="137.0"></omgdi:waypoint> <omgdi:waypoint x="940.0" y="137.0"></omgdi:waypoint> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7"> <omgdi:waypoint x="540.0" y="157.0"></omgdi:waypoint> <omgdi:waypoint x="539.0" y="240.0"></omgdi:waypoint> <bpmndi:BPMNLabel> <omgdc:Bounds height="56.0" width="100.0" x="541.0" y="184.0"></omgdc:Bounds> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="flow8" id="BPMNEdge_flow8"> <omgdi:waypoint x="960.0" y="157.0"></omgdi:waypoint> <omgdi:waypoint x="959.0" y="267.0"></omgdi:waypoint> <omgdi:waypoint x="592.0" y="267.0"></omgdi:waypoint> <bpmndi:BPMNLabel> <omgdc:Bounds height="42.0" width="100.0" x="801.0" y="239.0"></omgdc:Bounds> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="flow9" id="BPMNEdge_flow9"> <omgdi:waypoint x="487.0" y="267.0"></omgdi:waypoint> <omgdi:waypoint x="380.0" y="267.0"></omgdi:waypoint> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="flow10" id="BPMNEdge_flow10"> <omgdi:waypoint x="960.0" y="117.0"></omgdi:waypoint> <omgdi:waypoint x="959.0" y="34.0"></omgdi:waypoint> <omgdi:waypoint x="579.0" y="34.0"></omgdi:waypoint> <omgdi:waypoint x="172.0" y="34.0"></omgdi:waypoint> <omgdi:waypoint x="172.0" y="110.0"></omgdi:waypoint> <bpmndi:BPMNLabel> <omgdc:Bounds height="14.0" width="84.0" x="602.0" y="21.0"></omgdc:Bounds> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="flow11" id="BPMNEdge_flow11"> <omgdi:waypoint x="340.0" y="267.0"></omgdi:waypoint> <omgdi:waypoint x="172.0" y="266.0"></omgdi:waypoint> <omgdi:waypoint x="172.0" y="165.0"></omgdi:waypoint> <bpmndi:BPMNLabel> <omgdc:Bounds height="14.0" width="96.0" x="208.0" y="248.0"></omgdc:Bounds> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="flow12" id="BPMNEdge_flow12"> <omgdi:waypoint x="360.0" y="287.0"></omgdi:waypoint> <omgdi:waypoint x="360.0" y="400.0"></omgdi:waypoint> <bpmndi:BPMNLabel> <omgdc:Bounds height="14.0" width="84.0" x="258.0" y="329.0"></omgdc:Bounds> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="flow13" id="BPMNEdge_flow13"> <omgdi:waypoint x="980.0" y="137.0"></omgdi:waypoint> <omgdi:waypoint x="1016.0" y="137.0"></omgdi:waypoint> <omgdi:waypoint x="1016.0" y="427.0"></omgdi:waypoint> <omgdi:waypoint x="413.0" y="427.0"></omgdi:waypoint> <bpmndi:BPMNLabel> <omgdc:Bounds height="42.0" width="100.0" x="669.0" y="400.0"></omgdc:Bounds> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="flow15" id="BPMNEdge_flow15"> <omgdi:waypoint x="540.0" y="157.0"></omgdi:waypoint> <omgdi:waypoint x="520.0" y="187.0"></omgdi:waypoint> <omgdi:waypoint x="520.0" y="187.0"></omgdi:waypoint> <omgdi:waypoint x="422.0" y="187.0"></omgdi:waypoint> <omgdi:waypoint x="360.0" y="400.0"></omgdi:waypoint> <bpmndi:BPMNLabel> <omgdc:Bounds height="56.0" width="100.0" x="432.0" y="192.0"></omgdc:Bounds> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="flow16" id="BPMNEdge_flow16"> <omgdi:waypoint x="308.0" y="427.0"></omgdi:waypoint> <omgdi:waypoint x="192.0" y="427.0"></omgdi:waypoint> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="flow17" id="BPMNEdge_flow17"> <omgdi:waypoint x="172.0" y="407.0"></omgdi:waypoint> <omgdi:waypoint x="172.0" y="165.0"></omgdi:waypoint> <bpmndi:BPMNLabel> <omgdc:Bounds height="42.0" width="100.0" x="70.0" y="282.0"></omgdc:Bounds> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="flow18" id="BPMNEdge_flow18"> <omgdi:waypoint x="152.0" y="427.0"></omgdi:waypoint> <omgdi:waypoint x="45.0" y="427.0"></omgdi:waypoint> <bpmndi:BPMNLabel> <omgdc:Bounds height="14.0" width="96.0" x="47.0" y="430.0"></omgdc:Bounds> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </definitions>
其中isSequential=false 代表会签同步操作 counterList 为流程变量传入的会签人员列表
大概配置项如此 其他诸如activiti 相关流程实例的查询可百度