package jnpf.model.personnels.po;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import jnpf.base.entity.SuperBaseEntity;
import jnpf.model.personnels.dto.staff.roster.WorkerGroupDataDto;
import jnpf.model.personnels.vo.turnover.FtbPersonnelsTurnoverInfoVO;
import jnpf.permission.eum.v2.UserWorkStatusEnums;
import jnpf.permission.vo.v2.user.UserBoundVO;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.Date;

/**
 * 离职管理 
 * @author admin
 * @create 2024-02-01 
 */

@Getter
@Setter
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@TableName(value = "ftb_personnels_turnover_management")
public class FtbPersonnelsTurnoverManagement extends SuperBaseEntity.SuperCUDBaseEntity<String> implements Serializable {

    private static final long serialVersionUID = 299553124797311436L;


    /**
     * 手机号
     */
    @TableField(value = "F_PhoneNumber")
    private String phoneNumber;
    /**
     * 系统用户id
     */
    @TableField(value = "F_SystemWokerId")
    private String systemWokerId;
    /**
     * 用户id
     */
    @TableField(value = "F_UserId")
    private String userId;

    /**
     * 用户姓名
     */
    @TableField(value = "F_UserName")
    private String userName;

    /**
     * 入职日期
     */
    @TableField(value = "F_DateOfEntry")
    private Date dateOfEntry;

    /**
     * 工号
     */
    @TableField(value = "F_JobNumber")
    private String jobNumber;

    /**
     * 试用期
     */
    @TableField(value = "F_Probation")
    private String probation;

    /**
     * 试用期
     */
    @TableField(value = "F_ProbationPeriodDay")
    private String probationPeriodDay;

    /**
     * 实际转正日期
     */
    @TableField(value = "F_ActualConverDate")
    private Date actualConverDate;

    /**
     * 工作状态(预入职/试用/正式/待离职/已离职)
     *  301、预入职 302、试用 303、正式 304、待离职 305 离职
     */
    @TableField(value = "F_WorkingCondition")
    private String workingCondition;

    /**
     * 入职所属组织id
     */
    @TableField(value = "F_OrgId")
    private String orgId;

    /**
     * 入职所属组织名称
     */
    @TableField(value = "F_OrgName")
    private String orgName;

    /**
     * 入职岗位id
     */
    @TableField(value = "F_EntryPostId")
    private String entryPostId;

    /**
     * 入职岗位名称
     */
    @TableField(value = "F_EntryPostName")
    private String entryPostName;

    /**
     * 入职职等id
     */
    @TableField(value = "F_EntryGradeId")
    private String entryGradeId;

    /**
     * 入职职等name
     */
    @TableField(value = "F_EntryGradeName")
    private String entryGradeName;

    /**
     * 组织信息
     */
    @TableField(value = "F_OrganizationInfo")
    private String organizationInfo;

    /**
     * 离职日期
     */
    @TableField(value = "F_ResignationDate")
    private Date resignationDate;

    /**
     * 员工期望离职日期
     */
    @TableField(value = "F_EmpResignationDate")
    private Date empResignationDate;

    /** 离职原因 */
    @TableField(value = "F_ReasonForResignation")
    private String reasonForResignation;

    /**
     * 离职备注
     */
    @TableField(value = "F_RemarksConver")
    private String remarksConver;
    /**
     * 其他离职备注
     */
    @TableField(value = "F_OtherRemarksConver")
    private String otherRemarksConver;

    /**
     * 申请来源 0,员工申请,1,审批办理,2直接办理,3 试岗驳回
     */
    @TableField(value = "F_ApplicationSource")
    private Integer applicationSource;

    /** 离职状态(0,待审批,1审批中,2,审核通过,3,审核不通过,4,撤销,5未办理, 6手动,7逾期未审批) 8 自动离职 */
    @TableField(value = "F_TurnoverStatus")
    private Integer turnoverStatus;


    /**
     * 是否有效(1无效,0有效)
     */
    @TableField(value = "F_EnableMark")
	private Long enableMark;

    /**
     * 审批id
     */
    @TableField(value = "F_TaskInfoId")
	private String taskInfoId;

    /**
     * 是否纳入黑名单(0为否,默认为0,1为黑名单)
     * (v1.1)
     */
    @TableField(value = "F_IsBeBlackList")
	private Integer isBeBlackList;

    /**
     * 黑名单期限，0三个月，1六个月，2一年，3一年六个月，4两年，5三年，6五年，7永久
     * (v1.1)
     */
    @TableField(value = "F_BlackListPeriod")
	private Integer blackListPeriod;
    /**
     * 黑名单类型
     * (v1.1)
     */
    @TableField(value = "F_BlackTypeId")
	private String blackTypeId;
    /**
     * 纳入黑名单原因(500个字符限制)
     * (v1.1)
     */
    @TableField(value = "F_BlacklistCause")
	private String blacklistCause;

