package com.srs.flowable.listener;

import com.srs.common.doman.vo.TeacherVo;
import com.srs.common.utils.spring.SpringUtils;
import com.srs.flowable.mapper.LeaveMapper;
import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.ExecutionListener;
import org.flowable.engine.delegate.TaskListener;
import org.flowable.task.service.delegate.DelegateTask;
import org.springframework.stereotype.Component;

/**
 * 获取该生所在二级学院领导信息
 */
@Component
@Slf4j
public class SecondaryLeaderListener implements ExecutionListener {

    @Override
    public void notify(DelegateExecution delegateExecution) {
        LeaveMapper leaveMapper = (LeaveMapper) SpringUtils.getBean("leaveMapper");

        String deptId = delegateExecution.getVariable("deptId").toString();

        // 获取高辅导员
        TeacherVo secondaryLeaderInfo = leaveMapper.getSecondaryLeaderInfo(deptId);
        delegateExecution.setVariable("approval", secondaryLeaderInfo.getUserId());
        // todo 企业微信推送消息
        log.info("查询二级学院书记信息：{}", secondaryLeaderInfo);
    }
}
