package jnpf.model.personnels.dto.turnover;

import com.fasterxml.jackson.annotation.JsonIgnore;
import jnpf.model.cultivate.dto.offline.FtbCultivateOfflineFileDTO;
import jnpf.model.personnels.dto.base.FtbPersonnelsBaseForOA;
import jnpf.model.personnels.dto.black.FtbPersonnelsBlacklistAddDTO;
import jnpf.model.personnels.dto.staff.roster.WorkerGroupDataDto;
import jnpf.model.personnels.po.FtbPersonnelsTurnoverManagement;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.Valid;
import javax.validation.constraints.Size;
import java.util.Date;
import java.util.List;

/**
 * @Title:FtbPersonnelsTurnoverCreateDto
 * @Author:peng.hao
 * @create: 2024/2/117:35
 */
@Data
public class FtbPersonnelsTurnoverCreateDTO extends FtbPersonnelsBaseForOA {


    private String id;
    /**
     * 2,审批,3自动离职
     */
    private String flag;
    /**
     * 系统用户id
     */
    private String systemWokerId;

    /**
     * 手机号
     */
    private String phoneNumber;

    /**
     * 用户id
     */
    private String userId;


    /**
     * 用户姓名
     */
    private String userName;
    /**
     * 工号
     */
    @JsonIgnore
    private String jobNumber;

    /**
     * 入职日期
     */
    private Date dateOfEntry;

    /**
     * 所属组织Id
     */
    private String orgId;

    /**
     * 所属组织名称
     */
    private String orgName;

    /**
     * 岗位id
     */
    private String entryPostId;

    /**
     * 岗位名称
     */
    private String entryPostName;

    /**
     * 职级id
     */
    private String entryGradeId;

    /**
     * 职级name
     */
    private String entryGradeName;

    /**
     * 试用期
     * 100	无试用期
     * 101	1个月内
     * 102	1个月
     * 103	2个月
     * 104	3个月
     * 105	4个月
     * 106	5个月
     * 107	6个月
     * 108	7个月
     * 109	8个月
     */
    private String probation;

    /**
     * 试用期天数，如果是1个月内，这里就是天数
     */
    private String probationPeriodDay;

    /**
     * 实际转正日期
     */
    private Date actualConverDate;

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

    /**
     * 离职日期
     */
    private Date resignationDate;

    /**
     * 员工期望离职日期
     */
    private Date empResignationDate;

    /** 离职原因
     *  json 串
     * */
    private String reasonForResignation;

    /**
     * 离职备注
     */
    @Length(max = 500, message = "离职备注长度不能超过500")
    private String remarksConver;
    /**
     * 离职备注
     */
    @Length(max = 20, message = "其他备注长度不能超过20")
    private String otherRemarksConver;

    /**
     * 附件信息上限10个
     */
    @Size(max = 10, message = "附件信息上限10个")
    @Valid
    private List<FtbCultivateOfflineFileDTO> files;
    /**
     * 附件格式问题
     */
    private String filesWithOa;

    /**
     * 离职交接详情
     */
    private List<FtbPersonnelsTurnoverHandoverDTO> handover;
    /**
     * 0,员工申请,1,审批办理,2直接办理 3试岗驳回
     */
    private  Integer source;
    /**
     * 强制申请离职 1标识为是
     */
    private  Integer forceDelete;
    /**
     * 是否纳入黑名单(0为否,默认为0,1为黑名单)
     * (v1.1)
     */
    @JsonIgnore
    private Integer isBeBlackList;
    /**
     * 是否纳入黑名单(1否,2为是)
     * (v1.1)
     */
    @JsonIgnore
    private Integer isBeBlackListForOA;

    /**
     * 黑名单期限，0三个月，1六个月，2一年，3一年六个月，4两年，5三年，6五年，7永久
     * (v1.1)
     */
    @JsonIgnore
    private Integer blackListPeriod;

    /**
     * 黑名单期限，1三个月，2六个月，3一年，4一年六个月，5两年，6三年，7五年，8永久
     * (v1.1)
     */
    @JsonIgnore
    private Integer blackListPeriodForOA;

