package cn.lihongjie.coal.employee.entity;

import cn.lihongjie.coal.base.entity.OrgCommonEntity;
import cn.lihongjie.coal.department.entity.DepartmentEntity;
import cn.lihongjie.coal.file.entity.FileEntity;
import cn.lihongjie.coal.jobPost.entity.JobPostEntity;

import jakarta.persistence.ElementCollection;
import jakarta.persistence.Entity;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;

import lombok.Data;

import org.hibernate.annotations.Comment;
import org.hibernate.annotations.Formula;

import java.time.LocalDate;
import java.util.List;

@Data
@Entity
public class EmployeeEntity extends OrgCommonEntity {

    @Comment("性别")
    private String sex;

    @Formula(
            "(select i.name\n"
                    + "from t_dictionary d,\n"
                    + "     t_dictionary_item i\n"
                    + "where d.id = i.dictionary_id\n"
                    + "  and d.code = 'sex'\n"
                    + "  and i.code = sex)")
    private String sexName;

    @Comment("民族")
    private String nation;

    @Formula(
            "(select i.name\n"
                    + "from t_dictionary d,\n"
                    + "     t_dictionary_item i\n"
                    + "where d.id = i.dictionary_id\n"
                    + "  and d.code = 'nation'\n"
                    + "  and i.code = nation)")
    private String nationName;

    @Comment("婚姻状况")
    private String marriage;

    @Formula(
            "(select i.name\n"
                    + "from t_dictionary d,\n"
                    + "     t_dictionary_item i\n"
                    + "where d.id = i.dictionary_id\n"
                    + "  and d.code = 'marriage'\n"
                    + "  and i.code = marriage)")
    private String marriageName;

    @Comment("入职时间")
    private LocalDate entryDate;


    @Comment("离职时间")
    private LocalDate resignDate;

    @Comment("离职原因")
    private String resignReason;


    @Comment("身份证号")
    private String idCard;

    @Comment("学历")
    private String education;

    @Formula(
            "(select i.name\n"
                    + "from t_dictionary d,\n"
                    + "     t_dictionary_item i\n"
                    + "where d.id = i.dictionary_id\n"
                    + "  and d.code = 'education'\n"
                    + "  and i.code = education)")
    private String educationName;

    @Comment("毕业学校")
    private String school;

    @Comment("籍贯")
    private String nativePlace;

    @Comment("住址")
    private String address;

    @Comment("手机号")
    private String phone;

    @ManyToOne
    private FileEntity headImage;

    @Comment("身份证照片")
    @OneToMany
    private List<FileEntity> idImages;

    @Comment("银行卡照片")
    @OneToMany
    private List<FileEntity> bankCardImages;

    @Comment("部门")
    @ManyToOne
    private DepartmentEntity department;

    @Comment("岗位")
    @ManyToOne
    private JobPostEntity jobPost;

    @Comment("银行编码")
    private String bank;

    @Formula(
            "(select i.name\n"
                    + "from t_dictionary d,\n"
                    + "     t_dictionary_item i\n"
                    + "where d.id = i.dictionary_id\n"
                    + "  and d.code = 'bank'\n"
                    + "  and i.code = bank)")
    private String bankName;

    @Comment("银行卡号")
    private String bankCardNumber;

    @Comment("收款人姓名")
    private String bankCardName;

    @Comment("员工状态")
    private String empStatus;

    @Formula(
            "(select i.name\n"
                    + "from t_dictionary d,\n"
                    + "     t_dictionary_item i\n"
                    + "where d.id = i.dictionary_id\n"
                    + "  and d.code = 'emp.status'\n"
                    + "  and i.code = emp_status)")
    private String empStatusName;



    @ElementCollection
    @Comment("家庭成员")
    private List<EmpFamilyMemberVO> familyMembers;


    @ElementCollection
    @Comment("员工证件信息")
    private List<EmpCertVO> certs;



    @ElementCollection
    @Comment("员工车辆信息")
    private List<EmpCarVO> cars;

    /**
     * “五险”讲的是五种保险，包括养老保险、医疗保险、失业保险、工伤保险和生育保险。
     *
     * <p>“一金”指的是住房公积金。
     *
     * <p>其中养老保险、医疗保险和失业保险，这三种险是由企业和个人共同缴纳的保费，工伤保险和生育保险完全是由企业承担的。个人不需要缴纳。这里要注意的是“五险”是法定的，而“一金”不是法定的。
     */
    @Comment("养老保险基数")
    private Double insurance1Base;
    @Comment("养老保险比例")
    private Double insurance1Percent;


    @Comment("医疗保险基数")
    private Double insurance2Base;
    @Comment("医疗保险比例")
    private Double insurance2Percent;



    @Comment("失业保险基数")
    private Double insurance3Base;
    @Comment("失业保险比例")
    private Double insurance3Percent;



    @Comment("工伤保险基数")
    private Double insurance4Base;
    @Comment("工伤保险比例")
    private Double insurance4Percent;



    @Comment("生育保险基数")
    private Double insurance5Base;
    @Comment("生育保险比例")
    private Double insurance5Percent;

    @Comment("住房公积金基数")
    private Double insurance6Base;
    @Comment("住房公积金比例")
    private Double insurance6Percent;




}
