From 9136cb8d8a6e77c5f58a51d9946e1f88bc14fca6 Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Mon, 31 Mar 2025 12:17:10 +0700 Subject: [PATCH] =?UTF-8?q?add=20PositionLeaveName=20=E0=B9=83=E0=B8=99?= =?UTF-8?q?=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=87=E0=B8=B2=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Profiles/GetProfileByKeycloakIdDto.cs | 2 + .../Controllers/LeaveReportController.cs | 194 ++++++++---------- 2 files changed, 88 insertions(+), 108 deletions(-) diff --git a/BMA.EHR.Application/Responses/Profiles/GetProfileByKeycloakIdDto.cs b/BMA.EHR.Application/Responses/Profiles/GetProfileByKeycloakIdDto.cs index 72213b96..b9ac4725 100644 --- a/BMA.EHR.Application/Responses/Profiles/GetProfileByKeycloakIdDto.cs +++ b/BMA.EHR.Application/Responses/Profiles/GetProfileByKeycloakIdDto.cs @@ -79,6 +79,8 @@ namespace BMA.EHR.Application.Responses.Profiles public string? CurrentZipCode { get; set; } + public string? PositionLeaveName { get; set; } + } public class PosLevel diff --git a/BMA.EHR.Leave/Controllers/LeaveReportController.cs b/BMA.EHR.Leave/Controllers/LeaveReportController.cs index 0995f218..cf530522 100644 --- a/BMA.EHR.Leave/Controllers/LeaveReportController.cs +++ b/BMA.EHR.Leave/Controllers/LeaveReportController.cs @@ -146,18 +146,6 @@ namespace BMA.EHR.Leave.Service.Controllers // approver = list.First().Name; //} - var orgName = ""; - if (profile.Child1 != null && profile.Child1 != "") - orgName += $" {profile.Child1}"; - if (profile.Child2 != null && profile.Child2 != "") - orgName += $" {profile.Child2}"; - if (profile.Child3 != null && profile.Child3 != "") - orgName += $" {profile.Child3}"; - if (profile.Child4 != null && profile.Child4 != "") - orgName += $" {profile.Child4}"; - if (profile.Root != null && profile.Root != "") - orgName += $" {profile.Root}"; - var sumLeave = await _leaveRequestRepository.GetSumApproveLeaveByTypeForUserAsync(data.KeycloakUserId, data.Type.Id, data.LeaveStartDate.Year); return new @@ -172,8 +160,8 @@ namespace BMA.EHR.Leave.Service.Controllers dear = data.Dear, fullname = fullName, positionName = profile!.Position == null ? "-" : profile!.Position, - positionLeaveName = profile!.PosLevel == null ? "-" : profile!.PosLevel, - organizationName = orgName, + positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName, + organizationName = profile.Oc, leaveDetail = data.LeaveDetail, leaveDateStart = data.LeaveStartDate.Date.ToThaiShortDate(), leaveDateEnd = data.LeaveEndDate.Date.ToThaiShortDate(), @@ -209,17 +197,7 @@ namespace BMA.EHR.Leave.Service.Controllers // approver = list.First().Name; //} - var orgName = ""; - if (profile.Child1 != null && profile.Child1 != "") - orgName += $" {profile.Child1}"; - if (profile.Child2 != null && profile.Child2 != "") - orgName += $" {profile.Child2}"; - if (profile.Child3 != null && profile.Child3 != "") - orgName += $" {profile.Child3}"; - if (profile.Child4 != null && profile.Child4 != "") - orgName += $" {profile.Child4}"; - if (profile.Root != null && profile.Root != "") - orgName += $" {profile.Root}"; + return new { @@ -233,7 +211,7 @@ namespace BMA.EHR.Leave.Service.Controllers dear = data.Dear, fullname = fullName, positionName = profile!.Position == null ? "-" : profile!.Position, - positionLeaveName = profile!.Position == null ? "-" : profile!.Position, + positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName, organizationName = profile!.Oc ?? "", wifeDayName = data.WifeDayName ?? "", wifeDayDateBorn = data.WifeDayDateBorn ?? "", @@ -256,14 +234,14 @@ namespace BMA.EHR.Leave.Service.Controllers var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}"; - var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); - var approver = string.Empty; - if (rootOc != null) - { - var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty); - if (list.Count > 0) - approver = list.First().Name; - } + //var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); + //var approver = string.Empty; + //if (rootOc != null) + //{ + // var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty); + // if (list.Count > 0) + // approver = list.First().Name; + //} var sumLeave = await _leaveRequestRepository.GetSumApproveLeaveByTypeForUserAsync(data.KeycloakUserId, data.Type.Id, data.LeaveStartDate.Year); @@ -276,10 +254,10 @@ namespace BMA.EHR.Leave.Service.Controllers leaveWrote = data.LeaveWrote ?? "", dateSendLeave = data.CreatedAt.Date.ToThaiShortDate(), leaveTypeName = data.Type.Name, - dear = approver, + dear = data.Dear, fullname = fullName, positionName = profile!.Position == null ? "-" : profile!.Position, - positionLeaveName = profile!.Position == null ? "-" : profile!.Position, + positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName, organizationName = profile!.Oc ?? "", restDayOldTotal = data.RestDayOldTotal, @@ -307,14 +285,14 @@ namespace BMA.EHR.Leave.Service.Controllers var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}"; - var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); - var approver = string.Empty; - if (rootOc != null) - { - var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty); - if (list.Count > 0) - approver = list.First().Name; - } + //var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); + //var approver = string.Empty; + //if (rootOc != null) + //{ + // var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty); + // if (list.Count > 0) + // approver = list.First().Name; + //} if (data.HajjDayStatus == true) { @@ -327,10 +305,10 @@ namespace BMA.EHR.Leave.Service.Controllers leaveWrote = data.LeaveWrote ?? "", dateSendLeave = data.CreatedAt.Date.ToThaiShortDate(), leaveTypeName = data.Type.Name, - dear = approver, + dear = data.Dear, fullname = fullName, positionName = profile!.Position == null ? "-" : profile!.Position, - positionLeaveName = profile!.Position == null ? "-" : profile!.Position, + positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName, organizationName = profile!.Oc ?? "", @@ -355,10 +333,10 @@ namespace BMA.EHR.Leave.Service.Controllers leaveWrote = data.LeaveWrote ?? "", dateSendLeave = data.CreatedAt.Date.ToThaiShortDate(), leaveTypeName = data.Type.Name, - dear = approver, + dear = data.Dear, fullname = fullName, positionName = profile!.Position == null ? "-" : profile!.Position, - positionLeaveName = profile!.Position == null ? "-" : profile!.Position, + positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName, organizationName = profile!.Oc ?? "", leavebirthDate = data.LeaveBirthDate == null ? "" : data.LeaveBirthDate.Value.Date.ToThaiShortDate(), @@ -390,14 +368,14 @@ namespace BMA.EHR.Leave.Service.Controllers var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}"; - var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); - var approver = string.Empty; - if (rootOc != null) - { - var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty); - if (list.Count > 0) - approver = list.First().Name; - } + //var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); + //var approver = string.Empty; + //if (rootOc != null) + //{ + // var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty); + // if (list.Count > 0) + // approver = list.First().Name; + //} return new { @@ -408,10 +386,10 @@ namespace BMA.EHR.Leave.Service.Controllers leaveWrote = data.LeaveWrote ?? "", dateSendLeave = data.CreatedAt.Date.ToThaiShortDate(), leaveTypeName = data.Type.Name, - dear = approver, + dear = data.Dear, fullname = fullName, positionName = profile!.Position == null ? "-" : profile!.Position, - positionLeaveName = profile!.Position == null ? "-" : profile!.Position, + positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName, organizationName = profile!.Oc ?? "", absentDaySummon = data.AbsentDaySummon, @@ -438,14 +416,14 @@ namespace BMA.EHR.Leave.Service.Controllers var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}"; - var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); - var approver = string.Empty; - if (rootOc != null) - { - var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty); - if (list.Count > 0) - approver = list.First().Name; - } + //var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); + //var approver = string.Empty; + //if (rootOc != null) + //{ + // var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty); + // if (list.Count > 0) + // approver = list.First().Name; + //} return new { @@ -456,10 +434,10 @@ namespace BMA.EHR.Leave.Service.Controllers leaveWrote = data.LeaveWrote ?? "", dateSendLeave = data.CreatedAt.Date.ToThaiShortDate(), leaveTypeName = data.Type.Name, - dear = approver, + dear = data.Dear, fullname = fullName, positionName = profile!.Position == null ? "-" : profile!.Position, - positionLeaveName = profile!.Position == null ? "-" : profile!.Position, + positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName, organizationName = profile!.Oc ?? "", leavebirthDate = data.LeaveBirthDate == null ? "" : data.LeaveBirthDate.Value.Date.ToThaiShortDate(), @@ -493,14 +471,14 @@ namespace BMA.EHR.Leave.Service.Controllers var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}"; - var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); - var approver = string.Empty; - if (rootOc != null) - { - var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty); - if (list.Count > 0) - approver = list.First().Name; - } + //var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); + //var approver = string.Empty; + //if (rootOc != null) + //{ + // var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty); + // if (list.Count > 0) + // approver = list.First().Name; + //} return new { @@ -511,11 +489,11 @@ namespace BMA.EHR.Leave.Service.Controllers leaveWrote = data.LeaveWrote ?? "", dateSendLeave = data.CreatedAt.Date.ToThaiShortDate(), leaveTypeName = data.Type.Name, - dear = approver, + dear = data.Dear, fullname = fullName, fullnameEng = "", positionName = profile!.Position == null ? "-" : profile!.Position, - positionLeaveName = profile!.Position == null ? "-" : profile!.Position, + positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName, organizationName = profile!.Oc ?? "", leaveDateStart = data.LeaveStartDate.Date.ToThaiShortDate(), @@ -535,14 +513,14 @@ namespace BMA.EHR.Leave.Service.Controllers var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}"; - var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); - var approver = string.Empty; - if (rootOc != null) - { - var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty); - if (list.Count > 0) - approver = list.First().Name; - } + //var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); + //var approver = string.Empty; + //if (rootOc != null) + //{ + // var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty); + // if (list.Count > 0) + // approver = list.First().Name; + //} return new { @@ -553,10 +531,10 @@ namespace BMA.EHR.Leave.Service.Controllers leaveWrote = data.LeaveWrote ?? "", dateSendLeave = data.CreatedAt.Date.ToThaiShortDate(), leaveTypeName = data.Type.Name, - dear = approver, + dear = data.Dear, fullname = fullName, positionName = profile!.Position == null ? "-" : profile!.Position, - positionLeaveName = profile!.Position == null ? "-" : profile!.Position, + positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName, organizationName = profile!.Oc ?? "", leaveSalary = data.LeaveSalary, @@ -590,14 +568,14 @@ namespace BMA.EHR.Leave.Service.Controllers var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}"; - var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); - var approver = string.Empty; - if (rootOc != null) - { - var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty); - if (list.Count > 0) - approver = list.First().Name; - } + //var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); + //var approver = string.Empty; + //if (rootOc != null) + //{ + // var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty); + // if (list.Count > 0) + // approver = list.First().Name; + //} return new { @@ -608,10 +586,10 @@ namespace BMA.EHR.Leave.Service.Controllers leaveWrote = data.LeaveWrote ?? "", dateSendLeave = data.CreatedAt.Date.ToThaiShortDate(), leaveTypeName = data.Type.Name, - dear = approver, + dear = data.Dear, fullname = fullName, positionName = profile!.Position == null ? "-" : profile!.Position, - positionLeaveName = profile!.Position == null ? "-" : profile!.Position, + positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName, organizationName = profile!.Oc ?? "", @@ -740,14 +718,14 @@ namespace BMA.EHR.Leave.Service.Controllers var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}"; - var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); - var approver = string.Empty; - if (rootOc != null) - { - var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty); - if (list.Count > 0) - approver = list.First().Name; - } + //var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); + //var approver = string.Empty; + //if (rootOc != null) + //{ + // var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty); + // if (list.Count > 0) + // approver = list.First().Name; + //} var result = new { @@ -760,11 +738,11 @@ namespace BMA.EHR.Leave.Service.Controllers leaveTypeName = data.Type.Name, fullname = fullName, positionName = profile!.Position == null ? "-" : profile!.Position, - positionLeaveName = profile!.Position == null ? "-" : profile!.Position, + positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName, organizationName = profile!.Oc ?? "", leaveDateStart = data.LeaveStartDate.Date.ToThaiShortDate(), leaveDateEnd = data.LeaveEndDate.Date.ToThaiShortDate(), - dear = approver, + dear = data.Dear, leaveTotal = data.LeaveTotal } };