package com.tourism.common.flow.listener;

import cn.hutool.core.util.ObjectUtil;
import com.tourism.common.flow.constant.FlowConstant;
import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.delegate.TaskListener;
import org.flowable.task.service.delegate.DelegateTask;

import java.util.Map;

/**
 * 任务驳回后重新提交到该任务的通知监听器。
 *
 * @author 吃饭睡觉
 * @date 2024-09-06
 */
@Slf4j
public class FlowTaskRejectBackListener implements TaskListener {

    @Override
    public void notify(DelegateTask delegateTask) {
        Map<String, Object> variables = delegateTask.getVariables();
        Object v = variables.get(FlowConstant.REJECT_BACK_TO_SOURCE_DATA_VAR);
        if (ObjectUtil.isNotEmpty(v)) {
            delegateTask.setAssignee(v.toString());
        }
    }
}
