package jnpf.model.personnels.vo.apply;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import jnpf.model.cultivate.po.apply.FtbCultivatePromotionPostApply;
import jnpf.model.cultivate.vo.apply.FtbCultivatePromotionPostApplyVO;
import jnpf.model.cultivate.vo.offline.FtbCultivateOfflineFileVO;
import jnpf.model.cultivate.vo.promotion.FtbCultivatePromotionVO;
import jnpf.model.cultivate.vo.promotion.FtbCultivatePromotionWithPersonelVO;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @Title: FtbPersonnelsApplyVO
 * @Author:peng.hao
 * @create: 2023/12/2515:54
 */
@Data
public class FtbPersonnelsApplyVO {
    /**
     * 主键id
     */
    @Schema(title = "主键id")
    @ExcelIgnore
    private String id;
    /**
     * 用户id
     */
    @Schema(title = "用户id")
    @ExcelIgnore
    private String userId;
    /**
     * 系统用户展示id
     */
    @ExcelProperty(index = 1, value = "员工ID")
    private String systemWokerId;
    /**
     * 用户名称
     */
    @Schema(title = "用户名称")
    @ExcelProperty(index = 0, value = "晋升人")
    private String userName;


    /**
     * 当前岗位id
     */
    @ExcelIgnore
    private String postId;

    /**
     * 当前岗位名称
     */
    @ExcelIgnore
    private String postName;


    /**
     * 当前岗位职等id
     */
    @Schema(title = "当前岗位职等id")
    @ExcelIgnore
    private String postRankId;

    /**
     * 当前岗位职等名称
     */
    @ExcelIgnore
    private String postRankName;

    @ExcelProperty(index = 3, value = "晋升前岗位(职等)")
    @JsonIgnore
    private String positionBeforePromotion;

    /**
     * 晋升岗位id
     */
    @Schema(title = "晋升岗位id")
    @ExcelIgnore
    private String postPromotionId;
    /**
     * 晋升岗位名称
     */
    @ExcelIgnore
    private String postPromotionName;
    /**
     * 晋升岗位职等id
     */
    @ExcelIgnore
    private String postRankPromotionId;

    /**
     * 晋升岗位职等名称
     */
    @ExcelIgnore
    private String postRankPromotionName;

    @JsonIgnore
    @ExcelProperty(index = 5, value = "晋升岗位(职等)")
    private String positionAfterPromotion;

    /**
     * 晋升组织主键id
     */
    @ExcelIgnore
    private String orgId;
    /**
     * 晋升组织名称
     */
    @ExcelProperty(index = 2, value = "晋升前组织")
    private String orgName;

    /**
     * 当前晋升组织主键id
     */
    @ExcelIgnore
    private String orgCurrentId;
    /**
     * 晋升组织名称
     */
    @ExcelProperty(index = 4, value = "晋升组织")
    private String orgCurrentName;

    /**
     * 晋升原因
     */
    @Schema(title = "晋升原因")
    @ExcelProperty(index = 7, value = "晋升原因")
    private String promotionReason;


    /**
     * 申请来源 0,员工申请,1,审批办理,2直接办理
     */
    @ExcelIgnore
    private Integer source;

    /**
     * 申请来源 0,员工申请,1,审批办理,2直接办理
     */
    @JsonIgnore
    @ExcelProperty(index = 8, value = "申请来源")
    private String sourceExcel;


    /**
     * 创建用户
     */
    @Schema(title = "创建用户" )
    @ExcelIgnore
    private String creatorUserId;


    /**
     * 审核状态，(0,待审批,1审批中,2,审核通过,3,审核不通过,4,撤销,5未办理, 6手动,)
     */
    @ExcelIgnore
    private Integer state;

    /**
     * 审核状态，(0,待审批,1审批中,2,审核通过,3,审核不通过,4,撤销,5未办理, 6手动,)
     */
    @ExcelProperty(index = 10, value = "状态")
    private String stateExcel;

    /**
     * 晋升通道包含多个晋升通道
     *
     */
    @Schema(description = "晋升通道")
    @ExcelIgnore
    private List<FtbCultivatePromotionVO> channelInfos;

    /**
     * 晋升通道个数
     *
     */
    @Schema(description = "晋升通道个数")
    @ExcelIgnore
    private Integer channelCount;

    /**
     * 申请时间
     */
    @Schema(title = "申请时间" )
    @ExcelProperty(index = 9, value = "晋升日期")
    @ColumnWidth(value = 18)
    @DateTimeFormat(value = "yyyy-MM-dd HH:mm")
    private Date creatorTime;

    /**
     * 审核时间
     */
    @Schema(title = "审核时间" )
    @ExcelIgnore
    private Date lastModifyTime;

