fix กรณีไม่ได้กรอกข้อมูลตรวจสอบคุณสมบัติให้แสดงว่าง #2349

This commit is contained in:
harid 2026-03-12 11:13:43 +07:00
parent bb0b296086
commit 75718a955d

View file

@ -1604,11 +1604,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
r.ExamId = workSheet?.Cells[row, 2]?.GetValue<string>();
//var recruit = await _context.Disables.AsQueryable()
// .Include(x => x.PeriodExam)
// .Where(x => x.PeriodExam == rec_import && x.ExamId == r.ExamId)
// .FirstOrDefaultAsync();
// ใช้ dictionary lookup แทน query DB ทีละรอบ
if (!string.IsNullOrEmpty(r.ExamId) && recruitsDict.TryGetValue(r.ExamId, out var recruit))
{
@ -1633,26 +1628,19 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
r.FullScore = 300;
r.TotalScore = string.IsNullOrWhiteSpace(workSheet?.Cells[row, 13]?.GetValue<string>()) ? 0.00 : Math.Round(workSheet.Cells[row, 13].GetValue<double>(), 2);
if (workSheet?.Cells[row, 7]?.GetValue<string>() == "ขาดสอบ")
{
r.ExamStatus = "ขส.";
}
else if (workSheet?.Cells[row, 14]?.GetValue<string>() == "ได้")
{
r.ExamStatus = "ผ่าน";
}
else if (workSheet?.Cells[row, 14]?.GetValue<string>() == "ตก")
{
r.ExamStatus = "ไม่ผ่าน";
}
else
{
r.ExamStatus = "-";
}
var examStatusCol7 = workSheet?.Cells[row, 7]?.GetValue<string>()?.Trim();
var examStatusCol14 = workSheet?.Cells[row, 14]?.GetValue<string>()?.Trim();
r.ExamStatus =
examStatusCol7 == "ขาดสอบ" ? "ขส." :
examStatusCol14 == "ได้" ? "ผ่าน" :
examStatusCol14 == "ตก" ? "ไม่ผ่าน" : "-";
r.RemarkScore = string.IsNullOrWhiteSpace(workSheet?.Cells[row, 15]?.GetValue<string>()) ? string.Empty : workSheet?.Cells[row, 15]?.GetValue<string>();
r.ExamAttribute = (workSheet?.Cells[row, 16]?.GetValue<string>()?.Trim() == "ผ่าน") ? "มีคุณสมบัติ" : "ไม่มีคุณสมบัติ";
var examAttr = workSheet?.Cells[row, 16]?.GetValue<string>()?.Trim();
r.ExamAttribute =
examAttr == "ผ่าน" ? "มีคุณสมบัติ" :
examAttr == "ไม่ผ่าน" ? "ไม่มีคุณสมบัติ" : "";
r.Major = workSheet.Name;
@ -2098,11 +2086,11 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
// ? _disableService.CheckValidCertificate(x.disable.Certificates.First().IssueDate, 5)
// ? "มีคุณสมบัติ" : "ไม่มีคุณสมบัติ"
// : "ไม่มีคุณสมบัติ",
examAttribute = x.score == null
? "ไม่มีคุณสมบัติ"
: string.IsNullOrEmpty(x.score.ExamAttribute)
? "ไม่มีคุณสมบัติ"
: x.score.ExamAttribute,
examAttribute = x.score != null && !string.IsNullOrEmpty(x.score.ExamAttribute) &&
(x.score.ExamAttribute == "มีคุณสมบัติ" || x.score.ExamAttribute == "ไม่มีคุณสมบัติ")
? x.score.ExamAttribute : "",
remark = x.disable.Remark,
isSpecial = x.disable.Isspecial == "Y" ? x.disable.Isspecial : "",
applyDate = x.disable.ApplyDate.HasValue && x.disable.ApplyDate.Value != DateTime.MinValue
@ -2227,11 +2215,11 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
// ? "มีคุณสมบัติ"
// : "ไม่มีคุณสมบัติ"
// : "ไม่มีคุณสมบัติ",
ExamAttribute = sr == null
? "ไม่มีคุณสมบัติ"
: string.IsNullOrEmpty(sr.ExamAttribute)
? "ไม่มีคุณสมบัติ"
: sr.ExamAttribute,
ExamAttribute = sr != null && !string.IsNullOrEmpty(sr.ExamAttribute) &&
(sr.ExamAttribute == "มีคุณสมบัติ" || sr.ExamAttribute == "ไม่มีคุณสมบัติ")
? sr.ExamAttribute : "",
IsSpecial = p.Isspecial,
Remark = p.Remark,
University = p.Educations.First().University,