package jnpf.model.personnels.vo.employment;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import jnpf.model.personnels.dto.staff.employment.FtbPersonnelsStaffEmploymentApplyDto;
import lombok.Data;

import java.util.Date;

@Data
public class FtbPersonnelsStaffEmploymentApplyVO {
    /**
     * 手机号
     */
    @ExcelProperty(value = "手机号", index = 2)
    private String phone;

    /**
     * 姓名
     */
    @ExcelProperty(value = "姓名", index = 0)
    private String workerName;

    /**
     * 入职组织名称
     */
    @ExcelProperty(value = "组织", index = 1)
    private String currOrgName;

    /**
     * 入职岗位名称
     */
    @ExcelProperty(value = "岗位", index = 3)
    private String currPositionName;

    /**
     * 入职职等名称
     */
    @ExcelProperty(value = "职等", index = 4)
    private String currRankName;


    /**
     * 预计入职日期
     */
    @ExcelProperty(value = "预计入职日期", index = 5)
    @DateTimeFormat(value = "yyyy-MM-dd")
    private Date expectedStartDate;

    /**
     * 来源，1、内推  2、门店招聘、3、组织招聘
     */
    @ExcelProperty(value = "来源", index = 6)
    private String source;

    /**
     * 状态
     */
    @ExcelProperty(value = "状态", index = 7)
    private String status;

    public static FtbPersonnelsStaffEmploymentApplyVO convert(FtbPersonnelsStaffEmploymentApplyDto data) {
        if (data == null) {
            return null;
        }
        FtbPersonnelsStaffEmploymentApplyVO ftbPersonnelsStaffEmploymentApplyVO = new FtbPersonnelsStaffEmploymentApplyVO();
        ftbPersonnelsStaffEmploymentApplyVO.setPhone(data.getPhone());
        ftbPersonnelsStaffEmploymentApplyVO.setWorkerName(data.getWorkerName());
        ftbPersonnelsStaffEmploymentApplyVO.setExpectedStartDate(data.getExpectedStartDate());
        ftbPersonnelsStaffEmploymentApplyVO.setCurrOrgName(data.getCurrOrgName());
        ftbPersonnelsStaffEmploymentApplyVO.setCurrPositionName(data.getCurrPositionName());
        ftbPersonnelsStaffEmploymentApplyVO.setCurrRankName(data.getCurrRankName());
        // 来源，跟前端保持一致
        if (data.getSource() == 0) {
            ftbPersonnelsStaffEmploymentApplyVO.setSource("后台办理");
        } else if (data.getSource() == 1) {
            //ftbPersonnelsStaffEmploymentApplyVO.setSource("内推人:" + data.getOpUserName());
            ftbPersonnelsStaffEmploymentApplyVO.setSource("APP端个人内推");
        } else if (data.getSource() == 2) {
            ftbPersonnelsStaffEmploymentApplyVO.setSource("门店招聘");
        } else if (data.getSource() == 3) {
            ftbPersonnelsStaffEmploymentApplyVO.setSource("组织招聘");
        } else {
            ftbPersonnelsStaffEmploymentApplyVO.setSource(data.getSourceRelation());
        }
//        // 是否提交了入职登记表：0、未提交  1、已提交
//        switch (data.getIsSubmitForm()) {
//            case 0:
//                ftbPersonnelsStaffEmploymentApplyVO.setIsSubmitForm("未提交");
//                break;
//            case 1:
//                ftbPersonnelsStaffEmploymentApplyVO.setIsSubmitForm("已提交");
//                break;
//            default:
//                ftbPersonnelsStaffEmploymentApplyVO.setIsSubmitForm("未知");
//                break;
//        }
        if (data.getStatus() == 2) {
            ftbPersonnelsStaffEmploymentApplyVO.setStatus("逾期" + data.getExpireDayNum() + "天未到岗");
        } else {
            // 到岗状态：0、未到岗 1、已到岗
            switch (data.getStatus()) {
                case 0:
                    ftbPersonnelsStaffEmploymentApplyVO.setStatus("未到岗");
                    break;
                case 1:
                    ftbPersonnelsStaffEmploymentApplyVO.setStatus("已到岗");
                    break;
                default:
                    ftbPersonnelsStaffEmploymentApplyVO.setStatus("未知");
                    break;
            }
        }
        return ftbPersonnelsStaffEmploymentApplyVO;
    }

}
