package jnpf.model.personnels.vo.task;

import cn.hutool.core.util.ObjectUtil;
import jnpf.model.enums.FtbPersonnelsAuditTaskEnum;

import javax.validation.constraints.NotNull;

/**
 * @Title:FtbPersonnelsResult
 * @Author:peng.hao
 * @create: 2024/2/714:37
 */
public class FtbPersonnelsResult {
    //申请来源 0,员工申请,1,审批办理,2直接办理,3确认到岗
    public final Integer source;
    public final Integer state;

    public FtbPersonnelsResult(Integer source, Integer state) {
        this.source = source;
        this.state = state;
    }

    @NotNull
    public static FtbPersonnelsResult getResult(Integer createDtoSource,String createDtoFlag) {
        Integer source = null;
        Integer state = null;
        // 1员工个人申请 默认走审批
        if (ObjectUtil.isNotEmpty(createDtoSource)) {
            if (createDtoSource.equals(0)) {
                source = 0;
                state = FtbPersonnelsAuditTaskEnum.UNDER_REVIEW.getCode();
            }
        }
        //1,手动转正 2,审批, 3确认到岗
        if (createDtoFlag.equals("1")) {
            // 设置手动转正
            source = 2;
            state = FtbPersonnelsAuditTaskEnum.MANUAL_CONTROL.getCode();
        }else if ("3".equals(createDtoFlag)){
            source = 3;
            state = FtbPersonnelsAuditTaskEnum.NOT_PROCESSED.getCode();
        }else {
            if ((ObjectUtil.isEmpty(createDtoSource) && createDtoFlag.equals("2") ) ||
                    (1 == createDtoSource && createDtoFlag.equals("2") )) {
                source = 1;
                state = FtbPersonnelsAuditTaskEnum.UNDER_REVIEW.getCode();
            }
        }
        return new FtbPersonnelsResult(source, state);
    }
}
