package com.ruoyi.flowable.oa;

import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.system.mapper.SysUserPostMapper;
import org.flowable.common.engine.impl.identity.Authentication;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.ExecutionListener;
import org.springframework.stereotype.Component;

@Component("CallSafeActivityExecutionListener")
public class CallSafeActivityExecutionListener implements ExecutionListener {
    @Override
    public void notify(DelegateExecution delegateExecution) {
        SysUserPostMapper userPostMapper = SpringUtils.getBean(SysUserPostMapper.class);
        Long userId = userPostMapper.selectUserListByPostName("专职安全员").get(0).getUserId();
        Authentication.setAuthenticatedUserId(userId.toString());
        delegateExecution.setVariableLocal("approval", userId);
    }
}