    /**
     * 附件信息上限3个
     */
    @ExcelIgnore
    List<FtbCultivateOfflineFileVO> files;
    /**
     * 审批结果 0,不通过,1,通过
     */
    @ExcelIgnore
    private Integer  approvalResult;
    /**
     * 审批id
     */
    @ExcelIgnore
    private String taskInfoId;

    /**
     * 晋升后薪酬
     */
    @ExcelIgnore
    private BigDecimal postPromotionPay;
    /**
     * 工作状态
     *   * 302、试用
     *      * 303、正式
     *      * 304、待离职
     *      * 305 离职
     */
    @ExcelIgnore
    private String workingCondition;


    /**
     * 学习地图详情(v.1.0.1)
     *
     */
    @ExcelIgnore
    private FtbCultivatePromotionWithPersonelVO mapInfo;

    /**
     * 已学岗位数(v.1.0.1)
     *
     */
    @ExcelProperty(index = 6, value = "已学岗位")
    private Integer numberOfPositionsStudied = 0;

    /**
     *  版本号 区分是否为老版本审批数据 0为老版本 1为新版审批
     */
    @ExcelIgnore
    private Integer versionNum;


    public static FtbCultivatePromotionPostApplyVO coverFtbCultivatePromotionPostApplyVO(FtbCultivatePromotionPostApply vo) {
        if (vo == null) {
            return null;
        }
        FtbCultivatePromotionPostApplyVO ftbCultivatePromotionPostApplyVO = new FtbCultivatePromotionPostApplyVO();
        ftbCultivatePromotionPostApplyVO.setPostId(vo.getPostId());
        ftbCultivatePromotionPostApplyVO.setPostName(vo.getPostName());
        ftbCultivatePromotionPostApplyVO.setUserId(vo.getUserId());
        ftbCultivatePromotionPostApplyVO.setUserName(vo.getUserName());
        ftbCultivatePromotionPostApplyVO.setPromotionReason(vo.getPromotionReason());
        ftbCultivatePromotionPostApplyVO.setState(vo.getState());
        ftbCultivatePromotionPostApplyVO.setSource(vo.getSource());
        ftbCultivatePromotionPostApplyVO.setPostRankId(vo.getPostRankId());
        ftbCultivatePromotionPostApplyVO.setPostRankName(vo.getPostRankName());
        ftbCultivatePromotionPostApplyVO.setPostPromotionId(vo.getPostPromotionId());
        ftbCultivatePromotionPostApplyVO.setPostPromotionName(vo.getPostPromotionName());
        ftbCultivatePromotionPostApplyVO.setPostRankPromotionId(vo.getPostRankPromotionId());
        ftbCultivatePromotionPostApplyVO.setPostRankPromotionName(vo.getPostRankPromotionName());
        ftbCultivatePromotionPostApplyVO.setOrgId(vo.getOrgId());
        ftbCultivatePromotionPostApplyVO.setOrgName(vo.getOrgName());
        ftbCultivatePromotionPostApplyVO.setOrgCurrentId(vo.getOrgCurrentId());
        ftbCultivatePromotionPostApplyVO.setOrgCurrentName(vo.getOrgCurrentName());
        ftbCultivatePromotionPostApplyVO.setId(vo.getId());
        ftbCultivatePromotionPostApplyVO.setLastModifyTime(vo.getLastModifyTime());
        ftbCultivatePromotionPostApplyVO.setCreatorTime(vo.getCreatorTime());
        ftbCultivatePromotionPostApplyVO.setCreatorUserId(vo.getCreatorUserId());
        return ftbCultivatePromotionPostApplyVO;
    }

    public static void applicationSourceConversion(FtbPersonnelsApplyVO vo) {
        // 申请来源 0,员工申请,1,审批办理,2直接办理
        switch (vo.getSource()) {
            case 0:
                vo.setSourceExcel("员工申请");
                break;
            case 1:
                vo.setSourceExcel("审批办理");
                break;
            case 2:
                vo.setSourceExcel("直接办理");
                break;
            default:
                vo.setSourceExcel("未知");
                break;
        }
    }

    public static String stateConversion(Integer state) {
        // 审核状态，(0,待审批,1审批中,2,审核通过,3,审核不通过,4,撤销,5未办理, 6手动办理,)
        switch (state) {
            case 0:
                return "待审批";
            case 1:
                return "审批中";
            case 2:
                return "审核通过";
            case 3:
                return "审核不通过";
            case 4:
                return "撤销";
            case 5:
                return "未办理";
            case 6:
                return "手动办理";
            default:
                return "未知";
        }
    }

}
