From 6b9407f02ae67b3f4f6e4c85c9ba70805f4f6479 Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Mon, 8 Jul 2024 21:31:33 +0700 Subject: [PATCH] fix : RDEN Download --- .../Controllers/InsigniaRequestController.cs | 82 ++++++++++++------- 1 file changed, 52 insertions(+), 30 deletions(-) diff --git a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs index 26726ba9..4246f398 100644 --- a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs +++ b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs @@ -2310,28 +2310,28 @@ namespace BMA.EHR.Insignia.Service.Controllers var row = 2; foreach (var item in requestProfiles) { - var profile = _userProfileRepository.GetOfficerProfileById(item.ProfileId, AccessToken); + //var profile = _userProfileRepository.GetOfficerProfileById(item.ProfileId, AccessToken); workSheet.Cells[row, 1].Value = _userProfileRepository.GetOc(insigniaPeriod.OrganizationId, 0, AccessToken).Root; - workSheet.Cells[row, 2].Value = profile.CitizenId; - workSheet.Cells[row, 3].Value = profile.Prefix == null ? "-" : ((profile.Prefix == "นาย" || profile.Prefix == "นาง" || profile.Prefix == "นางสาว") ? profile.Prefix : "-"); - workSheet.Cells[row, 4].Value = profile.Prefix == null ? "-" : ((profile.Prefix == "นาย" || profile.Prefix == "นาง" || profile.Prefix == "นางสาว") ? "-" : profile.Prefix); - workSheet.Cells[row, 5].Value = profile.FirstName; - workSheet.Cells[row, 6].Value = profile.LastName; - workSheet.Cells[row, 7].Value = profile.Gender == null ? "-" : profile.Gender; - workSheet.Cells[row, 8].Value = profile.BirthDate.ToThaiDate(); - workSheet.Cells[row, 9].Value = profile.DateAppoint == null ? null : profile.DateAppoint.Value.ToThaiDate(); + workSheet.Cells[row, 2].Value = item.CitizenId; + workSheet.Cells[row, 3].Value = item.Prefix == null ? "-" : ((item.Prefix == "นาย" || item.Prefix == "นาง" || item.Prefix == "นางสาว") ? item.Prefix : "-"); + workSheet.Cells[row, 4].Value = item.Prefix == null ? "-" : ((item.Prefix == "นาย" || item.Prefix == "นาง" || item.Prefix == "นางสาว") ? "-" : item.Prefix); + workSheet.Cells[row, 5].Value = item.FirstName; + workSheet.Cells[row, 6].Value = item.LastName; + workSheet.Cells[row, 7].Value = item.Gender == null ? "-" : item.Gender; + workSheet.Cells[row, 8].Value = item.BirthDate == null ? "" : item.BirthDate.Value.ToThaiDate(); + workSheet.Cells[row, 9].Value = item.DateAppoint == null ? "" : item.DateAppoint.Value.ToThaiDate(); // workSheet.Cells[row, 10].Value = null; - //workSheet.Cells[row, 11].Value = item.Profile.Position == null ? null : item.Profile.Position.Name; + //workSheet.Cells[row, 11].Value = item.Position == null ? "" : item.Position; workSheet.Cells[row, 12].Value = ""; - workSheet.Cells[row, 13].Value = profile.PosLevel == null ? null : profile.PosLevel.PosLevelName; + workSheet.Cells[row, 13].Value = item.PosLevelName == null ? "" : item.PosLevelName; workSheet.Cells[row, 14].Value = ""; workSheet.Cells[row, 15].Value = null; - workSheet.Cells[row, 16].Value = profile.Position ?? ""; - workSheet.Cells[row, 17].Value = profile.ProfileSalary == null ? null : profile.ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().Amount; + workSheet.Cells[row, 16].Value = item.Position ?? ""; + workSheet.Cells[row, 17].Value = item.Amount == null ? 0 : item.Amount; workSheet.Cells[row, 18].Value = null; - workSheet.Cells[row, 19].Value = profile.ProfileSalary == null ? null : profile.ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount; - workSheet.Cells[row, 20].Value = ""; + workSheet.Cells[row, 19].Value = item.PositionSalaryAmount == null ? 0 : item.PositionSalaryAmount; + workSheet.Cells[row, 20].Value = item.LastInsigniaName; workSheet.Cells[row, 21].Value = ""; workSheet.Cells[row, 22].Value = null; row++; @@ -2409,27 +2409,49 @@ namespace BMA.EHR.Insignia.Service.Controllers var row = 2; foreach (var item in requestProfiles) { - var profile = _userProfileRepository.GetOfficerProfileById(item.ProfileId, AccessToken); + //var profile = _userProfileRepository.GetOfficerProfileById(item.ProfileId, AccessToken); + //workSheet.Cells[row, 1].Value = _userProfileRepository.GetOc(insigniaPeriod.OrganizationId, 0, AccessToken).Root; + //workSheet.Cells[row, 2].Value = profile.CitizenId; + //workSheet.Cells[row, 3].Value = profile.Prefix == null ? "-" : ((profile.Prefix == "นาย" || profile.Prefix == "นาง" || profile.Prefix == "นางสาว") ? profile.Prefix : "-"); + //workSheet.Cells[row, 4].Value = profile.Prefix == null ? "-" : ((profile.Prefix == "นาย" || profile.Prefix == "นาง" || profile.Prefix == "นางสาว") ? "-" : profile.Prefix); + //workSheet.Cells[row, 5].Value = profile.FirstName; + //workSheet.Cells[row, 6].Value = profile.LastName; + //workSheet.Cells[row, 7].Value = profile.Gender == null ? "-" : profile.Gender; + //workSheet.Cells[row, 8].Value = profile.BirthDate.ToThaiDate(); + //workSheet.Cells[row, 9].Value = profile.DateAppoint == null ? null : profile.DateAppoint.Value.ToThaiDate(); + //// workSheet.Cells[row, 10].Value = null; + //// workSheet.Cells[row, 11].Value = item.Profile.Position == null ? null : item.Profile.Position.Name; + //workSheet.Cells[row, 12].Value = ""; + //workSheet.Cells[row, 13].Value = profile.PosLevel == null ? null : profile.PosLevel.PosLevelName; + //workSheet.Cells[row, 14].Value = ""; + //workSheet.Cells[row, 15].Value = null; + //workSheet.Cells[row, 16].Value = profile.Position == null ? "-" : profile.Position; + //workSheet.Cells[row, 17].Value = profile.ProfileSalary == null ? 0 : profile.ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().Amount; + //workSheet.Cells[row, 18].Value = null; + //workSheet.Cells[row, 19].Value = profile.ProfileSalary == null ? 0 : profile.ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount; + //workSheet.Cells[row, 20].Value = ""; + //workSheet.Cells[row, 21].Value = ""; + //workSheet.Cells[row, 22].Value = null; workSheet.Cells[row, 1].Value = _userProfileRepository.GetOc(insigniaPeriod.OrganizationId, 0, AccessToken).Root; - workSheet.Cells[row, 2].Value = profile.CitizenId; - workSheet.Cells[row, 3].Value = profile.Prefix == null ? "-" : ((profile.Prefix == "นาย" || profile.Prefix == "นาง" || profile.Prefix == "นางสาว") ? profile.Prefix : "-"); - workSheet.Cells[row, 4].Value = profile.Prefix == null ? "-" : ((profile.Prefix == "นาย" || profile.Prefix == "นาง" || profile.Prefix == "นางสาว") ? "-" : profile.Prefix); - workSheet.Cells[row, 5].Value = profile.FirstName; - workSheet.Cells[row, 6].Value = profile.LastName; - workSheet.Cells[row, 7].Value = profile.Gender == null ? "-" : profile.Gender; - workSheet.Cells[row, 8].Value = profile.BirthDate.ToThaiDate(); - workSheet.Cells[row, 9].Value = profile.DateAppoint == null ? null : profile.DateAppoint.Value.ToThaiDate(); + workSheet.Cells[row, 2].Value = item.CitizenId; + workSheet.Cells[row, 3].Value = item.Prefix == null ? "-" : ((item.Prefix == "นาย" || item.Prefix == "นาง" || item.Prefix == "นางสาว") ? item.Prefix : "-"); + workSheet.Cells[row, 4].Value = item.Prefix == null ? "-" : ((item.Prefix == "นาย" || item.Prefix == "นาง" || item.Prefix == "นางสาว") ? "-" : item.Prefix); + workSheet.Cells[row, 5].Value = item.FirstName; + workSheet.Cells[row, 6].Value = item.LastName; + workSheet.Cells[row, 7].Value = item.Gender == null ? "-" : item.Gender; + workSheet.Cells[row, 8].Value = item.BirthDate == null ? "" : item.BirthDate.Value.ToThaiDate(); + workSheet.Cells[row, 9].Value = item.DateAppoint == null ? "" : item.DateAppoint.Value.ToThaiDate(); // workSheet.Cells[row, 10].Value = null; - // workSheet.Cells[row, 11].Value = item.Profile.Position == null ? null : item.Profile.Position.Name; + //workSheet.Cells[row, 11].Value = item.Position == null ? "" : item.Position; workSheet.Cells[row, 12].Value = ""; - workSheet.Cells[row, 13].Value = profile.PosLevel == null ? null : profile.PosLevel.PosLevelName; + workSheet.Cells[row, 13].Value = item.PosLevelName == null ? "" : item.PosLevelName; workSheet.Cells[row, 14].Value = ""; workSheet.Cells[row, 15].Value = null; - workSheet.Cells[row, 16].Value = profile.Position == null ? "-" : profile.Position; - workSheet.Cells[row, 17].Value = profile.ProfileSalary == null ? 0 : profile.ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().Amount; + workSheet.Cells[row, 16].Value = item.Position ?? ""; + workSheet.Cells[row, 17].Value = item.Amount == null ? 0 : item.Amount; workSheet.Cells[row, 18].Value = null; - workSheet.Cells[row, 19].Value = profile.ProfileSalary == null ? 0 : profile.ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount; - workSheet.Cells[row, 20].Value = ""; + workSheet.Cells[row, 19].Value = item.PositionSalaryAmount == null ? 0 : item.PositionSalaryAmount; + workSheet.Cells[row, 20].Value = item.LastInsigniaName; workSheet.Cells[row, 21].Value = ""; workSheet.Cells[row, 22].Value = null; row++;