package com.gtiit.shr.entity.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.sql.Date;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Objects;

/**
 * 人员信息表
 */
@TableName("CT_SHR_PERSONINFO")
public class PersonInfoVo implements Serializable {
    @TableField("PERSON_NUMBER")
    private String personNumber;
    @TableField("LAST_NAME")
    private String lastName;
    @TableField("MIDDLE_NAMES")
    private String middleNames;
    @TableField("FIRST_NAME")
    private String firstName;
    @TableField("LOCAL_NAME")
    private String localName;
    @TableField("DISPLAY_NAME")
    private String displayName;
    @TableField("USER_PERSON_TYPE")
    private String userPersonType;
    @TableField("FULL_PART_TIME")
    private String fullPartTime;
    @TableField("HIRE_DATE")
    private Date hireDate;
    @TableField("PROBATION_PERIOD")
    private String probationPeriod;
    @TableField("PROBATION_UNIT")
    private String probationUnit;
    @TableField("DATE_PROBATION_END")
    private Date dateProbationEnd;
    @TableField("WORK_PHONE")
    private String workPhone;
    @TableField("CELL_PHONE")
    private String cellPhone;
    @TableField("EMAIL_ADDRESS")
    private String emailAddress;
    @TableField("S_EMAIL_ADDRESS")
    private String sEmailAddress;
    @TableField("CITIZENSHIP")
    private String citizenShip;
    @TableField("GENDER")
    private String gender;
    @TableField("DATE_OF_BIRTH")
    private Date dateOfBirth;
    @TableField("ETHNICITY")
    private String ethnicity;
    @TableField("HUKOU_TYPE")
    private String hukouType;
    @TableField("POLITICAL_STATUS")
    private String politicalStatus;
    @TableField("TER_DATE")
    private Date terDate;
    @TableField("REASON")
    private String reason;
    @TableField("PROFESSIONAL_TITLE")
    private String professionalTitle;
    @TableField("JOB_LEVEL")
    private String jobLevel;
    @TableField("USER_NAME")
    private String userName;
    @TableField("CONTRACT_START_DATE")
    private Date contractStartDate;
    @TableField("CONTRACT_END_DATE")
    private Date contractEndDate;
    @TableField("ERP_CREATION_DATE")
    private Timestamp erpCreationDate;
    @TableField("ERP_LAST_UPDATE_DATE")
    private Timestamp erpLastUpdateDate;

    private String id;

    // 日期格式转换器
    private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
    private static final SimpleDateFormat DATE_ONLY_FORMAT = new SimpleDateFormat("yyyy-MM-dd");

    public String getPersonNumber() {
        return this.personNumber;
    }

    public String getLastName() {
        return this.lastName;
    }

    public String getMiddleNames() {
        return this.middleNames;
    }

    public String getFirstName() {
        return this.firstName;
    }

    public String getLocalName() {
        return this.localName;
    }

    public String getDisplayName() {
        return this.displayName;
    }

    public String getUserPersonType() {
        return this.userPersonType;
    }

    public String getFullPartTime() {
        return this.fullPartTime;
    }

    public Date getHireDate() {
        return this.hireDate;
    }

    public String getProbationPeriod() {
        return this.probationPeriod;
    }

    public String getProbationUnit() {
        return this.probationUnit;
    }

    public Date getDateProbationEnd() {
        return this.dateProbationEnd;
    }

    public String getWorkPhone() {
        return this.workPhone;
    }

    public String getCellPhone() {
        return this.cellPhone;
    }

    public String getEmailAddress() {
        return this.emailAddress;
    }

    public String getSEmailAddress() {
        return this.sEmailAddress;
    }

    public String getCitizenShip() {
        return this.citizenShip;
    }

    public String getGender() {
        return this.gender;
    }

    public Date getDateOfBirth() {
        return this.dateOfBirth;
    }

    public String getEthnicity() {
        return this.ethnicity;
    }

    public String getHukouType() {
        return this.hukouType;
    }

    public String getPoliticalStatus() {
        return this.politicalStatus;
    }

    public Date getTerDate() {
        return this.terDate;
    }

    public String getReason() {
        return this.reason;
    }

    public String getProfessionalTitle() {
        return this.professionalTitle;
    }

    public String getJobLevel() {
        return this.jobLevel;
    }

    public String getUserName() {
        return this.userName;
    }

