From b5c82f42431912fa7facc5cd0e0da78e779e1c34 Mon Sep 17 00:00:00 2001 From: harid Date: Mon, 19 Jan 2026 12:13:45 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B1=E0=B8=9A=E0=B8=A3?= =?UTF-8?q?=E0=B8=B2=E0=B8=A2=E0=B8=87=E0=B8=B2=E0=B8=99=E0=B8=A5=E0=B8=B2?= =?UTF-8?q?=20#2195?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/LeaveReportController.cs | 283 +++++++++++++++--- .../Controllers/LeaveRequestController.cs | 11 +- 2 files changed, 258 insertions(+), 36 deletions(-) diff --git a/BMA.EHR.Leave/Controllers/LeaveReportController.cs b/BMA.EHR.Leave/Controllers/LeaveReportController.cs index 8625497b..0dec80c6 100644 --- a/BMA.EHR.Leave/Controllers/LeaveReportController.cs +++ b/BMA.EHR.Leave/Controllers/LeaveReportController.cs @@ -165,9 +165,28 @@ namespace BMA.EHR.Leave.Service.Controllers leaveSubTypeName = data.LeaveSubTypeName != null ? data.LeaveSubTypeName.ToThaiNumber() : "", dear = data.CommanderPosition == null ? data.Dear : data.CommanderPosition.ToThaiNumber(), fullname = fullName, - positionName = profile!.Position == null ? "-" : profile!.Position.ToThaiNumber(), + position = string.IsNullOrEmpty(profile.Position) ? "-" : profile.Position, + positionName = (!string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? string.IsNullOrEmpty(profile.PosExecutiveName) + ? string.IsNullOrEmpty(profile.Position) + ? "-" + : profile.Position + : profile.PosExecutiveName + : string.IsNullOrEmpty(profile.Position) + ? "-" + : string.IsNullOrEmpty(profile.PositionLeaveName) + ? profile.Position + : $"{profile.Position}{profile.PositionLeaveName}").ToThaiNumber(), positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName.ToThaiNumber(), + posExecutiveName = profile.PosExecutiveName, organizationName = profile!.Oc!.ToThaiNumber(), + posExOrg = !string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? new[] { (profile!.Oc!.ToThaiNumber()) } + : !string.IsNullOrEmpty(profile.PosExecutiveName) + ? new[] { (profile.PosExecutiveName.ToThaiNumber()), (profile!.Oc!.ToThaiNumber()) } + : new[] { (profile!.Oc!.ToThaiNumber()) }, leaveDetail = data.LeaveDetail.ToThaiNumber(), leaveDateStart = data.LeaveStartDate.Date.ToThaiShortDate().ToThaiNumber(), leaveDateEnd = data.LeaveEndDate.Date.ToThaiShortDate().ToThaiNumber(), @@ -228,9 +247,28 @@ namespace BMA.EHR.Leave.Service.Controllers leaveSubTypeName = data.LeaveSubTypeName != null ? data.LeaveSubTypeName.ToThaiNumber() : "", dear = data.CommanderPosition == null ? data.Dear : data.CommanderPosition.ToThaiNumber(), fullname = fullName, - positionName = profile!.Position == null ? "-" : profile!.Position.ToThaiNumber(), + position = string.IsNullOrEmpty(profile.Position) ? "-" : profile.Position, + positionName = (!string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? string.IsNullOrEmpty(profile.PosExecutiveName) + ? string.IsNullOrEmpty(profile.Position) + ? "-" + : profile.Position + : profile.PosExecutiveName + : string.IsNullOrEmpty(profile.Position) + ? "-" + : string.IsNullOrEmpty(profile.PositionLeaveName) + ? profile.Position + : $"{profile.Position}{profile.PositionLeaveName}").ToThaiNumber(), positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName.ToThaiNumber(), - organizationName = profile!.Oc!.ToThaiNumber() ?? "", + posExecutiveName = profile.PosExecutiveName, + organizationName = profile!.Oc!.ToThaiNumber(), + posExOrg = !string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? new[] { (profile!.Oc!.ToThaiNumber()) } + : !string.IsNullOrEmpty(profile.PosExecutiveName) + ? new[] { (profile.PosExecutiveName.ToThaiNumber()), (profile!.Oc!.ToThaiNumber()) } + : new[] { (profile!.Oc!.ToThaiNumber()) }, wifeDayName = data.WifeDayName ?? "", wifeDayDateBorn = data.WifeDayDateBorn == null || data.WifeDayDateBorn == "" ? "" : DateTime.Parse(data.WifeDayDateBorn).ToThaiShortDate().ToThaiNumber(), leaveDateStart = data.LeaveStartDate.Date.ToThaiShortDate().ToThaiNumber(), @@ -289,9 +327,28 @@ namespace BMA.EHR.Leave.Service.Controllers leaveSubTypeName = data.LeaveSubTypeName != null ? data.LeaveSubTypeName.ToThaiNumber() : "", dear = data.CommanderPosition == null ? data.Dear : data.CommanderPosition.ToThaiNumber(), fullname = fullName, - positionName = profile!.Position == null ? "-" : profile!.Position.ToThaiNumber(), + position = string.IsNullOrEmpty(profile.Position) ? "-" : profile.Position, + positionName = (!string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? string.IsNullOrEmpty(profile.PosExecutiveName) + ? string.IsNullOrEmpty(profile.Position) + ? "-" + : profile.Position + : profile.PosExecutiveName + : string.IsNullOrEmpty(profile.Position) + ? "-" + : string.IsNullOrEmpty(profile.PositionLeaveName) + ? profile.Position + : $"{profile.Position}{profile.PositionLeaveName}").ToThaiNumber(), positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName.ToThaiNumber(), - organizationName = profile!.Oc!.ToThaiNumber() ?? "", + posExecutiveName = profile.PosExecutiveName, + organizationName = profile!.Oc!.ToThaiNumber(), + posExOrg = !string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? new[] { (profile!.Oc!.ToThaiNumber()) } + : !string.IsNullOrEmpty(profile.PosExecutiveName) + ? new[] { (profile.PosExecutiveName.ToThaiNumber()), (profile!.Oc!.ToThaiNumber()) } + : new[] { (profile!.Oc!.ToThaiNumber()) }, restDayOldTotal = extendLeave.ToString().ToThaiNumber(), restDayCurrentTotal = (10).ToString().ToThaiNumber(), @@ -357,9 +414,28 @@ namespace BMA.EHR.Leave.Service.Controllers leaveSubTypeName = data.LeaveSubTypeName != null ? data.LeaveSubTypeName.ToThaiNumber() : "", dear = data.CommanderPosition == null ? data.Dear : data.CommanderPosition.ToThaiNumber(), fullname = fullName, - positionName = profile!.Position == null ? "-" : profile!.Position.ToThaiNumber(), + position = string.IsNullOrEmpty(profile.Position) ? "-" : profile.Position, + positionName = (!string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? string.IsNullOrEmpty(profile.PosExecutiveName) + ? string.IsNullOrEmpty(profile.Position) + ? "-" + : profile.Position + : profile.PosExecutiveName + : string.IsNullOrEmpty(profile.Position) + ? "-" + : string.IsNullOrEmpty(profile.PositionLeaveName) + ? profile.Position + : $"{profile.Position}{profile.PositionLeaveName}").ToThaiNumber(), positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName.ToThaiNumber(), - organizationName = profile!.Oc!.ToThaiNumber() ?? "", + posExecutiveName = profile.PosExecutiveName, + organizationName = profile!.Oc!.ToThaiNumber(), + posExOrg = !string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? new[] { (profile!.Oc!.ToThaiNumber()) } + : !string.IsNullOrEmpty(profile.PosExecutiveName) + ? new[] { (profile.PosExecutiveName.ToThaiNumber()), (profile!.Oc!.ToThaiNumber()) } + : new[] { (profile!.Oc!.ToThaiNumber()) }, leavegovernmentDate = data.LeaveGovernmentDate == null ? "" : data.LeaveGovernmentDate.Value.Date.ToThaiShortDate().ToThaiNumber(), @@ -393,9 +469,28 @@ namespace BMA.EHR.Leave.Service.Controllers leaveSubTypeName = data.LeaveSubTypeName != null ? data.LeaveSubTypeName.ToThaiNumber() : "", dear = data.CommanderPosition == null ? data.Dear : data.CommanderPosition.ToThaiNumber(), fullname = fullName, - positionName = profile!.Position == null ? "-" : profile!.Position.ToThaiNumber(), + position = string.IsNullOrEmpty(profile.Position) ? "-" : profile.Position, + positionName = (!string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? string.IsNullOrEmpty(profile.PosExecutiveName) + ? string.IsNullOrEmpty(profile.Position) + ? "-" + : profile.Position + : profile.PosExecutiveName + : string.IsNullOrEmpty(profile.Position) + ? "-" + : string.IsNullOrEmpty(profile.PositionLeaveName) + ? profile.Position + : $"{profile.Position}{profile.PositionLeaveName}").ToThaiNumber(), positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName.ToThaiNumber(), - organizationName = profile!.Oc!.ToThaiNumber() ?? "", + posExecutiveName = profile.PosExecutiveName, + organizationName = profile!.Oc!.ToThaiNumber(), + posExOrg = !string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? new[] { (profile!.Oc!.ToThaiNumber()) } + : !string.IsNullOrEmpty(profile.PosExecutiveName) + ? new[] { (profile.PosExecutiveName.ToThaiNumber()), (profile!.Oc!.ToThaiNumber()) } + : new[] { (profile!.Oc!.ToThaiNumber()) }, leavebirthDate = data.LeaveBirthDate == null ? "" : data.LeaveBirthDate.Value.Date.ToThaiShortDate().ToThaiNumber(), leavegovernmentDate = data.LeaveGovernmentDate == null ? "" : data.LeaveGovernmentDate.Value.Date.ToThaiShortDate().ToThaiNumber(), @@ -454,9 +549,28 @@ namespace BMA.EHR.Leave.Service.Controllers leaveSubTypeName = data.LeaveSubTypeName != null ? data.LeaveSubTypeName.ToThaiNumber() : "", dear = data.CommanderPosition == null ? data.Dear : data.CommanderPosition.ToThaiNumber(), fullname = fullName, - positionName = profile!.Position == null ? "-" : profile!.Position.ToThaiNumber(), + position = string.IsNullOrEmpty(profile.Position) ? "-" : profile.Position, + positionName = (!string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? string.IsNullOrEmpty(profile.PosExecutiveName) + ? string.IsNullOrEmpty(profile.Position) + ? "-" + : profile.Position + : profile.PosExecutiveName + : string.IsNullOrEmpty(profile.Position) + ? "-" + : string.IsNullOrEmpty(profile.PositionLeaveName) + ? profile.Position + : $"{profile.Position}{profile.PositionLeaveName}").ToThaiNumber(), positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName.ToThaiNumber(), - organizationName = profile!.Oc!.ToThaiNumber() ?? "", + posExecutiveName = profile.PosExecutiveName, + organizationName = profile!.Oc!.ToThaiNumber(), + posExOrg = !string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? new[] { (profile!.Oc!.ToThaiNumber()) } + : !string.IsNullOrEmpty(profile.PosExecutiveName) + ? new[] { (profile.PosExecutiveName.ToThaiNumber()), (profile!.Oc!.ToThaiNumber()) } + : new[] { (profile!.Oc!.ToThaiNumber()) }, absentDaySummon = data.AbsentDaySummon.ToThaiNumber(), absentDayLocation = data.AbsentDayLocation.ToThaiNumber(), @@ -509,9 +623,28 @@ namespace BMA.EHR.Leave.Service.Controllers leaveSubTypeName = data.LeaveSubTypeName != null ? data.LeaveSubTypeName.ToThaiNumber() : "", dear = data.CommanderPosition == null ? data.Dear : data.CommanderPosition.ToThaiNumber(), fullname = fullName, - positionName = profile!.Position == null ? "-" : profile!.Position.ToThaiNumber(), + position = string.IsNullOrEmpty(profile.Position) ? "-" : profile.Position, + positionName = (!string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? string.IsNullOrEmpty(profile.PosExecutiveName) + ? string.IsNullOrEmpty(profile.Position) + ? "-" + : profile.Position + : profile.PosExecutiveName + : string.IsNullOrEmpty(profile.Position) + ? "-" + : string.IsNullOrEmpty(profile.PositionLeaveName) + ? profile.Position + : $"{profile.Position}{profile.PositionLeaveName}").ToThaiNumber(), positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName.ToThaiNumber(), - organizationName = profile!.Oc!.ToThaiNumber() ?? "", + posExecutiveName = profile.PosExecutiveName, + organizationName = profile!.Oc!.ToThaiNumber(), + posExOrg = !string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? new[] { (profile!.Oc!.ToThaiNumber()) } + : !string.IsNullOrEmpty(profile.PosExecutiveName) + ? new[] { (profile.PosExecutiveName.ToThaiNumber()), (profile!.Oc!.ToThaiNumber()) } + : new[] { (profile!.Oc!.ToThaiNumber()) }, leavebirthDate = data.LeaveBirthDate == null ? "" : data.LeaveBirthDate.Value.Date.ToThaiShortDate().ToThaiNumber(), leavegovernmentDate = data.LeaveGovernmentDate == null ? "" : data.LeaveGovernmentDate.Value.Date.ToThaiShortDate().ToThaiNumber(), @@ -587,9 +720,28 @@ namespace BMA.EHR.Leave.Service.Controllers dear = data.CommanderPosition == null ? data.Dear : data.CommanderPosition.ToThaiNumber(), fullname = fullName, fullnameEng = "", - positionName = profile!.Position == null ? "-" : profile!.Position.ToThaiNumber(), + position = string.IsNullOrEmpty(profile.Position) ? "-" : profile.Position, + positionName = (!string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? string.IsNullOrEmpty(profile.PosExecutiveName) + ? string.IsNullOrEmpty(profile.Position) + ? "-" + : profile.Position + : profile.PosExecutiveName + : string.IsNullOrEmpty(profile.Position) + ? "-" + : string.IsNullOrEmpty(profile.PositionLeaveName) + ? profile.Position + : $"{profile.Position}{profile.PositionLeaveName}").ToThaiNumber(), positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName.ToThaiNumber(), - organizationName = profile!.Oc!.ToThaiNumber() ?? "", + posExecutiveName = profile.PosExecutiveName, + organizationName = profile!.Oc!.ToThaiNumber(), + posExOrg = !string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? new[] { (profile!.Oc!.ToThaiNumber()) } + : !string.IsNullOrEmpty(profile.PosExecutiveName) + ? new[] { (profile.PosExecutiveName.ToThaiNumber()), (profile!.Oc!.ToThaiNumber()) } + : new[] { (profile!.Oc!.ToThaiNumber()) }, leaveDateStart = data.LeaveStartDate.Date.ToThaiShortDate().ToThaiNumber(), leaveDateEnd = data.LeaveEndDate.Date.ToThaiShortDate().ToThaiNumber(), @@ -679,9 +831,28 @@ namespace BMA.EHR.Leave.Service.Controllers leaveSubTypeName = data.LeaveSubTypeName != null ? data.LeaveSubTypeName.ToThaiNumber() : "", dear = data.CommanderPosition == null ? data.Dear : data.CommanderPosition.ToThaiNumber(), fullname = fullName, - positionName = profile!.Position == null ? "-" : profile!.Position.ToThaiNumber(), + position = string.IsNullOrEmpty(profile.Position) ? "-" : profile.Position, + positionName = (!string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? string.IsNullOrEmpty(profile.PosExecutiveName) + ? string.IsNullOrEmpty(profile.Position) + ? "-" + : profile.Position + : profile.PosExecutiveName + : string.IsNullOrEmpty(profile.Position) + ? "-" + : string.IsNullOrEmpty(profile.PositionLeaveName) + ? profile.Position + : $"{profile.Position}{profile.PositionLeaveName}").ToThaiNumber(), positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName.ToThaiNumber(), - organizationName = profile!.Oc!.ToThaiNumber() ?? "", + posExecutiveName = profile.PosExecutiveName, + organizationName = profile!.Oc!.ToThaiNumber(), + posExOrg = !string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? new[] { (profile!.Oc!.ToThaiNumber()) } + : !string.IsNullOrEmpty(profile.PosExecutiveName) + ? new[] { (profile.PosExecutiveName.ToThaiNumber()), (profile!.Oc!.ToThaiNumber()) } + : new[] { (profile!.Oc!.ToThaiNumber()) }, leaveSalary = data.LeaveSalary == null ? "" : data.LeaveSalary.Value.ToNumericText().ToThaiNumber(), leaveSalaryText = data.LeaveSalaryText.ToThaiNumber(), @@ -748,9 +919,28 @@ namespace BMA.EHR.Leave.Service.Controllers leaveSubTypeName = data.LeaveSubTypeName != null ? data.LeaveSubTypeName.ToThaiNumber() : "", dear = data.CommanderPosition == null ? data.Dear : data.CommanderPosition.ToThaiNumber(), fullname = fullName, - positionName = profile!.Position == null ? "-" : profile!.Position.ToThaiNumber(), + position = string.IsNullOrEmpty(profile.Position) ? "-" : profile.Position, + positionName = (!string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? string.IsNullOrEmpty(profile.PosExecutiveName) + ? string.IsNullOrEmpty(profile.Position) + ? "-" + : profile.Position + : profile.PosExecutiveName + : string.IsNullOrEmpty(profile.Position) + ? "-" + : string.IsNullOrEmpty(profile.PositionLeaveName) + ? profile.Position + : $"{profile.Position}{profile.PositionLeaveName}").ToThaiNumber(), positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName.ToThaiNumber(), - organizationName = profile!.Oc!.ToThaiNumber() ?? "", + posExecutiveName = profile.PosExecutiveName, + organizationName = profile!.Oc!.ToThaiNumber(), + posExOrg = !string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? new[] { (profile!.Oc!.ToThaiNumber()) } + : !string.IsNullOrEmpty(profile.PosExecutiveName) + ? new[] { (profile.PosExecutiveName.ToThaiNumber()), (profile!.Oc!.ToThaiNumber()) } + : new[] { (profile!.Oc!.ToThaiNumber()) }, leaveDateStart = data.LeaveStartDate.Date.ToThaiShortDate().ToThaiNumber(), leaveDateEnd = data.LeaveEndDate.Date.ToThaiShortDate().ToThaiNumber(), @@ -2606,11 +2796,12 @@ namespace BMA.EHR.Leave.Service.Controllers { var _default = new { - fullName = "......................", - positionName = "......................", - positionSign = "......................", - updatedAt = "...... /...... /......", - comment = "......................", + fullName = "............................................", + positionName = "............................................", + posExOrg = Array.Empty(), + positionSign = "............................................", + updatedAt = "............/............/............", + comment = "......................................................................................................................................................................", approveType = "" }; @@ -2618,37 +2809,61 @@ namespace BMA.EHR.Leave.Service.Controllers .Select(x => new { fullName = $"{(x.Prefix ?? "")}{(x.FirstName ?? "")} {(x.LastName ?? "")}".Trim(), - positionName = x.PositionName ?? "......................", - positionSign = x.PositionSign ?? "......................", + positionName = (!string.IsNullOrEmpty(x.PositionLevelName) && + (x.PositionLevelName.Contains("อำนวยการ") || x.PositionLevelName.Contains("บริหาร")) + ? string.IsNullOrEmpty(x.PosExecutiveName) + ? string.IsNullOrEmpty(x.PositionName) + ? "............................................" + : x.PositionName + : x.PosExecutiveName + : string.IsNullOrEmpty(x.PositionName) + ? "............................................" + : string.IsNullOrEmpty(x.PositionLevelName) + ? x.PositionName + : $"{x.PositionName}{x.PositionLevelName}").ToThaiNumber(), + posExOrg = !string.IsNullOrEmpty(x.PositionLevelName) && + (x.PositionLevelName.Contains("อำนวยการ") || x.PositionLevelName.Contains("บริหาร")) + ? new[] { (x!.OrganizationName!.ToThaiNumber()) } + : !string.IsNullOrEmpty(x.PosExecutiveName) + ? new[] { (x.PosExecutiveName.ToThaiNumber()), (x!.OrganizationName!.ToThaiNumber()) } + : new[] { (x!.OrganizationName!.ToThaiNumber()) }, + positionSign = !string.IsNullOrEmpty(x.PositionSign) + ? x.PositionSign.Replace("\r", "").Replace("\n", " ") + : "............................................", updatedAt = x.LastUpdatedAt.HasValue ? x.LastUpdatedAt.Value.Date.ToThaiShortDate().ToThaiNumber() - : "...... /...... /......", - comment = !string.IsNullOrEmpty(x.Comment) - ? x.Comment.Replace("\r", "").Replace("\n", "").Trim() - : "......................", + : "............/............/............", + comment = !string.IsNullOrEmpty(x.Comment) + ? x.Comment.Replace("\r", "").Replace("\n", " ").Trim() + : "......................................................................................................................................................................", approveType = (x.ApproveType ?? "").Trim().ToUpper() }) .ToList(); + // การเจ้าหน้าที่ var sender = approvers .FirstOrDefault(x => x.approveType == "SENDER") ?? _default; - var approver = approvers - .FirstOrDefault(x => x.approveType == "APPROVER") - ?? _default; - + // ผู้บังคับบัญชา (มีได้มากกว่า 1 คน) var commanders = approvers .Where(x => x.approveType == "COMMANDER") .DefaultIfEmpty(_default) .ToList(); + // ผู้มีอำนาจ + var approver = approvers + .FirstOrDefault(x => x.approveType == "APPROVER") + ?? _default; + return new { + sign = "............................................", sender = sender, approver = approver, commanders = commanders }; + } } diff --git a/BMA.EHR.Leave/Controllers/LeaveRequestController.cs b/BMA.EHR.Leave/Controllers/LeaveRequestController.cs index 4db84d53..dc3afc62 100644 --- a/BMA.EHR.Leave/Controllers/LeaveRequestController.cs +++ b/BMA.EHR.Leave/Controllers/LeaveRequestController.cs @@ -166,7 +166,14 @@ namespace BMA.EHR.Leave.Service.Controllers ProfileId = r.ProfileId, KeycloakId = r.KeycloakId, ApproveStatus = "PENDING", - ApproveType = type.Trim().ToUpper() + ApproveType = type.Trim().ToUpper(), + + CreatedFullName = FullName ?? "", + CreatedUserId = UserId!, + CreatedAt = DateTime.Now, + LastUpdateFullName = FullName ?? "", + LastUpdateUserId = UserId!, + LastUpdatedAt = DateTime.Now, }); } @@ -2033,7 +2040,7 @@ namespace BMA.EHR.Leave.Service.Controllers Prefix = profile.Prefix ?? "", FirstName = profile.FirstName ?? "", LastName = profile.LastName ?? "", - PositionName = $"{profile.Position ?? ""}{profile.PositionLeaveName ?? ""}", + PositionName = $"{profile.Position ?? ""}", ProfileId = profile.Id, KeycloakId = Guid.Parse(UserId!), ApproveType = "SENDER",