    /**
     * 黑名单类型
     * (v1.1)
     */
    @JsonIgnore
    private String blackTypeId;
    /**
     * 纳入黑名单原因(500个字符限制)
     * (v1.1)
     */
    @Length(max = 500, message = "黑名单原因不能超过500个字符")
    @JsonIgnore
    private String blacklistCause;
    /**
     * 组织信息添加
     */
    @JsonIgnore
    List<WorkerGroupDataDto> organizationInfo;
    /**
     * 组织信息添加
     */
    @JsonIgnore
    List<WorkerGroupDataDto> organizationInfoForApp;


    public static FtbPersonnelsTurnoverManagement coverFtbPersonnelsTurnoverManagement(FtbPersonnelsTurnoverCreateDTO createDTO) {
        if (createDTO == null) {
            return null;
        }
        FtbPersonnelsTurnoverManagement ftbPersonnelsTurnoverManagement = new FtbPersonnelsTurnoverManagement();
        ftbPersonnelsTurnoverManagement.setId(createDTO.getId());
        if (createDTO.getSpecialBusinessId() != null ) ftbPersonnelsTurnoverManagement.setId(createDTO.getSpecialBusinessId());
        ftbPersonnelsTurnoverManagement.setSystemWokerId(createDTO.getSystemWokerId());
        ftbPersonnelsTurnoverManagement.setPhoneNumber(createDTO.getPhoneNumber());
        ftbPersonnelsTurnoverManagement.setUserId(createDTO.getUserId());
        if (createDTO.getUserIds() != null && !createDTO.getUserIds().isEmpty())  ftbPersonnelsTurnoverManagement.setUserId(createDTO.getUserIds().get(0));
        ftbPersonnelsTurnoverManagement.setUserName(createDTO.getUserName());
        ftbPersonnelsTurnoverManagement.setJobNumber(createDTO.getJobNumber());
        ftbPersonnelsTurnoverManagement.setDateOfEntry(createDTO.getDateOfEntry());
        ftbPersonnelsTurnoverManagement.setOrgId(createDTO.getOrgId());
        ftbPersonnelsTurnoverManagement.setOrgName(createDTO.getOrgName());
        ftbPersonnelsTurnoverManagement.setEntryPostId(createDTO.getEntryPostId());
        ftbPersonnelsTurnoverManagement.setEntryPostName(createDTO.getEntryPostName());
        ftbPersonnelsTurnoverManagement.setEntryGradeId(createDTO.getEntryGradeId());
        ftbPersonnelsTurnoverManagement.setEntryGradeName(createDTO.getEntryGradeName());
        ftbPersonnelsTurnoverManagement.setProbation(createDTO.getProbation());
        ftbPersonnelsTurnoverManagement.setProbationPeriodDay(createDTO.getProbationPeriodDay());
        ftbPersonnelsTurnoverManagement.setActualConverDate(createDTO.getActualConverDate());
        ftbPersonnelsTurnoverManagement.setWorkingCondition(createDTO.getWorkingCondition());
        ftbPersonnelsTurnoverManagement.setReasonForResignation(createDTO.getReasonForResignation());
        ftbPersonnelsTurnoverManagement.setRemarksConver(createDTO.getRemarksConver());
        ftbPersonnelsTurnoverManagement.setOtherRemarksConver(createDTO.getOtherRemarksConver());
        ftbPersonnelsTurnoverManagement.setIsBeBlackList(createDTO.getIsBeBlackList());
        ftbPersonnelsTurnoverManagement.setBlackListPeriod(createDTO.getBlackListPeriod());
        ftbPersonnelsTurnoverManagement.setBlackTypeId(createDTO.getBlackTypeId());
        ftbPersonnelsTurnoverManagement.setBlacklistCause(createDTO.getBlacklistCause());
        return ftbPersonnelsTurnoverManagement;
    }

