工作以来一直接触EOS,没事的时候反编译器代码看看,对其结构有一定的了解,决定自己参照写一个类似的工作流。开始代码写没多长时间,大体结构写了差不多,能运行一个简单流程场景。(暂不公开代码,等感觉成熟了再发布)
流程实例图(借用EOS的。呵呵):
运行实例:
ProcessEngine processEngine = new Configuration().buildProcessEngine(); IProcessDefineService procDefService = processEngine.getProcessDefineService(); IProcessInstanceService procInstService = processEngine.getProcessInstanceService(); IWorkItemService workItemService = processEngine.getWorkItemService(); //部署流程 procDefService.deployProcessFile("Flow.xml"); //添加filter processEngine.addFilter(new LoggerProcessFilter()); //启动流程 ProcessInstance processInstance = procInstService.createProcess("TestFlow", "melin"); //创建流程 procInstService.startProcess(processInstance.getProcessInstId()); //List<WorkItem> workItems = workItemService.queryPersonWorkItems("melin"); //第一个参数为工作项ID,第二个参数为用户ID workItemService.finishWorkItem(1, "910150"); workItemService.finishWorkItem(2, "melin");
运行过程:
信息: 流程【TestFlow】创建成功, 流程实例ID = 1 2010-1-11 17:30:58 com.starit.wf.service.filter.LoggerProcessFilter processStart 信息: 流程【TestFlow】启动成功, 流程实例ID = 1 2010-1-11 17:30:58 com.starit.wf.service.filter.LoggerProcessFilter acitivityStart 信息: 环节【申请】创建成功, 环节实例ID = 2 2010-1-11 17:30:58 com.starit.wf.service.filter.LoggerProcessFilter acitivityComplete 信息: 环节【申请】执行完成, 环节实例ID = 2 2010-1-11 17:30:58 com.starit.wf.service.filter.LoggerProcessFilter acitivityStart 信息: 环节【审核】创建成功, 环节实例ID = 3 2010-1-11 17:30:58 com.starit.wf.service.filter.LoggerProcessFilter acitivityComplete 信息: 环节【审核】执行完成, 环节实例ID = 3 2010-1-11 17:30:58 com.starit.wf.service.filter.LoggerProcessFilter processComplete 信息: 流程【TestFlow】运行完成, 流程实例ID = 1
流程定义内容:
<?xml version="1.0" encoding="UTF-8"?> <ProcessDefine name="TestFlow" version="1.1.1" chname="测试流程"> <ProcessProperty> <limitTime>1440</limitTime> <description></description> </ProcessProperty> <Activitys> <Activity id="startAct" type="start" name="开始活动"> <splitMode>XOR</splitMode> <description></description> </Activity> <Activity id="A01" type="manual" name="申请"> <limitTime>60</limitTime> <splitMode>XOR</splitMode> <joinMode>XOR</joinMode> <wiMode>single</wiMode> <participantType>default</participantType> <ParticipantList> <participant id="910150" name="俞文琦" type="person"/> <participant id="910115" name="李强" type="person"/> </ParticipantList> <description></description> </Activity> <Activity id="A02" type="manual" name="审核"> <limitTime>60</limitTime> <splitMode>XOR</splitMode> <joinMode>XOR</joinMode> <wiMode>single</wiMode> <participantType>process-starter</participantType> <description></description> </Activity> <Activity id="endAct" type="end" name="结束活动"> <joinMode>XOR</joinMode> <description></description> </Activity> </Activitys> <Transitions> <Transition id="" from="startAct" to="A01" name=""> <isDefault>true</isDefault> </Transition> <Transition id="" from="A01" to="A02" name=""> <isDefault>true</isDefault> </Transition> <Transition id="" from="A02" to="endAct" name=""> <isDefault>false</isDefault> <Expression>optId==1</Expression> </Transition> </Transitions> </ProcessDefine>