From 60e3a5cf4a1c8f807c3f8f1a127581642c9c5eaa Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 12 Oct 2023 02:56:03 +0700 Subject: [PATCH] add model profile --- Data/MetadataDbContext.cs | 2 + Models/HR/Profile.cs | 326 +++++++++++++++++++++++++++ Models/HR/ProfileSalary.cs | 69 ++++++ Models/Placement/PlacementProfile.cs | 6 + Services/RecruitService.cs | 17 +- 5 files changed, 415 insertions(+), 5 deletions(-) create mode 100644 Models/HR/Profile.cs create mode 100644 Models/HR/ProfileSalary.cs diff --git a/Data/MetadataDbContext.cs b/Data/MetadataDbContext.cs index 7125a17..a4a4842 100644 --- a/Data/MetadataDbContext.cs +++ b/Data/MetadataDbContext.cs @@ -52,5 +52,7 @@ namespace BMA.EHR.Recurit.Service.Data public DbSet Religions { get; set; } public DbSet SubDistricts { get; set; } + public DbSet Profiles { get; set; } + public DbSet ProfileSalaries { get; set; } } } diff --git a/Models/HR/Profile.cs b/Models/HR/Profile.cs new file mode 100644 index 0000000..92757a2 --- /dev/null +++ b/Models/HR/Profile.cs @@ -0,0 +1,326 @@ + +using System.ComponentModel.DataAnnotations; +using BMA.EHR.Recruit.Service.Models; +using Microsoft.EntityFrameworkCore; + +namespace BMA.EHR.Profile.Service.Models.HR +{ + public class Profile : EntityBase + { // [Key] + // public Guid Id { get; set; } + [MaxLength(13), Comment("รหัสบัตรประชาชน")] + public string? CitizenId { get; set; } + [MaxLength(50)] + public string? ProfileType { get; set; } + [MaxLength(20), Comment("ประเภทการจ้าง")] + public string? EmployeeType { get; set; } + [MaxLength(20), Comment("ประเภทลูกจ้าง")] + public string? EmployeeClass { get; set; } + // [Comment("Id คำนำหน้า")] + // public Prefix? Prefix { get; set; } + [Required, MaxLength(100), Comment("ชื่อ")] + public string? FirstName { get; set; } + [Required, MaxLength(100), Comment("นามสกุล")] + public string? LastName { get; set; } + [Comment("Id คำนำหน้า(เดิม)")] + public Guid? PrefixOldId { get; set; } + [Required, MaxLength(100), Comment("ชื่อ(เดิม)")] + public string? FirstNameOld { get; set; } + [Required, MaxLength(100), Comment("นามสกุล(เดิม)")] + public string? LastNameOld { get; set; } + [MaxLength(100)] + public string AvatarRef { get; set; } + // [Comment("Id เพศ")] + // public Gender? Gender { get; set; } + [MaxLength(100), Comment("สัญชาติ")] + public string? Nationality { get; set; } + [MaxLength(100), Comment("เชื้อชาติ")] + public string? Race { get; set; } + [Comment("Id ศาสนา")] + public Guid? ReligionId { get; set; } + [Required, Comment("วันเกิด")] + public DateTime BirthDate { get; set; } + [Comment("Id กลุ่มเลือด")] + public Guid? BloodGroupId { get; set; } + [Comment("Id สถานะภาพ")] + public Guid? RelationshipId { get; set; } + [MaxLength(50), Comment("เบอร์โทร")] + public string? TelephoneNumber { get; set; } + [Comment("คู่สมรส")] + public bool? Couple { get; set; } + [Comment("Id คำนำหน้าคู่สมรส")] + public Guid? CouplePrefixId { get; set; } + [MaxLength(100), Comment("ชื่อคู่สมรส")] + public string? CoupleFirstName { get; set; } + [MaxLength(100), Comment("นามสกุลคู่สมรส")] + public string? CoupleLastName { get; set; } + [MaxLength(100), Comment("นามสกุลคู่สมรส(เดิม)")] + public string? CoupleLastNameOld { get; set; } + [MaxLength(100), Comment("อาชีพคู่สมรส")] + public string? CoupleCareer { get; set; } + [MaxLength(20), Comment("เลขที่บัตรประชาชนคู่สมรส")] + public string? CoupleCitizenId { get; set; } + + [Comment("มีชีวิตคู่สมรส")] + public bool CoupleLive { get; set; } = true; + [Comment("Id คำนำหน้าบิดา")] + public Guid? FatherPrefixId { get; set; } + [MaxLength(100), Comment("ชื่อบิดา")] + public string? FatherFirstName { get; set; } + + [MaxLength(100), Comment("นามสกุลบิดา")] + public string? FatherLastName { get; set; } + + [MaxLength(100), Comment("อาชีพบิดา")] + public string? FatherCareer { get; set; } + [MaxLength(20), Comment("เลขที่บัตรประชาชนบิดา")] + public string? FatherCitizenId { get; set; } + + [Comment("มีชีวิตบิดา")] + public bool FatherLive { get; set; } = true; + [Comment("Id คำนำหน้ามารดา")] + public Guid? MotherPrefixId { get; set; } + + [MaxLength(100), Comment("ชื่อมารดา")] + public string? MotherFirstName { get; set; } + + [MaxLength(100), Comment("นามสกุลมารดา")] + public string? MotherLastName { get; set; } + + [MaxLength(100), Comment("อาชีพมารดา")] + public string? MotherCareer { get; set; } + [MaxLength(20), Comment("เลขที่บัตรประชาชนมารดา")] + public string? MotherCitizenId { get; set; } + + [Comment("มีชีวิตมารดา")] + public bool MotherLive { get; set; } = true; + [MaxLength(200), Comment("ที่อยู่ปัจจุบัน")] + public string? CurrentAddress { get; set; } + [Comment("Id แขวงปัจจุบัน")] + public Guid? CurrentSubDistrictId { get; set; } + [Comment("Id เขตปัจจุบัน")] + public Guid? CurrentDistrictId { get; set; } + [Comment("Id จังหวัดปัจจุบัน")] + public Guid? CurrentProvinceId { get; set; } + [MaxLength(5), Comment("รหัสไปรษณีย์ปัจจุบัน")] + public string? CurrentZipCode { get; set; } + [Comment("ที่อยู่ปัจจุบันตรงกับที่อยู่ตามทะเบียนบ้านหรือไม่")] + public bool? RegistrationSame { get; set; } = false; + [MaxLength(200), Comment("Id แขวงตามทะเบียนบ้าน")] + public string? RegistrationAddress { get; set; } + [Comment("แขวงตามทะเบียนบ้าน")] + public Guid? RegistrationSubDistrictId { get; set; } + [Comment("Id เขตตามทะเบียนบ้าน")] + public Guid? RegistrationDistrictId { get; set; } + [Comment("Id จังหวัดตามทะเบียนบ้าน")] + public Guid? RegistrationProvinceId { get; set; } + [MaxLength(5), Comment("รหัสไปรษณีย์ตามทะเบียนบ้าน")] + public string? RegistrationZipCode { get; set; } + + public DateTime? DateAppoint { get; set; } + + public DateTime? DateStart { get; set; } + + public DateTime? DateRetire { get; set; } + + public string? ReasonSameDate { get; set; } + // public Guid? AffiliationId { get; set; } + // public Guid? PositionId { get; set; } + // public Guid? WorkId { get; set; } + // public Guid? TypeId { get; set; } + // public Guid? LevelId { get; set; } + // public Guid? NumberId { get; set; } + // public Guid? BusinessId { get; set; } + [Comment("Id สังกัด")] + public Guid? OcId { get; set; } + [Comment("สังกัด")] + public string? Oc { get; set; } + public Guid? OrganizationShortNameId { get; set; } + public string? OrganizationShortName { get; set; } + public string? GovernmentCode { get; set; } + public Guid? OrganizationOrganizationId { get; set; } + public string? OrganizationOrganization { get; set; } + // [Comment("Id ตำแหน่ง")] + // public PositionPath? Position { get; set; } + // // [Comment("ตำแหน่ง")] + // // public string? Position { get; set; } + // [Comment("Id เลขที่ตำแหน่ง")] + // public PositionNumberEntity? PosNo { get; set; } + // [Comment("เลขที่ตำแหน่ง")] + // public string? PosNo { get; set; } + [Comment("เลขที่ตำแหน่งลูกจ้าง")] + public string? PosNoEmployee { get; set; } + [Comment("Id สายงาน")] + public Guid? PositionLineId { get; set; } + [Comment("สายงาน")] + public string? PositionLine { get; set; } + [Comment("Id ด้าน/สาขา")] + public Guid? PositionPathSideId { get; set; } + [Comment("ด้าน/สาขา")] + public string? PositionPathSide { get; set; } + // [Comment("Id ประเภทตำแหน่ง")] + // public Guid? PositionTypeId { get; set; } + // [Comment("ประเภทตำแหน่ง")] + // public PositionType? PositionType { get; set; } + // // [Comment(" Id ระดับ")] + // // public Guid? PositionLevelId { get; set; } + // [Comment("ระดับ")] + // public PositionLevel? PositionLevel { get; set; } + [Comment("Id ตำแหน่งทางการบริหาร")] + public Guid? PositionExecutiveId { get; set; } + [Comment("ตำแหน่งทางการบริหาร")] + public string? PositionExecutive { get; set; } + [Comment("Id ด้านทางการบริหาร")] + public Guid? PositionExecutiveSideId { get; set; } + [Comment("ด้านทางการบริหาร")] + public string? PositionExecutiveSide { get; set; } + + // [Comment("Id ตำแหน่ง")] + // public PositionEmployeePosition? PositionEmployeePosition { get; set; } + // // [Comment("ตำแหน่ง")] + // // public string? PositionEmployeePosition { get; set; } + // [Comment("Id ด้านของตำแหน่ง")] + // public PositionEmployeePositionSide? PositionEmployeePositionSide { get; set; } + // // [Comment("ด้านของตำแหน่ง")] + // // public string? PositionEmployeePositionSide { get; set; } + // [Comment(" Id ระดับชั้นงาน")] + // public PositionEmployeeLevel? PositionEmployeeLevel { get; set; } + // // [Comment("ระดับชั้นงาน")] + // // public string? PositionEmployeeLevel { get; set; } + // [Comment("Id กลุ่มงาน")] + // public PositionEmployeeGroup? PositionEmployeeGroup { get; set; } + // // [Comment("กลุ่มงาน")] + // // public string? PositionEmployeeGroup { get; set; } + // [Comment("Id สายงาน")] + // public PositionEmployeeLine? PositionEmployeeLine { get; set; } + // // [Comment("สายงาน")] + // // public string? PositionEmployeeLine { get; set; } + + [MaxLength(100), Comment("สถานภาพทางกาย")] + public string Physical { get; set; } + + [MaxLength(100)] + public string Ability { get; set; } + + public bool IsActive { get; set; } = true; + + public bool IsLeave { get; set; } = false; + + public DateTime? LeaveDate { get; set; } + + [MaxLength(1000)] + public string? LeaveReason { get; set; } + public string? LeaveDetail { get; set; } + public string? LeaveNumberOrder { get; set; } + public DateTime? LeaveDateOrder { get; set; } + + public DateTime? CreatedDate { get; set; } + + public DateTime? ModifiedDate { get; set; } + + [MaxLength(250)] + public string CreatedUser { get; set; } = string.Empty; + + [MaxLength(5)] + public string EntryStatus { get; set; } = "st1"; // สถานะการตรวจสอบ st1 = create; st2 = pending + + public bool IsTransfer { get; set; } = false; + + public DateTime? TransferDate { get; set; } + + public int GovAgeAbsent { get; set; } = 0; + + public int GovAgePlus { get; set; } = 0; + + // public OrganizationEntity? Organization { get; set; } + + // public PositionNumberEntity PositionNumber { get; set; } + + // public Position Position { get; set; } + + // public PositionExecutive PositionExecutive { get; set; } + + public bool IsVerified { get; set; } = false; + + [MaxLength(100)] + public string VerifiedUser { get; set; } = string.Empty; + + public DateTime? VerifiedDate { get; set; } + + // public Document? Avatar { get; set; } + + public bool IsProbation { get; set; } = true; + + // public PositionType PositionType { get; set; } // ประเภทตำแหน่ง + + // public PositionLevel PositionLevel { get; set; } // ระดับ + + // public OrganizationPositionEntity? OrganizationPosition { get; set; } + // public LimitLeave? LimitLeave { get; set; } + public Guid? KeycloakId { get; set; } + [Comment("สังกัด")] + public string? EmployeeOc { get; set; } + [Comment("ค่าจ้าง")] + public double? EmployeeWage { get; set; } + [Comment("ประเภทบุคคล")] + public string? EmployeeTypeIndividual { get; set; } + [Comment("เงินเพิ่มการครองชีพชั่วคราว")] + public double? EmployeeMoneyIncrease { get; set; } + [Comment("เงินช่วยเหลือค่าครองชีพชั่วคราว")] + public double? EmployeeMoneyAllowance { get; set; } + [Comment("เงินสมทบประกันสังคม(ลูกจ้าง)")] + public double? EmployeeMoneyEmployee { get; set; } + [Comment("เงินสมทบประกันสังคม(นายจ้าง)")] + public double? EmployeeMoneyEmployer { get; set; } + + // public virtual List Educations { get; set; } = new List(); + + // public virtual List Honors { get; set; } = new List(); + // public virtual List Assessments { get; set; } = new List(); + + // public virtual List Disciplines { get; set; } = new List(); + + // public virtual List Certificates { get; set; } = new List(); + + // public virtual List Trainings { get; set; } = new List(); + + // public virtual List Insignias { get; set; } = new List(); + + public virtual List Salaries { get; set; } = new List(); + + // public virtual List ProfileHistory { get; set; } = new List(); + + // public virtual List CoupleHistory { get; set; } = new List(); + + // public virtual List FatherHistory { get; set; } = new List(); + + // public virtual List MotherHistory { get; set; } = new List(); + + // public virtual List FamilyHistory { get; set; } = new List(); + + // public virtual List GovernmentHistory { get; set; } = new List(); + + // public virtual List Leaves { get; set; } = new List(); + + // public virtual List CurrentAddressHistory { get; set; } = new List(); + + // public virtual List RegistrationAddressHistory { get; set; } = new List(); + + // public virtual List AddressHistory { get; set; } = new List(); + + // public virtual List Others { get; set; } = new List(); + + // public virtual List Abilitys { get; set; } = new List(); + + // public virtual List Dutys { get; set; } = new List(); + + // public virtual List Nopaids { get; set; } = new List(); + + // public virtual List AvatarHistory { get; set; } = new List(); + + // public virtual List Papers { get; set; } = new List(); + + // public virtual List Childrens { get; set; } = new List(); + // public virtual List ChangeNames { get; set; } = new List(); + } +} diff --git a/Models/HR/ProfileSalary.cs b/Models/HR/ProfileSalary.cs new file mode 100644 index 0000000..6fdf441 --- /dev/null +++ b/Models/HR/ProfileSalary.cs @@ -0,0 +1,69 @@ + +using BMA.EHR.Recruit.Service.Models; +using System.ComponentModel.DataAnnotations; +using Microsoft.EntityFrameworkCore; + +namespace BMA.EHR.Profile.Service.Models.HR +{ + public class ProfileSalary : EntityBase + { + [Comment("วัน เดือน ปี รับตำแหน่ง")] + public DateTime? Date { get; set; } + [Comment("ลำดับ")] + public int? Order { get; set; } + [Comment("เงินเดือน")] + public double? Amount { get; set; } + [Comment("เงินประจำตำแหน่ง")] + public double? PositionSalaryAmount { get; set; } + [Comment("เงินค่าตอบแทนรายเดือน")] + public double? MouthSalaryAmount { get; set; } + [Comment("Id สังกัด")] + public Guid? OcId { get; set; } + [Comment("Id ชื่อย่อหน่วยงาน")] + public Guid? OrganizationShortNameId { get; set; } + [Comment("Id ตำแหน่ง")] + public Guid? PositionId { get; set; } + [Comment("Id เลขที่ตำแหน่ง")] + public Guid? PosNoId { get; set; } + [Comment("เลขที่ตำแหน่งลูกจ้าง")] + public string? PosNoEmployee { get; set; } + [Comment("Id สายงาน")] + public Guid? PositionLineId { get; set; } + [Comment("Id ด้าน/สาขา")] + public Guid? PositionPathSideId { get; set; } + [Comment("Id ประเภทตำแหน่ง")] + public Guid? PositionTypeId { get; set; } + // [Comment("Id ระดับ")] + // public PositionLevel? PositionLevel { get; set; } + [Comment("Id ตำแหน่งทางการบริหาร")] + public Guid? PositionExecutiveId { get; set; } + [Comment("Id ด้านทางการบริหาร")] + public Guid? PositionExecutiveSideId { get; set; } + [Comment("Id ตำแหน่ง")] + public Guid? PositionEmployeePositionId { get; set; } + [Comment("Id ด้านของตำแหน่ง")] + public Guid? PositionEmployeePositionSideId { get; set; } + [Comment(" Id ระดับชั้นงาน")] + public Guid? PositionEmployeeLevelId { get; set; } + [Comment("Id กลุ่มงาน")] + public Guid? PositionEmployeeGroupId { get; set; } + + [Comment("ตำแหน่ง (รายละเอียด)")] + public string? SalaryClass { get; set; } + + [Comment("เอกสารอ้างอิง")] + public string? SalaryRef { get; set; } + // public virtual List ProfileSalaryHistorys { get; set; } = new List(); + public virtual Profile? Profile { get; set; } + + [Comment("เลขที่คำสั่ง")] + public string CommandNo { get; set; } + + [Comment("ประเภทคำสั่ง")] + public string CommandTypeName { get; set; } + + [Comment("ประเภทตำแหน่งกรณีพิเศษ")] + public string? SalaryStatus { get; set; } + public bool IsActive { get; set; } = true; + } +} diff --git a/Models/Placement/PlacementProfile.cs b/Models/Placement/PlacementProfile.cs index 77d91c2..33b981c 100644 --- a/Models/Placement/PlacementProfile.cs +++ b/Models/Placement/PlacementProfile.cs @@ -240,6 +240,12 @@ namespace BMA.EHR.Domain.Models.Placement [Comment("Id รูปโปรไฟล์")] public virtual Document? ProfileImg { get; set; } + + [Comment("หมายเหตุแนวตั้ง")] + public string? RemarkVertical { get; set; } + + [Comment("หมายเหตุแนวนอน")] + public string? RemarkHorizontal { get; set; } public virtual List PlacementCertificates { get; set; } = new List(); public virtual List PlacementEducations { get; set; } = new List(); } diff --git a/Services/RecruitService.cs b/Services/RecruitService.cs index dd47857..07aca11 100644 --- a/Services/RecruitService.cs +++ b/Services/RecruitService.cs @@ -221,6 +221,9 @@ namespace BMA.EHR.Recruit.Service.Services .FirstOrDefaultAsync(x => x.ExamId == candidate.ExamId && x.ScoreImport == scoreImport); if (recruitScore == null) continue; + var profile = await _contextMetadata.Profiles + .Include(x => x.Salaries) + .FirstOrDefaultAsync(p => p.CitizenId == candidate.CitizenId); var placementProfile = new PlacementProfile { Placement = placement, @@ -244,14 +247,14 @@ namespace BMA.EHR.Recruit.Service.Services // Knowledge = candidate.Knowledge, RegistAddress = $"{Address}{Moo}{Soi}{Road}", RegistProvince = candidate.Addresses.FirstOrDefault() == null ? null : await _contextMetadata.Provinces.FirstOrDefaultAsync(x => x.Name == candidate.Addresses.FirstOrDefault().Province), - RegistDistrict = candidate.Addresses.FirstOrDefault() == null ? null : await _contextMetadata.Districts.FirstOrDefaultAsync(x => x.Name == candidate.Addresses.FirstOrDefault().District), - RegistSubDistrict = candidate.Addresses.FirstOrDefault() == null ? null : await _contextMetadata.SubDistricts.FirstOrDefaultAsync(x => x.Name == candidate.Addresses.FirstOrDefault().Amphur), + RegistDistrict = candidate.Addresses.FirstOrDefault() == null ? null : await _contextMetadata.Districts.FirstOrDefaultAsync(x => x.Name == candidate.Addresses.FirstOrDefault().District && x.Province.Name == candidate.Addresses.FirstOrDefault().Province), + RegistSubDistrict = candidate.Addresses.FirstOrDefault() == null ? null : await _contextMetadata.SubDistricts.FirstOrDefaultAsync(x => x.Name == candidate.Addresses.FirstOrDefault().Amphur && x.District.Name == candidate.Addresses.FirstOrDefault().District && x.District.Province.Name == candidate.Addresses.FirstOrDefault().Province), RegistZipCode = candidate.Addresses.FirstOrDefault() == null ? null : candidate.Addresses.FirstOrDefault().ZipCode, RegistSame = false, CurrentAddress = $"{Address1}{Moo1}{Soi1}{Road1}", - CurrentProvince = candidate.Addresses.FirstOrDefault() == null ? null : await _contextMetadata.Provinces.FirstOrDefaultAsync(x => x.Name == candidate.Addresses.FirstOrDefault().Province1), - CurrentDistrict = candidate.Addresses.FirstOrDefault() == null ? null : await _contextMetadata.Districts.FirstOrDefaultAsync(x => x.Name == candidate.Addresses.FirstOrDefault().District1), - CurrentSubDistrict = candidate.Addresses.FirstOrDefault() == null ? null : await _contextMetadata.SubDistricts.FirstOrDefaultAsync(x => x.Name == candidate.Addresses.FirstOrDefault().Amphur1), + CurrentProvince = candidate.Addresses.FirstOrDefault() == null ? null : await _contextMetadata.Provinces.FirstOrDefaultAsync(x => x.Name == candidate.Addresses.FirstOrDefault().Moo1), + CurrentDistrict = candidate.Addresses.FirstOrDefault() == null ? null : await _contextMetadata.Districts.FirstOrDefaultAsync(x => x.Name == candidate.Addresses.FirstOrDefault().District1 && x.Province.Name == candidate.Addresses.FirstOrDefault().Moo1), + CurrentSubDistrict = candidate.Addresses.FirstOrDefault() == null ? null : await _contextMetadata.SubDistricts.FirstOrDefaultAsync(x => x.Name == candidate.Addresses.FirstOrDefault().Amphur1 && x.District.Name == candidate.Addresses.FirstOrDefault().District1 && x.District.Province.Name == candidate.Addresses.FirstOrDefault().Moo1), CurrentZipCode = candidate.Addresses.FirstOrDefault() == null ? null : candidate.Addresses.FirstOrDefault().ZipCode1, Marry = candidate.Marry.Contains("สมรส"), // MarryPrefix = await _contextMetadata.Prefixes.FirstOrDefaultAsync(x => x.Id == candidate.MarryPrefixId), @@ -288,6 +291,10 @@ namespace BMA.EHR.Recruit.Service.Services PlacementStatus = "UN-CONTAIN", Pass = recruitScore == null ? null : recruitScore.ExamStatus, // ReportingDate = DateTime.Now, + RemarkHorizontal = "โดยมีเงื่อนไขว่าต้องปฏิบัติงานให้กรุงเทพมหานครเป็นระยะเวลาไม่น้อยกว่า ๕ ปี นับแต่วันที่ได้รับการบรรจุและแต่งตั้ง โดยห้ามโอนไปหน่วยงานหรือส่วนราชการอื่น เว้นเเต่ลาออกจากราชการ", + Amount = profile == null || profile.Salaries.Count() == 0 ? 0 : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount, + PositionSalaryAmount = profile == null || profile.Salaries.Count() == 0 ? 0 : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount, + MouthSalaryAmount = profile == null || profile.Salaries.Count() == 0 ? 0 : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().MouthSalaryAmount, CreatedAt = DateTime.Now, CreatedUserId = UserId ?? "", CreatedFullName = FullName ?? "",