import { Entity, Column, OneToMany, ManyToOne, Double, ManyToMany, JoinTable } from "typeorm"; import { EntityBase } from "./base/Base"; import { EmployeePosLevel } from "./EmployeePosLevel"; import { EmployeePosType } from "./EmployeePosType"; import { EmployeePosMaster } from "./EmployeePosMaster"; import { ProfileSalary } from "./ProfileSalary"; import { ProfileCertificate } from "./ProfileCertificate"; import { ProfileTraining } from "./ProfileTraining"; import { ProfileInsignia } from "./ProfileInsignia"; import { ProfileHonor } from "./ProfileHonor"; import { ProfileAssessment } from "./ProfileAssessment"; import { ProfileLeave } from "./ProfileLeave"; import { ProfileDuty } from "./ProfileDuty"; import { ProfileNopaid } from "./ProfileNopaid"; import { ProfileDiscipline } from "./ProfileDiscipline"; import { ProfileChangeName } from "./ProfileChangeName"; import { ProfileFamilyHistory } from "./ProfileFamily"; import { ProfileEducation } from "./ProfileEducation"; import { ProfileAbility } from "./ProfileAbility"; import { ProfileOther } from "./ProfileOther"; import { ProfileAvatar } from "./ProfileAvatar"; import { ProfileGovernment } from "./ProfileGovernment"; import { ProfileFamilyFather } from "./ProfileFamilyFather"; import { ProfileFamilyMother } from "./ProfileFamilyMother"; import { ProfileFamilyCouple } from "./ProfileFamilyCouple"; import { ProfileChildren } from "./ProfileChildren"; import { ProfileAddressHistory } from "./Profile"; import { Province } from "./Province"; import { District } from "./District"; import { SubDistrict } from "./SubDistrict"; import { ProfileEmployeeInformationHistory } from "./ProfileEmployeeInformationHistory"; import { ProfileEmployeeEmployment } from "./ProfileEmployeeEmployment"; import { ProfileEdit } from "./ProfileEdit"; import { ProfileDevelopment } from "./ProfileDevelopment"; import { DevelopmentRequest } from "./DevelopmentRequest"; import { RoleKeycloak } from "./RoleKeycloak"; import { StateOperatorUser } from "./StateOperatorUser"; @Entity("profileEmployee") export class ProfileEmployee extends EntityBase { @Column({ nullable: true, comment: "รูปถ่าย", default: null, }) avatar: string; @Column({ nullable: true, comment: "รูปถ่าย", default: null, }) avatarName: string; @Column({ nullable: true, type: "datetime", comment: "วันที่บรรจุ", default: null, }) dateAppoint: Date; @Column({ nullable: true, type: "datetime", comment: "วันที่เริ่มปฏิบัติราชการ", default: null, }) dateStart: Date; @Column({ nullable: true, comment: "ขาดราชการ", default: null, }) govAgeAbsent: number; @Column({ nullable: true, comment: "อายุราชการเกื้อกูล", default: null, }) govAgePlus: number; @Column({ nullable: true, comment: "เหตุผลกรณีวันไม่ตรงกัน", length: 255, default: null, }) reasonSameDate: string; @Column({ nullable: true, comment: "ประเภทลูกจ้าง (perm->ลูกจ้างประจำ temp->ลูกจ้างชั่วคราว)", length: 40, default: null, }) employeeClass: string; @Column({ nullable: true, comment: "ยศ", length: 40, default: null, }) rank: string; @Column({ nullable: true, comment: "คำนำหน้าชื่อ", length: 40, default: null, }) prefix: string; @Column({ nullable: true, comment: "คำนำหน้าชื่อตัวหลัก", length: 40, default: null, }) prefixMain: string; @Column({ nullable: true, comment: "ชื่อ", length: 255, default: null, }) firstName: string; @Column({ nullable: true, comment: "นามสกุล", length: 255, default: null, }) lastName: string; @Column({ nullable: true, comment: "เลขประจำตัวประชาชน", default: null, length: 13, }) citizenId: string; @Column({ nullable: true, comment: "ตำแหน่ง", default: null, length: 255, }) position: string; @Column({ nullable: true, length: 40, comment: "ไอดีระดับตำแหน่ง", }) posLevelId: string | null; @Column({ nullable: true, length: 40, comment: "ไอดีกลุ่มงานตำแหน่ง", }) posTypeId: string | null; @Column({ nullable: true, length: 255, comment: "อีเมล", }) email: string; @Column({ nullable: true, length: 20, comment: "เบอร์โทร", }) phone: string; @Column({ nullable: true, comment: "id keycloak", length: 40, default: null, }) keycloak: string; @Column({ comment: "ทดลองปฏิบัติหน้าที่", default: false, }) isProbation: boolean; @Column({ comment: "พ้นราชการ", default: false, }) isLeave: boolean; @Column({ comment: "เกษียณ", default: false, }) isRetirement: boolean; @Column({ comment: "สถานะการใช้งาน", default: true, }) isActive: boolean; @Column({ nullable: true, comment: "เหตุผลเกษียณ", default: null, }) leaveReason: string; @Column({ nullable: true, type: "datetime", comment: "วันพ้นราชการ", default: null, }) dateLeave: Date; @Column({ nullable: true, type: "datetime", comment: "วันครบเกษียณอายุ", default: null, }) dateRetire: Date; @Column({ nullable: true, type: "datetime", comment: "วันเกิด", default: null, }) birthDate: Date; @Column({ nullable: true, type: "datetime", comment: "วันที่เกษียณอายุราชการตามกฏหมาย", default: null, }) dateRetireLaw: Date; @Column({ type: "double", nullable: true, comment: "ขั้นเงินเดือน", default: null, }) salaryLevel: number | null; @Column({ nullable: true, comment: "กลุ่มบัญชีการจ้าง", default: null, }) group: number; @Column({ nullable: true, comment: "เชื้อชาติ", length: 255, default: null, }) ethnicity: string; @Column({ nullable: true, comment: "เบอร์โทร", length: 255, default: null, }) telephoneNumber: string; @Column({ nullable: true, comment: "สัญชาติ", length: 255, default: null, }) nationality: string; @Column({ nullable: true, comment: "เพศ", length: 40, default: null, }) gender: string; @Column({ nullable: true, comment: "ความสัมพันธ์", length: 40, default: null, }) relationship: string; @Column({ nullable: true, comment: "ศาสนา", length: 255, default: null, }) religion: string; @Column({ nullable: true, comment: "กรุ๊ปเลือด", length: 40, default: null, }) bloodGroup: string; @Column({ nullable: true, comment: "id อัตรา", default: null, }) posmasterIdTemp: string; @Column({ nullable: true, comment: "node", default: null, }) nodeTemp: string; @Column({ nullable: true, comment: "id node", default: null, }) nodeIdTemp: string; @Column({ nullable: true, comment: "id Revision", default: null, }) orgRevisionIdTemp: string; @Column({ nullable: true, comment: "id position", default: null, }) positionIdTemp: string; @Column({ nullable: true, comment: "เลขที่ตำแหน่ง", default: null, }) posMasterNoTemp: string; @Column({ nullable: true, comment: "ตำแหน่ง", default: null, }) positionTemp: string; @Column({ nullable: true, comment: "ตำแหน่ง", default: null, }) positionFieldTemp: string; @Column({ nullable: true, comment: "id ประเภท", default: null, }) posTypeIdTemp: string; @Column({ nullable: true, comment: "ประเภท", default: null, }) posTypeNameTemp: string; @Column({ nullable: true, comment: "id ระดับ", default: null, }) posLevelIdTemp: string; @Column({ nullable: true, comment: "ระดับ", default: null, }) posLevelNameTemp: string; @Column({ nullable: true, comment: "ชื่อ root", default: null, }) rootTemp: string; @Column({ nullable: true, comment: "id root", default: null, }) rootIdTemp: string; @Column({ nullable: true, comment: "ชื่อย่อ root", default: null, }) rootShortNameTemp: string; @Column({ nullable: true, comment: "ชื่อ child1", default: null, }) child1Temp: string; @Column({ nullable: true, comment: "id child1", default: null, }) child1IdTemp: string; @Column({ nullable: true, comment: "ชื่อย่อ child1", default: null, }) child1ShortNameTemp: string; @Column({ nullable: true, comment: "ชื่อ child2", default: null, }) child2Temp: string; @Column({ nullable: true, comment: "id child2", default: null, }) child2IdTemp: string; @Column({ nullable: true, comment: "ชื่อย่อ child2", default: null, }) child2ShortNameTemp: string; @Column({ nullable: true, comment: "ชื่อ child3", default: null, }) child3Temp: string; @Column({ nullable: true, comment: "id child3", default: null, }) child3IdTemp: string; @Column({ nullable: true, comment: "ชื่อย่อ child3", default: null, }) child3ShortNameTemp: string; @Column({ nullable: true, comment: "ชื่อ child4", default: null, }) child4Temp: string; @Column({ nullable: true, comment: "id child4", default: null, }) child4IdTemp: string; @Column({ nullable: true, comment: "ชื่อย่อ child4", default: null, }) child4ShortNameTemp: string; @Column({ nullable: true, comment: "สถานะลูกจ้างชั่วคราว", default: null, }) statusTemp: string; @Column({ nullable: true, comment: "กลุ่มงาน", default: null, }) positionEmployeeGroupId: string; @Column({ nullable: true, comment: "สายงาน", default: null, }) positionEmployeeLineId: string; @Column({ nullable: true, comment: "ชื่อตำแหน่งทางสายงาน", default: null, }) positionEmployeePositionId: string; @Column({ nullable: true, comment: "สังกัด", default: null, }) employeeOc: string; @Column({ nullable: true, comment: "ประเภทบุคคล", default: null, }) employeeTypeIndividual: string; @Column({ nullable: true, comment: "ค่าจ้าง", default: null, }) employeeWage: string; @Column({ nullable: true, comment: "เงินเพิ่มการครองชีพชั่วคราว", default: null, }) employeeMoneyIncrease: string; @Column({ nullable: true, comment: "เงินช่วยเหลือการครองชีพชั่วคราว", default: null, }) employeeMoneyAllowance: string; @Column({ nullable: true, comment: "เงินสมทบประกันสังคม(ลูกจ้าง)", default: null, }) employeeMoneyEmployee: string; @Column({ nullable: true, comment: "เงินสมทบประกันสังคม(นายจ้าง)", default: null, }) employeeMoneyEmployer: string; @Column({ comment: "เงินเดือนฐาน", default: 0, nullable: true, type: "double", }) amount: Double; @Column({ comment: "เงินพิเศษ", default: 0, nullable: true, type: "double", }) amountSpecial: Double; @Column({ comment: "เงินประจำตำแหน่ง", default: 0, nullable: true, type: "double", }) positionSalaryAmount: Double; @Column({ comment: "เงินค่าตอบแทนรายเดือน", default: 0, nullable: true, type: "double", }) mouthSalaryAmount: Double; @Column({ nullable: true, length: 40, comment: "ไอดีคำสั่งพ้นจากราชการ", default: null, }) leaveCommandId: string; @Column({ nullable: true, length: 255, comment: "เลขที่คำสั่งพ้นจากราชการ", default: null, }) leaveCommandNo: string; @Column({ nullable: true, comment: "หมายเหตุแนวตั้งคำสั่งพ้นจากราชการ", type: "text", default: null, }) leaveRemark: string; @Column({ nullable: true, type: "datetime", comment: "วันที่ลงนามคำสั่งพ้นจากราชการ", default: null, }) leaveDate: Date | null; @Column({ nullable: true, type: "text", comment: "ประเภทพ้นคำสั่งพ้นจากราชการ", default: null, }) leaveType: string; @OneToMany(() => ProfileEmployeeInformationHistory, (v) => v.profileEmployeeInformation) information_histories: ProfileEmployeeInformationHistory[]; @OneToMany(() => ProfileEmployeeEmployment, (v) => v.profileEmployee) profileEmployeeEmployment: ProfileEmployeeEmployment[]; @OneToMany(() => EmployeePosMaster, (v) => v.current_holder) current_holders: EmployeePosMaster[]; @OneToMany(() => EmployeePosMaster, (v) => v.next_holder) next_holders: EmployeePosMaster[]; @OneToMany(() => ProfileSalary, (v) => v.profileEmployee) profileSalary: ProfileSalary[]; @OneToMany(() => ProfileCertificate, (v) => v.profileEmployee) profileCertificates: ProfileCertificate[]; @OneToMany(() => ProfileTraining, (v) => v.profileEmployee) profileTrainings: ProfileTraining[]; @OneToMany(() => ProfileInsignia, (v) => v.profileEmployee) profileInsignias: ProfileInsignia[]; @OneToMany(() => ProfileHonor, (v) => v.profileEmployee) profileHonors: ProfileHonor[]; @OneToMany(() => ProfileAssessment, (v) => v.profileEmployee) profileAssessments: ProfileAssessment[]; @OneToMany(() => ProfileLeave, (v) => v.profileEmployee) profileLeaves: ProfileLeave[]; @OneToMany(() => ProfileDuty, (v) => v.profileEmployee) profileDutys: ProfileDuty[]; @OneToMany(() => ProfileNopaid, (v) => v.profileEmployee) profileNopaids: ProfileNopaid[]; @OneToMany(() => ProfileDiscipline, (v) => v.profileEmployee) profileDisciplines: ProfileDiscipline[]; @OneToMany(() => ProfileChangeName, (v) => v.profileEmployee) profileChangeNames: ProfileChangeName[]; @OneToMany(() => ProfileFamilyHistory, (v) => v.profileEmployee) profileFamilys: ProfileFamilyHistory[]; @OneToMany(() => ProfileChildren, (v) => v.profileEmployee) profileChildrens: ProfileChildren[]; @OneToMany(() => ProfileEducation, (v) => v.profileEmployee) profileEducations: ProfileEducation[]; @OneToMany(() => ProfileAbility, (v) => v.profileEmployee) profileAbilities: ProfileAbility[]; @OneToMany(() => ProfileOther, (v) => v.profileEmployee) profileOthers: ProfileOther[]; @OneToMany(() => ProfileDevelopment, (v) => v.profileEmployee) profileDevelopments: ProfileDevelopment[]; @OneToMany(() => DevelopmentRequest, (v) => v.profileEmployee) developmentRequests: DevelopmentRequest[]; @OneToMany(() => ProfileAvatar, (v) => v.profileEmployee) profileAvatars: ProfileAvatar[]; @OneToMany(() => ProfileEdit, (v) => v.profileEmployee) profileEdits: ProfileEdit[]; @ManyToOne(() => EmployeePosLevel, (v) => v.profiles) posLevel: EmployeePosLevel; @ManyToOne(() => EmployeePosType, (v) => v.profiles) posType: EmployeePosType; @OneToMany(() => ProfileEmployeeHistory, (v) => v.profileEmployee) histories: ProfileEmployeeHistory[]; @OneToMany(() => ProfileAddressHistory, (v) => v.profileEmployee) profileAddressHistories: ProfileAddressHistory[]; @OneToMany(() => ProfileGovernment, (v) => v.profileEmployee) profileGovernment: ProfileGovernment[]; @OneToMany(() => ProfileFamilyFather, (v) => v.profile) profileFamilyFather: ProfileFamilyFather[]; @OneToMany(() => ProfileFamilyMother, (v) => v.profile) profileFamilyMother: ProfileFamilyMother[]; @OneToMany(() => ProfileFamilyCouple, (v) => v.profile) profileFamilyCouple: ProfileFamilyCouple[]; @OneToMany(() => StateOperatorUser, (v) => v.profile) stateOperatorUsers: StateOperatorUser[]; //ที่อยู่ @Column({ nullable: true, comment: "ที่อยู่ตามทะเบียนบ้าน", default: null, length: 255, }) registrationAddress: string; @Column({ nullable: true, comment: "จังหวัดตามทะเบียนบ้าน", length: 255, default: null, }) registrationProvinceId: string; @ManyToOne(() => Province, (v) => v.registrationProvinces) registrationProvince: Province; @Column({ nullable: true, comment: "เขตตามทะเบียนบ้าน", length: 255, default: null, }) registrationDistrictId: string; @ManyToOne(() => District, (v) => v.registrationDistricts) registrationDistrict: District; @Column({ nullable: true, comment: "แขวงตามทะเบียนบ้าน", length: 255, default: null, }) registrationSubDistrictId: string; @ManyToOne(() => SubDistrict, (v) => v.registrationSubDistricts) registrationSubDistrict: SubDistrict; @Column({ nullable: true, comment: "รหัสไปรษณีย์ตามทะเบียนบ้าน", default: null, length: 5, }) registrationZipCode: string; @Column({ nullable: true, comment: "ที่อยู่ตามปัจจุบัน", default: null, length: 255, }) currentAddress: string; @Column({ nullable: true, comment: "จังหวัดตามปัจจุบัน", length: 255, default: null, }) currentProvinceId: string; @ManyToOne(() => Province, (v) => v.currentProvinces) currentProvince: Province; @Column({ nullable: true, comment: "เขตตามปัจจุบัน", length: 255, default: null, }) currentDistrictId: string; @ManyToOne(() => District, (v) => v.currentDistricts) currentDistrict: District; @Column({ nullable: true, comment: "แขวงตามปัจจุบัน", length: 255, default: null, }) currentSubDistrictId: string; @ManyToOne(() => SubDistrict, (v) => v.currentSubDistricts) currentSubDistrict: SubDistrict; @Column({ nullable: true, comment: "รหัสไปรษณีย์ตามปัจจุบัน", default: null, length: 5, }) currentZipCode: string; @Column({ nullable: true, length: 40, comment: "ไอดีรอบลงเวลาล่าสุด", }) dutyTimeId: string; @Column({ nullable: true, type: "datetime", comment: "รอบลงเวลาล่าสุด", default: null, }) dutyTimeEffectiveDate: Date; @ManyToMany(() => RoleKeycloak, (roleKeycloak) => roleKeycloak.profileEmployees) @JoinTable() roleKeycloaks: RoleKeycloak[]; } @Entity("profileEmployeeHistory") export class ProfileEmployeeHistory extends ProfileEmployee { @Column({ nullable: true, length: 40, comment: "คีย์นอก(FK)ของตาราง ProfileInformation", default: null, }) profileEmployeeId: string; @ManyToOne(() => ProfileEmployee, (v) => v.histories, { onDelete: "CASCADE" }) profileEmployee: ProfileEmployee; } export class CreateProfileEmployee { prefix: string; prefixMain?: string; rank?: string | null; firstName: string; lastName: string; citizenId: string; birthDate?: Date | null; position?: string | null; posLevelId?: string | null; posTypeId?: string | null; gender?: string | null; relationship?: string | null; nationality?: string | null; ethnicity?: string | null; religion?: string | null; bloodGroup?: string | null; phone?: string | null; salaryLevel?: number | null; employeeClass?: string | null; } export class UpdateInformationProfileEmployee { positionEmployeeGroupId: string | null; positionEmployeeLineId: string | null; positionEmployeePositionId: string | null; employeeOc?: string | null; employeeTypeIndividual?: string | null; employeeWage?: string | null; employeeMoneyIncrease?: string | null; employeeMoneyAllowance?: string | null; employeeMoneyEmployee?: string | null; employeeMoneyEmployer?: string | null; } export type UpdateProfileEmployee = { prefix: string; rank?: string | null; firstName: string; lastName: string; citizenId: string; birthDate?: Date | null; position?: string | null; posLevelId?: string | null; posTypeId?: string | null; gender?: string | null; relationship?: string | null; nationality?: string | null; ethnicity?: string | null; religion?: string | null; bloodGroup?: string | null; phone?: string | null; salaryLevel?: number | null; employeeClass?: string | null; prefixMain?: string | null; }; export type UpdateProfileAddressEmployee = { registrationAddress?: string | null; registrationProvinceId?: string | null; registrationDistrictId?: string | null; registrationSubDistrictId?: string | null; registrationZipCode?: string | null; currentAddress?: string | null; currentProvinceId?: string | null; currentDistrictId?: string | null; currentSubDistrictId?: string | null; currentZipCode?: string | null; }; export type UpdatePositionTempProfileEmployee = { posmasterId: string; node: number; nodeId: string; orgRevisionId: string; positionId: string; posMasterNo: string; position: string; positionField: string; posTypeId: string | null; posTypeName: string; posLevelId: string | null; posLevelName: string; };