    public Date getContractStartDate() {
        return this.contractStartDate;
    }

    public Date getContractEndDate() {
        return this.contractEndDate;
    }

    public Timestamp getErpCreationDate() {
        return this.erpCreationDate;
    }

    public Timestamp getErpLastUpdateDate() {
        return this.erpLastUpdateDate;
    }

    public String getId() {
        return this.id;
    }

    public void setPersonNumber(final String personNumber) {
        this.personNumber = personNumber;
    }

    public void setLastName(final String lastName) {
        this.lastName = lastName;
    }

    public void setMiddleNames(final String middleNames) {
        this.middleNames = middleNames;
    }

    public void setFirstName(final String firstName) {
        this.firstName = firstName;
    }

    public void setLocalName(final String localName) {
        this.localName = localName;
    }

    public void setDisplayName(final String displayName) {
        this.displayName = displayName;
    }

    public void setUserPersonType(final String userPersonType) {
        this.userPersonType = userPersonType;
    }

    public void setFullPartTime(final String fullPartTime) {
        this.fullPartTime = fullPartTime;
    }

    public void setHireDate(final Date hireDate) {
        this.hireDate = hireDate;
    }

    public void setHireDate(final String hireDate) {
        if (hireDate != null && !hireDate.trim().isEmpty()) {
            try {
                java.util.Date utilDate = DATE_FORMAT.parse(hireDate);
                this.hireDate = new Date(utilDate.getTime());
            } catch (ParseException e) {
                try {
                    java.util.Date utilDate = DATE_ONLY_FORMAT.parse(hireDate);
                    this.hireDate = new Date(utilDate.getTime());
                } catch (ParseException ex) {
                    throw new RuntimeException("Failed to parse hire date: " + hireDate, ex);
                }
            }
        } else {
            this.hireDate = null;
        }
    }

    public void setProbationPeriod(final String probationPeriod) {
        this.probationPeriod = probationPeriod;
    }

    public void setProbationUnit(final String probationUnit) {
        this.probationUnit = probationUnit;
    }

    public void setDateProbationEnd(final Date dateProbationEnd) {
        this.dateProbationEnd = dateProbationEnd;
    }

    public void setDateProbationEnd(final String dateProbationEnd) {
        if (dateProbationEnd != null && !dateProbationEnd.trim().isEmpty()) {
            try {
                java.util.Date utilDate = DATE_FORMAT.parse(dateProbationEnd);
                this.dateProbationEnd = new Date(utilDate.getTime());
            } catch (ParseException e) {
                try {
                    java.util.Date utilDate = DATE_ONLY_FORMAT.parse(dateProbationEnd);
                    this.dateProbationEnd = new Date(utilDate.getTime());
                } catch (ParseException ex) {
                    throw new RuntimeException("Failed to parse probation end date: " + dateProbationEnd, ex);
                }
            }
        } else {
            this.dateProbationEnd = null;
        }
    }

    public void setWorkPhone(final String workPhone) {
        this.workPhone = workPhone;
    }

    public void setCellPhone(final String cellPhone) {
        this.cellPhone = cellPhone;
    }

    public void setEmailAddress(final String emailAddress) {
        this.emailAddress = emailAddress;
    }

    public void setSEmailAddress(final String sEmailAddress) {
        this.sEmailAddress = sEmailAddress;
    }

    public void setCitizenShip(final String citizenShip) {
        this.citizenShip = citizenShip;
    }

    public void setGender(final String gender) {
        this.gender = gender;
    }

    public void setDateOfBirth(final Date dateOfBirth) {
        this.dateOfBirth = dateOfBirth;
    }

    public void setDateOfBirth(final String dateOfBirth) {
        if (dateOfBirth != null && !dateOfBirth.trim().isEmpty()) {
            try {
                java.util.Date utilDate = DATE_FORMAT.parse(dateOfBirth);
                this.dateOfBirth = new Date(utilDate.getTime());
            } catch (ParseException e) {
                try {
                    java.util.Date utilDate = DATE_ONLY_FORMAT.parse(dateOfBirth);
                    this.dateOfBirth = new Date(utilDate.getTime());
                } catch (ParseException ex) {
                    throw new RuntimeException("Failed to parse date of birth: " + dateOfBirth, ex);
                }
            }
        } else {
            this.dateOfBirth = null;
        }
    }

