package com.activiti6.config.event.listener.task;


import com.activiti6.domain.ProcessInstanceEvEntFrom;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.ExecutionListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class EndListener implements ExecutionListener {
    protected final Logger logger = LoggerFactory.getLogger(EndListener.class);

    @Override
    public void notify(DelegateExecution delegateExecution) {
        Map<String, Object> variables =  delegateExecution.getVariables();
        Long formId =Long.parseLong(delegateExecution.getVariable("formId").toString());
        String formKey =delegateExecution.getVariable("formKey").toString();
        ProcessInstanceEvEntFrom processInstanceEvEntFrom=new ProcessInstanceEvEntFrom();
        processInstanceEvEntFrom.setFormId(formId);
        processInstanceEvEntFrom.setFormKey(formKey);
//        RemoteActivitiOperationService remoteActivitiOperationService = SpringUtils.getBean(RemoteActivitiOperationService.class);
//        R end = remoteActivitiOperationService.end(processInstanceEvEntFrom);
//        int code = end.getCode();
//        if(200!=code){
//            throw new RuntimeException("远程更新数据失败!");
//        }
        logger.info("执行了结束监听");
    }



}
