diff --git a/BMA.EHR.Application/Repositories/Reports/CandidateReportRepository.cs b/BMA.EHR.Application/Repositories/Reports/CandidateReportRepository.cs index 218c16a0..ae6568d6 100644 --- a/BMA.EHR.Application/Repositories/Reports/CandidateReportRepository.cs +++ b/BMA.EHR.Application/Repositories/Reports/CandidateReportRepository.cs @@ -83,84 +83,114 @@ namespace BMA.EHR.Application.Repositories.Reports sb.Append(monthDiff == 0 ? "" : $"{monthDiff} เดือน "); sb.Append(dayDiff == 0 ? "" : $"{dayDiff} วัน "); } - var data = await _dbExamContext.Set().AsQueryable() - .Where(x => x.Id == id) - .Select(p => new - { - p.Id, - AvatarId = p.ProfileImg == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.ProfileImg.Id, - ExamIdenNumber = p.ExamIdenNumber == null ? "-" : p.ExamIdenNumber, - PositionName = p.PositionExam == null ? "-" : p.PositionExam.PositionName, - PositionLevelName = p.PositionExam == null ? "-" : p.PositionExam.PositionLevelName, - PeriodExamName = p.PeriodExam == null ? "-" : p.PeriodExam.Name, - PeriodExamRound = p.PeriodExam == null ? "-" : p.PeriodExam.Round.ToString(), - PeriodExamYear = p.PeriodExam == null ? "-" : (p.PeriodExam.Year + 543).ToString(), + var candidate = await _dbExamContext.Set() + .Where(x => x.Id == id) + .Include(p => p.PeriodExam) + .Include(p => p.Educations) + .Include(p => p.PositionExam) + .Include(p => p.ProfileImg) + .FirstOrDefaultAsync(); - FullName = $"{p.PrefixName}{p.FirstName} {p.LastName}", - Religion = p.ReligionName == null ? "-" : p.ReligionName, - Nationality = p.Nationality == null ? "-" : p.Nationality, - DateOfBirth = p.DateOfBirth == null ? "-" : p.DateOfBirth.Value.ToThaiFullDate2(), - Age = p.DateOfBirth == null ? "-" : p.DateOfBirth.Value.CalculateAgeStrV2(0, 0), - CitizenId = p.CitizenId == null ? "-" : p.CitizenId, - - EducationLevelExamName = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationLevelExamName, - EducationName = p.Educations.FirstOrDefault() == null ? null : (p.Educations.FirstOrDefault().EducationLevelExamName == "ปริญญาตรี" || p.Educations.FirstOrDefault().EducationLevelExamName == "ปริญญาโท" || p.Educations.FirstOrDefault().EducationLevelExamName == "ปริญญาเอก" ? p.Educations.FirstOrDefault().EducationName : null), - EducationMajor = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationMajor, - EducationLocation = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationLocation, - EducationEndDate = p.Educations.FirstOrDefault() == null || p.Educations.FirstOrDefault().EducationEndDate == null ? "-" : p.Educations.FirstOrDefault().EducationEndDate.Value.ToThaiFullDate2(), - EducationScores = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationScores, - EducationType = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationType, - EducationLevelHighName = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationLevelHighName, - - OccupationPositionType = p.OccupationPositionType == "other" ? "ผู้ปฏิบัติงานอื่นในกรุงเทพมหานคร" : (p.OccupationPositionType == "temp" ? "ลูกจ้างชั่วคราว" : (p.OccupationPositionType == "prem" ? "ลูกจ้างประจำ" : "-")), - OccupationPosition = p.OccupationPosition == null ? "-" : p.OccupationPosition, - OccupationSalary = p.OccupationSalary == null ? "-" : (p.OccupationSalary.Value % 1 == 0 ? p.OccupationSalary.Value.ToString("N0") : p.OccupationSalary.Value.ToString("N2")), - OccupationGroup = p.OccupationGroup == null ? "-" : p.OccupationGroup, - OccupationPile = p.OccupationPile == null ? "-" : p.OccupationPile, - OccupationOrg = p.OccupationOrg == null ? "-" : p.OccupationOrg, - OccupationTelephone = p.OccupationTelephone == null ? "-" : p.OccupationTelephone, - - CareersTotal = sb.ToString(), - - RegistAddress = p.RegistAddress == null ? "-" : p.RegistAddress, - RegistProvinceName = p.RegistProvinceName == null ? "-" : p.RegistProvinceName, - RegistDistrictName = p.RegistDistrictName == null ? "-" : p.RegistDistrictName, - RegistSubDistrictName = p.RegistSubDistrictName == null ? "-" : p.RegistSubDistrictName, - RegistZipCode = p.RegistZipCode == null ? "-" : p.RegistZipCode, - CurrentAddress = p.CurrentAddress == null ? (p.RegistAddress == null ? "-" : p.RegistAddress) : p.CurrentAddress, - CurrentProvinceName = p.CurrentProvinceName == null ? (p.RegistProvinceName == null ? "-" : p.RegistProvinceName) : p.CurrentProvinceName, - CurrentDistrictName = p.CurrentDistrictName == null ? (p.RegistDistrictName == null ? "-" : p.RegistDistrictName) : p.CurrentDistrictName, - CurrentSubDistrictName = p.CurrentSubDistrictName == null ? (p.RegistSubDistrictName == null ? "-" : p.RegistSubDistrictName) : p.CurrentSubDistrictName, - CurrentZipCode = p.CurrentZipCode == null ? (p.RegistZipCode == null ? "-" : p.RegistZipCode) : p.CurrentZipCode, - Telephone = p.Telephone == null ? "-" : p.Telephone, - Email = p.Email == null ? "-" : p.Email, - - ContactFullName = $"{p.ContactPrefixName}{p.ContactFirstname} {p.ContactLastname}", - ContactRelations = p.ContactRelations == null ? "-" : p.ContactRelations, - ContactTel = p.ContactTel == null ? "-" : p.ContactTel, - - RegisterDate = p.RegisterDate == null ? "-" : p.RegisterDate.Value.ToThaiFullDate(), - - IsBachelors = p.PositionExam != null && !string.IsNullOrEmpty(p.PositionExam.EducationLevel) && p.PositionExam.EducationLevel.Trim().ToUpper() == "BACHELOR" - ? new List { - $"ชื่อปริญญา {(p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationLevelExamName)}", - $"สาขาวิชา/วิชาเอก {(p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationMajor)}" - } - : new List { - $"สาขาวิชา/วิชาเอก {(p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationMajor)}" - }, - EditorConfirm = p.PeriodExam == null || p.PeriodExam.EditorConfirm == null - ? "1. ข้าพเจ้าขอให้คำรับรองว่า ข้อความดังกล่าวข้างต้นเป็นจริงทุกประการ และข้าพเจ้ามีคุณสมบัติทั่วไปและไม่มีลักษณะต้องห้ามตามมาตรา 43 แห่งพระราชบัญญัติระเบียบข้าราชการกรุงเทพมหานครและบุคลากรกรุงเทพมหานคร พ.ศ. 2554 และมีคุณสมบัติเฉพาะสำหรับตำแหน่งที่สมัครตรงตามประกาศรับสมัคร\r\n" - + "2. กรณีข้าพเจ้ามีลักษณะต้องห้าม ตามมาตรา 43 ข. แห่งพระราชบัญญัติระเบียบข้าราชการกรุงเทพมหานครและบุคลากรกรุงเทพมหานคร พ.ศ. 2554 และประสงค์จะยื่นคำขอยกเว้นเข้ารับราชการฯ ต่อสำนักงาน ก.ก. ตามระเบียบ ก.ก. ว่าด้วยการยกเว้นให้ผู้มีลักษณะต้องห้ามเข้ารับราชการเป็นข้าราชการกรุงเทพมหานคร พ.ศ. 2556 ตามมติ ก.ก. ครั้งที่ 7/2556 เมื่อวันที่ 15 สิงหาคม 2556 ข้าพเจ้าจะยื่นคำขอยกเว้นฯ ภายในวันปิดรับสมัคร ทั้งนี้ หากยื่นภายหลังกำหนด สำนักงาน ก.ก. จะไม่รับคำขอดังกล่าว\r\n" - + "3. ข้าพเจ้าจะยื่นหลักฐานและเอกสารที่แสดงว่า เป็นผู้มีคุณสมบัติทั่วไปและมีคุณสมบัติเฉพาะสำหรับตำแหน่งที่สมัครตรงตามประกาศรับสมัครภายในระยะเวลาที่กำหนดตามประกาศฯ หากมีการตรวจสอบหลักฐานและเอกสาร และหรือคุณวุฒิการศึกษาของข้าพเจ้าในภายหลังปรากฏว่าข้าพเจ้ามีคุณสมบัติไม่ตรงหรือมีลักษณะต้องห้ามตามประกาศรับสมัครหรือไม่ได้รับการยกเว้น ให้ถือว่า ข้าพเจ้าเป็นผู้ขาดคุณสมบัติในการสมัครครั้งนี้มาตั้งแต่ต้น และไม่มีสิทธิได้รับการบรรจุและแต่งตั้งให้ดำรงตำแหน่ง และข้าพเจ้าจะไม่มีสิทธิเรียกร้องใดๆ ทั้งสิ้น และหากข้าพเจ้าจงใจกรอกข้อความอันเป็นเท็จ อาจมีความผิดทางอาญาฐานแจ้งความเท็จต่อเจ้าพนักงาน ตามประมวลกฎหมายอาญา มาตรา 137\r\n" - + "4. ข้าพเจ้าได้ศึกษาและทำความเข้าใจพระราชบัญญัติคุ้มครองข้อมูลส่วนบุคคล พ.ศ. 2562 ตลอดจนประกาศและระเบียบที่เกี่ยวข้องโดยละเอียดครบถ้วนแล้ว ข้าพเจ้าขอแสดงความยินยอมให้หน่วยงานหรือบุคคลที่เกี่ยวข้องกับการดำเนินการสรรหา สามารถเก็บ รวบรวม ใช้ และเปิดเผยข้อมูลส่วนบุคคลที่เกี่ยวข้องกับข้าพเจ้า เพื่อประโยชน์ของทางราชการตามกฎหมายที่เกี่ยวข้อง\r\n" - + "5. ข้าพเจ้ารับทราบว่า การส่งใบสมัครคัดเลือกฯ พร้อมเอกสารนี้ ยังไม่ได้รับการตรวจสอบคุณสมบัติตามหลักเกณฑ์ ประกาศรับสมัครคัดเลือก และเงื่อนไขต่างๆ โดยจะได้รับการตรวจสอบคุณสมบัติเมื่อเป็นผู้สอบผ่านข้อเขียนภาคความรู้ความสามารถที่ใช้เฉพาะตำแหน่งแล้วเท่านั้น" - : Regex.Replace(Regex.Match(p.PeriodExam.EditorConfirm, @"1\..*", RegexOptions.Singleline).Value,"<.*?>", string.Empty).Replace(" ", " ").Trim(), - }) - .FirstOrDefaultAsync(); - if (data == null) + if (candidate == null) throw new Exception(GlobalMessages.CandidateNotFound); - return data; + + // แปลง EditorConfirm เป็น List + { + "1. ข้าพเจ้าขอให้คำรับรองว่า ข้อความดังกล่าวข้างต้นเป็นจริงทุกประการ และข้าพเจ้ามีคุณสมบัติทั่วไปและไม่มีลักษณะต้องห้ามตามมาตรา 43 แห่งพระราชบัญญัติระเบียบข้าราชการกรุงเทพมหานครและบุคลากรกรุงเทพมหานคร พ.ศ. 2554 และมีคุณสมบัติเฉพาะสำหรับตำแหน่งที่สมัครตรงตามประกาศรับสมัคร", + "2. กรณีข้าพเจ้ามีลักษณะต้องห้าม ตามมาตรา 43 ข. แห่งพระราชบัญญัติระเบียบข้าราชการกรุงเทพมหานครและบุคลากรกรุงเทพมหานคร พ.ศ. 2554 และประสงค์จะยื่นคำขอยกเว้นเข้ารับราชการฯ ต่อสำนักงาน ก.ก. ตามระเบียบ ก.ก. ว่าด้วยการยกเว้นให้ผู้มีลักษณะต้องห้ามเข้ารับราชการเป็นข้าราชการกรุงเทพมหานคร พ.ศ. 2556 ตามมติ ก.ก. ครั้งที่ 7/2556 เมื่อวันที่ 15 สิงหาคม 2556 ข้าพเจ้าจะยื่นคำขอยกเว้นฯ ภายในวันปิดรับสมัคร ทั้งนี้ หากยื่นภายหลังกำหนด สำนักงาน ก.ก. จะไม่รับคำขอดังกล่าว", + "3. ข้าพเจ้าจะยื่นหลักฐานและเอกสารที่แสดงว่า เป็นผู้มีคุณสมบัติทั่วไปและมีคุณสมบัติเฉพาะสำหรับตำแหน่งที่สมัครตรงตามประกาศรับสมัครภายในระยะเวลาที่กำหนดตามประกาศฯ หากมีการตรวจสอบหลักฐานและเอกสาร และหรือคุณวุฒิการศึกษาของข้าพเจ้าในภายหลังปรากฏว่าข้าพเจ้ามีคุณสมบัติไม่ตรงหรือมีลักษณะต้องห้ามตามประกาศรับสมัครหรือไม่ได้รับการยกเว้น ให้ถือว่า ข้าพเจ้าเป็นผู้ขาดคุณสมบัติในการสมัครครั้งนี้มาตั้งแต่ต้น และไม่มีสิทธิได้รับการบรรจุและแต่งตั้งให้ดำรงตำแหน่ง และข้าพเจ้าจะไม่มีสิทธิเรียกร้องใดๆ ทั้งสิ้น และหากข้าพเจ้าจงใจกรอกข้อความอันเป็นเท็จ อาจมีความผิดทางอาญาฐานแจ้งความเท็จต่อเจ้าพนักงาน ตามประมวลกฎหมายอาญา มาตรา 137", + "4. ข้าพเจ้าได้ศึกษาและทำความเข้าใจพระราชบัญญัติคุ้มครองข้อมูลส่วนบุคคล พ.ศ. 2562 ตลอดจนประกาศและระเบียบที่เกี่ยวข้องโดยละเอียดครบถ้วนแล้ว ข้าพเจ้าขอแสดงความยินยอมให้หน่วยงานหรือบุคคลที่เกี่ยวข้องกับการดำเนินการสรรหา สามารถเก็บ รวบรวม ใช้ และเปิดเผยข้อมูลส่วนบุคคลที่เกี่ยวข้องกับข้าพเจ้า เพื่อประโยชน์ของทางราชการตามกฎหมายที่เกี่ยวข้อง", + "5. ข้าพเจ้ารับทราบว่า การส่งใบสมัครคัดเลือกฯ พร้อมเอกสารนี้ ยังไม่ได้รับการตรวจสอบคุณสมบัติตามหลักเกณฑ์ ประกาศรับสมัครคัดเลือก และเงื่อนไขต่างๆ โดยจะได้รับการตรวจสอบคุณสมบัติเมื่อเป็นผู้สอบผ่านข้อเขียนภาคความรู้ความสามารถที่ใช้เฉพาะตำแหน่งแล้วเท่านั้น" + } + /*: Regex.Matches( + Regex.Replace(candidate.PeriodExam.EditorConfirm, "<.*?>", string.Empty) + .Replace(" ", " ") + .Trim(), + @"(?:[1-9]|[1-9][0-9]|100)\.\s*.*?(?=(?:[1-9]|[1-9][0-9]|100)\.|$)", + RegexOptions.Singleline + ) + .Cast() + .Select(m => m.Groups[1].Value.Trim()) + .ToList()*/; + + return new + { + candidate.Id, + AvatarId = candidate.ProfileImg?.Id ?? Guid.Empty, + ExamIdenNumber = candidate.ExamIdenNumber ?? "-", + PositionName = candidate.PositionExam?.PositionName ?? "-", + PositionLevelName = candidate.PositionExam?.PositionLevelName ?? "-", + PeriodExamName = candidate.PeriodExam?.Name ?? "-", + PeriodExamRound = candidate.PeriodExam?.Round.ToString() ?? "-", + PeriodExamYear = candidate.PeriodExam != null ? (candidate.PeriodExam.Year + 543).ToString() : "-", + FullName = $"{candidate.PrefixName}{candidate.FirstName} {candidate.LastName}", + Religion = candidate.ReligionName ?? "-", + Nationality = candidate.Nationality ?? "-", + DateOfBirth = candidate.DateOfBirth?.ToThaiFullDate2() ?? "-", + Age = candidate.DateOfBirth?.CalculateAgeStrV2(0, 0) ?? "-", + CitizenId = candidate.CitizenId ?? "-", + + EducationLevelExamName = candidate.Educations.FirstOrDefault()?.EducationLevelExamName ?? "-", + EducationName = (candidate.Educations.FirstOrDefault()?.EducationLevelExamName is "ปริญญาตรี" or "ปริญญาโท" or "ปริญญาเอก") + ? candidate.Educations.FirstOrDefault()?.EducationName + : null, + EducationMajor = candidate.Educations.FirstOrDefault()?.EducationMajor ?? "-", + EducationLocation = candidate.Educations.FirstOrDefault()?.EducationLocation ?? "-", + EducationEndDate = candidate.Educations.FirstOrDefault()?.EducationEndDate?.ToThaiFullDate2() ?? "-", + EducationScores = candidate.Educations.FirstOrDefault()?.EducationScores ?? "-", + EducationType = candidate.Educations.FirstOrDefault()?.EducationType ?? "-", + EducationLevelHighName = candidate.Educations.FirstOrDefault()?.EducationLevelHighName ?? "-", + + OccupationPositionType = candidate.OccupationPositionType == "other" ? "ผู้ปฏิบัติงานอื่นในกรุงเทพมหานคร" : + candidate.OccupationPositionType == "temp" ? "ลูกจ้างชั่วคราว" : + candidate.OccupationPositionType == "prem" ? "ลูกจ้างประจำ" : "-", + OccupationPosition = candidate.OccupationPosition ?? "-", + OccupationSalary = candidate.OccupationSalary.HasValue + ? (candidate.OccupationSalary.Value % 1 == 0 + ? candidate.OccupationSalary.Value.ToString("N0") + : candidate.OccupationSalary.Value.ToString("N2")) + : "-", + OccupationGroup = candidate.OccupationGroup ?? "-", + OccupationPile = candidate.OccupationPile ?? "-", + OccupationOrg = candidate.OccupationOrg ?? "-", + OccupationTelephone = candidate.OccupationTelephone ?? "-", + + CareersTotal = sb.ToString(), + + RegistAddress = candidate.RegistAddress ?? "-", + RegistProvinceName = candidate.RegistProvinceName ?? "-", + RegistDistrictName = candidate.RegistDistrictName ?? "-", + RegistSubDistrictName = candidate.RegistSubDistrictName ?? "-", + RegistZipCode = candidate.RegistZipCode ?? "-", + CurrentAddress = candidate.CurrentAddress ?? candidate.RegistAddress ?? "-", + CurrentProvinceName = candidate.CurrentProvinceName ?? candidate.RegistProvinceName ?? "-", + CurrentDistrictName = candidate.CurrentDistrictName ?? candidate.RegistDistrictName ?? "-", + CurrentSubDistrictName = candidate.CurrentSubDistrictName ?? candidate.RegistSubDistrictName ?? "-", + CurrentZipCode = candidate.CurrentZipCode ?? candidate.RegistZipCode ?? "-", + Telephone = candidate.Telephone ?? "-", + Email = candidate.Email ?? "-", + + ContactFullName = $"{candidate.ContactPrefixName}{candidate.ContactFirstname} {candidate.ContactLastname}", + ContactRelations = candidate.ContactRelations ?? "-", + ContactTel = candidate.ContactTel ?? "-", + + RegisterDate = candidate.RegisterDate?.ToThaiFullDate() ?? "-", + + IsBachelors = candidate.PositionExam != null && !string.IsNullOrEmpty(candidate.PositionExam.EducationLevel) && candidate.PositionExam.EducationLevel.Trim().ToUpper() == "BACHELOR" + ? new List + { + new { label = "ชื่อปริญญา", value = candidate.Educations.FirstOrDefault()?.EducationName ?? "-" }, + new { label = "สาขาวิชา/วิชาเอก", value = candidate.Educations.FirstOrDefault()?.EducationMajor ?? "-" } + } + : new List + { + new { label = "สาขาวิชา/วิชาเอก", value = candidate.Educations.FirstOrDefault()?.EducationMajor ?? "-" } + }, + + EditorConfirms = editorConfirmLists + }; } public async Task GetExamCareerCandidateAsync(Guid id) { diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index e4c11ca7..d0a10879 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -3541,7 +3541,7 @@ namespace BMA.EHR.Placement.Service.Controllers Url = picContent ?? "https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg", Careers = careers, IsBachelors = candidate.GetType().GetProperty("IsBachelors").GetValue(candidate), - EditorConfirm = candidate.GetType().GetProperty("EditorConfirm").GetValue(candidate) + EditorConfirms = candidate.GetType().GetProperty("EditorConfirms").GetValue(candidate) }; var data = new