    /**
     *  版本号 区分是否为老版本审批数据 0为老版本 1为新版审批
     */
    @TableField(value = "F_VersionNum")
    private Integer versionNum;

    public static FtbPersonnelsTurnoverInfoVO coverFtbPersonnelsTurnoverInfoVO(FtbPersonnelsTurnoverManagement management) {
        if (management == null) {
            return null;
        }
        FtbPersonnelsTurnoverInfoVO ftbPersonnelsTurnoverInfoVO = new FtbPersonnelsTurnoverInfoVO();
        ftbPersonnelsTurnoverInfoVO.setUserId(management.getUserId());
        ftbPersonnelsTurnoverInfoVO.setSystemWokerId(management.getSystemWokerId());
        ftbPersonnelsTurnoverInfoVO.setUserName(management.getUserName());
        ftbPersonnelsTurnoverInfoVO.setDateOfEntry(management.getDateOfEntry());
        ftbPersonnelsTurnoverInfoVO.setJobNumber(management.getJobNumber());
        ftbPersonnelsTurnoverInfoVO.setProbation(management.getProbation());
        ftbPersonnelsTurnoverInfoVO.setProbationPeriodDay(management.getProbationPeriodDay());
        ftbPersonnelsTurnoverInfoVO.setProbationPeriodDay(management.getProbationPeriodDay());
        ftbPersonnelsTurnoverInfoVO.setActualConverDate(management.getActualConverDate());
        ftbPersonnelsTurnoverInfoVO.setWorkingCondition(management.getWorkingCondition());
        ftbPersonnelsTurnoverInfoVO.setOrgId(management.getOrgId());
        ftbPersonnelsTurnoverInfoVO.setOrgName(management.getOrgName());
        ftbPersonnelsTurnoverInfoVO.setEntryPostId(management.getEntryPostId());
        ftbPersonnelsTurnoverInfoVO.setEntryPostName(management.getEntryPostName());
        ftbPersonnelsTurnoverInfoVO.setEntryGradeId(management.getEntryGradeId());
        ftbPersonnelsTurnoverInfoVO.setEntryGradeName(management.getEntryGradeName());
        ftbPersonnelsTurnoverInfoVO.setResignationDate(management.getResignationDate());
        ftbPersonnelsTurnoverInfoVO.setEmpResignationDate(management.getEmpResignationDate());
        ftbPersonnelsTurnoverInfoVO.setReasonForResignation(management.getReasonForResignation());
        ftbPersonnelsTurnoverInfoVO.setRemarksConver(management.getRemarksConver());
        ftbPersonnelsTurnoverInfoVO.setOtherRemarksConver(management.getOtherRemarksConver());
        ftbPersonnelsTurnoverInfoVO.setId(management.getId());
        ftbPersonnelsTurnoverInfoVO.setCreatorTime(management.getCreatorTime());
        ftbPersonnelsTurnoverInfoVO.setTaskInfoId(management.getTaskInfoId());
        ftbPersonnelsTurnoverInfoVO.setTurnoverStatus(management.getTurnoverStatus());
        ftbPersonnelsTurnoverInfoVO.setApplicationSource(management.getApplicationSource());
        // 员工黑名单不会展示这个详情
         ftbPersonnelsTurnoverInfoVO.setIsBeBlackList(management.getIsBeBlackList());
         ftbPersonnelsTurnoverInfoVO.setBlackListPeriod(management.getBlackListPeriod());
         ftbPersonnelsTurnoverInfoVO.setBlackTypeId(management.getBlackTypeId());
         ftbPersonnelsTurnoverInfoVO.setBlacklistCause(management.getBlacklistCause());
        ftbPersonnelsTurnoverInfoVO.setVersionNum(management.getVersionNum());
        if (StringUtils.isNotEmpty(management.getOrganizationInfo())){
            ftbPersonnelsTurnoverInfoVO.setOrganizationInfo(JSONObject.parseArray(management.getOrganizationInfo(), WorkerGroupDataDto.class));
        }
        return ftbPersonnelsTurnoverInfoVO;
    }

    public static UserBoundVO coverUserBoundVO(FtbPersonnelsTurnoverManagement management) {
        if (management == null) {
            return null;
        }
        UserBoundVO userBoundVO = new UserBoundVO();
        userBoundVO.setUserName(management.getUserName());
        userBoundVO.setId(management.getUserId());
        userBoundVO.setSystemWorkerId(management.getSystemWokerId());
        userBoundVO.setWorkStatusEnums(UserWorkStatusEnums.RESIGNED);
        userBoundVO.setPhone(management.getPhoneNumber());
        userBoundVO.setEntryDate(management.getDateOfEntry());
        userBoundVO.setDepartDate(management.getResignationDate());
        return userBoundVO;
    }

}
