diff --git a/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs b/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs index 5afced0e..d2711cad 100644 --- a/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs +++ b/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs @@ -37,15 +37,61 @@ namespace BMA.EHR.Application.Repositories.Reports #endregion #region " Methods " - // public async Task GetOcInsigniaPeriod(Guid id) + // private string GetPositionByYear(string profileID, int year) // { - // var period = await _dbContext.Set() - // .FirstOrDefaultAsync(x => x.Id == id); - // if (period == null) - // throw new Exception(GlobalMessages.InsigniaPeriodNotFound); - // period. - // var OCName = r.OcId == null ? "-" : _organizationCommonRepository.GetOrganizationNameFullPath(r.OcId.Value, false, false); - // return OCName; + // using (var ctx = new ApplicationDbContext()) + // { + // var ret = (from x in ctx.ProfileSalaryPositions.AsQueryable() + // where x.IdNavigation.ProfileId == profileID && + // x.IdNavigation.SalaryDateAnnounce.Value.Year == year + // orderby x.IdNavigation.Order descending + // select x) + // .Include(x => x.Position) + // .FirstOrDefault(); + + // if (ret != null) + // return ret.Position.Name; + // else + // return "ไม่ระบุ"; + // } + // } + + // private string GetPositionLevelByYear(string profileID, int year) + // { + // using (var ctx = new ApplicationDbContext()) + // { + // var ret = (from x in ctx.ProfileSalaryPositionLevels.AsQueryable() + // where x.IdNavigation.ProfileId == profileID && + // x.IdNavigation.SalaryDateAnnounce.Value.Year == year + // orderby x.IdNavigation.Order descending + // select x) + // .Include(x => x.PositionLevel) + // .FirstOrDefault(); + + // if (ret != null) + // return ret.PositionLevel.Name; + // else + // return "ไม่ระบุ"; + // } + // } + + // private string GetPositionTypeByYear(string profileID, int year) + // { + // using (var ctx = new ApplicationDbContext()) + // { + // var ret = (from x in ctx.ProfileSalaryPositionTypes.AsQueryable() + // where x.IdNavigation.ProfileId == profileID && + // x.IdNavigation.SalaryDateAnnounce.Value.Year == year + // orderby x.IdNavigation.Order descending + // select x) + // .Include(x => x.PositionType) + // .FirstOrDefault(); + + // if (ret != null) + // return ret.PositionType.Name; + // else + // return "ไม่ระบุ"; + // } // } public async Task GetYearInsigniaPeriod(Guid id) @@ -149,6 +195,7 @@ namespace BMA.EHR.Application.Repositories.Reports G4Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "ประถมาภรณ์มงกุฎไทย" ? 1 : 0), G5Male = g.Sum(x => x.Gendor == "ชาย" ? 1 : 0), G5Female = g.Sum(x => x.Gendor == "หญิง" ? 1 : 0), + Remark = "", }).ToList(); return insignia; @@ -191,6 +238,7 @@ namespace BMA.EHR.Application.Repositories.Reports G4Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "ประถมาภรณ์มงกุฎไทย" ? 1 : 0), G5Male = g.Sum(x => x.Gendor == "ชาย" ? 1 : 0), G5Female = g.Sum(x => x.Gendor == "หญิง" ? 1 : 0), + Remark = "", }).ToList(); return new @@ -205,6 +253,7 @@ namespace BMA.EHR.Application.Repositories.Reports G4Female = insignia.Sum(x => x.G4Female), G5Male = insignia.Sum(x => x.G5Male), G5Female = insignia.Sum(x => x.G5Female), + Remark = "", }; } @@ -254,6 +303,7 @@ namespace BMA.EHR.Application.Repositories.Reports G8Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "เบญจมาภรณ์มงกุฎไทย" ? 1 : 0), G9Male = g.Sum(x => x.Gendor == "ชาย" ? 1 : 0), G9Female = g.Sum(x => x.Gendor == "หญิง" ? 1 : 0), + Remark = "", }).ToList(); return insignia; @@ -303,6 +353,7 @@ namespace BMA.EHR.Application.Repositories.Reports G8Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "เบญจมาภรณ์มงกุฎไทย" ? 1 : 0), G9Male = g.Sum(x => x.Gendor == "ชาย" ? 1 : 0), G9Female = g.Sum(x => x.Gendor == "หญิง" ? 1 : 0), + Remark = "", }).ToList(); return new @@ -325,6 +376,7 @@ namespace BMA.EHR.Application.Repositories.Reports G8Female = insignia.Sum(x => x.G8Female), G9Male = insignia.Sum(x => x.G9Male), G9Female = insignia.Sum(x => x.G9Female), + Remark = "", }; } @@ -430,6 +482,7 @@ namespace BMA.EHR.Application.Repositories.Reports InsigniaInitial = r.RequestInsignia.ShortName, InsigniaName = r.RequestInsignia.Name, ProfileId = r.Profile.Id, + CitizenId = r.Profile.CitizenId, FullName = $"{r.Profile.Prefix?.Name}{r.Profile.FirstName} {r.Profile.LastName}", ShowProfileId = r.Profile.Id, Type = r.Profile.PositionType == null ? "-" : r.Profile.PositionType.Name, @@ -444,8 +497,9 @@ namespace BMA.EHR.Application.Repositories.Reports Remark = "", Position = r.Profile.Position?.Name + (r.Profile.PositionType == null ? null : " ประเภท" + r.Profile.PositionType?.Name) + - (r.Profile.PositionLevel == null ? null : " ระดับ" + r.Profile.PositionLevel?.Name) + - CRLF, + (r.Profile.PositionLevel == null ? null : " สังกัด" + r.Profile.PositionLevel?.Name) + + (r.Request.Organization == null ? null : " ระดับ" + CRLF + _organizationCommonRepository.GetOrganizationNameFullPath(r.Request.Organization.Id, false, false)) + , OCName = _organizationCommonRepository.GetOrganizationNameFullPath(r.Request.Organization.Id, false, false) }) .Distinct() @@ -473,6 +527,7 @@ namespace BMA.EHR.Application.Repositories.Reports InsigniaInitial = r.RequestInsignia.ShortName, InsigniaName = r.RequestInsignia.Name, ProfileId = r.Profile.Id, + CitizenId = r.Profile.CitizenId, FullName = $"", ShowProfileId = Guid.Parse("00000000-0000-0000-0000-000000000000"), Type = "", @@ -487,6 +542,9 @@ namespace BMA.EHR.Application.Repositories.Reports InsigniaRequest = "", Remark = "", Position = "", + // Position = GetPositionByYear(r.Profile.Id, r.Request.Period.Year) + " ประเภท" + + // GetPositionTypeByYear(r.Profile.Id, r.Request.Period.Year) + " ระดับ" + + // GetPositionLevelByYear(r.Profile.Id, r.Request.Period.Year), OCName = _organizationCommonRepository.GetOrganizationNameFullPath(r.Request.Organization.Id, false, false) }) .Distinct() @@ -528,6 +586,7 @@ namespace BMA.EHR.Application.Repositories.Reports G1Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "เหรียญจักรพรรดิมาลา" ? 1 : 0), G2Male = g.Sum(x => x.Gendor == "ชาย" ? 1 : 0), G2Female = g.Sum(x => x.Gendor == "หญิง" ? 1 : 0), + Remark = "", }).ToList(); return insignia; @@ -563,6 +622,7 @@ namespace BMA.EHR.Application.Repositories.Reports G1Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "เหรียญจักรพรรดิมาลา" ? 1 : 0), G2Male = g.Sum(x => x.Gendor == "ชาย" ? 1 : 0), G2Female = g.Sum(x => x.Gendor == "หญิง" ? 1 : 0), + Remark = "", }).ToList(); return new @@ -570,7 +630,8 @@ namespace BMA.EHR.Application.Repositories.Reports G1Male = insignia.Sum(x => x.G1Male), G1Female = insignia.Sum(x => x.G1Female), G2Male = insignia.Sum(x => x.G2Male), - G2Female = insignia.Sum(x => x.G2Female) + G2Female = insignia.Sum(x => x.G2Female), + Remark = "", }; }