package jnpf.model.personnels.vo.uchisuike;

import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import lombok.Data;

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

@Data
public class FtbinternalRecommendationPoolExportVO {
    /**
     * 姓名
     */
    @ExcelProperty(value = "姓名", index = 0)
    private String userName;

    /**
     * 性别0男1女
     */
    @ExcelProperty(value = "性别", index = 1)
    private String sex;

    /**
     * 身份证号码
     */
    @ExcelProperty(value = "身份证号码", index = 2)
    private String idCard;

    /**
     * 手机号码
     */
    @ExcelProperty(value = "手机号码", index = 3)
    private String phone;

    /**
     * 期望薪资
     */
    @ExcelProperty(value = "期望薪资", index = 7)
    private BigDecimal money;

    /**
     * 工作状态0未办理入职1预入职2已入职(试用)3已入职(正式)4已入职(待离职)5已入职(已离职)
     */
    @ExcelIgnore
    private Long state;

    /**
     * 来源1、APP端个人内推  2、门店招聘、3、组织招聘',
     */
    @ExcelIgnore
    private Long source;

    /**
     * 期望组织名字
     */
    @ExcelProperty(value = "期望组织", index = 4)
    private String orgName;

    /**
     * 期望岗位名称
     */
    @ExcelProperty(value = "期望岗位", index = 5)
    private String postName;

    /**
     * 期望职等名称
     */
    @ExcelProperty(value = "期望职级", index = 6)
    private String postRankName;

    /**
     * 内推时间
     */
    @ExcelProperty(value = "推荐时间", index = 8)
    @DateTimeFormat(value = "yyyy-MM-dd")
    private Date createTime;

    /**
     * 招聘信息获取渠道
     */
    @ExcelProperty(value = "招聘信息获取渠道", index = 9)
    private String channelsRecruitments;

    /**
     * 是否入职
     */
    @ExcelProperty(value = "是否入职", index = 11)
    private String whetherToJoinTheJob;

    /**
     * 来源
     */
    @ExcelProperty(value = "来源", index = 10)
    private String sourceName;

    public static FtbinternalRecommendationPoolExportVO convert(FtbinternalRecommendationPoolVO data) {
        if (data == null) {
            return null;
        }
        FtbinternalRecommendationPoolExportVO ftbinternalRecommendationPoolExportVO = new FtbinternalRecommendationPoolExportVO();
        ftbinternalRecommendationPoolExportVO.setUserName(data.getUserName());
        // 性别0男1女
        if (data.getSex() == 0) {
            ftbinternalRecommendationPoolExportVO.setSex("男");
        } else if (data.getSex() == 1) {
            ftbinternalRecommendationPoolExportVO.setSex("女");
        } else {
            ftbinternalRecommendationPoolExportVO.setSex("未知");
        }
        ftbinternalRecommendationPoolExportVO.setIdCard(data.getIdCard());
        ftbinternalRecommendationPoolExportVO.setPhone(data.getPhone());
        ftbinternalRecommendationPoolExportVO.setMoney(data.getMoney());
        ftbinternalRecommendationPoolExportVO.setState(data.getState());
        ftbinternalRecommendationPoolExportVO.setSource(data.getSource());
        ftbinternalRecommendationPoolExportVO.setOrgName(data.getOrgName());
        ftbinternalRecommendationPoolExportVO.setPostName(data.getPostName());
        ftbinternalRecommendationPoolExportVO.setPostRankName(data.getPostRankName());
        ftbinternalRecommendationPoolExportVO.setCreateTime(data.getCreateTime());
        ftbinternalRecommendationPoolExportVO.setChannelsRecruitments(data.getChannelsRecruitments());
        // 是否入职
        if (data.getState() == 0) {
            ftbinternalRecommendationPoolExportVO.setWhetherToJoinTheJob("未办理");
        } else if (data.getState() > 0) {
            ftbinternalRecommendationPoolExportVO.setWhetherToJoinTheJob("已入职");
        }
        // 来源1、APP端个人内推  2、门店招聘、3、组织招聘',
        if (Objects.nonNull(data.getSource())) {
            if (data.getSource() == 1) {
                ftbinternalRecommendationPoolExportVO.setSourceName("内推人：" + (StrUtil.isBlank(data.getPushUserName()) ? "" : data.getPushUserName()));
            } else if (data.getSource() == 2) {
                if (StrUtil.isNotBlank(data.getPushStoreName())) {
                    ftbinternalRecommendationPoolExportVO.setSourceName(data.getPushStoreName());
                } else {
                    ftbinternalRecommendationPoolExportVO.setSourceName(data.getPushOrgName());
                }
            } else if (data.getSource() == 3) {
                ftbinternalRecommendationPoolExportVO.setSourceName(data.getPushOrgName());
            }
        } else {
            ftbinternalRecommendationPoolExportVO.setSourceName("");
        }
        return ftbinternalRecommendationPoolExportVO;
    }

}
