第一组启动:
task任务的XML
<task name="申请" g="71,45,64,52" assignee="#{archRead.applyOperatePersonNo}">
<transition name="申请" g="-14,-20" to="支行(部门)初审"/>
</task>
代码:
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("archRead", entity);//流程图中有${archRead.applyOperatePersonNo},所以需要把实体对象放进来
ExecutionService executionService = processEngine.getExecutionService();
//开始一个流程,流程的KEY为archRead
ProcessInstance processInstance = executionService.startProcessInstanceByKey("archRead", variables, entity.getId());
说明:
//设置jbpm_task表的name为xml的task标签的name属性,assigness为assigne标签的属性.www.twitterchina.net
//(executeion_id_:archRead.2c924a805a8e3ff0015a8e536c6e0006,是key和entity.getId()的组合值。activity_name_:申请,execution_:40008,taskdefname_:申请)
JBPM4_EXECUTION表的变化:activityName_:申请,key:2c924a805a8e3ff0015a8e536c6e0006为entity.getId()的值。id_:archRead.2c924a805a8e3ff0015a8e536c6e0006,是key和entity.getId()的组合值。
//删掉任务:
--delete from dbo.JBPM4_TASK
--delete from dbo.JBPM4_EXECUTION
--delete from dbo.JBPM4_VARIABLE
第二组完成任务:
Task任务xml:
<task name="支行(部门)初审" g="169,43,119,52" form="/archRead!toDeptAudit.action" candidate-groups="deptAudit-#{archRead.applyDeptCasCode}">
<description>机构审核</description>
<transition name="退回修改" g="307,34:-23,-12" to="修改"/>
<transition name="同意" g="3,-11" to="档案部门复审"/>
<transition name="否决" g="-30,-3" to="cancel1"/>
</task>
代码:
查询指定人的指定流程为空archRead开始的任务
String hql = "from org.jbpm.pvm.internal.task.TaskImpl where assignee='" + entity.getApplyOperatePersonNo() 。
+ "' AND executionId='archRead." + entity.getId() + "'";
TaskImpl task = (TaskImpl)this.baseDao.findSingle(hql);
TaskService taskService = processEngine.getTaskService();taskService.completeTask(task.getId(),entity.getFlowDir());//完成任务
entity.setFlowId(processInstance.getId());
entity.setFlowState("1");
this.baseDao.update(entity);
说明:
Task标签的form设置在task表的form_字段中
task标签的candidate-groups属性,设置在candidate-groups表中,这是分组任务的表。
要获取分组任务在这个表中查询,哪些用户能查询这个分组任务的信息,就看用户是否有deptAudit的角色,并且用户管理的机构号在#{archRead.applyDeptCasCode}设置的机构内。
//配置的candidate-groups,会设置在JBPM4_PARTICIPATION表中
select * from dbo.JBPM4_PARTICIPATION
(来源:www.javait.org)