    public static FtbPersonnelsBlacklistAddDTO covertBlacklist(FtbPersonnelsTurnoverManagement ftbPersonnelsTurnoverManagementO) {
        if (ftbPersonnelsTurnoverManagementO == null) {
            return null;
        }
        FtbPersonnelsBlacklistAddDTO ftbPersonnelsBlacklistAddDTO = new FtbPersonnelsBlacklistAddDTO();
        ftbPersonnelsBlacklistAddDTO.setUserId(ftbPersonnelsTurnoverManagementO.getUserId());
        ftbPersonnelsBlacklistAddDTO.setUserName(ftbPersonnelsTurnoverManagementO.getUserName());
        ftbPersonnelsBlacklistAddDTO.setOrgName(ftbPersonnelsTurnoverManagementO.getOrgName());
        ftbPersonnelsBlacklistAddDTO.setPostName(ftbPersonnelsTurnoverManagementO.getEntryPostName());
        ftbPersonnelsBlacklistAddDTO.setBlackTypeId(ftbPersonnelsTurnoverManagementO.getBlackTypeId());
        ftbPersonnelsBlacklistAddDTO.setPhone(ftbPersonnelsTurnoverManagementO.getPhoneNumber());
        ftbPersonnelsBlacklistAddDTO.setType(ftbPersonnelsTurnoverManagementO.getBlackListPeriod());
        ftbPersonnelsBlacklistAddDTO.setUserSystemId(ftbPersonnelsTurnoverManagementO.getSystemWokerId());
        ftbPersonnelsBlacklistAddDTO.setReason(ftbPersonnelsTurnoverManagementO.getBlacklistCause());
        return ftbPersonnelsBlacklistAddDTO;
    }
    public static FtbPersonnelsTurnoverCreateDTO covertJobRejected(FtbPersonnelsJobTrialRejectedCreateDTO createDTO) {
        if (createDTO == null) {
            return null;
        }
        FtbPersonnelsTurnoverCreateDTO ftbPersonnelsTurnoverCreateDTO = new FtbPersonnelsTurnoverCreateDTO();
        ftbPersonnelsTurnoverCreateDTO.setSystemWokerId(createDTO.getSystemWokerId());
        ftbPersonnelsTurnoverCreateDTO.setPhoneNumber(createDTO.getPhoneNumber());
        ftbPersonnelsTurnoverCreateDTO.setUserId(createDTO.getUserId());
        ftbPersonnelsTurnoverCreateDTO.setUserName(createDTO.getUserName());
        ftbPersonnelsTurnoverCreateDTO.setJobNumber(createDTO.getJobNumber());
        ftbPersonnelsTurnoverCreateDTO.setDateOfEntry(createDTO.getDateOfEntry());
        ftbPersonnelsTurnoverCreateDTO.setOrgId(createDTO.getOrgId());
        ftbPersonnelsTurnoverCreateDTO.setOrgName(createDTO.getOrgName());
        ftbPersonnelsTurnoverCreateDTO.setEntryPostId(createDTO.getEntryPostId());
        ftbPersonnelsTurnoverCreateDTO.setEntryPostName(createDTO.getEntryPostName());
        ftbPersonnelsTurnoverCreateDTO.setEntryGradeId(createDTO.getEntryGradeId());
        ftbPersonnelsTurnoverCreateDTO.setEntryGradeName(createDTO.getEntryGradeName());
        ftbPersonnelsTurnoverCreateDTO.setProbation(createDTO.getProbation());
        ftbPersonnelsTurnoverCreateDTO.setProbationPeriodDay(createDTO.getProbationPeriodDay());
        ftbPersonnelsTurnoverCreateDTO.setResignationDate(createDTO.getResignationDate());
        ftbPersonnelsTurnoverCreateDTO.setOrganizationInfo(createDTO.getOrganizationInfo());
        ftbPersonnelsTurnoverCreateDTO.setFlag("3");
        ftbPersonnelsTurnoverCreateDTO.setSource(3);
        return ftbPersonnelsTurnoverCreateDTO;
    }

}
