package com.leanwo.activiti.delegate.base;

import java.util.ArrayList;
import java.util.List;

import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 设置审批用户的Id进流程变量
 * @author GuoZhiBo 20180918
 *
 */
public class UserTaskListener3 implements TaskListener {
	private static Logger logger = LoggerFactory.getLogger(UserTaskListener3.class);
	
	@Override
	public void notify(DelegateTask delegateTask) {
		DelegateExecution execution = delegateTask.getExecution();
		String userId = delegateTask.getAssignee();
		List<String> listStr =  (List<String>)execution.getVariable("approvedUserList");
		if(listStr != null && listStr.size() > 0) {
			listStr.add(userId);
		}else {
			listStr = new ArrayList<>();
			listStr.add(userId);
		}
		execution.setVariable("approvedUserList",listStr);
	}
}
