package com.bbd.bpm.listener;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.TaskService;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;
import org.activiti.engine.impl.el.FixedValue;

import java.io.Serializable;

/**
 * Created by houkang on 2019/1/28.
 */
public class PutAssigneeListener   implements Serializable, TaskListener {
    private FixedValue job;

    @Override
    public void notify(DelegateTask delegateTask) {

        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        TaskService taskService = processEngine.getTaskService();
        if(job!=null){
            if("jingli".equals(job.getExpressionText())){
                delegateTask.setAssignee("wang");
            }else if("emp".equals(job.getExpressionText())){
                delegateTask.setAssignee("houkang");
            }
        }else{
        taskService.setAssignee(delegateTask.getId(),"hr");
        }
    }
}