    public void setEthnicity(final String ethnicity) {
        this.ethnicity = ethnicity;
    }

    public void setHukouType(final String hukouType) {
        this.hukouType = hukouType;
    }

    public void setPoliticalStatus(final String politicalStatus) {
        this.politicalStatus = politicalStatus;
    }

    public void setTerDate(final Date terDate) {
        this.terDate = terDate;
    }

    public void setTerDate(final String terDate) {
        if (terDate != null && !terDate.trim().isEmpty()) {
            try {
                java.util.Date utilDate = DATE_FORMAT.parse(terDate);
                this.terDate = new Date(utilDate.getTime());
            } catch (ParseException e) {
                try {
                    java.util.Date utilDate = DATE_ONLY_FORMAT.parse(terDate);
                    this.terDate = new Date(utilDate.getTime());
                } catch (ParseException ex) {
                    throw new RuntimeException("Failed to parse termination date: " + terDate, ex);
                }
            }
        } else {
            this.terDate = null;
        }
    }

    public void setReason(final String reason) {
        this.reason = reason;
    }

    public void setProfessionalTitle(final String professionalTitle) {
        this.professionalTitle = professionalTitle;
    }

    public void setJobLevel(final String jobLevel) {
        this.jobLevel = jobLevel;
    }

    public void setUserName(final String userName) {
        this.userName = userName;
    }

    public void setContractStartDate(final Date contractStartDate) {
        this.contractStartDate = contractStartDate;
    }

    public void setContractStartDate(final String contractStartDate) {
        if (contractStartDate != null && !contractStartDate.trim().isEmpty()) {
            try {
                java.util.Date utilDate = DATE_FORMAT.parse(contractStartDate);
                this.contractStartDate = new Date(utilDate.getTime());
            } catch (ParseException e) {
                try {
                    java.util.Date utilDate = DATE_ONLY_FORMAT.parse(contractStartDate);
                    this.contractStartDate = new Date(utilDate.getTime());
                } catch (ParseException ex) {
                    throw new RuntimeException("Failed to parse contract start date: " + contractStartDate, ex);
                }
            }
        } else {
            this.contractStartDate = null;
        }
    }

    public void setContractEndDate(final Date contractEndDate) {
        this.contractEndDate = contractEndDate;
    }

    public void setContractEndDate(final String contractEndDate) {
        if (contractEndDate != null && !contractEndDate.trim().isEmpty()) {
            try {
                java.util.Date utilDate = DATE_FORMAT.parse(contractEndDate);
                this.contractEndDate = new Date(utilDate.getTime());
            } catch (ParseException e) {
                try {
                    java.util.Date utilDate = DATE_ONLY_FORMAT.parse(contractEndDate);
                    this.contractEndDate = new Date(utilDate.getTime());
                } catch (ParseException ex) {
                    throw new RuntimeException("Failed to parse contract end date: " + contractEndDate, ex);
                }
            }
        } else {
            this.contractEndDate = null;
        }
    }

    public void setErpCreationDate(final Timestamp erpCreationDate) {
        this.erpCreationDate = erpCreationDate;
    }

    public void setErpCreationDate(final String erpCreationDate) {
        if (erpCreationDate != null && !erpCreationDate.trim().isEmpty()) {
            try {
                java.util.Date utilDate = DATE_FORMAT.parse(erpCreationDate);
                this.erpCreationDate = new Timestamp(utilDate.getTime());
            } catch (ParseException e) {
                throw new RuntimeException("Failed to parse ERP creation date: " + erpCreationDate, e);
            }
        } else {
            this.erpCreationDate = null;
        }
    }

    public void setErpLastUpdateDate(final Timestamp erpLastUpdateDate) {
        this.erpLastUpdateDate = erpLastUpdateDate;
    }

    public void setErpLastUpdateDate(final String erpLastUpdateDate) {
        if (erpLastUpdateDate != null && !erpLastUpdateDate.trim().isEmpty()) {
            try {
                java.util.Date utilDate = DATE_FORMAT.parse(erpLastUpdateDate);
                this.erpLastUpdateDate = new Timestamp(utilDate.getTime());
            } catch (ParseException e) {
                throw new RuntimeException("Failed to parse ERP last update date: " + erpLastUpdateDate, e);
            }
        } else {
            this.erpLastUpdateDate = null;
        }
    }

