diff --git a/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs b/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs index e33f854b..4a6f845d 100644 --- a/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs +++ b/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs @@ -18,6 +18,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.Globalization; using System.Net; using System.Net.Http.Headers; @@ -1114,6 +1115,60 @@ namespace BMA.EHR.Application.Repositories.Reports return s_data; } + public async Task GeInsigniaRequestProfiles(Guid id) + { + var profile = await _dbContext.Set() + .Where(x => x.Id == id) + .Select(x => new + { + Fullname = $"{x.Prefix}{x.FirstName} {x.LastName}", + Position = x.Position ?? "", + Oc = (x.Child4 == null ? "" : x.Child4 + " ") + + (x.Child3 == null ? "" : x.Child3 + " ") + + (x.Child2 == null ? "" : x.Child2 + " ") + + (x.Child1 == null ? "" : x.Child1 + " ") + + (x.Root == null ? "" : x.Root), + BirthDate = x.BirthDate == null ? "" : x.BirthDate.Value.ToThaiShortDate().ToString().ToThaiNumber(), + DateAppoint = x.DateAppoint == null ? "" : x.DateAppoint.Value.ToThaiShortDate().ToString().ToThaiNumber(), + ProfileId = x.ProfileId + }) + .FirstOrDefaultAsync(); + + if (profile == null) + throw new Exception(GlobalMessages.DataNotFound); + + var profileSalarys = await _userProfileRepository.GetProfileSalaryById(profile.ProfileId, AccessToken); + var salarys = profileSalarys.Select(x => new + { + DateAffect = x.DateAffect == null ? "" : x.DateAffect.ToThaiShortDate().ToString().ToThaiNumber(), + Position = x.Position ?? "", + Root = x.Root, + Child1 = x.Child1, + Child2 = x.Child2, + Child3 = x.Child3, + Child4 = x.Child4, + Oc = (x.Child4 == null ? "" : x.Child4 + " ") + + (x.Child3 == null ? "" : x.Child3 + " ") + + (x.Child2 == null ? "" : x.Child2 + " ") + + (x.Child1 == null ? "" : x.Child1 + " ") + + (x.Root == null ? "" : x.Root), + Age = x.Age == null ? "" : x.Age.ToString().ToThaiNumber(), + Amount = x.Amount == null ? "" : x.Amount.ToString("N0", new CultureInfo("th-TH")).ToThaiNumber(), + Remark = x.Remark == null ? "" : x.Remark.ToThaiNumber(), + }).ToList(); + + var result = new + { + profile.Fullname, + profile.Position, + profile.Oc, + profile.BirthDate, + profile.DateAppoint, + Salarys = salarys + }; + return result; + } + //47-บัญชีระดับผลการประเมินผลการปฏิบัติราชการในรอบ 5 ปี public async Task GetEvaluationResultReport(Guid id, string type = null, int node = -1, Guid nodeId = default) { diff --git a/BMA.EHR.Application/Repositories/UserProfileRepository.cs b/BMA.EHR.Application/Repositories/UserProfileRepository.cs index 3031c6ac..c1df38ca 100644 --- a/BMA.EHR.Application/Repositories/UserProfileRepository.cs +++ b/BMA.EHR.Application/Repositories/UserProfileRepository.cs @@ -1246,6 +1246,31 @@ namespace BMA.EHR.Application.Repositories throw; } } + public async Task> GetProfileSalaryById(Guid profileId, string? accessToken) + { + try + { + var apiPath = $"{_configuration["API"]}/org/profile/insignia/position"; + var apiKey = _configuration["API_KEY"]; + var body = new + { + profileId = profileId.ToString(), + }; + var apiResult = await PostExternalAPIAsync(apiPath, accessToken ?? "", body, apiKey); + if (apiResult != null) + { + var raw = JsonConvert.DeserializeObject(apiResult); + if (raw != null) + return raw.Result; + } + return null; + } + catch + { + throw; + } + } + #endregion } } diff --git a/BMA.EHR.Application/Responses/Profiles/GetProfileSalaryDto.cs b/BMA.EHR.Application/Responses/Profiles/GetProfileSalaryDto.cs new file mode 100644 index 00000000..db0cf18d --- /dev/null +++ b/BMA.EHR.Application/Responses/Profiles/GetProfileSalaryDto.cs @@ -0,0 +1,16 @@ +namespace BMA.EHR.Application.Responses.Profiles +{ + public class GetProfileSalaryDto + { + public DateTime DateAffect { get; set; } + public string Position { get; set; } = string.Empty; + public string Root { get; set; } = string.Empty; + public string Child1 { get; set; } = string.Empty; + public string Child2 { get; set; } = string.Empty; + public string Child3 { get; set; } = string.Empty; + public string Child4 { get; set; } = string.Empty; + public int Age { get; set; } = 0; + public int Amount { get; set; } = 0; + public string Remark { get; set; } = string.Empty; + } +} diff --git a/BMA.EHR.Application/Responses/Profiles/GetProfileSalaryResultDto.cs b/BMA.EHR.Application/Responses/Profiles/GetProfileSalaryResultDto.cs new file mode 100644 index 00000000..5ad8a9e3 --- /dev/null +++ b/BMA.EHR.Application/Responses/Profiles/GetProfileSalaryResultDto.cs @@ -0,0 +1,11 @@ +namespace BMA.EHR.Application.Responses.Profiles +{ + public class GetProfileSalaryResultDto + { + public string Message { get; set; } = string.Empty; + + public int Status { get; set; } = -1; + + public List Result { get; set; } = new(); + } +} diff --git a/BMA.EHR.Insignia/Controllers/InsigniaReportController.cs b/BMA.EHR.Insignia/Controllers/InsigniaReportController.cs index 448d69fb..060a711f 100644 --- a/BMA.EHR.Insignia/Controllers/InsigniaReportController.cs +++ b/BMA.EHR.Insignia/Controllers/InsigniaReportController.cs @@ -587,7 +587,6 @@ namespace BMA.EHR.Insignia.Service.Controllers } #endregion - #region รายงานสถิติการได้รับเครื่องราชอิสริยาภรณ์ข้าราชการ ฯ /// /// รายงานสถิติการได้รับเครื่องราชอิสริยาภรณ์ข้าราชการ ฯ @@ -688,7 +687,6 @@ namespace BMA.EHR.Insignia.Service.Controllers } #endregion - #region รายงานผลการจ่ายประกาศนียบัตรกำกับเครื่องราชอิสริยาภรณ์ แยกรายหน่วยงาน /// /// รายงานผลการจ่ายประกาศนียบัตรกำกับเครื่องราชอิสริยาภรณ์ แยกรายหน่วยงาน @@ -833,5 +831,37 @@ namespace BMA.EHR.Insignia.Service.Controllers } #endregion + #region ประวัติสำหรับการเสนอขอพระราชทานเหรียญจักรพรรดิมาลา + /// + /// ประวัติสำหรับการเสนอขอพระราชทานเหรียญจักรพรรดิมาลา + /// + /// id + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("report8/{id}")] + public async Task> GetInsigniaReport8Async(Guid id) + { + + try + { + var data = await _repository.GeInsigniaRequestProfiles(id); + var result = new + { + template = "reportInsignia8", + reportName = "reportInsignia8", + data = data + }; + return Success(result); + + } + catch + { + throw; + } + } + #endregion + } }