From 40861853dde9c43085f6aa237beeef9fc2a45923 Mon Sep 17 00:00:00 2001 From: "DESKTOP-2S5P7D1\\Windows 10" Date: Mon, 4 Sep 2023 16:02:20 +0700 Subject: [PATCH 1/4] =?UTF-8?q?query=20=E0=B8=82=E0=B8=A3=201-4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApplicationServicesRegistration.cs | 1 + .../Reports/InsigniaReportRepository.cs | 176 +++++++++++++++++- .../Controllers/InsigniaReportController.cs | 30 +-- 3 files changed, 184 insertions(+), 23 deletions(-) diff --git a/BMA.EHR.Application/ApplicationServicesRegistration.cs b/BMA.EHR.Application/ApplicationServicesRegistration.cs index a292d497..e92d8c5d 100644 --- a/BMA.EHR.Application/ApplicationServicesRegistration.cs +++ b/BMA.EHR.Application/ApplicationServicesRegistration.cs @@ -25,6 +25,7 @@ namespace BMA.EHR.Application services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); return services; diff --git a/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs b/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs index 6a8bc7bf..98ba6fc7 100644 --- a/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs +++ b/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs @@ -1,6 +1,7 @@ using BMA.EHR.Application.Common.Interfaces; using BMA.EHR.Application.Responses; using BMA.EHR.Domain.Extensions; +using BMA.EHR.Domain.Models.HR; using BMA.EHR.Domain.Models.Insignias; using BMA.EHR.Domain.Models.Organizations; using BMA.EHR.Domain.Models.Retirement; @@ -17,6 +18,7 @@ namespace BMA.EHR.Application.Repositories.Reports private readonly IApplicationDBContext _dbContext; private readonly IWebHostEnvironment _hostingEnvironment; private readonly OrganizationCommonRepository _organizationCommonRepository; + private readonly string CRLF = "\r\n"; #endregion @@ -43,6 +45,7 @@ namespace BMA.EHR.Application.Repositories.Reports string thaiYear = period.Year.ToThaiYear().ToString(); return thaiYear; } + public async Task GetKhr1Report(Guid id) { var period = await _dbContext.Set() @@ -52,11 +55,6 @@ namespace BMA.EHR.Application.Repositories.Reports var data_insignia = await _dbContext.Set() .Include(x => x.Profile) - // .ThenInclude(x => x.OrganizationOrganization) - // .ThenInclude(x => x.Type) - // .Include(x => x.RequestInsignia) - // .ThenInclude(x => x.InsigniaType) - // .Include(x => x.Request) .Where(x => x.Request.Period == period) .Where(x => x.IsApprove == true) .Where(x => x.RequestInsignia.InsigniaType != null) @@ -87,6 +85,7 @@ namespace BMA.EHR.Application.Repositories.Reports return insignia; } + public async Task GetKhr2Report(Guid id) { var period = await _dbContext.Set() @@ -96,11 +95,6 @@ namespace BMA.EHR.Application.Repositories.Reports var data_insignia = await _dbContext.Set() .Include(x => x.Profile) - // .ThenInclude(x => x.OrganizationOrganization) - // .ThenInclude(x => x.Type) - // .Include(x => x.RequestInsignia) - // .ThenInclude(x => x.InsigniaType) - // .Include(x => x.Request) .Where(x => x.Request.Period == period) .Where(x => x.IsApprove == true) .Where(x => x.RequestInsignia.InsigniaType != null) @@ -140,6 +134,168 @@ namespace BMA.EHR.Application.Repositories.Reports return insignia; } + public async Task GetKhr3Report(Guid id) + { + var period = await _dbContext.Set() + .FirstOrDefaultAsync(x => x.Id == id); + if (period == null) + throw new Exception(GlobalMessages.InsigniaPeriodNotFound); + + var data = (from r in await _dbContext.Set() + .Include(x => x.Profile) + .ThenInclude(x => x.Gender) + .Include(x => x.Profile) + .ThenInclude(x => x.Prefix) + .Include(x => x.Request) + .ThenInclude(x => x.Period) + .Include(x => x.Request) + .ThenInclude(x => x.Organization) + .Include(x => x.RequestInsignia) + .ThenInclude(x => x.InsigniaType) + .ToListAsync() + where r.Request.Period == period + && r.IsApprove == true + && r.RequestInsignia.InsigniaType != null + && r.RequestInsignia.InsigniaType.Name != "เหรียญบำเหน็จในราชการ" + select new + { + InsigniaInitial = r.RequestInsignia.ShortName, + InsigniaName = r.RequestInsignia.Name, + ProfileId = r.Profile.Id, + FullName = $"{r.Profile.Prefix?.Name}{r.Profile.FirstName} {r.Profile.LastName}", + Gender = r.Profile.Gender == null ? null : r.Profile.Gender.Name, + InsigniaId = r.RequestInsignia.Id, + OCName = _organizationCommonRepository.GetOrganizationNameFullPath(r.Request.Organization.Id, false, false) + }) + .Distinct() + .ToList(); + + // loop to add temp row with 50 rows per page + var insigniaList = data.Select(x => new { InsigniaId = x.InsigniaId, InsigniaInitial = x.InsigniaInitial, InsigniaName = x.InsigniaName }) + .Distinct().ToList(); + + foreach (var ins in insigniaList) + { + var count = data.Where(x => x.InsigniaId == ins.InsigniaId).Count(); + var mod_val = count <= 50 ? 50 - count : count % 50.0; + for (int i = 0; i < mod_val; i++) + { + var p = new + { + InsigniaInitial = ins.InsigniaInitial, + InsigniaName = ins.InsigniaName, + ProfileId = Guid.Parse("00000000-0000-0000-0000-000000000000"), + FullName = "", + Gender = "", + InsigniaId = ins.InsigniaId, + OCName = "" + }; + data.Add(p); + } + } + return data; + } + + public async Task GetKhr4Report(Guid id) + { + var period = await _dbContext.Set() + .FirstOrDefaultAsync(x => x.Id == id); + if (period == null) + throw new Exception(GlobalMessages.InsigniaPeriodNotFound); + + var teacher_data = (from r in await _dbContext.Set() + .Include(x => x.Profile) + .ThenInclude(x => x.Salaries) + .Include(x => x.Profile) + .ThenInclude(x => x.Gender) + .Include(x => x.Profile) + .ThenInclude(x => x.Prefix) + .Include(x => x.Profile) + .ThenInclude(x => x.PositionType) + .Include(x => x.Profile) + .ThenInclude(x => x.PositionLevel) + .Include(x => x.Request) + .ThenInclude(x => x.Period) + .Include(x => x.RequestInsignia) + .ThenInclude(x => x.InsigniaType) + .Include(x => x.Request) + .ThenInclude(x => x.Organization) + .ToListAsync() + where r.Request.Period == period + && r.IsApprove == true + && r.RequestInsignia.InsigniaType != null + && r.RequestInsignia.InsigniaType.Name != "เหรียญบำเหน็จในราชการ" + select new + { + InsigniaInitial = r.RequestInsignia.ShortName, + InsigniaName = r.RequestInsignia.Name, + ProfileId = r.Profile.Id, + FullName = $"{r.Profile.Prefix?.Name}{r.Profile.FirstName} {r.Profile.LastName}", + ShowProfileId = r.Profile.Id, + Type = r.Profile.PositionType?.Name, + AcademicStanding = "", + Level = r.Profile.PositionLevel?.Name, + DateStart = r.Profile.DateStart == null ? null : r.Profile.DateStart.Value.ToThaiShortDate(), + SalaryAmount = r.Profile.Salaries.Count() == 0 ? 0 : + r.Profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount, + InsigniaRecv = "", + InsigniaRecvDate = "", + InsigniaRequest = r.RequestInsignia.ShortName, + Remark = "", + Position = r.Profile.Position?.Name + + (r.Profile.PositionType == null ? null : " ประเภท" + r.Profile.PositionType?.Name) + + (r.Profile.PositionLevel == null ? null : " ระดับ" + r.Profile.PositionLevel?.Name) + + CRLF, + OCName = _organizationCommonRepository.GetOrganizationNameFullPath(r.Request.Organization.Id, false, false) + }) + .Distinct() + .ToList(); + + var insignia_data = (from r in await _dbContext.Set() + .Include(x => x.Profile) + .ThenInclude(x => x.Gender) + .Include(x => x.Profile) + .ThenInclude(x => x.Insignias) + .ThenInclude(x => x.Insignia) + .Include(x => x.Request) + .ThenInclude(x => x.Period) + .Include(x => x.Request) + .ThenInclude(x => x.Organization) + .Include(x => x.RequestInsignia) + .ThenInclude(x => x.InsigniaType) + .ToListAsync() + where r.Request.Period == period + && r.IsApprove == true + && r.RequestInsignia.InsigniaType != null + && r.RequestInsignia.InsigniaType.Name != "เหรียญบำเหน็จในราชการ" + select new + { + InsigniaInitial = r.RequestInsignia.ShortName, + InsigniaName = r.RequestInsignia.Name, + ProfileId = r.Profile.Id, + FullName = $"", + ShowProfileId = Guid.Parse("00000000-0000-0000-0000-000000000000"), + Type = "", + AcademicStanding = "", + Level = "", + DateStart = "", + SalaryAmount = new double?(0), + InsigniaRecv = r.Profile.Insignias.Count() == 0 ? null : + (r.Profile.Insignias.OrderByDescending(x => x.Year).FirstOrDefault().Insignia == null ? null : r.Profile.Insignias.OrderByDescending(x => x.Year).FirstOrDefault().Insignia.ShortName), + InsigniaRecvDate = r.Profile.Insignias.Count() == 0 ? null : + (r.Profile.Insignias.OrderByDescending(x => x.Year).FirstOrDefault().DateAnnounce == null ? null : r.Profile.Insignias.OrderByDescending(x => x.Year).FirstOrDefault().DateAnnounce.Value.ToThaiShortDate()), + InsigniaRequest = "", + Remark = "", + Position = "", + OCName = _organizationCommonRepository.GetOrganizationNameFullPath(r.Request.Organization.Id, false, false) + }) + .Distinct() + .ToList(); + + var data2 = teacher_data.Union(insignia_data).ToList(); + return data2; + } + #endregion } } diff --git a/BMA.EHR.Report.Service/Controllers/InsigniaReportController.cs b/BMA.EHR.Report.Service/Controllers/InsigniaReportController.cs index e61dce26..7fb08d5b 100644 --- a/BMA.EHR.Report.Service/Controllers/InsigniaReportController.cs +++ b/BMA.EHR.Report.Service/Controllers/InsigniaReportController.cs @@ -31,7 +31,7 @@ namespace BMA.EHR.Report.Service.Controllers _hostingEnvironment = hostingEnvironment; _configuration = configuration; - //_repository = repository; + _repository = repository; _reportGenerator = reportGenerator; } @@ -50,11 +50,12 @@ namespace BMA.EHR.Report.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpGet("39/{exportType}/{id}")] - public IActionResult GetInsignia39ConvertReportAsync(Guid id, string exportType = "pdf") + public async Task> GetInsignia39ConvertReportAsync(Guid id, string exportType = "pdf") { try { - // GetKhr1Report + var data = await _repository.GetKhr1Report(id); + return Success(data); var mimeType = ""; switch (exportType.Trim().ToLower()) { @@ -87,11 +88,12 @@ namespace BMA.EHR.Report.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpGet("40/{exportType}/{id}")] - public IActionResult GetInsignia40ConvertReportAsync(Guid id, string exportType = "pdf") + public async Task> GetInsignia40ConvertReportAsync(Guid id, string exportType = "pdf") { try { - // GetKhr2Report + var data = await _repository.GetKhr2Report(id); + return Success(data); var mimeType = ""; switch (exportType.Trim().ToLower()) { @@ -124,11 +126,12 @@ namespace BMA.EHR.Report.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpGet("41/{exportType}/{id}")] - public IActionResult GetInsignia41ConvertReportAsync(Guid id, string exportType = "pdf") + public async Task> GetInsignia41ConvertReportAsync(Guid id, string exportType = "pdf") { try { - // GetKhr3Report + var data = await _repository.GetKhr3Report(id); + return Success(data); var mimeType = ""; switch (exportType.Trim().ToLower()) { @@ -161,11 +164,12 @@ namespace BMA.EHR.Report.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpGet("42/{exportType}/{id}")] - public IActionResult GetInsignia42ConvertReportAsync(Guid id, string exportType = "pdf") + public async Task> GetInsignia42ConvertReportAsync(Guid id, string exportType = "pdf") { try { - + var data = await _repository.GetKhr4Report(id); + return Success(data); var mimeType = ""; switch (exportType.Trim().ToLower()) { @@ -198,7 +202,7 @@ namespace BMA.EHR.Report.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpGet("43/{exportType}/{id}")] - public IActionResult GetInsignia43ConvertReportAsync(Guid id, string exportType = "pdf") + public async Task> GetInsignia43ConvertReportAsync(Guid id, string exportType = "pdf") { try { @@ -235,7 +239,7 @@ namespace BMA.EHR.Report.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpGet("44/{exportType}/{id}")] - public IActionResult GetInsignia44ConvertReportAsync(Guid id, string exportType = "pdf") + public async Task> GetInsignia44ConvertReportAsync(Guid id, string exportType = "pdf") { try { @@ -272,7 +276,7 @@ namespace BMA.EHR.Report.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpGet("45/{exportType}/{id}")] - public IActionResult GetInsignia45ConvertReportAsync(Guid id, string exportType = "pdf") + public async Task> GetInsignia45ConvertReportAsync(Guid id, string exportType = "pdf") { try { @@ -309,7 +313,7 @@ namespace BMA.EHR.Report.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpGet("46/{exportType}/{id}")] - public IActionResult GetInsignia46ConvertReportAsync(Guid id, string exportType = "pdf") + public async Task> GetInsignia46ConvertReportAsync(Guid id, string exportType = "pdf") { try { From 3ed1eed02dddbd294256063794cfd07ac24b524d Mon Sep 17 00:00:00 2001 From: "DESKTOP-2S5P7D1\\Windows 10" Date: Mon, 4 Sep 2023 17:00:37 +0700 Subject: [PATCH 2/4] format year to thai --- .../Repositories/Reports/InsigniaReportRepository.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs b/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs index 98ba6fc7..cefd7326 100644 --- a/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs +++ b/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs @@ -42,10 +42,20 @@ namespace BMA.EHR.Application.Repositories.Reports .FirstOrDefaultAsync(x => x.Id == id); if (period == null) throw new Exception(GlobalMessages.InsigniaPeriodNotFound); - string thaiYear = period.Year.ToThaiYear().ToString(); + string thaiYear = period.Year.ToThaiYear().ToString().ToThaiNumber(); return thaiYear; } + public async Task Get2YearInsigniaPeriod(Guid id) + { + var period = await _dbContext.Set() + .FirstOrDefaultAsync(x => x.Id == id); + if (period == null) + throw new Exception(GlobalMessages.InsigniaPeriodNotFound); + string thaiYear = period.Year.ToThaiYear().ToString().ToThaiNumber(); + return thaiYear.Substring(2); + } + public async Task GetKhr1Report(Guid id) { var period = await _dbContext.Set() From 425cf5de02734c440114f659987c505b18b238d0 Mon Sep 17 00:00:00 2001 From: "DESKTOP-2S5P7D1\\Windows 10" Date: Mon, 4 Sep 2023 17:56:44 +0700 Subject: [PATCH 3/4] no message --- .../Reports/InsigniaReportRepository.cs | 127 ++++++++++++++++++ 1 file changed, 127 insertions(+) diff --git a/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs b/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs index cefd7326..cbe34be6 100644 --- a/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs +++ b/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs @@ -91,11 +91,66 @@ namespace BMA.EHR.Application.Repositories.Reports G3Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "ประถมาภรณ์ช้างเผือก" ? 1 : 0), G4Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "ประถมาภรณ์มงกุฎไทย" ? 1 : 0), G4Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "ประถมาภรณ์มงกุฎไทย" ? 1 : 0), + G5Male = g.Sum(x => x.Gendor == "ชาย" ? 1 : 0), + G5Female = g.Sum(x => x.Gendor == "หญิง" ? 1 : 0), }).ToList(); return insignia; } + public async Task GetKhr1TotalReport(Guid id) + { + var period = await _dbContext.Set() + .FirstOrDefaultAsync(x => x.Id == id); + if (period == null) + throw new Exception(GlobalMessages.InsigniaPeriodNotFound); + + var data_insignia = await _dbContext.Set() + .Include(x => x.Profile) + .Where(x => x.Request.Period == period) + .Where(x => x.IsApprove == true) + .Where(x => x.RequestInsignia.InsigniaType != null) + .Where(x => x.RequestInsignia.InsigniaType.Name == "ชั้นสายสะพาย") + .Select(x => new + { + Gendor = x.Profile.Gender == null ? null : x.Profile.Gender.Name, + RequestInsigniaName = x.RequestInsignia.Name, + OcId = x.Request.Organization.Id + }) + .ToListAsync(); + + var insignia = (from r in data_insignia + group r by new { OcId = r.OcId } into g + select new + { + RowNo = 1, + DepartmentName = _organizationCommonRepository.GetOrganizationNameFullPath(g.Key.OcId, false, false), + G1Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "มหาปรมาภรณ์ช้างเผือก" ? 1 : 0), + G1Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "มหาปรมาภรณ์ช้างเผือก" ? 1 : 0), + G2Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "มหาวชิรมงกุฎ" ? 1 : 0), + G2Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "มหาวชิรมงกุฎ" ? 1 : 0), + G3Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "ประถมาภรณ์ช้างเผือก" ? 1 : 0), + G3Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "ประถมาภรณ์ช้างเผือก" ? 1 : 0), + G4Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "ประถมาภรณ์มงกุฎไทย" ? 1 : 0), + G4Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "ประถมาภรณ์มงกุฎไทย" ? 1 : 0), + G5Male = g.Sum(x => x.Gendor == "ชาย" ? 1 : 0), + G5Female = g.Sum(x => x.Gendor == "หญิง" ? 1 : 0), + }).ToList(); + return new + { + G1Male = insignia.Sum(x => x.G1Male), + G1Female = insignia.Sum(x => x.G1Female), + G2Male = insignia.Sum(x => x.G2Male), + G2Female = insignia.Sum(x => x.G2Female), + G3Male = insignia.Sum(x => x.G3Male), + G3Female = insignia.Sum(x => x.G3Female), + G4Male = insignia.Sum(x => x.G4Male), + G4Female = insignia.Sum(x => x.G4Female), + G5Male = insignia.Sum(x => x.G5Male), + G5Female = insignia.Sum(x => x.G5Female), + }; + } + public async Task GetKhr2Report(Guid id) { var period = await _dbContext.Set() @@ -139,6 +194,78 @@ namespace BMA.EHR.Application.Repositories.Reports G7Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "เบญจมาภรณ์ช้างเผือก" ? 1 : 0), G8Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "เบญจมาภรณ์มงกุฎไทย" ? 1 : 0), G8Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "เบญจมาภรณ์มงกุฎไทย" ? 1 : 0), + G9Male = g.Sum(x => x.Gendor == "ชาย" ? 1 : 0), + G9Female = g.Sum(x => x.Gendor == "หญิง" ? 1 : 0), + }).ToList(); + + return new + { + G1Male = insignia.Sum(x => x.G1Male), + G1Female = insignia.Sum(x => x.G1Female), + G2Male = insignia.Sum(x => x.G2Male), + G2Female = insignia.Sum(x => x.G2Female), + G3Male = insignia.Sum(x => x.G3Male), + G3Female = insignia.Sum(x => x.G3Female), + G4Male = insignia.Sum(x => x.G4Male), + G4Female = insignia.Sum(x => x.G4Female), + G5Male = insignia.Sum(x => x.G5Male), + G5Female = insignia.Sum(x => x.G5Female), + G6Male = insignia.Sum(x => x.G6Male), + G6Female = insignia.Sum(x => x.G6Female), + G7Male = insignia.Sum(x => x.G7Male), + G7Female = insignia.Sum(x => x.G7Female), + G8Male = insignia.Sum(x => x.G8Male), + G8Female = insignia.Sum(x => x.G8Female), + G9Male = insignia.Sum(x => x.G9Male), + G9Female = insignia.Sum(x => x.G9Female), + }; + } + + public async Task GetKhr2TotalReport(Guid id) + { + var period = await _dbContext.Set() + .FirstOrDefaultAsync(x => x.Id == id); + if (period == null) + throw new Exception(GlobalMessages.InsigniaPeriodNotFound); + + var data_insignia = await _dbContext.Set() + .Include(x => x.Profile) + .Where(x => x.Request.Period == period) + .Where(x => x.IsApprove == true) + .Where(x => x.RequestInsignia.InsigniaType != null) + .Where(x => x.RequestInsignia.InsigniaType.Name == "ชั้นต่ำกว่าสายสะพาย") + .Select(x => new + { + Gendor = x.Profile.Gender == null ? null : x.Profile.Gender.Name, + RequestInsigniaName = x.RequestInsignia.Name, + OcId = x.Request.Organization.Id + }) + .ToListAsync(); + + var insignia = (from r in data_insignia + group r by new { OcId = r.OcId } into g + select new + { + RowNo = 1, + DepartmentName = _organizationCommonRepository.GetOrganizationNameFullPath(g.Key.OcId, false, false), + G1Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "ทวีติยาภรณ์ช้างเผือก" ? 1 : 0), + G1Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "ทวีติยาภรณ์ช้างเผือก" ? 1 : 0), + G2Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "ทวีติยาภรณ์มงกุฎไทย" ? 1 : 0), + G2Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "ทวีติยาภรณ์มงกุฎไทย" ? 1 : 0), + G3Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "ตริตาภรณ์ช้างเผือก" ? 1 : 0), + G3Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "ตริตาภรณ์ช้างเผือก" ? 1 : 0), + G4Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "ตริตาภรณ์มงกุฎไทย" ? 1 : 0), + G4Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "ตริตาภรณ์มงกุฎไทย" ? 1 : 0), + G5Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "จัตุรถาภรณ์ช้างเผือก" ? 1 : 0), + G5Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "จัตุรถาภรณ์ช้างเผือก" ? 1 : 0), + G6Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "จัตุรถาภรณ์มงกุฎไทย" ? 1 : 0), + G6Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "จัตุรถาภรณ์มงกุฎไทย" ? 1 : 0), + G7Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "เบญจมาภรณ์ช้างเผือก" ? 1 : 0), + G7Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "เบญจมาภรณ์ช้างเผือก" ? 1 : 0), + G8Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "เบญจมาภรณ์มงกุฎไทย" ? 1 : 0), + G8Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "เบญจมาภรณ์มงกุฎไทย" ? 1 : 0), + G9Male = g.Sum(x => x.Gendor == "ชาย" ? 1 : 0), + G9Female = g.Sum(x => x.Gendor == "หญิง" ? 1 : 0), }).ToList(); return insignia; From dce7beb853544463f6059fdacdce86248adab355 Mon Sep 17 00:00:00 2001 From: "DESKTOP-2S5P7D1\\Windows 10" Date: Mon, 4 Sep 2023 17:58:00 +0700 Subject: [PATCH 4/4] =?UTF-8?q?total=20=E0=B8=82=E0=B8=A31-2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reports/InsigniaReportRepository.cs | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs b/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs index cbe34be6..bc2c4d60 100644 --- a/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs +++ b/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs @@ -198,27 +198,7 @@ namespace BMA.EHR.Application.Repositories.Reports G9Female = g.Sum(x => x.Gendor == "หญิง" ? 1 : 0), }).ToList(); - return new - { - G1Male = insignia.Sum(x => x.G1Male), - G1Female = insignia.Sum(x => x.G1Female), - G2Male = insignia.Sum(x => x.G2Male), - G2Female = insignia.Sum(x => x.G2Female), - G3Male = insignia.Sum(x => x.G3Male), - G3Female = insignia.Sum(x => x.G3Female), - G4Male = insignia.Sum(x => x.G4Male), - G4Female = insignia.Sum(x => x.G4Female), - G5Male = insignia.Sum(x => x.G5Male), - G5Female = insignia.Sum(x => x.G5Female), - G6Male = insignia.Sum(x => x.G6Male), - G6Female = insignia.Sum(x => x.G6Female), - G7Male = insignia.Sum(x => x.G7Male), - G7Female = insignia.Sum(x => x.G7Female), - G8Male = insignia.Sum(x => x.G8Male), - G8Female = insignia.Sum(x => x.G8Female), - G9Male = insignia.Sum(x => x.G9Male), - G9Female = insignia.Sum(x => x.G9Female), - }; + return insignia; } public async Task GetKhr2TotalReport(Guid id) @@ -268,7 +248,27 @@ namespace BMA.EHR.Application.Repositories.Reports G9Female = g.Sum(x => x.Gendor == "หญิง" ? 1 : 0), }).ToList(); - return insignia; + return new + { + G1Male = insignia.Sum(x => x.G1Male), + G1Female = insignia.Sum(x => x.G1Female), + G2Male = insignia.Sum(x => x.G2Male), + G2Female = insignia.Sum(x => x.G2Female), + G3Male = insignia.Sum(x => x.G3Male), + G3Female = insignia.Sum(x => x.G3Female), + G4Male = insignia.Sum(x => x.G4Male), + G4Female = insignia.Sum(x => x.G4Female), + G5Male = insignia.Sum(x => x.G5Male), + G5Female = insignia.Sum(x => x.G5Female), + G6Male = insignia.Sum(x => x.G6Male), + G6Female = insignia.Sum(x => x.G6Female), + G7Male = insignia.Sum(x => x.G7Male), + G7Female = insignia.Sum(x => x.G7Female), + G8Male = insignia.Sum(x => x.G8Male), + G8Female = insignia.Sum(x => x.G8Female), + G9Male = insignia.Sum(x => x.G9Male), + G9Female = insignia.Sum(x => x.G9Female), + }; } public async Task GetKhr3Report(Guid id)