activiti workflow learning (c)

Exclusive gateway

Flowcharting

Here Insert Picture Description
Exclusive process for each branch lines plus the condition gateway conditions
Here Insert Picture Description
flowcharting complete, save the resulting png file

Deployment of design resources

/**
	 * 部署设计资源 即之前创建的流程设计图
	 */
	@Test
	public void deploy() {
		pe.getRepositoryService().createDeployment().addClasspathResource("MyProcess.png")
				.addClasspathResource("MyProcess.bpmn").name("学生请假-排他网关").deploy();
	}

act_re_deployment table generation deployment process information

Start the test

/**
	 * 启动流程实例
	 */
	@Test
	public void start() {
		// 通过id启动 启动时赋予流程执行人即 刚才${}中的值
		//此时act_ru_execution act_ru_task 两张表中有数据
		Map<String, Object> map = new HashMap<>();
		map.put("student", "冯宝宝");
		map.put("time", "请假2天");
		ProcessInstance pi = pe.getRuntimeService().startProcessInstanceByKey("myProcess", map);
	}
  • act_ru_variable table generating the map information is of variable

Fung completed application

/**
	 * 完成任务
	 * 此时act_ru_execution act_ru_task 两张表中没有数据
	 * 相对应的 在历史表中有数据
	 */
	@Test
	public void completeTask() {
		Map<String, Object> map = new HashMap<>();
		map.put("day", "2");//流程图 流程连线的判断依据,sta
		pe.getTaskService().complete("32507",map);//通过任务id来完成任务 此处将判断依据传入 
													//这里的id在实际应用中建议和实体类绑定
	}

The next step, according to the leave time determination, where approval to the relevant person.

/**
	 * 启动流程实例
	 */
	@Test
	public void start() {
		// 通过id启动 启动时赋予流程执行人即 刚才${}中的值
		//此时act_ru_execution act_ru_task 两张表中有数据
		Map<String, Object> map = new HashMap<>();
		map.put("student", "冯宝宝");
		map.put("time", "请假2天");
		ProcessInstance pi = pe.getRuntimeService().startProcessInstanceByKey("myProcess", map);
	}

Complete the relevant approval

/**
	 * 完成任务
	 * 此时act_ru_execution act_ru_task 两张表中没有数据
	 * 相对应的 在历史表中有数据
	 */
	@Test
	public void completeTask() {
		Map<String, Object> map = new HashMap<>();
		map.put("day", "2");//流程图 流程连线的判断依据,sta
		pe.getTaskService().complete("35007",map);//通过任务id来完成任务 此处将判断依据传入
	}
历史任务id35007
历史任务名称学生请假
历史任务创建时间Wed Jan 22 14:35:08 CST 2020
历史任务结束时间Wed Jan 22 14:36:05 CST 2020
历史任务执行人冯宝宝
历史任务id37504
历史任务名称班长审批
历史任务创建时间Wed Jan 22 14:36:05 CST 2020
历史任务结束时间null
历史任务执行人班长

Executed again
query history

/**
	 * 查看历史任务数据
	 */
	@Test
	public void findHistoryTask() {
		List<HistoricTaskInstance> htis = pe.getHistoryService()
										.createHistoricTaskInstanceQuery()
										.taskId("37504").list();
		htis.forEach(hti->{
			System.out.println("历史任务id"+hti.getId());
			System.out.println("历史任务名称"+hti.getName());
			System.out.println("历史任务创建时间"+hti.getCreateTime());
			System.out.println("历史任务结束时间"+hti.getEndTime());
			System.out.println("历史任务执行人"+hti.getAssignee());
		});
	}
历史任务id37504
历史任务名称班长审批
历史任务创建时间Wed Jan 22 14:36:05 CST 2020
历史任务结束时间Wed Jan 22 14:39:07 CST 2020
历史任务执行人班长

The process ends

Explanation

The above-mentioned process:

  1. Students start to leave, leave to complete the task, where the task is completed, fill taskId students leave the task id,
  2. Upon completion, students leave the task of running the table disappear into history data.
  3. Run the task appears, the task of approving the squad leader,
  4. Monitor the implementation of the approval, the completion of approval, when the task is completed here, days taskid is the id of the task team leader for approval
Published 19 original articles · won praise 4 · Views 545

Guess you like

Origin blog.csdn.net/qq_44382452/article/details/104069679