package com.base.pf.m150workflow.f070task.controller;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.ExecutionListener;
import org.activiti.engine.impl.el.FixedValue;
import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;
import com.base.pf.m150workflow.f070task.service.TasksService;
import com.base.pf.m150workflow.f070task.service.VariableService;
/**
* 排他网管:执行监听<br/>
* 该类是为了根据业务ID,表名,字段,查询该业务值,来判断流程走向
*
* @author ZHEN.L
*
*/
public class GateWayTaskListiner implements ExecutionListener {
private static final long serialVersionUID = 102702298968012874L;
private VariableService variableService;
private TasksService tasksService;
private FixedValue tableName; // 同流程图中名称
private FixedValue tableField; // 同流程图中字段名称
public void notify(DelegateExecution task) throws Exception {
String table = String.valueOf(tableName.getValue(task));
String field = String.valueOf(tableField.getValue(task));
WebApplicationContext context = ContextLoader
.getCurrentWebApplicationContext();
tasksService = (TasksService) context.getBean("tasksService");
variableService = (VariableService) context.getBean("variableService");
String bussinessId = tasksService
.findBussinessIdByProcessInstanceId(task.getProcessInstanceId());
Object value = variableService.findVariable(table, field, bussinessId);
task.setVariable(field, value);
}
public FixedValue getTableName() {
return tableName;
}
public void setTableName(FixedValue tableName) {
this.tableName = tableName;
}
public FixedValue getTableField() {
return tableField;
}
public void setTableField(FixedValue tableField) {
this.tableField = tableField;
}
}