From e801653d6095604823fefb04db3148a8e3436813 Mon Sep 17 00:00:00 2001 From: "Harid Promsri (Bright)" Date: Wed, 13 Sep 2023 14:29:53 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84=E0=B8=82?= =?UTF-8?q?=20api=20=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=87=E0=B8=B2=E0=B8=99?= =?UTF-8?q?=E0=B8=9A=E0=B8=B1=E0=B8=99=E0=B8=97=E0=B8=B6=E0=B8=81=E0=B9=80?= =?UTF-8?q?=E0=B8=A7=E0=B8=B5=E0=B8=A2=E0=B8=99=E0=B9=81=E0=B8=88=E0=B9=89?= =?UTF-8?q?=E0=B8=87=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=96=E0=B8=B6=E0=B8=87?= =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=88=E0=B8=81=E0=B8=A3=E0=B8=A3=E0=B8=A1?= =?UTF-8?q?=20(=E0=B8=82=E0=B8=B2=E0=B8=94=E0=B8=9A=E0=B8=B2=E0=B8=87?= =?UTF-8?q?=E0=B8=9F=E0=B8=B4=E0=B8=A5=E0=B8=94=E0=B9=8C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reports/RetireReportRepository.cs | 65 +++++++++++++++++- .../Controllers/DeceasedReportController.cs | 48 +++++++++---- .../Reports/36-บันทึกเวียนแจ้งการถึงแก่กรรม.trdp | Bin 28675 -> 28514 bytes 3 files changed, 98 insertions(+), 15 deletions(-) diff --git a/BMA.EHR.Application/Repositories/Reports/RetireReportRepository.cs b/BMA.EHR.Application/Repositories/Reports/RetireReportRepository.cs index 82eace7f..561ddd3e 100644 --- a/BMA.EHR.Application/Repositories/Reports/RetireReportRepository.cs +++ b/BMA.EHR.Application/Repositories/Reports/RetireReportRepository.cs @@ -49,7 +49,8 @@ namespace BMA.EHR.Application.Repositories.Reports // throw; // } //} - + + #region รายงานประกาศเกษียณ public async Task GetProfileRetirementdAsync(Guid retireId) { var retire = await _dbContext.Set() @@ -122,6 +123,68 @@ namespace BMA.EHR.Application.Repositories.Reports 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 }; } } + #endregion + + #region รายงานบันทึกการถึงแก่กรรม + public async Task GetRetirementDeceasedAsync(Guid id) + { + var data = await _dbContext.Set().AsQueryable() + .Where(x => x.Id == id) + .Select(p => new + { + p.Id, + ProfileId = p.Profile.Id, + Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name, + PrefixId = p.Profile.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Prefix.Id, + p.Profile.FirstName, + p.Profile.LastName, + Position = p.Profile.Position == null ? null : p.Profile.Position.Name, + PositionId = p.Profile.Position == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Position.Id, + PositionType = p.Profile.PositionType == null ? null : p.Profile.PositionType.Name, + PositionTypeId = p.Profile.PositionType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.PositionType.Id, + p.Profile.PositionLine, + p.Profile.PositionLineId, + PositionLevel = p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name, + PositionLevelId = p.Profile.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.PositionLevel.Id, + p.Profile.PositionExecutive, + p.Profile.PositionExecutiveId, + Organization = p.Profile.Oc, + OrganizationId = p.Profile.OcId, + p.Number, + p.Date, + p.Location, + p.Reason, + }) + .FirstOrDefaultAsync(); + + if (data == null) + return null; + + string Date = string.IsNullOrEmpty(data.Date.ToString()) ? "วันที่ - เดือน - พ.ศ. -" : DateTime.Parse(data.Date.ToString()).ToThaiFullDate().ToString().ToThaiNumber(); + return new + { + data.Prefix, + data.FirstName, + data.LastName, + data.Position, + data.PositionExecutive, + data.PositionType, + data.PositionLine, + data.PositionLevel, + data.Organization, + data.PositionId, + data.PositionExecutiveId, + data.PositionTypeId, + data.PositionLineId, + data.PositionLevelId, + data.OrganizationId, + data.Number, + Date, + data.Location, + data.Reason, + }; + } + #endregion #endregion } diff --git a/BMA.EHR.Report.Service/Controllers/DeceasedReportController.cs b/BMA.EHR.Report.Service/Controllers/DeceasedReportController.cs index 804f9691..29c9eeae 100644 --- a/BMA.EHR.Report.Service/Controllers/DeceasedReportController.cs +++ b/BMA.EHR.Report.Service/Controllers/DeceasedReportController.cs @@ -26,18 +26,19 @@ namespace BMA.EHR.Report.Service.Controllers private readonly IWebHostEnvironment _hostingEnvironment; private readonly IConfiguration _configuration; private readonly GenericReportGenerator _reportGenerator; - + private readonly RetireReportRepository _repository; #endregion #region " Constuctor and Destructor " - public DeceasedReportController(IWebHostEnvironment hostingEnvironment, IConfiguration configuration, GenericReportGenerator reportGenerator) + public DeceasedReportController(IWebHostEnvironment hostingEnvironment, IConfiguration configuration, GenericReportGenerator reportGenerator, RetireReportRepository repository) { _hostingEnvironment = hostingEnvironment; _configuration = configuration; _reportGenerator = reportGenerator; + _repository = repository; } #endregion @@ -55,23 +56,42 @@ namespace BMA.EHR.Report.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpGet("36/{exportType}/{id}")] - public IActionResult GetDeceasedConvertReportAsync(Guid id, string exportType = "pdf") + public async Task> GetDeceasedReportAsync(Guid id, string exportType = "pdf") { try { - var mimeType = ""; - switch (exportType.Trim().ToLower()) + var data = await _repository.GetRetirementDeceasedAsync(id); + if (data != null) { - case "pdf": mimeType = "application/pdf"; break; - case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; - case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; + var mimeType = ""; + switch (exportType.Trim().ToLower()) + { + case "pdf": mimeType = "application/pdf"; break; + case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; + case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; + } + + var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"36-บันทึกเวียนแจ้งการถึงแก่กรรม.trdp"); + ReportPackager reportPacker = new ReportPackager(); + Telerik.Reporting.Report? report = null; + using (var sourceStream = System.IO.File.OpenRead(rptFile)) + { + report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream); + } + report.DataSource = data; + System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + InstanceReportSource instanceReportSource = new InstanceReportSource() + { + ReportDocument = report, + }; + ReportProcessor reportProcessor = new ReportProcessor(_configuration); + RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo); + return File(result.DocumentBytes, mimeType, $"deceased.{exportType.Trim().ToLower()}"); + } + else + { + return NotFound(); } - - var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"36-บันทึกเวียนแจ้งการถึงแก่กรรม.trdp"); - var contentData = _reportGenerator.GenerateReport(rptFile, exportType); - - return File(contentData, mimeType, $"deceased.{exportType.Trim().ToLower()}"); - } catch { diff --git a/BMA.EHR.Report.Service/Reports/36-บันทึกเวียนแจ้งการถึงแก่กรรม.trdp b/BMA.EHR.Report.Service/Reports/36-บันทึกเวียนแจ้งการถึงแก่กรรม.trdp index 63385573c0838ee6cb1b8c7464e9af7b431a614a..1ddb6506b97274881f67726eebda1ebff5d88f55 100644 GIT binary patch delta 1327 zcmV+~1 zSZ!+?M-cvA=zmzQQ2NDtI=#D*6XF=xA&wE2+kU=CYwO6ph`UvA8Uj`lup9cJtIZPQJH#ybpTyuA`9^(_wR3xillfXCgci;d>E& z5R)AdZi~rCgulgO7)be#IDRL>i3s8C4oZ$u_*_jqz@_$4ejp}WBHR-bP#B*vaSxUM zkizg}#?T1Baf3On&-vhMT@Si_=9mHH%x1oIpLRV*_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