From f6c6fe069d2226bc0d125385b99fa9897beb305a Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Wed, 12 Feb 2025 18:33:19 +0700 Subject: [PATCH] fix issue : #1067 --- .../Controllers/InsigniaRequestController.cs | 60 ++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs index d03b7b53..97a891ed 100644 --- a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs +++ b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs @@ -388,6 +388,16 @@ namespace BMA.EHR.Insignia.Service.Controllers return Success(); } + + [HttpGet("cal-test/{period:guid}/{oc:guid}")] + public async Task> GetTestInsigniaRequest(Guid period, Guid oc) + { + var candidate = await _repository.GetInsigniaCandidateBKK(period, oc); + await _repository.InsertCandidate(period, oc, "สำนักงานเขตพระนคร", candidate); + + return Success(candidate); + } + /// /// คำนวณราชชื่อผู้ได้รับเครื่องราช /// @@ -1062,6 +1072,50 @@ namespace BMA.EHR.Insignia.Service.Controllers { if (profileOld.ProfileId == null) continue; + + var pf = _userProfileRepository.GetOfficerProfileById(profileOld.ProfileId, AccessToken); + if (pf == null) + pf = _userProfileRepository.GetEmployeeProfileById(profileOld.ProfileId, AccessToken); + + var orgSend = ""; + var orgRecv = ""; + + if (profileOld.Child4 != null || profileOld.Child4 != "") + orgSend += $"{profileOld.Child4}"; + if (profileOld.Child3 != null || profileOld.Child3 != "") + orgSend += $" {profileOld.Child3}"; + if (profileOld.Child2 != null || profileOld.Child2 != "") + orgSend += $" {profileOld.Child2}"; + if (profileOld.Child1 != null || profileOld.Child1 != "") + orgSend += $" {profileOld.Child1}"; + if (profileOld.Root != null || profileOld.Root != "") + orgSend += $" {profileOld.Root}"; + + orgSend = orgSend.Trim(); + + if (pf != null) + { + var kk = pf.Keycloak == null ? Guid.Empty : pf.Keycloak.Value; + var pfData = await _userProfileRepository.GetProfileByKeycloakIdAsync(kk, AccessToken); + if (pfData != null) + { + if (pfData.Child4 != null || pfData.Child4 != "") + orgRecv += $"{pfData.Child4}"; + if (pfData.Child3 != null || pfData.Child3 != "") + orgRecv += $" {pfData.Child3}"; + if (pfData.Child2 != null || pfData.Child2 != "") + orgRecv += $" {pfData.Child2}"; + if (pfData.Child1 != null || pfData.Child1 != "") + orgRecv += $" {pfData.Child1}"; + if (pfData.Root != null || pfData.Root != "") + orgRecv += $" {pfData.Root}"; + + + orgRecv = orgRecv.Trim(); + } + } + + await _context.InsigniaNoteProfiles.AddAsync(new InsigniaNoteProfile { RequestDate = profileOld.RequestDate, @@ -1070,7 +1124,11 @@ namespace BMA.EHR.Insignia.Service.Controllers Status = "PENDING", ProfileId = profileOld.ProfileId, RequestInsignia = profileOld.RequestInsignia, - OrganizationOrganizationSend = null, + + + OrganizationOrganizationSend = orgSend, + OrganizationOrganizationReceive = orgRecv, + InsigniaNote = insigniaNote, CreatedFullName = FullName ?? "System Administrator", CreatedUserId = UserId ?? "",