From 52ab6ee6f71fb6022ae78e7872f241785d8e14af Mon Sep 17 00:00:00 2001 From: "DESKTOP-2S5P7D1\\Windows 10" Date: Tue, 5 Sep 2023 19:44:44 +0700 Subject: [PATCH] =?UTF-8?q?summary=20=E0=B8=84=E0=B8=B4=E0=B8=A7=E0=B8=A3?= =?UTF-8?q?=E0=B8=B5=E0=B9=88=E0=B9=80=E0=B8=84=E0=B8=A3=E0=B8=B7=E0=B9=88?= =?UTF-8?q?=E0=B8=AD=E0=B8=87=E0=B8=A3=E0=B8=B2=E0=B8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reports/InsigniaReportRepository.cs | 170 ++++++++++++++++++ .../Storage/MinIOService.cs | 22 +++ .../Controllers/InsigniaRequestController.cs | 2 +- BMA.EHR.Placement.Service/appsettings.json | 2 +- .../wwwroot/keycloak.json | 2 +- .../BMA.EHR.Report.Service.csproj | 3 + .../Controllers/RetirementController.cs | 9 +- BMA.EHR.Retirement.Service/appsettings.json | 6 +- 8 files changed, 208 insertions(+), 8 deletions(-) diff --git a/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs b/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs index d6928de6..29649f98 100644 --- a/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs +++ b/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs @@ -136,11 +136,67 @@ namespace BMA.EHR.Application.Repositories.Reports G3Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "ประถมาภรณ์ช้างเผือก" ? 1 : 0), G4Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "ประถมาภรณ์มงกุฎไทย" ? 1 : 0), 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), }).ToList(); return insignia; } + public async Task GetKhr1TotalReport(Guid id) + { + var period = await _dbContext.Set() + .FirstOrDefaultAsync(x => x.Id == id); + if (period == null) + throw new Exception(GlobalMessages.InsigniaPeriodNotFound); + + var data_insignia = await _dbContext.Set() + .Include(x => x.Profile) + .Where(x => x.Request.Period == period) + .Where(x => x.IsApprove == true) + .Where(x => x.RequestInsignia.InsigniaType != null) + .Where(x => x.RequestInsignia.InsigniaType.Name == "ชั้นสายสะพาย") + .Select(x => new + { + Gendor = x.Profile.Gender == null ? null : x.Profile.Gender.Name, + RequestInsigniaName = x.RequestInsignia.Name, + OcId = x.Request.Organization.Id + }) + .ToListAsync(); + + var insignia = (from r in data_insignia + group r by new { OcId = r.OcId } into g + select new + { + RowNo = 1, + DepartmentName = _organizationCommonRepository.GetOrganizationNameFullPath(g.Key.OcId, false, false), + G1Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "มหาปรมาภรณ์ช้างเผือก" ? 1 : 0), + G1Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "มหาปรมาภรณ์ช้างเผือก" ? 1 : 0), + G2Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "มหาวชิรมงกุฎ" ? 1 : 0), + G2Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "มหาวชิรมงกุฎ" ? 1 : 0), + G3Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "ประถมาภรณ์ช้างเผือก" ? 1 : 0), + G3Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "ประถมาภรณ์ช้างเผือก" ? 1 : 0), + G4Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "ประถมาภรณ์มงกุฎไทย" ? 1 : 0), + 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), + }).ToList(); + + return new + { + G1Male = insignia.Sum(x => x.G1Male), + G1Female = insignia.Sum(x => x.G1Female), + G2Male = insignia.Sum(x => x.G2Male), + G2Female = insignia.Sum(x => x.G2Female), + G3Male = insignia.Sum(x => x.G3Male), + G3Female = insignia.Sum(x => x.G3Female), + G4Male = insignia.Sum(x => x.G4Male), + G4Female = insignia.Sum(x => x.G4Female), + G5Male = insignia.Sum(x => x.G5Male), + G5Female = insignia.Sum(x => x.G5Female), + }; + } + //40-แบบ ขร2 บัญชีแสดงจำนวนชั้นตราเครื่องราชฯ ข้าราชการ ชั้นต่ำกว่าสายสะพาย public async Task GetKhr2Report(Guid id) { @@ -185,10 +241,81 @@ namespace BMA.EHR.Application.Repositories.Reports G7Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "เบญจมาภรณ์ช้างเผือก" ? 1 : 0), G8Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "เบญจมาภรณ์มงกุฎไทย" ? 1 : 0), 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), }).ToList(); return insignia; } + public async Task GetKhr2TotalReport(Guid id) + { + var period = await _dbContext.Set() + .FirstOrDefaultAsync(x => x.Id == id); + if (period == null) + throw new Exception(GlobalMessages.InsigniaPeriodNotFound); + + var data_insignia = await _dbContext.Set() + .Include(x => x.Profile) + .Where(x => x.Request.Period == period) + .Where(x => x.IsApprove == true) + .Where(x => x.RequestInsignia.InsigniaType != null) + .Where(x => x.RequestInsignia.InsigniaType.Name == "ชั้นต่ำกว่าสายสะพาย") + .Select(x => new + { + Gendor = x.Profile.Gender == null ? null : x.Profile.Gender.Name, + RequestInsigniaName = x.RequestInsignia.Name, + OcId = x.Request.Organization.Id + }) + .ToListAsync(); + + var insignia = (from r in data_insignia + group r by new { OcId = r.OcId } into g + select new + { + RowNo = 1, + DepartmentName = _organizationCommonRepository.GetOrganizationNameFullPath(g.Key.OcId, false, false), + G1Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "ทวีติยาภรณ์ช้างเผือก" ? 1 : 0), + G1Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "ทวีติยาภรณ์ช้างเผือก" ? 1 : 0), + G2Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "ทวีติยาภรณ์มงกุฎไทย" ? 1 : 0), + G2Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "ทวีติยาภรณ์มงกุฎไทย" ? 1 : 0), + G3Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "ตริตาภรณ์ช้างเผือก" ? 1 : 0), + G3Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "ตริตาภรณ์ช้างเผือก" ? 1 : 0), + G4Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "ตริตาภรณ์มงกุฎไทย" ? 1 : 0), + G4Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "ตริตาภรณ์มงกุฎไทย" ? 1 : 0), + G5Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "จัตุรถาภรณ์ช้างเผือก" ? 1 : 0), + G5Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "จัตุรถาภรณ์ช้างเผือก" ? 1 : 0), + G6Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "จัตุรถาภรณ์มงกุฎไทย" ? 1 : 0), + G6Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "จัตุรถาภรณ์มงกุฎไทย" ? 1 : 0), + G7Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "เบญจมาภรณ์ช้างเผือก" ? 1 : 0), + G7Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "เบญจมาภรณ์ช้างเผือก" ? 1 : 0), + G8Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "เบญจมาภรณ์มงกุฎไทย" ? 1 : 0), + 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), + }).ToList(); + + return new + { + G1Male = insignia.Sum(x => x.G1Male), + G1Female = insignia.Sum(x => x.G1Female), + G2Male = insignia.Sum(x => x.G2Male), + G2Female = insignia.Sum(x => x.G2Female), + G3Male = insignia.Sum(x => x.G3Male), + G3Female = insignia.Sum(x => x.G3Female), + G4Male = insignia.Sum(x => x.G4Male), + G4Female = insignia.Sum(x => x.G4Female), + G5Male = insignia.Sum(x => x.G5Male), + G5Female = insignia.Sum(x => x.G5Female), + G6Male = insignia.Sum(x => x.G6Male), + G6Female = insignia.Sum(x => x.G6Female), + G7Male = insignia.Sum(x => x.G7Male), + G7Female = insignia.Sum(x => x.G7Female), + G8Male = insignia.Sum(x => x.G8Male), + G8Female = insignia.Sum(x => x.G8Female), + G9Male = insignia.Sum(x => x.G9Male), + G9Female = insignia.Sum(x => x.G9Female), + }; + } //41-แบบ ขร3 บัญชีรายชื่อข้าราชการผู้ขอพระราชทานเครื่องราชฯ public async Task GetKhr3Report(Guid id) @@ -384,10 +511,53 @@ namespace BMA.EHR.Application.Repositories.Reports DepartmentName = _organizationCommonRepository.GetOrganizationNameFullPath(g.Key.OcId, false, false), G1Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "เหรียญจักรพรรดิมาลา" ? 1 : 0), 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), }).ToList(); return insignia; } + public async Task GetSummaryTotalCoinReport(Guid id) + { + var period = await _dbContext.Set() + .FirstOrDefaultAsync(x => x.Id == id); + if (period == null) + throw new Exception(GlobalMessages.InsigniaPeriodNotFound); + + var data_insignia = await _dbContext.Set() + .Include(x => x.Profile) + .Where(x => x.Request.Period == period) + .Where(x => x.IsApprove == true) + .Where(x => x.RequestInsignia.InsigniaType != null) + .Where(x => x.RequestInsignia.InsigniaType.Name == "เหรียญบำเหน็จในราชการ") + .Select(x => new + { + Gendor = x.Profile.Gender == null ? null : x.Profile.Gender.Name, + RequestInsigniaName = x.RequestInsignia.Name, + OcId = x.Request.Organization.Id + }) + .ToListAsync(); + + var insignia = (from r in data_insignia + group r by new { OcId = r.OcId } into g + select new + { + RowNo = 1, + DepartmentName = _organizationCommonRepository.GetOrganizationNameFullPath(g.Key.OcId, false, false), + G1Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "เหรียญจักรพรรดิมาลา" ? 1 : 0), + 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), + }).ToList(); + + return new + { + G1Male = insignia.Sum(x => x.G1Male), + G1Female = insignia.Sum(x => x.G1Female), + G2Male = insignia.Sum(x => x.G2Male), + G2Female = insignia.Sum(x => x.G2Female) + }; + } //45-บัญชีแสดงรายชื่อผู้ขอพระราชทานเหรียญจักรพรรดิมาลา public async Task GetCoinReport(Guid id) diff --git a/BMA.EHR.Infrastructure/Storage/MinIOService.cs b/BMA.EHR.Infrastructure/Storage/MinIOService.cs index 03eea08b..a6f14d49 100644 --- a/BMA.EHR.Infrastructure/Storage/MinIOService.cs +++ b/BMA.EHR.Infrastructure/Storage/MinIOService.cs @@ -213,6 +213,28 @@ namespace BMA.EHR.Application.Repositories return path; } + public async Task ImagesPathByName(string fileName) + { + var config = new AmazonS3Config + { + ServiceURL = _configuration["MinIO:Endpoint"], + ForcePathStyle = true + }; + + DateTime expires = DateTime.UtcNow.AddHours(6); + var _protocol = _configuration["Protocol"]; + GetPreSignedUrlRequest request = new GetPreSignedUrlRequest + { + BucketName = _bucketName, + Key = fileName, + Expires = expires, + Protocol = _protocol == "HTTPS" ? Protocol.HTTPS : Protocol.HTTP + }; + string path = _s3Client.GetPreSignedURL(request); + + return path; + } + #endregion public List GetAllIdByRoot(Guid? id) diff --git a/BMA.EHR.Insignia.Service/Controllers/InsigniaRequestController.cs b/BMA.EHR.Insignia.Service/Controllers/InsigniaRequestController.cs index ed82518f..db2af0c9 100644 --- a/BMA.EHR.Insignia.Service/Controllers/InsigniaRequestController.cs +++ b/BMA.EHR.Insignia.Service/Controllers/InsigniaRequestController.cs @@ -431,7 +431,7 @@ namespace BMA.EHR.Insignia.Service.Controllers }; if (RoleAdmin == true && result.RequestStatus != "st5") return Success(resend); - if (RoleInsignia2 == true && (result.RequestStatus == "st1" || result.RequestStatus == "st2" || result.RequestStatus == "st3")) + if (RoleInsignia2 == true && (result.RequestStatus == "st1" || result.RequestStatus == "st2")) return Success(resend); // var candidate = await _repository.GetInsigniaCandidateBKK(period, ocId); diff --git a/BMA.EHR.Placement.Service/appsettings.json b/BMA.EHR.Placement.Service/appsettings.json index c8cd1ab9..ddc81996 100644 --- a/BMA.EHR.Placement.Service/appsettings.json +++ b/BMA.EHR.Placement.Service/appsettings.json @@ -18,7 +18,7 @@ }, "Jwt": { "Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI", - "Issuer": "https://identity.frappet.com/realms/bma-ehr" + "Issuer": "https://id.frappet.synology.me/realms/bma-ehr" }, "EPPlus": { "ExcelPackage": { diff --git a/BMA.EHR.Placement.Service/wwwroot/keycloak.json b/BMA.EHR.Placement.Service/wwwroot/keycloak.json index 9eba3b39..a023eb38 100644 --- a/BMA.EHR.Placement.Service/wwwroot/keycloak.json +++ b/BMA.EHR.Placement.Service/wwwroot/keycloak.json @@ -1,6 +1,6 @@ { "realm": "bma-ehr", - "auth-server-url": "https://identity.frappet.com", + "auth-server-url": "https://id.frappet.synology.me", "ssl-required": "external", "resource": "bma-ehr", "public-client": true diff --git a/BMA.EHR.Report.Service/BMA.EHR.Report.Service.csproj b/BMA.EHR.Report.Service/BMA.EHR.Report.Service.csproj index d82ae1c7..c5a1df22 100644 --- a/BMA.EHR.Report.Service/BMA.EHR.Report.Service.csproj +++ b/BMA.EHR.Report.Service/BMA.EHR.Report.Service.csproj @@ -567,6 +567,9 @@ PreserveNewest + + PreserveNewest + diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementController.cs index 897b6aca..4e2db845 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementController.cs @@ -25,16 +25,19 @@ namespace BMA.EHR.Retirement.Service.Controllers private readonly ApplicationDBContext _context; private readonly MinIOService _documentService; private readonly IHttpContextAccessor _httpContextAccessor; + private readonly IConfiguration _configuration; public RetirementController(RetirementRepository repository, ApplicationDBContext context, MinIOService documentService, + IConfiguration configuration, IHttpContextAccessor httpContextAccessor) { _repository = repository; _context = context; _documentService = documentService; _httpContextAccessor = httpContextAccessor; + _configuration = configuration; } #region " Properties " @@ -449,11 +452,13 @@ namespace BMA.EHR.Retirement.Service.Controllers return Error(GlobalMessages.RetirementHistoryNotFound, 404); using (var client = new HttpClient()) { - var url = $"https://s3cluster.frappet.com/bma-ehr-fpt/{profileHistorys.ProfileFile}.json"; + // var Endpoint = _configuration["MinIO:Endpoint"]; + // var BucketName = _configuration["MinIO:BucketName"]; + var url = await _documentService.ImagesPathByName($"{profileHistorys.ProfileFile}.json"); + // var url = $"{Endpoint}{BucketName}/{profileHistorys.ProfileFile}.json"; var responseTask = client.GetAsync(url); var results = responseTask.Result; var filehis = profileHistorys.Document == null ? null : await _documentService.ImagesPath(profileHistorys.Document.Id); - // Console.WriteLine(results.Content.ReadAsStringAsync().Result); return Success(new { Json = true, profileHistorys.Id, profileHistorys.CreatedAt, profileHistorys.Year, profileHistorys.Round, profileHistorys.Type, profileHistorys.TypeReport, profile = Newtonsoft.Json.JsonConvert.DeserializeObject>(results.Content.ReadAsStringAsync().Result), File = filehis }); } } diff --git a/BMA.EHR.Retirement.Service/appsettings.json b/BMA.EHR.Retirement.Service/appsettings.json index eb56e841..c694a90c 100644 --- a/BMA.EHR.Retirement.Service/appsettings.json +++ b/BMA.EHR.Retirement.Service/appsettings.json @@ -27,10 +27,10 @@ } }, "MinIO": { - "Endpoint": "https://s3cluster.frappet.com/", + "Endpoint": "https://s3.frappet.com/", "AccessKey": "frappet", - "SecretKey": "FPTadmin2357", - "BucketName": "bma-ehr-fpt" + "SecretKey": "P@ssw0rd", + "BucketName": "bma-recruit" }, "Protocol": "HTTPS" } \ No newline at end of file