From d29d5afcc83d1b6cb65c7df23f26302f65ee9be2 Mon Sep 17 00:00:00 2001 From: "DESKTOP-2S5P7D1\\Windows 10" Date: Tue, 5 Sep 2023 12:58:57 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=84=E0=B8=B4=E0=B8=A7=E0=B8=A3=E0=B8=B5?= =?UTF-8?q?=E0=B9=88=2046-=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=A7=E0=B8=B1?= =?UTF-8?q?=E0=B8=95=E0=B8=B4=E0=B8=AA=E0=B8=B3=E0=B8=AB=E0=B8=A3=E0=B8=B1?= =?UTF-8?q?=E0=B8=9A=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B9=80=E0=B8=AA=E0=B8=99?= =?UTF-8?q?=E0=B8=AD=E0=B8=82=E0=B8=AD=E0=B8=9E=E0=B8=A3=E0=B8=B0=E0=B8=A3?= =?UTF-8?q?=E0=B8=B2=E0=B8=8A=E0=B8=97=E0=B8=B2=E0=B8=99=E0=B9=80=E0=B8=AB?= =?UTF-8?q?=E0=B8=A3=E0=B8=B5=E0=B8=A2=E0=B8=8D=E0=B8=88=E0=B8=B1=E0=B8=81?= =?UTF-8?q?=E0=B8=A3=E0=B8=9E=E0=B8=A3=E0=B8=A3=E0=B8=94=E0=B8=B4=E0=B8=A1?= =?UTF-8?q?=E0=B8=B2=E0=B8=A5=E0=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reports/InsigniaReportRepository.cs | 64 ++++++++++++++++++- 1 file changed, 62 insertions(+), 2 deletions(-) diff --git a/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs b/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs index eb4e982f..078cc2bb 100644 --- a/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs +++ b/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs @@ -3,6 +3,7 @@ using BMA.EHR.Application.Responses; using BMA.EHR.Domain.Extensions; using BMA.EHR.Domain.Models.HR; using BMA.EHR.Domain.Models.Insignias; +using BMA.EHR.Domain.Models.MetaData; using BMA.EHR.Domain.Models.Organizations; using BMA.EHR.Domain.Models.Retirement; using BMA.EHR.Domain.Shared; @@ -78,6 +79,27 @@ namespace BMA.EHR.Application.Repositories.Reports }; } + public async Task GetProfileInsignia(Guid id) + { + var profile = (from r in await _dbContext.Set() + .Include(x => x.Prefix) + .Include(x => x.Position) + .ToListAsync() + where r.Id == id + select new + { + FullName = $"{r.Prefix?.Name}{r.FirstName} {r.LastName}", + Position = r.Position == null ? "-" : r.Position.Name, + OCName = r.OcId == null ? "-" : _organizationCommonRepository.GetOrganizationNameFullPath(r.OcId.Value, false, false), + BirthDate = r.BirthDate.ToThaiFullDate().ToString().ToThaiNumber(), + }) + .FirstOrDefault(); + if (profile == null) + throw new Exception(GlobalMessages.DataNotFound); + + return profile; + } + //39-แบบ ขร1 บัญชีแสดงจำนวนชั้นตราเครื่องราชฯ ข้าราชการ ชั้นสายสะพาย public async Task GetKhr1Report(Guid id) { @@ -268,9 +290,9 @@ namespace BMA.EHR.Application.Repositories.Reports ProfileId = r.Profile.Id, FullName = $"{r.Profile.Prefix?.Name}{r.Profile.FirstName} {r.Profile.LastName}", ShowProfileId = r.Profile.Id, - Type = r.Profile.PositionType?.Name, + Type = r.Profile.PositionType == null ? "-" : r.Profile.PositionType.Name, AcademicStanding = "", - Level = r.Profile.PositionLevel?.Name, + Level = r.Profile.PositionLevel == null ? "-" : r.Profile.PositionLevel.Name, DateStart = r.Profile.DateStart == null ? null : r.Profile.DateStart.Value.ToThaiShortDate(), SalaryAmount = r.Profile.Salaries.Count() == 0 ? 0 : r.Profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount, @@ -430,6 +452,44 @@ namespace BMA.EHR.Application.Repositories.Reports return data; } + //46-ประวัติสำหรับการเสนอขอพระราชทานเหรียญจักรพรรดิมาลา + public async Task GetHistorySalaryReport(Guid id) + { + var profile = await _dbContext.Set() + .FirstOrDefaultAsync(x => x.Id == id); + if (profile == null) + throw new Exception(GlobalMessages.DataNotFound); + var positions = await _dbContext.Set() + .ToListAsync(); + var organizations = await _dbContext.Set() + .Include(x => x.Parent) + .ThenInclude(x => x.OrganizationOrganization) + .ToListAsync(); + + var data = (from r in await _dbContext.Set() + .Include(x => x.Profile) + .ToListAsync() + join p in positions on r.PositionId equals p.Id into pGroup + from p in pGroup.DefaultIfEmpty() + join o in organizations on r.OcId equals o.Id into oGroup + from o in oGroup.DefaultIfEmpty() + where r.Profile == profile + select new + { + DateTh = r.Date == null ? "-" : r.Date.Value.ToThaiShortDate().ToString().ToThaiNumber(), + Position = p.Name, + OCName = o.Parent == null ? "-" : (o.Parent.OrganizationOrganization == null ? "-" : o.Parent.OrganizationOrganization.Name), + Age = r.Date == null ? "-" : r.Date.Value.CalculateAgeStrV2(0, 0).ToThaiNumber(), + Amount = r.Amount == null ? null : r.Amount.Value.ToNumericText().ToThaiNumber(), + Date = r.Date, + }) + .Distinct() + .OrderBy(x => x.Date) + .ToList(); + + return data; + } + #endregion } }