diff --git a/BMA.EHR.Application/Repositories/Reports/RetireReportRepository.cs b/BMA.EHR.Application/Repositories/Reports/RetireReportRepository.cs index 444ed5d2..cbe645cc 100644 --- a/BMA.EHR.Application/Repositories/Reports/RetireReportRepository.cs +++ b/BMA.EHR.Application/Repositories/Reports/RetireReportRepository.cs @@ -1,12 +1,15 @@ using System.Reflection.Metadata; using BMA.EHR.Application.Common.Interfaces; +using BMA.EHR.Application.Responses; using BMA.EHR.Domain.Extensions; +using BMA.EHR.Domain.Models.HR; using BMA.EHR.Domain.Models.Organizations; using BMA.EHR.Domain.Models.Retirement; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; +using Newtonsoft.Json; namespace BMA.EHR.Application.Repositories.Reports { @@ -70,64 +73,73 @@ namespace BMA.EHR.Application.Repositories.Reports if (retireHistorys == null) return null; - var profile_retireHistory = await _dbContext.Set() - .Where(x => x.RetirementPeriod == retire) - .OrderBy(x => x.Order) - .Select(x => new - { - order = x.Order, - id = x.Id, - reason = x.Reason, - remove = x.Remove, - profileId = x.Profile.Id, - citizenId = x.Profile.CitizenId, - prefix = x.Profile.Prefix == null ? null : x.Profile.Prefix.Name, - fullName = $"{x.Profile.FirstName} {x.Profile.LastName}", - organizationOrganization = x.Profile.OrganizationOrganization, - oc = x.Profile.Oc, - position = x.Profile.Position == null ? null : x.Profile.Position.Name, - positionType = x.Profile.PositionType == null ? null : x.Profile.PositionType.Name, - positionExecutive = x.Profile.PositionExecutive, - posNo = x.Profile.PosNo == null ? null : x.Profile.PosNo.Name, - positionEmployeePosition = x.Profile.PositionEmployeePosition, - positionEmployeeLevel = x.Profile.PositionEmployeeLevel, - positionEmployeeGroup = x.Profile.PositionEmployeeGroup, - posNoEmployee = x.Profile.PosNoEmployee, - }) - .ToListAsync(); - - return new { retireHistorys.Id, retireHistorys.CreatedAt, Year = retireHistorys.Year.ToThaiYear().ToString().ToThaiNumber(), retireHistorys.Round, retireHistorys.Type, retireHistorys.TypeReport, Total = retireHistorys.Total.ToString().ToThaiNumber(), profile = profile_retireHistory }; + //var profile_retireHistory = await _dbContext.Set() + // .Where(x => x.RetirementPeriod == retire) + // .OrderBy(x => x.Order) + // .Select(x => new + // { + // order = x.Order, + // id = x.Id, + // reason = x.Reason, + // remove = x.Remove, + // profileId = x.Profile.Id, + // citizenId = x.Profile.CitizenId, + // prefix = x.Profile.Prefix == null ? string.Empty : x.Profile.Prefix.Name, + // fullName = $"{x.Profile.FirstName} {x.Profile.LastName}", + // organizationOrganization = x.Profile.OrganizationOrganization, + // oc = x.Profile.Oc, + // position = x.Profile.Position == null ? string.Empty : x.Profile.Position.Name, + // positionType = x.Profile.PositionType == null ? string.Empty : x.Profile.PositionType.Name, + // positionExecutive = x.Profile.PositionExecutive, + // posNo = x.Profile.PosNo == null ? string.Empty : x.Profile.PosNo.Name, + // positionEmployeePosition = x.Profile.PositionEmployeePosition, + // positionEmployeeLevel = x.Profile.PositionEmployeeLevel, + // positionEmployeeGroup = x.Profile.PositionEmployeeGroup, + // posNoEmployee = x.Profile.PosNoEmployee, + // }) + // .ToListAsync(); + //return new { retireHistorys.Detail, retireHistorys.Id, retireHistorys.CreatedAt, Year = retireHistorys.Year.ToThaiYear().ToString().ToThaiNumber(), retireHistorys.Round, retireHistorys.Type, retireHistorys.TypeReport, Total = retireHistorys.Total.ToString().ToThaiNumber(), profile = profile_retireHistory }; + using (var client = new HttpClient()) + { + var url = await _documentService.ImagesPathByName($"{retireHistorys.ProfileFile}.json"); + var responseTask = client.GetAsync(url); + var results = responseTask.Result; + var json = results.Content.ReadAsStringAsync().Result; + List profiles = JsonConvert.DeserializeObject>(json); + profiles = profiles.OrderBy(x => x.order).ToList(); + return new { retireHistorys.Detail, retireHistorys.Id, retireHistorys.CreatedAt, Year = retireHistorys.Year.ToThaiYear().ToString().ToThaiNumber(), retireHistorys.Round, retireHistorys.Type, retireHistorys.TypeReport, Total = retireHistorys.Total.ToString().ToThaiNumber(), profile = profiles}; + } } else { var profile_retire = await _dbContext.Set() - .Where(x => x.RetirementPeriod == retire) - .OrderBy(x => x.Order) - .Select(x => new - { - order = x.Order, - id = x.Id, - reason = x.Reason, - remove = x.Remove, - profileId = x.Profile.Id, - citizenId = x.Profile.CitizenId, - prefix = x.Profile.Prefix == null ? null : x.Profile.Prefix.Name, - fullName = $"{x.Profile.FirstName} {x.Profile.LastName}", - organizationOrganization = x.Profile.OrganizationOrganization, - oc = x.Profile.Oc, - position = x.Profile.Position == null ? null : x.Profile.Position.Name, - positionType = x.Profile.PositionType == null ? null : x.Profile.PositionType.Name, - positionExecutive = x.Profile.PositionExecutive, - posNo = x.Profile.PosNo == null ? null : x.Profile.PosNo.Name, - positionEmployeePosition = x.Profile.PositionEmployeePosition, - positionEmployeeLevel = x.Profile.PositionEmployeeLevel, - positionEmployeeGroup = x.Profile.PositionEmployeeGroup, + .Where(x => x.RetirementPeriod == retire) + .OrderBy(x => x.Order) + .Select(x => new + { + order = x.Order, + id = x.Id, + reason = x.Reason, + remove = x.Remove, + profileId = x.Profile.Id, + citizenId = x.Profile.CitizenId, + prefix = x.Profile.Prefix == null ? string.Empty : x.Profile.Prefix.Name, + fullName = $"{x.Profile.FirstName} {x.Profile.LastName}", + organizationOrganization = x.Profile.OrganizationOrganization, + oc = x.Profile.Oc, + position = x.Profile.Position == null ? string.Empty : x.Profile.Position.Name, + positionType = x.Profile.PositionType == null ? string.Empty : x.Profile.PositionType.Name, + positionExecutive = x.Profile.PositionExecutive, + posNo = x.Profile.PosNo == null ? string.Empty : x.Profile.PosNo.Name, + positionEmployeePosition = x.Profile.PositionEmployeePosition, + positionEmployeeLevel = x.Profile.PositionEmployeeLevel, + positionEmployeeGroup = x.Profile.PositionEmployeeGroup, posNoEmployee = x.Profile.PosNoEmployee, }) .ToListAsync(); - return new { retire.Id, retire.CreatedAt, Year = retire.Year.ToThaiYear().ToString().ToThaiNumber(), retire.Round, retire.Type, retire.TypeReport, Total = profile_retire.Count.ToString().ToThaiNumber(), profile = profile_retire }; + return new { retire.Detail, retire.Id, retire.CreatedAt, Year = retire.Year.ToThaiYear().ToString().ToThaiNumber(), retire.Round, retire.Type, retire.TypeReport, Total = profile_retire.Count.ToString().ToThaiNumber(), profile = profile_retire }; } } #endregion diff --git a/BMA.EHR.Application/Responses/ProfileJsonRequest.cs b/BMA.EHR.Application/Responses/ProfileJsonRequest.cs new file mode 100644 index 00000000..6c19f255 --- /dev/null +++ b/BMA.EHR.Application/Responses/ProfileJsonRequest.cs @@ -0,0 +1,24 @@ +namespace BMA.EHR.Application.Responses +{ + public class ProfileJsonRequest + { + public int order { get; set; } + public Guid id { get; set; } + public string reason { get; set; } + public string remove { get; set; } + public Guid profileId { get; set; } + public string? citizenId { get; set; } + public string? prefix { get; set; } + public string? fullName { get; set; } + public string? organizationOrganization { get; set; } + public string? oc { get; set; } + public string? position { get; set; } + public string? positionType { get; set; } + public string? positionExecutive { get; set; } + public string? posNo { get; set; } + public string? positionEmployeePosition { get; set; } + public string? positionEmployeeLevel { get; set; } + public string? positionEmployeeGroup { get; set; } + public string? posNoEmployee { get; set; } + } +} diff --git a/BMA.EHR.Report.Service/Controllers/RetireReportController.cs b/BMA.EHR.Report.Service/Controllers/RetireReportController.cs index 0dfb6a88..9d56912b 100644 --- a/BMA.EHR.Report.Service/Controllers/RetireReportController.cs +++ b/BMA.EHR.Report.Service/Controllers/RetireReportController.cs @@ -42,14 +42,10 @@ namespace BMA.EHR.Report.Service.Controllers public async Task> GetProfileRetirement([FromRoute] Guid Id, string exportType = "pdf") { var retire = await _service.GetProfileRetirementdAsync(Id); - if (retire == null) + if (retire != null) { - return NotFound(); - } - else - { - var reportfile = ""; - var returnfile = ""; + var reportfile = string.Empty; + var returnfile = string.Empty; exportType = exportType.Trim(); switch (retire.GetType().GetProperty("Type").GetValue(retire)) { @@ -89,9 +85,10 @@ namespace BMA.EHR.Report.Service.Controllers { report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream); } - //Add Parameter - report.ReportParameters["Year"].Value = retire.GetType().GetProperty("Year").GetValue(retire); - report.ReportParameters["Total"].Value = retire.GetType().GetProperty("Total").GetValue(retire); + report.DataSource = retire; + ////Add Parameter + //report.ReportParameters["Year"].Value = retire.GetType().GetProperty("Year").GetValue(retire); + //report.ReportParameters["Total"].Value = retire.GetType().GetProperty("Total").GetValue(retire); var _profileList = new List(); @@ -123,6 +120,10 @@ namespace BMA.EHR.Report.Service.Controllers var content = result.DocumentBytes; return File(content, $"application/{exportType}", returnfile); } + else + { + return NotFound(); + } } #endregion } diff --git a/BMA.EHR.Report.Service/Reports/31-ประกาศเกษียณข้าราชการ-1.trdp b/BMA.EHR.Report.Service/Reports/31-ประกาศเกษียณข้าราชการ-1.trdp index aef01206..75a2286d 100644 Binary files a/BMA.EHR.Report.Service/Reports/31-ประกาศเกษียณข้าราชการ-1.trdp and b/BMA.EHR.Report.Service/Reports/31-ประกาศเกษียณข้าราชการ-1.trdp differ diff --git a/BMA.EHR.Report.Service/Reports/31-ประกาศเกษียณข้าราชการ-2.trdp b/BMA.EHR.Report.Service/Reports/31-ประกาศเกษียณข้าราชการ-2.trdp index f2f7deb8..132a00da 100644 Binary files a/BMA.EHR.Report.Service/Reports/31-ประกาศเกษียณข้าราชการ-2.trdp and b/BMA.EHR.Report.Service/Reports/31-ประกาศเกษียณข้าราชการ-2.trdp differ diff --git a/BMA.EHR.Report.Service/Reports/31-ประกาศเกษียณข้าราชการ-3.trdp b/BMA.EHR.Report.Service/Reports/31-ประกาศเกษียณข้าราชการ-3.trdp index 09beb8c6..2919650d 100644 Binary files a/BMA.EHR.Report.Service/Reports/31-ประกาศเกษียณข้าราชการ-3.trdp and b/BMA.EHR.Report.Service/Reports/31-ประกาศเกษียณข้าราชการ-3.trdp differ diff --git a/BMA.EHR.Report.Service/Reports/32-ประกาศเกษียณลูกจ้างประจำ.trdp b/BMA.EHR.Report.Service/Reports/32-ประกาศเกษียณลูกจ้างประจำ.trdp index bbb55bcf..5799b202 100644 Binary files a/BMA.EHR.Report.Service/Reports/32-ประกาศเกษียณลูกจ้างประจำ.trdp and b/BMA.EHR.Report.Service/Reports/32-ประกาศเกษียณลูกจ้างประจำ.trdp differ diff --git a/BMA.EHR.Report.Service/appsettings.json b/BMA.EHR.Report.Service/appsettings.json index d6921d83..169430e3 100644 --- a/BMA.EHR.Report.Service/appsettings.json +++ b/BMA.EHR.Report.Service/appsettings.json @@ -26,10 +26,10 @@ } }, "MinIO": { - "Endpoint": "https://s3.frappet.com/", + "Endpoint": "https://s3cluster.frappet.com/", "AccessKey": "frappet", - "SecretKey": "P@ssw0rd", - "BucketName": "bma-recruit" + "SecretKey": "FPTadmin2357", + "BucketName": "bma-ehr-fpt" }, "Protocol": "HTTPS", "telerikReporting": {