diff --git a/BMA.EHR.Application/Repositories/Reports/CandidateReportRepository.cs b/BMA.EHR.Application/Repositories/Reports/CandidateReportRepository.cs index 2cb94e82..6a87fb29 100644 --- a/BMA.EHR.Application/Repositories/Reports/CandidateReportRepository.cs +++ b/BMA.EHR.Application/Repositories/Reports/CandidateReportRepository.cs @@ -59,6 +59,7 @@ namespace BMA.EHR.Application.Repositories.Reports var monthDiff = 0; var dayDiff = 0; var sb = new StringBuilder(); + var zxc = new List(); foreach (var career in careers) { if (career.DurationEnd < career.DurationStart) @@ -67,6 +68,7 @@ namespace BMA.EHR.Application.Repositories.Reports yearDiff = yearDiff + rangeObj.years; monthDiff = monthDiff + rangeObj.months; dayDiff = dayDiff + rangeObj.days; + zxc.Add(rangeObj); } else { @@ -74,6 +76,7 @@ namespace BMA.EHR.Application.Repositories.Reports yearDiff = yearDiff + rangeObj.years; monthDiff = monthDiff + rangeObj.months; dayDiff = dayDiff + rangeObj.days; + zxc.Add(rangeObj); } if (dayDiff >= 30) { @@ -90,7 +93,6 @@ 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 @@ -120,7 +122,7 @@ namespace BMA.EHR.Application.Repositories.Reports 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 == "perm" ? "ลูกจ้างประจำ" : "-")), + OccupationPositionType = p.OccupationPositionType == "other" ? "ผู้ปฏิบัติงานอื่นในกรุงเทพมหานคร" : (p.OccupationPositionType == "temp" ? "ลูกจ้างชั่วคราว" : (p.OccupationPositionType == "prem" ? "ลูกจ้างประจำ" : "-")), OccupationPosition = p.OccupationPosition == null ? "-" : p.OccupationPosition, OccupationSalary = p.OccupationSalary == null ? "-" : p.OccupationSalary.ToString(), OccupationGroup = p.OccupationGroup == null ? "-" : p.OccupationGroup, @@ -143,11 +145,11 @@ namespace BMA.EHR.Application.Repositories.Reports RegistDistrictName = p.RegistDistrictName == null ? "-" : p.RegistDistrictName, RegistSubDistrictName = p.RegistSubDistrictName == null ? "-" : p.RegistSubDistrictName, RegistZipCode = p.RegistZipCode == null ? "-" : p.RegistZipCode, - CurrentAddress = p.CurrentAddress == null ? "-" : p.CurrentAddress, - CurrentProvinceName = p.CurrentProvinceName == null ? "-" : p.CurrentProvinceName, - CurrentSubDistrictName = p.CurrentSubDistrictName == null ? "-" : p.CurrentSubDistrictName, - CurrentDistrictName = p.CurrentDistrictName == null ? "-" : p.CurrentDistrictName, - CurrentZipCode = p.CurrentZipCode == null ? "-" : p.CurrentZipCode, + CurrentAddress = p.CurrentAddress == null ? (p.RegistAddress == null ? "-" : p.RegistAddress) : p.CurrentAddress, + CurrentProvinceName = p.CurrentProvinceName == null ? (p.RegistProvinceName == null ? "-" : p.RegistProvinceName) : p.CurrentProvinceName, + CurrentSubDistrictName = p.CurrentSubDistrictName == null ? (p.RegistDistrictName == null ? "-" : p.RegistDistrictName) : p.CurrentSubDistrictName, + CurrentDistrictName = p.CurrentDistrictName == null ? (p.RegistSubDistrictName == null ? "-" : p.RegistSubDistrictName) : p.CurrentDistrictName, + CurrentZipCode = p.CurrentZipCode == null ? (p.RegistZipCode == null ? "-" : p.RegistZipCode) : p.CurrentZipCode, Telephone = p.Telephone == null ? "-" : p.Telephone, Email = p.Email == null ? "-" : p.Email, diff --git a/BMA.EHR.Domain/Extensions/DateTimeExtension.cs b/BMA.EHR.Domain/Extensions/DateTimeExtension.cs index 43c41f51..b9c0a579 100644 --- a/BMA.EHR.Domain/Extensions/DateTimeExtension.cs +++ b/BMA.EHR.Domain/Extensions/DateTimeExtension.cs @@ -334,14 +334,8 @@ namespace BMA.EHR.Domain.Extensions { // if (startDate == null || endDate == null) // return null; - DateTime today = endDate; - DateTime birthDate = Convert.ToDateTime(startDate).AddDays(-1); - var years1 = birthDate; - var years2 = endDate; - var years3 = endDate.Subtract(birthDate); - var years4 = endDate.Subtract(birthDate).Ticks; - var years5 = new DateTime(endDate.Subtract(birthDate).Ticks); - var years6 = new DateTime(endDate.Subtract(birthDate).Ticks).Year; + DateTime today = endDate.AddDays(1); + DateTime birthDate = startDate; int years = new DateTime(endDate.Subtract(birthDate).Ticks).Year - 1; DateTime pastYearDate = birthDate.AddYears(years); int months = 0; @@ -370,6 +364,17 @@ namespace BMA.EHR.Domain.Extensions days -= 1; } } + if (days >= 30) + { + months = months + 1; + days = 0; + if (months >= 12) + { + years = years + 1; + months = 0; + } + } + var sb = new StringBuilder(); sb.Clear(); sb.Append(years == 0 ? "" : $"{years} ปี "); diff --git a/BMA.EHR.Report.Service/Reports/ผลสอบคัดเลือกรายบุคคล.trdp b/BMA.EHR.Report.Service/Reports/ผลสอบคัดเลือกรายบุคคล.trdp index 558b65a2..c61efa1d 100644 Binary files a/BMA.EHR.Report.Service/Reports/ผลสอบคัดเลือกรายบุคคล.trdp and b/BMA.EHR.Report.Service/Reports/ผลสอบคัดเลือกรายบุคคล.trdp differ