package org.springblade.modules.flowable.tasks;

import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.ExecutionListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springblade.flow.engine.service.impl.ApplicationDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component("myListener")
public class MyListener implements ExecutionListener {

    private static Logger logger = LoggerFactory.getLogger(MyListener.class);


    @Autowired
    private ApplicationDetailService detailService;


    @Override
    public void notify(DelegateExecution execution) {
        logger.info("notify exec of task start");
       String processInstanceId=execution.getProcessInstanceId();
       logger.info(" >>>>>> 审批完成的流程Id processInstanceId : {}"+processInstanceId);
        execution.setVariable("execVar", "hello");
        logger.info(" >>>>>>>> execution: {}: " +execution.getVariable("applicationId"));
        //审批完成后 申请的修改
        detailService.endProcess(processInstanceId);
    }
}