    public void setId(final String id) {
        this.id = id;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        PersonInfoVo that = (PersonInfoVo) o;
        return Objects.equals(personNumber, that.personNumber) &&
                Objects.equals(lastName, that.lastName) &&
                Objects.equals(middleNames, that.middleNames) &&
                Objects.equals(firstName, that.firstName) &&
                Objects.equals(localName, that.localName) &&
                Objects.equals(displayName, that.displayName) &&
                Objects.equals(userPersonType, that.userPersonType) &&
                Objects.equals(fullPartTime, that.fullPartTime) &&
                Objects.equals(hireDate, that.hireDate) &&
                Objects.equals(probationPeriod, that.probationPeriod) &&
                Objects.equals(probationUnit, that.probationUnit) &&
                Objects.equals(dateProbationEnd, that.dateProbationEnd) &&
                Objects.equals(workPhone, that.workPhone) &&
                Objects.equals(cellPhone, that.cellPhone) &&
                Objects.equals(emailAddress, that.emailAddress) &&
                Objects.equals(sEmailAddress, that.sEmailAddress) &&
                Objects.equals(citizenShip, that.citizenShip) &&
                Objects.equals(gender, that.gender) &&
                Objects.equals(dateOfBirth, that.dateOfBirth) &&
                Objects.equals(ethnicity, that.ethnicity) &&
                Objects.equals(hukouType, that.hukouType) &&
                Objects.equals(politicalStatus, that.politicalStatus) &&
                Objects.equals(terDate, that.terDate) &&
                Objects.equals(reason, that.reason) &&
                Objects.equals(professionalTitle, that.professionalTitle) &&
                Objects.equals(jobLevel, that.jobLevel) &&
                Objects.equals(userName, that.userName) &&
                Objects.equals(contractStartDate, that.contractStartDate) &&
                Objects.equals(contractEndDate, that.contractEndDate) &&
                Objects.equals(erpCreationDate, that.erpCreationDate) &&
                Objects.equals(erpLastUpdateDate, that.erpLastUpdateDate) &&
                Objects.equals(id, that.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(
                personNumber, lastName, middleNames, firstName, localName, displayName,
                userPersonType, fullPartTime, hireDate, probationPeriod, probationUnit,
                dateProbationEnd, workPhone, cellPhone, emailAddress, sEmailAddress,
                citizenShip, gender, dateOfBirth, ethnicity, hukouType, politicalStatus,
                terDate, reason, professionalTitle, jobLevel, userName, contractStartDate,
                contractEndDate, erpCreationDate, erpLastUpdateDate, id
        );
    }

    @Override
    public String toString() {
        return "PersonInfoVo{" +
                "personNumber='" + personNumber + '\'' +
                ", lastName='" + lastName + '\'' +
                ", middleNames='" + middleNames + '\'' +
                ", firstName='" + firstName + '\'' +
                ", localName='" + localName + '\'' +
                ", displayName='" + displayName + '\'' +
                ", userPersonType='" + userPersonType + '\'' +
                ", fullPartTime='" + fullPartTime + '\'' +
                ", hireDate=" + hireDate +
                ", probationPeriod='" + probationPeriod + '\'' +
                ", probationUnit='" + probationUnit + '\'' +
                ", dateProbationEnd=" + dateProbationEnd +
                ", workPhone='" + workPhone + '\'' +
                ", cellPhone='" + cellPhone + '\'' +
                ", emailAddress='" + emailAddress + '\'' +
                ", sEmailAddress='" + sEmailAddress + '\'' +
                ", citizenShip='" + citizenShip + '\'' +
                ", gender='" + gender + '\'' +
                ", dateOfBirth=" + dateOfBirth +
                ", ethnicity='" + ethnicity + '\'' +
                ", hukouType='" + hukouType + '\'' +
                ", politicalStatus='" + politicalStatus + '\'' +
                ", terDate=" + terDate +
                ", reason='" + reason + '\'' +
                ", professionalTitle='" + professionalTitle + '\'' +
                ", jobLevel='" + jobLevel + '\'' +
                ", userName='" + userName + '\'' +
                ", contractStartDate=" + contractStartDate +
                ", contractEndDate=" + contractEndDate +
                ", erpCreationDate=" + erpCreationDate +
                ", erpLastUpdateDate=" + erpLastUpdateDate +
                ", id='" + id + '\'' +
                '}';
    }
}