From 47e8290cd2a56ececa42d5898d7c4b45f1da9340 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Mon, 30 Sep 2024 11:50:29 +0700 Subject: [PATCH 01/42] fix #642 again --- BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs index 8096bb67..8b1a9559 100644 --- a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs +++ b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs @@ -2013,7 +2013,7 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpPut("note/doc/{insigniaNoteId:length(36)}")] public async Task> AddDocumentProfile([FromForm] InsigniaNoteDocRequest req, Guid insigniaNoteId) { - var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_INSIGNIA_RECORD"); + var getPermission = await _permission.GetPermissionAPIAsync("CREATE", "SYS_INSIGNIA_RECORD"); var jsonData = JsonConvert.DeserializeObject(getPermission); if (jsonData["status"]?.ToString() != "200") { @@ -2282,7 +2282,7 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpPut("preview/receice/{insigniaNoteId:length(36)}"), DisableRequestSizeLimit] public async Task> PreviewReceiceProfile([FromForm] ImportFileRequest req, Guid insigniaNoteId) { - var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_INSIGNIA_RECORD"); + var getPermission = await _permission.GetPermissionAPIAsync("CREATE", "SYS_INSIGNIA_RECORD"); var jsonData = JsonConvert.DeserializeObject(getPermission); if (jsonData["status"]?.ToString() != "200") { @@ -2414,7 +2414,7 @@ namespace BMA.EHR.Insignia.Service.Controllers [HttpPut("preview/invoice/{insigniaNoteId:length(36)}"), DisableRequestSizeLimit] public async Task> PreviewInvoiceProfile([FromForm] ImportFileRequest req, Guid insigniaNoteId) { - var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_INSIGNIA_RECORD"); + var getPermission = await _permission.GetPermissionAPIAsync("CREATE", "SYS_INSIGNIA_RECORD"); var jsonData = JsonConvert.DeserializeObject(getPermission); if (jsonData["status"]?.ToString() != "200") { From a0cc2338467e3fea00f43f1b2534314fc4f33160 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Mon, 30 Sep 2024 14:45:40 +0700 Subject: [PATCH 02/42] fix #617 --- .../PlacementTransferController.cs | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs index 000adcf0..373cc005 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs @@ -14,6 +14,8 @@ using System.Net.Http.Headers; using System.Security.Claims; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using Microsoft.AspNetCore.Mvc.RazorPages; +using System.Drawing.Printing; namespace BMA.EHR.Placement.Service.Controllers { @@ -70,7 +72,7 @@ namespace BMA.EHR.Placement.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpGet("user")] - public async Task> GetListByProfile() + public async Task> GetListByProfile(string keyword = "") { var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position"; using (var client = new HttpClient()) @@ -129,6 +131,23 @@ namespace BMA.EHR.Placement.Service.Controllers p.IsActive, }) .ToListAsync(); + if (keyword != "") + { + var data = placementTransfers.Where(x => + (x.OrganizationPositionOld != null && x.OrganizationPositionOld.Contains(keyword)) || + (x.rootShortNameOld != null && x.rootShortNameOld.Contains(keyword)) || + (x.PositionNumberOld != null && x.PositionNumberOld.Contains(keyword)) || + (x.posTypeNameOld != null && x.posTypeNameOld.Contains(keyword)) || + (x.posLevelNameOld != null && x.posLevelNameOld.Contains(keyword)) || + (x.Organization != null && x.Organization.Contains(keyword)) + ) + //.OrderByDescending(x => x.CreatedAt) + // .Skip((page - 1) * pageSize) + // .Take(pageSize) + .ToList(); + + placementTransfers = data; + } return Success(placementTransfers); } } From d3d7179c4883793792af4443bf6f34f96076cd9c Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Mon, 30 Sep 2024 16:57:46 +0700 Subject: [PATCH 03/42] fix --- .../PlacementTransferController.cs | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs index 373cc005..57ff7c6f 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs @@ -72,7 +72,7 @@ namespace BMA.EHR.Placement.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpGet("user")] - public async Task> GetListByProfile(string keyword = "") + public async Task> GetListByProfile() { var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position"; using (var client = new HttpClient()) @@ -131,23 +131,23 @@ namespace BMA.EHR.Placement.Service.Controllers p.IsActive, }) .ToListAsync(); - if (keyword != "") - { - var data = placementTransfers.Where(x => - (x.OrganizationPositionOld != null && x.OrganizationPositionOld.Contains(keyword)) || - (x.rootShortNameOld != null && x.rootShortNameOld.Contains(keyword)) || - (x.PositionNumberOld != null && x.PositionNumberOld.Contains(keyword)) || - (x.posTypeNameOld != null && x.posTypeNameOld.Contains(keyword)) || - (x.posLevelNameOld != null && x.posLevelNameOld.Contains(keyword)) || - (x.Organization != null && x.Organization.Contains(keyword)) - ) - //.OrderByDescending(x => x.CreatedAt) - // .Skip((page - 1) * pageSize) - // .Take(pageSize) - .ToList(); + //if (keyword != "") + //{ + // var data = placementTransfers.Where(x => + // (x.OrganizationPositionOld != null && x.OrganizationPositionOld.Contains(keyword)) || + // (x.rootShortNameOld != null && x.rootShortNameOld.Contains(keyword)) || + // (x.PositionNumberOld != null && x.PositionNumberOld.Contains(keyword)) || + // (x.posTypeNameOld != null && x.posTypeNameOld.Contains(keyword)) || + // (x.posLevelNameOld != null && x.posLevelNameOld.Contains(keyword)) || + // (x.Organization != null && x.Organization.Contains(keyword)) + // ) + // .OrderByDescending(x => x.CreatedAt) + // .Skip((page - 1) * pageSize) + // .Take(pageSize) + // .ToList(); - placementTransfers = data; - } + // placementTransfers = data; + //} return Success(placementTransfers); } } From 938bfe0c4fef275aa7eaf0a4098cfbc2ab105093 Mon Sep 17 00:00:00 2001 From: kittapath Date: Tue, 1 Oct 2024 23:34:01 +0700 Subject: [PATCH 04/42] =?UTF-8?q?=E0=B8=AD=E0=B8=AD=E0=B8=81=E0=B8=84?= =?UTF-8?q?=E0=B8=B3=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87=2001=2002?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/PlacementController.cs | 212 ++++++++++++++++++ .../Requests/ReportExecuteRequest.cs | 18 ++ .../Requests/ReportPersonRequest.cs | 10 + 3 files changed, 240 insertions(+) create mode 100644 BMA.EHR.Placement.Service/Requests/ReportExecuteRequest.cs create mode 100644 BMA.EHR.Placement.Service/Requests/ReportPersonRequest.cs diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index 4700c31f..d48ad9ca 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -1446,5 +1446,217 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(position); } + /// + /// ส่งรายชื่อออกคำสั่ง + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("recruit/report")] + public async Task> PostReportRecruit([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.PlacementProfiles + .Where(x => req.refIds.Contains(x.Id.ToString())) + .ToListAsync(); + foreach (var placementProfile in placementProfiles) + { + // update placementstatus + placementProfile.PlacementStatus = "PREPARE-CONTAIN"; + } + await _context.SaveChangesAsync(); + return Success(); + } + + /// + /// ออกคำสั่ง + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("recruit/report/excecute")] + public async Task> PostReportExecuteRecruit([FromBody] ReportExecuteRequest req) + { + // create new profile + foreach (var recv in req.refIds) + { + // query placement Profile + var placementProfile = await _context.PlacementProfiles + .Include(x => x.PlacementCertificates) + .Include(x => x.PlacementEducations) + .ThenInclude(x => x.EducationLevel) + .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); + + if (placementProfile == null) + continue; + + /*ข้อมูล Profile ใหม่*/ + var apiUrl = $"{_configuration["API"]}/org/profile/all"; + var profileId = string.Empty; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl); + var _res = await client.PostAsJsonAsync(apiUrl, new + { + rank = string.Empty, + prefix = placementProfile.Prefix == null ? string.Empty : placementProfile.Prefix, + firstName = placementProfile.Firstname == null ? string.Empty : placementProfile.Firstname, + lastName = placementProfile.Lastname == null ? string.Empty : placementProfile.Lastname, + citizenId = placementProfile.CitizenId == null ? string.Empty : placementProfile.CitizenId, + position = placementProfile.positionName == null ? string.Empty : placementProfile.positionName, + posLevelId = placementProfile.posLevelId == null ? string.Empty : placementProfile.posLevelId, + posTypeId = placementProfile.posTypeId == null ? string.Empty : placementProfile.posTypeId, + email = placementProfile.Email == null ? string.Empty : placementProfile.Email, + phone = placementProfile.MobilePhone == null ? string.Empty : placementProfile.MobilePhone, + keycloak = string.Empty, + isProbation = true, + isLeave = false, + dateRetire = (DateTime?)null, + dateAppoint = recv.commandAffectDate, + dateStart = recv.commandAffectDate, + govAgeAbsent = 0, + govAgePlus = 0, + birthDate = placementProfile.DateOfBirth == null ? (DateTime?)null : placementProfile.DateOfBirth, + reasonSameDate = (DateTime?)null, + ethnicity = placementProfile.Race == null ? string.Empty : placementProfile.Race, + telephoneNumber = placementProfile.Telephone == null ? string.Empty : placementProfile.Telephone, + nationality = placementProfile.Nationality == null ? string.Empty : placementProfile.Nationality, + gender = placementProfile.Gender == null ? string.Empty : placementProfile.Gender, + relationship = placementProfile.Relationship == null ? string.Empty : placementProfile.Relationship, + religion = placementProfile.Religion == null ? string.Empty : placementProfile.Religion, + bloodGroup = string.Empty, + registrationAddress = placementProfile.RegistAddress == null ? string.Empty : placementProfile.RegistAddress, + registrationProvinceId = (String?)null, + registrationDistrictId = (String?)null, + registrationSubDistrictId = (String?)null, + registrationZipCode = placementProfile.RegistZipCode == null ? string.Empty : placementProfile.RegistZipCode, + currentAddress = placementProfile.CurrentAddress == null ? string.Empty : placementProfile.CurrentAddress, + currentProvinceId = (String?)null, + currentDistrictId = (String?)null, + currentSubDistrictId = (String?)null, + currentZipCode = placementProfile.CurrentZipCode == null ? string.Empty : placementProfile.CurrentZipCode, + }); + var _result = await _res.Content.ReadAsStringAsync(); + profileId = JsonConvert.DeserializeObject(_result).result; + } + + if (placementProfile.PlacementEducations != null) + { + var apiUrlEdu = $"{_configuration["API"]}/org/profile/educations"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + foreach (var edu in placementProfile.PlacementEducations) + { + var _res = await client.PostAsJsonAsync(apiUrlEdu, new + { + profileId = profileId, + country = edu.Country == null ? string.Empty : edu.Country, + degree = edu.Degree == null ? string.Empty : edu.Degree, + duration = edu.Duration == null ? string.Empty : edu.Duration, + durationYear = edu.DurationYear == null ? 0 : edu.DurationYear, + field = edu.Field == null ? string.Empty : edu.Field, + finishDate = edu.FinishDate == null ? (DateTime?)null : edu.FinishDate, + fundName = edu.FundName == null ? string.Empty : edu.FundName, + gpa = edu.Gpa == null ? string.Empty : edu.Gpa, + institute = edu.Institute == null ? string.Empty : edu.Institute, + other = edu.Other == null ? string.Empty : edu.Other, + startDate = edu.StartDate == null ? (DateTime?)null : edu.StartDate, + endDate = edu.EndDate == null ? (DateTime?)null : edu.EndDate, + educationLevel = edu.EducationLevel == null ? string.Empty : edu.EducationLevel.Name, + educationLevelId = string.Empty, + positionPath = edu.PositionPath == null ? null : edu.PositionPath, + positionPathId = string.Empty, + isDate = edu.IsDate, + isEducation = edu.IsEducation, + note = string.Empty, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + } + } + + if (placementProfile.PlacementCertificates != null) + { + var apiUrlCer = $"{_configuration["API"]}/org/profile/certificate"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + foreach (var cer in placementProfile.PlacementCertificates) + { + var _res = await client.PostAsJsonAsync(apiUrlCer, new + { + profileId = profileId, + expireDate = cer.ExpireDate == null ? (DateTime?)null : cer.ExpireDate, + issueDate = cer.IssueDate == null ? (DateTime?)null : cer.IssueDate, + certificateNo = cer.CertificateNo == null ? string.Empty : cer.CertificateNo, + certificateType = cer.CertificateType == null ? string.Empty : cer.CertificateType, + issuer = cer.Issuer == null ? string.Empty : cer.Issuer, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + } + } + + var apiUrlSalary = $"{_configuration["API"]}/org/profile/salary"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlSalary, new + { + profileId = profileId, + date = recv.commandAffectDate, + amount = placementProfile.Amount, + positionSalaryAmount = placementProfile.PositionSalaryAmount, + mouthSalaryAmount = placementProfile.MouthSalaryAmount, + posNo = placementProfile.posMasterNo == null ? "" : + placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "", + position = placementProfile.positionName == null ? string.Empty : placementProfile.positionName, + positionLine = string.Empty, + positionPathSide = string.Empty, + positionExecutive = string.Empty, + positionType = placementProfile.posTypeName == null ? string.Empty : placementProfile.posTypeName, + positionLevel = placementProfile.posLevelName == null ? string.Empty : placementProfile.posLevelName, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + templateDoc = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/pos/report/current"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new + { + posmasterId = placementProfile.posmasterId, + positionId = placementProfile.positionId, + profileId = profileId, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + // update placementstatus + placementProfile.PlacementStatus = "CONTAIN";//DONE + + await _context.SaveChangesAsync(); + } + return Success(); + } + } } diff --git a/BMA.EHR.Placement.Service/Requests/ReportExecuteRequest.cs b/BMA.EHR.Placement.Service/Requests/ReportExecuteRequest.cs new file mode 100644 index 00000000..fc5b180c --- /dev/null +++ b/BMA.EHR.Placement.Service/Requests/ReportExecuteRequest.cs @@ -0,0 +1,18 @@ +using BMA.EHR.Domain.Models.MetaData; +using Microsoft.EntityFrameworkCore; + +namespace BMA.EHR.Placement.Service.Requests +{ + public class ReportExecuteRequest + { + public ReportExecuteRequestObj[] refIds { get; set; } + } + public class ReportExecuteRequestObj + { + public string? refId { get; set; } + public DateTime commandAffectDate { get; set; } + public string? commandNo { get; set; } + public int commandYear { get; set; } + public string? templateDoc { get; set; } + } +} diff --git a/BMA.EHR.Placement.Service/Requests/ReportPersonRequest.cs b/BMA.EHR.Placement.Service/Requests/ReportPersonRequest.cs new file mode 100644 index 00000000..e061f5a1 --- /dev/null +++ b/BMA.EHR.Placement.Service/Requests/ReportPersonRequest.cs @@ -0,0 +1,10 @@ +using BMA.EHR.Domain.Models.MetaData; +using Microsoft.EntityFrameworkCore; + +namespace BMA.EHR.Placement.Service.Requests +{ + public class ReportPersonRequest + { + public string[] refIds { get; set; } + } +} From 14b3c386e0d834f8ea00a4546d87b4637c6024c9 Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 2 Oct 2024 09:48:59 +0700 Subject: [PATCH 05/42] no message --- .../Controllers/PlacementController.cs | 225 +++++++++++++++++- 1 file changed, 223 insertions(+), 2 deletions(-) diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index d48ad9ca..7201875f 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -1447,7 +1447,7 @@ namespace BMA.EHR.Placement.Service.Controllers } /// - /// ส่งรายชื่อออกคำสั่ง + /// ส่งรายชื่อออกคำสั่ง C-PM-01 /// /// /// @@ -1458,7 +1458,11 @@ namespace BMA.EHR.Placement.Service.Controllers public async Task> PostReportRecruit([FromBody] ReportPersonRequest req) { var placementProfiles = await _context.PlacementProfiles + .Include(x => x.Placement) + .ThenInclude(x => x.PlacementType) .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Placement!.PlacementType!.Name != "สอบแข่งขัน") + .Where(x => x.typeCommand.Trim().ToUpper() == "APPOINTED") .ToListAsync(); foreach (var placementProfile in placementProfiles) { @@ -1470,7 +1474,7 @@ namespace BMA.EHR.Placement.Service.Controllers } /// - /// ออกคำสั่ง + /// ออกคำสั่ง C-PM-01 /// /// /// @@ -1658,5 +1662,222 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-02 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("candidate/report")] + public async Task> PostReportCandidate([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.PlacementProfiles + .Include(x => x.Placement) + .ThenInclude(x => x.PlacementType) + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Placement!.PlacementType!.Name != "สอบแข่งขัน") + .Where(x => x.typeCommand.Trim().ToUpper() == "APPOINTED") + .ToListAsync(); + foreach (var placementProfile in placementProfiles) + { + // update placementstatus + placementProfile.PlacementStatus = "PREPARE-CONTAIN"; + } + await _context.SaveChangesAsync(); + return Success(); + } + + /// + /// ออกคำสั่ง C-PM-02 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("candidate/report/excecute")] + public async Task> PostReportExecuteCandidate([FromBody] ReportExecuteRequest req) + { + // create new profile + foreach (var recv in req.refIds) + { + // query placement Profile + var placementProfile = await _context.PlacementProfiles + .Include(x => x.PlacementCertificates) + .Include(x => x.PlacementEducations) + .ThenInclude(x => x.EducationLevel) + .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); + + if (placementProfile == null) + continue; + + /*ข้อมูล Profile ใหม่*/ + var apiUrl = $"{_configuration["API"]}/org/profile/all"; + var profileId = string.Empty; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl); + var _res = await client.PostAsJsonAsync(apiUrl, new + { + rank = string.Empty, + prefix = placementProfile.Prefix == null ? string.Empty : placementProfile.Prefix, + firstName = placementProfile.Firstname == null ? string.Empty : placementProfile.Firstname, + lastName = placementProfile.Lastname == null ? string.Empty : placementProfile.Lastname, + citizenId = placementProfile.CitizenId == null ? string.Empty : placementProfile.CitizenId, + position = placementProfile.positionName == null ? string.Empty : placementProfile.positionName, + posLevelId = placementProfile.posLevelId == null ? string.Empty : placementProfile.posLevelId, + posTypeId = placementProfile.posTypeId == null ? string.Empty : placementProfile.posTypeId, + email = placementProfile.Email == null ? string.Empty : placementProfile.Email, + phone = placementProfile.MobilePhone == null ? string.Empty : placementProfile.MobilePhone, + keycloak = string.Empty, + isProbation = true, + isLeave = false, + dateRetire = (DateTime?)null, + dateAppoint = recv.commandAffectDate, + dateStart = recv.commandAffectDate, + govAgeAbsent = 0, + govAgePlus = 0, + birthDate = placementProfile.DateOfBirth == null ? (DateTime?)null : placementProfile.DateOfBirth, + reasonSameDate = (DateTime?)null, + ethnicity = placementProfile.Race == null ? string.Empty : placementProfile.Race, + telephoneNumber = placementProfile.Telephone == null ? string.Empty : placementProfile.Telephone, + nationality = placementProfile.Nationality == null ? string.Empty : placementProfile.Nationality, + gender = placementProfile.Gender == null ? string.Empty : placementProfile.Gender, + relationship = placementProfile.Relationship == null ? string.Empty : placementProfile.Relationship, + religion = placementProfile.Religion == null ? string.Empty : placementProfile.Religion, + bloodGroup = string.Empty, + registrationAddress = placementProfile.RegistAddress == null ? string.Empty : placementProfile.RegistAddress, + registrationProvinceId = (String?)null, + registrationDistrictId = (String?)null, + registrationSubDistrictId = (String?)null, + registrationZipCode = placementProfile.RegistZipCode == null ? string.Empty : placementProfile.RegistZipCode, + currentAddress = placementProfile.CurrentAddress == null ? string.Empty : placementProfile.CurrentAddress, + currentProvinceId = (String?)null, + currentDistrictId = (String?)null, + currentSubDistrictId = (String?)null, + currentZipCode = placementProfile.CurrentZipCode == null ? string.Empty : placementProfile.CurrentZipCode, + }); + var _result = await _res.Content.ReadAsStringAsync(); + profileId = JsonConvert.DeserializeObject(_result).result; + } + + if (placementProfile.PlacementEducations != null) + { + var apiUrlEdu = $"{_configuration["API"]}/org/profile/educations"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + foreach (var edu in placementProfile.PlacementEducations) + { + var _res = await client.PostAsJsonAsync(apiUrlEdu, new + { + profileId = profileId, + country = edu.Country == null ? string.Empty : edu.Country, + degree = edu.Degree == null ? string.Empty : edu.Degree, + duration = edu.Duration == null ? string.Empty : edu.Duration, + durationYear = edu.DurationYear == null ? 0 : edu.DurationYear, + field = edu.Field == null ? string.Empty : edu.Field, + finishDate = edu.FinishDate == null ? (DateTime?)null : edu.FinishDate, + fundName = edu.FundName == null ? string.Empty : edu.FundName, + gpa = edu.Gpa == null ? string.Empty : edu.Gpa, + institute = edu.Institute == null ? string.Empty : edu.Institute, + other = edu.Other == null ? string.Empty : edu.Other, + startDate = edu.StartDate == null ? (DateTime?)null : edu.StartDate, + endDate = edu.EndDate == null ? (DateTime?)null : edu.EndDate, + educationLevel = edu.EducationLevel == null ? string.Empty : edu.EducationLevel.Name, + educationLevelId = string.Empty, + positionPath = edu.PositionPath == null ? null : edu.PositionPath, + positionPathId = string.Empty, + isDate = edu.IsDate, + isEducation = edu.IsEducation, + note = string.Empty, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + } + } + + if (placementProfile.PlacementCertificates != null) + { + var apiUrlCer = $"{_configuration["API"]}/org/profile/certificate"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + foreach (var cer in placementProfile.PlacementCertificates) + { + var _res = await client.PostAsJsonAsync(apiUrlCer, new + { + profileId = profileId, + expireDate = cer.ExpireDate == null ? (DateTime?)null : cer.ExpireDate, + issueDate = cer.IssueDate == null ? (DateTime?)null : cer.IssueDate, + certificateNo = cer.CertificateNo == null ? string.Empty : cer.CertificateNo, + certificateType = cer.CertificateType == null ? string.Empty : cer.CertificateType, + issuer = cer.Issuer == null ? string.Empty : cer.Issuer, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + } + } + + var apiUrlSalary = $"{_configuration["API"]}/org/profile/salary"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlSalary, new + { + profileId = profileId, + date = recv.commandAffectDate, + amount = placementProfile.Amount, + positionSalaryAmount = placementProfile.PositionSalaryAmount, + mouthSalaryAmount = placementProfile.MouthSalaryAmount, + posNo = placementProfile.posMasterNo == null ? "" : + placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "", + position = placementProfile.positionName == null ? string.Empty : placementProfile.positionName, + positionLine = string.Empty, + positionPathSide = string.Empty, + positionExecutive = string.Empty, + positionType = placementProfile.posTypeName == null ? string.Empty : placementProfile.posTypeName, + positionLevel = placementProfile.posLevelName == null ? string.Empty : placementProfile.posLevelName, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + templateDoc = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/pos/report/current"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new + { + posmasterId = placementProfile.posmasterId, + positionId = placementProfile.positionId, + profileId = profileId, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + // update placementstatus + placementProfile.PlacementStatus = "CONTAIN";//DONE + + await _context.SaveChangesAsync(); + } + return Success(); + } + } } From 9b6db93a5fc6de3b7108f3b1bfdee192e60f2d5e Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 2 Oct 2024 11:25:45 +0700 Subject: [PATCH 06/42] no message --- .../PlacementAppointmentController.cs | 155 ++++++++++++ .../Controllers/PlacementController.cs | 229 +++++++++++++++++- .../Requests/ReportExecuteRequest.cs | 3 + 3 files changed, 382 insertions(+), 5 deletions(-) diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs index 20d533d4..40ae00ea 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs @@ -1,6 +1,7 @@ using BMA.EHR.Application.Repositories; using BMA.EHR.Application.Repositories.MessageQueue; using BMA.EHR.Domain.Common; +using BMA.EHR.Domain.Extensions; using BMA.EHR.Domain.Models.Placement; using BMA.EHR.Domain.Shared; using BMA.EHR.Infrastructure.Persistence; @@ -741,5 +742,159 @@ namespace BMA.EHR.Placement.Service.Controllers .ToListAsync(); return Success(appointments); } + + /// + /// ออกคำสั่ง C-PM-05 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("appoint/report/excecute")] + public async Task> PostReportExecuteAppoint([FromBody] ReportExecuteRequest req) + { + // create new profile + foreach (var recv in req.refIds) + { + var placementProfile = await _context.PlacementAppointments + .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); + if (placementProfile == null) + continue; + + if (placementProfile == null) + throw new Exception(GlobalMessages.DataNotFound); + var baseAPI = _configuration["API"]; + var apiUrlSalary = $"{baseAPI}/org/profile/salary"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); + var _res = await client.PostAsJsonAsync(apiUrlSalary, new + { + profileId = placementProfile.profileId, + date = recv.commandAffectDate, + amount = recv.amount, + positionSalaryAmount = recv.positionSalaryAmount, + mouthSalaryAmount = recv.mouthSalaryAmount, + posNo = placementProfile.posMasterNo == null ? "" : + placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "", + position = placementProfile.position, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = placementProfile.posTypeName, + positionLevel = placementProfile.posLevelName, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + templateDoc = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/pos/report/current"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new + { + posmasterId = placementProfile.posmasterId, + positionId = placementProfile.positionId, + profileId = placementProfile.profileId, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + // update placementstatus + placementProfile.Status = "DONE"; + + await _context.SaveChangesAsync(); + } + return Success(); + } + + /// + /// ออกคำสั่ง C-PM-06 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("slip/report/excecute")] + public async Task> PostReportExecuteSlip([FromBody] ReportExecuteRequest req) + { + // create new profile + foreach (var recv in req.refIds) + { + var placementProfile = await _context.PlacementAppointments + .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); + if (placementProfile == null) + continue; + + if (placementProfile == null) + throw new Exception(GlobalMessages.DataNotFound); + var baseAPI = _configuration["API"]; + var apiUrlSalary = $"{baseAPI}/org/profile/salary"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); + var _res = await client.PostAsJsonAsync(apiUrlSalary, new + { + profileId = placementProfile.profileId, + date = recv.commandAffectDate, + amount = recv.amount, + positionSalaryAmount = recv.positionSalaryAmount, + mouthSalaryAmount = recv.mouthSalaryAmount, + posNo = placementProfile.posMasterNo == null ? "" : + placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "", + position = placementProfile.position, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = placementProfile.posTypeName, + positionLevel = placementProfile.posLevelName, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + templateDoc = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/pos/report/current"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new + { + posmasterId = placementProfile.posmasterId, + positionId = placementProfile.positionId, + profileId = placementProfile.profileId, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + // update placementstatus + placementProfile.Status = "DONE"; + + await _context.SaveChangesAsync(); + } + return Success(); + } } } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index 7201875f..857222a5 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -2,7 +2,6 @@ using BMA.EHR.Application.Repositories.MessageQueue; using BMA.EHR.Domain.Common; using BMA.EHR.Domain.Extensions; -using BMA.EHR.Domain.Models.MetaData; using BMA.EHR.Domain.Models.Placement; using BMA.EHR.Domain.Shared; using BMA.EHR.Infrastructure.Persistence; @@ -12,13 +11,9 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Swashbuckle.AspNetCore.Annotations; using System.Security.Claims; -using System.Security.Cryptography; -using Microsoft.Extensions.Configuration; using System.Net.Http.Headers; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using Microsoft.AspNetCore.Http.HttpResults; -using System.Drawing.Drawing2D; namespace BMA.EHR.Placement.Service.Controllers { @@ -1879,5 +1874,229 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// ออกคำสั่ง C-PM-03 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("appoint/report/excecute")] + public async Task> PostReportExecuteAppoint([FromBody] ReportExecuteRequest req) + { + // create new profile + foreach (var recv in req.refIds) + { + var placementProfile = await _context.PlacementProfiles + .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); + if (placementProfile == null) + continue; + + var baseAPI = _configuration["API"]; + var apiUrlSalary = $"{baseAPI}/org/profile/salary"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); + var _res = await client.PostAsJsonAsync(apiUrlSalary, new + { + profileId = placementProfile.profileId, + date = recv.commandAffectDate, + amount = recv.amount, + positionSalaryAmount = recv.positionSalaryAmount, + mouthSalaryAmount = recv.mouthSalaryAmount, + posNo = placementProfile.posMasterNo == null ? "" : + placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "", + position = placementProfile.positionName, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = placementProfile.posTypeName, + positionLevel = placementProfile.posLevelName, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + templateDoc = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/pos/report/current"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new + { + posmasterId = placementProfile.posmasterId, + positionId = placementProfile.positionId, + profileId = placementProfile.profileId, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + // update placementstatus + placementProfile.PlacementStatus = "CONTAIN"; + + await _context.SaveChangesAsync(); + } + return Success(); + } + + /// + /// ออกคำสั่ง C-PM-04 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("move/report/excecute")] + public async Task> PostReportExecuteMove([FromBody] ReportExecuteRequest req) + { + // create new profile + foreach (var recv in req.refIds) + { + var placementProfile = await _context.PlacementProfiles + .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); + if (placementProfile == null) + continue; + + var baseAPI = _configuration["API"]; + var apiUrlSalary = $"{baseAPI}/org/profile/salary"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); + var _res = await client.PostAsJsonAsync(apiUrlSalary, new + { + profileId = placementProfile.profileId, + date = recv.commandAffectDate, + amount = recv.amount, + positionSalaryAmount = recv.positionSalaryAmount, + mouthSalaryAmount = recv.mouthSalaryAmount, + posNo = placementProfile.posMasterNo == null ? "" : + placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "", + position = placementProfile.positionName, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = placementProfile.posTypeName, + positionLevel = placementProfile.posLevelName, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + templateDoc = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/pos/report/current"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new + { + posmasterId = placementProfile.posmasterId, + positionId = placementProfile.positionId, + profileId = placementProfile.profileId, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + // update placementstatus + placementProfile.PlacementStatus = "CONTAIN"; + + await _context.SaveChangesAsync(); + } + return Success(); + } + + /// + /// ออกคำสั่ง C-PM-39 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("slip/report/excecute")] + public async Task> PostReportExecuteSlip([FromBody] ReportExecuteRequest req) + { + // create new profile + foreach (var recv in req.refIds) + { + var placementProfile = await _context.PlacementProfiles + .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); + if (placementProfile == null) + continue; + + var baseAPI = _configuration["API"]; + var apiUrlSalary = $"{baseAPI}/org/profile/salary"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); + var _res = await client.PostAsJsonAsync(apiUrlSalary, new + { + profileId = placementProfile.profileId, + date = recv.commandAffectDate, + amount = recv.amount, + positionSalaryAmount = recv.positionSalaryAmount, + mouthSalaryAmount = recv.mouthSalaryAmount, + posNo = placementProfile.posMasterNo == null ? "" : + placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "", + position = placementProfile.positionName, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = placementProfile.posTypeName, + positionLevel = placementProfile.posLevelName, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + templateDoc = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/pos/report/current"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new + { + posmasterId = placementProfile.posmasterId, + positionId = placementProfile.positionId, + profileId = placementProfile.profileId, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + // update placementstatus + placementProfile.PlacementStatus = "CONTAIN"; + + await _context.SaveChangesAsync(); + } + return Success(); + } } } diff --git a/BMA.EHR.Placement.Service/Requests/ReportExecuteRequest.cs b/BMA.EHR.Placement.Service/Requests/ReportExecuteRequest.cs index fc5b180c..7718c354 100644 --- a/BMA.EHR.Placement.Service/Requests/ReportExecuteRequest.cs +++ b/BMA.EHR.Placement.Service/Requests/ReportExecuteRequest.cs @@ -14,5 +14,8 @@ namespace BMA.EHR.Placement.Service.Requests public string? commandNo { get; set; } public int commandYear { get; set; } public string? templateDoc { get; set; } + public double? amount { get; set; } + public double? positionSalaryAmount { get; set; } + public double? mouthSalaryAmount { get; set; } } } From 27aa7a773d13540ca78fa2979c29f7079261b78d Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 2 Oct 2024 12:04:06 +0700 Subject: [PATCH 07/42] =?UTF-8?q?=E0=B8=AA=E0=B9=88=E0=B8=87=E0=B8=A3?= =?UTF-8?q?=E0=B8=B2=E0=B8=A2=E0=B8=8A=E0=B8=B7=E0=B9=88=E0=B8=AD=E0=B8=AD?= =?UTF-8?q?=E0=B8=AD=E0=B8=81=E0=B8=84=E0=B8=B3=E0=B8=AA=E0=B8=B1=E0=B9=88?= =?UTF-8?q?=E0=B8=87=203,=204,=2039,=205,=206?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlacementAppointmentController.cs | 54 +++++++++++++ .../Controllers/PlacementController.cs | 81 +++++++++++++++++++ 2 files changed, 135 insertions(+) diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs index 40ae00ea..307aa88a 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs @@ -743,6 +743,33 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(appointments); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-05 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("appoint/report")] + public async Task> PostReportAppoint([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.PlacementProfiles + .Include(x => x.Placement) + .ThenInclude(x => x.PlacementType) + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Placement!.PlacementType!.Name == "คำสั่งแต่งตั้ง") + .Where(x => x.typeCommand.Trim().ToUpper() == "REPORT") + .ToListAsync(); + foreach (var placementProfile in placementProfiles) + { + // update placementstatus + placementProfile.PlacementStatus = "PREPARE-CONTAIN"; + } + await _context.SaveChangesAsync(); + return Success(); + } + /// /// ออกคำสั่ง C-PM-05 /// @@ -820,6 +847,33 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-06 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("slip/report")] + public async Task> PostReportSlip([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.PlacementProfiles + .Include(x => x.Placement) + .ThenInclude(x => x.PlacementType) + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Placement!.PlacementType!.Name == "เลื่อนข้าราชการ") + .Where(x => x.typeCommand.Trim().ToUpper() == "REPORT") + .ToListAsync(); + foreach (var placementProfile in placementProfiles) + { + // update placementstatus + placementProfile.PlacementStatus = "PREPARE-CONTAIN"; + } + await _context.SaveChangesAsync(); + return Success(); + } + /// /// ออกคำสั่ง C-PM-06 /// diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index 857222a5..d79907a0 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -1874,6 +1874,33 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-03 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("appoint/report")] + public async Task> PostReportAppoint([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.PlacementProfiles + .Include(x => x.Placement) + .ThenInclude(x => x.PlacementType) + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Placement!.PlacementType!.Name == "แต่งตั้งข้าราชการ") + .Where(x => x.typeCommand.Trim().ToUpper() == "APPOIN") + .ToListAsync(); + foreach (var placementProfile in placementProfiles) + { + // update placementstatus + placementProfile.PlacementStatus = "PREPARE-CONTAIN"; + } + await _context.SaveChangesAsync(); + return Success(); + } + /// /// ออกคำสั่ง C-PM-03 /// @@ -1949,6 +1976,33 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-04 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("move/report")] + public async Task> PostReportMove([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.PlacementProfiles + .Include(x => x.Placement) + .ThenInclude(x => x.PlacementType) + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Placement!.PlacementType!.Name == "ย้ายข้าราชการ") + .Where(x => x.typeCommand.Trim().ToUpper() == "MOVE") + .ToListAsync(); + foreach (var placementProfile in placementProfiles) + { + // update placementstatus + placementProfile.PlacementStatus = "PREPARE-CONTAIN"; + } + await _context.SaveChangesAsync(); + return Success(); + } + /// /// ออกคำสั่ง C-PM-04 /// @@ -2024,6 +2078,33 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-39 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("slip/report")] + public async Task> PostReportSlip([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.PlacementProfiles + .Include(x => x.Placement) + .ThenInclude(x => x.PlacementType) + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Placement!.PlacementType!.Name == "เลื่อนข้าราชการ") + .Where(x => x.typeCommand.Trim().ToUpper() == "SLIP") + .ToListAsync(); + foreach (var placementProfile in placementProfiles) + { + // update placementstatus + placementProfile.PlacementStatus = "PREPARE-CONTAIN"; + } + await _context.SaveChangesAsync(); + return Success(); + } + /// /// ออกคำสั่ง C-PM-39 /// From a3ed79227bbefa2b49b835375ea487ac5fb76056 Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 2 Oct 2024 13:06:05 +0700 Subject: [PATCH 08/42] no message --- .../PlacementAppointmentController.cs | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs index 307aa88a..57e7973a 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs @@ -950,5 +950,79 @@ namespace BMA.EHR.Placement.Service.Controllers } return Success(); } + + /// + /// ออกคำสั่ง C-PM-07 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("move/report/excecute")] + public async Task> PostReportExecuteMove([FromBody] ReportExecuteRequest req) + { + // create new profile + foreach (var recv in req.refIds) + { + var placementProfile = await _context.PlacementAppointments + .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); + if (placementProfile == null) + continue; + var baseAPI = _configuration["API"]; + var apiUrlSalary = $"{baseAPI}/org/profile/salary"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); + var _res = await client.PostAsJsonAsync(apiUrlSalary, new + { + profileId = placementProfile.profileId, + date = recv.commandAffectDate, + amount = recv.amount, + positionSalaryAmount = recv.positionSalaryAmount, + mouthSalaryAmount = recv.mouthSalaryAmount, + posNo = placementProfile.posMasterNo == null ? "" : + placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "", + position = placementProfile.position, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = placementProfile.posTypeName, + positionLevel = placementProfile.posLevelName, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + templateDoc = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/pos/report/current"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new + { + posmasterId = placementProfile.posmasterId, + positionId = placementProfile.positionId, + profileId = placementProfile.profileId, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + // update placementstatus + placementProfile.Status = "DONE"; + + await _context.SaveChangesAsync(); + } + return Success(); + } } } From 874d310b35b66377d2e387bdb983bcbe0c6f7d6d Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 2 Oct 2024 13:24:16 +0700 Subject: [PATCH 09/42] no message --- .../Controllers/PlacementController.cs | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index d79907a0..402fe56b 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -1468,6 +1468,64 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// เอกสารแนบท้าย C-PM-01 + /// + /// Record Id ของคำสั่ง + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("recruit/report/attachment")] + [AllowAnonymous] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> PostReportRecruitAttachment([FromBody] ReportPersonRequest req) + { + try + { + var report_data = "null"; + // var report_data = (from r in req.refIds + // join p in _dbContext.Set() + // .Include(x => x.PlacementEducations) + // .Include(x => x.Placement) + // on r equals p.Id + // orderby r.Sequence + // select new CommandType01Response + // { + // Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" : + // p.PlacementEducations.FirstOrDefault().Degree, + // Seq = r.Sequence.ToString().ToThaiNumber(), + // CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + // FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + // Oc = p.root == null ? "" : p.root, + // PositionName = p.positionName == null ? "" : p.positionName, + // PositionLevel = p.posLevelName == null ? "" : p.posLevelName, + // PositionType = p.posTypeName == null ? "" : p.posTypeName, + // PositionNumber = p.posMasterNo == null ? "" : + // p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : + // p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : + // p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : + // p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : + // p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", + // Salary = p.Amount == null ? "0" : p.Amount.Value.ToNumericNoDecimalText().ToThaiNumber().ToThaiNumber(), + // AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), + // ExamNumber = p.ExamNumber == null ? "0" : p.ExamNumber.Value.ToString().ToThaiNumber(), + // PlacementName = $"{p.Placement.Name.ToThaiNumber()} ครั้งที่ {p.Placement.Round.ToThaiNumber()}/{p.Placement.Year.ToThaiYear().ToString().ToThaiNumber()}", + // RemarkHorizontal = p.RemarkHorizontal, + // RemarkVertical = p.RemarkVertical, + // }).ToList(); + + return Success(report_data); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-01 /// From 0e5946db71a40f87a013fe09a5c692be4e7ede9e Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 2 Oct 2024 14:51:16 +0700 Subject: [PATCH 10/42] =?UTF-8?q?=E0=B9=81=E0=B8=99=E0=B8=9A=E0=B8=97?= =?UTF-8?q?=E0=B9=89=E0=B8=B2=E0=B8=A2=201=202=203=204=2039=205=206=207?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlacementAppointmentController.cs | 221 +++++++++++- .../Controllers/PlacementController.cs | 333 ++++++++++++++++-- 2 files changed, 509 insertions(+), 45 deletions(-) diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs index 57e7973a..77b70913 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs @@ -754,22 +754,79 @@ namespace BMA.EHR.Placement.Service.Controllers [HttpPost("appoint/report")] public async Task> PostReportAppoint([FromBody] ReportPersonRequest req) { - var placementProfiles = await _context.PlacementProfiles - .Include(x => x.Placement) - .ThenInclude(x => x.PlacementType) + var placementProfiles = await _context.PlacementAppointments .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Placement!.PlacementType!.Name == "คำสั่งแต่งตั้ง") - .Where(x => x.typeCommand.Trim().ToUpper() == "REPORT") .ToListAsync(); foreach (var placementProfile in placementProfiles) { // update placementstatus - placementProfile.PlacementStatus = "PREPARE-CONTAIN"; + placementProfile.Status = "REPORT"; } await _context.SaveChangesAsync(); return Success(); } + /// + /// เอกสารแนบท้าย C-PM-5 + /// + /// Record Id ของคำสั่ง + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("appoint/report/attachment")] + [AllowAnonymous] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> PostReportAppointAttachment([FromBody] ReportPersonRequest req) + { + try + { + var report_data = await _context.PlacementAppointments + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Select(p => new + { + Education = p.EducationOld == null ? "-" : p.EducationOld, + //Seq = r.Sequence.ToString().ToThaiNumber(), + //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + Seq = "", + CitizenId = "", + FullName = "", + OldOc = p.rootOld == null ? "" : p.rootOld, + OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, + OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, + OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, + OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), + OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), + NewOc = p.root == null ? "" : p.root, + NewPositionName = p.position == null ? "" : p.position, + NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, + NewPositionType = p.posTypeName == null ? "" : p.posTypeName, + NewPositionNumber = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", + //NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), + NewSalary = "", + AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), + Reason = p.Reason == null ? "-" : p.Reason + + }) + .ToListAsync(); + return Success(report_data); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-05 /// @@ -858,22 +915,79 @@ namespace BMA.EHR.Placement.Service.Controllers [HttpPost("slip/report")] public async Task> PostReportSlip([FromBody] ReportPersonRequest req) { - var placementProfiles = await _context.PlacementProfiles - .Include(x => x.Placement) - .ThenInclude(x => x.PlacementType) + var placementProfiles = await _context.PlacementAppointments .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Placement!.PlacementType!.Name == "เลื่อนข้าราชการ") - .Where(x => x.typeCommand.Trim().ToUpper() == "REPORT") .ToListAsync(); foreach (var placementProfile in placementProfiles) { // update placementstatus - placementProfile.PlacementStatus = "PREPARE-CONTAIN"; + placementProfile.Status = "REPORT"; } await _context.SaveChangesAsync(); return Success(); } + /// + /// เอกสารแนบท้าย C-PM-6 + /// + /// Record Id ของคำสั่ง + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("slip/report/attachment")] + [AllowAnonymous] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> PostReporSlipAttachment([FromBody] ReportPersonRequest req) + { + try + { + var report_data = await _context.PlacementAppointments + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Select(p => new + { + Education = p.EducationOld == null ? "-" : p.EducationOld, + //Seq = r.Sequence.ToString().ToThaiNumber(), + //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + Seq = "", + CitizenId = "", + FullName = "", + OldOc = p.rootOld == null ? "" : p.rootOld, + OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, + OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, + OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, + OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), + OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), + NewOc = p.root == null ? "" : p.root, + NewPositionName = p.position == null ? "" : p.position, + NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, + NewPositionType = p.posTypeName == null ? "" : p.posTypeName, + NewPositionNumber = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", + //NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), + NewSalary = "", + AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), + Reason = p.Reason == null ? "-" : p.Reason + + }) + .ToListAsync(); + return Success(report_data); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-06 /// @@ -951,6 +1065,89 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-07 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("move/report")] + public async Task> PostReportMove([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.PlacementAppointments + .Where(x => req.refIds.Contains(x.Id.ToString())) + .ToListAsync(); + foreach (var placementProfile in placementProfiles) + { + // update placementstatus + placementProfile.Status = "REPORT"; + } + await _context.SaveChangesAsync(); + return Success(); + } + + /// + /// เอกสารแนบท้าย C-PM-7 + /// + /// Record Id ของคำสั่ง + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("move/report/attachment")] + [AllowAnonymous] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> PostReporMoveAttachment([FromBody] ReportPersonRequest req) + { + try + { + var report_data = await _context.PlacementAppointments + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Select(p => new + { + Education = p.EducationOld == null ? "-" : p.EducationOld, + //Seq = r.Sequence.ToString().ToThaiNumber(), + //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + Seq = "", + CitizenId = "", + FullName = "", + OldOc = p.rootOld == null ? "" : p.rootOld, + OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, + OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, + OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, + OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), + OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), + NewOc = p.root == null ? "" : p.root, + NewPositionName = p.position == null ? "" : p.position, + NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, + NewPositionType = p.posTypeName == null ? "" : p.posTypeName, + NewPositionNumber = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", + //NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), + NewSalary = "", + AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), + Reason = p.Reason == null ? "-" : p.Reason + }) + .ToListAsync(); + return Success(report_data); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-07 /// diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index 402fe56b..2d5d3044 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -1477,7 +1477,7 @@ namespace BMA.EHR.Placement.Service.Controllers /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpGet("recruit/report/attachment")] + [HttpPost("recruit/report/attachment")] [AllowAnonymous] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] @@ -1486,38 +1486,40 @@ namespace BMA.EHR.Placement.Service.Controllers { try { - var report_data = "null"; - // var report_data = (from r in req.refIds - // join p in _dbContext.Set() - // .Include(x => x.PlacementEducations) - // .Include(x => x.Placement) - // on r equals p.Id - // orderby r.Sequence - // select new CommandType01Response - // { - // Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" : - // p.PlacementEducations.FirstOrDefault().Degree, - // Seq = r.Sequence.ToString().ToThaiNumber(), - // CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), - // FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - // Oc = p.root == null ? "" : p.root, - // PositionName = p.positionName == null ? "" : p.positionName, - // PositionLevel = p.posLevelName == null ? "" : p.posLevelName, - // PositionType = p.posTypeName == null ? "" : p.posTypeName, - // PositionNumber = p.posMasterNo == null ? "" : - // p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : - // p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : - // p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : - // p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : - // p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", - // Salary = p.Amount == null ? "0" : p.Amount.Value.ToNumericNoDecimalText().ToThaiNumber().ToThaiNumber(), - // AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), - // ExamNumber = p.ExamNumber == null ? "0" : p.ExamNumber.Value.ToString().ToThaiNumber(), - // PlacementName = $"{p.Placement.Name.ToThaiNumber()} ครั้งที่ {p.Placement.Round.ToThaiNumber()}/{p.Placement.Year.ToThaiYear().ToString().ToThaiNumber()}", - // RemarkHorizontal = p.RemarkHorizontal, - // RemarkVertical = p.RemarkVertical, - // }).ToList(); - + var report_data = await _context.PlacementProfiles + .Include(x => x.Placement) + .ThenInclude(x => x.PlacementType) + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Placement!.PlacementType!.Name != "สอบแข่งขัน") + .Where(x => x.typeCommand.Trim().ToUpper() == "APPOINTED") + .Select(p => new + { + Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" : + p.PlacementEducations.FirstOrDefault().Degree, + //Seq = r.Sequence.ToString().ToThaiNumber(), + //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + Seq = "", + CitizenId = "", + FullName = "", + Oc = p.root == null ? "" : p.root, + PositionName = p.positionName == null ? "" : p.positionName, + PositionLevel = p.posLevelName == null ? "" : p.posLevelName, + PositionType = p.posTypeName == null ? "" : p.posTypeName, + PositionNumber = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", + Salary = p.Amount == null ? "0" : p.Amount.Value.ToNumericNoDecimalText().ToThaiNumber().ToThaiNumber(), + AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), + ExamNumber = p.ExamNumber == null ? "0" : p.ExamNumber.Value.ToString().ToThaiNumber(), + PlacementName = $"{p.Placement.Name.ToThaiNumber()} ครั้งที่ {p.Placement.Round.ToThaiNumber()}/{p.Placement.Year.ToThaiYear().ToString().ToThaiNumber()}", + RemarkHorizontal = p.RemarkHorizontal, + RemarkVertical = p.RemarkVertical, + }) + .ToListAsync(); return Success(report_data); } catch @@ -1743,6 +1745,66 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// เอกสารแนบท้าย C-PM-02 + /// + /// Record Id ของคำสั่ง + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("candidate/report/attachment")] + [AllowAnonymous] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> PostReportCandidateAttachment([FromBody] ReportPersonRequest req) + { + try + { + var report_data = await _context.PlacementProfiles + .Include(x => x.Placement) + .ThenInclude(x => x.PlacementType) + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Placement!.PlacementType!.Name != "สอบแข่งขัน") + .Where(x => x.typeCommand.Trim().ToUpper() == "APPOINTED") + .Select(p => new + { + Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" : + p.PlacementEducations.FirstOrDefault().Degree, + //Seq = r.Sequence.ToString().ToThaiNumber(), + //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + Seq = "", + CitizenId = "", + FullName = "", + Oc = p.root == null ? "" : p.root, + PositionName = p.positionName == null ? "" : p.positionName, + PositionLevel = p.posLevelName == null ? "" : p.posLevelName, + PositionType = p.posTypeName == null ? "" : p.posTypeName, + PositionNumber = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", + Salary = p.Amount == null ? "0" : p.Amount.Value.ToNumericNoDecimalText().ToThaiNumber().ToThaiNumber(), + AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), + ExamNumber = p.ExamNumber == null ? "0" : p.ExamNumber.Value.ToString().ToThaiNumber(), + PlacementName = $"{p.Placement.Name.ToThaiNumber()} ครั้งที่ {p.Placement.Round.ToThaiNumber()}/{p.Placement.Year.ToThaiYear().ToString().ToThaiNumber()}", + RemarkHorizontal = p.RemarkHorizontal, + RemarkVertical = p.RemarkVertical, + }) + .ToListAsync(); + return Success(report_data); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-02 /// @@ -1959,6 +2021,77 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// เอกสารแนบท้าย C-PM-03 + /// + /// Record Id ของคำสั่ง + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("appoint/report/attachment")] + [AllowAnonymous] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> PostReportAppointAttachment([FromBody] ReportPersonRequest req) + { + try + { + var report_data = await _context.PlacementProfiles + .Include(x => x.Placement) + .ThenInclude(x => x.PlacementType) + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Placement!.PlacementType!.Name == "แต่งตั้งข้าราชการ") + .Where(x => x.typeCommand.Trim().ToUpper() == "APPOIN") + .Select(p => new + { + Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" : + p.PlacementEducations.FirstOrDefault().Degree, + //Seq = r.Sequence.ToString().ToThaiNumber(), + //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + Seq = "", + CitizenId = "", + FullName = "", + OldOc = p.rootOld == null ? "" : p.rootOld, + Probation = "", + OldPositionName = p.positionNameOld == null ? "" : p.positionNameOld, + OldPositionLevel = p.posLevelNameOld == null ? "" : p.posLevelNameOld, + OldPositionType = p.posTypeNameOld == null ? "" : p.posTypeNameOld, + OldPositionNumber = p.posMasterNoOld == null ? "" : + p.nodeOld == "4" ? $"{p.child4ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : + p.nodeOld == "3" ? $"{p.child3ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : + p.nodeOld == "2" ? $"{p.child2ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : + p.nodeOld == "1" ? $"{p.child1ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : + p.nodeOld == "0" ? $"{p.rootShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : "", + OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + + NewOc = p.root == null ? "" : p.root, + NewPositionName = p.positionName == null ? "" : p.positionName, + NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, + NewPositionType = p.posTypeName == null ? "" : p.posTypeName, + NewPositionNumber = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", + NewSalary = p.Amount == null ? "" : p.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), + AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), + RemarkHorizontal = p.RemarkHorizontal, + RemarkVertical = p.RemarkVertical + }) + .ToListAsync(); + return Success(report_data); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-03 /// @@ -2061,6 +2194,73 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// เอกสารแนบท้าย C-PM-04 + /// + /// Record Id ของคำสั่ง + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("move/report/attachment")] + [AllowAnonymous] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> PostReportMoveAttachment([FromBody] ReportPersonRequest req) + { + try + { + var report_data = await _context.PlacementProfiles + .Include(x => x.Placement) + .ThenInclude(x => x.PlacementType) + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Placement!.PlacementType!.Name == "แต่งตั้งข้าราชการ") + .Where(x => x.typeCommand.Trim().ToUpper() == "APPOIN") + .Select(p => new + { + Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "": + p.PlacementEducations.FirstOrDefault().Degree, + //Seq = r.Sequence.ToString().ToThaiNumber(), + //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + Seq = "", + CitizenId = "", + FullName = "", + OldOc = p.rootOld == null ? "" : p.rootOld, + OldPositionName = p.positionNameOld == null ? "" : p.positionNameOld, + OldPositionLevel = p.posLevelNameOld == null ? "" : p.posLevelNameOld, + OldPositionType = p.posTypeNameOld == null ? "" : p.posTypeNameOld, + OldPositionNumber = p.posMasterNoOld == null ? "" : + p.nodeOld == "4" ? $"{p.child4ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : + p.nodeOld == "3" ? $"{p.child3ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : + p.nodeOld == "2" ? $"{p.child2ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : + p.nodeOld == "1" ? $"{p.child1ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : + p.nodeOld == "0" ? $"{p.rootShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : "", + OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + NewOc = p.root == null ? "" : p.root, + NewPositionName = p.positionName == null ? "" : p.positionName, + NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, + NewPositionType = p.posTypeName == null ? "" : p.posTypeName, + NewPositionNumber = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", + NewSalary = p.Amount == null ? "" : p.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), + AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber() + }) + .ToListAsync(); + return Success(report_data); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-04 /// @@ -2163,6 +2363,73 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// เอกสารแนบท้าย C-PM-39 + /// + /// Record Id ของคำสั่ง + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("slip/report/attachment")] + [AllowAnonymous] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> PostReportSlipAttachment([FromBody] ReportPersonRequest req) + { + try + { + var report_data = await _context.PlacementProfiles + .Include(x => x.Placement) + .ThenInclude(x => x.PlacementType) + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Placement!.PlacementType!.Name == "เลื่อนข้าราชการ") + .Where(x => x.typeCommand.Trim().ToUpper() == "SLIP") + .Select(p => new + { + Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" : + p.PlacementEducations.FirstOrDefault().Degree, + //Seq = r.Sequence.ToString().ToThaiNumber(), + //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + Seq = "", + CitizenId = "", + FullName = "", + OldOc = p.rootOld == null ? "" : p.rootOld, + OldPositionName = p.positionNameOld == null ? "" : p.positionNameOld, + OldPositionLevel = p.posLevelNameOld == null ? "" : p.posLevelNameOld, + OldPositionType = p.posTypeNameOld == null ? "" : p.posTypeNameOld, + OldPositionNumber = p.posMasterNoOld == null ? "" : + p.nodeOld == "4" ? $"{p.child4ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : + p.nodeOld == "3" ? $"{p.child3ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : + p.nodeOld == "2" ? $"{p.child2ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : + p.nodeOld == "1" ? $"{p.child1ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : + p.nodeOld == "0" ? $"{p.rootShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : "", + OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + NewOc = p.root == null ? "" : p.root, + NewPositionName = p.positionName == null ? "" : p.positionName, + NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, + NewPositionType = p.posTypeName == null ? "" : p.posTypeName, + NewPositionNumber = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", + NewSalary = p.Amount == null ? "" : p.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), + AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber() + }) + .ToListAsync(); + return Success(report_data); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-39 /// From bce6732bdb0892f377f398be2ff5a7c2bc320893 Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 2 Oct 2024 15:14:37 +0700 Subject: [PATCH 11/42] no message --- .../Controllers/OrderController.cs | 72 ++++++++- .../Requests/ReportExecuteRequest.cs | 21 +++ .../Requests/ReportPersonRequest.cs | 10 ++ .../Controllers/PlacementController.cs | 10 ++ .../Controllers/RetirementOtherController.cs | 143 ++++++++++++++++++ .../Requests/ReportExecuteRequest.cs | 21 +++ .../Requests/ReportPersonRequest.cs | 10 ++ 7 files changed, 284 insertions(+), 3 deletions(-) create mode 100644 BMA.EHR.Command.Service/Requests/ReportExecuteRequest.cs create mode 100644 BMA.EHR.Command.Service/Requests/ReportPersonRequest.cs create mode 100644 BMA.EHR.Retirement.Service/Requests/ReportExecuteRequest.cs create mode 100644 BMA.EHR.Retirement.Service/Requests/ReportPersonRequest.cs diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs index 613e52f1..f4a848c2 100644 --- a/BMA.EHR.Command.Service/Controllers/OrderController.cs +++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs @@ -3,10 +3,10 @@ using BMA.EHR.Application.Repositories; using BMA.EHR.Application.Repositories.Commands; using BMA.EHR.Application.Requests.Commands; using BMA.EHR.Application.Responses; +using BMA.EHR.Domain.Extensions; using BMA.EHR.Command.Service.Requests; using BMA.EHR.Command.Service.Responses; using BMA.EHR.Domain.Common; -using BMA.EHR.Domain.Extensions; using BMA.EHR.Domain.Models.Commands.Core; using BMA.EHR.Domain.Shared; using BMA.EHR.Infrastructure.Persistence; @@ -16,10 +16,8 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; using Swashbuckle.AspNetCore.Annotations; -using System.Net; using System.Net.Http.Headers; using System.Security.Claims; -using Newtonsoft.Json; using Newtonsoft.Json.Linq; namespace BMA.EHR.Command.Service.Controllers @@ -6575,5 +6573,73 @@ namespace BMA.EHR.Command.Service.Controllers } #endregion + + /// + /// ออกคำสั่ง C-PM-11 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command11/report/excecute")] + public async Task> PostReportCommand11Execute([FromBody] ReportExecuteRequest req) + { + // create new profile + foreach (var recv in req.refIds) + { + var baseAPI = _configuration["API"]; + var apiUrl = $"{baseAPI}/org/profile/command11/{recv.refId}"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl); + var _res = await client.PostAsJsonAsync(apiUrl, new + { + profileId = recv.refId, + date = recv.commandAffectDate, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + salaryRef = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + } + return Success(); + } + + /// + /// ออกคำสั่ง C-PM-12 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command12/report/excecute")] + public async Task> PostReportCommand12Execute([FromBody] ReportExecuteRequest req) + { + // create new profile + foreach (var recv in req.refIds) + { + var baseAPI = _configuration["API"]; + var apiUrl = $"{baseAPI}/org/profile/command12/{recv.refId}"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl); + var _res = await client.PostAsJsonAsync(apiUrl, new + { + profileId = recv.refId, + date = recv.commandAffectDate, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + salaryRef = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + } + return Success(); + } } } diff --git a/BMA.EHR.Command.Service/Requests/ReportExecuteRequest.cs b/BMA.EHR.Command.Service/Requests/ReportExecuteRequest.cs new file mode 100644 index 00000000..c66de13b --- /dev/null +++ b/BMA.EHR.Command.Service/Requests/ReportExecuteRequest.cs @@ -0,0 +1,21 @@ +using BMA.EHR.Domain.Models.MetaData; +using Microsoft.EntityFrameworkCore; + +namespace BMA.EHR.Command.Service.Requests +{ + public class ReportExecuteRequest + { + public ReportExecuteRequestObj[] refIds { get; set; } + } + public class ReportExecuteRequestObj + { + public string? refId { get; set; } + public DateTime commandAffectDate { get; set; } + public string? commandNo { get; set; } + public int commandYear { get; set; } + public string? templateDoc { get; set; } + public double? amount { get; set; } + public double? positionSalaryAmount { get; set; } + public double? mouthSalaryAmount { get; set; } + } +} diff --git a/BMA.EHR.Command.Service/Requests/ReportPersonRequest.cs b/BMA.EHR.Command.Service/Requests/ReportPersonRequest.cs new file mode 100644 index 00000000..3747c878 --- /dev/null +++ b/BMA.EHR.Command.Service/Requests/ReportPersonRequest.cs @@ -0,0 +1,10 @@ +using BMA.EHR.Domain.Models.MetaData; +using Microsoft.EntityFrameworkCore; + +namespace BMA.EHR.Command.Service.Requests +{ + public class ReportPersonRequest + { + public string[] refIds { get; set; } + } +} diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index 402fe56b..52351ef6 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -142,10 +142,15 @@ namespace BMA.EHR.Placement.Service.Controllers { var data = await _context.PlacementProfiles.Where(x => x.Placement.Id == examId).Select(x => new { + Id = x.Id, PersonalId = x.Id, Avatar = x.ProfileImg == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.ProfileImg.Id, FullName = $"{x.Prefix}{x.Firstname} {x.Lastname}", + Prefix = x.Prefix, + Firstname = x.Firstname, + Lastname = x.Lastname, IdCard = x.CitizenId, + CitizenId = x.CitizenId, ExamNumber = x.ExamNumber, posmasterId = x.posmasterId, root = x.root, @@ -189,10 +194,15 @@ namespace BMA.EHR.Placement.Service.Controllers { var _data = new { + p.Id, p.PersonalId, Avatar = p.Avatar == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(p.Avatar), p.FullName, + p.Prefix, + p.Firstname, + p.Lastname, p.IdCard, + p.CitizenId, p.ExamNumber, p.posmasterId, p.root, diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs index a3b2ec1a..1ba37ef2 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs @@ -1,6 +1,7 @@ using BMA.EHR.Application.Repositories; using BMA.EHR.Application.Repositories.MessageQueue; using BMA.EHR.Domain.Common; +using BMA.EHR.Domain.Extensions; using BMA.EHR.Domain.Models.Retirement; using BMA.EHR.Domain.Shared; using BMA.EHR.Infrastructure.Persistence; @@ -623,5 +624,147 @@ namespace BMA.EHR.Retirement.Service.Controllers return Success(); } + + /// + /// ออกคำสั่ง C-PM-08 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("appoint/report/excecute")] + public async Task> PostReportExecuteAppoint([FromBody] ReportExecuteRequest req) + { + // create new profile + foreach (var recv in req.refIds) + { + var placementProfile = await _context.RetirementOthers + .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); + + if (placementProfile == null) + throw new Exception(GlobalMessages.DataNotFound); + var baseAPI = _configuration["API"]; + var apiUrlSalary = $"{baseAPI}/org/profile/salary"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); + var _res = await client.PostAsJsonAsync(apiUrlSalary, new + { + profileId = placementProfile.profileId, + date = recv.commandAffectDate, + amount = recv.amount, + positionSalaryAmount = recv.positionSalaryAmount, + mouthSalaryAmount = recv.mouthSalaryAmount, + posNo = placementProfile.PositionNumberOld, + position = placementProfile.PositionOld, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = placementProfile.PositionTypeOld, + positionLevel = placementProfile.PositionLevelOld, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + templateDoc = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + var baseAPILeave = _configuration["API"]; + var apiUrlLeave = $"{baseAPI}/org/profile/leave/{placementProfile.profileId}"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlLeave); + string? _null = null; + var _res = await client.PostAsJsonAsync(apiUrlLeave, new + { + isLeave = false, + leaveReason = _null, + dateLeave = _null, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + // update placementstatus + placementProfile.Status = "DONE"; + + await _context.SaveChangesAsync(); + } + return Success(); + } + + /// + /// ออกคำสั่ง C-PM-09 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("out/report/excecute")] + public async Task> PostReportExecuteOut([FromBody] ReportExecuteRequest req) + { + // create new profile + foreach (var recv in req.refIds) + { + var placementProfile = await _context.RetirementOthers + .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); + + if (placementProfile == null) + throw new Exception(GlobalMessages.DataNotFound); + var baseAPI = _configuration["API"]; + var apiUrlSalary = $"{baseAPI}/org/profile/salary"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); + var _res = await client.PostAsJsonAsync(apiUrlSalary, new + { + profileId = placementProfile.profileId, + date = recv.commandAffectDate, + amount = recv.amount, + positionSalaryAmount = recv.positionSalaryAmount, + mouthSalaryAmount = recv.mouthSalaryAmount, + posNo = placementProfile.PositionNumberOld, + position = placementProfile.PositionOld, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = placementProfile.PositionTypeOld, + positionLevel = placementProfile.PositionLevelOld, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + templateDoc = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + var baseAPILeave = _configuration["API"]; + var apiUrlLeave = $"{baseAPI}/org/profile/leave/{placementProfile.profileId}"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlLeave); + string? _null = null; + var _res = await client.PostAsJsonAsync(apiUrlLeave, new + { + isLeave = false, + leaveReason = _null, + dateLeave = _null, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + // update placementstatus + placementProfile.Status = "DONE"; + + await _context.SaveChangesAsync(); + } + return Success(); + } } } diff --git a/BMA.EHR.Retirement.Service/Requests/ReportExecuteRequest.cs b/BMA.EHR.Retirement.Service/Requests/ReportExecuteRequest.cs new file mode 100644 index 00000000..c9d87113 --- /dev/null +++ b/BMA.EHR.Retirement.Service/Requests/ReportExecuteRequest.cs @@ -0,0 +1,21 @@ +using BMA.EHR.Domain.Models.MetaData; +using Microsoft.EntityFrameworkCore; + +namespace BMA.EHR.Retirement.Service.Requests +{ + public class ReportExecuteRequest + { + public ReportExecuteRequestObj[] refIds { get; set; } + } + public class ReportExecuteRequestObj + { + public string? refId { get; set; } + public DateTime commandAffectDate { get; set; } + public string? commandNo { get; set; } + public int commandYear { get; set; } + public string? templateDoc { get; set; } + public double? amount { get; set; } + public double? positionSalaryAmount { get; set; } + public double? mouthSalaryAmount { get; set; } + } +} diff --git a/BMA.EHR.Retirement.Service/Requests/ReportPersonRequest.cs b/BMA.EHR.Retirement.Service/Requests/ReportPersonRequest.cs new file mode 100644 index 00000000..5a6136be --- /dev/null +++ b/BMA.EHR.Retirement.Service/Requests/ReportPersonRequest.cs @@ -0,0 +1,10 @@ +using BMA.EHR.Domain.Models.MetaData; +using Microsoft.EntityFrameworkCore; + +namespace BMA.EHR.Retirement.Service.Requests +{ + public class ReportPersonRequest + { + public string[] refIds { get; set; } + } +} From 1374757bf2cbefdfeeab586b54ebf75d99b6245f Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 2 Oct 2024 16:02:20 +0700 Subject: [PATCH 12/42] =?UTF-8?q?=E0=B8=AD=E0=B8=AD=E0=B8=81=E0=B8=84?= =?UTF-8?q?=E0=B8=B3=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/OrderController.cs | 100 ++++++++++++++++++ .../PlacementAppointmentController.cs | 72 +++++++++++++ .../Controllers/PlacementOfficerController.cs | 56 ++++++++++ .../Controllers/PlacementReceiveController.cs | 78 ++++++++++++++ .../PlacementRepatriationController.cs | 56 ++++++++++ .../PlacementTransferController.cs | 59 ++++++++++- .../Controllers/RetirementOtherController.cs | 71 +++++++++++++ .../Controllers/RetirementResignController.cs | 71 +++++++++++++ 8 files changed, 560 insertions(+), 3 deletions(-) diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs index f4a848c2..e1513832 100644 --- a/BMA.EHR.Command.Service/Controllers/OrderController.cs +++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs @@ -6641,5 +6641,105 @@ namespace BMA.EHR.Command.Service.Controllers } return Success(); } + + /// + /// ออกคำสั่ง C-PM-19 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command19/report/excecute")] + public async Task> PostReportCommand19Execute([FromBody] ReportExecuteRequest req) + { + // create new profile + foreach (var recv in req.refIds) + { + var baseAPI = _configuration["API"]; + var apiUrl = $"{baseAPI}/org/profile/command19/{recv.refId}"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl); + var _res = await client.PostAsJsonAsync(apiUrl, new + { + profileId = recv.refId, + date = recv.commandAffectDate, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + salaryRef = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + } + return Success(); + } + + /// + /// ออกคำสั่ง C-PM-20 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command20/report/excecute")] + public async Task> PostReportCommand20Execute([FromBody] ReportExecuteRequest req) + { + // create new profile + foreach (var recv in req.refIds) + { + var baseAPI = _configuration["API"]; + var apiUrl = $"{baseAPI}/org/profile/command20/{recv.refId}"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl); + var _res = await client.PostAsJsonAsync(apiUrl, new + { + profileId = recv.refId, + date = recv.commandAffectDate, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + salaryRef = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + } + return Success(); + } + + /// + /// ออกคำสั่ง C-PM-21 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command21/report/excecute")] + public async Task> PostReportCommand21Execute([FromBody] ReportExecuteRequest req) + { + var data = req.refIds.Select(x => new + { + id = x.refId, + amount = x.amount, + positionSalaryAmount = x.positionSalaryAmount, + mouthSalaryAmount = x.mouthSalaryAmount, + refCommandNo = $"{x.commandNo}/{x.commandYear.ToThaiYear()}", + templateDoc = x.templateDoc, + }); + var baseAPI = _configuration["API"]; + var apiUrl = $"{baseAPI}/org/profile-employee/report/resume"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); + var result = await res.Content.ReadAsStringAsync(); + } + return Success(); + } } } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs index 77b70913..ea592f96 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs @@ -1221,5 +1221,77 @@ namespace BMA.EHR.Placement.Service.Controllers } return Success(); } + + /// + /// ออกคำสั่ง C-PM-22 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("employee-appoint/report/excecute")] + public async Task> PostReportExecuteEmployeeAppoint([FromBody] ReportExecuteRequest req) + { + // create new profile + foreach (var recv in req.refIds) + { + var data = await _context.PlacementAppointments + .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); + if (data == null) + continue; + + var baseAPI = _configuration["API"]; + var apiUrlSalary = $"{baseAPI}/org/profile-employee/salary"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); + var _res = await client.PostAsJsonAsync(apiUrlSalary, new + { + profileEmployeeId = data.profileId, + date = recv.commandAffectDate, + amount = recv.amount, + positionSalaryAmount = recv.positionSalaryAmount, + mouthSalaryAmount = recv.mouthSalaryAmount, + posNo = data.posMasterNo == null ? "" : + data.node == 4 ? $"{data.child4ShortName}{data.posMasterNo}" : + data.node == 3 ? $"{data.child3ShortName}{data.posMasterNo}" : + data.node == 2 ? $"{data.child2ShortName}{data.posMasterNo}" : + data.node == 1 ? $"{data.child1ShortName}{data.posMasterNo}" : + data.node == 0 ? $"{data.rootShortName}{data.posMasterNo}" : "", + position = data.position, + positionType = data.posTypeName, + positionLevel = data.posLevelName, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + templateDoc = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/employee/pos/report/current"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new + { + posmasterId = data.posmasterId, + positionId = data.positionId, + profileId = data.profileId, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + // update placementstatus + data.Status = "DONE"; + + await _context.SaveChangesAsync(); + } + return Success(); + } } } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs index 8ad0b7fa..18412174 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs @@ -1,6 +1,7 @@ using BMA.EHR.Application.Repositories; using BMA.EHR.Application.Repositories.MessageQueue; using BMA.EHR.Domain.Common; +using BMA.EHR.Domain.Extensions; using BMA.EHR.Domain.Models.Placement; using BMA.EHR.Domain.Shared; using BMA.EHR.Infrastructure.Persistence; @@ -566,5 +567,60 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + + /// + /// ออกคำสั่ง C-PM-15 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("report/excecute")] + public async Task> PostReportExecute([FromBody] ReportExecuteRequest req) + { + // create new profile + foreach (var recv in req.refIds) + { + var data = await _context.PlacementOfficers + .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); + + if (data == null) + throw new Exception(GlobalMessages.DataNotFound); + + var baseAPI = _configuration["API"]; + var apiUrlSalary = $"{baseAPI}/org/profile/salary"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); + var _res = await client.PostAsJsonAsync(apiUrlSalary, new + { + profileId = data.profileId, + date = recv.commandAffectDate, + amount = recv.amount, + positionSalaryAmount = recv.positionSalaryAmount, + mouthSalaryAmount = recv.mouthSalaryAmount, + posNo = data.PositionNumberOld, + position = data.PositionOld, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = data.PositionTypeOld, + positionLevel = data.PositionLevelOld, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + templateDoc = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + // update placementstatus + data.Status = "DONE"; + + await _context.SaveChangesAsync(); + } + return Success(); + } } } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs index 7bf549b9..03a6e88c 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs @@ -1,6 +1,7 @@ using BMA.EHR.Application.Repositories; using BMA.EHR.Application.Repositories.MessageQueue; using BMA.EHR.Domain.Common; +using BMA.EHR.Domain.Extensions; using BMA.EHR.Domain.Models.Placement; using BMA.EHR.Domain.Shared; using BMA.EHR.Infrastructure.Persistence; @@ -878,5 +879,82 @@ namespace BMA.EHR.Placement.Service.Controllers .ToListAsync(); return Success(position); } + + /// + /// ออกคำสั่ง C-PM-14 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("report/excecute")] + public async Task> PostReportExecute([FromBody] ReportExecuteRequest req) + { + // create new profile + foreach (var recv in req.refIds) + { + // query placement Profile + var placementProfile = await _context.PlacementReceives + .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); + + if (placementProfile == null) + throw new Exception(GlobalMessages.DataNotFound); + + var baseAPI = _configuration["API"]; + var apiUrlSalary = $"{baseAPI}/org/profile/salary"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); + var _res = await client.PostAsJsonAsync(apiUrlSalary, new + { + profileId = placementProfile.profileId, + date = recv.commandAffectDate, + amount = recv.amount, + positionSalaryAmount = recv.positionSalaryAmount, + mouthSalaryAmount = recv.mouthSalaryAmount, + posNo = placementProfile.posMasterNo == null ? "" : + placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "", + position = placementProfile.position, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = placementProfile.posTypeName, + positionLevel = placementProfile.posLevelName, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + templateDoc = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/pos/report/current"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new + { + posmasterId = placementProfile.posmasterId, + positionId = placementProfile.positionId, + profileId = placementProfile.profileId, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + // update placementstatus + placementProfile.Status = "DONE"; + + await _context.SaveChangesAsync(); + } + return Success(); + } } } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs index abb7055c..c5bbb70b 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs @@ -1,6 +1,7 @@ using BMA.EHR.Application.Repositories; using BMA.EHR.Application.Repositories.MessageQueue; using BMA.EHR.Domain.Common; +using BMA.EHR.Domain.Extensions; using BMA.EHR.Domain.Models.Placement; using BMA.EHR.Domain.Shared; using BMA.EHR.Infrastructure.Persistence; @@ -473,5 +474,60 @@ namespace BMA.EHR.Placement.Service.Controllers // return Success(); // } + + /// + /// ออกคำสั่ง C-PM-16 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("report/excecute")] + public async Task> PostReportExecute([FromBody] ReportExecuteRequest req) + { + // create new profile + foreach (var recv in req.refIds) + { + var data = await _context.PlacementRepatriations + .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); + + if (data == null) + throw new Exception(GlobalMessages.DataNotFound); + + var baseAPI = _configuration["API"]; + var apiUrlSalary = $"{baseAPI}/org/profile/salary"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); + var _res = await client.PostAsJsonAsync(apiUrlSalary, new + { + profileId = data.profileId, + date = recv.commandAffectDate, + amount = recv.amount, + positionSalaryAmount = recv.positionSalaryAmount, + mouthSalaryAmount = recv.mouthSalaryAmount, + posNo = data.PositionNumberOld, + position = data.PositionOld, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = data.PositionTypeOld, + positionLevel = data.PositionLevelOld, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + templateDoc = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + // update placementstatus + data.Status = "DONE"; + + await _context.SaveChangesAsync(); + } + return Success(); + } } } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs index 57ff7c6f..92b571bf 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs @@ -1,6 +1,7 @@ using BMA.EHR.Application.Repositories; using BMA.EHR.Application.Repositories.MessageQueue; using BMA.EHR.Domain.Common; +using BMA.EHR.Domain.Extensions; using BMA.EHR.Domain.Models.Placement; using BMA.EHR.Domain.Shared; using BMA.EHR.Infrastructure.Persistence; @@ -12,10 +13,7 @@ using Newtonsoft.Json; using Swashbuckle.AspNetCore.Annotations; using System.Net.Http.Headers; using System.Security.Claims; -using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using Microsoft.AspNetCore.Mvc.RazorPages; -using System.Drawing.Printing; namespace BMA.EHR.Placement.Service.Controllers { @@ -759,5 +757,60 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + + /// + /// ออกคำสั่ง C-PM-13 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("report/excecute")] + public async Task> PostReportExecute([FromBody] ReportExecuteRequest req) + { + // create new profile + foreach (var recv in req.refIds) + { + var data = await _context.PlacementTransfers + .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); + + if (data == null) + throw new Exception(GlobalMessages.DataNotFound); + + var baseAPI = _configuration["API"]; + var apiUrlSalary = $"{baseAPI}/org/profile/salary"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); + var _res = await client.PostAsJsonAsync(apiUrlSalary, new + { + profileId = data.profileId, + date = recv.commandAffectDate, + amount = recv.amount, + positionSalaryAmount = recv.positionSalaryAmount, + mouthSalaryAmount = recv.mouthSalaryAmount, + posNo = data.PositionNumberOld, + position = data.PositionOld, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = data.PositionTypeOld, + positionLevel = data.PositionLevelOld, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + templateDoc = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + // update placementstatus + data.Status = "DONE"; + + await _context.SaveChangesAsync(); + } + return Success(); + } } } diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs index 1ba37ef2..fde6ce3e 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs @@ -766,5 +766,76 @@ namespace BMA.EHR.Retirement.Service.Controllers } return Success(); } + + /// + /// ออกคำสั่ง C-PM-18 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("leave/report/excecute")] + public async Task> PostReportExecuteLeave([FromBody] ReportExecuteRequest req) + { + // create new profile + foreach (var recv in req.refIds) + { + var data = await _context.RetirementOuts + .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); + + if (data == null) + throw new Exception(GlobalMessages.DataNotFound); + + var baseAPI = _configuration["API"]; + var apiUrl = $"{baseAPI}/org/profile/leave/{data.profileId}"; + + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl); + var _res = await client.PostAsJsonAsync(apiUrl, new + { + isLeave = true, + leaveReason = "ให้ออกจากราชการ", + dateLeave = recv.commandAffectDate, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + var apiUrlSalary = $"{baseAPI}/org/profile/salary"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); + var _res = await client.PostAsJsonAsync(apiUrlSalary, new + { + profileId = data.profileId, + date = recv.commandAffectDate, + amount = recv.amount, + positionSalaryAmount = recv.positionSalaryAmount, + mouthSalaryAmount = recv.mouthSalaryAmount, + posNo = data.PositionNumberOld, + position = data.PositionOld, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = data.PositionTypeOld, + positionLevel = data.PositionLevelOld, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + templateDoc = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + // update placementstatus + data.Status = "DONE"; + + await _context.SaveChangesAsync(); + } + return Success(); + } } } diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs index 5013adeb..0e318488 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs @@ -1628,5 +1628,76 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda return Success(retirementQuestionnaireQuestion); } + + /// + /// ออกคำสั่ง C-PM-17 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("report/excecute")] + public async Task> PostReportExecute([FromBody] ReportExecuteRequest req) + { + // create new profile + foreach (var recv in req.refIds) + { + var data = await _context.RetirementResigns + .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); + + if (data == null) + throw new Exception(GlobalMessages.DataNotFound); + + var baseAPI = _configuration["API"]; + var apiUrl = $"{baseAPI}/org/profile/leave/{data.profileId}"; + + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl); + var _res = await client.PostAsJsonAsync(apiUrl, new + { + isLeave = true, + leaveReason = "ลาออกจากราชการ", + dateLeave = recv.commandAffectDate, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + var apiUrlSalary = $"{baseAPI}/org/profile/salary"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); + var _res = await client.PostAsJsonAsync(apiUrlSalary, new + { + profileId = data.profileId, + date = recv.commandAffectDate, + amount = recv.amount, + positionSalaryAmount = recv.positionSalaryAmount, + mouthSalaryAmount = recv.mouthSalaryAmount, + posNo = data.PositionNumberOld, + position = data.PositionOld, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = data.PositionTypeOld, + positionLevel = data.PositionLevelOld, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + templateDoc = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + // update placementstatus + data.Status = "DONE"; + + await _context.SaveChangesAsync(); + } + return Success(); + } } } From 64f0e992836b8c2316bd6a063cbb209a8d75754f Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 2 Oct 2024 16:10:16 +0700 Subject: [PATCH 13/42] no message --- .../Controllers/OrderController.cs | 86 ++++++++++ .../Controllers/RetirementOtherController.cs | 158 ++++++++++++++++++ 2 files changed, 244 insertions(+) diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs index f4a848c2..7b191ff2 100644 --- a/BMA.EHR.Command.Service/Controllers/OrderController.cs +++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs @@ -6574,6 +6574,91 @@ namespace BMA.EHR.Command.Service.Controllers #endregion + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-11 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("appoint/report")] + public async Task> PostReportAppoint([FromBody] ReportPersonRequest req) + { + //var placementProfiles = await _context.PlacementAppointments + // .Where(x => req.refIds.Contains(x.Id.ToString())) + // .ToListAsync(); + //foreach (var placementProfile in placementProfiles) + //{ + // // update placementstatus + // placementProfile.Status = "REPORT"; + //} + //await _context.SaveChangesAsync(); + return Success(); + } + + /// + /// เอกสารแนบท้าย C-PM-11 + /// + /// Record Id ของคำสั่ง + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("appoint/report/attachment")] + [AllowAnonymous] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> PostReportAppointAttachment([FromBody] ReportPersonRequest req) + { + try + { + //var report_data = await _context.PlacementAppointments + // .Where(x => req.refIds.Contains(x.Id.ToString())) + // .Select(p => new + // { + // Education = p.EducationOld == null ? "-" : p.EducationOld, + // //Seq = r.Sequence.ToString().ToThaiNumber(), + // //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + // //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + // Seq = "", + // CitizenId = "", + // FullName = "", + // OldOc = p.rootOld == null ? "" : p.rootOld, + // OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, + // OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, + // OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, + // OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), + // OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + // OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), + // NewOc = p.root == null ? "" : p.root, + // NewPositionName = p.position == null ? "" : p.position, + // NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, + // NewPositionType = p.posTypeName == null ? "" : p.posTypeName, + // NewPositionNumber = p.posMasterNo == null ? "" : + // p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : + // p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : + // p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : + // p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : + // p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", + // //NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), + // NewSalary = "", + // AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), + // Reason = p.Reason == null ? "-" : p.Reason + + // }) + // .ToListAsync(); + //return Success(report_data); + return null; + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-11 /// @@ -6608,6 +6693,7 @@ namespace BMA.EHR.Command.Service.Controllers return Success(); } + //bright 12 /// /// ออกคำสั่ง C-PM-12 /// diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs index 1ba37ef2..9fc364de 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs @@ -625,6 +625,85 @@ namespace BMA.EHR.Retirement.Service.Controllers return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-08 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("appoint/report")] + public async Task> PostReportAppoint([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.RetirementOthers + .Where(x => req.refIds.Contains(x.Id.ToString())) + .ToListAsync(); + foreach (var placementProfile in placementProfiles) + { + // update placementstatus + placementProfile.Status = "REPORT"; + } + await _context.SaveChangesAsync(); + return Success(); + } + + /// + /// เอกสารแนบท้าย C-PM-08 + /// + /// Record Id ของคำสั่ง + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("appoint/report/attachment")] + [AllowAnonymous] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> PostReportAppointAttachment([FromBody] ReportPersonRequest req) + { + try + { + var report_data = await _context.RetirementOthers + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Select(p => new + { + Education = p.EducationOld == null ? "-" : p.EducationOld, + //Seq = r.Sequence.ToString().ToThaiNumber(), + //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + Seq = "", + CitizenId = "", + FullName = "", + OldOc = p.rootOld == null ? "" : p.rootOld, + OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, + OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, + OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, + OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), + OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), + NewOc = p.rootOld == null ? "" : p.rootOld, + NewPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, + NewPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, + NewPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, + NewPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), + //NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), + NewSalary = "", + AppointDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), + LeaveDate = p.LeaveDate == null ? "" : p.LeaveDate.Value.ToThaiShortDate2().ToThaiNumber(), + Reason = p.Reason == null ? "-" : p.Reason, + }) + .ToListAsync(); + return Success(report_data); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-08 /// @@ -696,6 +775,85 @@ namespace BMA.EHR.Retirement.Service.Controllers return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-09 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("out/report")] + public async Task> PostReportOut([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.RetirementOthers + .Where(x => req.refIds.Contains(x.Id.ToString())) + .ToListAsync(); + foreach (var placementProfile in placementProfiles) + { + // update placementstatus + placementProfile.Status = "REPORT"; + } + await _context.SaveChangesAsync(); + return Success(); + } + + /// + /// เอกสารแนบท้าย C-PM-09 + /// + /// Record Id ของคำสั่ง + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("out/report/attachment")] + [AllowAnonymous] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> PostReportOutAttachment([FromBody] ReportPersonRequest req) + { + try + { + var report_data = await _context.RetirementOthers + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Select(p => new + { + Education = p.EducationOld == null ? "-" : p.EducationOld, + //Seq = r.Sequence.ToString().ToThaiNumber(), + //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + Seq = "", + CitizenId = "", + FullName = "", + OldOc = p.rootOld == null ? "" : p.rootOld, + OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, + OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, + OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, + OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), + OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), + NewOc = p.rootOld == null ? "" : p.rootOld, + NewPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, + NewPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, + NewPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, + NewPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), + NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), + AppointDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), + LeaveDate = p.LeaveDate == null ? "" : p.LeaveDate.Value.ToThaiShortDate2().ToThaiNumber(), + MilitaryDate = p.MilitaryDate == null ? "" : p.MilitaryDate.Value.ToThaiShortDate2().ToThaiNumber(), + Reason = p.Reason == null ? "-" : p.Reason, + }) + .ToListAsync(); + return Success(report_data); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-09 /// From 3419a314e1fc1df4146763e07c0b1a7ba6bb3a2d Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 2 Oct 2024 16:24:02 +0700 Subject: [PATCH 14/42] update 11 12 --- .../Controllers/OrderController.cs | 188 +++++++++++------- 1 file changed, 121 insertions(+), 67 deletions(-) diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs index 43392771..ecfb9deb 100644 --- a/BMA.EHR.Command.Service/Controllers/OrderController.cs +++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs @@ -6582,81 +6582,66 @@ namespace BMA.EHR.Command.Service.Controllers /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("appoint/report")] - public async Task> PostReportAppoint([FromBody] ReportPersonRequest req) - { - //var placementProfiles = await _context.PlacementAppointments - // .Where(x => req.refIds.Contains(x.Id.ToString())) - // .ToListAsync(); - //foreach (var placementProfile in placementProfiles) - //{ - // // update placementstatus - // placementProfile.Status = "REPORT"; - //} - //await _context.SaveChangesAsync(); - return Success(); - } - - /// - /// เอกสารแนบท้าย C-PM-11 - /// - /// Record Id ของคำสั่ง - /// pdf, docx หรือ xlsx - /// - /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("appoint/report/attachment")] - [AllowAnonymous] - [ProducesResponseType(StatusCodes.Status200OK)] - [ProducesResponseType(StatusCodes.Status401Unauthorized)] - [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> PostReportAppointAttachment([FromBody] ReportPersonRequest req) + [HttpPost("command11/report")] + public async Task> PostReportCommand11([FromBody] ReportPersonRequest reqss) { try { - //var report_data = await _context.PlacementAppointments - // .Where(x => req.refIds.Contains(x.Id.ToString())) - // .Select(p => new - // { - // Education = p.EducationOld == null ? "-" : p.EducationOld, - // //Seq = r.Sequence.ToString().ToThaiNumber(), - // //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), - // //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - // Seq = "", - // CitizenId = "", - // FullName = "", - // OldOc = p.rootOld == null ? "" : p.rootOld, - // OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, - // OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, - // OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, - // OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), - // OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), - // OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), - // NewOc = p.root == null ? "" : p.root, - // NewPositionName = p.position == null ? "" : p.position, - // NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, - // NewPositionType = p.posTypeName == null ? "" : p.posTypeName, - // NewPositionNumber = p.posMasterNo == null ? "" : - // p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : - // p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : - // p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : - // p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : - // p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", - // //NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), - // NewSalary = "", - // AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), - // Reason = p.Reason == null ? "-" : p.Reason + var resultData = new List(); - // }) - // .ToListAsync(); - //return Success(report_data); - return null; + var baseAPI = _configuration["Node:API"]; + var apiUrl = $"{baseAPI}/report/pass"; + + var response = new PassProbationResponse(); + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var res = await client.SendAsync(req); + var result = await res.Content.ReadAsStringAsync(); + + response = JsonConvert.DeserializeObject(result); + + var seq = 1; + foreach (var d in response!.data) + { + var _baseAPI = _configuration["API"]; + var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.person.id}"; + using (var _client = new HttpClient()) + { + _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); + var _res = await _client.SendAsync(_req); + var _result = await _res.Content.ReadAsStringAsync(); + + var org = JsonConvert.DeserializeObject(_result); + + if (org == null || org.result == null) + continue; + + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, + Prefix = org.result.prefix == null ? "" : org.result.prefix, + FirstName = org.result.firstName == null ? "" : org.result.firstName, + LastName = org.result.lastName == null ? "" : org.result.lastName, + RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), + }; + seq++; + resultData.Add(receiver); + } + } + } + return Success(); } catch { throw; } + } /// @@ -6693,7 +6678,76 @@ namespace BMA.EHR.Command.Service.Controllers return Success(); } - //bright 12 + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-12 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command12/report")] + public async Task> PostReportCommand12([FromBody] ReportPersonRequest reqss) + { + try + { + var resultData = new List(); + + var baseAPI = _configuration["Node:API"]; + var apiUrl = $"{baseAPI}/report/not-pass"; + + var response = new PassProbationResponse(); + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var res = await client.SendAsync(req); + var result = await res.Content.ReadAsStringAsync(); + + response = JsonConvert.DeserializeObject(result); + + var seq = 1; + foreach (var d in response!.data) + { + var _baseAPI = _configuration["API"]; + var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.person.id}"; + using (var _client = new HttpClient()) + { + _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); + var _res = await _client.SendAsync(_req); + var _result = await _res.Content.ReadAsStringAsync(); + + var org = JsonConvert.DeserializeObject(_result); + + if (org == null || org.result == null) + continue; + + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, + Prefix = org.result.prefix == null ? "" : org.result.prefix, + FirstName = org.result.firstName == null ? "" : org.result.firstName, + LastName = org.result.lastName == null ? "" : org.result.lastName, + RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), + }; + seq++; + resultData.Add(receiver); + } + } + } + + return Success(); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-12 /// From d5a2042d355810d3469be2a9be4012a983b66b04 Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 2 Oct 2024 17:48:55 +0700 Subject: [PATCH 15/42] no message --- .../Controllers/OrderController.cs | 110 ++++++++++++++++++ .../Controllers/PlacementOfficerController.cs | 66 +++++++++++ .../Controllers/PlacementReceiveController.cs | 82 +++++++++++++ .../PlacementRepatriationController.cs | 23 ++++ .../PlacementTransferController.cs | 71 +++++++++++ .../Controllers/RetirementOtherController.cs | 71 ----------- .../Controllers/RetirementOutController.cs | 94 +++++++++++++++ .../Controllers/RetirementResignController.cs | 67 +++++++++++ 8 files changed, 513 insertions(+), 71 deletions(-) diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs index ecfb9deb..aa57f316 100644 --- a/BMA.EHR.Command.Service/Controllers/OrderController.cs +++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs @@ -6782,6 +6782,30 @@ namespace BMA.EHR.Command.Service.Controllers return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-19 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command19/report")] + public async Task> PostReportCommand19([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.RetirementDischarges + .Where(x => req.refIds.Contains(x.Id.ToString())) + .ToListAsync(); + + foreach (var placementProfile in placementProfiles) + { + // update placementstatus + placementProfile.Status = "REPORT"; + } + await _context.SaveChangesAsync(); + return Success(); + } + /// /// ออกคำสั่ง C-PM-19 /// @@ -6816,6 +6840,30 @@ namespace BMA.EHR.Command.Service.Controllers return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-20 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command20/report")] + public async Task> PostReportcommand20([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.RetirementExpulsions + .Where(x => req.refIds.Contains(x.Id.ToString())) + .ToListAsync(); + + foreach (var placementProfile in placementProfiles) + { + // update placementstatus + placementProfile.Status = "REPORT"; + } + await _context.SaveChangesAsync(); + return Success(); + } + /// /// ออกคำสั่ง C-PM-20 /// @@ -6850,6 +6898,68 @@ namespace BMA.EHR.Command.Service.Controllers return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-21 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command21/report")] + public async Task> PostReportcommand21([FromBody] ReportPersonRequest req_) + { + try + { + var resultData = new List(); + + var baseAPI = _configuration["API"]; + var apiUrl = $"{baseAPI}/org/profile-employee/report-temp"; + + var response = new PassSalaryResponse(); + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var res = await client.SendAsync(req); + var result = await res.Content.ReadAsStringAsync(); + + response = JsonConvert.DeserializeObject(result); + + var seq = 1; + foreach (var d in response!.result) + { + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = d.citizenId, + Prefix = d.prefix == null ? "" : d.prefix, + FirstName = d.firstName == null ? "" : d.firstName, + LastName = d.lastName == null ? "" : d.lastName, + RefPlacementProfileId = d.id, + RefDisciplineId = d.id, + Organization = d.organization, + PositionName = d.positionName, + PositionLevel = d.positionLevel, + PositionType = d.positionType, + PositionNumber = d.positionNumber, + BirthDate = d.birthDate, + }; + seq++; + + resultData.Add(receiver); + } + } + + return Success(resultData); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-21 /// diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs index 18412174..d8b869d2 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs @@ -568,6 +568,72 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-15 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("report/report")] + public async Task> PostReport([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.PlacementOfficers + .Where(x => req.refIds.Contains(x.Id.ToString())) + .ToListAsync(); + foreach (var placementProfile in placementProfiles) + { + // update placementstatus + placementProfile.Status = "REPORT"; + } + await _context.SaveChangesAsync(); + return Success(); + } + + /// + /// เอกสารแนบท้าย C-PM-15 + /// + /// Record Id ของคำสั่ง + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("report/report/attachment")] + [AllowAnonymous] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> PostReportAttachment([FromBody] ReportPersonRequest req) + { + try + { + var report_data = await _context.PlacementOfficers + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Select(p => new + { + //Seq = r.Sequence.ToString().ToThaiNumber(), + //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + Seq = "", + CitizenId = "", + FullName = "", + PositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, + Organization = p.Organization == null ? "" : p.Organization, + StartDate = p.DateStart == null ? "" : p.DateStart.Value.ToThaiShortDate2().ToThaiNumber(), + EndDate = p.DateEnd == null ? "" : p.DateEnd.Value.ToThaiShortDate2().ToThaiNumber(), + Reason = p.Reason == null ? "" : p.Reason.ToThaiNumber() + }) + .ToListAsync(); + return Success(report_data); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-15 /// diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs index 03a6e88c..ae052aeb 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs @@ -880,6 +880,88 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(position); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-14 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("report/report")] + public async Task> PostReport([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.PlacementReceives + .Where(x => req.refIds.Contains(x.Id.ToString())) + .ToListAsync(); + foreach (var placementProfile in placementProfiles) + { + // update placementstatus + placementProfile.Status = "REPORT"; + } + await _context.SaveChangesAsync(); + return Success(); + } + + /// + /// เอกสารแนบท้าย C-PM-14 + /// + /// Record Id ของคำสั่ง + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("report/report/attachment")] + [AllowAnonymous] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> PostReportAttachment([FromBody] ReportPersonRequest req) + { + try + { + var report_data = await _context.PlacementReceives + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Select(p => new + { + Education = p.EducationOld == null ? "-" : p.EducationOld, + //Seq = r.Sequence.ToString().ToThaiNumber(), + //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + Seq = "", + CitizenId = "", + FullName = "", + OldOc = p.OrganizationPositionOld ?? "", + OldPositionName = p.OrganizationPositionOld ?? "", + OldPositionLevel = p.PositionLevelOld ?? "", + OldPositionType = p.PositionTypeOld ?? "", + OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), + OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + NewOc = p.root == null ? "" : p.root, + NewPositionName = p.position == null ? "" : p.position, + NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, + NewPositionType = p.posTypeName == null ? "" : p.posTypeName, + NewPositionNumber = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", + //NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), + NewSalary = "", + AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), + Reason = p.Reason == null ? "-" : p.Reason, + }) + .ToListAsync(); + return Success(report_data); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-14 /// diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs index c5bbb70b..69fe576e 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs @@ -475,6 +475,29 @@ namespace BMA.EHR.Placement.Service.Controllers // return Success(); // } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-16 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("report/report")] + public async Task> PostReport([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.PlacementRepatriations + .Where(x => req.refIds.Contains(x.Id.ToString())) + .ToListAsync(); + foreach (var placementProfile in placementProfiles) + { + // update placementstatus + placementProfile.Status = "REPORT"; + } + await _context.SaveChangesAsync(); + return Success(); + } + /// /// ออกคำสั่ง C-PM-16 /// diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs index 92b571bf..aeb6ff96 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs @@ -758,6 +758,77 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-13 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("report/report")] + public async Task> PostReport([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.PlacementTransfers + .Where(x => req.refIds.Contains(x.Id.ToString())) + .ToListAsync(); + foreach (var placementProfile in placementProfiles) + { + // update placementstatus + placementProfile.Status = "REPORT"; + } + await _context.SaveChangesAsync(); + return Success(); + } + + /// + /// เอกสารแนบท้าย C-PM-13 + /// + /// Record Id ของคำสั่ง + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("report/report/attachment")] + [AllowAnonymous] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> PostReportAttachment([FromBody] ReportPersonRequest req) + { + try + { + var report_data = await _context.PlacementTransfers + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Select(p => new + { + //Seq = r.Sequence.ToString().ToThaiNumber(), + //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + Seq = "", + CitizenId = "", + FullName = "", + Organization = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, + PositionName = p.PositionOld == null ? "" : p.PositionOld, + PositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, + PositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, + PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), + Salary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + ActiveDate = p.Date == null ? "" : p.Date.Value.ToThaiShortDate2().ToThaiNumber(), + //ReceiveOrganizationName = r.Command!.ReceiveOrganizationName ?? "", + ReceiveOrganizationName = "", + Reason = p.Reason ?? "" + }) + .ToListAsync(); + return Success(report_data); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-13 /// diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs index cd336224..9fc364de 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs @@ -924,76 +924,5 @@ namespace BMA.EHR.Retirement.Service.Controllers } return Success(); } - - /// - /// ออกคำสั่ง C-PM-18 - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("leave/report/excecute")] - public async Task> PostReportExecuteLeave([FromBody] ReportExecuteRequest req) - { - // create new profile - foreach (var recv in req.refIds) - { - var data = await _context.RetirementOuts - .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); - - if (data == null) - throw new Exception(GlobalMessages.DataNotFound); - - var baseAPI = _configuration["API"]; - var apiUrl = $"{baseAPI}/org/profile/leave/{data.profileId}"; - - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl); - var _res = await client.PostAsJsonAsync(apiUrl, new - { - isLeave = true, - leaveReason = "ให้ออกจากราชการ", - dateLeave = recv.commandAffectDate, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - - var apiUrlSalary = $"{baseAPI}/org/profile/salary"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); - var _res = await client.PostAsJsonAsync(apiUrlSalary, new - { - profileId = data.profileId, - date = recv.commandAffectDate, - amount = recv.amount, - positionSalaryAmount = recv.positionSalaryAmount, - mouthSalaryAmount = recv.mouthSalaryAmount, - posNo = data.PositionNumberOld, - position = data.PositionOld, - positionLine = "", - positionPathSide = "", - positionExecutive = "", - positionType = data.PositionTypeOld, - positionLevel = data.PositionLevelOld, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - templateDoc = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - - // update placementstatus - data.Status = "DONE"; - - await _context.SaveChangesAsync(); - } - return Success(); - } } } diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs index 51c253c8..0cc77964 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs @@ -464,5 +464,99 @@ namespace BMA.EHR.Retirement.Service.Controllers return Success(); } + + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-18 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command18/report")] + public async Task> PostReportCommand18([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.RetirementResigns + .Where(x => req.refIds.Contains(x.Id.ToString())) + .ToListAsync(); + foreach (var placementProfile in placementProfiles) + { + // update placementstatus + placementProfile.Status = "REPORT"; + } + await _context.SaveChangesAsync(); + return Success(); + } + + /// + /// ออกคำสั่ง C-PM-18 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command18/report/excecute")] + public async Task> PostReportExecuteLeave([FromBody] ReportExecuteRequest req) + { + // create new profile + foreach (var recv in req.refIds) + { + var data = await _context.RetirementOuts + .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); + + if (data == null) + throw new Exception(GlobalMessages.DataNotFound); + + var baseAPI = _configuration["API"]; + var apiUrl = $"{baseAPI}/org/profile/leave/{data.profileId}"; + + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl); + var _res = await client.PostAsJsonAsync(apiUrl, new + { + isLeave = true, + leaveReason = "ให้ออกจากราชการ", + dateLeave = recv.commandAffectDate, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + var apiUrlSalary = $"{baseAPI}/org/profile/salary"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); + var _res = await client.PostAsJsonAsync(apiUrlSalary, new + { + profileId = data.profileId, + date = recv.commandAffectDate, + amount = recv.amount, + positionSalaryAmount = recv.positionSalaryAmount, + mouthSalaryAmount = recv.mouthSalaryAmount, + posNo = data.PositionNumberOld, + position = data.PositionOld, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = data.PositionTypeOld, + positionLevel = data.PositionLevelOld, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + templateDoc = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + // update placementstatus + data.Status = "DONE"; + + await _context.SaveChangesAsync(); + } + return Success(); + } } } diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs index 0e318488..7d3c4b40 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs @@ -1629,6 +1629,73 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda return Success(retirementQuestionnaireQuestion); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-17 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("report/report")] + public async Task> PostReport([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.RetirementResigns + .Where(x => req.refIds.Contains(x.Id.ToString())) + .ToListAsync(); + foreach (var placementProfile in placementProfiles) + { + // update placementstatus + placementProfile.Status = "REPORT"; + } + await _context.SaveChangesAsync(); + return Success(); + } + + /// + /// เอกสารแนบท้าย C-PM-17 + /// + /// Record Id ของคำสั่ง + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("report/report/attachment")] + [AllowAnonymous] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> PostReportAttachment([FromBody] ReportPersonRequest req) + { + try + { + var report_data = await _context.RetirementResigns + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Select(p => new + { + //Seq = r.Sequence.ToString().ToThaiNumber(), + //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + PositionName = p.PositionOld ?? "", + Organization = p.OrganizationPositionOld ?? "", + PositionLevel = p.PositionLevelOld ?? "", + PositionType = p.PositionTypeOld ?? "", + PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), + ActiveDate = p.ActiveDate == null ? "" : p.ActiveDate.Value.ToThaiShortDate2().ToThaiNumber(), + Salary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + Remark = p.Reason ?? "", + RemarkHorizontal = p.RemarkHorizontal, + }) + .ToListAsync(); + return Success(report_data); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-17 /// From 9567181117229ed979516ffffe7037acef9e5cd2 Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 2 Oct 2024 21:29:44 +0700 Subject: [PATCH 16/42] no message --- .../Controllers/OrderController.cs | 405 ++++++++++++++++++ .../Controllers/DisciplineResultController.cs | 10 +- .../Requests/PassDisciplineResponse.cs | 2 +- .../PlacementAppointmentController.cs | 72 ++++ .../Controllers/RetirementResignController.cs | 45 ++ 5 files changed, 528 insertions(+), 6 deletions(-) diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs index e1513832..7f804153 100644 --- a/BMA.EHR.Command.Service/Controllers/OrderController.cs +++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs @@ -6741,5 +6741,410 @@ namespace BMA.EHR.Command.Service.Controllers } return Success(); } + + /// + /// ออกคำสั่ง C-PM-25 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command25/report/excecute")] + public async Task> PostReportCommand25Execute([FromBody] ReportExecuteRequest req) + { + var data = req.refIds.Select(x => new + { + Id = x.refId, + CommandAffectDate = x.commandAffectDate, + CommandNo = x.commandNo, + CommandYear = x.commandYear.ToThaiYear(), + Detail = "คำสั่งลงโทษ พักจากราชการ" + }); + + var baseAPI = _configuration["API"]; + var apiUrl = $"{baseAPI}/discipline/result/report/stop/resume"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); + var result = await res.Content.ReadAsStringAsync(); + } + return Success(); + } + + /// + /// ออกคำสั่ง C-PM-26 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command26/report/excecute")] + public async Task> PostReportCommand26Execute([FromBody] ReportExecuteRequest req) + { + var data = req.refIds.Select(x => new + { + Id = x.refId, + CommandAffectDate = x.commandAffectDate, + CommandNo = x.commandNo, + CommandYear = x.commandYear.ToThaiYear(), + Detail = "คำสั่งลงโทษ ให้ออกจากราชการไว้ก่อน" + }); + + var baseAPI = _configuration["API"]; + var apiUrl = $"{baseAPI}/discipline/result/report/stop/resume"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); + var result = await res.Content.ReadAsStringAsync(); + } + return Success(); + } + + /// + /// ออกคำสั่ง C-PM-27 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command27/report/excecute")] + public async Task> PostReportCommand27Execute([FromBody] ReportExecuteRequest req) + { + var data = req.refIds.Select(x => new + { + Id = x.refId, + CommandAffectDate = x.commandAffectDate, + CommandNo = x.commandNo, + CommandYear = x.commandYear.ToThaiYear(), + Detail = "คำสั่งลงโทษ ลงโทษ ภาคทัณฑ์" + }); + + var baseAPI = _configuration["API"]; + var apiUrl = $"{baseAPI}/discipline/result/report/up/resume"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); + var result = await res.Content.ReadAsStringAsync(); + } + return Success(); + } + + /// + /// ออกคำสั่ง C-PM-28 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command28/report/excecute")] + public async Task> PostReportCommand28Execute([FromBody] ReportExecuteRequest req) + { + var data = req.refIds.Select(x => new + { + Id = x.refId, + CommandAffectDate = x.commandAffectDate, + CommandNo = x.commandNo, + CommandYear = x.commandYear.ToThaiYear(), + Detail = "คำสั่งลงโทษ ตัดเงินเดือน" + }); + + var baseAPI = _configuration["API"]; + var apiUrl = $"{baseAPI}/discipline/result/report/up/resume"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); + var result = await res.Content.ReadAsStringAsync(); + } + return Success(); + } + + /// + /// ออกคำสั่ง C-PM-29 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command29/report/excecute")] + public async Task> PostReportCommand29Execute([FromBody] ReportExecuteRequest req) + { + var data = req.refIds.Select(x => new + { + Id = x.refId, + CommandAffectDate = x.commandAffectDate, + CommandNo = x.commandNo, + CommandYear = x.commandYear.ToThaiYear(), + Detail = "คำสั่งลงโทษ ลดขั้นเงินเดือน" + }); + + var baseAPI = _configuration["API"]; + var apiUrl = $"{baseAPI}/discipline/result/report/up/resume"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); + var result = await res.Content.ReadAsStringAsync(); + } + return Success(); + } + + /// + /// ออกคำสั่ง C-PM-30 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command30/report/excecute")] + public async Task> PostReportCommand30Execute([FromBody] ReportExecuteRequest req) + { + var data = req.refIds.Select(x => new + { + Id = x.refId, + CommandAffectDate = x.commandAffectDate, + CommandNo = x.commandNo, + CommandYear = x.commandYear.ToThaiYear(), + Detail = "คำสั่งเพิ่มโทษ" + }); + + var baseAPI = _configuration["API"]; + var apiUrl = $"{baseAPI}/discipline/result/report/up/resume"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); + var result = await res.Content.ReadAsStringAsync(); + } + return Success(); + } + + /// + /// ออกคำสั่ง C-PM-31 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command31/report/excecute")] + public async Task> PostReportCommand31Execute([FromBody] ReportExecuteRequest req) + { + var data = req.refIds.Select(x => new + { + Id = x.refId, + CommandAffectDate = x.commandAffectDate, + CommandNo = x.commandNo, + CommandYear = x.commandYear.ToThaiYear(), + Detail = "คำสั่งงดโทษ" + }); + + var baseAPI = _configuration["API"]; + var apiUrl = $"{baseAPI}/discipline/result/report/up/resume"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); + var result = await res.Content.ReadAsStringAsync(); + } + return Success(); + } + + /// + /// ออกคำสั่ง C-PM-32 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command32/report/excecute")] + public async Task> PostReportCommand32Execute([FromBody] ReportExecuteRequest req) + { + var data = req.refIds.Select(x => new + { + Id = x.refId, + CommandAffectDate = x.commandAffectDate, + CommandNo = x.commandNo, + CommandYear = x.commandYear.ToThaiYear(), + Detail = "คำสั่งยุติเรื่อง" + }); + + var baseAPI = _configuration["API"]; + var apiUrl = $"{baseAPI}/discipline/result/report/reject/resume"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); + var result = await res.Content.ReadAsStringAsync(); + } + return Success(); + } + + /// + /// ออกคำสั่ง C-PM-33 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command33/report/excecute")] + public async Task> PostReportCommand33Execute([FromBody] ReportExecuteRequest req) + { + var data = req.refIds.Select(x => new + { + Id = x.refId, + refCommandNo = $"{x.commandNo}/{x.commandYear.ToThaiYear()}", + templateDoc = x.templateDoc, + }); + + var baseAPI = _configuration["API"]; + var apiUrl = $"{baseAPI}/salary/report/command/33/resume"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); + var result = await res.Content.ReadAsStringAsync(); + } + return Success(); + } + + /// + /// ออกคำสั่ง C-PM-34 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command34/report/excecute")] + public async Task> PostReportCommand34Execute([FromBody] ReportExecuteRequest req) + { + var data = req.refIds.Select(x => new + { + Id = x.refId, + refCommandNo = $"{x.commandNo}/{x.commandYear.ToThaiYear()}", + templateDoc = x.templateDoc, + }); + + var baseAPI = _configuration["API"]; + var apiUrl = $"{baseAPI}/salary/report/command/34/resume"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); + var result = await res.Content.ReadAsStringAsync(); + } + return Success(); + } + + /// + /// ออกคำสั่ง C-PM-35 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command35/report/excecute")] + public async Task> PostReportCommand35Execute([FromBody] ReportExecuteRequest req) + { + var data = req.refIds.Select(x => new + { + Id = x.refId, + refCommandNo = $"{x.commandNo}/{x.commandYear.ToThaiYear()}", + templateDoc = x.templateDoc, + }); + + var baseAPI = _configuration["API"]; + var apiUrl = $"{baseAPI}/salary/report/command/35/resume"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); + var result = await res.Content.ReadAsStringAsync(); + } + return Success(); + } + + /// + /// ออกคำสั่ง C-PM-36 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command36/report/excecute")] + public async Task> PostReportCommand36Execute([FromBody] ReportExecuteRequest req) + { + var data = req.refIds.Select(x => new + { + Id = x.refId, + refCommandNo = $"{x.commandNo}/{x.commandYear.ToThaiYear()}", + templateDoc = x.templateDoc, + }); + + var baseAPI = _configuration["API"]; + var apiUrl = $"{baseAPI}/salary/report/command/36/resume"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); + var result = await res.Content.ReadAsStringAsync(); + } + return Success(); + } + + /// + /// ออกคำสั่ง C-PM-37 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command37/report/excecute")] + public async Task> PostReportCommand37Execute([FromBody] ReportExecuteRequest req) + { + var data = req.refIds.Select(x => new + { + refCommandNo = $"{x.commandNo}/{x.commandYear.ToThaiYear()}", + templateDoc = x.templateDoc, + }); + + var baseAPI = _configuration["API"]; + var apiUrl = $"{baseAPI}/salary/report/command/37/resume"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); + var result = await res.Content.ReadAsStringAsync(); + } + return Success(); + } } } diff --git a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs index 6e90ce13..c6b59020 100644 --- a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs +++ b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs @@ -517,7 +517,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlDiscipline); var _res = await client.PostAsJsonAsync(apiUrlDiscipline, new { - profileId = d.personId, + profileId = data.PersonId, date = d.commandAffectDate, detail = data.DisciplineDisciplinary.Title, level = data.DisciplineDisciplinary.DisciplinaryFaultLevel, @@ -564,7 +564,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlDiscipline); var _res = await client.PostAsJsonAsync(apiUrlDiscipline, new { - profileId = d.personId, + profileId = data.PersonId, date = d.commandAffectDate, detail = data.DisciplineDisciplinary.Title, level = data.DisciplineDisciplinary.DisciplinaryFaultLevel, @@ -610,7 +610,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlDiscipline); var _res = await client.PostAsJsonAsync(apiUrlDiscipline, new { - profileId = d.personId, + profileId = data1.PersonId, date = d.commandAffectDate, detail = data1.DisciplineInvestigate.Title, level = "", @@ -638,7 +638,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlDiscipline); var _res = await client.PostAsJsonAsync(apiUrlDiscipline, new { - profileId = d.personId, + profileId = data2.PersonId, date = d.commandAffectDate, detail = data2.DisciplineDisciplinary.Title, level = data2.DisciplineDisciplinary.DisciplinaryFaultLevel, @@ -684,7 +684,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlDiscipline); var _res = await client.PostAsJsonAsync(apiUrlDiscipline, new { - profileId = d.personId, + profileId = data.PersonId, date = d.commandAffectDate, detail = data.DisciplineDisciplinary.Title, level = data.DisciplineDisciplinary.DisciplinaryFaultLevel, diff --git a/BMA.EHR.Discipline.Service/Requests/PassDisciplineResponse.cs b/BMA.EHR.Discipline.Service/Requests/PassDisciplineResponse.cs index c95f888c..2e3a8a81 100644 --- a/BMA.EHR.Discipline.Service/Requests/PassDisciplineResponse.cs +++ b/BMA.EHR.Discipline.Service/Requests/PassDisciplineResponse.cs @@ -11,7 +11,7 @@ namespace BMA.EHR.Discipline.Service.Requests public class DisciplineDataResponse { public Guid id { get; set; } = Guid.Empty; - public Guid personId { get; set; } = Guid.Empty; + // public Guid personId { get; set; } = Guid.Empty; public Guid? commandId { get; set; } = Guid.Empty; public DateTime? commandAffectDate { get; set; } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs index ea592f96..cd2c55b6 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs @@ -1293,5 +1293,77 @@ namespace BMA.EHR.Placement.Service.Controllers } return Success(); } + + /// + /// ออกคำสั่ง C-PM-24 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("employee-move/report/excecute")] + public async Task> PostReportExecuteEmployeeMove([FromBody] ReportExecuteRequest req) + { + // create new profile + foreach (var recv in req.refIds) + { + var data = await _context.PlacementAppointments + .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); + + if (data == null) + throw new Exception(GlobalMessages.DataNotFound); + var baseAPI = _configuration["API"]; + var apiUrlSalary = $"{baseAPI}/org/profile-employee/salary"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); + var _res = await client.PostAsJsonAsync(apiUrlSalary, new + { + profileEmployeeId = data.profileId, + date = recv.commandAffectDate, + amount = recv.amount, + positionSalaryAmount = recv.positionSalaryAmount, + mouthSalaryAmount = recv.mouthSalaryAmount, + posNo = data.posMasterNo == null ? "" : + data.node == 4 ? $"{data.child4ShortName}{data.posMasterNo}" : + data.node == 3 ? $"{data.child3ShortName}{data.posMasterNo}" : + data.node == 2 ? $"{data.child2ShortName}{data.posMasterNo}" : + data.node == 1 ? $"{data.child1ShortName}{data.posMasterNo}" : + data.node == 0 ? $"{data.rootShortName}{data.posMasterNo}" : "", + position = data.position, + positionType = data.posTypeName, + positionLevel = data.posLevelName, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + templateDoc = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/employee/pos/report/current"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new + { + posmasterId = data.posmasterId, + positionId = data.positionId, + profileId = data.profileId, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + // update placementstatus + data.Status = "DONE"; + + await _context.SaveChangesAsync(); + } + return Success(); + } } } diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs index 0e318488..5c81b0a7 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs @@ -1699,5 +1699,50 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda } return Success(); } + + /// + /// ออกคำสั่ง C-PM-23 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("employee/report/excecute")] + public async Task> PostReportExecuteEmployee([FromBody] ReportExecuteRequest req) + { + // create new profile + foreach (var recv in req.refIds) + { + var data = await _context.RetirementResigns + .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); + + if (data == null) + throw new Exception(GlobalMessages.DataNotFound); + + var baseAPI = _configuration["API"]; + var apiUrl = $"{baseAPI}/org/profile-employee/salary/{data.profileId}"; + + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Put, apiUrl); + var _res = await client.PutAsJsonAsync(apiUrl, new + { + isLeave = true, + leaveReason = "ลาออกจากราชการ", + dateLeave = recv.commandAffectDate, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + // update placementstatus + data.Status = "DONE"; + + await _context.SaveChangesAsync(); + } + return Success(); + } } } From 4cf3f15fb89c78db686e1ce5704a35f30294e720 Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 2 Oct 2024 22:54:34 +0700 Subject: [PATCH 17/42] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B8=84?= =?UTF-8?q?=E0=B8=B3=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/OrderController.cs | 211 +++++++++++++++++- .../Controllers/PlacementOfficerController.cs | 6 +- .../Controllers/PlacementReceiveController.cs | 6 +- .../PlacementRepatriationController.cs | 4 +- .../PlacementTransferController.cs | 6 +- .../Controllers/RetirementOtherController.cs | 2 +- .../Controllers/RetirementOutController.cs | 7 +- .../Controllers/RetirementResignController.cs | 81 ++++++- 8 files changed, 296 insertions(+), 27 deletions(-) diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs index 02a993ac..4e9e0356 100644 --- a/BMA.EHR.Command.Service/Controllers/OrderController.cs +++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs @@ -19,6 +19,7 @@ using Swashbuckle.AspNetCore.Annotations; using System.Net.Http.Headers; using System.Security.Claims; using Newtonsoft.Json.Linq; +using Microsoft.EntityFrameworkCore; namespace BMA.EHR.Command.Service.Controllers { @@ -6664,7 +6665,6 @@ namespace BMA.EHR.Command.Service.Controllers { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl); var _res = await client.PostAsJsonAsync(apiUrl, new { profileId = recv.refId, @@ -6768,7 +6768,6 @@ namespace BMA.EHR.Command.Service.Controllers { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl); var _res = await client.PostAsJsonAsync(apiUrl, new { profileId = recv.refId, @@ -6793,7 +6792,7 @@ namespace BMA.EHR.Command.Service.Controllers [HttpPost("command19/report")] public async Task> PostReportCommand19([FromBody] ReportPersonRequest req) { - var placementProfiles = await _context.RetirementDischarges + var placementProfiles = await _context.RetirementDischarges.AsQueryable() .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); @@ -6826,7 +6825,6 @@ namespace BMA.EHR.Command.Service.Controllers { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl); var _res = await client.PostAsJsonAsync(apiUrl, new { profileId = recv.refId, @@ -6837,6 +6835,25 @@ namespace BMA.EHR.Command.Service.Controllers var _result = await _res.Content.ReadAsStringAsync(); } } + + var dataSend = req.refIds.Select(x => new + { + Id = x.refId, + CommandAffectDate = x.commandAffectDate, + CommandNo = x.commandNo, + CommandYear = x.commandYear.ToThaiYear(), + Detail = "คำสั่งลงโทษ ปลดออกจากราชการ" + }); + + var _baseAPI = _configuration["API"]; + var _apiUrl = $"{_baseAPI}/discipline/result/report/up/resume"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var res = await client.PostAsJsonAsync(_apiUrl, new { result = dataSend }); + var result = await res.Content.ReadAsStringAsync(); + } return Success(); } @@ -6851,7 +6868,7 @@ namespace BMA.EHR.Command.Service.Controllers [HttpPost("command20/report")] public async Task> PostReportcommand20([FromBody] ReportPersonRequest req) { - var placementProfiles = await _context.RetirementExpulsions + var placementProfiles = await _context.RetirementExpulsions.AsQueryable() .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); @@ -6884,7 +6901,6 @@ namespace BMA.EHR.Command.Service.Controllers { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl); var _res = await client.PostAsJsonAsync(apiUrl, new { profileId = recv.refId, @@ -6895,6 +6911,25 @@ namespace BMA.EHR.Command.Service.Controllers var _result = await _res.Content.ReadAsStringAsync(); } } + + var dataSend = req.refIds.Select(x => new + { + Id = x.refId, + CommandAffectDate = x.commandAffectDate, + CommandNo = x.commandNo, + CommandYear = x.commandYear.ToThaiYear(), + detail = "คำสั่งลงโทษ ไล่ออกจากราชการ" + }); + + var _baseAPI = _configuration["API"]; + var _apiUrl = $"{_baseAPI}/discipline/result/report/up/resume"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var res = await client.PostAsJsonAsync(_apiUrl, new { result = dataSend }); + var result = await res.Content.ReadAsStringAsync(); + } return Success(); } @@ -7021,6 +7056,23 @@ namespace BMA.EHR.Command.Service.Controllers var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); var result = await res.Content.ReadAsStringAsync(); } + foreach (var recv in req.refIds) + { + var apiUrl2 = $"{baseAPI}/org/profile/command25/{recv.refId}"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrl2, new + { + profileId = recv.refId, + date = recv.commandAffectDate, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + salaryRef = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + } return Success(); } @@ -7053,6 +7105,23 @@ namespace BMA.EHR.Command.Service.Controllers var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); var result = await res.Content.ReadAsStringAsync(); } + foreach (var recv in req.refIds) + { + var apiUrl2 = $"{baseAPI}/org/profile/command26/{recv.refId}"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrl2, new + { + profileId = recv.refId, + date = recv.commandAffectDate, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + salaryRef = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + } return Success(); } @@ -7085,6 +7154,23 @@ namespace BMA.EHR.Command.Service.Controllers var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); var result = await res.Content.ReadAsStringAsync(); } + foreach (var recv in req.refIds) + { + var apiUrl2 = $"{baseAPI}/org/profile/command27/{recv.refId}"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrl2, new + { + profileId = recv.refId, + date = recv.commandAffectDate, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + salaryRef = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + } return Success(); } @@ -7117,6 +7203,23 @@ namespace BMA.EHR.Command.Service.Controllers var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); var result = await res.Content.ReadAsStringAsync(); } + foreach (var recv in req.refIds) + { + var apiUrl2 = $"{baseAPI}/org/profile/command28/{recv.refId}"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrl2, new + { + profileId = recv.refId, + date = recv.commandAffectDate, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + salaryRef = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + } return Success(); } @@ -7149,6 +7252,23 @@ namespace BMA.EHR.Command.Service.Controllers var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); var result = await res.Content.ReadAsStringAsync(); } + foreach (var recv in req.refIds) + { + var apiUrl2 = $"{baseAPI}/org/profile/command29/{recv.refId}"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrl2, new + { + profileId = recv.refId, + date = recv.commandAffectDate, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + salaryRef = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + } return Success(); } @@ -7181,6 +7301,23 @@ namespace BMA.EHR.Command.Service.Controllers var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); var result = await res.Content.ReadAsStringAsync(); } + foreach (var recv in req.refIds) + { + var apiUrl2 = $"{baseAPI}/org/profile/command30/{recv.refId}"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrl2, new + { + profileId = recv.refId, + date = recv.commandAffectDate, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + salaryRef = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + } return Success(); } @@ -7213,6 +7350,23 @@ namespace BMA.EHR.Command.Service.Controllers var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); var result = await res.Content.ReadAsStringAsync(); } + foreach (var recv in req.refIds) + { + var apiUrl2 = $"{baseAPI}/org/profile/command31/{recv.refId}"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrl2, new + { + profileId = recv.refId, + date = recv.commandAffectDate, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + salaryRef = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + } return Success(); } @@ -7245,6 +7399,23 @@ namespace BMA.EHR.Command.Service.Controllers var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); var result = await res.Content.ReadAsStringAsync(); } + foreach (var recv in req.refIds) + { + var apiUrl2 = $"{baseAPI}/org/profile/command32/{recv.refId}"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrl2, new + { + profileId = recv.refId, + date = recv.commandAffectDate, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + salaryRef = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + } return Success(); } @@ -7396,5 +7567,33 @@ namespace BMA.EHR.Command.Service.Controllers } return Success(); } + + /// + /// ออกคำสั่ง C-PM-38 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command38/report/excecute")] + public async Task> PostReportCommand38Execute([FromBody] ReportExecuteRequest req) + { + return Success(); + } + + /// + /// ออกคำสั่ง C-PM-40 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command40/report/excecute")] + public async Task> PostReportCommand40Execute([FromBody] ReportExecuteRequest req) + { + return Success(); + } } } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs index d8b869d2..abb9002f 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs @@ -576,7 +576,7 @@ namespace BMA.EHR.Placement.Service.Controllers /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("report/report")] + [HttpPost("command/report")] public async Task> PostReport([FromBody] ReportPersonRequest req) { var placementProfiles = await _context.PlacementOfficers @@ -600,7 +600,7 @@ namespace BMA.EHR.Placement.Service.Controllers /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("report/report/attachment")] + [HttpPost("command/report/attachment")] [AllowAnonymous] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] @@ -642,7 +642,7 @@ namespace BMA.EHR.Placement.Service.Controllers /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("report/excecute")] + [HttpPost("command/report/excecute")] public async Task> PostReportExecute([FromBody] ReportExecuteRequest req) { // create new profile diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs index ae052aeb..e48ca341 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs @@ -888,7 +888,7 @@ namespace BMA.EHR.Placement.Service.Controllers /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("report/report")] + [HttpPost("command/report")] public async Task> PostReport([FromBody] ReportPersonRequest req) { var placementProfiles = await _context.PlacementReceives @@ -912,7 +912,7 @@ namespace BMA.EHR.Placement.Service.Controllers /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("report/report/attachment")] + [HttpPost("command/report/attachment")] [AllowAnonymous] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] @@ -970,7 +970,7 @@ namespace BMA.EHR.Placement.Service.Controllers /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("report/excecute")] + [HttpPost("command/report/excecute")] public async Task> PostReportExecute([FromBody] ReportExecuteRequest req) { // create new profile diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs index 69fe576e..dde4991b 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs @@ -483,7 +483,7 @@ namespace BMA.EHR.Placement.Service.Controllers /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("report/report")] + [HttpPost("command/report")] public async Task> PostReport([FromBody] ReportPersonRequest req) { var placementProfiles = await _context.PlacementRepatriations @@ -506,7 +506,7 @@ namespace BMA.EHR.Placement.Service.Controllers /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("report/excecute")] + [HttpPost("command/report/excecute")] public async Task> PostReportExecute([FromBody] ReportExecuteRequest req) { // create new profile diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs index aeb6ff96..dd164e49 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs @@ -766,7 +766,7 @@ namespace BMA.EHR.Placement.Service.Controllers /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("report/report")] + [HttpPost("command/report")] public async Task> PostReport([FromBody] ReportPersonRequest req) { var placementProfiles = await _context.PlacementTransfers @@ -790,7 +790,7 @@ namespace BMA.EHR.Placement.Service.Controllers /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("report/report/attachment")] + [HttpPost("command/report/attachment")] [AllowAnonymous] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] @@ -837,7 +837,7 @@ namespace BMA.EHR.Placement.Service.Controllers /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("report/excecute")] + [HttpPost("command/report/excecute")] public async Task> PostReportExecute([FromBody] ReportExecuteRequest req) { // create new profile diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs index 9fc364de..bd08e778 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs @@ -839,7 +839,7 @@ namespace BMA.EHR.Retirement.Service.Controllers NewPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, NewPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, NewPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), - NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), + // NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), AppointDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), LeaveDate = p.LeaveDate == null ? "" : p.LeaveDate.Value.ToThaiShortDate2().ToThaiNumber(), MilitaryDate = p.MilitaryDate == null ? "" : p.MilitaryDate.Value.ToThaiShortDate2().ToThaiNumber(), diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs index 0cc77964..7f88d024 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs @@ -1,6 +1,7 @@ using BMA.EHR.Application.Repositories; using BMA.EHR.Application.Repositories.MessageQueue; using BMA.EHR.Domain.Common; +using BMA.EHR.Domain.Extensions; using BMA.EHR.Domain.Models.Retirement; using BMA.EHR.Domain.Shared; using BMA.EHR.Infrastructure.Persistence; @@ -473,8 +474,8 @@ namespace BMA.EHR.Retirement.Service.Controllers /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command18/report")] - public async Task> PostReportCommand18([FromBody] ReportPersonRequest req) + [HttpPost("command/report")] + public async Task> PostReport([FromBody] ReportPersonRequest req) { var placementProfiles = await _context.RetirementResigns .Where(x => req.refIds.Contains(x.Id.ToString())) @@ -496,7 +497,7 @@ namespace BMA.EHR.Retirement.Service.Controllers /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command18/report/excecute")] + [HttpPost("command/report/excecute")] public async Task> PostReportExecuteLeave([FromBody] ReportExecuteRequest req) { // create new profile diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs index f83fd2c5..fb2079c7 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs @@ -2,7 +2,6 @@ using BMA.EHR.Application.Repositories.MessageQueue; using BMA.EHR.Domain.Common; using BMA.EHR.Domain.Extensions; -using BMA.EHR.Domain.Models.MetaData; using BMA.EHR.Domain.Models.Retirement; using BMA.EHR.Domain.Shared; using BMA.EHR.Infrastructure.Persistence; @@ -15,8 +14,6 @@ using Newtonsoft.Json.Linq; using Swashbuckle.AspNetCore.Annotations; using System.Net.Http.Headers; using System.Security.Claims; -using System.Security.Cryptography; -using static Microsoft.EntityFrameworkCore.DbLoggerCategory; namespace BMA.EHR.Retirement.Service.Controllers { @@ -1637,7 +1634,7 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("report/report")] + [HttpPost("command/report")] public async Task> PostReport([FromBody] ReportPersonRequest req) { var placementProfiles = await _context.RetirementResigns @@ -1661,7 +1658,7 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("report/report/attachment")] + [HttpPost("command/report/attachment")] [AllowAnonymous] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] @@ -1704,7 +1701,7 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("report/excecute")] + [HttpPost("command/report/excecute")] public async Task> PostReportExecute([FromBody] ReportExecuteRequest req) { // create new profile @@ -1811,5 +1808,77 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda } return Success(); } + + /// + /// ออกคำสั่ง C-PM-23 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("leave-cancel/report/excecute")] + public async Task> PostReportExecuteLeaveCancel([FromBody] ReportExecuteRequest req) + { + // create new profile + foreach (var recv in req.refIds) + { + var data = await _context.RetirementResigns + .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); + + if (data == null) + throw new Exception(GlobalMessages.DataNotFound); + + var baseAPI = _configuration["API"]; + var apiUrl = $"{baseAPI}/org/profile/leave/{data.profileId}"; + + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl); + string? _null = null; + var _res = await client.PostAsJsonAsync(apiUrl, new + { + isLeave = false, + leaveReason = _null, + dateLeave = _null, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + var apiUrlSalary = $"{baseAPI}/org/profile/salary"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); + var _res = await client.PostAsJsonAsync(apiUrlSalary, new + { + profileId = data.profileId, + date = recv.commandAffectDate, + amount = recv.amount, + positionSalaryAmount = recv.positionSalaryAmount, + mouthSalaryAmount = recv.mouthSalaryAmount, + posNo = data.PositionNumberOld, + position = data.PositionOld, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = data.PositionTypeOld, + positionLevel = data.PositionLevelOld, + refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", + templateDoc = recv.templateDoc, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + // update placementstatus + data.Status = "DONEREJECT"; + + await _context.SaveChangesAsync(); + } + return Success(); + } } } From a2bc5f116bb342b455e8d2b4dad82beb64a71d82 Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 3 Oct 2024 13:27:22 +0700 Subject: [PATCH 18/42] no message --- .../Controllers/OrderController.cs | 1096 ++++++++++++++++- .../PlacementAppointmentController.cs | 159 +++ .../Controllers/RetirementResignController.cs | 70 ++ 3 files changed, 1322 insertions(+), 3 deletions(-) diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs index 4e9e0356..ff725e06 100644 --- a/BMA.EHR.Command.Service/Controllers/OrderController.cs +++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs @@ -20,6 +20,7 @@ using System.Net.Http.Headers; using System.Security.Claims; using Newtonsoft.Json.Linq; using Microsoft.EntityFrameworkCore; +using BMA.EHR.Application.Responses.Reports; namespace BMA.EHR.Command.Service.Controllers { @@ -6584,7 +6585,7 @@ namespace BMA.EHR.Command.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpPost("command11/report")] - public async Task> PostReportCommand11([FromBody] ReportPersonRequest reqss) + public async Task> PostReportCommand11([FromBody] ReportPersonRequest req_) { try { @@ -6687,7 +6688,7 @@ namespace BMA.EHR.Command.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpPost("command12/report")] - public async Task> PostReportCommand12([FromBody] ReportPersonRequest reqss) + public async Task> PostReportCommand12([FromBody] ReportPersonRequest req_) { try { @@ -6987,7 +6988,7 @@ namespace BMA.EHR.Command.Service.Controllers } } - return Success(resultData); + return Success(); } catch { @@ -7027,6 +7028,144 @@ namespace BMA.EHR.Command.Service.Controllers return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-25 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command25/report")] + public async Task> PostReportCommand25([FromBody] ReportPersonRequest req_) + { + try + { + var resultData = new List(); + var baseAPI = _configuration["API"]; + + foreach (var id in req_.refIds) + { + var apiUrl = $"{baseAPI}/discipline/result/report/stop/{id}"; + var commandType = await _context.Set() + .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-25") + .FirstOrDefaultAsync(); + var response = new PassDisciplineResponse(); + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var res = await client.SendAsync(req); + var result = await res.Content.ReadAsStringAsync(); + + response = JsonConvert.DeserializeObject(result); + + var seq = 1; + foreach (var d in response!.result) + { + if (commandType == null || commandType.Id != d.commandId) + continue; + var _baseAPI = _configuration["API"]; + var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; + using (var _client = new HttpClient()) + { + _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); + var _res = await _client.SendAsync(_req); + var _result = await _res.Content.ReadAsStringAsync(); + + var org = JsonConvert.DeserializeObject(_result); + + if (org == null || org.result == null) + continue; + + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, + Prefix = org.result.prefix == null ? "" : org.result.prefix, + FirstName = org.result.firstName == null ? "" : org.result.firstName, + LastName = org.result.lastName == null ? "" : org.result.lastName, + RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), + RefDisciplineId = d.id, + Amount = 0, + }; + seq++; + resultData.Add(receiver); + } + } + } + } + return Success(); + } + catch + { + throw; + } + } + + /// + /// เอกสารแนบท้าย C-PM-25 + /// + /// Record Id ของคำสั่ง + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command25/report/attachment")] + [AllowAnonymous] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> PostReportCommand25Attachment([FromBody] ReportPersonRequest req_) + { + try + { + var raw_data = await _context.Set() + .Include(c => c.Command) + .Where(c => req_.refIds.Contains(c.Id.ToString())) + .ToListAsync(); + if (raw_data == null) + { + throw new Exception(GlobalMessages.CommandNotFound); + } + foreach (var d in raw_data) + { + var apiUrl = $"{_configuration["API"]}/discipline/result/report/find/{d.RefDisciplineId}/{d.RefPlacementProfileId}"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var _res = await client.SendAsync(_req); + var _result = await _res.Content.ReadAsStringAsync(); + + var org = JsonConvert.DeserializeObject(_result); + + if (org == null || org.result == null) + continue; + var receiver = new CommandType23Response + { + fullName = $"{org.result.prefix}{org.result.firstName} {org.result.lastName}", + positionname = org.result.position, + positionno = org.result.posNo == null ? null : org.result.posNo.ToThaiNumber(), + organizationname = org.result.organization, + salary = org.result.salary == null ? null : org.result.salary.Value.ToNumericNoDecimalText().ToString(), + }; + + return Success(receiver); + } + } + return null; + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-25 /// @@ -7076,6 +7215,85 @@ namespace BMA.EHR.Command.Service.Controllers return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-26 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command26/report")] + public async Task> PostReportCommand26([FromBody] ReportPersonRequest req_) + { + try + { + var resultData = new List(); + var baseAPI = _configuration["API"]; + + foreach (var id in req_.refIds) + { + var apiUrl = $"{baseAPI}/discipline/result/report/stop/{id}"; + + var commandType = await _context.Set() + .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-26") + .FirstOrDefaultAsync(); + var response = new PassDisciplineResponse(); + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var res = await client.SendAsync(req); + var result = await res.Content.ReadAsStringAsync(); + + response = JsonConvert.DeserializeObject(result); + + var seq = 1; + foreach (var d in response!.result) + { + if (commandType == null || commandType.Id != d.commandId) + continue; + var _baseAPI = _configuration["API"]; + var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; + using (var _client = new HttpClient()) + { + _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); + var _res = await _client.SendAsync(_req); + var _result = await _res.Content.ReadAsStringAsync(); + + var org = JsonConvert.DeserializeObject(_result); + + if (org == null || org.result == null) + continue; + + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, + Prefix = org.result.prefix == null ? "" : org.result.prefix, + FirstName = org.result.firstName == null ? "" : org.result.firstName, + LastName = org.result.lastName == null ? "" : org.result.lastName, + RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), + RefDisciplineId = d.id, + Amount = 0, + }; + seq++; + resultData.Add(receiver); + } + } + } + } + return Success(); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-26 /// @@ -7125,6 +7343,85 @@ namespace BMA.EHR.Command.Service.Controllers return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-27 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command27/report")] + public async Task> PostReportCommand27([FromBody] ReportPersonRequest req_) + { + try + { + var resultData = new List(); + var baseAPI = _configuration["API"]; + + foreach (var id in req_.refIds) + { + var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}"; + + var commandType = await _context.Set() + .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-27") + .FirstOrDefaultAsync(); + var response = new PassDisciplineResponse(); + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var res = await client.SendAsync(req); + var result = await res.Content.ReadAsStringAsync(); + + response = JsonConvert.DeserializeObject(result); + + var seq = 1; + foreach (var d in response!.result) + { + if (commandType == null || commandType.Id != d.commandId) + continue; + var _baseAPI = _configuration["API"]; + var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; + using (var _client = new HttpClient()) + { + _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); + var _res = await _client.SendAsync(_req); + var _result = await _res.Content.ReadAsStringAsync(); + + var org = JsonConvert.DeserializeObject(_result); + + if (org == null || org.result == null) + continue; + + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, + Prefix = org.result.prefix == null ? "" : org.result.prefix, + FirstName = org.result.firstName == null ? "" : org.result.firstName, + LastName = org.result.lastName == null ? "" : org.result.lastName, + RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), + RefDisciplineId = d.id, + Amount = 0, + }; + seq++; + resultData.Add(receiver); + } + } + } + } + return Success(); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-27 /// @@ -7174,6 +7471,85 @@ namespace BMA.EHR.Command.Service.Controllers return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-28 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command28/report")] + public async Task> PostReportCommand28([FromBody] ReportPersonRequest req_) + { + try + { + var resultData = new List(); + var baseAPI = _configuration["API"]; + + foreach (var id in req_.refIds) + { + var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}"; + + var commandType = await _context.Set() + .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-28") + .FirstOrDefaultAsync(); + var response = new PassDisciplineResponse(); + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var res = await client.SendAsync(req); + var result = await res.Content.ReadAsStringAsync(); + + response = JsonConvert.DeserializeObject(result); + + var seq = 1; + foreach (var d in response!.result) + { + if (commandType == null || commandType.Id != d.commandId) + continue; + var _baseAPI = _configuration["API"]; + var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; + using (var _client = new HttpClient()) + { + _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); + var _res = await _client.SendAsync(_req); + var _result = await _res.Content.ReadAsStringAsync(); + + var org = JsonConvert.DeserializeObject(_result); + + if (org == null || org.result == null) + continue; + + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, + Prefix = org.result.prefix == null ? "" : org.result.prefix, + FirstName = org.result.firstName == null ? "" : org.result.firstName, + LastName = org.result.lastName == null ? "" : org.result.lastName, + RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), + RefDisciplineId = d.id, + Amount = 0, + }; + seq++; + resultData.Add(receiver); + } + } + } + } + return Success(); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-28 /// @@ -7223,6 +7599,85 @@ namespace BMA.EHR.Command.Service.Controllers return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-29 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command29/report")] + public async Task> PostReportCommand29([FromBody] ReportPersonRequest req_) + { + try + { + var resultData = new List(); + var baseAPI = _configuration["API"]; + + foreach (var id in req_.refIds) + { + var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}"; + + var commandType = await _context.Set() + .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-29") + .FirstOrDefaultAsync(); + var response = new PassDisciplineResponse(); + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var res = await client.SendAsync(req); + var result = await res.Content.ReadAsStringAsync(); + + response = JsonConvert.DeserializeObject(result); + + var seq = 1; + foreach (var d in response!.result) + { + if (commandType == null || commandType.Id != d.commandId) + continue; + var _baseAPI = _configuration["API"]; + var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; + using (var _client = new HttpClient()) + { + _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); + var _res = await _client.SendAsync(_req); + var _result = await _res.Content.ReadAsStringAsync(); + + var org = JsonConvert.DeserializeObject(_result); + + if (org == null || org.result == null) + continue; + + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, + Prefix = org.result.prefix == null ? "" : org.result.prefix, + FirstName = org.result.firstName == null ? "" : org.result.firstName, + LastName = org.result.lastName == null ? "" : org.result.lastName, + RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), + RefDisciplineId = d.id, + Amount = 0, + }; + seq++; + resultData.Add(receiver); + } + } + } + } + return Success(); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-29 /// @@ -7272,6 +7727,85 @@ namespace BMA.EHR.Command.Service.Controllers return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-30 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command30/report")] + public async Task> PostReportCommand30([FromBody] ReportPersonRequest req_) + { + try + { + var resultData = new List(); + var baseAPI = _configuration["API"]; + + foreach (var id in req_.refIds) + { + var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}"; + + var commandType = await _context.Set() + .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-30") + .FirstOrDefaultAsync(); + var response = new PassDisciplineResponse(); + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var res = await client.SendAsync(req); + var result = await res.Content.ReadAsStringAsync(); + + response = JsonConvert.DeserializeObject(result); + + var seq = 1; + foreach (var d in response!.result) + { + if (commandType == null || commandType.Id != d.commandId) + continue; + var _baseAPI = _configuration["API"]; + var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; + using (var _client = new HttpClient()) + { + _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); + var _res = await _client.SendAsync(_req); + var _result = await _res.Content.ReadAsStringAsync(); + + var org = JsonConvert.DeserializeObject(_result); + + if (org == null || org.result == null) + continue; + + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, + Prefix = org.result.prefix == null ? "" : org.result.prefix, + FirstName = org.result.firstName == null ? "" : org.result.firstName, + LastName = org.result.lastName == null ? "" : org.result.lastName, + RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), + RefDisciplineId = d.id, + Amount = 0, + }; + seq++; + resultData.Add(receiver); + } + } + } + } + return Success(); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-30 /// @@ -7321,6 +7855,85 @@ namespace BMA.EHR.Command.Service.Controllers return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-31 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command31/report")] + public async Task> PostReportCommand31([FromBody] ReportPersonRequest req_) + { + try + { + var resultData = new List(); + var baseAPI = _configuration["API"]; + + foreach (var id in req_.refIds) + { + var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}"; + + var commandType = await _context.Set() + .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-31") + .FirstOrDefaultAsync(); + var response = new PassDisciplineResponse(); + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var res = await client.SendAsync(req); + var result = await res.Content.ReadAsStringAsync(); + + response = JsonConvert.DeserializeObject(result); + + var seq = 1; + foreach (var d in response!.result) + { + if (commandType == null || commandType.Id != d.commandId) + continue; + var _baseAPI = _configuration["API"]; + var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; + using (var _client = new HttpClient()) + { + _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); + var _res = await _client.SendAsync(_req); + var _result = await _res.Content.ReadAsStringAsync(); + + var org = JsonConvert.DeserializeObject(_result); + + if (org == null || org.result == null) + continue; + + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, + Prefix = org.result.prefix == null ? "" : org.result.prefix, + FirstName = org.result.firstName == null ? "" : org.result.firstName, + LastName = org.result.lastName == null ? "" : org.result.lastName, + RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), + RefDisciplineId = d.id, + Amount = 0, + }; + seq++; + resultData.Add(receiver); + } + } + } + } + return Success(); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-31 /// @@ -7370,6 +7983,80 @@ namespace BMA.EHR.Command.Service.Controllers return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-32 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command32/report")] + public async Task> PostReportCommand32([FromBody] ReportPersonRequest req_) + { + try + { + var resultData = new List(); + var baseAPI = _configuration["API"]; + + foreach (var id in req_.refIds) + { + var apiUrl = $"{baseAPI}/discipline/result/report/reject/{id}"; + + var response = new PassDisciplineResponse(); + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var res = await client.SendAsync(req); + var result = await res.Content.ReadAsStringAsync(); + + response = JsonConvert.DeserializeObject(result); + + var seq = 1; + foreach (var d in response!.result) + { + var _baseAPI = _configuration["API"]; + var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; + using (var _client = new HttpClient()) + { + _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); + var _res = await _client.SendAsync(_req); + var _result = await _res.Content.ReadAsStringAsync(); + + var org = JsonConvert.DeserializeObject(_result); + + if (org == null || org.result == null) + continue; + + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, + Prefix = org.result.prefix == null ? "" : org.result.prefix, + FirstName = org.result.firstName == null ? "" : org.result.firstName, + LastName = org.result.lastName == null ? "" : org.result.lastName, + RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), + RefDisciplineId = d.id, + Amount = 0, + }; + seq++; + resultData.Add(receiver); + } + } + } + } + return Success(); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-32 /// @@ -7419,6 +8106,65 @@ namespace BMA.EHR.Command.Service.Controllers return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-33 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command33/report")] + public async Task> PostReportCommand33([FromBody] ReportPersonRequest req_) + { + try + { + var resultData = new List(); + var baseAPI = _configuration["API"]; + + foreach (var id in req_.refIds) + { + var apiUrl = $"{baseAPI}/salary/report/command/33/{id}"; + + var response = new PassSalaryResponse(); + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var res = await client.SendAsync(req); + var result = await res.Content.ReadAsStringAsync(); + + response = JsonConvert.DeserializeObject(result); + + var seq = 1; + foreach (var d in response!.result) + { + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = d.citizenId, + Prefix = d.prefix == null ? "" : d.prefix, + FirstName = d.firstName, + LastName = d.lastName, + RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId), + RefDisciplineId = d.id, + }; + seq++; + + resultData.Add(receiver); + } + } + + } + return Success(); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-33 /// @@ -7449,6 +8195,64 @@ namespace BMA.EHR.Command.Service.Controllers return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-34 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command34/report")] + public async Task> PostReportCommand34([FromBody] ReportPersonRequest req_) + { + try + { + var resultData = new List(); + var baseAPI = _configuration["API"]; + + foreach (var id in req_.refIds) + { + var apiUrl = $"{baseAPI}/salary/report/command/34/{id}"; + + var response = new PassSalaryResponse(); + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var res = await client.SendAsync(req); + var result = await res.Content.ReadAsStringAsync(); + + response = JsonConvert.DeserializeObject(result); + + var seq = 1; + foreach (var d in response!.result) + { + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = d.citizenId, + Prefix = d.prefix == null ? "" : d.prefix, + FirstName = d.firstName, + LastName = d.lastName, + RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId), + RefDisciplineId = d.id, + }; + seq++; + + resultData.Add(receiver); + } + } + } + return Success(); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-34 /// @@ -7479,6 +8283,64 @@ namespace BMA.EHR.Command.Service.Controllers return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-35 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command35/report")] + public async Task> PostReportCommand35([FromBody] ReportPersonRequest req_) + { + try + { + var resultData = new List(); + var baseAPI = _configuration["API"]; + + foreach (var id in req_.refIds) + { + var apiUrl = $"{baseAPI}/salary/report/command/35/{id}"; + + var response = new PassSalaryResponse(); + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var res = await client.SendAsync(req); + var result = await res.Content.ReadAsStringAsync(); + + response = JsonConvert.DeserializeObject(result); + + var seq = 1; + foreach (var d in response!.result) + { + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = d.citizenId, + Prefix = d.prefix == null ? "" : d.prefix, + FirstName = d.firstName, + LastName = d.lastName, + RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId), + RefDisciplineId = d.id, + }; + seq++; + + resultData.Add(receiver); + } + } + } + return Success(); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-35 /// @@ -7509,6 +8371,64 @@ namespace BMA.EHR.Command.Service.Controllers return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-36 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command36/report")] + public async Task> PostReportCommand36([FromBody] ReportPersonRequest req_) + { + try + { + var resultData = new List(); + var baseAPI = _configuration["API"]; + + foreach (var id in req_.refIds) + { + var apiUrl = $"{baseAPI}/salary/report/command/36/{id}"; + + var response = new PassSalaryResponse(); + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var res = await client.SendAsync(req); + var result = await res.Content.ReadAsStringAsync(); + + response = JsonConvert.DeserializeObject(result); + + var seq = 1; + foreach (var d in response!.result) + { + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = d.citizenId, + Prefix = d.prefix == null ? "" : d.prefix, + FirstName = d.firstName, + LastName = d.lastName, + RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId), + RefDisciplineId = d.id, + }; + seq++; + + resultData.Add(receiver); + } + } + } + return Success(); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-36 /// @@ -7539,6 +8459,64 @@ namespace BMA.EHR.Command.Service.Controllers return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-37 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command37/report")] + public async Task> PostReportCommand37([FromBody] ReportPersonRequest req_) + { + try + { + var resultData = new List(); + var baseAPI = _configuration["API"]; + + foreach (var id in req_.refIds) + { + var apiUrl = $"{baseAPI}/salary/report/command/37/{id}"; + + var response = new PassSalaryResponse(); + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var res = await client.SendAsync(req); + var result = await res.Content.ReadAsStringAsync(); + + response = JsonConvert.DeserializeObject(result); + + var seq = 1; + foreach (var d in response!.result) + { + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = d.citizenId, + Prefix = d.prefix == null ? "" : d.prefix, + FirstName = d.firstName, + LastName = d.lastName, + RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId), + RefDisciplineId = d.id, + }; + seq++; + + resultData.Add(receiver); + } + } + } + return Success(); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-37 /// @@ -7568,6 +8546,64 @@ namespace BMA.EHR.Command.Service.Controllers return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-38 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command38/report")] + public async Task> PostReportCommand38([FromBody] ReportPersonRequest req_) + { + try + { + var resultData = new List(); + var baseAPI = _configuration["API"]; + + foreach (var id in req_.refIds) + { + var apiUrl = $"{baseAPI}/salary/report/command/38/{id}"; + + var response = new PassSalaryResponse(); + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var res = await client.SendAsync(req); + var result = await res.Content.ReadAsStringAsync(); + + response = JsonConvert.DeserializeObject(result); + + var seq = 1; + foreach (var d in response!.result) + { + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = d.citizenId, + Prefix = d.prefix == null ? "" : d.prefix, + FirstName = d.firstName, + LastName = d.lastName, + RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId), + RefDisciplineId = d.id, + }; + seq++; + + resultData.Add(receiver); + } + } + } + return Success(); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-38 /// @@ -7582,6 +8618,60 @@ namespace BMA.EHR.Command.Service.Controllers return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-40 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command40/report")] + public async Task> PostReportCommand40([FromBody] ReportPersonRequest req_) + { + try + { + var resultData = new List(); + var baseAPI = _configuration["API"]; + var apiUrl = $"{baseAPI}/org/pos/act/profile"; + + var response = new PassSalaryResponse(); + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var res = await client.SendAsync(req); + var result = await res.Content.ReadAsStringAsync(); + + response = JsonConvert.DeserializeObject(result); + + var seq = 1; + foreach (var d in response!.result) + { + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = d.citizenId, + Prefix = d.prefix == null ? "" : d.prefix, + FirstName = d.firstName, + LastName = d.lastName, + RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId), + RefDisciplineId = d.id, + }; + seq++; + + resultData.Add(receiver); + } + } + return Success(); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-40 /// diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs index cd2c55b6..bd37a113 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs @@ -1222,6 +1222,85 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-22 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("employee-appoint/report")] + public async Task> PostReportEmployeeAppoint([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.PlacementAppointments + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.type == "EMPLOYEE") + .ToListAsync(); + foreach (var placementProfile in placementProfiles) + { + // update placementstatus + placementProfile.Status = "REPORT"; + } + await _context.SaveChangesAsync(); + return Success(); + } + + /// + /// เอกสารแนบท้าย C-PM-22 + /// + /// Record Id ของคำสั่ง + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("employee-appoint/report/attachment")] + [AllowAnonymous] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> PostReportEmployeeAppointAttachment([FromBody] ReportPersonRequest req) + { + try + { + var report_data = await _context.PlacementAppointments + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.type == "EMPLOYEE") + .Select(p => new + { + //Seq = r.Sequence.ToString().ToThaiNumber(), + //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + Seq = "", + FullName = "", + Organization = p.rootOld, + OldOrganization = p.OrganizationOld, + OldPositionName = p.positionOld, + OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld.ToThaiNumber(), + OldPositionNumber = p.PositionNumberOld == null ? null : p.PositionNumberOld.ToThaiNumber(), + OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + NewOc = p.root == null ? "" : p.root, + NewPositionName = p.position == null ? "" : p.position, + NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName.ToThaiNumber(), + NewPositionNumber = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", + //NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), + NewSalary = "", + Reason = p.Reason == null ? "-" : p.Reason + }) + .ToListAsync(); + return Success(report_data); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-22 /// @@ -1294,6 +1373,86 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-24 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("employee-move/report")] + public async Task> PostReportEmployeeMove([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.PlacementAppointments + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.type == "EMPLOYEE") + .ToListAsync(); + foreach (var placementProfile in placementProfiles) + { + // update placementstatus + placementProfile.Status = "REPORT"; + } + await _context.SaveChangesAsync(); + return Success(); + } + + /// + /// เอกสารแนบท้าย C-PM-24 + /// + /// Record Id ของคำสั่ง + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("employee-move/report/attachment")] + [AllowAnonymous] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> PostReportEmployeeMoveAttachment([FromBody] ReportPersonRequest req) + { + try + { + var report_data = await _context.PlacementAppointments + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.type == "EMPLOYEE") + .Select(p => new + { + //Seq = r.Sequence.ToString().ToThaiNumber(), + //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + Seq = "", + FullName = "", + Organization = p.OrganizationPositionOld, + OldOrganization = p.OrganizationOld, + OldPositionName = p.positionOld, + OldPositionLevel = p.PositionLevelOld, + OldPositionNumber = p.PositionNumberOld == null ? null : p.PositionNumberOld.ToThaiNumber(), + OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + NewOc = p.root == null ? "" : p.root, + NewPositionName = p.position == null ? "" : p.position, + NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, + NewPositionNumber = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", + //NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), + NewSalary = "", + Reason = p.Reason == null ? "-" : p.Reason, + + }) + .ToListAsync(); + return Success(report_data); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-24 /// diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs index fb2079c7..9b4774d4 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs @@ -1809,6 +1809,76 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-23 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("leave-cancel/report")] + public async Task> PostReportLeaveCancel([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.RetirementResigns + .Where(x => req.refIds.Contains(x.Id.ToString())) + .ToListAsync(); + foreach (var placementProfile in placementProfiles) + { + // update placementstatus + placementProfile.Status = "REPORT"; + } + await _context.SaveChangesAsync(); + return Success(); + } + + /// + /// เอกสารแนบท้าย C-PM-23 + /// + /// Record Id ของคำสั่ง + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("leave-cancel/report/attachment")] + [AllowAnonymous] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> PostReportLeaveCancelAttachment([FromBody] ReportPersonRequest req) + { + try + { + var report_data = await _context.RetirementResigns + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Select(p => new + { + //Seq = r.Sequence.ToString().ToThaiNumber(), + //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + Seq = "", + CitizenId = "", + FullName = "", + Organization = p.OrganizationPositionOld ?? "", + PositionName = p.PositionOld ?? "", + PositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld.ToThaiNumber(), + PositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld.ToThaiNumber(), + PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), + Salary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + RetireDate = p.ActiveDate == null ? "" : p.ActiveDate.Value.ToThaiFullDate3().ToThaiNumber(), + //CommandYear = r.Command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(), + CommandYear = "" + }) + .ToListAsync(); + return Success(report_data); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-23 /// From 78ebcd3a4ed056d5e40a4913993f034f00cb7818 Mon Sep 17 00:00:00 2001 From: kittapath Date: Thu, 3 Oct 2024 14:02:06 +0700 Subject: [PATCH 19/42] no message --- .../Controllers/PlacementController.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index ecedd689..3767bb5a 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -280,10 +280,15 @@ namespace BMA.EHR.Placement.Service.Controllers .Where(x => rootId == "" ? true : (child1Id == "" ? x.rootId == rootId : (child2Id == "" ? x.child1Id == child1Id : (child3Id == "" ? x.child2Id == child2Id : (child4Id == "" ? x.child3Id == child3Id : x.child4Id == child4Id))))) .Select(x => new { + Id = x.Id, PersonalId = x.Id, Avatar = x.ProfileImg == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.ProfileImg.Id, FullName = $"{x.Prefix}{x.Firstname} {x.Lastname}", + Prefix = x.Prefix, + Firstname = x.Firstname, + Lastname = x.Lastname, IdCard = x.CitizenId, + CitizenId = x.CitizenId, ExamNumber = x.ExamNumber, posmasterId = x.posmasterId, root = x.root, @@ -327,10 +332,15 @@ namespace BMA.EHR.Placement.Service.Controllers { var _data = new { + p.Id, p.PersonalId, Avatar = p.Avatar == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(p.Avatar), p.FullName, + p.Prefix, + p.Firstname, + p.Lastname, p.IdCard, + p.CitizenId, p.ExamNumber, p.posmasterId, p.root, From 197bcd2307fb47e9ad51392c3a60e8c35aa1e12a Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 3 Oct 2024 14:10:35 +0700 Subject: [PATCH 20/42] no message --- .../Controllers/RetirementResignController.cs | 90 ++++++++++++++++--- 1 file changed, 80 insertions(+), 10 deletions(-) diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs index 9b4774d4..736c6f78 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs @@ -1764,6 +1764,76 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda return Success(); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-23 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("employee/report")] + public async Task> PostReportEmployee([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.RetirementResigns + .Where(x => req.refIds.Contains(x.Id.ToString())) + .ToListAsync(); + foreach (var placementProfile in placementProfiles) + { + // update placementstatus + placementProfile.Status = "REPORT"; + } + await _context.SaveChangesAsync(); + return Success(); + } + + /// + /// เอกสารแนบท้าย C-PM-23 + /// + /// Record Id ของคำสั่ง + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("employee/report/attachment")] + [AllowAnonymous] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> PostReportEmployeeAttachment([FromBody] ReportPersonRequest req) + { + try + { + var report_data = await _context.RetirementResigns + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Select(p => new + { + //Seq = r.Sequence.ToString().ToThaiNumber(), + //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + Seq = "", + CitizenId = "", + FullName = "", + Organization = p.OrganizationPositionOld ?? "", + PositionName = p.PositionOld ?? "", + PositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld.ToThaiNumber(), + PositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld.ToThaiNumber(), + PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), + Salary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + RetireDate = p.ActiveDate == null ? "" : p.ActiveDate.Value.ToThaiFullDate3().ToThaiNumber(), + //CommandYear = r.Command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(), + CommandYear = "" + }) + .ToListAsync(); + return Success(report_data); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-23 /// @@ -1810,7 +1880,7 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda } /// - /// ส่งรายชื่อออกคำสั่ง C-PM-23 + /// ส่งรายชื่อออกคำสั่ง C-PM-41 /// /// /// @@ -1826,14 +1896,14 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda foreach (var placementProfile in placementProfiles) { // update placementstatus - placementProfile.Status = "REPORT"; + placementProfile.Status = "DONE"; } await _context.SaveChangesAsync(); return Success(); } /// - /// เอกสารแนบท้าย C-PM-23 + /// เอกสารแนบท้าย C-PM-41 /// /// Record Id ของคำสั่ง /// pdf, docx หรือ xlsx @@ -1860,15 +1930,15 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda Seq = "", CitizenId = "", FullName = "", - Organization = p.OrganizationPositionOld ?? "", PositionName = p.PositionOld ?? "", - PositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld.ToThaiNumber(), - PositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld.ToThaiNumber(), + Organization = p.OrganizationPositionOld ?? "", + PositionLevel = p.PositionLevelOld ?? "", + PositionType = p.PositionTypeOld ?? "", PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), + ActiveDate = p.ActiveDate == null ? "" : p.ActiveDate.Value.ToThaiShortDate2().ToThaiNumber(), Salary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), - RetireDate = p.ActiveDate == null ? "" : p.ActiveDate.Value.ToThaiFullDate3().ToThaiNumber(), - //CommandYear = r.Command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(), - CommandYear = "" + Remark = p.Reason ?? "", + RemarkHorizontal = p.RemarkHorizontal, }) .ToListAsync(); return Success(report_data); @@ -1880,7 +1950,7 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda } /// - /// ออกคำสั่ง C-PM-23 + /// ออกคำสั่ง C-PM-41 /// /// /// From 63a9d4226cbd9fc3a1f91058844365d2900f7bb1 Mon Sep 17 00:00:00 2001 From: kittapath Date: Thu, 3 Oct 2024 14:27:52 +0700 Subject: [PATCH 21/42] no message --- .../Controllers/RetirementResignController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs index 9b4774d4..0b3c6dbb 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs @@ -1826,7 +1826,7 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda foreach (var placementProfile in placementProfiles) { // update placementstatus - placementProfile.Status = "REPORT"; + placementProfile.Status = "DONECANCEL"; } await _context.SaveChangesAsync(); return Success(); From ac60b954d4b4e2a8d819ed4ec06b1f1050304919 Mon Sep 17 00:00:00 2001 From: kittapath Date: Thu, 3 Oct 2024 14:52:39 +0700 Subject: [PATCH 22/42] no message --- .../PlacementAppointmentController.cs | 30 ++++--------------- .../Controllers/PlacementController.cs | 30 ++++--------------- .../Controllers/PlacementOfficerController.cs | 6 +--- .../Controllers/PlacementReceiveController.cs | 6 +--- .../PlacementRepatriationController.cs | 6 +--- .../PlacementTransferController.cs | 6 +--- .../Requests/ReportAttachmentRequest.cs | 21 +++++++++++++ .../Controllers/RetirementOtherController.cs | 12 ++------ .../Controllers/RetirementOutController.cs | 6 +--- 9 files changed, 38 insertions(+), 85 deletions(-) create mode 100644 BMA.EHR.Placement.Service/Requests/ReportAttachmentRequest.cs diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs index bd37a113..75642804 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs @@ -757,11 +757,7 @@ namespace BMA.EHR.Placement.Service.Controllers var placementProfiles = await _context.PlacementAppointments .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); - foreach (var placementProfile in placementProfiles) - { - // update placementstatus - placementProfile.Status = "REPORT"; - } + placementProfiles.ForEach(profile => profile.Status = "REPORT"); await _context.SaveChangesAsync(); return Success(); } @@ -918,11 +914,7 @@ namespace BMA.EHR.Placement.Service.Controllers var placementProfiles = await _context.PlacementAppointments .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); - foreach (var placementProfile in placementProfiles) - { - // update placementstatus - placementProfile.Status = "REPORT"; - } + placementProfiles.ForEach(profile => profile.Status = "REPORT"); await _context.SaveChangesAsync(); return Success(); } @@ -1079,11 +1071,7 @@ namespace BMA.EHR.Placement.Service.Controllers var placementProfiles = await _context.PlacementAppointments .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); - foreach (var placementProfile in placementProfiles) - { - // update placementstatus - placementProfile.Status = "REPORT"; - } + placementProfiles.ForEach(profile => profile.Status = "REPORT"); await _context.SaveChangesAsync(); return Success(); } @@ -1237,11 +1225,7 @@ namespace BMA.EHR.Placement.Service.Controllers .Where(x => req.refIds.Contains(x.Id.ToString())) .Where(x => x.type == "EMPLOYEE") .ToListAsync(); - foreach (var placementProfile in placementProfiles) - { - // update placementstatus - placementProfile.Status = "REPORT"; - } + placementProfiles.ForEach(profile => profile.Status = "REPORT"); await _context.SaveChangesAsync(); return Success(); } @@ -1388,11 +1372,7 @@ namespace BMA.EHR.Placement.Service.Controllers .Where(x => req.refIds.Contains(x.Id.ToString())) .Where(x => x.type == "EMPLOYEE") .ToListAsync(); - foreach (var placementProfile in placementProfiles) - { - // update placementstatus - placementProfile.Status = "REPORT"; - } + placementProfiles.ForEach(profile => profile.Status = "REPORT"); await _context.SaveChangesAsync(); return Success(); } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index 3767bb5a..45eb20eb 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -1479,11 +1479,7 @@ namespace BMA.EHR.Placement.Service.Controllers .Where(x => x.Placement!.PlacementType!.Name != "สอบแข่งขัน") .Where(x => x.typeCommand.Trim().ToUpper() == "APPOINTED") .ToListAsync(); - foreach (var placementProfile in placementProfiles) - { - // update placementstatus - placementProfile.PlacementStatus = "PREPARE-CONTAIN"; - } + placementProfiles.ForEach(profile => profile.PlacementStatus = "PREPARE-CONTAIN"); await _context.SaveChangesAsync(); return Success(); } @@ -1756,11 +1752,7 @@ namespace BMA.EHR.Placement.Service.Controllers .Where(x => x.Placement!.PlacementType!.Name != "สอบแข่งขัน") .Where(x => x.typeCommand.Trim().ToUpper() == "APPOINTED") .ToListAsync(); - foreach (var placementProfile in placementProfiles) - { - // update placementstatus - placementProfile.PlacementStatus = "PREPARE-CONTAIN"; - } + placementProfiles.ForEach(profile => profile.PlacementStatus = "PREPARE-CONTAIN"); await _context.SaveChangesAsync(); return Success(); } @@ -2032,11 +2024,7 @@ namespace BMA.EHR.Placement.Service.Controllers .Where(x => x.Placement!.PlacementType!.Name == "แต่งตั้งข้าราชการ") .Where(x => x.typeCommand.Trim().ToUpper() == "APPOIN") .ToListAsync(); - foreach (var placementProfile in placementProfiles) - { - // update placementstatus - placementProfile.PlacementStatus = "PREPARE-CONTAIN"; - } + placementProfiles.ForEach(profile => profile.PlacementStatus = "PREPARE-CONTAIN"); await _context.SaveChangesAsync(); return Success(); } @@ -2205,11 +2193,7 @@ namespace BMA.EHR.Placement.Service.Controllers .Where(x => x.Placement!.PlacementType!.Name == "ย้ายข้าราชการ") .Where(x => x.typeCommand.Trim().ToUpper() == "MOVE") .ToListAsync(); - foreach (var placementProfile in placementProfiles) - { - // update placementstatus - placementProfile.PlacementStatus = "PREPARE-CONTAIN"; - } + placementProfiles.ForEach(profile => profile.PlacementStatus = "PREPARE-CONTAIN"); await _context.SaveChangesAsync(); return Success(); } @@ -2374,11 +2358,7 @@ namespace BMA.EHR.Placement.Service.Controllers .Where(x => x.Placement!.PlacementType!.Name == "เลื่อนข้าราชการ") .Where(x => x.typeCommand.Trim().ToUpper() == "SLIP") .ToListAsync(); - foreach (var placementProfile in placementProfiles) - { - // update placementstatus - placementProfile.PlacementStatus = "PREPARE-CONTAIN"; - } + placementProfiles.ForEach(profile => profile.PlacementStatus = "PREPARE-CONTAIN"); await _context.SaveChangesAsync(); return Success(); } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs index abb9002f..555606a6 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs @@ -582,11 +582,7 @@ namespace BMA.EHR.Placement.Service.Controllers var placementProfiles = await _context.PlacementOfficers .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); - foreach (var placementProfile in placementProfiles) - { - // update placementstatus - placementProfile.Status = "REPORT"; - } + placementProfiles.ForEach(profile => profile.Status = "REPORT"); await _context.SaveChangesAsync(); return Success(); } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs index e48ca341..87c72f20 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs @@ -894,11 +894,7 @@ namespace BMA.EHR.Placement.Service.Controllers var placementProfiles = await _context.PlacementReceives .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); - foreach (var placementProfile in placementProfiles) - { - // update placementstatus - placementProfile.Status = "REPORT"; - } + placementProfiles.ForEach(profile => profile.Status = "REPORT"); await _context.SaveChangesAsync(); return Success(); } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs index dde4991b..6ea41841 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs @@ -489,11 +489,7 @@ namespace BMA.EHR.Placement.Service.Controllers var placementProfiles = await _context.PlacementRepatriations .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); - foreach (var placementProfile in placementProfiles) - { - // update placementstatus - placementProfile.Status = "REPORT"; - } + placementProfiles.ForEach(profile => profile.Status = "REPORT"); await _context.SaveChangesAsync(); return Success(); } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs index dd164e49..cc4322ea 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs @@ -772,11 +772,7 @@ namespace BMA.EHR.Placement.Service.Controllers var placementProfiles = await _context.PlacementTransfers .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); - foreach (var placementProfile in placementProfiles) - { - // update placementstatus - placementProfile.Status = "REPORT"; - } + placementProfiles.ForEach(profile => profile.Status = "REPORT"); await _context.SaveChangesAsync(); return Success(); } diff --git a/BMA.EHR.Placement.Service/Requests/ReportAttachmentRequest.cs b/BMA.EHR.Placement.Service/Requests/ReportAttachmentRequest.cs new file mode 100644 index 00000000..7718c354 --- /dev/null +++ b/BMA.EHR.Placement.Service/Requests/ReportAttachmentRequest.cs @@ -0,0 +1,21 @@ +using BMA.EHR.Domain.Models.MetaData; +using Microsoft.EntityFrameworkCore; + +namespace BMA.EHR.Placement.Service.Requests +{ + public class ReportExecuteRequest + { + public ReportExecuteRequestObj[] refIds { get; set; } + } + public class ReportExecuteRequestObj + { + public string? refId { get; set; } + public DateTime commandAffectDate { get; set; } + public string? commandNo { get; set; } + public int commandYear { get; set; } + public string? templateDoc { get; set; } + public double? amount { get; set; } + public double? positionSalaryAmount { get; set; } + public double? mouthSalaryAmount { get; set; } + } +} diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs index bd08e778..eb0b7199 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs @@ -639,11 +639,7 @@ namespace BMA.EHR.Retirement.Service.Controllers var placementProfiles = await _context.RetirementOthers .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); - foreach (var placementProfile in placementProfiles) - { - // update placementstatus - placementProfile.Status = "REPORT"; - } + placementProfiles.ForEach(profile => profile.Status = "REPORT"); await _context.SaveChangesAsync(); return Success(); } @@ -789,11 +785,7 @@ namespace BMA.EHR.Retirement.Service.Controllers var placementProfiles = await _context.RetirementOthers .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); - foreach (var placementProfile in placementProfiles) - { - // update placementstatus - placementProfile.Status = "REPORT"; - } + placementProfiles.ForEach(profile => profile.Status = "REPORT"); await _context.SaveChangesAsync(); return Success(); } diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs index 7f88d024..034e2e55 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs @@ -480,11 +480,7 @@ namespace BMA.EHR.Retirement.Service.Controllers var placementProfiles = await _context.RetirementResigns .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); - foreach (var placementProfile in placementProfiles) - { - // update placementstatus - placementProfile.Status = "REPORT"; - } + placementProfiles.ForEach(profile => profile.Status = "REPORT"); await _context.SaveChangesAsync(); return Success(); } From 93f8fa5832b025789471fe916a083168583277cf Mon Sep 17 00:00:00 2001 From: kittapath Date: Thu, 3 Oct 2024 14:58:01 +0700 Subject: [PATCH 23/42] no message --- .../Requests/ReportAttachmentRequest.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/BMA.EHR.Placement.Service/Requests/ReportAttachmentRequest.cs b/BMA.EHR.Placement.Service/Requests/ReportAttachmentRequest.cs index 7718c354..3b5d2c59 100644 --- a/BMA.EHR.Placement.Service/Requests/ReportAttachmentRequest.cs +++ b/BMA.EHR.Placement.Service/Requests/ReportAttachmentRequest.cs @@ -3,19 +3,22 @@ using Microsoft.EntityFrameworkCore; namespace BMA.EHR.Placement.Service.Requests { - public class ReportExecuteRequest + public class ReportAttachmentRequest { - public ReportExecuteRequestObj[] refIds { get; set; } + public ReportAttachmentRequestObj[] refIds { get; set; } } - public class ReportExecuteRequestObj + public class ReportAttachmentRequestObj { - public string? refId { get; set; } - public DateTime commandAffectDate { get; set; } - public string? commandNo { get; set; } - public int commandYear { get; set; } - public string? templateDoc { get; set; } + public int? Sequence { get; set; } + public string? CitizenId { get; set; } + public string? Prefix { get; set; } + public string? FirstName { get; set; } + public string? LastName { get; set; } public double? amount { get; set; } public double? positionSalaryAmount { get; set; } public double? mouthSalaryAmount { get; set; } + public string? RemarkHorizontal { get; set; } + public string? RemarkVertical { get; set; } + } } From 2f3a68254e396c39ecceb94864a1b9fd9a74d7b6 Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 3 Oct 2024 14:58:48 +0700 Subject: [PATCH 24/42] no message --- .../Controllers/OrderController.cs | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs index ff725e06..22017275 100644 --- a/BMA.EHR.Command.Service/Controllers/OrderController.cs +++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs @@ -8672,6 +8672,74 @@ namespace BMA.EHR.Command.Service.Controllers } } + /// + /// เอกสารแนบท้าย C-PM-40 + /// + /// Record Id ของคำสั่ง + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command40/report/attachment")] + [AllowAnonymous] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> PostReportCommand40Attachment([FromBody] ReportPersonRequest req_) + { + try + { + var raw_data = await _context.Set() + .Include(c => c.Command) + .Where(c => req_.refIds.Contains(c.Id.ToString())) + .ToListAsync(); + if (raw_data == null) + { + throw new Exception(GlobalMessages.CommandNotFound); + } + var data = new List(); + var no = 1; + foreach (var d in raw_data) + { + var apiUrl = $"{_configuration["API"]}/org/pos/act/{d.RefDisciplineId}/{d.RefPlacementProfileId}"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var _res = await client.SendAsync(_req); + var _result = await _res.Content.ReadAsStringAsync(); + + var org = JsonConvert.DeserializeObject(_result); + + if (org == null || org.result == null) + continue; + var receiver = new CommandType40Response + { + no = no.ToString().ToThaiNumber(), + fullName = $"{org.result.prefix}{org.result.firstName} {org.result.lastName}", + organization = org.result.organization, + position = org.result.position, + postype = org.result.postype, + poslevel = org.result.poslevel, + organizationNew = org.result.organizationNew, + dateStart = d.Command.ActStartDate == null ? "-" : d.Command.ActStartDate.Value.ToThaiFullDate3().ToThaiNumber(), + dateEnd = d.Command.ActEndDate == null ? "-" : d.Command.ActEndDate.Value.ToThaiFullDate3().ToThaiNumber(), + order = org.result.order, + }; + no = no + 1; + + data.Add(receiver); + } + } + return Success(data); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-40 /// From e862829246d7a6bc31824bff05da1e29df8152ff Mon Sep 17 00:00:00 2001 From: kittapath Date: Thu, 3 Oct 2024 15:10:58 +0700 Subject: [PATCH 25/42] no message --- .../Controllers/RetirementResignController.cs | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs index 4a747124..0691de34 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs @@ -1640,11 +1640,7 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda var placementProfiles = await _context.RetirementResigns .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); - foreach (var placementProfile in placementProfiles) - { - // update placementstatus - placementProfile.Status = "REPORT"; - } + placementProfiles.ForEach(profile => profile.Status = "REPORT"); await _context.SaveChangesAsync(); return Success(); } @@ -1778,11 +1774,7 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda var placementProfiles = await _context.RetirementResigns .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); - foreach (var placementProfile in placementProfiles) - { - // update placementstatus - placementProfile.Status = "REPORT"; - } + placementProfiles.ForEach(profile => profile.Status = "REPORT"); await _context.SaveChangesAsync(); return Success(); } @@ -1893,11 +1885,7 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda var placementProfiles = await _context.RetirementResigns .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); - foreach (var placementProfile in placementProfiles) - { - // update placementstatus - placementProfile.Status = "DONECANCEL"; - } + placementProfiles.ForEach(profile => profile.Status = "DONECANCEL"); await _context.SaveChangesAsync(); return Success(); } From 604b234c4b5dd77bfcdbab1a9da82aed10cc7c37 Mon Sep 17 00:00:00 2001 From: kittapath Date: Thu, 3 Oct 2024 18:34:13 +0700 Subject: [PATCH 26/42] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=20=E0=B8=AD?= =?UTF-8?q?=E0=B8=AD=E0=B8=81=20=E0=B8=84=E0=B8=B3=20=E0=B8=AA=E0=B8=B1?= =?UTF-8?q?=E0=B9=88=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/OrderController.cs | 507 +++++++++--------- .../Requests/ReportAttachmentRequest.cs | 26 + .../Controllers/DisciplineResultController.cs | 8 +- .../PlacementAppointmentController.cs | 346 ++++++------ .../Controllers/PlacementController.cs | 402 +++++++------- .../Controllers/PlacementOfficerController.cs | 39 +- .../Controllers/PlacementReceiveController.cs | 69 +-- .../PlacementRepatriationController.cs | 1 + .../PlacementTransferController.cs | 47 +- .../Requests/ReportAttachmentRequest.cs | 9 +- .../RetirementDeceasedController.cs | 1 + .../Controllers/RetirementOtherController.cs | 128 ++--- .../Controllers/RetirementOutController.cs | 1 + .../Controllers/RetirementResignController.cs | 133 ++--- .../Requests/ReportAttachmentRequest.cs | 25 + 15 files changed, 897 insertions(+), 845 deletions(-) create mode 100644 BMA.EHR.Command.Service/Requests/ReportAttachmentRequest.cs create mode 100644 BMA.EHR.Retirement.Service/Requests/ReportAttachmentRequest.cs diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs index 22017275..6e8a2c35 100644 --- a/BMA.EHR.Command.Service/Controllers/OrderController.cs +++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs @@ -6797,11 +6797,7 @@ namespace BMA.EHR.Command.Service.Controllers .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); - foreach (var placementProfile in placementProfiles) - { - // update placementstatus - placementProfile.Status = "REPORT"; - } + placementProfiles.ForEach(profile => profile.Status = "REPORT"); await _context.SaveChangesAsync(); return Success(); } @@ -6873,11 +6869,7 @@ namespace BMA.EHR.Command.Service.Controllers .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); - foreach (var placementProfile in placementProfiles) - { - // update placementstatus - placementProfile.Status = "REPORT"; - } + placementProfiles.ForEach(profile => profile.Status = "REPORT"); await _context.SaveChangesAsync(); return Success(); } @@ -7120,21 +7112,13 @@ namespace BMA.EHR.Command.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> PostReportCommand25Attachment([FromBody] ReportPersonRequest req_) + public async Task> PostReportCommand25Attachment([FromBody] ReportAttachmentRequest req) { try { - var raw_data = await _context.Set() - .Include(c => c.Command) - .Where(c => req_.refIds.Contains(c.Id.ToString())) - .ToListAsync(); - if (raw_data == null) + foreach (var d in req.refIds) { - throw new Exception(GlobalMessages.CommandNotFound); - } - foreach (var d in raw_data) - { - var apiUrl = $"{_configuration["API"]}/discipline/result/report/find/{d.RefDisciplineId}/{d.RefPlacementProfileId}"; + var apiUrl = $"{_configuration["API"]}/discipline/result/report/find/{d.refId}"; using (var client = new HttpClient()) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); @@ -7148,7 +7132,7 @@ namespace BMA.EHR.Command.Service.Controllers continue; var receiver = new CommandType23Response { - fullName = $"{org.result.prefix}{org.result.firstName} {org.result.lastName}", + fullName = $"{d.Prefix}{d.FirstName} {d.LastName}", positionname = org.result.position, positionno = org.result.posNo == null ? null : org.result.posNo.ToThaiNumber(), organizationname = org.result.organization, @@ -7164,7 +7148,7 @@ namespace BMA.EHR.Command.Service.Controllers { throw; } - } + } /// /// ออกคำสั่ง C-PM-25 @@ -8115,48 +8099,47 @@ namespace BMA.EHR.Command.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpPost("command33/report")] - public async Task> PostReportCommand33([FromBody] ReportPersonRequest req_) + public async Task> PostReportCommand33([FromBody] ReportPersonRequest req) { try { - var resultData = new List(); - var baseAPI = _configuration["API"]; + // var resultData = new List(); + // var baseAPI = _configuration["API"]; - foreach (var id in req_.refIds) - { - var apiUrl = $"{baseAPI}/salary/report/command/33/{id}"; + // foreach (var id in req.refIds) + // { + // var apiUrl = $"{baseAPI}/salary/report/command/33/{id}"; - var response = new PassSalaryResponse(); - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var res = await client.SendAsync(req); - var result = await res.Content.ReadAsStringAsync(); + // var response = new PassSalaryResponse(); + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + // client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + // var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + // var res = await client.SendAsync(_req); + // // var result = await res.Content.ReadAsStringAsync(); - response = JsonConvert.DeserializeObject(result); + // // response = JsonConvert.DeserializeObject(result); - var seq = 1; - foreach (var d in response!.result) - { - var receiver = new CommandReceiver - { - Sequence = seq, - CitizenId = d.citizenId, - Prefix = d.prefix == null ? "" : d.prefix, - FirstName = d.firstName, - LastName = d.lastName, - RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId), - RefDisciplineId = d.id, - }; - seq++; + // // var seq = 1; + // // foreach (var d in response!.result) + // // { + // // var receiver = new CommandReceiver + // // { + // // Sequence = seq, + // // CitizenId = d.citizenId, + // // Prefix = d.prefix == null ? "" : d.prefix, + // // FirstName = d.firstName, + // // LastName = d.lastName, + // // RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId), + // // RefDisciplineId = d.id, + // // }; + // // seq++; - resultData.Add(receiver); - } - } - - } + // // resultData.Add(receiver); + // // } + // } + // } return Success(); } catch @@ -8204,47 +8187,47 @@ namespace BMA.EHR.Command.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpPost("command34/report")] - public async Task> PostReportCommand34([FromBody] ReportPersonRequest req_) + public async Task> PostReportCommand34([FromBody] ReportPersonRequest req) { try { - var resultData = new List(); - var baseAPI = _configuration["API"]; + // var resultData = new List(); + // var baseAPI = _configuration["API"]; - foreach (var id in req_.refIds) - { - var apiUrl = $"{baseAPI}/salary/report/command/34/{id}"; + // foreach (var id in req.refIds) + // { + // var apiUrl = $"{baseAPI}/salary/report/command/34/{id}"; - var response = new PassSalaryResponse(); - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var res = await client.SendAsync(req); - var result = await res.Content.ReadAsStringAsync(); + // var response = new PassSalaryResponse(); + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + // client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + // var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + // var res = await client.SendAsync(_req); + // // var result = await res.Content.ReadAsStringAsync(); - response = JsonConvert.DeserializeObject(result); + // // response = JsonConvert.DeserializeObject(result); - var seq = 1; - foreach (var d in response!.result) - { - var receiver = new CommandReceiver - { - Sequence = seq, - CitizenId = d.citizenId, - Prefix = d.prefix == null ? "" : d.prefix, - FirstName = d.firstName, - LastName = d.lastName, - RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId), - RefDisciplineId = d.id, - }; - seq++; + // // var seq = 1; + // // foreach (var d in response!.result) + // // { + // // var receiver = new CommandReceiver + // // { + // // Sequence = seq, + // // CitizenId = d.citizenId, + // // Prefix = d.prefix == null ? "" : d.prefix, + // // FirstName = d.firstName, + // // LastName = d.lastName, + // // RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId), + // // RefDisciplineId = d.id, + // // }; + // // seq++; - resultData.Add(receiver); - } - } - } + // // resultData.Add(receiver); + // // } + // } + // } return Success(); } catch @@ -8292,47 +8275,47 @@ namespace BMA.EHR.Command.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpPost("command35/report")] - public async Task> PostReportCommand35([FromBody] ReportPersonRequest req_) + public async Task> PostReportCommand35([FromBody] ReportPersonRequest req) { try { - var resultData = new List(); - var baseAPI = _configuration["API"]; + // var resultData = new List(); + // var baseAPI = _configuration["API"]; - foreach (var id in req_.refIds) - { - var apiUrl = $"{baseAPI}/salary/report/command/35/{id}"; + // foreach (var id in req.refIds) + // { + // var apiUrl = $"{baseAPI}/salary/report/command/35/{id}"; - var response = new PassSalaryResponse(); - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var res = await client.SendAsync(req); - var result = await res.Content.ReadAsStringAsync(); + // var response = new PassSalaryResponse(); + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + // client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + // var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + // var res = await client.SendAsync(_req); + // // var result = await res.Content.ReadAsStringAsync(); - response = JsonConvert.DeserializeObject(result); + // // response = JsonConvert.DeserializeObject(result); - var seq = 1; - foreach (var d in response!.result) - { - var receiver = new CommandReceiver - { - Sequence = seq, - CitizenId = d.citizenId, - Prefix = d.prefix == null ? "" : d.prefix, - FirstName = d.firstName, - LastName = d.lastName, - RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId), - RefDisciplineId = d.id, - }; - seq++; + // // var seq = 1; + // // foreach (var d in response!.result) + // // { + // // var receiver = new CommandReceiver + // // { + // // Sequence = seq, + // // CitizenId = d.citizenId, + // // Prefix = d.prefix == null ? "" : d.prefix, + // // FirstName = d.firstName, + // // LastName = d.lastName, + // // RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId), + // // RefDisciplineId = d.id, + // // }; + // // seq++; - resultData.Add(receiver); - } - } - } + // // resultData.Add(receiver); + // // } + // } + // } return Success(); } catch @@ -8380,47 +8363,47 @@ namespace BMA.EHR.Command.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpPost("command36/report")] - public async Task> PostReportCommand36([FromBody] ReportPersonRequest req_) + public async Task> PostReportCommand36([FromBody] ReportPersonRequest req) { try { - var resultData = new List(); - var baseAPI = _configuration["API"]; + // var resultData = new List(); + // var baseAPI = _configuration["API"]; - foreach (var id in req_.refIds) - { - var apiUrl = $"{baseAPI}/salary/report/command/36/{id}"; + // foreach (var id in req.refIds) + // { + // var apiUrl = $"{baseAPI}/salary/report/command/36/{id}"; - var response = new PassSalaryResponse(); - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var res = await client.SendAsync(req); - var result = await res.Content.ReadAsStringAsync(); + // var response = new PassSalaryResponse(); + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + // client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + // var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + // var res = await client.SendAsync(_req); + // // var result = await res.Content.ReadAsStringAsync(); - response = JsonConvert.DeserializeObject(result); + // // response = JsonConvert.DeserializeObject(result); - var seq = 1; - foreach (var d in response!.result) - { - var receiver = new CommandReceiver - { - Sequence = seq, - CitizenId = d.citizenId, - Prefix = d.prefix == null ? "" : d.prefix, - FirstName = d.firstName, - LastName = d.lastName, - RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId), - RefDisciplineId = d.id, - }; - seq++; + // // var seq = 1; + // // foreach (var d in response!.result) + // // { + // // var receiver = new CommandReceiver + // // { + // // Sequence = seq, + // // CitizenId = d.citizenId, + // // Prefix = d.prefix == null ? "" : d.prefix, + // // FirstName = d.firstName, + // // LastName = d.lastName, + // // RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId), + // // RefDisciplineId = d.id, + // // }; + // // seq++; - resultData.Add(receiver); - } - } - } + // // resultData.Add(receiver); + // // } + // } + // } return Success(); } catch @@ -8468,47 +8451,47 @@ namespace BMA.EHR.Command.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpPost("command37/report")] - public async Task> PostReportCommand37([FromBody] ReportPersonRequest req_) + public async Task> PostReportCommand37([FromBody] ReportPersonRequest req) { try { - var resultData = new List(); - var baseAPI = _configuration["API"]; + // var resultData = new List(); + // var baseAPI = _configuration["API"]; - foreach (var id in req_.refIds) - { - var apiUrl = $"{baseAPI}/salary/report/command/37/{id}"; + // foreach (var id in req.refIds) + // { + // var apiUrl = $"{baseAPI}/salary/report/command/37/{id}"; - var response = new PassSalaryResponse(); - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var res = await client.SendAsync(req); - var result = await res.Content.ReadAsStringAsync(); + // var response = new PassSalaryResponse(); + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + // client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + // var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + // var res = await client.SendAsync(_req); + // // var result = await res.Content.ReadAsStringAsync(); - response = JsonConvert.DeserializeObject(result); + // // response = JsonConvert.DeserializeObject(result); - var seq = 1; - foreach (var d in response!.result) - { - var receiver = new CommandReceiver - { - Sequence = seq, - CitizenId = d.citizenId, - Prefix = d.prefix == null ? "" : d.prefix, - FirstName = d.firstName, - LastName = d.lastName, - RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId), - RefDisciplineId = d.id, - }; - seq++; + // // var seq = 1; + // // foreach (var d in response!.result) + // // { + // // var receiver = new CommandReceiver + // // { + // // Sequence = seq, + // // CitizenId = d.citizenId, + // // Prefix = d.prefix == null ? "" : d.prefix, + // // FirstName = d.firstName, + // // LastName = d.lastName, + // // RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId), + // // RefDisciplineId = d.id, + // // }; + // // seq++; - resultData.Add(receiver); - } - } - } + // // resultData.Add(receiver); + // // } + // } + // } return Success(); } catch @@ -8555,47 +8538,47 @@ namespace BMA.EHR.Command.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpPost("command38/report")] - public async Task> PostReportCommand38([FromBody] ReportPersonRequest req_) + public async Task> PostReportCommand38([FromBody] ReportPersonRequest req) { try { - var resultData = new List(); - var baseAPI = _configuration["API"]; + // var resultData = new List(); + // var baseAPI = _configuration["API"]; - foreach (var id in req_.refIds) - { - var apiUrl = $"{baseAPI}/salary/report/command/38/{id}"; + // foreach (var id in req.refIds) + // { + // var apiUrl = $"{baseAPI}/salary/report/command/38/{id}"; - var response = new PassSalaryResponse(); - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var res = await client.SendAsync(req); - var result = await res.Content.ReadAsStringAsync(); + // var response = new PassSalaryResponse(); + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + // client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + // var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + // var res = await client.SendAsync(_req); + // // var result = await res.Content.ReadAsStringAsync(); - response = JsonConvert.DeserializeObject(result); + // // response = JsonConvert.DeserializeObject(result); - var seq = 1; - foreach (var d in response!.result) - { - var receiver = new CommandReceiver - { - Sequence = seq, - CitizenId = d.citizenId, - Prefix = d.prefix == null ? "" : d.prefix, - FirstName = d.firstName, - LastName = d.lastName, - RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId), - RefDisciplineId = d.id, - }; - seq++; + // // var seq = 1; + // // foreach (var d in response!.result) + // // { + // // var receiver = new CommandReceiver + // // { + // // Sequence = seq, + // // CitizenId = d.citizenId, + // // Prefix = d.prefix == null ? "" : d.prefix, + // // FirstName = d.firstName, + // // LastName = d.lastName, + // // RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId), + // // RefDisciplineId = d.id, + // // }; + // // seq++; - resultData.Add(receiver); - } - } - } + // // resultData.Add(receiver); + // // } + // } + // } return Success(); } catch @@ -8627,43 +8610,43 @@ namespace BMA.EHR.Command.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpPost("command40/report")] - public async Task> PostReportCommand40([FromBody] ReportPersonRequest req_) + public async Task> PostReportCommand40([FromBody] ReportPersonRequest req) { try { - var resultData = new List(); - var baseAPI = _configuration["API"]; - var apiUrl = $"{baseAPI}/org/pos/act/profile"; + // var resultData = new List(); + // var baseAPI = _configuration["API"]; + // var apiUrl = $"{baseAPI}/org/pos/act/profile"; - var response = new PassSalaryResponse(); - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var res = await client.SendAsync(req); - var result = await res.Content.ReadAsStringAsync(); + // var response = new PassSalaryResponse(); + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + // client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + // var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + // var res = await client.SendAsync(_req); + // // var result = await res.Content.ReadAsStringAsync(); - response = JsonConvert.DeserializeObject(result); + // // response = JsonConvert.DeserializeObject(result); - var seq = 1; - foreach (var d in response!.result) - { - var receiver = new CommandReceiver - { - Sequence = seq, - CitizenId = d.citizenId, - Prefix = d.prefix == null ? "" : d.prefix, - FirstName = d.firstName, - LastName = d.lastName, - RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId), - RefDisciplineId = d.id, - }; - seq++; + // // var seq = 1; + // // foreach (var d in response!.result) + // // { + // // var receiver = new CommandReceiver + // // { + // // Sequence = seq, + // // CitizenId = d.citizenId, + // // Prefix = d.prefix == null ? "" : d.prefix, + // // FirstName = d.firstName, + // // LastName = d.lastName, + // // RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId), + // // RefDisciplineId = d.id, + // // }; + // // seq++; - resultData.Add(receiver); - } - } + // // resultData.Add(receiver); + // // } + // } return Success(); } catch @@ -8686,23 +8669,15 @@ namespace BMA.EHR.Command.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> PostReportCommand40Attachment([FromBody] ReportPersonRequest req_) + public async Task> PostReportCommand40Attachment([FromBody] ReportAttachmentRequest req) { try { - var raw_data = await _context.Set() - .Include(c => c.Command) - .Where(c => req_.refIds.Contains(c.Id.ToString())) - .ToListAsync(); - if (raw_data == null) - { - throw new Exception(GlobalMessages.CommandNotFound); - } var data = new List(); var no = 1; - foreach (var d in raw_data) + foreach (var d in req.refIds) { - var apiUrl = $"{_configuration["API"]}/org/pos/act/{d.RefDisciplineId}/{d.RefPlacementProfileId}"; + var apiUrl = $"{_configuration["API"]}/org/pos/act/{d.refId}"; using (var client = new HttpClient()) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); @@ -8723,8 +8698,10 @@ namespace BMA.EHR.Command.Service.Controllers postype = org.result.postype, poslevel = org.result.poslevel, organizationNew = org.result.organizationNew, - dateStart = d.Command.ActStartDate == null ? "-" : d.Command.ActStartDate.Value.ToThaiFullDate3().ToThaiNumber(), - dateEnd = d.Command.ActEndDate == null ? "-" : d.Command.ActEndDate.Value.ToThaiFullDate3().ToThaiNumber(), + // dateStart = d.Command.ActStartDate == null ? "-" : d.Command.ActStartDate.Value.ToThaiFullDate3().ToThaiNumber(), + // dateEnd = d.Command.ActEndDate == null ? "-" : d.Command.ActEndDate.Value.ToThaiFullDate3().ToThaiNumber(), + dateStart = "xxx", + dateEnd = "xxx", order = org.result.order, }; no = no + 1; diff --git a/BMA.EHR.Command.Service/Requests/ReportAttachmentRequest.cs b/BMA.EHR.Command.Service/Requests/ReportAttachmentRequest.cs new file mode 100644 index 00000000..a3ddafe6 --- /dev/null +++ b/BMA.EHR.Command.Service/Requests/ReportAttachmentRequest.cs @@ -0,0 +1,26 @@ +using BMA.EHR.Domain.Models.MetaData; +using Microsoft.EntityFrameworkCore; + +namespace BMA.EHR.Command.Service.Requests +{ + public class ReportAttachmentRequest + { + public ReportAttachmentRequestObj[] refIds { get; set; } + } + public class ReportAttachmentRequestObj + { + public string? refId { get; set; } + public int? Sequence { get; set; } + public string? CitizenId { get; set; } + public string? Prefix { get; set; } + public string? FirstName { get; set; } + public string? LastName { get; set; } + public double? Amount { get; set; } + public double? PositionSalaryAmount { get; set; } + public double? MouthSalaryAmount { get; set; } + public string? RemarkHorizontal { get; set; } + public string? RemarkVertical { get; set; } + public int CommandYear { get; set; } + + } +} diff --git a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs index c6b59020..0210a48a 100644 --- a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs +++ b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs @@ -708,30 +708,26 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpGet("report/find/{periodId:guid}/{personId:guid}")] - public async Task> GetPersonReportFind(Guid periodId, Guid personId) + [HttpGet("report/find/{periodId:guid}")] + public async Task> GetPersonReportFind(Guid periodId) { var data1 = await _context.DisciplineComplaint_Profiles .Where(x => x.Id == periodId) - .Where(x => x.PersonId == personId.ToString()) .FirstOrDefaultAsync(); if (data1 == null) { var data2 = await _context.DisciplineInvestigate_ProfileComplaints .Where(x => x.Id == periodId) - .Where(x => x.PersonId == personId.ToString()) .FirstOrDefaultAsync(); if (data2 == null) { var data3 = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates .Where(x => x.Id == periodId) - .Where(x => x.PersonId == personId.ToString()) .FirstOrDefaultAsync(); if (data3 == null) { var data4 = await _context.DisciplineReport_Profiles .Where(x => x.Id == periodId) - .Where(x => x.PersonId == personId.ToString()) .FirstOrDefaultAsync(); return Success(data4); } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs index 75642804..5a93eb6a 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs @@ -763,7 +763,7 @@ namespace BMA.EHR.Placement.Service.Controllers } /// - /// เอกสารแนบท้าย C-PM-5 + /// เอกสารแนบท้าย C-PM-05 /// /// Record Id ของคำสั่ง /// pdf, docx หรือ xlsx @@ -776,45 +776,45 @@ namespace BMA.EHR.Placement.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> PostReportAppointAttachment([FromBody] ReportPersonRequest req) + public async Task> PostReportAppointAttachment([FromBody] ReportAttachmentRequest req) { try { - var report_data = await _context.PlacementAppointments - .Where(x => req.refIds.Contains(x.Id.ToString())) - .Select(p => new - { - Education = p.EducationOld == null ? "-" : p.EducationOld, - //Seq = r.Sequence.ToString().ToThaiNumber(), - //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), - //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - Seq = "", - CitizenId = "", - FullName = "", - OldOc = p.rootOld == null ? "" : p.rootOld, - OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, - OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, - OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, - OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), - OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), - OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), - NewOc = p.root == null ? "" : p.root, - NewPositionName = p.position == null ? "" : p.position, - NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, - NewPositionType = p.posTypeName == null ? "" : p.posTypeName, - NewPositionNumber = p.posMasterNo == null ? "" : - p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", - //NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), - NewSalary = "", - AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), - Reason = p.Reason == null ? "-" : p.Reason - - }) - .ToListAsync(); + var report_data = (from p in _context.PlacementAppointments + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToList() + join r in req.refIds + on p.Id.ToString() equals r.refId + orderby r.Sequence + select new + { + Education = p.EducationOld == null ? "-" : p.EducationOld, + Seq = r.Sequence.ToString().ToThaiNumber(), + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + OldOc = p.rootOld == null ? "" : p.rootOld, + OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, + OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, + OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, + OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), + OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), + NewOc = p.root == null ? "" : p.root, + NewPositionName = p.position == null ? "" : p.position, + NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, + NewPositionType = p.posTypeName == null ? "" : p.posTypeName, + NewPositionNumber = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", + NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), + AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), + Reason = p.Reason == null ? "-" : p.Reason, + RemarkHorizontal = r.RemarkHorizontal, + RemarkVertical = r.RemarkVertical, + }).ToList(); return Success(report_data); } catch @@ -920,7 +920,7 @@ namespace BMA.EHR.Placement.Service.Controllers } /// - /// เอกสารแนบท้าย C-PM-6 + /// เอกสารแนบท้าย C-PM-06 /// /// Record Id ของคำสั่ง /// pdf, docx หรือ xlsx @@ -933,45 +933,45 @@ namespace BMA.EHR.Placement.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> PostReporSlipAttachment([FromBody] ReportPersonRequest req) + public async Task> PostReporSlipAttachment([FromBody] ReportAttachmentRequest req) { try { - var report_data = await _context.PlacementAppointments - .Where(x => req.refIds.Contains(x.Id.ToString())) - .Select(p => new - { - Education = p.EducationOld == null ? "-" : p.EducationOld, - //Seq = r.Sequence.ToString().ToThaiNumber(), - //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), - //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - Seq = "", - CitizenId = "", - FullName = "", - OldOc = p.rootOld == null ? "" : p.rootOld, - OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, - OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, - OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, - OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), - OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), - OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), - NewOc = p.root == null ? "" : p.root, - NewPositionName = p.position == null ? "" : p.position, - NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, - NewPositionType = p.posTypeName == null ? "" : p.posTypeName, - NewPositionNumber = p.posMasterNo == null ? "" : - p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", - //NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), - NewSalary = "", - AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), - Reason = p.Reason == null ? "-" : p.Reason - - }) - .ToListAsync(); + var report_data = (from p in _context.PlacementAppointments + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToList() + join r in req.refIds + on p.Id.ToString() equals r.refId + orderby r.Sequence + select new + { + Education = p.EducationOld == null ? "-" : p.EducationOld, + Seq = r.Sequence.ToString().ToThaiNumber(), + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + OldOc = p.rootOld == null ? "" : p.rootOld, + OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, + OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, + OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, + OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), + OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), + NewOc = p.root == null ? "" : p.root, + NewPositionName = p.position == null ? "" : p.position, + NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, + NewPositionType = p.posTypeName == null ? "" : p.posTypeName, + NewPositionNumber = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", + NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), + AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), + Reason = p.Reason == null ? "-" : p.Reason, + RemarkHorizontal = r.RemarkHorizontal, + RemarkVertical = r.RemarkVertical, + }).ToList(); return Success(report_data); } catch @@ -1077,7 +1077,7 @@ namespace BMA.EHR.Placement.Service.Controllers } /// - /// เอกสารแนบท้าย C-PM-7 + /// เอกสารแนบท้าย C-PM-07 /// /// Record Id ของคำสั่ง /// pdf, docx หรือ xlsx @@ -1090,44 +1090,45 @@ namespace BMA.EHR.Placement.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> PostReporMoveAttachment([FromBody] ReportPersonRequest req) + public async Task> PostReporMoveAttachment([FromBody] ReportAttachmentRequest req) { try { - var report_data = await _context.PlacementAppointments - .Where(x => req.refIds.Contains(x.Id.ToString())) - .Select(p => new - { - Education = p.EducationOld == null ? "-" : p.EducationOld, - //Seq = r.Sequence.ToString().ToThaiNumber(), - //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), - //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - Seq = "", - CitizenId = "", - FullName = "", - OldOc = p.rootOld == null ? "" : p.rootOld, - OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, - OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, - OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, - OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), - OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), - OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), - NewOc = p.root == null ? "" : p.root, - NewPositionName = p.position == null ? "" : p.position, - NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, - NewPositionType = p.posTypeName == null ? "" : p.posTypeName, - NewPositionNumber = p.posMasterNo == null ? "" : - p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", - //NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), - NewSalary = "", - AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), - Reason = p.Reason == null ? "-" : p.Reason - }) - .ToListAsync(); + var report_data = (from p in _context.PlacementAppointments + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToList() + join r in req.refIds + on p.Id.ToString() equals r.refId + orderby r.Sequence + select new + { + Education = p.EducationOld == null ? "-" : p.EducationOld, + Seq = r.Sequence.ToString().ToThaiNumber(), + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + OldOc = p.rootOld == null ? "" : p.rootOld, + OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, + OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, + OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, + OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), + OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), + NewOc = p.root == null ? "" : p.root, + NewPositionName = p.position == null ? "" : p.position, + NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, + NewPositionType = p.posTypeName == null ? "" : p.posTypeName, + NewPositionNumber = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", + NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), + AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), + Reason = p.Reason == null ? "-" : p.Reason, + RemarkHorizontal = r.RemarkHorizontal, + RemarkVertical = r.RemarkVertical, + }).ToList(); return Success(report_data); } catch @@ -1244,39 +1245,41 @@ namespace BMA.EHR.Placement.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> PostReportEmployeeAppointAttachment([FromBody] ReportPersonRequest req) + public async Task> PostReportEmployeeAppointAttachment([FromBody] ReportAttachmentRequest req) { try { - var report_data = await _context.PlacementAppointments - .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.type == "EMPLOYEE") - .Select(p => new - { - //Seq = r.Sequence.ToString().ToThaiNumber(), - //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - Seq = "", - FullName = "", - Organization = p.rootOld, - OldOrganization = p.OrganizationOld, - OldPositionName = p.positionOld, - OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld.ToThaiNumber(), - OldPositionNumber = p.PositionNumberOld == null ? null : p.PositionNumberOld.ToThaiNumber(), - OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), - NewOc = p.root == null ? "" : p.root, - NewPositionName = p.position == null ? "" : p.position, - NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName.ToThaiNumber(), - NewPositionNumber = p.posMasterNo == null ? "" : - p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", - //NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), - NewSalary = "", - Reason = p.Reason == null ? "-" : p.Reason - }) - .ToListAsync(); + var report_data = (from p in _context.PlacementAppointments + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .Where(x => x.type == "EMPLOYEE") + .ToList() + join r in req.refIds + on p.Id.ToString() equals r.refId + orderby r.Sequence + select new + { + Seq = r.Sequence.ToString().ToThaiNumber(), + FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + Organization = p.rootOld, + OldOrganization = p.OrganizationOld, + OldPositionName = p.positionOld, + OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld.ToThaiNumber(), + OldPositionNumber = p.PositionNumberOld == null ? null : p.PositionNumberOld.ToThaiNumber(), + OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + NewOc = p.root == null ? "" : p.root, + NewPositionName = p.position == null ? "" : p.position, + NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName.ToThaiNumber(), + NewPositionNumber = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", + NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), + Reason = p.Reason == null ? "-" : p.Reason, + RemarkHorizontal = r.RemarkHorizontal, + RemarkVertical = r.RemarkVertical, + }).ToList(); return Success(report_data); } catch @@ -1391,40 +1394,41 @@ namespace BMA.EHR.Placement.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> PostReportEmployeeMoveAttachment([FromBody] ReportPersonRequest req) + public async Task> PostReportEmployeeMoveAttachment([FromBody] ReportAttachmentRequest req) { try { - var report_data = await _context.PlacementAppointments - .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.type == "EMPLOYEE") - .Select(p => new - { - //Seq = r.Sequence.ToString().ToThaiNumber(), - //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - Seq = "", - FullName = "", - Organization = p.OrganizationPositionOld, - OldOrganization = p.OrganizationOld, - OldPositionName = p.positionOld, - OldPositionLevel = p.PositionLevelOld, - OldPositionNumber = p.PositionNumberOld == null ? null : p.PositionNumberOld.ToThaiNumber(), - OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), - NewOc = p.root == null ? "" : p.root, - NewPositionName = p.position == null ? "" : p.position, - NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, - NewPositionNumber = p.posMasterNo == null ? "" : - p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", - //NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), - NewSalary = "", - Reason = p.Reason == null ? "-" : p.Reason, - - }) - .ToListAsync(); + var report_data = (from p in _context.PlacementAppointments + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .Where(x => x.type == "EMPLOYEE") + .ToList() + join r in req.refIds + on p.Id.ToString() equals r.refId + orderby r.Sequence + select new + { + Seq = r.Sequence.ToString().ToThaiNumber(), + FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + Organization = p.OrganizationPositionOld, + OldOrganization = p.OrganizationOld, + OldPositionName = p.positionOld, + OldPositionLevel = p.PositionLevelOld, + OldPositionNumber = p.PositionNumberOld == null ? null : p.PositionNumberOld.ToThaiNumber(), + OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + NewOc = p.root == null ? "" : p.root, + NewPositionName = p.position == null ? "" : p.position, + NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, + NewPositionNumber = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", + NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), + Reason = p.Reason == null ? "-" : p.Reason, + RemarkHorizontal = r.RemarkHorizontal, + RemarkVertical = r.RemarkVertical, + }).ToList(); return Success(report_data); } catch diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index 45eb20eb..6cdcbc75 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -1498,44 +1498,44 @@ namespace BMA.EHR.Placement.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> PostReportRecruitAttachment([FromBody] ReportPersonRequest req) + public async Task> PostReportRecruitAttachment([FromBody] ReportAttachmentRequest req) { try { - var report_data = await _context.PlacementProfiles - .Include(x => x.Placement) - .ThenInclude(x => x.PlacementType) - .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Placement!.PlacementType!.Name != "สอบแข่งขัน") - .Where(x => x.typeCommand.Trim().ToUpper() == "APPOINTED") - .Select(p => new - { - Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" : - p.PlacementEducations.FirstOrDefault().Degree, - //Seq = r.Sequence.ToString().ToThaiNumber(), - //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), - //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - Seq = "", - CitizenId = "", - FullName = "", - Oc = p.root == null ? "" : p.root, - PositionName = p.positionName == null ? "" : p.positionName, - PositionLevel = p.posLevelName == null ? "" : p.posLevelName, - PositionType = p.posTypeName == null ? "" : p.posTypeName, - PositionNumber = p.posMasterNo == null ? "" : - p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", - Salary = p.Amount == null ? "0" : p.Amount.Value.ToNumericNoDecimalText().ToThaiNumber().ToThaiNumber(), - AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), - ExamNumber = p.ExamNumber == null ? "0" : p.ExamNumber.Value.ToString().ToThaiNumber(), - PlacementName = $"{p.Placement.Name.ToThaiNumber()} ครั้งที่ {p.Placement.Round.ToThaiNumber()}/{p.Placement.Year.ToThaiYear().ToString().ToThaiNumber()}", - RemarkHorizontal = p.RemarkHorizontal, - RemarkVertical = p.RemarkVertical, - }) - .ToListAsync(); + var report_data = (from p in _context.PlacementProfiles + .Include(x => x.Placement) + .ThenInclude(x => x.PlacementType) + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .Where(x => x.Placement!.PlacementType!.Name != "สอบแข่งขัน") + .Where(x => x.typeCommand.Trim().ToUpper() == "APPOINTED") + .ToList() + join r in req.refIds + on p.Id.ToString() equals r.refId + orderby r.Sequence + select new + { + Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" : + p.PlacementEducations.FirstOrDefault().Degree, + Seq = r.Sequence.ToString().ToThaiNumber(), + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + Oc = p.root == null ? "" : p.root, + PositionName = p.positionName == null ? "" : p.positionName, + PositionLevel = p.posLevelName == null ? "" : p.posLevelName, + PositionType = p.posTypeName == null ? "" : p.posTypeName, + PositionNumber = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", + Salary = r.Amount == null ? "0" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber().ToThaiNumber(), + AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), + ExamNumber = p.ExamNumber == null ? "0" : p.ExamNumber.Value.ToString().ToThaiNumber(), + PlacementName = $"{p.Placement.Name.ToThaiNumber()} ครั้งที่ {p.Placement.Round.ToThaiNumber()}/{p.Placement.Year.ToThaiYear().ToString().ToThaiNumber()}", + RemarkHorizontal = r.RemarkHorizontal, + RemarkVertical = r.RemarkVertical, + }).ToList(); return Success(report_data); } catch @@ -1771,44 +1771,44 @@ namespace BMA.EHR.Placement.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> PostReportCandidateAttachment([FromBody] ReportPersonRequest req) + public async Task> PostReportCandidateAttachment([FromBody] ReportAttachmentRequest req) { try { - var report_data = await _context.PlacementProfiles - .Include(x => x.Placement) - .ThenInclude(x => x.PlacementType) - .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Placement!.PlacementType!.Name != "สอบแข่งขัน") - .Where(x => x.typeCommand.Trim().ToUpper() == "APPOINTED") - .Select(p => new - { - Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" : - p.PlacementEducations.FirstOrDefault().Degree, - //Seq = r.Sequence.ToString().ToThaiNumber(), - //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), - //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - Seq = "", - CitizenId = "", - FullName = "", - Oc = p.root == null ? "" : p.root, - PositionName = p.positionName == null ? "" : p.positionName, - PositionLevel = p.posLevelName == null ? "" : p.posLevelName, - PositionType = p.posTypeName == null ? "" : p.posTypeName, - PositionNumber = p.posMasterNo == null ? "" : - p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", - Salary = p.Amount == null ? "0" : p.Amount.Value.ToNumericNoDecimalText().ToThaiNumber().ToThaiNumber(), - AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), - ExamNumber = p.ExamNumber == null ? "0" : p.ExamNumber.Value.ToString().ToThaiNumber(), - PlacementName = $"{p.Placement.Name.ToThaiNumber()} ครั้งที่ {p.Placement.Round.ToThaiNumber()}/{p.Placement.Year.ToThaiYear().ToString().ToThaiNumber()}", - RemarkHorizontal = p.RemarkHorizontal, - RemarkVertical = p.RemarkVertical, - }) - .ToListAsync(); + var report_data = (from p in _context.PlacementProfiles + .Include(x => x.Placement) + .ThenInclude(x => x.PlacementType) + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .Where(x => x.Placement!.PlacementType!.Name != "สอบแข่งขัน") + .Where(x => x.typeCommand.Trim().ToUpper() == "APPOINTED") + .ToList() + join r in req.refIds + on p.Id.ToString() equals r.refId + orderby r.Sequence + select new + { + Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" : + p.PlacementEducations.FirstOrDefault().Degree, + Seq = r.Sequence.ToString().ToThaiNumber(), + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + Oc = p.root == null ? "" : p.root, + PositionName = p.positionName == null ? "" : p.positionName, + PositionLevel = p.posLevelName == null ? "" : p.posLevelName, + PositionType = p.posTypeName == null ? "" : p.posTypeName, + PositionNumber = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", + Salary = r.Amount == null ? "0" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber().ToThaiNumber(), + AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), + ExamNumber = p.ExamNumber == null ? "0" : p.ExamNumber.Value.ToString().ToThaiNumber(), + PlacementName = $"{p.Placement.Name.ToThaiNumber()} ครั้งที่ {p.Placement.Round.ToThaiNumber()}/{p.Placement.Year.ToThaiYear().ToString().ToThaiNumber()}", + RemarkHorizontal = r.RemarkHorizontal, + RemarkVertical = r.RemarkVertical, + }).ToList(); return Success(report_data); } catch @@ -2043,55 +2043,55 @@ namespace BMA.EHR.Placement.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> PostReportAppointAttachment([FromBody] ReportPersonRequest req) + public async Task> PostReportAppointAttachment([FromBody] ReportAttachmentRequest req) { try { - var report_data = await _context.PlacementProfiles - .Include(x => x.Placement) - .ThenInclude(x => x.PlacementType) - .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Placement!.PlacementType!.Name == "แต่งตั้งข้าราชการ") - .Where(x => x.typeCommand.Trim().ToUpper() == "APPOIN") - .Select(p => new - { - Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" : - p.PlacementEducations.FirstOrDefault().Degree, - //Seq = r.Sequence.ToString().ToThaiNumber(), - //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), - //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - Seq = "", - CitizenId = "", - FullName = "", - OldOc = p.rootOld == null ? "" : p.rootOld, - Probation = "", - OldPositionName = p.positionNameOld == null ? "" : p.positionNameOld, - OldPositionLevel = p.posLevelNameOld == null ? "" : p.posLevelNameOld, - OldPositionType = p.posTypeNameOld == null ? "" : p.posTypeNameOld, - OldPositionNumber = p.posMasterNoOld == null ? "" : - p.nodeOld == "4" ? $"{p.child4ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : - p.nodeOld == "3" ? $"{p.child3ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : - p.nodeOld == "2" ? $"{p.child2ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : - p.nodeOld == "1" ? $"{p.child1ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : - p.nodeOld == "0" ? $"{p.rootShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : "", - OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + var report_data = (from p in _context.PlacementProfiles + .Include(x => x.Placement) + .ThenInclude(x => x.PlacementType) + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .Where(x => x.Placement!.PlacementType!.Name == "แต่งตั้งข้าราชการ") + .Where(x => x.typeCommand.Trim().ToUpper() == "APPOIN") + .ToList() + join r in req.refIds + on p.Id.ToString() equals r.refId + orderby r.Sequence + select new + { + Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" : + p.PlacementEducations.FirstOrDefault().Degree, + Seq = r.Sequence.ToString().ToThaiNumber(), + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + OldOc = p.rootOld == null ? "" : p.rootOld, + Probation = "", + OldPositionName = p.positionNameOld == null ? "" : p.positionNameOld, + OldPositionLevel = p.posLevelNameOld == null ? "" : p.posLevelNameOld, + OldPositionType = p.posTypeNameOld == null ? "" : p.posTypeNameOld, + OldPositionNumber = p.posMasterNoOld == null ? "" : + p.nodeOld == "4" ? $"{p.child4ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : + p.nodeOld == "3" ? $"{p.child3ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : + p.nodeOld == "2" ? $"{p.child2ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : + p.nodeOld == "1" ? $"{p.child1ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : + p.nodeOld == "0" ? $"{p.rootShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : "", + OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), - NewOc = p.root == null ? "" : p.root, - NewPositionName = p.positionName == null ? "" : p.positionName, - NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, - NewPositionType = p.posTypeName == null ? "" : p.posTypeName, - NewPositionNumber = p.posMasterNo == null ? "" : - p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", - NewSalary = p.Amount == null ? "" : p.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), - AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), - RemarkHorizontal = p.RemarkHorizontal, - RemarkVertical = p.RemarkVertical - }) - .ToListAsync(); + NewOc = p.root == null ? "" : p.root, + NewPositionName = p.positionName == null ? "" : p.positionName, + NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, + NewPositionType = p.posTypeName == null ? "" : p.posTypeName, + NewPositionNumber = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", + NewSalary = p.Amount == null ? "" : p.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), + AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), + RemarkHorizontal = r.RemarkHorizontal, + RemarkVertical = r.RemarkVertical + }).ToList(); return Success(report_data); } catch @@ -2212,51 +2212,53 @@ namespace BMA.EHR.Placement.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> PostReportMoveAttachment([FromBody] ReportPersonRequest req) + public async Task> PostReportMoveAttachment([FromBody] ReportAttachmentRequest req) { try { - var report_data = await _context.PlacementProfiles - .Include(x => x.Placement) - .ThenInclude(x => x.PlacementType) - .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Placement!.PlacementType!.Name == "แต่งตั้งข้าราชการ") - .Where(x => x.typeCommand.Trim().ToUpper() == "APPOIN") - .Select(p => new - { - Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "": - p.PlacementEducations.FirstOrDefault().Degree, - //Seq = r.Sequence.ToString().ToThaiNumber(), - //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), - //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - Seq = "", - CitizenId = "", - FullName = "", - OldOc = p.rootOld == null ? "" : p.rootOld, - OldPositionName = p.positionNameOld == null ? "" : p.positionNameOld, - OldPositionLevel = p.posLevelNameOld == null ? "" : p.posLevelNameOld, - OldPositionType = p.posTypeNameOld == null ? "" : p.posTypeNameOld, - OldPositionNumber = p.posMasterNoOld == null ? "" : - p.nodeOld == "4" ? $"{p.child4ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : - p.nodeOld == "3" ? $"{p.child3ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : - p.nodeOld == "2" ? $"{p.child2ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : - p.nodeOld == "1" ? $"{p.child1ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : - p.nodeOld == "0" ? $"{p.rootShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : "", - OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), - NewOc = p.root == null ? "" : p.root, - NewPositionName = p.positionName == null ? "" : p.positionName, - NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, - NewPositionType = p.posTypeName == null ? "" : p.posTypeName, - NewPositionNumber = p.posMasterNo == null ? "" : - p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", - NewSalary = p.Amount == null ? "" : p.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), - AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber() - }) - .ToListAsync(); + var report_data = (from p in _context.PlacementProfiles + .Include(x => x.Placement) + .ThenInclude(x => x.PlacementType) + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .Where(x => x.Placement!.PlacementType!.Name == "แต่งตั้งข้าราชการ") + .Where(x => x.typeCommand.Trim().ToUpper() == "APPOIN") + .ToList() + join r in req.refIds + on p.Id.ToString() equals r.refId + orderby r.Sequence + select new + { + Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" : + p.PlacementEducations.FirstOrDefault().Degree, + Seq = r.Sequence.ToString().ToThaiNumber(), + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + OldOc = p.rootOld == null ? "" : p.rootOld, + OldPositionName = p.positionNameOld == null ? "" : p.positionNameOld, + OldPositionLevel = p.posLevelNameOld == null ? "" : p.posLevelNameOld, + OldPositionType = p.posTypeNameOld == null ? "" : p.posTypeNameOld, + OldPositionNumber = p.posMasterNoOld == null ? "" : + p.nodeOld == "4" ? $"{p.child4ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : + p.nodeOld == "3" ? $"{p.child3ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : + p.nodeOld == "2" ? $"{p.child2ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : + p.nodeOld == "1" ? $"{p.child1ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : + p.nodeOld == "0" ? $"{p.rootShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : "", + OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + NewOc = p.root == null ? "" : p.root, + NewPositionName = p.positionName == null ? "" : p.positionName, + NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, + NewPositionType = p.posTypeName == null ? "" : p.posTypeName, + NewPositionNumber = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", + NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), + AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), + RemarkHorizontal = r.RemarkHorizontal, + RemarkVertical = r.RemarkVertical, + }).ToList(); return Success(report_data); } catch @@ -2377,51 +2379,53 @@ namespace BMA.EHR.Placement.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> PostReportSlipAttachment([FromBody] ReportPersonRequest req) + public async Task> PostReportSlipAttachment([FromBody] ReportAttachmentRequest req) { try { - var report_data = await _context.PlacementProfiles - .Include(x => x.Placement) - .ThenInclude(x => x.PlacementType) - .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Placement!.PlacementType!.Name == "เลื่อนข้าราชการ") - .Where(x => x.typeCommand.Trim().ToUpper() == "SLIP") - .Select(p => new - { - Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" : - p.PlacementEducations.FirstOrDefault().Degree, - //Seq = r.Sequence.ToString().ToThaiNumber(), - //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), - //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - Seq = "", - CitizenId = "", - FullName = "", - OldOc = p.rootOld == null ? "" : p.rootOld, - OldPositionName = p.positionNameOld == null ? "" : p.positionNameOld, - OldPositionLevel = p.posLevelNameOld == null ? "" : p.posLevelNameOld, - OldPositionType = p.posTypeNameOld == null ? "" : p.posTypeNameOld, - OldPositionNumber = p.posMasterNoOld == null ? "" : - p.nodeOld == "4" ? $"{p.child4ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : - p.nodeOld == "3" ? $"{p.child3ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : - p.nodeOld == "2" ? $"{p.child2ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : - p.nodeOld == "1" ? $"{p.child1ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : - p.nodeOld == "0" ? $"{p.rootShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : "", - OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), - NewOc = p.root == null ? "" : p.root, - NewPositionName = p.positionName == null ? "" : p.positionName, - NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, - NewPositionType = p.posTypeName == null ? "" : p.posTypeName, - NewPositionNumber = p.posMasterNo == null ? "" : - p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", - NewSalary = p.Amount == null ? "" : p.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), - AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber() - }) - .ToListAsync(); + var report_data = (from p in _context.PlacementProfiles + .Include(x => x.Placement) + .ThenInclude(x => x.PlacementType) + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .Where(x => x.Placement!.PlacementType!.Name == "เลื่อนข้าราชการ") + .Where(x => x.typeCommand.Trim().ToUpper() == "SLIP") + .ToList() + join r in req.refIds + on p.Id.ToString() equals r.refId + orderby r.Sequence + select new + { + Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" : + p.PlacementEducations.FirstOrDefault().Degree, + Seq = r.Sequence.ToString().ToThaiNumber(), + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + OldOc = p.rootOld == null ? "" : p.rootOld, + OldPositionName = p.positionNameOld == null ? "" : p.positionNameOld, + OldPositionLevel = p.posLevelNameOld == null ? "" : p.posLevelNameOld, + OldPositionType = p.posTypeNameOld == null ? "" : p.posTypeNameOld, + OldPositionNumber = p.posMasterNoOld == null ? "" : + p.nodeOld == "4" ? $"{p.child4ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : + p.nodeOld == "3" ? $"{p.child3ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : + p.nodeOld == "2" ? $"{p.child2ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : + p.nodeOld == "1" ? $"{p.child1ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : + p.nodeOld == "0" ? $"{p.rootShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : "", + OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + NewOc = p.root == null ? "" : p.root, + NewPositionName = p.positionName == null ? "" : p.positionName, + NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, + NewPositionType = p.posTypeName == null ? "" : p.posTypeName, + NewPositionNumber = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", + NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), + AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), + RemarkHorizontal = r.RemarkHorizontal, + RemarkVertical = r.RemarkVertical, + }).ToList(); return Success(report_data); } catch diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs index 555606a6..4528957d 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs @@ -109,6 +109,7 @@ namespace BMA.EHR.Placement.Service.Controllers .Select(p => new { p.Id, + p.citizenId, p.prefix, p.firstName, p.lastName, @@ -601,27 +602,29 @@ namespace BMA.EHR.Placement.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> PostReportAttachment([FromBody] ReportPersonRequest req) + public async Task> PostReportAttachment([FromBody] ReportAttachmentRequest req) { try { - var report_data = await _context.PlacementOfficers - .Where(x => req.refIds.Contains(x.Id.ToString())) - .Select(p => new - { - //Seq = r.Sequence.ToString().ToThaiNumber(), - //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), - //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - Seq = "", - CitizenId = "", - FullName = "", - PositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, - Organization = p.Organization == null ? "" : p.Organization, - StartDate = p.DateStart == null ? "" : p.DateStart.Value.ToThaiShortDate2().ToThaiNumber(), - EndDate = p.DateEnd == null ? "" : p.DateEnd.Value.ToThaiShortDate2().ToThaiNumber(), - Reason = p.Reason == null ? "" : p.Reason.ToThaiNumber() - }) - .ToListAsync(); + var report_data = (from p in _context.PlacementOfficers + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToList() + join r in req.refIds + on p.Id.ToString() equals r.refId + orderby r.Sequence + select new + { + Seq = r.Sequence.ToString().ToThaiNumber(), + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + PositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, + Organization = p.Organization == null ? "" : p.Organization, + StartDate = p.DateStart == null ? "" : p.DateStart.Value.ToThaiShortDate2().ToThaiNumber(), + EndDate = p.DateEnd == null ? "" : p.DateEnd.Value.ToThaiShortDate2().ToThaiNumber(), + Reason = p.Reason == null ? "" : p.Reason.ToThaiNumber(), + RemarkHorizontal = r.RemarkHorizontal, + RemarkVertical = r.RemarkVertical, + }).ToList(); return Success(report_data); } catch diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs index 87c72f20..a8c10381 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs @@ -913,43 +913,44 @@ namespace BMA.EHR.Placement.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> PostReportAttachment([FromBody] ReportPersonRequest req) + public async Task> PostReportAttachment([FromBody] ReportAttachmentRequest req) { try { - var report_data = await _context.PlacementReceives - .Where(x => req.refIds.Contains(x.Id.ToString())) - .Select(p => new - { - Education = p.EducationOld == null ? "-" : p.EducationOld, - //Seq = r.Sequence.ToString().ToThaiNumber(), - //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), - //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - Seq = "", - CitizenId = "", - FullName = "", - OldOc = p.OrganizationPositionOld ?? "", - OldPositionName = p.OrganizationPositionOld ?? "", - OldPositionLevel = p.PositionLevelOld ?? "", - OldPositionType = p.PositionTypeOld ?? "", - OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), - OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), - NewOc = p.root == null ? "" : p.root, - NewPositionName = p.position == null ? "" : p.position, - NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, - NewPositionType = p.posTypeName == null ? "" : p.posTypeName, - NewPositionNumber = p.posMasterNo == null ? "" : - p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : - p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", - //NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), - NewSalary = "", - AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), - Reason = p.Reason == null ? "-" : p.Reason, - }) - .ToListAsync(); + var report_data = (from p in _context.PlacementReceives + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToList() + join r in req.refIds + on p.Id.ToString() equals r.refId + orderby r.Sequence + select new + { + Education = p.EducationOld == null ? "-" : p.EducationOld, + Seq = r.Sequence.ToString().ToThaiNumber(), + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + OldOc = p.OrganizationPositionOld ?? "", + OldPositionName = p.OrganizationPositionOld ?? "", + OldPositionLevel = p.PositionLevelOld ?? "", + OldPositionType = p.PositionTypeOld ?? "", + OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), + OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + NewOc = p.root == null ? "" : p.root, + NewPositionName = p.position == null ? "" : p.position, + NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, + NewPositionType = p.posTypeName == null ? "" : p.posTypeName, + NewPositionNumber = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", + NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), + AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), + Reason = p.Reason == null ? "-" : p.Reason, + RemarkHorizontal = r.RemarkHorizontal, + RemarkVertical = r.RemarkVertical, + }).ToList(); return Success(report_data); } catch diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs index 6ea41841..0e7b2bde 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs @@ -110,6 +110,7 @@ namespace BMA.EHR.Placement.Service.Controllers .Select(p => new { p.Id, + p.citizenId, p.profileId, p.prefix, p.firstName, diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs index cc4322ea..5dda6f29 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs @@ -198,6 +198,7 @@ namespace BMA.EHR.Placement.Service.Controllers .Select(p => new { p.Id, + p.citizenId, p.profileId, p.prefix, p.firstName, @@ -791,32 +792,32 @@ namespace BMA.EHR.Placement.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> PostReportAttachment([FromBody] ReportPersonRequest req) + public async Task> PostReportAttachment([FromBody] ReportAttachmentRequest req) { try { - var report_data = await _context.PlacementTransfers - .Where(x => req.refIds.Contains(x.Id.ToString())) - .Select(p => new - { - //Seq = r.Sequence.ToString().ToThaiNumber(), - //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), - //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - Seq = "", - CitizenId = "", - FullName = "", - Organization = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, - PositionName = p.PositionOld == null ? "" : p.PositionOld, - PositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, - PositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, - PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), - Salary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), - ActiveDate = p.Date == null ? "" : p.Date.Value.ToThaiShortDate2().ToThaiNumber(), - //ReceiveOrganizationName = r.Command!.ReceiveOrganizationName ?? "", - ReceiveOrganizationName = "", - Reason = p.Reason ?? "" - }) - .ToListAsync(); + var report_data = (from p in _context.PlacementTransfers + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToList() + join r in req.refIds + on p.Id.ToString() equals r.refId + orderby r.Sequence + select new + { + Seq = r.Sequence.ToString().ToThaiNumber(), + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + Organization = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, + PositionName = p.PositionOld == null ? "" : p.PositionOld, + PositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, + PositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, + PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), + Salary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + ActiveDate = p.Date == null ? "" : p.Date.Value.ToThaiShortDate2().ToThaiNumber(), + //ReceiveOrganizationName = r.Command!.ReceiveOrganizationName ?? "", + ReceiveOrganizationName = "", + Reason = p.Reason ?? "" + }).ToList(); return Success(report_data); } catch diff --git a/BMA.EHR.Placement.Service/Requests/ReportAttachmentRequest.cs b/BMA.EHR.Placement.Service/Requests/ReportAttachmentRequest.cs index 3b5d2c59..75379027 100644 --- a/BMA.EHR.Placement.Service/Requests/ReportAttachmentRequest.cs +++ b/BMA.EHR.Placement.Service/Requests/ReportAttachmentRequest.cs @@ -9,16 +9,17 @@ namespace BMA.EHR.Placement.Service.Requests } public class ReportAttachmentRequestObj { + public string? refId { get; set; } public int? Sequence { get; set; } public string? CitizenId { get; set; } public string? Prefix { get; set; } public string? FirstName { get; set; } public string? LastName { get; set; } - public double? amount { get; set; } - public double? positionSalaryAmount { get; set; } - public double? mouthSalaryAmount { get; set; } + public double? Amount { get; set; } + public double? PositionSalaryAmount { get; set; } + public double? MouthSalaryAmount { get; set; } public string? RemarkHorizontal { get; set; } public string? RemarkVertical { get; set; } - + public int CommandYear { get; set; } } } diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementDeceasedController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementDeceasedController.cs index 1585fcac..3d365f7c 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementDeceasedController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementDeceasedController.cs @@ -118,6 +118,7 @@ namespace BMA.EHR.Retirement.Service.Controllers .Select(p => new { p.Id, + p.citizenId, p.profileId, p.prefix, p.firstName, diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs index eb0b7199..2713a01b 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs @@ -109,6 +109,7 @@ namespace BMA.EHR.Retirement.Service.Controllers .Select(p => new { p.Id, + p.citizenId, p.profileId, p.prefix, p.firstName, @@ -658,40 +659,41 @@ namespace BMA.EHR.Retirement.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> PostReportAppointAttachment([FromBody] ReportPersonRequest req) + public async Task> PostReportAppointAttachment([FromBody] ReportAttachmentRequest req) { try { - var report_data = await _context.RetirementOthers - .Where(x => req.refIds.Contains(x.Id.ToString())) - .Select(p => new - { - Education = p.EducationOld == null ? "-" : p.EducationOld, - //Seq = r.Sequence.ToString().ToThaiNumber(), - //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), - //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - Seq = "", - CitizenId = "", - FullName = "", - OldOc = p.rootOld == null ? "" : p.rootOld, - OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, - OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, - OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, - OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), - OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), - OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), - NewOc = p.rootOld == null ? "" : p.rootOld, - NewPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, - NewPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, - NewPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, - NewPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), - //NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), - NewSalary = "", - AppointDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), - LeaveDate = p.LeaveDate == null ? "" : p.LeaveDate.Value.ToThaiShortDate2().ToThaiNumber(), - Reason = p.Reason == null ? "-" : p.Reason, - }) - .ToListAsync(); + var report_data = (from p in _context.RetirementOthers + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToList() + join r in req.refIds + on p.Id.ToString() equals r.refId + orderby r.Sequence + select new + { + Education = p.EducationOld == null ? "-" : p.EducationOld, + Seq = r.Sequence.ToString().ToThaiNumber(), + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + OldOc = p.rootOld == null ? "" : p.rootOld, + OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, + OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, + OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, + OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), + OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), + NewOc = p.rootOld == null ? "" : p.rootOld, + NewPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, + NewPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, + NewPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, + NewPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), + NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), + AppointDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), + LeaveDate = p.LeaveDate == null ? "" : p.LeaveDate.Value.ToThaiShortDate2().ToThaiNumber(), + Reason = p.Reason == null ? "-" : p.Reason, + RemarkHorizontal = r.RemarkHorizontal, + RemarkVertical = r.RemarkVertical, + }).ToList(); return Success(report_data); } catch @@ -804,40 +806,42 @@ namespace BMA.EHR.Retirement.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> PostReportOutAttachment([FromBody] ReportPersonRequest req) + public async Task> PostReportOutAttachment([FromBody] ReportAttachmentRequest req) { try { - var report_data = await _context.RetirementOthers - .Where(x => req.refIds.Contains(x.Id.ToString())) - .Select(p => new - { - Education = p.EducationOld == null ? "-" : p.EducationOld, - //Seq = r.Sequence.ToString().ToThaiNumber(), - //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), - //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - Seq = "", - CitizenId = "", - FullName = "", - OldOc = p.rootOld == null ? "" : p.rootOld, - OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, - OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, - OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, - OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), - OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), - OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), - NewOc = p.rootOld == null ? "" : p.rootOld, - NewPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, - NewPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, - NewPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, - NewPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), - // NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), - AppointDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), - LeaveDate = p.LeaveDate == null ? "" : p.LeaveDate.Value.ToThaiShortDate2().ToThaiNumber(), - MilitaryDate = p.MilitaryDate == null ? "" : p.MilitaryDate.Value.ToThaiShortDate2().ToThaiNumber(), - Reason = p.Reason == null ? "-" : p.Reason, - }) - .ToListAsync(); + var report_data = (from p in _context.RetirementOthers + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToList() + join r in req.refIds + on p.Id.ToString() equals r.refId + orderby r.Sequence + select new + { + Education = p.EducationOld == null ? "-" : p.EducationOld, + Seq = r.Sequence.ToString().ToThaiNumber(), + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + OldOc = p.rootOld == null ? "" : p.rootOld, + OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, + OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, + OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, + OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), + OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), + NewOc = p.rootOld == null ? "" : p.rootOld, + NewPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, + NewPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, + NewPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, + NewPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), + NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), + AppointDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), + LeaveDate = p.LeaveDate == null ? "" : p.LeaveDate.Value.ToThaiShortDate2().ToThaiNumber(), + MilitaryDate = p.MilitaryDate == null ? "" : p.MilitaryDate.Value.ToThaiShortDate2().ToThaiNumber(), + Reason = p.Reason == null ? "-" : p.Reason, + RemarkHorizontal = r.RemarkHorizontal, + RemarkVertical = r.RemarkVertical, + }).ToList(); return Success(report_data); } catch diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs index 034e2e55..979de96d 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs @@ -108,6 +108,7 @@ namespace BMA.EHR.Retirement.Service.Controllers .Select(p => new { p.Id, + p.citizenId, p.profileId, p.prefix, p.firstName, diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs index 0691de34..0873422a 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs @@ -182,6 +182,7 @@ namespace BMA.EHR.Retirement.Service.Controllers .Select(p => new { p.Id, + p.citizenId, p.profileId, p.prefix, p.firstName, @@ -1659,28 +1660,32 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> PostReportAttachment([FromBody] ReportPersonRequest req) + public async Task> PostReportAttachment([FromBody] ReportAttachmentRequest req) { try { - var report_data = await _context.RetirementResigns - .Where(x => req.refIds.Contains(x.Id.ToString())) - .Select(p => new - { - //Seq = r.Sequence.ToString().ToThaiNumber(), - //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), - //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - PositionName = p.PositionOld ?? "", - Organization = p.OrganizationPositionOld ?? "", - PositionLevel = p.PositionLevelOld ?? "", - PositionType = p.PositionTypeOld ?? "", - PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), - ActiveDate = p.ActiveDate == null ? "" : p.ActiveDate.Value.ToThaiShortDate2().ToThaiNumber(), - Salary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), - Remark = p.Reason ?? "", - RemarkHorizontal = p.RemarkHorizontal, - }) - .ToListAsync(); + var report_data = (from p in _context.RetirementResigns + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToList() + join r in req.refIds + on p.Id.ToString() equals r.refId + orderby r.Sequence + select new + { + Seq = r.Sequence.ToString().ToThaiNumber(), + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + PositionName = p.PositionOld ?? "", + Organization = p.OrganizationPositionOld ?? "", + PositionLevel = p.PositionLevelOld ?? "", + PositionType = p.PositionTypeOld ?? "", + PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), + ActiveDate = p.ActiveDate == null ? "" : p.ActiveDate.Value.ToThaiShortDate2().ToThaiNumber(), + Salary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + Remark = p.Reason ?? "", + RemarkHorizontal = r.RemarkHorizontal, + RemarkVertical = r.RemarkVertical, + }).ToList(); return Success(report_data); } catch @@ -1793,31 +1798,32 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> PostReportEmployeeAttachment([FromBody] ReportPersonRequest req) + public async Task> PostReportEmployeeAttachment([FromBody] ReportAttachmentRequest req) { try { - var report_data = await _context.RetirementResigns - .Where(x => req.refIds.Contains(x.Id.ToString())) - .Select(p => new - { - //Seq = r.Sequence.ToString().ToThaiNumber(), - //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), - //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - Seq = "", - CitizenId = "", - FullName = "", - Organization = p.OrganizationPositionOld ?? "", - PositionName = p.PositionOld ?? "", - PositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld.ToThaiNumber(), - PositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld.ToThaiNumber(), - PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), - Salary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), - RetireDate = p.ActiveDate == null ? "" : p.ActiveDate.Value.ToThaiFullDate3().ToThaiNumber(), - //CommandYear = r.Command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(), - CommandYear = "" - }) - .ToListAsync(); + var report_data = (from p in _context.RetirementResigns + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToList() + join r in req.refIds + on p.Id.ToString() equals r.refId + orderby r.Sequence + select new + { + Seq = r.Sequence.ToString().ToThaiNumber(), + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + Organization = p.OrganizationPositionOld ?? "", + PositionName = p.PositionOld ?? "", + PositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld.ToThaiNumber(), + PositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld.ToThaiNumber(), + PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), + Salary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + RetireDate = p.ActiveDate == null ? "" : p.ActiveDate.Value.ToThaiFullDate3().ToThaiNumber(), + CommandYear = r.CommandYear.ToThaiYear().ToString().ToThaiNumber(), + RemarkHorizontal = r.RemarkHorizontal, + RemarkVertical = r.RemarkVertical, + }).ToList(); return Success(report_data); } catch @@ -1904,31 +1910,32 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> PostReportLeaveCancelAttachment([FromBody] ReportPersonRequest req) + public async Task> PostReportLeaveCancelAttachment([FromBody] ReportAttachmentRequest req) { try { - var report_data = await _context.RetirementResigns - .Where(x => req.refIds.Contains(x.Id.ToString())) - .Select(p => new - { - //Seq = r.Sequence.ToString().ToThaiNumber(), - //CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), - //FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - Seq = "", - CitizenId = "", - FullName = "", - PositionName = p.PositionOld ?? "", - Organization = p.OrganizationPositionOld ?? "", - PositionLevel = p.PositionLevelOld ?? "", - PositionType = p.PositionTypeOld ?? "", - PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), - ActiveDate = p.ActiveDate == null ? "" : p.ActiveDate.Value.ToThaiShortDate2().ToThaiNumber(), - Salary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), - Remark = p.Reason ?? "", - RemarkHorizontal = p.RemarkHorizontal, - }) - .ToListAsync(); + var report_data = (from p in _context.RetirementResigns + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToList() + join r in req.refIds + on p.Id.ToString() equals r.refId + orderby r.Sequence + select new + { + Seq = r.Sequence.ToString().ToThaiNumber(), + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + PositionName = p.PositionOld ?? "", + Organization = p.OrganizationPositionOld ?? "", + PositionLevel = p.PositionLevelOld ?? "", + PositionType = p.PositionTypeOld ?? "", + PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), + ActiveDate = p.ActiveDate == null ? "" : p.ActiveDate.Value.ToThaiShortDate2().ToThaiNumber(), + Salary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), + Remark = p.Reason ?? "", + RemarkHorizontal = r.RemarkHorizontal, + RemarkVertical = r.RemarkVertical, + }).ToList(); return Success(report_data); } catch diff --git a/BMA.EHR.Retirement.Service/Requests/ReportAttachmentRequest.cs b/BMA.EHR.Retirement.Service/Requests/ReportAttachmentRequest.cs new file mode 100644 index 00000000..2e71ceda --- /dev/null +++ b/BMA.EHR.Retirement.Service/Requests/ReportAttachmentRequest.cs @@ -0,0 +1,25 @@ +using BMA.EHR.Domain.Models.MetaData; +using Microsoft.EntityFrameworkCore; + +namespace BMA.EHR.Retirement.Service.Requests +{ + public class ReportAttachmentRequest + { + public ReportAttachmentRequestObj[] refIds { get; set; } + } + public class ReportAttachmentRequestObj + { + public string? refId { get; set; } + public int? Sequence { get; set; } + public string? CitizenId { get; set; } + public string? Prefix { get; set; } + public string? FirstName { get; set; } + public string? LastName { get; set; } + public double? Amount { get; set; } + public double? PositionSalaryAmount { get; set; } + public double? MouthSalaryAmount { get; set; } + public string? RemarkHorizontal { get; set; } + public string? RemarkVertical { get; set; } + public int CommandYear { get; set; } + } +} From 1290da7211b41b018693636c0e20fc9e25be7d8e Mon Sep 17 00:00:00 2001 From: kittapath Date: Fri, 4 Oct 2024 15:36:34 +0700 Subject: [PATCH 27/42] =?UTF-8?q?=E0=B8=AD=E0=B8=AD=E0=B8=81=E0=B8=84?= =?UTF-8?q?=E0=B8=B3=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/OrderController.cs | 1094 +--------------- .../Controllers/DisciplineResultController.cs | 1164 +++++++++++++++++ .../Requests/ReportAttachmentRequest.cs | 25 + .../Requests/ReportExecuteRequest.cs | 21 + .../Requests/ReportPersonRequest.cs | 10 + .../PlacementAppointmentController.cs | 496 +++---- .../Controllers/PlacementController.cs | 307 ++--- .../Controllers/PlacementOfficerController.cs | 76 +- .../Controllers/PlacementReceiveController.cs | 103 +- .../PlacementRepatriationController.cs | 76 +- .../PlacementTransferController.cs | 76 +- .../Controllers/RetirementOtherController.cs | 188 ++- .../Controllers/RetirementOutController.cs | 93 +- .../Controllers/RetirementResignController.cs | 254 ++-- 14 files changed, 1979 insertions(+), 2004 deletions(-) create mode 100644 BMA.EHR.Discipline.Service/Requests/ReportAttachmentRequest.cs create mode 100644 BMA.EHR.Discipline.Service/Requests/ReportExecuteRequest.cs create mode 100644 BMA.EHR.Discipline.Service/Requests/ReportPersonRequest.cs diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs index 6e8a2c35..aec3d5f0 100644 --- a/BMA.EHR.Command.Service/Controllers/OrderController.cs +++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs @@ -6647,7 +6647,7 @@ namespace BMA.EHR.Command.Service.Controllers } /// - /// ออกคำสั่ง C-PM-11 + /// ออกคำสั่ง C-PM-11 คำสั่งให้ข้าราชการที่มีผลการทดลองปฏิบัติหน้าที่ราชการไม่ต่ำกว่ามาตรฐานที่กำหนดรับราชการต่อไป /// /// /// @@ -6750,7 +6750,7 @@ namespace BMA.EHR.Command.Service.Controllers } /// - /// ออกคำสั่ง C-PM-12 + /// ออกคำสั่ง C-PM-12 คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด /// /// /// @@ -6803,7 +6803,7 @@ namespace BMA.EHR.Command.Service.Controllers } /// - /// ออกคำสั่ง C-PM-19 + /// ออกคำสั่ง C-PM-19 คำสั่งปลดออกจากราชการ /// /// /// @@ -6875,7 +6875,7 @@ namespace BMA.EHR.Command.Service.Controllers } /// - /// ออกคำสั่ง C-PM-20 + /// ออกคำสั่ง C-PM-20 คำสั่งไล่ออกจากราชการ /// /// /// @@ -6989,7 +6989,7 @@ namespace BMA.EHR.Command.Service.Controllers } /// - /// ออกคำสั่ง C-PM-21 + /// ออกคำสั่ง C-PM-21 คำสั่งแต่งตั้งลูกจ้างชั่วคราวเป็นลูกจ้างประจำ /// /// /// @@ -7020,1076 +7020,6 @@ namespace BMA.EHR.Command.Service.Controllers return Success(); } - /// - /// ส่งรายชื่อออกคำสั่ง C-PM-25 - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command25/report")] - public async Task> PostReportCommand25([FromBody] ReportPersonRequest req_) - { - try - { - var resultData = new List(); - var baseAPI = _configuration["API"]; - - foreach (var id in req_.refIds) - { - var apiUrl = $"{baseAPI}/discipline/result/report/stop/{id}"; - var commandType = await _context.Set() - .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-25") - .FirstOrDefaultAsync(); - var response = new PassDisciplineResponse(); - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var res = await client.SendAsync(req); - var result = await res.Content.ReadAsStringAsync(); - - response = JsonConvert.DeserializeObject(result); - - var seq = 1; - foreach (var d in response!.result) - { - if (commandType == null || commandType.Id != d.commandId) - continue; - var _baseAPI = _configuration["API"]; - var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; - using (var _client = new HttpClient()) - { - _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); - var _res = await _client.SendAsync(_req); - var _result = await _res.Content.ReadAsStringAsync(); - - var org = JsonConvert.DeserializeObject(_result); - - if (org == null || org.result == null) - continue; - - var receiver = new CommandReceiver - { - Sequence = seq, - CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, - Prefix = org.result.prefix == null ? "" : org.result.prefix, - FirstName = org.result.firstName == null ? "" : org.result.firstName, - LastName = org.result.lastName == null ? "" : org.result.lastName, - RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), - RefDisciplineId = d.id, - Amount = 0, - }; - seq++; - resultData.Add(receiver); - } - } - } - } - return Success(); - } - catch - { - throw; - } - } - - /// - /// เอกสารแนบท้าย C-PM-25 - /// - /// Record Id ของคำสั่ง - /// pdf, docx หรือ xlsx - /// - /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command25/report/attachment")] - [AllowAnonymous] - [ProducesResponseType(StatusCodes.Status200OK)] - [ProducesResponseType(StatusCodes.Status401Unauthorized)] - [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> PostReportCommand25Attachment([FromBody] ReportAttachmentRequest req) - { - try - { - foreach (var d in req.refIds) - { - var apiUrl = $"{_configuration["API"]}/discipline/result/report/find/{d.refId}"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var _res = await client.SendAsync(_req); - var _result = await _res.Content.ReadAsStringAsync(); - - var org = JsonConvert.DeserializeObject(_result); - - if (org == null || org.result == null) - continue; - var receiver = new CommandType23Response - { - fullName = $"{d.Prefix}{d.FirstName} {d.LastName}", - positionname = org.result.position, - positionno = org.result.posNo == null ? null : org.result.posNo.ToThaiNumber(), - organizationname = org.result.organization, - salary = org.result.salary == null ? null : org.result.salary.Value.ToNumericNoDecimalText().ToString(), - }; - - return Success(receiver); - } - } - return null; - } - catch - { - throw; - } - } - - /// - /// ออกคำสั่ง C-PM-25 - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command25/report/excecute")] - public async Task> PostReportCommand25Execute([FromBody] ReportExecuteRequest req) - { - var data = req.refIds.Select(x => new - { - Id = x.refId, - CommandAffectDate = x.commandAffectDate, - CommandNo = x.commandNo, - CommandYear = x.commandYear.ToThaiYear(), - Detail = "คำสั่งลงโทษ พักจากราชการ" - }); - - var baseAPI = _configuration["API"]; - var apiUrl = $"{baseAPI}/discipline/result/report/stop/resume"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); - var result = await res.Content.ReadAsStringAsync(); - } - foreach (var recv in req.refIds) - { - var apiUrl2 = $"{baseAPI}/org/profile/command25/{recv.refId}"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _res = await client.PostAsJsonAsync(apiUrl2, new - { - profileId = recv.refId, - date = recv.commandAffectDate, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - salaryRef = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - return Success(); - } - - /// - /// ส่งรายชื่อออกคำสั่ง C-PM-26 - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command26/report")] - public async Task> PostReportCommand26([FromBody] ReportPersonRequest req_) - { - try - { - var resultData = new List(); - var baseAPI = _configuration["API"]; - - foreach (var id in req_.refIds) - { - var apiUrl = $"{baseAPI}/discipline/result/report/stop/{id}"; - - var commandType = await _context.Set() - .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-26") - .FirstOrDefaultAsync(); - var response = new PassDisciplineResponse(); - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var res = await client.SendAsync(req); - var result = await res.Content.ReadAsStringAsync(); - - response = JsonConvert.DeserializeObject(result); - - var seq = 1; - foreach (var d in response!.result) - { - if (commandType == null || commandType.Id != d.commandId) - continue; - var _baseAPI = _configuration["API"]; - var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; - using (var _client = new HttpClient()) - { - _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); - var _res = await _client.SendAsync(_req); - var _result = await _res.Content.ReadAsStringAsync(); - - var org = JsonConvert.DeserializeObject(_result); - - if (org == null || org.result == null) - continue; - - var receiver = new CommandReceiver - { - Sequence = seq, - CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, - Prefix = org.result.prefix == null ? "" : org.result.prefix, - FirstName = org.result.firstName == null ? "" : org.result.firstName, - LastName = org.result.lastName == null ? "" : org.result.lastName, - RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), - RefDisciplineId = d.id, - Amount = 0, - }; - seq++; - resultData.Add(receiver); - } - } - } - } - return Success(); - } - catch - { - throw; - } - } - - /// - /// ออกคำสั่ง C-PM-26 - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command26/report/excecute")] - public async Task> PostReportCommand26Execute([FromBody] ReportExecuteRequest req) - { - var data = req.refIds.Select(x => new - { - Id = x.refId, - CommandAffectDate = x.commandAffectDate, - CommandNo = x.commandNo, - CommandYear = x.commandYear.ToThaiYear(), - Detail = "คำสั่งลงโทษ ให้ออกจากราชการไว้ก่อน" - }); - - var baseAPI = _configuration["API"]; - var apiUrl = $"{baseAPI}/discipline/result/report/stop/resume"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); - var result = await res.Content.ReadAsStringAsync(); - } - foreach (var recv in req.refIds) - { - var apiUrl2 = $"{baseAPI}/org/profile/command26/{recv.refId}"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _res = await client.PostAsJsonAsync(apiUrl2, new - { - profileId = recv.refId, - date = recv.commandAffectDate, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - salaryRef = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - return Success(); - } - - /// - /// ส่งรายชื่อออกคำสั่ง C-PM-27 - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command27/report")] - public async Task> PostReportCommand27([FromBody] ReportPersonRequest req_) - { - try - { - var resultData = new List(); - var baseAPI = _configuration["API"]; - - foreach (var id in req_.refIds) - { - var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}"; - - var commandType = await _context.Set() - .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-27") - .FirstOrDefaultAsync(); - var response = new PassDisciplineResponse(); - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var res = await client.SendAsync(req); - var result = await res.Content.ReadAsStringAsync(); - - response = JsonConvert.DeserializeObject(result); - - var seq = 1; - foreach (var d in response!.result) - { - if (commandType == null || commandType.Id != d.commandId) - continue; - var _baseAPI = _configuration["API"]; - var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; - using (var _client = new HttpClient()) - { - _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); - var _res = await _client.SendAsync(_req); - var _result = await _res.Content.ReadAsStringAsync(); - - var org = JsonConvert.DeserializeObject(_result); - - if (org == null || org.result == null) - continue; - - var receiver = new CommandReceiver - { - Sequence = seq, - CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, - Prefix = org.result.prefix == null ? "" : org.result.prefix, - FirstName = org.result.firstName == null ? "" : org.result.firstName, - LastName = org.result.lastName == null ? "" : org.result.lastName, - RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), - RefDisciplineId = d.id, - Amount = 0, - }; - seq++; - resultData.Add(receiver); - } - } - } - } - return Success(); - } - catch - { - throw; - } - } - - /// - /// ออกคำสั่ง C-PM-27 - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command27/report/excecute")] - public async Task> PostReportCommand27Execute([FromBody] ReportExecuteRequest req) - { - var data = req.refIds.Select(x => new - { - Id = x.refId, - CommandAffectDate = x.commandAffectDate, - CommandNo = x.commandNo, - CommandYear = x.commandYear.ToThaiYear(), - Detail = "คำสั่งลงโทษ ลงโทษ ภาคทัณฑ์" - }); - - var baseAPI = _configuration["API"]; - var apiUrl = $"{baseAPI}/discipline/result/report/up/resume"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); - var result = await res.Content.ReadAsStringAsync(); - } - foreach (var recv in req.refIds) - { - var apiUrl2 = $"{baseAPI}/org/profile/command27/{recv.refId}"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _res = await client.PostAsJsonAsync(apiUrl2, new - { - profileId = recv.refId, - date = recv.commandAffectDate, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - salaryRef = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - return Success(); - } - - /// - /// ส่งรายชื่อออกคำสั่ง C-PM-28 - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command28/report")] - public async Task> PostReportCommand28([FromBody] ReportPersonRequest req_) - { - try - { - var resultData = new List(); - var baseAPI = _configuration["API"]; - - foreach (var id in req_.refIds) - { - var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}"; - - var commandType = await _context.Set() - .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-28") - .FirstOrDefaultAsync(); - var response = new PassDisciplineResponse(); - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var res = await client.SendAsync(req); - var result = await res.Content.ReadAsStringAsync(); - - response = JsonConvert.DeserializeObject(result); - - var seq = 1; - foreach (var d in response!.result) - { - if (commandType == null || commandType.Id != d.commandId) - continue; - var _baseAPI = _configuration["API"]; - var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; - using (var _client = new HttpClient()) - { - _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); - var _res = await _client.SendAsync(_req); - var _result = await _res.Content.ReadAsStringAsync(); - - var org = JsonConvert.DeserializeObject(_result); - - if (org == null || org.result == null) - continue; - - var receiver = new CommandReceiver - { - Sequence = seq, - CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, - Prefix = org.result.prefix == null ? "" : org.result.prefix, - FirstName = org.result.firstName == null ? "" : org.result.firstName, - LastName = org.result.lastName == null ? "" : org.result.lastName, - RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), - RefDisciplineId = d.id, - Amount = 0, - }; - seq++; - resultData.Add(receiver); - } - } - } - } - return Success(); - } - catch - { - throw; - } - } - - /// - /// ออกคำสั่ง C-PM-28 - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command28/report/excecute")] - public async Task> PostReportCommand28Execute([FromBody] ReportExecuteRequest req) - { - var data = req.refIds.Select(x => new - { - Id = x.refId, - CommandAffectDate = x.commandAffectDate, - CommandNo = x.commandNo, - CommandYear = x.commandYear.ToThaiYear(), - Detail = "คำสั่งลงโทษ ตัดเงินเดือน" - }); - - var baseAPI = _configuration["API"]; - var apiUrl = $"{baseAPI}/discipline/result/report/up/resume"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); - var result = await res.Content.ReadAsStringAsync(); - } - foreach (var recv in req.refIds) - { - var apiUrl2 = $"{baseAPI}/org/profile/command28/{recv.refId}"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _res = await client.PostAsJsonAsync(apiUrl2, new - { - profileId = recv.refId, - date = recv.commandAffectDate, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - salaryRef = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - return Success(); - } - - /// - /// ส่งรายชื่อออกคำสั่ง C-PM-29 - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command29/report")] - public async Task> PostReportCommand29([FromBody] ReportPersonRequest req_) - { - try - { - var resultData = new List(); - var baseAPI = _configuration["API"]; - - foreach (var id in req_.refIds) - { - var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}"; - - var commandType = await _context.Set() - .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-29") - .FirstOrDefaultAsync(); - var response = new PassDisciplineResponse(); - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var res = await client.SendAsync(req); - var result = await res.Content.ReadAsStringAsync(); - - response = JsonConvert.DeserializeObject(result); - - var seq = 1; - foreach (var d in response!.result) - { - if (commandType == null || commandType.Id != d.commandId) - continue; - var _baseAPI = _configuration["API"]; - var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; - using (var _client = new HttpClient()) - { - _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); - var _res = await _client.SendAsync(_req); - var _result = await _res.Content.ReadAsStringAsync(); - - var org = JsonConvert.DeserializeObject(_result); - - if (org == null || org.result == null) - continue; - - var receiver = new CommandReceiver - { - Sequence = seq, - CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, - Prefix = org.result.prefix == null ? "" : org.result.prefix, - FirstName = org.result.firstName == null ? "" : org.result.firstName, - LastName = org.result.lastName == null ? "" : org.result.lastName, - RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), - RefDisciplineId = d.id, - Amount = 0, - }; - seq++; - resultData.Add(receiver); - } - } - } - } - return Success(); - } - catch - { - throw; - } - } - - /// - /// ออกคำสั่ง C-PM-29 - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command29/report/excecute")] - public async Task> PostReportCommand29Execute([FromBody] ReportExecuteRequest req) - { - var data = req.refIds.Select(x => new - { - Id = x.refId, - CommandAffectDate = x.commandAffectDate, - CommandNo = x.commandNo, - CommandYear = x.commandYear.ToThaiYear(), - Detail = "คำสั่งลงโทษ ลดขั้นเงินเดือน" - }); - - var baseAPI = _configuration["API"]; - var apiUrl = $"{baseAPI}/discipline/result/report/up/resume"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); - var result = await res.Content.ReadAsStringAsync(); - } - foreach (var recv in req.refIds) - { - var apiUrl2 = $"{baseAPI}/org/profile/command29/{recv.refId}"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _res = await client.PostAsJsonAsync(apiUrl2, new - { - profileId = recv.refId, - date = recv.commandAffectDate, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - salaryRef = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - return Success(); - } - - /// - /// ส่งรายชื่อออกคำสั่ง C-PM-30 - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command30/report")] - public async Task> PostReportCommand30([FromBody] ReportPersonRequest req_) - { - try - { - var resultData = new List(); - var baseAPI = _configuration["API"]; - - foreach (var id in req_.refIds) - { - var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}"; - - var commandType = await _context.Set() - .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-30") - .FirstOrDefaultAsync(); - var response = new PassDisciplineResponse(); - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var res = await client.SendAsync(req); - var result = await res.Content.ReadAsStringAsync(); - - response = JsonConvert.DeserializeObject(result); - - var seq = 1; - foreach (var d in response!.result) - { - if (commandType == null || commandType.Id != d.commandId) - continue; - var _baseAPI = _configuration["API"]; - var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; - using (var _client = new HttpClient()) - { - _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); - var _res = await _client.SendAsync(_req); - var _result = await _res.Content.ReadAsStringAsync(); - - var org = JsonConvert.DeserializeObject(_result); - - if (org == null || org.result == null) - continue; - - var receiver = new CommandReceiver - { - Sequence = seq, - CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, - Prefix = org.result.prefix == null ? "" : org.result.prefix, - FirstName = org.result.firstName == null ? "" : org.result.firstName, - LastName = org.result.lastName == null ? "" : org.result.lastName, - RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), - RefDisciplineId = d.id, - Amount = 0, - }; - seq++; - resultData.Add(receiver); - } - } - } - } - return Success(); - } - catch - { - throw; - } - } - - /// - /// ออกคำสั่ง C-PM-30 - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command30/report/excecute")] - public async Task> PostReportCommand30Execute([FromBody] ReportExecuteRequest req) - { - var data = req.refIds.Select(x => new - { - Id = x.refId, - CommandAffectDate = x.commandAffectDate, - CommandNo = x.commandNo, - CommandYear = x.commandYear.ToThaiYear(), - Detail = "คำสั่งเพิ่มโทษ" - }); - - var baseAPI = _configuration["API"]; - var apiUrl = $"{baseAPI}/discipline/result/report/up/resume"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); - var result = await res.Content.ReadAsStringAsync(); - } - foreach (var recv in req.refIds) - { - var apiUrl2 = $"{baseAPI}/org/profile/command30/{recv.refId}"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _res = await client.PostAsJsonAsync(apiUrl2, new - { - profileId = recv.refId, - date = recv.commandAffectDate, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - salaryRef = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - return Success(); - } - - /// - /// ส่งรายชื่อออกคำสั่ง C-PM-31 - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command31/report")] - public async Task> PostReportCommand31([FromBody] ReportPersonRequest req_) - { - try - { - var resultData = new List(); - var baseAPI = _configuration["API"]; - - foreach (var id in req_.refIds) - { - var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}"; - - var commandType = await _context.Set() - .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-31") - .FirstOrDefaultAsync(); - var response = new PassDisciplineResponse(); - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var res = await client.SendAsync(req); - var result = await res.Content.ReadAsStringAsync(); - - response = JsonConvert.DeserializeObject(result); - - var seq = 1; - foreach (var d in response!.result) - { - if (commandType == null || commandType.Id != d.commandId) - continue; - var _baseAPI = _configuration["API"]; - var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; - using (var _client = new HttpClient()) - { - _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); - var _res = await _client.SendAsync(_req); - var _result = await _res.Content.ReadAsStringAsync(); - - var org = JsonConvert.DeserializeObject(_result); - - if (org == null || org.result == null) - continue; - - var receiver = new CommandReceiver - { - Sequence = seq, - CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, - Prefix = org.result.prefix == null ? "" : org.result.prefix, - FirstName = org.result.firstName == null ? "" : org.result.firstName, - LastName = org.result.lastName == null ? "" : org.result.lastName, - RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), - RefDisciplineId = d.id, - Amount = 0, - }; - seq++; - resultData.Add(receiver); - } - } - } - } - return Success(); - } - catch - { - throw; - } - } - - /// - /// ออกคำสั่ง C-PM-31 - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command31/report/excecute")] - public async Task> PostReportCommand31Execute([FromBody] ReportExecuteRequest req) - { - var data = req.refIds.Select(x => new - { - Id = x.refId, - CommandAffectDate = x.commandAffectDate, - CommandNo = x.commandNo, - CommandYear = x.commandYear.ToThaiYear(), - Detail = "คำสั่งงดโทษ" - }); - - var baseAPI = _configuration["API"]; - var apiUrl = $"{baseAPI}/discipline/result/report/up/resume"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); - var result = await res.Content.ReadAsStringAsync(); - } - foreach (var recv in req.refIds) - { - var apiUrl2 = $"{baseAPI}/org/profile/command31/{recv.refId}"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _res = await client.PostAsJsonAsync(apiUrl2, new - { - profileId = recv.refId, - date = recv.commandAffectDate, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - salaryRef = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - return Success(); - } - - /// - /// ส่งรายชื่อออกคำสั่ง C-PM-32 - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command32/report")] - public async Task> PostReportCommand32([FromBody] ReportPersonRequest req_) - { - try - { - var resultData = new List(); - var baseAPI = _configuration["API"]; - - foreach (var id in req_.refIds) - { - var apiUrl = $"{baseAPI}/discipline/result/report/reject/{id}"; - - var response = new PassDisciplineResponse(); - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var res = await client.SendAsync(req); - var result = await res.Content.ReadAsStringAsync(); - - response = JsonConvert.DeserializeObject(result); - - var seq = 1; - foreach (var d in response!.result) - { - var _baseAPI = _configuration["API"]; - var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; - using (var _client = new HttpClient()) - { - _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); - var _res = await _client.SendAsync(_req); - var _result = await _res.Content.ReadAsStringAsync(); - - var org = JsonConvert.DeserializeObject(_result); - - if (org == null || org.result == null) - continue; - - var receiver = new CommandReceiver - { - Sequence = seq, - CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, - Prefix = org.result.prefix == null ? "" : org.result.prefix, - FirstName = org.result.firstName == null ? "" : org.result.firstName, - LastName = org.result.lastName == null ? "" : org.result.lastName, - RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), - RefDisciplineId = d.id, - Amount = 0, - }; - seq++; - resultData.Add(receiver); - } - } - } - } - return Success(); - } - catch - { - throw; - } - } - - /// - /// ออกคำสั่ง C-PM-32 - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command32/report/excecute")] - public async Task> PostReportCommand32Execute([FromBody] ReportExecuteRequest req) - { - var data = req.refIds.Select(x => new - { - Id = x.refId, - CommandAffectDate = x.commandAffectDate, - CommandNo = x.commandNo, - CommandYear = x.commandYear.ToThaiYear(), - Detail = "คำสั่งยุติเรื่อง" - }); - - var baseAPI = _configuration["API"]; - var apiUrl = $"{baseAPI}/discipline/result/report/reject/resume"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); - var result = await res.Content.ReadAsStringAsync(); - } - foreach (var recv in req.refIds) - { - var apiUrl2 = $"{baseAPI}/org/profile/command32/{recv.refId}"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _res = await client.PostAsJsonAsync(apiUrl2, new - { - profileId = recv.refId, - date = recv.commandAffectDate, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - salaryRef = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - return Success(); - } - /// /// ส่งรายชื่อออกคำสั่ง C-PM-33 /// @@ -8149,7 +7079,7 @@ namespace BMA.EHR.Command.Service.Controllers } /// - /// ออกคำสั่ง C-PM-33 + /// ออกคำสั่ง C-PM-33 เลื่อนเงินเดือนและให้ข้าราชการกรุงเทพมหานครสามัญ ได้รับเงินเดือนสูงกว่าขั้นสูงของตำแหน่งที่ได้รับแต่งตั้ง /// /// /// @@ -8237,7 +7167,7 @@ namespace BMA.EHR.Command.Service.Controllers } /// - /// ออกคำสั่ง C-PM-34 + /// ออกคำสั่ง C-PM-34 ให้ข้าราชการกรุงเทพมหานครสามัญได้รับค่าตอบแทนพิเศษ /// /// /// @@ -8325,7 +7255,7 @@ namespace BMA.EHR.Command.Service.Controllers } /// - /// ออกคำสั่ง C-PM-35 + /// ออกคำสั่ง C-PM-35 เลื่อนเงินเดือนและให้ข้าราชการกรุงเทพมหานครสามัญที่เกษียณอายุราชการ ในสิ้นปีงบประมาณ พ.ศ.……… ได้รับเงินเดือนสูงกว่าขั้นสูงของตำแหน่งที่ได้รับแต่งตั้ง /// /// /// @@ -8413,7 +7343,7 @@ namespace BMA.EHR.Command.Service.Controllers } /// - /// ออกคำสั่ง C-PM-36 + /// ออกคำสั่ง C-PM-36 เลื่อนขั้นค่าจ้างและให้ลูกจ้างประจำกรุงเทพมหานครได้รับอัตราค่าจ้างสูงกว่าอัตราค่าจ้างขั้นสูงของตำแหน่งที่ได้รับแต่งตั้งในแต่ละระดับ /// /// /// @@ -8501,7 +7431,7 @@ namespace BMA.EHR.Command.Service.Controllers } /// - /// ออกคำสั่ง C-PM-37 + /// ออกคำสั่ง C-PM-37 ให้ลูกจ้างประจำกรุงเทพมหานครได้รับค่าตอบแทนพิเศษ /// /// /// @@ -8588,7 +7518,7 @@ namespace BMA.EHR.Command.Service.Controllers } /// - /// ออกคำสั่ง C-PM-38 + /// ออกคำสั่ง C-PM-38 แต่งตั้งข้าราชการให้ดำรงตำแหน่ง /// /// /// @@ -8718,7 +7648,7 @@ namespace BMA.EHR.Command.Service.Controllers } /// - /// ออกคำสั่ง C-PM-40 + /// ออกคำสั่ง C-PM-40 คำสั่งให้ข้าราชการรักษาการในตำแหน่ง /// /// /// diff --git a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs index 0210a48a..2363f19f 100644 --- a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs +++ b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs @@ -1,6 +1,7 @@ using BMA.EHR.Application.Repositories; using BMA.EHR.Application.Repositories.MessageQueue; using BMA.EHR.Discipline.Service.Requests; +using BMA.EHR.Domain.Extensions; using BMA.EHR.Domain.Common; using BMA.EHR.Domain.Models.Commands.Core; using BMA.EHR.Domain.Models.Discipline; @@ -738,5 +739,1168 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers return Success(data1); } + + + + + + + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-25 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command25/report")] + public async Task> PostReportCommand25([FromBody] ReportPersonRequest req_) + { + try + { + var resultData = new List(); + var baseAPI = _configuration["API"]; + + foreach (var id in req_.refIds) + { + var apiUrl = $"{baseAPI}/discipline/result/report/stop/{id}"; + var commandType = await _context.Set() + .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-25") + .FirstOrDefaultAsync(); + var response = new PassDisciplineResponse(); + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var res = await client.SendAsync(req); + var result = await res.Content.ReadAsStringAsync(); + + response = JsonConvert.DeserializeObject(result); + + var seq = 1; + foreach (var d in response!.result) + { + if (commandType == null || commandType.Id != d.commandId) + continue; + var _baseAPI = _configuration["API"]; + var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; + using (var _client = new HttpClient()) + { + _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); + var _res = await _client.SendAsync(_req); + var _result = await _res.Content.ReadAsStringAsync(); + + var org = JsonConvert.DeserializeObject(_result); + + if (org == null || org.result == null) + continue; + + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, + Prefix = org.result.prefix == null ? "" : org.result.prefix, + FirstName = org.result.firstName == null ? "" : org.result.firstName, + LastName = org.result.lastName == null ? "" : org.result.lastName, + RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), + RefDisciplineId = d.id, + Amount = 0, + }; + seq++; + resultData.Add(receiver); + } + } + } + } + return Success(); + } + catch + { + throw; + } + } + + /// + /// เอกสารแนบท้าย C-PM-25 + /// + /// Record Id ของคำสั่ง + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command25/report/attachment")] + [AllowAnonymous] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> PostReportCommand25Attachment([FromBody] ReportAttachmentRequest req) + { + try + { + foreach (var d in req.refIds) + { + var apiUrl = $"{_configuration["API"]}/discipline/result/report/find/{d.refId}"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var _res = await client.SendAsync(_req); + var _result = await _res.Content.ReadAsStringAsync(); + + var org = JsonConvert.DeserializeObject(_result); + + if (org == null || org.result == null) + continue; + var receiver = new CommandType23Response + { + fullName = $"{d.Prefix}{d.FirstName} {d.LastName}", + positionname = org.result.position, + positionno = org.result.posNo == null ? null : org.result.posNo.ToThaiNumber(), + organizationname = org.result.organization, + salary = org.result.salary == null ? null : org.result.salary.Value.ToNumericNoDecimalText().ToString(), + }; + + return Success(receiver); + } + } + return null; + } + catch + { + throw; + } + } + + /// + /// ออกคำสั่ง C-PM-25 คำสั่งพักจากราชการ + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command25/report/excecute")] + public async Task> PostReportCommand25Execute([FromBody] ReportExecuteRequest req) + { + var data = await _context.DisciplineReport_Profiles + .Include(x => x.DisciplineDisciplinary) + .Where(x => x.Status == "REPORT") + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + var resultData = (from p in data + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + profileId = p.PersonId, + date = r.commandAffectDate, + refCommandNo = $"{r.commandNo}/{r.commandYear}", + salaryRef = r.templateDoc, + isLeave = true, + leaveReason = "ได้รับโทษทางวินัย พักจากราชการ", + dateLeave = r.commandAffectDate, + refCommandDate = DateTime.Now, + detail = p.DisciplineDisciplinary.Title, + level = p.DisciplineDisciplinary.DisciplinaryFaultLevel, + unStigma = "คำสั่งลงโทษ พักจากราชการ", + }).ToList(); + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new + { + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) + { + data.ForEach(profile => profile.Status = "DONE"); + await _context.SaveChangesAsync(); + } + } + return Success(); + } + + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-26 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command26/report")] + public async Task> PostReportCommand26([FromBody] ReportPersonRequest req_) + { + try + { + var resultData = new List(); + var baseAPI = _configuration["API"]; + + foreach (var id in req_.refIds) + { + var apiUrl = $"{baseAPI}/discipline/result/report/stop/{id}"; + + var commandType = await _context.Set() + .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-26") + .FirstOrDefaultAsync(); + var response = new PassDisciplineResponse(); + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var res = await client.SendAsync(req); + var result = await res.Content.ReadAsStringAsync(); + + response = JsonConvert.DeserializeObject(result); + + var seq = 1; + foreach (var d in response!.result) + { + if (commandType == null || commandType.Id != d.commandId) + continue; + var _baseAPI = _configuration["API"]; + var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; + using (var _client = new HttpClient()) + { + _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); + var _res = await _client.SendAsync(_req); + var _result = await _res.Content.ReadAsStringAsync(); + + var org = JsonConvert.DeserializeObject(_result); + + if (org == null || org.result == null) + continue; + + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, + Prefix = org.result.prefix == null ? "" : org.result.prefix, + FirstName = org.result.firstName == null ? "" : org.result.firstName, + LastName = org.result.lastName == null ? "" : org.result.lastName, + RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), + RefDisciplineId = d.id, + Amount = 0, + }; + seq++; + resultData.Add(receiver); + } + } + } + } + return Success(); + } + catch + { + throw; + } + } + + /// + /// ออกคำสั่ง C-PM-26 คำสั่งให้ออกจากราชการไว้ก่อน + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command26/report/excecute")] + public async Task> PostReportCommand26Execute([FromBody] ReportExecuteRequest req) + { + + var data = await _context.DisciplineReport_Profiles + .Include(x => x.DisciplineDisciplinary) + .Where(x => x.Status == "REPORT") + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + var resultData = (from p in data + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + profileId = p.PersonId, + date = r.commandAffectDate, + refCommandNo = $"{r.commandNo}/{r.commandYear}", + salaryRef = r.templateDoc, + isLeave = true, + leaveReason = "ได้รับโทษทางวินัย ให้ออกจากราชการไว้ก่อน", + dateLeave = r.commandAffectDate, + refCommandDate = DateTime.Now, + detail = p.DisciplineDisciplinary.Title, + level = p.DisciplineDisciplinary.DisciplinaryFaultLevel, + unStigma = "คำสั่งลงโทษ ให้ออกจากราชการไว้ก่อน", + }).ToList(); + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new + { + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) + { + data.ForEach(profile => profile.Status = "DONE"); + await _context.SaveChangesAsync(); + } + } + return Success(); + } + + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-27 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command27/report")] + public async Task> PostReportCommand27([FromBody] ReportPersonRequest req_) + { + try + { + var resultData = new List(); + var baseAPI = _configuration["API"]; + + foreach (var id in req_.refIds) + { + var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}"; + + var commandType = await _context.Set() + .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-27") + .FirstOrDefaultAsync(); + var response = new PassDisciplineResponse(); + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var res = await client.SendAsync(req); + var result = await res.Content.ReadAsStringAsync(); + + response = JsonConvert.DeserializeObject(result); + + var seq = 1; + foreach (var d in response!.result) + { + if (commandType == null || commandType.Id != d.commandId) + continue; + var _baseAPI = _configuration["API"]; + var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; + using (var _client = new HttpClient()) + { + _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); + var _res = await _client.SendAsync(_req); + var _result = await _res.Content.ReadAsStringAsync(); + + var org = JsonConvert.DeserializeObject(_result); + + if (org == null || org.result == null) + continue; + + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, + Prefix = org.result.prefix == null ? "" : org.result.prefix, + FirstName = org.result.firstName == null ? "" : org.result.firstName, + LastName = org.result.lastName == null ? "" : org.result.lastName, + RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), + RefDisciplineId = d.id, + Amount = 0, + }; + seq++; + resultData.Add(receiver); + } + } + } + } + return Success(); + } + catch + { + throw; + } + } + + /// + /// ออกคำสั่ง C-PM-27 คำสั่งลงโทษ ภาคทัณฑ์ + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command27/report/excecute")] + public async Task> PostReportCommand27Execute([FromBody] ReportExecuteRequest req) + { + var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Include(x => x.DisciplineDisciplinary) + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + string? _null = null; + var resultData = (from p in data + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + profileId = p.PersonId, + date = r.commandAffectDate, + refCommandNo = $"{r.commandNo}/{r.commandYear}", + salaryRef = r.templateDoc, + isLeave = _null, + leaveReason = _null, + dateLeave = _null, + refCommandDate = DateTime.Now, + detail = p.DisciplineDisciplinary.Title, + level = p.DisciplineDisciplinary.DisciplinaryFaultLevel, + unStigma = "คำสั่งลงโทษ ลงโทษ ภาคทัณฑ์", + }).ToList(); + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new + { + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) + { + data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; }); + await _context.SaveChangesAsync(); + } + } + return Success(); + } + + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-28 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command28/report")] + public async Task> PostReportCommand28([FromBody] ReportPersonRequest req_) + { + try + { + var resultData = new List(); + var baseAPI = _configuration["API"]; + + foreach (var id in req_.refIds) + { + var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}"; + + var commandType = await _context.Set() + .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-28") + .FirstOrDefaultAsync(); + var response = new PassDisciplineResponse(); + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var res = await client.SendAsync(req); + var result = await res.Content.ReadAsStringAsync(); + + response = JsonConvert.DeserializeObject(result); + + var seq = 1; + foreach (var d in response!.result) + { + if (commandType == null || commandType.Id != d.commandId) + continue; + var _baseAPI = _configuration["API"]; + var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; + using (var _client = new HttpClient()) + { + _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); + var _res = await _client.SendAsync(_req); + var _result = await _res.Content.ReadAsStringAsync(); + + var org = JsonConvert.DeserializeObject(_result); + + if (org == null || org.result == null) + continue; + + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, + Prefix = org.result.prefix == null ? "" : org.result.prefix, + FirstName = org.result.firstName == null ? "" : org.result.firstName, + LastName = org.result.lastName == null ? "" : org.result.lastName, + RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), + RefDisciplineId = d.id, + Amount = 0, + }; + seq++; + resultData.Add(receiver); + } + } + } + } + return Success(); + } + catch + { + throw; + } + } + + /// + /// ออกคำสั่ง C-PM-28 คำสั่งลงโทษ ตัดเงินเดือน + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command28/report/excecute")] + public async Task> PostReportCommand28Execute([FromBody] ReportExecuteRequest req) + { + var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Include(x => x.DisciplineDisciplinary) + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + string? _null = null; + var resultData = (from p in data + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + profileId = p.PersonId, + date = r.commandAffectDate, + refCommandNo = $"{r.commandNo}/{r.commandYear}", + salaryRef = r.templateDoc, + isLeave = _null, + leaveReason = _null, + dateLeave = _null, + refCommandDate = DateTime.Now, + detail = p.DisciplineDisciplinary.Title, + level = p.DisciplineDisciplinary.DisciplinaryFaultLevel, + unStigma = "คำสั่งลงโทษ ตัดเงินเดือน" + }).ToList(); + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new + { + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) + { + data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; }); + await _context.SaveChangesAsync(); + } + } + return Success(); + } + + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-29 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command29/report")] + public async Task> PostReportCommand29([FromBody] ReportPersonRequest req_) + { + try + { + var resultData = new List(); + var baseAPI = _configuration["API"]; + + foreach (var id in req_.refIds) + { + var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}"; + + var commandType = await _context.Set() + .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-29") + .FirstOrDefaultAsync(); + var response = new PassDisciplineResponse(); + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var res = await client.SendAsync(req); + var result = await res.Content.ReadAsStringAsync(); + + response = JsonConvert.DeserializeObject(result); + + var seq = 1; + foreach (var d in response!.result) + { + if (commandType == null || commandType.Id != d.commandId) + continue; + var _baseAPI = _configuration["API"]; + var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; + using (var _client = new HttpClient()) + { + _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); + var _res = await _client.SendAsync(_req); + var _result = await _res.Content.ReadAsStringAsync(); + + var org = JsonConvert.DeserializeObject(_result); + + if (org == null || org.result == null) + continue; + + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, + Prefix = org.result.prefix == null ? "" : org.result.prefix, + FirstName = org.result.firstName == null ? "" : org.result.firstName, + LastName = org.result.lastName == null ? "" : org.result.lastName, + RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), + RefDisciplineId = d.id, + Amount = 0, + }; + seq++; + resultData.Add(receiver); + } + } + } + } + return Success(); + } + catch + { + throw; + } + } + + /// + /// ออกคำสั่ง C-PM-29 คำสั่งลงโทษ ลดขั้นเงินเดือน + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command29/report/excecute")] + public async Task> PostReportCommand29Execute([FromBody] ReportExecuteRequest req) + { + var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Include(x => x.DisciplineDisciplinary) + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + string? _null = null; + var resultData = (from p in data + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + profileId = p.PersonId, + date = r.commandAffectDate, + refCommandNo = $"{r.commandNo}/{r.commandYear}", + salaryRef = r.templateDoc, + isLeave = _null, + leaveReason = _null, + dateLeave = _null, + refCommandDate = DateTime.Now, + detail = p.DisciplineDisciplinary.Title, + level = p.DisciplineDisciplinary.DisciplinaryFaultLevel, + unStigma = "คำสั่งลงโทษ ลดขั้นเงินเดือน" + }).ToList(); + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new + { + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) + { + data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; }); + await _context.SaveChangesAsync(); + } + } + return Success(); + } + + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-30 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command30/report")] + public async Task> PostReportCommand30([FromBody] ReportPersonRequest req_) + { + try + { + var resultData = new List(); + var baseAPI = _configuration["API"]; + + foreach (var id in req_.refIds) + { + var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}"; + + var commandType = await _context.Set() + .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-30") + .FirstOrDefaultAsync(); + var response = new PassDisciplineResponse(); + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var res = await client.SendAsync(req); + var result = await res.Content.ReadAsStringAsync(); + + response = JsonConvert.DeserializeObject(result); + + var seq = 1; + foreach (var d in response!.result) + { + if (commandType == null || commandType.Id != d.commandId) + continue; + var _baseAPI = _configuration["API"]; + var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; + using (var _client = new HttpClient()) + { + _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); + var _res = await _client.SendAsync(_req); + var _result = await _res.Content.ReadAsStringAsync(); + + var org = JsonConvert.DeserializeObject(_result); + + if (org == null || org.result == null) + continue; + + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, + Prefix = org.result.prefix == null ? "" : org.result.prefix, + FirstName = org.result.firstName == null ? "" : org.result.firstName, + LastName = org.result.lastName == null ? "" : org.result.lastName, + RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), + RefDisciplineId = d.id, + Amount = 0, + }; + seq++; + resultData.Add(receiver); + } + } + } + } + return Success(); + } + catch + { + throw; + } + } + + /// + /// ออกคำสั่ง C-PM-30 คำสั่งเพิ่มโทษ + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command30/report/excecute")] + public async Task> PostReportCommand30Execute([FromBody] ReportExecuteRequest req) + { + var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Include(x => x.DisciplineDisciplinary) + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + string? _null = null; + var resultData = (from p in data + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + profileId = p.PersonId, + date = r.commandAffectDate, + refCommandNo = $"{r.commandNo}/{r.commandYear}", + salaryRef = r.templateDoc, + isLeave = _null, + leaveReason = _null, + dateLeave = _null, + refCommandDate = DateTime.Now, + detail = p.DisciplineDisciplinary.Title, + level = p.DisciplineDisciplinary.DisciplinaryFaultLevel, + unStigma = "คำสั่งเพิ่มโทษ" + }).ToList(); + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new + { + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) + { + data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; }); + await _context.SaveChangesAsync(); + } + } + return Success(); + } + + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-31 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command31/report")] + public async Task> PostReportCommand31([FromBody] ReportPersonRequest req_) + { + try + { + var resultData = new List(); + var baseAPI = _configuration["API"]; + + foreach (var id in req_.refIds) + { + var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}"; + + var commandType = await _context.Set() + .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-31") + .FirstOrDefaultAsync(); + var response = new PassDisciplineResponse(); + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var res = await client.SendAsync(req); + var result = await res.Content.ReadAsStringAsync(); + + response = JsonConvert.DeserializeObject(result); + + var seq = 1; + foreach (var d in response!.result) + { + if (commandType == null || commandType.Id != d.commandId) + continue; + var _baseAPI = _configuration["API"]; + var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; + using (var _client = new HttpClient()) + { + _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); + var _res = await _client.SendAsync(_req); + var _result = await _res.Content.ReadAsStringAsync(); + + var org = JsonConvert.DeserializeObject(_result); + + if (org == null || org.result == null) + continue; + + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, + Prefix = org.result.prefix == null ? "" : org.result.prefix, + FirstName = org.result.firstName == null ? "" : org.result.firstName, + LastName = org.result.lastName == null ? "" : org.result.lastName, + RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), + RefDisciplineId = d.id, + Amount = 0, + }; + seq++; + resultData.Add(receiver); + } + } + } + } + return Success(); + } + catch + { + throw; + } + } + + /// + /// ออกคำสั่ง C-PM-31 คำสั่งงดโทษ + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command31/report/excecute")] + public async Task> PostReportCommand31Execute([FromBody] ReportExecuteRequest req) + { + var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Include(x => x.DisciplineDisciplinary) + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + string? _null = null; + var resultData = (from p in data + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + profileId = p.PersonId, + date = r.commandAffectDate, + refCommandNo = $"{r.commandNo}/{r.commandYear}", + salaryRef = r.templateDoc, + isLeave = _null, + leaveReason = _null, + dateLeave = _null, + refCommandDate = DateTime.Now, + detail = p.DisciplineDisciplinary.Title, + level = p.DisciplineDisciplinary.DisciplinaryFaultLevel, + unStigma = "คำสั่งงดโทษ" + }).ToList(); + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new + { + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) + { + data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; }); + await _context.SaveChangesAsync(); + } + } + return Success(); + } + + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-32 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command32/report")] + public async Task> PostReportCommand32([FromBody] ReportPersonRequest req_) + { + try + { + var resultData = new List(); + var baseAPI = _configuration["API"]; + + foreach (var id in req_.refIds) + { + var apiUrl = $"{baseAPI}/discipline/result/report/reject/{id}"; + + var response = new PassDisciplineResponse(); + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var res = await client.SendAsync(req); + var result = await res.Content.ReadAsStringAsync(); + + response = JsonConvert.DeserializeObject(result); + + var seq = 1; + foreach (var d in response!.result) + { + var _baseAPI = _configuration["API"]; + var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; + using (var _client = new HttpClient()) + { + _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); + var _res = await _client.SendAsync(_req); + var _result = await _res.Content.ReadAsStringAsync(); + + var org = JsonConvert.DeserializeObject(_result); + + if (org == null || org.result == null) + continue; + + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, + Prefix = org.result.prefix == null ? "" : org.result.prefix, + FirstName = org.result.firstName == null ? "" : org.result.firstName, + LastName = org.result.lastName == null ? "" : org.result.lastName, + RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), + RefDisciplineId = d.id, + Amount = 0, + }; + seq++; + resultData.Add(receiver); + } + } + } + } + return Success(); + } + catch + { + throw; + } + } + + /// + /// ออกคำสั่ง C-PM-32 คำสั่งยุติเรื่อง + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command32/report/excecute")] + public async Task> PostReportCommand32Execute([FromBody] ReportExecuteRequest req) + { + var data = await _context.DisciplineInvestigate_ProfileComplaints + .Include(x => x.DisciplineInvestigate) + .Where(x => x.IsReport == "REPORT") + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + string? _null = null; + dynamic? resultData = null; + if (data.Count != 0) + { + resultData = (from p in data + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + profileId = p.PersonId, + date = r.commandAffectDate, + refCommandNo = $"{r.commandNo}/{r.commandYear}", + salaryRef = r.templateDoc, + isLeave = false, + leaveReason = _null, + dateLeave = _null, + refCommandDate = DateTime.Now, + detail = p.DisciplineInvestigate.Title, + level = "", + unStigma = "คำสั่งยุติเรื่อง" + }).ToList(); + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new + { + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) + { + data.ForEach(profile => profile.IsReport = "NEW"); + await _context.SaveChangesAsync(); + } + } + } + else + { + var data1 = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Include(x => x.DisciplineDisciplinary) + .Where(x => x.IsReport == "REPORT") + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + resultData = (from p in data1 + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + profileId = p.PersonId, + date = r.commandAffectDate, + refCommandNo = $"{r.commandNo}/{r.commandYear}", + salaryRef = r.templateDoc, + isLeave = false, + leaveReason = _null, + dateLeave = _null, + refCommandDate = DateTime.Now, + detail = p.DisciplineDisciplinary.Title, + level = p.DisciplineDisciplinary.DisciplinaryFaultLevel, + unStigma = "คำสั่งยุติเรื่อง" + }).ToList(); + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new + { + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) + { + data1.ForEach(profile => profile.IsReport = "NEW"); + await _context.SaveChangesAsync(); + } + } + } + + return Success(); + } } } diff --git a/BMA.EHR.Discipline.Service/Requests/ReportAttachmentRequest.cs b/BMA.EHR.Discipline.Service/Requests/ReportAttachmentRequest.cs new file mode 100644 index 00000000..e371d927 --- /dev/null +++ b/BMA.EHR.Discipline.Service/Requests/ReportAttachmentRequest.cs @@ -0,0 +1,25 @@ +using BMA.EHR.Domain.Models.MetaData; +using Microsoft.EntityFrameworkCore; + +namespace BMA.EHR.Discipline.Service.Requests +{ + public class ReportAttachmentRequest + { + public ReportAttachmentRequestObj[] refIds { get; set; } + } + public class ReportAttachmentRequestObj + { + public string? refId { get; set; } + public int? Sequence { get; set; } + public string? CitizenId { get; set; } + public string? Prefix { get; set; } + public string? FirstName { get; set; } + public string? LastName { get; set; } + public double? Amount { get; set; } + public double? PositionSalaryAmount { get; set; } + public double? MouthSalaryAmount { get; set; } + public string? RemarkHorizontal { get; set; } + public string? RemarkVertical { get; set; } + public int CommandYear { get; set; } + } +} diff --git a/BMA.EHR.Discipline.Service/Requests/ReportExecuteRequest.cs b/BMA.EHR.Discipline.Service/Requests/ReportExecuteRequest.cs new file mode 100644 index 00000000..c7446828 --- /dev/null +++ b/BMA.EHR.Discipline.Service/Requests/ReportExecuteRequest.cs @@ -0,0 +1,21 @@ +using BMA.EHR.Domain.Models.MetaData; +using Microsoft.EntityFrameworkCore; + +namespace BMA.EHR.Discipline.Service.Requests +{ + public class ReportExecuteRequest + { + public ReportExecuteRequestObj[] refIds { get; set; } + } + public class ReportExecuteRequestObj + { + public string? refId { get; set; } + public DateTime commandAffectDate { get; set; } + public string? commandNo { get; set; } + public int commandYear { get; set; } + public string? templateDoc { get; set; } + public double? amount { get; set; } + public double? positionSalaryAmount { get; set; } + public double? mouthSalaryAmount { get; set; } + } +} diff --git a/BMA.EHR.Discipline.Service/Requests/ReportPersonRequest.cs b/BMA.EHR.Discipline.Service/Requests/ReportPersonRequest.cs new file mode 100644 index 00000000..f393a864 --- /dev/null +++ b/BMA.EHR.Discipline.Service/Requests/ReportPersonRequest.cs @@ -0,0 +1,10 @@ +using BMA.EHR.Domain.Models.MetaData; +using Microsoft.EntityFrameworkCore; + +namespace BMA.EHR.Discipline.Service.Requests +{ + public class ReportPersonRequest + { + public string[] refIds { get; set; } + } +} diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs index 5a93eb6a..c7fd9ad3 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs @@ -824,7 +824,7 @@ namespace BMA.EHR.Placement.Service.Controllers } /// - /// ออกคำสั่ง C-PM-05 + /// ออกคำสั่ง C-PM-05 คำสั่งแต่งตั้ง /// /// /// @@ -834,68 +834,53 @@ namespace BMA.EHR.Placement.Service.Controllers [HttpPost("appoint/report/excecute")] public async Task> PostReportExecuteAppoint([FromBody] ReportExecuteRequest req) { - // create new profile - foreach (var recv in req.refIds) + var data = await _context.PlacementAppointments + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + var resultData = (from p in data + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + profileId = p.profileId, + date = r.commandAffectDate, + amount = r.amount, + positionSalaryAmount = r.positionSalaryAmount, + mouthSalaryAmount = r.mouthSalaryAmount, + posNo = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}" : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}" : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}" : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}" : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}" : "", + position = p.position, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = p.posTypeName, + positionLevel = p.posLevelName, + refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}", + templateDoc = r.templateDoc, + posmasterId = p.posmasterId, + positionId = p.positionId, + }).ToList(); + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current"; + using (var client = new HttpClient()) { - var placementProfile = await _context.PlacementAppointments - .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); - if (placementProfile == null) - continue; - - if (placementProfile == null) - throw new Exception(GlobalMessages.DataNotFound); - var baseAPI = _configuration["API"]; - var apiUrlSalary = $"{baseAPI}/org/profile/salary"; - using (var client = new HttpClient()) + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); - var _res = await client.PostAsJsonAsync(apiUrlSalary, new - { - profileId = placementProfile.profileId, - date = recv.commandAffectDate, - amount = recv.amount, - positionSalaryAmount = recv.positionSalaryAmount, - mouthSalaryAmount = recv.mouthSalaryAmount, - posNo = placementProfile.posMasterNo == null ? "" : - placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "", - position = placementProfile.position, - positionLine = "", - positionPathSide = "", - positionExecutive = "", - positionType = placementProfile.posTypeName, - positionLevel = placementProfile.posLevelName, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - templateDoc = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - - var baseAPIOrg = _configuration["API"]; - var apiUrlOrg = $"{baseAPIOrg}/org/pos/report/current"; - using (var client = new HttpClient()) + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg); - var _res = await client.PostAsJsonAsync(apiUrlOrg, new - { - posmasterId = placementProfile.posmasterId, - positionId = placementProfile.positionId, - profileId = placementProfile.profileId, - }); - var _result = await _res.Content.ReadAsStringAsync(); + data.ForEach(profile => profile.Status = "DONE"); + await _context.SaveChangesAsync(); } - - // update placementstatus - placementProfile.Status = "DONE"; - - await _context.SaveChangesAsync(); } return Success(); } @@ -981,7 +966,7 @@ namespace BMA.EHR.Placement.Service.Controllers } /// - /// ออกคำสั่ง C-PM-06 + /// ออกคำสั่ง C-PM-06 เลื่อนข้าราชการ /// /// /// @@ -991,68 +976,53 @@ namespace BMA.EHR.Placement.Service.Controllers [HttpPost("slip/report/excecute")] public async Task> PostReportExecuteSlip([FromBody] ReportExecuteRequest req) { - // create new profile - foreach (var recv in req.refIds) + var data = await _context.PlacementAppointments + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + var resultData = (from p in data + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + profileId = p.profileId, + date = r.commandAffectDate, + amount = r.amount, + positionSalaryAmount = r.positionSalaryAmount, + mouthSalaryAmount = r.mouthSalaryAmount, + posNo = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}" : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}" : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}" : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}" : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}" : "", + position = p.position, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = p.posTypeName, + positionLevel = p.posLevelName, + refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}", + templateDoc = r.templateDoc, + posmasterId = p.posmasterId, + positionId = p.positionId, + }).ToList(); + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current"; + using (var client = new HttpClient()) { - var placementProfile = await _context.PlacementAppointments - .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); - if (placementProfile == null) - continue; - - if (placementProfile == null) - throw new Exception(GlobalMessages.DataNotFound); - var baseAPI = _configuration["API"]; - var apiUrlSalary = $"{baseAPI}/org/profile/salary"; - using (var client = new HttpClient()) + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); - var _res = await client.PostAsJsonAsync(apiUrlSalary, new - { - profileId = placementProfile.profileId, - date = recv.commandAffectDate, - amount = recv.amount, - positionSalaryAmount = recv.positionSalaryAmount, - mouthSalaryAmount = recv.mouthSalaryAmount, - posNo = placementProfile.posMasterNo == null ? "" : - placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "", - position = placementProfile.position, - positionLine = "", - positionPathSide = "", - positionExecutive = "", - positionType = placementProfile.posTypeName, - positionLevel = placementProfile.posLevelName, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - templateDoc = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - - var baseAPIOrg = _configuration["API"]; - var apiUrlOrg = $"{baseAPIOrg}/org/pos/report/current"; - using (var client = new HttpClient()) + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg); - var _res = await client.PostAsJsonAsync(apiUrlOrg, new - { - posmasterId = placementProfile.posmasterId, - positionId = placementProfile.positionId, - profileId = placementProfile.profileId, - }); - var _result = await _res.Content.ReadAsStringAsync(); + data.ForEach(profile => profile.Status = "DONE"); + await _context.SaveChangesAsync(); } - - // update placementstatus - placementProfile.Status = "DONE"; - - await _context.SaveChangesAsync(); } return Success(); } @@ -1138,7 +1108,7 @@ namespace BMA.EHR.Placement.Service.Controllers } /// - /// ออกคำสั่ง C-PM-07 + /// ออกคำสั่ง C-PM-07 ย้ายข้าราชการ /// /// /// @@ -1148,65 +1118,53 @@ namespace BMA.EHR.Placement.Service.Controllers [HttpPost("move/report/excecute")] public async Task> PostReportExecuteMove([FromBody] ReportExecuteRequest req) { - // create new profile - foreach (var recv in req.refIds) + var data = await _context.PlacementAppointments + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + var resultData = (from p in data + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + profileId = p.profileId, + date = r.commandAffectDate, + amount = r.amount, + positionSalaryAmount = r.positionSalaryAmount, + mouthSalaryAmount = r.mouthSalaryAmount, + posNo = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}" : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}" : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}" : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}" : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}" : "", + position = p.position, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = p.posTypeName, + positionLevel = p.posLevelName, + refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}", + templateDoc = r.templateDoc, + posmasterId = p.posmasterId, + positionId = p.positionId, + }).ToList(); + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current"; + using (var client = new HttpClient()) { - var placementProfile = await _context.PlacementAppointments - .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); - if (placementProfile == null) - continue; - var baseAPI = _configuration["API"]; - var apiUrlSalary = $"{baseAPI}/org/profile/salary"; - using (var client = new HttpClient()) + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); - var _res = await client.PostAsJsonAsync(apiUrlSalary, new - { - profileId = placementProfile.profileId, - date = recv.commandAffectDate, - amount = recv.amount, - positionSalaryAmount = recv.positionSalaryAmount, - mouthSalaryAmount = recv.mouthSalaryAmount, - posNo = placementProfile.posMasterNo == null ? "" : - placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "", - position = placementProfile.position, - positionLine = "", - positionPathSide = "", - positionExecutive = "", - positionType = placementProfile.posTypeName, - positionLevel = placementProfile.posLevelName, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - templateDoc = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - - var baseAPIOrg = _configuration["API"]; - var apiUrlOrg = $"{baseAPIOrg}/org/pos/report/current"; - using (var client = new HttpClient()) + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg); - var _res = await client.PostAsJsonAsync(apiUrlOrg, new - { - posmasterId = placementProfile.posmasterId, - positionId = placementProfile.positionId, - profileId = placementProfile.profileId, - }); - var _result = await _res.Content.ReadAsStringAsync(); + data.ForEach(profile => profile.Status = "DONE"); + await _context.SaveChangesAsync(); } - - // update placementstatus - placementProfile.Status = "DONE"; - - await _context.SaveChangesAsync(); } return Success(); } @@ -1289,7 +1247,7 @@ namespace BMA.EHR.Placement.Service.Controllers } /// - /// ออกคำสั่ง C-PM-22 + /// ออกคำสั่ง C-PM-22 คำสั่งปรับระดับชั้นงาน /// /// /// @@ -1299,63 +1257,50 @@ namespace BMA.EHR.Placement.Service.Controllers [HttpPost("employee-appoint/report/excecute")] public async Task> PostReportExecuteEmployeeAppoint([FromBody] ReportExecuteRequest req) { - // create new profile - foreach (var recv in req.refIds) + var data = await _context.PlacementAppointments + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + var resultData = (from p in data + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + profileId = p.profileId, + date = r.commandAffectDate, + amount = r.amount, + positionSalaryAmount = r.positionSalaryAmount, + mouthSalaryAmount = r.mouthSalaryAmount, + posNo = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}" : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}" : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}" : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}" : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}" : "", + position = p.position, + positionType = p.posTypeName, + positionLevel = p.posLevelName, + refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}", + templateDoc = r.templateDoc, + posmasterId = p.posmasterId, + positionId = p.positionId, + }).ToList(); + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-employee-current"; + using (var client = new HttpClient()) { - var data = await _context.PlacementAppointments - .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); - if (data == null) - continue; - - var baseAPI = _configuration["API"]; - var apiUrlSalary = $"{baseAPI}/org/profile-employee/salary"; - using (var client = new HttpClient()) + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); - var _res = await client.PostAsJsonAsync(apiUrlSalary, new - { - profileEmployeeId = data.profileId, - date = recv.commandAffectDate, - amount = recv.amount, - positionSalaryAmount = recv.positionSalaryAmount, - mouthSalaryAmount = recv.mouthSalaryAmount, - posNo = data.posMasterNo == null ? "" : - data.node == 4 ? $"{data.child4ShortName}{data.posMasterNo}" : - data.node == 3 ? $"{data.child3ShortName}{data.posMasterNo}" : - data.node == 2 ? $"{data.child2ShortName}{data.posMasterNo}" : - data.node == 1 ? $"{data.child1ShortName}{data.posMasterNo}" : - data.node == 0 ? $"{data.rootShortName}{data.posMasterNo}" : "", - position = data.position, - positionType = data.posTypeName, - positionLevel = data.posLevelName, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - templateDoc = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - - var baseAPIOrg = _configuration["API"]; - var apiUrlOrg = $"{baseAPIOrg}/org/employee/pos/report/current"; - using (var client = new HttpClient()) + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg); - var _res = await client.PostAsJsonAsync(apiUrlOrg, new - { - posmasterId = data.posmasterId, - positionId = data.positionId, - profileId = data.profileId, - }); - var _result = await _res.Content.ReadAsStringAsync(); + data.ForEach(profile => profile.Status = "DONE"); + await _context.SaveChangesAsync(); } - - // update placementstatus - data.Status = "DONE"; - - await _context.SaveChangesAsync(); } return Success(); } @@ -1438,7 +1383,7 @@ namespace BMA.EHR.Placement.Service.Controllers } /// - /// ออกคำสั่ง C-PM-24 + /// ออกคำสั่ง C-PM-24 คำสั่งย้ายลูกจ้างประจำ /// /// /// @@ -1448,63 +1393,50 @@ namespace BMA.EHR.Placement.Service.Controllers [HttpPost("employee-move/report/excecute")] public async Task> PostReportExecuteEmployeeMove([FromBody] ReportExecuteRequest req) { - // create new profile - foreach (var recv in req.refIds) + var data = await _context.PlacementAppointments + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + var resultData = (from p in data + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + profileId = p.profileId, + date = r.commandAffectDate, + amount = r.amount, + positionSalaryAmount = r.positionSalaryAmount, + mouthSalaryAmount = r.mouthSalaryAmount, + posNo = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}" : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}" : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}" : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}" : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}" : "", + position = p.position, + positionType = p.posTypeName, + positionLevel = p.posLevelName, + refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}", + templateDoc = r.templateDoc, + posmasterId = p.posmasterId, + positionId = p.positionId, + }).ToList(); + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-employee-current"; + using (var client = new HttpClient()) { - var data = await _context.PlacementAppointments - .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); - - if (data == null) - throw new Exception(GlobalMessages.DataNotFound); - var baseAPI = _configuration["API"]; - var apiUrlSalary = $"{baseAPI}/org/profile-employee/salary"; - using (var client = new HttpClient()) + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); - var _res = await client.PostAsJsonAsync(apiUrlSalary, new - { - profileEmployeeId = data.profileId, - date = recv.commandAffectDate, - amount = recv.amount, - positionSalaryAmount = recv.positionSalaryAmount, - mouthSalaryAmount = recv.mouthSalaryAmount, - posNo = data.posMasterNo == null ? "" : - data.node == 4 ? $"{data.child4ShortName}{data.posMasterNo}" : - data.node == 3 ? $"{data.child3ShortName}{data.posMasterNo}" : - data.node == 2 ? $"{data.child2ShortName}{data.posMasterNo}" : - data.node == 1 ? $"{data.child1ShortName}{data.posMasterNo}" : - data.node == 0 ? $"{data.rootShortName}{data.posMasterNo}" : "", - position = data.position, - positionType = data.posTypeName, - positionLevel = data.posLevelName, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - templateDoc = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - - var baseAPIOrg = _configuration["API"]; - var apiUrlOrg = $"{baseAPIOrg}/org/employee/pos/report/current"; - using (var client = new HttpClient()) + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg); - var _res = await client.PostAsJsonAsync(apiUrlOrg, new - { - posmasterId = data.posmasterId, - positionId = data.positionId, - profileId = data.profileId, - }); - var _result = await _res.Content.ReadAsStringAsync(); + data.ForEach(profile => profile.Status = "DONE"); + await _context.SaveChangesAsync(); } - - // update placementstatus - data.Status = "DONE"; - - await _context.SaveChangesAsync(); } return Success(); } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index 6cdcbc75..067dae21 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -1545,7 +1545,7 @@ namespace BMA.EHR.Placement.Service.Controllers } /// - /// ออกคำสั่ง C-PM-01 + /// ออกคำสั่ง C-PM-01 บรรจุและแต่งตั้งผู้สอบแข่งขันได้ /// /// /// @@ -1818,7 +1818,7 @@ namespace BMA.EHR.Placement.Service.Controllers } /// - /// ออกคำสั่ง C-PM-02 + /// ออกคำสั่ง C-PM-02 บรรจุและแต่งตั้งผู้ได้รับคัดเลือก /// /// /// @@ -2101,7 +2101,7 @@ namespace BMA.EHR.Placement.Service.Controllers } /// - /// ออกคำสั่ง C-PM-03 + /// ออกคำสั่ง C-PM-03 แต่งตั้งข้าราชการ /// /// /// @@ -2111,66 +2111,53 @@ namespace BMA.EHR.Placement.Service.Controllers [HttpPost("appoint/report/excecute")] public async Task> PostReportExecuteAppoint([FromBody] ReportExecuteRequest req) { - // create new profile - foreach (var recv in req.refIds) + var data = await _context.PlacementProfiles + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + var resultData = (from p in data + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + profileId = p.profileId, + date = r.commandAffectDate, + amount = r.amount, + positionSalaryAmount = r.positionSalaryAmount, + mouthSalaryAmount = r.mouthSalaryAmount, + posNo = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}" : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}" : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}" : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}" : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}" : "", + position = p.positionName, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = p.posTypeName, + positionLevel = p.posLevelName, + refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}", + templateDoc = r.templateDoc, + posmasterId = p.posmasterId, + positionId = p.positionId, + }).ToList(); + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current"; + using (var client = new HttpClient()) { - var placementProfile = await _context.PlacementProfiles - .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); - if (placementProfile == null) - continue; - - var baseAPI = _configuration["API"]; - var apiUrlSalary = $"{baseAPI}/org/profile/salary"; - using (var client = new HttpClient()) + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); - var _res = await client.PostAsJsonAsync(apiUrlSalary, new - { - profileId = placementProfile.profileId, - date = recv.commandAffectDate, - amount = recv.amount, - positionSalaryAmount = recv.positionSalaryAmount, - mouthSalaryAmount = recv.mouthSalaryAmount, - posNo = placementProfile.posMasterNo == null ? "" : - placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "", - position = placementProfile.positionName, - positionLine = "", - positionPathSide = "", - positionExecutive = "", - positionType = placementProfile.posTypeName, - positionLevel = placementProfile.posLevelName, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - templateDoc = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - - var baseAPIOrg = _configuration["API"]; - var apiUrlOrg = $"{baseAPIOrg}/org/pos/report/current"; - using (var client = new HttpClient()) + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg); - var _res = await client.PostAsJsonAsync(apiUrlOrg, new - { - posmasterId = placementProfile.posmasterId, - positionId = placementProfile.positionId, - profileId = placementProfile.profileId, - }); - var _result = await _res.Content.ReadAsStringAsync(); + data.ForEach(profile => profile.PlacementStatus = "CONTAIN"); + await _context.SaveChangesAsync(); } - - // update placementstatus - placementProfile.PlacementStatus = "CONTAIN"; - - await _context.SaveChangesAsync(); } return Success(); } @@ -2268,7 +2255,7 @@ namespace BMA.EHR.Placement.Service.Controllers } /// - /// ออกคำสั่ง C-PM-04 + /// ออกคำสั่ง C-PM-04 ย้ายข้าราชการ /// /// /// @@ -2278,66 +2265,53 @@ namespace BMA.EHR.Placement.Service.Controllers [HttpPost("move/report/excecute")] public async Task> PostReportExecuteMove([FromBody] ReportExecuteRequest req) { - // create new profile - foreach (var recv in req.refIds) + var data = await _context.PlacementProfiles + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + var resultData = (from p in data + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + profileId = p.profileId, + date = r.commandAffectDate, + amount = r.amount, + positionSalaryAmount = r.positionSalaryAmount, + mouthSalaryAmount = r.mouthSalaryAmount, + posNo = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}" : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}" : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}" : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}" : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}" : "", + position = p.positionName, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = p.posTypeName, + positionLevel = p.posLevelName, + refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}", + templateDoc = r.templateDoc, + posmasterId = p.posmasterId, + positionId = p.positionId, + }).ToList(); + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current"; + using (var client = new HttpClient()) { - var placementProfile = await _context.PlacementProfiles - .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); - if (placementProfile == null) - continue; - - var baseAPI = _configuration["API"]; - var apiUrlSalary = $"{baseAPI}/org/profile/salary"; - using (var client = new HttpClient()) + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); - var _res = await client.PostAsJsonAsync(apiUrlSalary, new - { - profileId = placementProfile.profileId, - date = recv.commandAffectDate, - amount = recv.amount, - positionSalaryAmount = recv.positionSalaryAmount, - mouthSalaryAmount = recv.mouthSalaryAmount, - posNo = placementProfile.posMasterNo == null ? "" : - placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "", - position = placementProfile.positionName, - positionLine = "", - positionPathSide = "", - positionExecutive = "", - positionType = placementProfile.posTypeName, - positionLevel = placementProfile.posLevelName, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - templateDoc = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - - var baseAPIOrg = _configuration["API"]; - var apiUrlOrg = $"{baseAPIOrg}/org/pos/report/current"; - using (var client = new HttpClient()) + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg); - var _res = await client.PostAsJsonAsync(apiUrlOrg, new - { - posmasterId = placementProfile.posmasterId, - positionId = placementProfile.positionId, - profileId = placementProfile.profileId, - }); - var _result = await _res.Content.ReadAsStringAsync(); + data.ForEach(profile => profile.PlacementStatus = "CONTAIN"); + await _context.SaveChangesAsync(); } - - // update placementstatus - placementProfile.PlacementStatus = "CONTAIN"; - - await _context.SaveChangesAsync(); } return Success(); } @@ -2435,7 +2409,7 @@ namespace BMA.EHR.Placement.Service.Controllers } /// - /// ออกคำสั่ง C-PM-39 + /// ออกคำสั่ง C-PM-39 เลื่อนข้าราชการ /// /// /// @@ -2445,66 +2419,53 @@ namespace BMA.EHR.Placement.Service.Controllers [HttpPost("slip/report/excecute")] public async Task> PostReportExecuteSlip([FromBody] ReportExecuteRequest req) { - // create new profile - foreach (var recv in req.refIds) + var data = await _context.PlacementProfiles + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + var resultData = (from p in data + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + profileId = p.profileId, + date = r.commandAffectDate, + amount = r.amount, + positionSalaryAmount = r.positionSalaryAmount, + mouthSalaryAmount = r.mouthSalaryAmount, + posNo = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}" : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}" : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}" : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}" : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}" : "", + position = p.positionName, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = p.posTypeName, + positionLevel = p.posLevelName, + refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}", + templateDoc = r.templateDoc, + posmasterId = p.posmasterId, + positionId = p.positionId, + }).ToList(); + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current"; + using (var client = new HttpClient()) { - var placementProfile = await _context.PlacementProfiles - .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); - if (placementProfile == null) - continue; - - var baseAPI = _configuration["API"]; - var apiUrlSalary = $"{baseAPI}/org/profile/salary"; - using (var client = new HttpClient()) + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); - var _res = await client.PostAsJsonAsync(apiUrlSalary, new - { - profileId = placementProfile.profileId, - date = recv.commandAffectDate, - amount = recv.amount, - positionSalaryAmount = recv.positionSalaryAmount, - mouthSalaryAmount = recv.mouthSalaryAmount, - posNo = placementProfile.posMasterNo == null ? "" : - placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "", - position = placementProfile.positionName, - positionLine = "", - positionPathSide = "", - positionExecutive = "", - positionType = placementProfile.posTypeName, - positionLevel = placementProfile.posLevelName, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - templateDoc = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - - var baseAPIOrg = _configuration["API"]; - var apiUrlOrg = $"{baseAPIOrg}/org/pos/report/current"; - using (var client = new HttpClient()) + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg); - var _res = await client.PostAsJsonAsync(apiUrlOrg, new - { - posmasterId = placementProfile.posmasterId, - positionId = placementProfile.positionId, - profileId = placementProfile.profileId, - }); - var _result = await _res.Content.ReadAsStringAsync(); + data.ForEach(profile => profile.PlacementStatus = "CONTAIN"); + await _context.SaveChangesAsync(); } - - // update placementstatus - placementProfile.PlacementStatus = "CONTAIN"; - - await _context.SaveChangesAsync(); } return Success(); } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs index 4528957d..1cd048e4 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs @@ -634,7 +634,7 @@ namespace BMA.EHR.Placement.Service.Controllers } /// - /// ออกคำสั่ง C-PM-15 + /// ออกคำสั่ง C-PM-15 คำสั่งให้ช่วยราชการ /// /// /// @@ -644,46 +644,46 @@ namespace BMA.EHR.Placement.Service.Controllers [HttpPost("command/report/excecute")] public async Task> PostReportExecute([FromBody] ReportExecuteRequest req) { - // create new profile - foreach (var recv in req.refIds) + var data = await _context.PlacementOfficers + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + var resultData = (from p in data + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + profileId = p.profileId, + date = r.commandAffectDate, + amount = r.amount, + positionSalaryAmount = r.positionSalaryAmount, + mouthSalaryAmount = r.mouthSalaryAmount, + posNo = p.PositionNumberOld, + position = p.PositionOld, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = p.PositionTypeOld, + positionLevel = p.PositionLevelOld, + refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}", + templateDoc = r.templateDoc, + }).ToList(); + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary"; + using (var client = new HttpClient()) { - var data = await _context.PlacementOfficers - .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); - - if (data == null) - throw new Exception(GlobalMessages.DataNotFound); - - var baseAPI = _configuration["API"]; - var apiUrlSalary = $"{baseAPI}/org/profile/salary"; - using (var client = new HttpClient()) + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); - var _res = await client.PostAsJsonAsync(apiUrlSalary, new - { - profileId = data.profileId, - date = recv.commandAffectDate, - amount = recv.amount, - positionSalaryAmount = recv.positionSalaryAmount, - mouthSalaryAmount = recv.mouthSalaryAmount, - posNo = data.PositionNumberOld, - position = data.PositionOld, - positionLine = "", - positionPathSide = "", - positionExecutive = "", - positionType = data.PositionTypeOld, - positionLevel = data.PositionLevelOld, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - templateDoc = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) + { + data.ForEach(profile => profile.Status = "DONE"); + await _context.SaveChangesAsync(); } - - // update placementstatus - data.Status = "DONE"; - - await _context.SaveChangesAsync(); } return Success(); } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs index a8c10381..a4c5bcd4 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs @@ -960,7 +960,7 @@ namespace BMA.EHR.Placement.Service.Controllers } /// - /// ออกคำสั่ง C-PM-14 + /// ออกคำสั่ง C-PM-14 คำสั่งรับโอนข้าราชการกรุงเทพมหานครสามัญ /// /// /// @@ -970,68 +970,53 @@ namespace BMA.EHR.Placement.Service.Controllers [HttpPost("command/report/excecute")] public async Task> PostReportExecute([FromBody] ReportExecuteRequest req) { - // create new profile - foreach (var recv in req.refIds) + var data = await _context.PlacementReceives + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + var resultData = (from p in data + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + profileId = p.profileId, + date = r.commandAffectDate, + amount = r.amount, + positionSalaryAmount = r.positionSalaryAmount, + mouthSalaryAmount = r.mouthSalaryAmount, + posNo = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}" : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}" : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}" : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}" : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}" : "", + position = p.position, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = p.posTypeName, + positionLevel = p.posLevelName, + refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}", + templateDoc = r.templateDoc, + posmasterId = p.posmasterId, + positionId = p.positionId, + }).ToList(); + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current"; + using (var client = new HttpClient()) { - // query placement Profile - var placementProfile = await _context.PlacementReceives - .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); - - if (placementProfile == null) - throw new Exception(GlobalMessages.DataNotFound); - - var baseAPI = _configuration["API"]; - var apiUrlSalary = $"{baseAPI}/org/profile/salary"; - using (var client = new HttpClient()) + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); - var _res = await client.PostAsJsonAsync(apiUrlSalary, new - { - profileId = placementProfile.profileId, - date = recv.commandAffectDate, - amount = recv.amount, - positionSalaryAmount = recv.positionSalaryAmount, - mouthSalaryAmount = recv.mouthSalaryAmount, - posNo = placementProfile.posMasterNo == null ? "" : - placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "", - position = placementProfile.position, - positionLine = "", - positionPathSide = "", - positionExecutive = "", - positionType = placementProfile.posTypeName, - positionLevel = placementProfile.posLevelName, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - templateDoc = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - - var baseAPIOrg = _configuration["API"]; - var apiUrlOrg = $"{baseAPIOrg}/org/pos/report/current"; - using (var client = new HttpClient()) + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg); - var _res = await client.PostAsJsonAsync(apiUrlOrg, new - { - posmasterId = placementProfile.posmasterId, - positionId = placementProfile.positionId, - profileId = placementProfile.profileId, - }); - var _result = await _res.Content.ReadAsStringAsync(); + data.ForEach(profile => profile.Status = "DONE"); + await _context.SaveChangesAsync(); } - - // update placementstatus - placementProfile.Status = "DONE"; - - await _context.SaveChangesAsync(); } return Success(); } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs index 0e7b2bde..b2cf8359 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs @@ -496,7 +496,7 @@ namespace BMA.EHR.Placement.Service.Controllers } /// - /// ออกคำสั่ง C-PM-16 + /// ออกคำสั่ง C-PM-16 คำสั่งส่งตัวกลับ /// /// /// @@ -506,46 +506,46 @@ namespace BMA.EHR.Placement.Service.Controllers [HttpPost("command/report/excecute")] public async Task> PostReportExecute([FromBody] ReportExecuteRequest req) { - // create new profile - foreach (var recv in req.refIds) + var data = await _context.PlacementRepatriations + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + var resultData = (from p in data + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + profileId = p.profileId, + date = r.commandAffectDate, + amount = r.amount, + positionSalaryAmount = r.positionSalaryAmount, + mouthSalaryAmount = r.mouthSalaryAmount, + posNo = p.PositionNumberOld, + position = p.PositionOld, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = p.PositionTypeOld, + positionLevel = p.PositionLevelOld, + refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}", + templateDoc = r.templateDoc, + }).ToList(); + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary"; + using (var client = new HttpClient()) { - var data = await _context.PlacementRepatriations - .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); - - if (data == null) - throw new Exception(GlobalMessages.DataNotFound); - - var baseAPI = _configuration["API"]; - var apiUrlSalary = $"{baseAPI}/org/profile/salary"; - using (var client = new HttpClient()) + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); - var _res = await client.PostAsJsonAsync(apiUrlSalary, new - { - profileId = data.profileId, - date = recv.commandAffectDate, - amount = recv.amount, - positionSalaryAmount = recv.positionSalaryAmount, - mouthSalaryAmount = recv.mouthSalaryAmount, - posNo = data.PositionNumberOld, - position = data.PositionOld, - positionLine = "", - positionPathSide = "", - positionExecutive = "", - positionType = data.PositionTypeOld, - positionLevel = data.PositionLevelOld, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - templateDoc = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) + { + data.ForEach(profile => profile.Status = "DONE"); + await _context.SaveChangesAsync(); } - - // update placementstatus - data.Status = "DONE"; - - await _context.SaveChangesAsync(); } return Success(); } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs index 5dda6f29..58c4a3a2 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs @@ -827,7 +827,7 @@ namespace BMA.EHR.Placement.Service.Controllers } /// - /// ออกคำสั่ง C-PM-13 + /// ออกคำสั่ง C-PM-13 คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ /// /// /// @@ -837,46 +837,46 @@ namespace BMA.EHR.Placement.Service.Controllers [HttpPost("command/report/excecute")] public async Task> PostReportExecute([FromBody] ReportExecuteRequest req) { - // create new profile - foreach (var recv in req.refIds) + var data = await _context.PlacementTransfers + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + var resultData = (from p in data + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + profileId = p.profileId, + date = r.commandAffectDate, + amount = r.amount, + positionSalaryAmount = r.positionSalaryAmount, + mouthSalaryAmount = r.mouthSalaryAmount, + posNo = p.PositionNumberOld, + position = p.PositionOld, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = p.PositionTypeOld, + positionLevel = p.PositionLevelOld, + refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}", + templateDoc = r.templateDoc, + }).ToList(); + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary"; + using (var client = new HttpClient()) { - var data = await _context.PlacementTransfers - .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); - - if (data == null) - throw new Exception(GlobalMessages.DataNotFound); - - var baseAPI = _configuration["API"]; - var apiUrlSalary = $"{baseAPI}/org/profile/salary"; - using (var client = new HttpClient()) + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); - var _res = await client.PostAsJsonAsync(apiUrlSalary, new - { - profileId = data.profileId, - date = recv.commandAffectDate, - amount = recv.amount, - positionSalaryAmount = recv.positionSalaryAmount, - mouthSalaryAmount = recv.mouthSalaryAmount, - posNo = data.PositionNumberOld, - position = data.PositionOld, - positionLine = "", - positionPathSide = "", - positionExecutive = "", - positionType = data.PositionTypeOld, - positionLevel = data.PositionLevelOld, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - templateDoc = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) + { + data.ForEach(profile => profile.Status = "DONE"); + await _context.SaveChangesAsync(); } - - // update placementstatus - data.Status = "DONE"; - - await _context.SaveChangesAsync(); } return Success(); } diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs index 2713a01b..b3a130c8 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs @@ -703,7 +703,7 @@ namespace BMA.EHR.Retirement.Service.Controllers } /// - /// ออกคำสั่ง C-PM-08 + /// ออกคำสั่ง C-PM-08 บรรจุและแต่งตั้งข้าราชการกลับเข้ารับราชการ /// /// /// @@ -713,62 +713,50 @@ namespace BMA.EHR.Retirement.Service.Controllers [HttpPost("appoint/report/excecute")] public async Task> PostReportExecuteAppoint([FromBody] ReportExecuteRequest req) { - // create new profile - foreach (var recv in req.refIds) + var data = await _context.RetirementOthers + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + string? _null = null; + var resultData = (from p in data + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + profileId = p.profileId, + date = r.commandAffectDate, + amount = r.amount, + positionSalaryAmount = r.positionSalaryAmount, + mouthSalaryAmount = r.mouthSalaryAmount, + posNo = p.PositionNumberOld, + position = p.PositionOld, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = p.PositionTypeOld, + positionLevel = p.PositionLevelOld, + refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}", + templateDoc = r.templateDoc, + isLeave = false, + leaveReason = _null, + dateLeave = _null, + }).ToList(); + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave"; + using (var client = new HttpClient()) { - var placementProfile = await _context.RetirementOthers - .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); - - if (placementProfile == null) - throw new Exception(GlobalMessages.DataNotFound); - var baseAPI = _configuration["API"]; - var apiUrlSalary = $"{baseAPI}/org/profile/salary"; - using (var client = new HttpClient()) + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); - var _res = await client.PostAsJsonAsync(apiUrlSalary, new - { - profileId = placementProfile.profileId, - date = recv.commandAffectDate, - amount = recv.amount, - positionSalaryAmount = recv.positionSalaryAmount, - mouthSalaryAmount = recv.mouthSalaryAmount, - posNo = placementProfile.PositionNumberOld, - position = placementProfile.PositionOld, - positionLine = "", - positionPathSide = "", - positionExecutive = "", - positionType = placementProfile.PositionTypeOld, - positionLevel = placementProfile.PositionLevelOld, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - templateDoc = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - - var baseAPILeave = _configuration["API"]; - var apiUrlLeave = $"{baseAPI}/org/profile/leave/{placementProfile.profileId}"; - using (var client = new HttpClient()) + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlLeave); - string? _null = null; - var _res = await client.PostAsJsonAsync(apiUrlLeave, new - { - isLeave = false, - leaveReason = _null, - dateLeave = _null, - }); - var _result = await _res.Content.ReadAsStringAsync(); + data.ForEach(profile => profile.Status = "DONE"); + await _context.SaveChangesAsync(); } - - // update placementstatus - placementProfile.Status = "DONE"; - - await _context.SaveChangesAsync(); } return Success(); } @@ -851,7 +839,7 @@ namespace BMA.EHR.Retirement.Service.Controllers } /// - /// ออกคำสั่ง C-PM-09 + /// ออกคำสั่ง C-PM-09 คำสั่งบรรจุและแต่งตั้งผู้ออกไปรับราชการทหารกลับเข้ารับราชการ /// /// /// @@ -861,62 +849,50 @@ namespace BMA.EHR.Retirement.Service.Controllers [HttpPost("out/report/excecute")] public async Task> PostReportExecuteOut([FromBody] ReportExecuteRequest req) { - // create new profile - foreach (var recv in req.refIds) + var data = await _context.RetirementOthers + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + string? _null = null; + var resultData = (from p in data + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + profileId = p.profileId, + date = r.commandAffectDate, + amount = r.amount, + positionSalaryAmount = r.positionSalaryAmount, + mouthSalaryAmount = r.mouthSalaryAmount, + posNo = p.PositionNumberOld, + position = p.PositionOld, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = p.PositionTypeOld, + positionLevel = p.PositionLevelOld, + refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}", + templateDoc = r.templateDoc, + isLeave = false, + leaveReason = _null, + dateLeave = _null, + }).ToList(); + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave"; + using (var client = new HttpClient()) { - var placementProfile = await _context.RetirementOthers - .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); - - if (placementProfile == null) - throw new Exception(GlobalMessages.DataNotFound); - var baseAPI = _configuration["API"]; - var apiUrlSalary = $"{baseAPI}/org/profile/salary"; - using (var client = new HttpClient()) + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); - var _res = await client.PostAsJsonAsync(apiUrlSalary, new - { - profileId = placementProfile.profileId, - date = recv.commandAffectDate, - amount = recv.amount, - positionSalaryAmount = recv.positionSalaryAmount, - mouthSalaryAmount = recv.mouthSalaryAmount, - posNo = placementProfile.PositionNumberOld, - position = placementProfile.PositionOld, - positionLine = "", - positionPathSide = "", - positionExecutive = "", - positionType = placementProfile.PositionTypeOld, - positionLevel = placementProfile.PositionLevelOld, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - templateDoc = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - - var baseAPILeave = _configuration["API"]; - var apiUrlLeave = $"{baseAPI}/org/profile/leave/{placementProfile.profileId}"; - using (var client = new HttpClient()) + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlLeave); - string? _null = null; - var _res = await client.PostAsJsonAsync(apiUrlLeave, new - { - isLeave = false, - leaveReason = _null, - dateLeave = _null, - }); - var _result = await _res.Content.ReadAsStringAsync(); + data.ForEach(profile => profile.Status = "DONE"); + await _context.SaveChangesAsync(); } - - // update placementstatus - placementProfile.Status = "DONE"; - - await _context.SaveChangesAsync(); } return Success(); } diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs index 979de96d..d059ad26 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs @@ -487,7 +487,7 @@ namespace BMA.EHR.Retirement.Service.Controllers } /// - /// ออกคำสั่ง C-PM-18 + /// ออกคำสั่ง C-PM-18 คำสั่งให้ออกจากราชการ /// /// /// @@ -497,62 +497,49 @@ namespace BMA.EHR.Retirement.Service.Controllers [HttpPost("command/report/excecute")] public async Task> PostReportExecuteLeave([FromBody] ReportExecuteRequest req) { - // create new profile - foreach (var recv in req.refIds) + var data = await _context.RetirementOuts + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + var resultData = (from p in data + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + profileId = p.profileId, + date = r.commandAffectDate, + amount = r.amount, + positionSalaryAmount = r.positionSalaryAmount, + mouthSalaryAmount = r.mouthSalaryAmount, + posNo = p.PositionNumberOld, + position = p.PositionOld, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = p.PositionTypeOld, + positionLevel = p.PositionLevelOld, + refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}", + templateDoc = r.templateDoc, + isLeave = true, + leaveReason = "ให้ออกจากราชการ", + dateLeave = r.commandAffectDate, + }).ToList(); + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave"; + using (var client = new HttpClient()) { - var data = await _context.RetirementOuts - .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); - - if (data == null) - throw new Exception(GlobalMessages.DataNotFound); - - var baseAPI = _configuration["API"]; - var apiUrl = $"{baseAPI}/org/profile/leave/{data.profileId}"; - - using (var client = new HttpClient()) + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl); - var _res = await client.PostAsJsonAsync(apiUrl, new - { - isLeave = true, - leaveReason = "ให้ออกจากราชการ", - dateLeave = recv.commandAffectDate, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - - var apiUrlSalary = $"{baseAPI}/org/profile/salary"; - using (var client = new HttpClient()) + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); - var _res = await client.PostAsJsonAsync(apiUrlSalary, new - { - profileId = data.profileId, - date = recv.commandAffectDate, - amount = recv.amount, - positionSalaryAmount = recv.positionSalaryAmount, - mouthSalaryAmount = recv.mouthSalaryAmount, - posNo = data.PositionNumberOld, - position = data.PositionOld, - positionLine = "", - positionPathSide = "", - positionExecutive = "", - positionType = data.PositionTypeOld, - positionLevel = data.PositionLevelOld, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - templateDoc = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); + data.ForEach(profile => profile.Status = "DONE"); + await _context.SaveChangesAsync(); } - - // update placementstatus - data.Status = "DONE"; - - await _context.SaveChangesAsync(); } return Success(); } diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs index 0873422a..277025a4 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs @@ -1695,7 +1695,7 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda } /// - /// ออกคำสั่ง C-PM-17 + /// ออกคำสั่ง C-PM-17 คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ /// /// /// @@ -1705,62 +1705,49 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda [HttpPost("command/report/excecute")] public async Task> PostReportExecute([FromBody] ReportExecuteRequest req) { - // create new profile - foreach (var recv in req.refIds) + var data = await _context.RetirementResigns + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + var resultData = (from p in data + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + profileId = p.profileId, + date = r.commandAffectDate, + amount = r.amount, + positionSalaryAmount = r.positionSalaryAmount, + mouthSalaryAmount = r.mouthSalaryAmount, + posNo = p.PositionNumberOld, + position = p.PositionOld, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = p.PositionTypeOld, + positionLevel = p.PositionLevelOld, + refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}", + templateDoc = r.templateDoc, + isLeave = true, + leaveReason = "ลาออกจากราชการ", + dateLeave = r.commandAffectDate, + }).ToList(); + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave"; + using (var client = new HttpClient()) { - var data = await _context.RetirementResigns - .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); - - if (data == null) - throw new Exception(GlobalMessages.DataNotFound); - - var baseAPI = _configuration["API"]; - var apiUrl = $"{baseAPI}/org/profile/leave/{data.profileId}"; - - using (var client = new HttpClient()) + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl); - var _res = await client.PostAsJsonAsync(apiUrl, new - { - isLeave = true, - leaveReason = "ลาออกจากราชการ", - dateLeave = recv.commandAffectDate, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - - var apiUrlSalary = $"{baseAPI}/org/profile/salary"; - using (var client = new HttpClient()) + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); - var _res = await client.PostAsJsonAsync(apiUrlSalary, new - { - profileId = data.profileId, - date = recv.commandAffectDate, - amount = recv.amount, - positionSalaryAmount = recv.positionSalaryAmount, - mouthSalaryAmount = recv.mouthSalaryAmount, - posNo = data.PositionNumberOld, - position = data.PositionOld, - positionLine = "", - positionPathSide = "", - positionExecutive = "", - positionType = data.PositionTypeOld, - positionLevel = data.PositionLevelOld, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - templateDoc = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); + data.ForEach(profile => profile.Status = "DONE"); + await _context.SaveChangesAsync(); } - - // update placementstatus - data.Status = "DONE"; - - await _context.SaveChangesAsync(); } return Success(); } @@ -1833,7 +1820,7 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda } /// - /// ออกคำสั่ง C-PM-23 + /// ออกคำสั่ง C-PM-23 คำสั่งให้ลูกจ้างออกจากราชการ /// /// /// @@ -1843,36 +1830,46 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda [HttpPost("employee/report/excecute")] public async Task> PostReportExecuteEmployee([FromBody] ReportExecuteRequest req) { - // create new profile - foreach (var recv in req.refIds) + var data = await _context.RetirementResigns + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + var resultData = (from p in data + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + profileId = p.profileId, + date = r.commandAffectDate, + amount = r.amount, + positionSalaryAmount = r.positionSalaryAmount, + mouthSalaryAmount = r.mouthSalaryAmount, + posNo = p.PositionNumberOld, + position = p.PositionOld, + positionType = p.PositionTypeOld, + positionLevel = p.PositionLevelOld, + refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}", + templateDoc = r.templateDoc, + isLeave = true, + leaveReason = "ลาออกจากราชการ", + dateLeave = r.commandAffectDate, + }).ToList(); + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-employee-leave"; + using (var client = new HttpClient()) { - var data = await _context.RetirementResigns - .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); - - if (data == null) - throw new Exception(GlobalMessages.DataNotFound); - - var baseAPI = _configuration["API"]; - var apiUrl = $"{baseAPI}/org/profile-employee/salary/{data.profileId}"; - - using (var client = new HttpClient()) + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Put, apiUrl); - var _res = await client.PutAsJsonAsync(apiUrl, new - { - isLeave = true, - leaveReason = "ลาออกจากราชการ", - dateLeave = recv.commandAffectDate, - }); - var _result = await _res.Content.ReadAsStringAsync(); + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) + { + data.ForEach(profile => profile.Status = "DONE"); + await _context.SaveChangesAsync(); } - - // update placementstatus - data.Status = "DONE"; - - await _context.SaveChangesAsync(); } return Success(); } @@ -1945,7 +1942,7 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda } /// - /// ออกคำสั่ง C-PM-41 + /// ออกคำสั่ง C-PM-41 คำสั่งยกเลิกการลาออก /// /// /// @@ -1955,63 +1952,50 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda [HttpPost("leave-cancel/report/excecute")] public async Task> PostReportExecuteLeaveCancel([FromBody] ReportExecuteRequest req) { - // create new profile - foreach (var recv in req.refIds) + var data = await _context.RetirementResigns + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + string? _null = null; + var resultData = (from p in data + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + profileId = p.profileId, + date = r.commandAffectDate, + amount = r.amount, + positionSalaryAmount = r.positionSalaryAmount, + mouthSalaryAmount = r.mouthSalaryAmount, + posNo = p.PositionNumberOld, + position = p.PositionOld, + positionLine = "", + positionPathSide = "", + positionExecutive = "", + positionType = p.PositionTypeOld, + positionLevel = p.PositionLevelOld, + refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}", + templateDoc = r.templateDoc, + isLeave = false, + leaveReason = _null, + dateLeave = _null, + }).ToList(); + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave"; + using (var client = new HttpClient()) { - var data = await _context.RetirementResigns - .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); - - if (data == null) - throw new Exception(GlobalMessages.DataNotFound); - - var baseAPI = _configuration["API"]; - var apiUrl = $"{baseAPI}/org/profile/leave/{data.profileId}"; - - using (var client = new HttpClient()) + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl); - string? _null = null; - var _res = await client.PostAsJsonAsync(apiUrl, new - { - isLeave = false, - leaveReason = _null, - dateLeave = _null, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - - var apiUrlSalary = $"{baseAPI}/org/profile/salary"; - using (var client = new HttpClient()) + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary); - var _res = await client.PostAsJsonAsync(apiUrlSalary, new - { - profileId = data.profileId, - date = recv.commandAffectDate, - amount = recv.amount, - positionSalaryAmount = recv.positionSalaryAmount, - mouthSalaryAmount = recv.mouthSalaryAmount, - posNo = data.PositionNumberOld, - position = data.PositionOld, - positionLine = "", - positionPathSide = "", - positionExecutive = "", - positionType = data.PositionTypeOld, - positionLevel = data.PositionLevelOld, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - templateDoc = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); + data.ForEach(profile => profile.Status = "DONEREJECT"); + await _context.SaveChangesAsync(); } - - // update placementstatus - data.Status = "DONEREJECT"; - - await _context.SaveChangesAsync(); } return Success(); } From 7655b1169017ff2fef44914a0cb09c65b26eae79 Mon Sep 17 00:00:00 2001 From: kittapath Date: Fri, 4 Oct 2024 16:01:35 +0700 Subject: [PATCH 28/42] no message --- .../Controllers/DisciplineResultController.cs | 78 ++++++------------- 1 file changed, 22 insertions(+), 56 deletions(-) diff --git a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs index 2363f19f..025c78c1 100644 --- a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs +++ b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs @@ -754,67 +754,33 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpPost("command25/report")] - public async Task> PostReportCommand25([FromBody] ReportPersonRequest req_) + public async Task> PostReportCommand25([FromBody] ReportPersonRequest req) { try { - var resultData = new List(); - var baseAPI = _configuration["API"]; + // var resultData = new List(); + // var baseAPI = _configuration["API"]; - foreach (var id in req_.refIds) - { - var apiUrl = $"{baseAPI}/discipline/result/report/stop/{id}"; - var commandType = await _context.Set() - .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-25") - .FirstOrDefaultAsync(); - var response = new PassDisciplineResponse(); - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var res = await client.SendAsync(req); - var result = await res.Content.ReadAsStringAsync(); + // foreach (var id in req_.refIds) + // { + // var apiUrl = $"{baseAPI}/discipline/result/report/stop/{id}"; - response = JsonConvert.DeserializeObject(result); - - var seq = 1; - foreach (var d in response!.result) - { - if (commandType == null || commandType.Id != d.commandId) - continue; - var _baseAPI = _configuration["API"]; - var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; - using (var _client = new HttpClient()) - { - _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); - var _res = await _client.SendAsync(_req); - var _result = await _res.Content.ReadAsStringAsync(); - - var org = JsonConvert.DeserializeObject(_result); - - if (org == null || org.result == null) - continue; - - var receiver = new CommandReceiver - { - Sequence = seq, - CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, - Prefix = org.result.prefix == null ? "" : org.result.prefix, - FirstName = org.result.firstName == null ? "" : org.result.firstName, - LastName = org.result.lastName == null ? "" : org.result.lastName, - RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), - RefDisciplineId = d.id, - Amount = 0, - }; - seq++; - resultData.Add(receiver); - } - } - } - } + // } + // var data = await _context.DisciplineReport_Profiles + // .Where(x => x.Status == "REPORT") + // .Where(x => x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id == id) + // .Select(x => new + // { + // PersonId = x.PersonId, + // Id = x.Id, + // CommandId = x.CommandTypeId, + // }) + // .ToListAsync(); + var data = await _context.DisciplineReport_Profiles + .Where(x => req.refIds.Contains(x.Id.ToString())) + .ToListAsync(); + data.ForEach(profile => profile.Status = "REPORT"); + await _context.SaveChangesAsync(); return Success(); } catch From dd170565b5292bd81d951cc9320be15c8c510b41 Mon Sep 17 00:00:00 2001 From: kittapath Date: Fri, 4 Oct 2024 16:10:37 +0700 Subject: [PATCH 29/42] no message --- .../Controllers/DisciplineResultController.cs | 113 ++++++++---------- 1 file changed, 53 insertions(+), 60 deletions(-) diff --git a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs index 025c78c1..ee347123 100644 --- a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs +++ b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs @@ -1785,10 +1785,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) .ToListAsync(); string? _null = null; - dynamic? resultData = null; - if (data.Count != 0) - { - resultData = (from p in data + var resultData = (from p in data join r in req.refIds on p.Id.ToString() equals r.refId select new @@ -1805,67 +1802,63 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers level = "", unStigma = "คำสั่งยุติเรื่อง" }).ToList(); - var baseAPIOrg = _configuration["API"]; - var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _res = await client.PostAsJsonAsync(apiUrlOrg, new - { - data = resultData, - }); - var _result = await _res.Content.ReadAsStringAsync(); - if (_res.IsSuccessStatusCode) - { - data.ForEach(profile => profile.IsReport = "NEW"); - await _context.SaveChangesAsync(); - } - } - } - else + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline"; + using (var client = new HttpClient()) { - var data1 = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates - .Include(x => x.DisciplineDisciplinary) - .Where(x => x.IsReport == "REPORT") - .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) - .ToListAsync(); - resultData = (from p in data1 - join r in req.refIds - on p.Id.ToString() equals r.refId - select new - { - profileId = p.PersonId, - date = r.commandAffectDate, - refCommandNo = $"{r.commandNo}/{r.commandYear}", - salaryRef = r.templateDoc, - isLeave = false, - leaveReason = _null, - dateLeave = _null, - refCommandDate = DateTime.Now, - detail = p.DisciplineDisciplinary.Title, - level = p.DisciplineDisciplinary.DisciplinaryFaultLevel, - unStigma = "คำสั่งยุติเรื่อง" - }).ToList(); - var baseAPIOrg = _configuration["API"]; - var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline"; - using (var client = new HttpClient()) + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _res = await client.PostAsJsonAsync(apiUrlOrg, new - { - data = resultData, - }); - var _result = await _res.Content.ReadAsStringAsync(); - if (_res.IsSuccessStatusCode) - { - data1.ForEach(profile => profile.IsReport = "NEW"); - await _context.SaveChangesAsync(); - } + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) + { + data.ForEach(profile => profile.IsReport = "NEW"); + await _context.SaveChangesAsync(); } } + var data1 = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Include(x => x.DisciplineDisciplinary) + .Where(x => x.IsReport == "REPORT") + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + var resultData1 = (from p in data1 + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + profileId = p.PersonId, + date = r.commandAffectDate, + refCommandNo = $"{r.commandNo}/{r.commandYear}", + salaryRef = r.templateDoc, + isLeave = false, + leaveReason = _null, + dateLeave = _null, + refCommandDate = DateTime.Now, + detail = p.DisciplineDisciplinary.Title, + level = p.DisciplineDisciplinary.DisciplinaryFaultLevel, + unStigma = "คำสั่งยุติเรื่อง" + }).ToList(); + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new + { + data = resultData1, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) + { + data1.ForEach(profile => profile.IsReport = "NEW"); + await _context.SaveChangesAsync(); + } + } + + return Success(); } } From 5c016fafbd9e659aebecfb00d17c9a3f7031d773 Mon Sep 17 00:00:00 2001 From: Bright Date: Fri, 4 Oct 2024 17:54:25 +0700 Subject: [PATCH 30/42] =?UTF-8?q?fix=20=E0=B8=AA=E0=B9=88=E0=B8=87?= =?UTF-8?q?=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=8A=E0=B8=B7=E0=B9=88=E0=B8=AD?= =?UTF-8?q?=E0=B8=AD=E0=B8=AD=E0=B8=81=E0=B8=84=E0=B8=B3=E0=B8=AA=E0=B8=B1?= =?UTF-8?q?=E0=B9=88=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/DisciplineResultController.cs | 648 ++++++------------ 1 file changed, 200 insertions(+), 448 deletions(-) diff --git a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs index ee347123..f0a754d0 100644 --- a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs +++ b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs @@ -739,11 +739,149 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers return Success(data1); } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-19 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command19/report")] + public async Task> PostReportCommand19([FromBody] ReportPersonRequest req) + { + var data = await _context.DisciplineReport_Profiles + .Where(x => req.refIds.Contains(x.Id.ToString())) + .ToListAsync(); + data.ForEach(profile => profile.Status = "REPORT"); + await _context.SaveChangesAsync(); + return Success(); + } + /// + /// ออกคำสั่ง C-PM-19 คำสั่งปลดออกจากราชการ + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command19/report/excecute")] + public async Task> PostReportCommand19Execute([FromBody] ReportExecuteRequest req) + { + var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Include(x => x.DisciplineDisciplinary) + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + var resultData = (from p in data + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + profileId = p.PersonId, + date = r.commandAffectDate, + refCommandNo = $"{r.commandNo}/{r.commandYear}", + salaryRef = r.templateDoc, + isLeave = true, + leaveReason = "ได้รับโทษทางวินัย ปลดออกจากราชการ", + dateLeave = r.commandAffectDate, + refCommandDate = DateTime.Now, + detail = p.DisciplineDisciplinary.Title, + level = p.DisciplineDisciplinary.DisciplinaryFaultLevel, + unStigma = "คำสั่งลงโทษ ปลดออกจากราชการ", + }).ToList(); + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new + { + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) + { + data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; }); + await _context.SaveChangesAsync(); + } + } + return Success(); + } + /// + /// ส่งรายชื่อออกคำสั่ง C-PM-20 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command20/report")] + public async Task> PostReportcommand20([FromBody] ReportPersonRequest req) + { + var data = await _context.DisciplineReport_Profiles + .Where(x => req.refIds.Contains(x.Id.ToString())) + .ToListAsync(); + data.ForEach(profile => profile.Status = "REPORT"); + await _context.SaveChangesAsync(); + return Success(); + } + /// + /// ออกคำสั่ง C-PM-20 คำสั่งไล่ออกจากราชการ + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command20/report/excecute")] + public async Task> PostReportCommand20Execute([FromBody] ReportExecuteRequest req) + { + var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Include(x => x.DisciplineDisciplinary) + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + var resultData = (from p in data + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + profileId = p.PersonId, + date = r.commandAffectDate, + refCommandNo = $"{r.commandNo}/{r.commandYear}", + salaryRef = r.templateDoc, + isLeave = true, + leaveReason = "ได้รับโทษทางวินัย ไล่ออกจากราชการ", + dateLeave = r.commandAffectDate, + refCommandDate = DateTime.Now, + detail = p.DisciplineDisciplinary.Title, + level = p.DisciplineDisciplinary.DisciplinaryFaultLevel, + unStigma = "คำสั่งลงโทษ ไล่ออกจากราชการ", + }).ToList(); + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new + { + data = resultData, + }); + var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) + { + data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; }); + await _context.SaveChangesAsync(); + } + } + return Success(); + } /// /// ส่งรายชื่อออกคำสั่ง C-PM-25 @@ -758,24 +896,6 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers { try { - // var resultData = new List(); - // var baseAPI = _configuration["API"]; - - // foreach (var id in req_.refIds) - // { - // var apiUrl = $"{baseAPI}/discipline/result/report/stop/{id}"; - - // } - // var data = await _context.DisciplineReport_Profiles - // .Where(x => x.Status == "REPORT") - // .Where(x => x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id == id) - // .Select(x => new - // { - // PersonId = x.PersonId, - // Id = x.Id, - // CommandId = x.CommandTypeId, - // }) - // .ToListAsync(); var data = await _context.DisciplineReport_Profiles .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); @@ -807,33 +927,24 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers { try { - foreach (var d in req.refIds) - { - var apiUrl = $"{_configuration["API"]}/discipline/result/report/find/{d.refId}"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var _res = await client.SendAsync(_req); - var _result = await _res.Content.ReadAsStringAsync(); + var data = await _context.DisciplineReport_Profiles + .Where(x => x.Status == "REPORT") + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); - var org = JsonConvert.DeserializeObject(_result); + var resultData = (from p in data + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + fullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + positionname = p.Position, + positionno = p.PosNo, + organizationname = p.Organization, + salary = r.Amount + }).ToList(); - if (org == null || org.result == null) - continue; - var receiver = new CommandType23Response - { - fullName = $"{d.Prefix}{d.FirstName} {d.LastName}", - positionname = org.result.position, - positionno = org.result.posNo == null ? null : org.result.posNo.ToThaiNumber(), - organizationname = org.result.organization, - salary = org.result.salary == null ? null : org.result.salary.Value.ToNumericNoDecimalText().ToString(), - }; - - return Success(receiver); - } - } - return null; + return Success(resultData); } catch { @@ -904,68 +1015,15 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpPost("command26/report")] - public async Task> PostReportCommand26([FromBody] ReportPersonRequest req_) + public async Task> PostReportCommand26([FromBody] ReportPersonRequest req) { try { - var resultData = new List(); - var baseAPI = _configuration["API"]; - - foreach (var id in req_.refIds) - { - var apiUrl = $"{baseAPI}/discipline/result/report/stop/{id}"; - - var commandType = await _context.Set() - .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-26") - .FirstOrDefaultAsync(); - var response = new PassDisciplineResponse(); - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var res = await client.SendAsync(req); - var result = await res.Content.ReadAsStringAsync(); - - response = JsonConvert.DeserializeObject(result); - - var seq = 1; - foreach (var d in response!.result) - { - if (commandType == null || commandType.Id != d.commandId) - continue; - var _baseAPI = _configuration["API"]; - var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; - using (var _client = new HttpClient()) - { - _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); - var _res = await _client.SendAsync(_req); - var _result = await _res.Content.ReadAsStringAsync(); - - var org = JsonConvert.DeserializeObject(_result); - - if (org == null || org.result == null) - continue; - - var receiver = new CommandReceiver - { - Sequence = seq, - CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, - Prefix = org.result.prefix == null ? "" : org.result.prefix, - FirstName = org.result.firstName == null ? "" : org.result.firstName, - LastName = org.result.lastName == null ? "" : org.result.lastName, - RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), - RefDisciplineId = d.id, - Amount = 0, - }; - seq++; - resultData.Add(receiver); - } - } - } - } + var data = await _context.DisciplineReport_Profiles + .Where(x => req.refIds.Contains(x.Id.ToString())) + .ToListAsync(); + data.ForEach(profile => profile.Status = "REPORT"); + await _context.SaveChangesAsync(); return Success(); } catch @@ -1038,68 +1096,15 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpPost("command27/report")] - public async Task> PostReportCommand27([FromBody] ReportPersonRequest req_) + public async Task> PostReportCommand27([FromBody] ReportPersonRequest req) { try { - var resultData = new List(); - var baseAPI = _configuration["API"]; - - foreach (var id in req_.refIds) - { - var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}"; - - var commandType = await _context.Set() - .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-27") - .FirstOrDefaultAsync(); - var response = new PassDisciplineResponse(); - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var res = await client.SendAsync(req); - var result = await res.Content.ReadAsStringAsync(); - - response = JsonConvert.DeserializeObject(result); - - var seq = 1; - foreach (var d in response!.result) - { - if (commandType == null || commandType.Id != d.commandId) - continue; - var _baseAPI = _configuration["API"]; - var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; - using (var _client = new HttpClient()) - { - _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); - var _res = await _client.SendAsync(_req); - var _result = await _res.Content.ReadAsStringAsync(); - - var org = JsonConvert.DeserializeObject(_result); - - if (org == null || org.result == null) - continue; - - var receiver = new CommandReceiver - { - Sequence = seq, - CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, - Prefix = org.result.prefix == null ? "" : org.result.prefix, - FirstName = org.result.firstName == null ? "" : org.result.firstName, - LastName = org.result.lastName == null ? "" : org.result.lastName, - RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), - RefDisciplineId = d.id, - Amount = 0, - }; - seq++; - resultData.Add(receiver); - } - } - } - } + var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Where(x => req.refIds.Contains(x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id.ToString())) + .ToListAsync(); + data.ForEach(profile => profile.Status = "REPORT"); + await _context.SaveChangesAsync(); return Success(); } catch @@ -1171,68 +1176,15 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpPost("command28/report")] - public async Task> PostReportCommand28([FromBody] ReportPersonRequest req_) + public async Task> PostReportCommand28([FromBody] ReportPersonRequest req) { try { - var resultData = new List(); - var baseAPI = _configuration["API"]; - - foreach (var id in req_.refIds) - { - var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}"; - - var commandType = await _context.Set() - .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-28") - .FirstOrDefaultAsync(); - var response = new PassDisciplineResponse(); - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var res = await client.SendAsync(req); - var result = await res.Content.ReadAsStringAsync(); - - response = JsonConvert.DeserializeObject(result); - - var seq = 1; - foreach (var d in response!.result) - { - if (commandType == null || commandType.Id != d.commandId) - continue; - var _baseAPI = _configuration["API"]; - var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; - using (var _client = new HttpClient()) - { - _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); - var _res = await _client.SendAsync(_req); - var _result = await _res.Content.ReadAsStringAsync(); - - var org = JsonConvert.DeserializeObject(_result); - - if (org == null || org.result == null) - continue; - - var receiver = new CommandReceiver - { - Sequence = seq, - CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, - Prefix = org.result.prefix == null ? "" : org.result.prefix, - FirstName = org.result.firstName == null ? "" : org.result.firstName, - LastName = org.result.lastName == null ? "" : org.result.lastName, - RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), - RefDisciplineId = d.id, - Amount = 0, - }; - seq++; - resultData.Add(receiver); - } - } - } - } + var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Where(x => req.refIds.Contains(x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id.ToString())) + .ToListAsync(); + data.ForEach(profile => profile.Status = "REPORT"); + await _context.SaveChangesAsync(); return Success(); } catch @@ -1304,68 +1256,15 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpPost("command29/report")] - public async Task> PostReportCommand29([FromBody] ReportPersonRequest req_) + public async Task> PostReportCommand29([FromBody] ReportPersonRequest req) { try { - var resultData = new List(); - var baseAPI = _configuration["API"]; - - foreach (var id in req_.refIds) - { - var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}"; - - var commandType = await _context.Set() - .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-29") - .FirstOrDefaultAsync(); - var response = new PassDisciplineResponse(); - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var res = await client.SendAsync(req); - var result = await res.Content.ReadAsStringAsync(); - - response = JsonConvert.DeserializeObject(result); - - var seq = 1; - foreach (var d in response!.result) - { - if (commandType == null || commandType.Id != d.commandId) - continue; - var _baseAPI = _configuration["API"]; - var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; - using (var _client = new HttpClient()) - { - _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); - var _res = await _client.SendAsync(_req); - var _result = await _res.Content.ReadAsStringAsync(); - - var org = JsonConvert.DeserializeObject(_result); - - if (org == null || org.result == null) - continue; - - var receiver = new CommandReceiver - { - Sequence = seq, - CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, - Prefix = org.result.prefix == null ? "" : org.result.prefix, - FirstName = org.result.firstName == null ? "" : org.result.firstName, - LastName = org.result.lastName == null ? "" : org.result.lastName, - RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), - RefDisciplineId = d.id, - Amount = 0, - }; - seq++; - resultData.Add(receiver); - } - } - } - } + var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Where(x => req.refIds.Contains(x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id.ToString())) + .ToListAsync(); + data.ForEach(profile => profile.Status = "REPORT"); + await _context.SaveChangesAsync(); return Success(); } catch @@ -1437,68 +1336,15 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpPost("command30/report")] - public async Task> PostReportCommand30([FromBody] ReportPersonRequest req_) + public async Task> PostReportCommand30([FromBody] ReportPersonRequest req) { try { - var resultData = new List(); - var baseAPI = _configuration["API"]; - - foreach (var id in req_.refIds) - { - var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}"; - - var commandType = await _context.Set() - .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-30") - .FirstOrDefaultAsync(); - var response = new PassDisciplineResponse(); - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var res = await client.SendAsync(req); - var result = await res.Content.ReadAsStringAsync(); - - response = JsonConvert.DeserializeObject(result); - - var seq = 1; - foreach (var d in response!.result) - { - if (commandType == null || commandType.Id != d.commandId) - continue; - var _baseAPI = _configuration["API"]; - var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; - using (var _client = new HttpClient()) - { - _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); - var _res = await _client.SendAsync(_req); - var _result = await _res.Content.ReadAsStringAsync(); - - var org = JsonConvert.DeserializeObject(_result); - - if (org == null || org.result == null) - continue; - - var receiver = new CommandReceiver - { - Sequence = seq, - CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, - Prefix = org.result.prefix == null ? "" : org.result.prefix, - FirstName = org.result.firstName == null ? "" : org.result.firstName, - LastName = org.result.lastName == null ? "" : org.result.lastName, - RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), - RefDisciplineId = d.id, - Amount = 0, - }; - seq++; - resultData.Add(receiver); - } - } - } - } + var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Where(x => req.refIds.Contains(x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id.ToString())) + .ToListAsync(); + data.ForEach(profile => profile.Status = "REPORT"); + await _context.SaveChangesAsync(); return Success(); } catch @@ -1570,68 +1416,15 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpPost("command31/report")] - public async Task> PostReportCommand31([FromBody] ReportPersonRequest req_) + public async Task> PostReportCommand31([FromBody] ReportPersonRequest req) { try { - var resultData = new List(); - var baseAPI = _configuration["API"]; - - foreach (var id in req_.refIds) - { - var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}"; - - var commandType = await _context.Set() - .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-31") - .FirstOrDefaultAsync(); - var response = new PassDisciplineResponse(); - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var res = await client.SendAsync(req); - var result = await res.Content.ReadAsStringAsync(); - - response = JsonConvert.DeserializeObject(result); - - var seq = 1; - foreach (var d in response!.result) - { - if (commandType == null || commandType.Id != d.commandId) - continue; - var _baseAPI = _configuration["API"]; - var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; - using (var _client = new HttpClient()) - { - _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); - var _res = await _client.SendAsync(_req); - var _result = await _res.Content.ReadAsStringAsync(); - - var org = JsonConvert.DeserializeObject(_result); - - if (org == null || org.result == null) - continue; - - var receiver = new CommandReceiver - { - Sequence = seq, - CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, - Prefix = org.result.prefix == null ? "" : org.result.prefix, - FirstName = org.result.firstName == null ? "" : org.result.firstName, - LastName = org.result.lastName == null ? "" : org.result.lastName, - RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), - RefDisciplineId = d.id, - Amount = 0, - }; - seq++; - resultData.Add(receiver); - } - } - } - } + var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Where(x => req.refIds.Contains(x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id.ToString())) + .ToListAsync(); + data.ForEach(profile => profile.Status = "REPORT"); + await _context.SaveChangesAsync(); return Success(); } catch @@ -1703,63 +1496,22 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpPost("command32/report")] - public async Task> PostReportCommand32([FromBody] ReportPersonRequest req_) + public async Task> PostReportCommand32([FromBody] ReportPersonRequest req) { try { - var resultData = new List(); - var baseAPI = _configuration["API"]; + var data1 = await _context.DisciplineInvestigate_ProfileComplaints + .Where(x => req.refIds.Contains(x.DisciplineInvestigate.DisciplineComplaint.Id.ToString())) + .ToListAsync(); - foreach (var id in req_.refIds) - { - var apiUrl = $"{baseAPI}/discipline/result/report/reject/{id}"; + data1.ForEach(profile => profile.IsReport = "REPORT"); + var data2 = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Where(x => req.refIds.Contains(x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id.ToString())) + .ToListAsync(); - var response = new PassDisciplineResponse(); - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var res = await client.SendAsync(req); - var result = await res.Content.ReadAsStringAsync(); + data2.ForEach(profile => profile.IsReport = "REPORT"); - response = JsonConvert.DeserializeObject(result); - - var seq = 1; - foreach (var d in response!.result) - { - var _baseAPI = _configuration["API"]; - var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; - using (var _client = new HttpClient()) - { - _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); - var _res = await _client.SendAsync(_req); - var _result = await _res.Content.ReadAsStringAsync(); - - var org = JsonConvert.DeserializeObject(_result); - - if (org == null || org.result == null) - continue; - - var receiver = new CommandReceiver - { - Sequence = seq, - CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, - Prefix = org.result.prefix == null ? "" : org.result.prefix, - FirstName = org.result.firstName == null ? "" : org.result.firstName, - LastName = org.result.lastName == null ? "" : org.result.lastName, - RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), - RefDisciplineId = d.id, - Amount = 0, - }; - seq++; - resultData.Add(receiver); - } - } - } - } + await _context.SaveChangesAsync(); return Success(); } catch From 345de976570120a185509a72d9050ac6c2351dd0 Mon Sep 17 00:00:00 2001 From: kittapath Date: Fri, 4 Oct 2024 18:16:31 +0700 Subject: [PATCH 31/42] no message --- .../Controllers/OrderController.cs | 583 ------------------ 1 file changed, 583 deletions(-) diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs index aec3d5f0..17d5b9a5 100644 --- a/BMA.EHR.Command.Service/Controllers/OrderController.cs +++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs @@ -6782,150 +6782,6 @@ namespace BMA.EHR.Command.Service.Controllers return Success(); } - /// - /// ส่งรายชื่อออกคำสั่ง C-PM-19 - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command19/report")] - public async Task> PostReportCommand19([FromBody] ReportPersonRequest req) - { - var placementProfiles = await _context.RetirementDischarges.AsQueryable() - .Where(x => req.refIds.Contains(x.Id.ToString())) - .ToListAsync(); - - placementProfiles.ForEach(profile => profile.Status = "REPORT"); - await _context.SaveChangesAsync(); - return Success(); - } - - /// - /// ออกคำสั่ง C-PM-19 คำสั่งปลดออกจากราชการ - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command19/report/excecute")] - public async Task> PostReportCommand19Execute([FromBody] ReportExecuteRequest req) - { - // create new profile - foreach (var recv in req.refIds) - { - var baseAPI = _configuration["API"]; - var apiUrl = $"{baseAPI}/org/profile/command19/{recv.refId}"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _res = await client.PostAsJsonAsync(apiUrl, new - { - profileId = recv.refId, - date = recv.commandAffectDate, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - salaryRef = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - - var dataSend = req.refIds.Select(x => new - { - Id = x.refId, - CommandAffectDate = x.commandAffectDate, - CommandNo = x.commandNo, - CommandYear = x.commandYear.ToThaiYear(), - Detail = "คำสั่งลงโทษ ปลดออกจากราชการ" - }); - - var _baseAPI = _configuration["API"]; - var _apiUrl = $"{_baseAPI}/discipline/result/report/up/resume"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var res = await client.PostAsJsonAsync(_apiUrl, new { result = dataSend }); - var result = await res.Content.ReadAsStringAsync(); - } - return Success(); - } - - /// - /// ส่งรายชื่อออกคำสั่ง C-PM-20 - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command20/report")] - public async Task> PostReportcommand20([FromBody] ReportPersonRequest req) - { - var placementProfiles = await _context.RetirementExpulsions.AsQueryable() - .Where(x => req.refIds.Contains(x.Id.ToString())) - .ToListAsync(); - - placementProfiles.ForEach(profile => profile.Status = "REPORT"); - await _context.SaveChangesAsync(); - return Success(); - } - - /// - /// ออกคำสั่ง C-PM-20 คำสั่งไล่ออกจากราชการ - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command20/report/excecute")] - public async Task> PostReportCommand20Execute([FromBody] ReportExecuteRequest req) - { - // create new profile - foreach (var recv in req.refIds) - { - var baseAPI = _configuration["API"]; - var apiUrl = $"{baseAPI}/org/profile/command20/{recv.refId}"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _res = await client.PostAsJsonAsync(apiUrl, new - { - profileId = recv.refId, - date = recv.commandAffectDate, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - salaryRef = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - - var dataSend = req.refIds.Select(x => new - { - Id = x.refId, - CommandAffectDate = x.commandAffectDate, - CommandNo = x.commandNo, - CommandYear = x.commandYear.ToThaiYear(), - detail = "คำสั่งลงโทษ ไล่ออกจากราชการ" - }); - - var _baseAPI = _configuration["API"]; - var _apiUrl = $"{_baseAPI}/discipline/result/report/up/resume"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var res = await client.PostAsJsonAsync(_apiUrl, new { result = dataSend }); - var result = await res.Content.ReadAsStringAsync(); - } - return Success(); - } - /// /// ส่งรายชื่อออกคำสั่ง C-PM-21 /// @@ -7020,445 +6876,6 @@ namespace BMA.EHR.Command.Service.Controllers return Success(); } - /// - /// ส่งรายชื่อออกคำสั่ง C-PM-33 - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command33/report")] - public async Task> PostReportCommand33([FromBody] ReportPersonRequest req) - { - try - { - // var resultData = new List(); - // var baseAPI = _configuration["API"]; - - // foreach (var id in req.refIds) - // { - // var apiUrl = $"{baseAPI}/salary/report/command/33/{id}"; - - // var response = new PassSalaryResponse(); - // using (var client = new HttpClient()) - // { - // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - // client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - // var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - // var res = await client.SendAsync(_req); - // // var result = await res.Content.ReadAsStringAsync(); - - // // response = JsonConvert.DeserializeObject(result); - - // // var seq = 1; - // // foreach (var d in response!.result) - // // { - // // var receiver = new CommandReceiver - // // { - // // Sequence = seq, - // // CitizenId = d.citizenId, - // // Prefix = d.prefix == null ? "" : d.prefix, - // // FirstName = d.firstName, - // // LastName = d.lastName, - // // RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId), - // // RefDisciplineId = d.id, - // // }; - // // seq++; - - // // resultData.Add(receiver); - // // } - // } - // } - return Success(); - } - catch - { - throw; - } - } - - /// - /// ออกคำสั่ง C-PM-33 เลื่อนเงินเดือนและให้ข้าราชการกรุงเทพมหานครสามัญ ได้รับเงินเดือนสูงกว่าขั้นสูงของตำแหน่งที่ได้รับแต่งตั้ง - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command33/report/excecute")] - public async Task> PostReportCommand33Execute([FromBody] ReportExecuteRequest req) - { - var data = req.refIds.Select(x => new - { - Id = x.refId, - refCommandNo = $"{x.commandNo}/{x.commandYear.ToThaiYear()}", - templateDoc = x.templateDoc, - }); - - var baseAPI = _configuration["API"]; - var apiUrl = $"{baseAPI}/salary/report/command/33/resume"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); - var result = await res.Content.ReadAsStringAsync(); - } - return Success(); - } - - /// - /// ส่งรายชื่อออกคำสั่ง C-PM-34 - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command34/report")] - public async Task> PostReportCommand34([FromBody] ReportPersonRequest req) - { - try - { - // var resultData = new List(); - // var baseAPI = _configuration["API"]; - - // foreach (var id in req.refIds) - // { - // var apiUrl = $"{baseAPI}/salary/report/command/34/{id}"; - - // var response = new PassSalaryResponse(); - // using (var client = new HttpClient()) - // { - // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - // client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - // var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - // var res = await client.SendAsync(_req); - // // var result = await res.Content.ReadAsStringAsync(); - - // // response = JsonConvert.DeserializeObject(result); - - // // var seq = 1; - // // foreach (var d in response!.result) - // // { - // // var receiver = new CommandReceiver - // // { - // // Sequence = seq, - // // CitizenId = d.citizenId, - // // Prefix = d.prefix == null ? "" : d.prefix, - // // FirstName = d.firstName, - // // LastName = d.lastName, - // // RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId), - // // RefDisciplineId = d.id, - // // }; - // // seq++; - - // // resultData.Add(receiver); - // // } - // } - // } - return Success(); - } - catch - { - throw; - } - } - - /// - /// ออกคำสั่ง C-PM-34 ให้ข้าราชการกรุงเทพมหานครสามัญได้รับค่าตอบแทนพิเศษ - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command34/report/excecute")] - public async Task> PostReportCommand34Execute([FromBody] ReportExecuteRequest req) - { - var data = req.refIds.Select(x => new - { - Id = x.refId, - refCommandNo = $"{x.commandNo}/{x.commandYear.ToThaiYear()}", - templateDoc = x.templateDoc, - }); - - var baseAPI = _configuration["API"]; - var apiUrl = $"{baseAPI}/salary/report/command/34/resume"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); - var result = await res.Content.ReadAsStringAsync(); - } - return Success(); - } - - /// - /// ส่งรายชื่อออกคำสั่ง C-PM-35 - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command35/report")] - public async Task> PostReportCommand35([FromBody] ReportPersonRequest req) - { - try - { - // var resultData = new List(); - // var baseAPI = _configuration["API"]; - - // foreach (var id in req.refIds) - // { - // var apiUrl = $"{baseAPI}/salary/report/command/35/{id}"; - - // var response = new PassSalaryResponse(); - // using (var client = new HttpClient()) - // { - // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - // client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - // var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - // var res = await client.SendAsync(_req); - // // var result = await res.Content.ReadAsStringAsync(); - - // // response = JsonConvert.DeserializeObject(result); - - // // var seq = 1; - // // foreach (var d in response!.result) - // // { - // // var receiver = new CommandReceiver - // // { - // // Sequence = seq, - // // CitizenId = d.citizenId, - // // Prefix = d.prefix == null ? "" : d.prefix, - // // FirstName = d.firstName, - // // LastName = d.lastName, - // // RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId), - // // RefDisciplineId = d.id, - // // }; - // // seq++; - - // // resultData.Add(receiver); - // // } - // } - // } - return Success(); - } - catch - { - throw; - } - } - - /// - /// ออกคำสั่ง C-PM-35 เลื่อนเงินเดือนและให้ข้าราชการกรุงเทพมหานครสามัญที่เกษียณอายุราชการ ในสิ้นปีงบประมาณ พ.ศ.……… ได้รับเงินเดือนสูงกว่าขั้นสูงของตำแหน่งที่ได้รับแต่งตั้ง - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command35/report/excecute")] - public async Task> PostReportCommand35Execute([FromBody] ReportExecuteRequest req) - { - var data = req.refIds.Select(x => new - { - Id = x.refId, - refCommandNo = $"{x.commandNo}/{x.commandYear.ToThaiYear()}", - templateDoc = x.templateDoc, - }); - - var baseAPI = _configuration["API"]; - var apiUrl = $"{baseAPI}/salary/report/command/35/resume"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); - var result = await res.Content.ReadAsStringAsync(); - } - return Success(); - } - - /// - /// ส่งรายชื่อออกคำสั่ง C-PM-36 - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command36/report")] - public async Task> PostReportCommand36([FromBody] ReportPersonRequest req) - { - try - { - // var resultData = new List(); - // var baseAPI = _configuration["API"]; - - // foreach (var id in req.refIds) - // { - // var apiUrl = $"{baseAPI}/salary/report/command/36/{id}"; - - // var response = new PassSalaryResponse(); - // using (var client = new HttpClient()) - // { - // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - // client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - // var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - // var res = await client.SendAsync(_req); - // // var result = await res.Content.ReadAsStringAsync(); - - // // response = JsonConvert.DeserializeObject(result); - - // // var seq = 1; - // // foreach (var d in response!.result) - // // { - // // var receiver = new CommandReceiver - // // { - // // Sequence = seq, - // // CitizenId = d.citizenId, - // // Prefix = d.prefix == null ? "" : d.prefix, - // // FirstName = d.firstName, - // // LastName = d.lastName, - // // RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId), - // // RefDisciplineId = d.id, - // // }; - // // seq++; - - // // resultData.Add(receiver); - // // } - // } - // } - return Success(); - } - catch - { - throw; - } - } - - /// - /// ออกคำสั่ง C-PM-36 เลื่อนขั้นค่าจ้างและให้ลูกจ้างประจำกรุงเทพมหานครได้รับอัตราค่าจ้างสูงกว่าอัตราค่าจ้างขั้นสูงของตำแหน่งที่ได้รับแต่งตั้งในแต่ละระดับ - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command36/report/excecute")] - public async Task> PostReportCommand36Execute([FromBody] ReportExecuteRequest req) - { - var data = req.refIds.Select(x => new - { - Id = x.refId, - refCommandNo = $"{x.commandNo}/{x.commandYear.ToThaiYear()}", - templateDoc = x.templateDoc, - }); - - var baseAPI = _configuration["API"]; - var apiUrl = $"{baseAPI}/salary/report/command/36/resume"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); - var result = await res.Content.ReadAsStringAsync(); - } - return Success(); - } - - /// - /// ส่งรายชื่อออกคำสั่ง C-PM-37 - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command37/report")] - public async Task> PostReportCommand37([FromBody] ReportPersonRequest req) - { - try - { - // var resultData = new List(); - // var baseAPI = _configuration["API"]; - - // foreach (var id in req.refIds) - // { - // var apiUrl = $"{baseAPI}/salary/report/command/37/{id}"; - - // var response = new PassSalaryResponse(); - // using (var client = new HttpClient()) - // { - // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - // client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - // var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - // var res = await client.SendAsync(_req); - // // var result = await res.Content.ReadAsStringAsync(); - - // // response = JsonConvert.DeserializeObject(result); - - // // var seq = 1; - // // foreach (var d in response!.result) - // // { - // // var receiver = new CommandReceiver - // // { - // // Sequence = seq, - // // CitizenId = d.citizenId, - // // Prefix = d.prefix == null ? "" : d.prefix, - // // FirstName = d.firstName, - // // LastName = d.lastName, - // // RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId), - // // RefDisciplineId = d.id, - // // }; - // // seq++; - - // // resultData.Add(receiver); - // // } - // } - // } - return Success(); - } - catch - { - throw; - } - } - - /// - /// ออกคำสั่ง C-PM-37 ให้ลูกจ้างประจำกรุงเทพมหานครได้รับค่าตอบแทนพิเศษ - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command37/report/excecute")] - public async Task> PostReportCommand37Execute([FromBody] ReportExecuteRequest req) - { - var data = req.refIds.Select(x => new - { - refCommandNo = $"{x.commandNo}/{x.commandYear.ToThaiYear()}", - templateDoc = x.templateDoc, - }); - - var baseAPI = _configuration["API"]; - var apiUrl = $"{baseAPI}/salary/report/command/37/resume"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); - var result = await res.Content.ReadAsStringAsync(); - } - return Success(); - } - /// /// ส่งรายชื่อออกคำสั่ง C-PM-38 /// From 61b6f77d85b906d11bb270868faa42fafedf0061 Mon Sep 17 00:00:00 2001 From: kittapath Date: Fri, 4 Oct 2024 22:43:49 +0700 Subject: [PATCH 32/42] =?UTF-8?q?=E0=B8=AD=E0=B8=AD=E0=B8=81=E0=B8=84?= =?UTF-8?q?=E0=B8=B3=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/OrderController.cs | 502 ------------------ .../Controllers/DisciplineResultController.cs | 4 +- 2 files changed, 2 insertions(+), 504 deletions(-) diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs index 17d5b9a5..16867ddf 100644 --- a/BMA.EHR.Command.Service/Controllers/OrderController.cs +++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs @@ -6575,507 +6575,5 @@ namespace BMA.EHR.Command.Service.Controllers } #endregion - - /// - /// ส่งรายชื่อออกคำสั่ง C-PM-11 - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command11/report")] - public async Task> PostReportCommand11([FromBody] ReportPersonRequest req_) - { - try - { - var resultData = new List(); - - var baseAPI = _configuration["Node:API"]; - var apiUrl = $"{baseAPI}/report/pass"; - - var response = new PassProbationResponse(); - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var res = await client.SendAsync(req); - var result = await res.Content.ReadAsStringAsync(); - - response = JsonConvert.DeserializeObject(result); - - var seq = 1; - foreach (var d in response!.data) - { - var _baseAPI = _configuration["API"]; - var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.person.id}"; - using (var _client = new HttpClient()) - { - _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); - var _res = await _client.SendAsync(_req); - var _result = await _res.Content.ReadAsStringAsync(); - - var org = JsonConvert.DeserializeObject(_result); - - if (org == null || org.result == null) - continue; - - var receiver = new CommandReceiver - { - Sequence = seq, - CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, - Prefix = org.result.prefix == null ? "" : org.result.prefix, - FirstName = org.result.firstName == null ? "" : org.result.firstName, - LastName = org.result.lastName == null ? "" : org.result.lastName, - RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), - }; - seq++; - resultData.Add(receiver); - } - } - } - return Success(); - } - catch - { - throw; - } - - } - - /// - /// ออกคำสั่ง C-PM-11 คำสั่งให้ข้าราชการที่มีผลการทดลองปฏิบัติหน้าที่ราชการไม่ต่ำกว่ามาตรฐานที่กำหนดรับราชการต่อไป - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command11/report/excecute")] - public async Task> PostReportCommand11Execute([FromBody] ReportExecuteRequest req) - { - // create new profile - foreach (var recv in req.refIds) - { - var baseAPI = _configuration["API"]; - var apiUrl = $"{baseAPI}/org/profile/command11/{recv.refId}"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _res = await client.PostAsJsonAsync(apiUrl, new - { - profileId = recv.refId, - date = recv.commandAffectDate, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - salaryRef = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - return Success(); - } - - /// - /// ส่งรายชื่อออกคำสั่ง C-PM-12 - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command12/report")] - public async Task> PostReportCommand12([FromBody] ReportPersonRequest req_) - { - try - { - var resultData = new List(); - - var baseAPI = _configuration["Node:API"]; - var apiUrl = $"{baseAPI}/report/not-pass"; - - var response = new PassProbationResponse(); - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var res = await client.SendAsync(req); - var result = await res.Content.ReadAsStringAsync(); - - response = JsonConvert.DeserializeObject(result); - - var seq = 1; - foreach (var d in response!.data) - { - var _baseAPI = _configuration["API"]; - var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.person.id}"; - using (var _client = new HttpClient()) - { - _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); - var _res = await _client.SendAsync(_req); - var _result = await _res.Content.ReadAsStringAsync(); - - var org = JsonConvert.DeserializeObject(_result); - - if (org == null || org.result == null) - continue; - - var receiver = new CommandReceiver - { - Sequence = seq, - CitizenId = org.result.citizenId == null ? "" : org.result.citizenId, - Prefix = org.result.prefix == null ? "" : org.result.prefix, - FirstName = org.result.firstName == null ? "" : org.result.firstName, - LastName = org.result.lastName == null ? "" : org.result.lastName, - RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId), - }; - seq++; - resultData.Add(receiver); - } - } - } - - return Success(); - } - catch - { - throw; - } - } - - /// - /// ออกคำสั่ง C-PM-12 คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command12/report/excecute")] - public async Task> PostReportCommand12Execute([FromBody] ReportExecuteRequest req) - { - // create new profile - foreach (var recv in req.refIds) - { - var baseAPI = _configuration["API"]; - var apiUrl = $"{baseAPI}/org/profile/command12/{recv.refId}"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _res = await client.PostAsJsonAsync(apiUrl, new - { - profileId = recv.refId, - date = recv.commandAffectDate, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - salaryRef = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - return Success(); - } - - /// - /// ส่งรายชื่อออกคำสั่ง C-PM-21 - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command21/report")] - public async Task> PostReportcommand21([FromBody] ReportPersonRequest req_) - { - try - { - var resultData = new List(); - - var baseAPI = _configuration["API"]; - var apiUrl = $"{baseAPI}/org/profile-employee/report-temp"; - - var response = new PassSalaryResponse(); - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var res = await client.SendAsync(req); - var result = await res.Content.ReadAsStringAsync(); - - response = JsonConvert.DeserializeObject(result); - - var seq = 1; - foreach (var d in response!.result) - { - var receiver = new CommandReceiver - { - Sequence = seq, - CitizenId = d.citizenId, - Prefix = d.prefix == null ? "" : d.prefix, - FirstName = d.firstName == null ? "" : d.firstName, - LastName = d.lastName == null ? "" : d.lastName, - RefPlacementProfileId = d.id, - RefDisciplineId = d.id, - Organization = d.organization, - PositionName = d.positionName, - PositionLevel = d.positionLevel, - PositionType = d.positionType, - PositionNumber = d.positionNumber, - BirthDate = d.birthDate, - }; - seq++; - - resultData.Add(receiver); - } - } - - return Success(); - } - catch - { - throw; - } - } - - /// - /// ออกคำสั่ง C-PM-21 คำสั่งแต่งตั้งลูกจ้างชั่วคราวเป็นลูกจ้างประจำ - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command21/report/excecute")] - public async Task> PostReportCommand21Execute([FromBody] ReportExecuteRequest req) - { - var data = req.refIds.Select(x => new - { - id = x.refId, - amount = x.amount, - positionSalaryAmount = x.positionSalaryAmount, - mouthSalaryAmount = x.mouthSalaryAmount, - refCommandNo = $"{x.commandNo}/{x.commandYear.ToThaiYear()}", - templateDoc = x.templateDoc, - }); - var baseAPI = _configuration["API"]; - var apiUrl = $"{baseAPI}/org/profile-employee/report/resume"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var res = await client.PostAsJsonAsync(apiUrl, new { result = data }); - var result = await res.Content.ReadAsStringAsync(); - } - return Success(); - } - - /// - /// ส่งรายชื่อออกคำสั่ง C-PM-38 - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command38/report")] - public async Task> PostReportCommand38([FromBody] ReportPersonRequest req) - { - try - { - // var resultData = new List(); - // var baseAPI = _configuration["API"]; - - // foreach (var id in req.refIds) - // { - // var apiUrl = $"{baseAPI}/salary/report/command/38/{id}"; - - // var response = new PassSalaryResponse(); - // using (var client = new HttpClient()) - // { - // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - // client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - // var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - // var res = await client.SendAsync(_req); - // // var result = await res.Content.ReadAsStringAsync(); - - // // response = JsonConvert.DeserializeObject(result); - - // // var seq = 1; - // // foreach (var d in response!.result) - // // { - // // var receiver = new CommandReceiver - // // { - // // Sequence = seq, - // // CitizenId = d.citizenId, - // // Prefix = d.prefix == null ? "" : d.prefix, - // // FirstName = d.firstName, - // // LastName = d.lastName, - // // RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId), - // // RefDisciplineId = d.id, - // // }; - // // seq++; - - // // resultData.Add(receiver); - // // } - // } - // } - return Success(); - } - catch - { - throw; - } - } - - /// - /// ออกคำสั่ง C-PM-38 แต่งตั้งข้าราชการให้ดำรงตำแหน่ง - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command38/report/excecute")] - public async Task> PostReportCommand38Execute([FromBody] ReportExecuteRequest req) - { - return Success(); - } - - /// - /// ส่งรายชื่อออกคำสั่ง C-PM-40 - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command40/report")] - public async Task> PostReportCommand40([FromBody] ReportPersonRequest req) - { - try - { - // var resultData = new List(); - // var baseAPI = _configuration["API"]; - // var apiUrl = $"{baseAPI}/org/pos/act/profile"; - - // var response = new PassSalaryResponse(); - // using (var client = new HttpClient()) - // { - // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - // client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - // var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - // var res = await client.SendAsync(_req); - // // var result = await res.Content.ReadAsStringAsync(); - - // // response = JsonConvert.DeserializeObject(result); - - // // var seq = 1; - // // foreach (var d in response!.result) - // // { - // // var receiver = new CommandReceiver - // // { - // // Sequence = seq, - // // CitizenId = d.citizenId, - // // Prefix = d.prefix == null ? "" : d.prefix, - // // FirstName = d.firstName, - // // LastName = d.lastName, - // // RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId), - // // RefDisciplineId = d.id, - // // }; - // // seq++; - - // // resultData.Add(receiver); - // // } - // } - return Success(); - } - catch - { - throw; - } - } - - /// - /// เอกสารแนบท้าย C-PM-40 - /// - /// Record Id ของคำสั่ง - /// pdf, docx หรือ xlsx - /// - /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command40/report/attachment")] - [AllowAnonymous] - [ProducesResponseType(StatusCodes.Status200OK)] - [ProducesResponseType(StatusCodes.Status401Unauthorized)] - [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> PostReportCommand40Attachment([FromBody] ReportAttachmentRequest req) - { - try - { - var data = new List(); - var no = 1; - foreach (var d in req.refIds) - { - var apiUrl = $"{_configuration["API"]}/org/pos/act/{d.refId}"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var _res = await client.SendAsync(_req); - var _result = await _res.Content.ReadAsStringAsync(); - - var org = JsonConvert.DeserializeObject(_result); - - if (org == null || org.result == null) - continue; - var receiver = new CommandType40Response - { - no = no.ToString().ToThaiNumber(), - fullName = $"{org.result.prefix}{org.result.firstName} {org.result.lastName}", - organization = org.result.organization, - position = org.result.position, - postype = org.result.postype, - poslevel = org.result.poslevel, - organizationNew = org.result.organizationNew, - // dateStart = d.Command.ActStartDate == null ? "-" : d.Command.ActStartDate.Value.ToThaiFullDate3().ToThaiNumber(), - // dateEnd = d.Command.ActEndDate == null ? "-" : d.Command.ActEndDate.Value.ToThaiFullDate3().ToThaiNumber(), - dateStart = "xxx", - dateEnd = "xxx", - order = org.result.order, - }; - no = no + 1; - - data.Add(receiver); - } - } - return Success(data); - } - catch - { - throw; - } - } - - /// - /// ออกคำสั่ง C-PM-40 คำสั่งให้ข้าราชการรักษาการในตำแหน่ง - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("command40/report/excecute")] - public async Task> PostReportCommand40Execute([FromBody] ReportExecuteRequest req) - { - return Success(); - } } } diff --git a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs index f0a754d0..4d5998c4 100644 --- a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs +++ b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs @@ -1501,12 +1501,12 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers try { var data1 = await _context.DisciplineInvestigate_ProfileComplaints - .Where(x => req.refIds.Contains(x.DisciplineInvestigate.DisciplineComplaint.Id.ToString())) + .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); data1.ForEach(profile => profile.IsReport = "REPORT"); var data2 = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates - .Where(x => req.refIds.Contains(x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id.ToString())) + .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); data2.ForEach(profile => profile.IsReport = "REPORT"); From d1289601114ca83a034719c43c6a30d4446caed2 Mon Sep 17 00:00:00 2001 From: Bright Date: Mon, 7 Oct 2024 17:05:12 +0700 Subject: [PATCH 33/42] =?UTF-8?q?=E0=B8=A5=E0=B8=9A=E0=B8=A3=E0=B8=B2?= =?UTF-8?q?=E0=B8=A2=E0=B8=8A=E0=B8=B7=E0=B9=88=E0=B8=AD=E0=B8=AD=E0=B8=AD?= =?UTF-8?q?=E0=B8=81=E0=B8=84=E0=B8=B3=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/DisciplineResultController.cs | 264 ++++++++++++++++++ .../PlacementAppointmentController.cs | 102 +++++++ .../Controllers/PlacementController.cs | 100 +++++++ .../Controllers/PlacementOfficerController.cs | 20 ++ .../Controllers/PlacementReceiveController.cs | 20 ++ .../PlacementTransferController.cs | 20 ++ .../Controllers/RetirementOtherController.cs | 40 +++ .../Controllers/RetirementOutController.cs | 20 ++ .../Controllers/RetirementResignController.cs | 58 ++++ 9 files changed, 644 insertions(+) diff --git a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs index 4d5998c4..30bd1142 100644 --- a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs +++ b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs @@ -758,6 +758,26 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers return Success(); } + /// + /// ลบรายชื่อออกคำสั่ง C-PM-19 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command19/report/delete")] + public async Task> PostReportDeleteCommand19([FromBody] ReportPersonRequest req) + { + var data = await _context.DisciplineReport_Profiles + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Status.ToUpper() == "REPORT") + .ToListAsync(); + data.ForEach(profile => profile.Status = "APPROVE"); + await _context.SaveChangesAsync(); + return Success(); + } + /// /// ออกคำสั่ง C-PM-19 คำสั่งปลดออกจากราชการ /// @@ -830,6 +850,26 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers return Success(); } + /// + /// ลบรายชื่อออกคำสั่ง C-PM-20 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command20/report/delete")] + public async Task> PostReportDeletecommand20([FromBody] ReportPersonRequest req) + { + var data = await _context.DisciplineReport_Profiles + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Status.ToUpper() == "REPORT") + .ToListAsync(); + data.ForEach(profile => profile.Status = "APPROVE"); + await _context.SaveChangesAsync(); + return Success(); + } + /// /// ออกคำสั่ง C-PM-20 คำสั่งไล่ออกจากราชการ /// @@ -909,6 +949,33 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers } } + /// + /// ลบรายชื่อออกคำสั่ง C-PM-25 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command25/report/delete")] + public async Task> PostReportDeleteCommand25([FromBody] ReportPersonRequest req) + { + try + { + var data = await _context.DisciplineReport_Profiles + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Status.ToUpper() =="REPORT") + .ToListAsync(); + data.ForEach(profile => profile.Status = "APPROVE"); + await _context.SaveChangesAsync(); + return Success(); + } + catch + { + throw; + } + } + /// /// เอกสารแนบท้าย C-PM-25 /// @@ -1032,6 +1099,33 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers } } + /// + /// ลบรายชื่อออกคำสั่ง C-PM-26 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command26/report/delete")] + public async Task> PostReportDeleteCommand26([FromBody] ReportPersonRequest req) + { + try + { + var data = await _context.DisciplineReport_Profiles + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Status.ToUpper() == "REPORT") + .ToListAsync(); + data.ForEach(profile => profile.Status = "APPROVE"); + await _context.SaveChangesAsync(); + return Success(); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-26 คำสั่งให้ออกจากราชการไว้ก่อน /// @@ -1113,6 +1207,33 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers } } + /// + /// ลบรายชื่อออกคำสั่ง C-PM-27 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command27/report/delete")] + public async Task> PostReportDeleteCommand27([FromBody] ReportPersonRequest req) + { + try + { + var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Where(x => req.refIds.Contains(x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id.ToString())) + .Where(x => x.Status.ToUpper() == "REPORT") + .ToListAsync(); + data.ForEach(profile => profile.Status = "APPROVE"); + await _context.SaveChangesAsync(); + return Success(); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-27 คำสั่งลงโทษ ภาคทัณฑ์ /// @@ -1193,6 +1314,33 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers } } + /// + /// ลบรายชื่อออกคำสั่ง C-PM-28 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command28/report/delete")] + public async Task> PostReportDeleteCommand28([FromBody] ReportPersonRequest req) + { + try + { + var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Where(x => req.refIds.Contains(x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id.ToString())) + .Where(x => x.Status.ToUpper() == "REPORT") + .ToListAsync(); + data.ForEach(profile => profile.Status = "APPROVE"); + await _context.SaveChangesAsync(); + return Success(); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-28 คำสั่งลงโทษ ตัดเงินเดือน /// @@ -1273,6 +1421,33 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers } } + /// + /// ลบรายชื่อออกคำสั่ง C-PM-29 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command29/report/delete")] + public async Task> PostReportDeleteCommand29([FromBody] ReportPersonRequest req) + { + try + { + var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Where(x => req.refIds.Contains(x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id.ToString())) + .Where(x => x.Status.ToUpper() == "REPORT") + .ToListAsync(); + data.ForEach(profile => profile.Status = "APPROVE"); + await _context.SaveChangesAsync(); + return Success(); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-29 คำสั่งลงโทษ ลดขั้นเงินเดือน /// @@ -1353,6 +1528,33 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers } } + /// + /// ลบรายชื่อออกคำสั่ง C-PM-30 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command30/report/delete")] + public async Task> PostReportDeleteCommand30([FromBody] ReportPersonRequest req) + { + try + { + var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Where(x => req.refIds.Contains(x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id.ToString())) + .Where(x => x.Status.ToUpper() == "REPORT") + .ToListAsync(); + data.ForEach(profile => profile.Status = "APPROVE"); + await _context.SaveChangesAsync(); + return Success(); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-30 คำสั่งเพิ่มโทษ /// @@ -1433,6 +1635,33 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers } } + /// + /// ลบรายชื่อออกคำสั่ง C-PM-31 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command31/report/delete")] + public async Task> PostReportDeleteCommand31([FromBody] ReportPersonRequest req) + { + try + { + var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Where(x => req.refIds.Contains(x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id.ToString())) + .Where(x => x.Status.ToUpper() == "REPORT") + .ToListAsync(); + data.ForEach(profile => profile.Status = "APPROVE"); + await _context.SaveChangesAsync(); + return Success(); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-31 คำสั่งงดโทษ /// @@ -1520,6 +1749,41 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers } } + /// + /// ลบรายชื่อออกคำสั่ง C-PM-32 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command32/report/delete")] + public async Task> PostReportDeleteCommand32([FromBody] ReportPersonRequest req) + { + try + { + var data1 = await _context.DisciplineInvestigate_ProfileComplaints + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.IsReport == "REPORT") + .ToListAsync(); + + data1.ForEach(profile => profile.IsReport = "APPROVE"); + var data2 = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.IsReport == "REPORT") + .ToListAsync(); + + data2.ForEach(profile => profile.IsReport = "APPROVE"); + + await _context.SaveChangesAsync(); + return Success(); + } + catch + { + throw; + } + } + /// /// ออกคำสั่ง C-PM-32 คำสั่งยุติเรื่อง /// diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs index c7fd9ad3..699d5ddd 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs @@ -762,6 +762,26 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// ลบรายชื่อออกคำสั่ง C-PM-05 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("appoint/report/delete")] + public async Task> PostReportDeleteAppoint([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.PlacementAppointments + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Status.ToUpper() == "REPORT") + .ToListAsync(); + placementProfiles.ForEach(profile => profile.Status = "APPROVE"); + await _context.SaveChangesAsync(); + return Success(); + } + /// /// เอกสารแนบท้าย C-PM-05 /// @@ -904,6 +924,26 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// ลบรายชื่อออกคำสั่ง C-PM-06 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("slip/report/delete")] + public async Task> PostReportDeleteSlip([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.PlacementAppointments + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Status.ToUpper() == "REPORT") + .ToListAsync(); + placementProfiles.ForEach(profile => profile.Status = "APPROVE"); + await _context.SaveChangesAsync(); + return Success(); + } + /// /// เอกสารแนบท้าย C-PM-06 /// @@ -1046,6 +1086,26 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// ลบรายชื่อออกคำสั่ง C-PM-07 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("move/report/delete")] + public async Task> PostReportDeleteMove([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.PlacementAppointments + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Status.ToUpper() == "REPORT") + .ToListAsync(); + placementProfiles.ForEach(profile => profile.Status = "APPROVE"); + await _context.SaveChangesAsync(); + return Success(); + } + /// /// เอกสารแนบท้าย C-PM-07 /// @@ -1189,6 +1249,27 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// ลบรายชื่อออกคำสั่ง C-PM-22 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("employee-appoint/report/delete")] + public async Task> PostReportDeleteEmployeeAppoint([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.PlacementAppointments + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.type == "EMPLOYEE") + .Where(x => x.Status.ToUpper() == "REPORT") + .ToListAsync(); + placementProfiles.ForEach(profile => profile.Status = "APPROVE"); + await _context.SaveChangesAsync(); + return Success(); + } + /// /// เอกสารแนบท้าย C-PM-22 /// @@ -1325,6 +1406,27 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// ลบรายชื่อออกคำสั่ง C-PM-24 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("employee-move/report/delete")] + public async Task> PostReportDeleteEmployeeMove([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.PlacementAppointments + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.type == "EMPLOYEE") + .Where(x => x.Status.ToUpper() == "REPORT") + .ToListAsync(); + placementProfiles.ForEach(profile => profile.Status = "APPROVE"); + await _context.SaveChangesAsync(); + return Success(); + } + /// /// เอกสารแนบท้าย C-PM-24 /// diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index 067dae21..c8f93b8c 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -1484,6 +1484,26 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// ลบรายชื่อออกคำสั่ง C-PM-01 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("recruit/report/delete")] + public async Task> PostReportDeleteRecruit([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.PlacementProfiles + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.PlacementStatus.ToUpper() == "PREPARE-CONTAIN") + .ToListAsync(); + placementProfiles.ForEach(profile => profile.PlacementStatus = "PREPARE-CONTAIN"); + await _context.SaveChangesAsync(); + return Success(); + } + /// /// เอกสารแนบท้าย C-PM-01 /// @@ -1757,6 +1777,26 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// ลบรายชื่อออกคำสั่ง C-PM-02 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("candidate/report/delete")] + public async Task> PostReportDeleteCandidate([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.PlacementProfiles + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.PlacementStatus.ToUpper() == "PREPARE-CONTAIN") + .ToListAsync(); + placementProfiles.ForEach(profile => profile.PlacementStatus = "PREPARE-CONTAIN"); + await _context.SaveChangesAsync(); + return Success(); + } + /// /// เอกสารแนบท้าย C-PM-02 /// @@ -2029,6 +2069,26 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// ลบรายชื่อออกคำสั่ง C-PM-03 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("appoint/report/delete")] + public async Task> PostReportDeleteAppoint([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.PlacementProfiles + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.PlacementStatus.ToUpper() == "PREPARE-CONTAIN") + .ToListAsync(); + placementProfiles.ForEach(profile => profile.PlacementStatus = "PREPARE-CONTAIN"); + await _context.SaveChangesAsync(); + return Success(); + } + /// /// เอกสารแนบท้าย C-PM-03 /// @@ -2185,6 +2245,26 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// ลบรายชื่อออกคำสั่ง C-PM-04 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("move/report/delete")] + public async Task> PostReportDeleteMove([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.PlacementProfiles + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.PlacementStatus.ToUpper() == "PREPARE-CONTAIN") + .ToListAsync(); + placementProfiles.ForEach(profile => profile.PlacementStatus = "PREPARE-CONTAIN"); + await _context.SaveChangesAsync(); + return Success(); + } + /// /// เอกสารแนบท้าย C-PM-04 /// @@ -2339,6 +2419,26 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// ลบรายชื่อออกคำสั่ง C-PM-39 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("slip/report/delete")] + public async Task> PostReportDeleteSlip([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.PlacementProfiles + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.PlacementStatus.ToUpper() == "PREPARE-CONTAIN") + .ToListAsync(); + placementProfiles.ForEach(profile => profile.PlacementStatus = "PREPARE-CONTAIN"); + await _context.SaveChangesAsync(); + return Success(); + } + /// /// เอกสารแนบท้าย C-PM-39 /// diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs index 1cd048e4..95ea3a91 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs @@ -588,6 +588,26 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// ลบรายชื่อออกคำสั่ง C-PM-15 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command/report/delete")] + public async Task> PostReportDelete([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.PlacementOfficers + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Status.ToUpper() == "REPORT") + .ToListAsync(); + placementProfiles.ForEach(profile => profile.Status = "APPROVE"); + await _context.SaveChangesAsync(); + return Success(); + } + /// /// เอกสารแนบท้าย C-PM-15 /// diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs index a4c5bcd4..1483572c 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs @@ -899,6 +899,26 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// ลบรายชื่อออกคำสั่ง C-PM-14 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command/report/delete")] + public async Task> PostReportDelete([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.PlacementReceives + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Status.ToUpper() == "REPORT") + .ToListAsync(); + placementProfiles.ForEach(profile => profile.Status = "APPROVE"); + await _context.SaveChangesAsync(); + return Success(); + } + /// /// เอกสารแนบท้าย C-PM-14 /// diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs index 58c4a3a2..c447495f 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs @@ -778,6 +778,26 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// ลบรายชื่อออกคำสั่ง C-PM-13 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command/report/delete")] + public async Task> PostReportDelete([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.PlacementTransfers + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Status.ToUpper() == "REPORT") + .ToListAsync(); + placementProfiles.ForEach(profile => profile.Status = "REPORTREPORT"); + await _context.SaveChangesAsync(); + return Success(); + } + /// /// เอกสารแนบท้าย C-PM-13 /// diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs index b3a130c8..8ec26491 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs @@ -645,6 +645,26 @@ namespace BMA.EHR.Retirement.Service.Controllers return Success(); } + /// + /// ลบรายชื่อออกคำสั่ง C-PM-08 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("appoint/report/delete")] + public async Task> PostReportDeleteAppoint([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.RetirementOthers + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Status.ToUpper() == "REPORT") + .ToListAsync(); + placementProfiles.ForEach(profile => profile.Status = "APPROVE"); + await _context.SaveChangesAsync(); + return Success(); + } + /// /// เอกสารแนบท้าย C-PM-08 /// @@ -780,6 +800,26 @@ namespace BMA.EHR.Retirement.Service.Controllers return Success(); } + /// + /// ลบรายชื่อออกคำสั่ง C-PM-09 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("out/report/delete")] + public async Task> PostReportDeleteOut([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.RetirementOthers + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Status.ToUpper() == "REPORT") + .ToListAsync(); + placementProfiles.ForEach(profile => profile.Status = "APPROVE"); + await _context.SaveChangesAsync(); + return Success(); + } + /// /// เอกสารแนบท้าย C-PM-09 /// diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs index d059ad26..ec8982d5 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs @@ -486,6 +486,26 @@ namespace BMA.EHR.Retirement.Service.Controllers return Success(); } + /// + /// ลบรายชื่อออกคำสั่ง C-PM-18 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command/report/delete")] + public async Task> PostDeleteReport([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.RetirementResigns + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Status.ToUpper() == "REPORT") + .ToListAsync(); + placementProfiles.ForEach(profile => profile.Status = "APPROVE"); + await _context.SaveChangesAsync(); + return Success(); + } + /// /// ออกคำสั่ง C-PM-18 คำสั่งให้ออกจากราชการ /// diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs index 277025a4..dc2b4cb9 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs @@ -1645,6 +1645,25 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda await _context.SaveChangesAsync(); return Success(); } + /// + /// ลบรายชื่อออกคำสั่ง C-PM-17 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command/report/delete")] + public async Task> PostReportDelete([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.RetirementResigns + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Status.ToUpper() == "REPORT") + .ToListAsync(); + placementProfiles.ForEach(profile => profile.Status = "APPROVE"); + await _context.SaveChangesAsync(); + return Success(); + } /// /// เอกสารแนบท้าย C-PM-17 @@ -1771,6 +1790,26 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda return Success(); } + /// + /// ลบรายชื่อออกคำสั่ง C-PM-23 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("employee/report/delete")] + public async Task> PostReportDeleteEmployee([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.RetirementResigns + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Status.ToUpper() == "REPORT") + .ToListAsync(); + placementProfiles.ForEach(profile => profile.Status = "APPROVE"); + await _context.SaveChangesAsync(); + return Success(); + } + /// /// เอกสารแนบท้าย C-PM-23 /// @@ -1893,6 +1932,25 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda return Success(); } + /// + /// ลบรายชื่อออกคำสั่ง C-PM-41 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("leave-cancel/report/delete")] + public async Task> PostReportDeleteLeaveCancel([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.RetirementResigns + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Status.ToUpper() == "DONECANCEL") + .ToListAsync(); + placementProfiles.ForEach(profile => profile.Status = "DONE"); + await _context.SaveChangesAsync(); + return Success(); + } /// /// เอกสารแนบท้าย C-PM-41 /// From 85d9754db65a1196b45ee91e5770efc93cfb60cf Mon Sep 17 00:00:00 2001 From: kittapath Date: Mon, 7 Oct 2024 22:35:34 +0700 Subject: [PATCH 34/42] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B8=AD?= =?UTF-8?q?=E0=B8=AD=E0=B8=81=E0=B8=84=E0=B8=B3=E0=B8=AA=E0=B8=B1=E0=B9=88?= =?UTF-8?q?=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/DisciplineResultController.cs | 144 +++++++++--------- .../PlacementAppointmentController.cs | 10 +- .../Controllers/PlacementController.cs | 40 ++--- .../Controllers/PlacementReceiveController.cs | 2 +- .../PlacementRepatriationController.cs | 19 +++ .../PlacementTransferController.cs | 2 +- .../Controllers/RetirementOtherController.cs | 4 +- .../Controllers/RetirementResignController.cs | 6 +- 8 files changed, 124 insertions(+), 103 deletions(-) diff --git a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs index 30bd1142..749394de 100644 --- a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs +++ b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs @@ -750,9 +750,9 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers [HttpPost("command19/report")] public async Task> PostReportCommand19([FromBody] ReportPersonRequest req) { - var data = await _context.DisciplineReport_Profiles - .Where(x => req.refIds.Contains(x.Id.ToString())) - .ToListAsync(); + var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Where(x => req.refIds.Contains(x.Id.ToString())) + .ToListAsync(); data.ForEach(profile => profile.Status = "REPORT"); await _context.SaveChangesAsync(); return Success(); @@ -769,11 +769,11 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers [HttpPost("command19/report/delete")] public async Task> PostReportDeleteCommand19([FromBody] ReportPersonRequest req) { - var data = await _context.DisciplineReport_Profiles - .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Status.ToUpper() == "REPORT") - .ToListAsync(); - data.ForEach(profile => profile.Status = "APPROVE"); + var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Status.ToUpper() == "REPORT") + .ToListAsync(); + data.ForEach(profile => profile.Status = "NEW"); await _context.SaveChangesAsync(); return Success(); } @@ -790,9 +790,9 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers public async Task> PostReportCommand19Execute([FromBody] ReportExecuteRequest req) { var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates - .Include(x => x.DisciplineDisciplinary) - .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) - .ToListAsync(); + .Include(x => x.DisciplineDisciplinary) + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); var resultData = (from p in data join r in req.refIds on p.Id.ToString() equals r.refId @@ -842,9 +842,9 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers [HttpPost("command20/report")] public async Task> PostReportcommand20([FromBody] ReportPersonRequest req) { - var data = await _context.DisciplineReport_Profiles - .Where(x => req.refIds.Contains(x.Id.ToString())) - .ToListAsync(); + var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Where(x => req.refIds.Contains(x.Id.ToString())) + .ToListAsync(); data.ForEach(profile => profile.Status = "REPORT"); await _context.SaveChangesAsync(); return Success(); @@ -861,11 +861,11 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers [HttpPost("command20/report/delete")] public async Task> PostReportDeletecommand20([FromBody] ReportPersonRequest req) { - var data = await _context.DisciplineReport_Profiles - .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Status.ToUpper() == "REPORT") - .ToListAsync(); - data.ForEach(profile => profile.Status = "APPROVE"); + var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Status.ToUpper() == "REPORT") + .ToListAsync(); + data.ForEach(profile => profile.Status = "NEW"); await _context.SaveChangesAsync(); return Success(); } @@ -882,9 +882,9 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers public async Task> PostReportCommand20Execute([FromBody] ReportExecuteRequest req) { var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates - .Include(x => x.DisciplineDisciplinary) - .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) - .ToListAsync(); + .Include(x => x.DisciplineDisciplinary) + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); var resultData = (from p in data join r in req.refIds on p.Id.ToString() equals r.refId @@ -937,8 +937,8 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers try { var data = await _context.DisciplineReport_Profiles - .Where(x => req.refIds.Contains(x.Id.ToString())) - .ToListAsync(); + .Where(x => req.refIds.Contains(x.Id.ToString())) + .ToListAsync(); data.ForEach(profile => profile.Status = "REPORT"); await _context.SaveChangesAsync(); return Success(); @@ -963,10 +963,10 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers try { var data = await _context.DisciplineReport_Profiles - .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Status.ToUpper() =="REPORT") - .ToListAsync(); - data.ForEach(profile => profile.Status = "APPROVE"); + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Status.ToUpper() == "REPORT") + .ToListAsync(); + data.ForEach(profile => profile.Status = "PENDING"); await _context.SaveChangesAsync(); return Success(); } @@ -995,9 +995,9 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers try { var data = await _context.DisciplineReport_Profiles - .Where(x => x.Status == "REPORT") - .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) - .ToListAsync(); + .Where(x => x.Status == "REPORT") + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); var resultData = (from p in data join r in req.refIds @@ -1087,8 +1087,8 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers try { var data = await _context.DisciplineReport_Profiles - .Where(x => req.refIds.Contains(x.Id.ToString())) - .ToListAsync(); + .Where(x => req.refIds.Contains(x.Id.ToString())) + .ToListAsync(); data.ForEach(profile => profile.Status = "REPORT"); await _context.SaveChangesAsync(); return Success(); @@ -1113,10 +1113,10 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers try { var data = await _context.DisciplineReport_Profiles - .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Status.ToUpper() == "REPORT") - .ToListAsync(); - data.ForEach(profile => profile.Status = "APPROVE"); + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.Status.ToUpper() == "REPORT") + .ToListAsync(); + data.ForEach(profile => profile.Status = "PENDING"); await _context.SaveChangesAsync(); return Success(); } @@ -1139,10 +1139,10 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers { var data = await _context.DisciplineReport_Profiles - .Include(x => x.DisciplineDisciplinary) - .Where(x => x.Status == "REPORT") - .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) - .ToListAsync(); + .Include(x => x.DisciplineDisciplinary) + .Where(x => x.Status == "REPORT") + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); var resultData = (from p in data join r in req.refIds on p.Id.ToString() equals r.refId @@ -1195,7 +1195,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers try { var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates - .Where(x => req.refIds.Contains(x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id.ToString())) + .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); data.ForEach(profile => profile.Status = "REPORT"); await _context.SaveChangesAsync(); @@ -1221,10 +1221,10 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers try { var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates - .Where(x => req.refIds.Contains(x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id.ToString())) + .Where(x => req.refIds.Contains(x.Id.ToString())) .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); - data.ForEach(profile => profile.Status = "APPROVE"); + data.ForEach(profile => profile.Status = "NEW"); await _context.SaveChangesAsync(); return Success(); } @@ -1246,9 +1246,9 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers public async Task> PostReportCommand27Execute([FromBody] ReportExecuteRequest req) { var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates - .Include(x => x.DisciplineDisciplinary) - .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) - .ToListAsync(); + .Include(x => x.DisciplineDisciplinary) + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); string? _null = null; var resultData = (from p in data join r in req.refIds @@ -1302,7 +1302,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers try { var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates - .Where(x => req.refIds.Contains(x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id.ToString())) + .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); data.ForEach(profile => profile.Status = "REPORT"); await _context.SaveChangesAsync(); @@ -1328,10 +1328,10 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers try { var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates - .Where(x => req.refIds.Contains(x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id.ToString())) + .Where(x => req.refIds.Contains(x.Id.ToString())) .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); - data.ForEach(profile => profile.Status = "APPROVE"); + data.ForEach(profile => profile.Status = "NEW"); await _context.SaveChangesAsync(); return Success(); } @@ -1353,9 +1353,9 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers public async Task> PostReportCommand28Execute([FromBody] ReportExecuteRequest req) { var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates - .Include(x => x.DisciplineDisciplinary) - .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) - .ToListAsync(); + .Include(x => x.DisciplineDisciplinary) + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); string? _null = null; var resultData = (from p in data join r in req.refIds @@ -1409,7 +1409,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers try { var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates - .Where(x => req.refIds.Contains(x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id.ToString())) + .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); data.ForEach(profile => profile.Status = "REPORT"); await _context.SaveChangesAsync(); @@ -1435,10 +1435,10 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers try { var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates - .Where(x => req.refIds.Contains(x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id.ToString())) + .Where(x => req.refIds.Contains(x.Id.ToString())) .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); - data.ForEach(profile => profile.Status = "APPROVE"); + data.ForEach(profile => profile.Status = "NEW"); await _context.SaveChangesAsync(); return Success(); } @@ -1460,9 +1460,9 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers public async Task> PostReportCommand29Execute([FromBody] ReportExecuteRequest req) { var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates - .Include(x => x.DisciplineDisciplinary) - .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) - .ToListAsync(); + .Include(x => x.DisciplineDisciplinary) + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); string? _null = null; var resultData = (from p in data join r in req.refIds @@ -1516,7 +1516,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers try { var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates - .Where(x => req.refIds.Contains(x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id.ToString())) + .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); data.ForEach(profile => profile.Status = "REPORT"); await _context.SaveChangesAsync(); @@ -1542,10 +1542,10 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers try { var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates - .Where(x => req.refIds.Contains(x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id.ToString())) + .Where(x => req.refIds.Contains(x.Id.ToString())) .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); - data.ForEach(profile => profile.Status = "APPROVE"); + data.ForEach(profile => profile.Status = "NEW"); await _context.SaveChangesAsync(); return Success(); } @@ -1623,9 +1623,9 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers try { var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates - .Where(x => req.refIds.Contains(x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id.ToString())) + .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); - data.ForEach(profile => profile.Status = "REPORT"); + data.ForEach(profile => profile.StatusDiscard = "REPORT"); await _context.SaveChangesAsync(); return Success(); } @@ -1649,10 +1649,10 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers try { var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates - .Where(x => req.refIds.Contains(x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id.ToString())) - .Where(x => x.Status.ToUpper() == "REPORT") + .Where(x => req.refIds.Contains(x.Id.ToString())) + .Where(x => x.StatusDiscard.ToUpper() == "REPORT") .ToListAsync(); - data.ForEach(profile => profile.Status = "APPROVE"); + data.ForEach(profile => profile.StatusDiscard = "NEW"); await _context.SaveChangesAsync(); return Success(); } @@ -1709,7 +1709,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers var _result = await _res.Content.ReadAsStringAsync(); if (_res.IsSuccessStatusCode) { - data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; }); + data.ForEach(profile => { profile.StatusDiscard = "NEW"; profile.CommandTypeId = null; }); await _context.SaveChangesAsync(); } } @@ -1767,13 +1767,13 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers .Where(x => x.IsReport == "REPORT") .ToListAsync(); - data1.ForEach(profile => profile.IsReport = "APPROVE"); + data1.ForEach(profile => profile.IsReport = "NEW"); var data2 = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates .Where(x => req.refIds.Contains(x.Id.ToString())) .Where(x => x.IsReport == "REPORT") .ToListAsync(); - data2.ForEach(profile => profile.IsReport = "APPROVE"); + data2.ForEach(profile => profile.IsReport = "NEW"); await _context.SaveChangesAsync(); return Success(); @@ -1831,7 +1831,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers var _result = await _res.Content.ReadAsStringAsync(); if (_res.IsSuccessStatusCode) { - data.ForEach(profile => profile.IsReport = "NEW"); + data.ForEach(profile => profile.IsReport = "DONE"); await _context.SaveChangesAsync(); } } @@ -1869,7 +1869,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers var _result = await _res.Content.ReadAsStringAsync(); if (_res.IsSuccessStatusCode) { - data1.ForEach(profile => profile.IsReport = "NEW"); + data1.ForEach(profile => profile.IsReport = "DONE"); await _context.SaveChangesAsync(); } } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs index 699d5ddd..22c0a386 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs @@ -777,7 +777,7 @@ namespace BMA.EHR.Placement.Service.Controllers .Where(x => req.refIds.Contains(x.Id.ToString())) .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); - placementProfiles.ForEach(profile => profile.Status = "APPROVE"); + placementProfiles.ForEach(profile => profile.Status = "PENDING"); await _context.SaveChangesAsync(); return Success(); } @@ -939,7 +939,7 @@ namespace BMA.EHR.Placement.Service.Controllers .Where(x => req.refIds.Contains(x.Id.ToString())) .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); - placementProfiles.ForEach(profile => profile.Status = "APPROVE"); + placementProfiles.ForEach(profile => profile.Status = "PENDING"); await _context.SaveChangesAsync(); return Success(); } @@ -1101,7 +1101,7 @@ namespace BMA.EHR.Placement.Service.Controllers .Where(x => req.refIds.Contains(x.Id.ToString())) .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); - placementProfiles.ForEach(profile => profile.Status = "APPROVE"); + placementProfiles.ForEach(profile => profile.Status = "PENDING"); await _context.SaveChangesAsync(); return Success(); } @@ -1265,7 +1265,7 @@ namespace BMA.EHR.Placement.Service.Controllers .Where(x => x.type == "EMPLOYEE") .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); - placementProfiles.ForEach(profile => profile.Status = "APPROVE"); + placementProfiles.ForEach(profile => profile.Status = "PENDING"); await _context.SaveChangesAsync(); return Success(); } @@ -1422,7 +1422,7 @@ namespace BMA.EHR.Placement.Service.Controllers .Where(x => x.type == "EMPLOYEE") .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); - placementProfiles.ForEach(profile => profile.Status = "APPROVE"); + placementProfiles.ForEach(profile => profile.Status = "PENDING"); await _context.SaveChangesAsync(); return Success(); } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index c8f93b8c..2aab3c38 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -614,7 +614,8 @@ namespace BMA.EHR.Placement.Service.Controllers Total = x.PlacementProfiles.Count(), UnContain = x.PlacementProfiles.Where(p => p.PlacementStatus.Trim().ToUpper() == "UN-CONTAIN").Count(), PrepareContain = x.PlacementProfiles.Where(p => p.PlacementStatus.Trim().ToUpper() == "PREPARE-CONTAIN").Count(), - Contain = x.PlacementProfiles.Where(p => p.PlacementStatus.Trim().ToUpper() == "CONTAIN").Count(), + Report = x.PlacementProfiles.Where(p => p.PlacementStatus.Trim().ToUpper() == "REPORT").Count(), + Done = x.PlacementProfiles.Where(p => p.PlacementStatus.Trim().ToUpper() == "DONE").Count(), Disclaim = x.PlacementProfiles.Where(p => p.PlacementStatus.Trim().ToUpper() == "DISCLAIM").Count(), }).FirstOrDefaultAsync(); if (placement == null) @@ -658,7 +659,8 @@ namespace BMA.EHR.Placement.Service.Controllers Total = x.PlacementProfiles.Where(x => x.Draft == true).Where(x => rootId == "" ? true : (child1Id == "" ? x.rootId == rootId : (child2Id == "" ? x.child1Id == child1Id : (child3Id == "" ? x.child2Id == child2Id : (child4Id == "" ? x.child3Id == child3Id : x.child4Id == child4Id))))).Count(), UnContain = x.PlacementProfiles.Where(x => x.Draft == true).Where(x => rootId == "" ? true : (child1Id == "" ? x.rootId == rootId : (child2Id == "" ? x.child1Id == child1Id : (child3Id == "" ? x.child2Id == child2Id : (child4Id == "" ? x.child3Id == child3Id : x.child4Id == child4Id))))).Where(p => p.PlacementStatus.Trim().ToUpper() == "UN-CONTAIN").Count(), PrepareContain = x.PlacementProfiles.Where(x => x.Draft == true).Where(x => rootId == "" ? true : (child1Id == "" ? x.rootId == rootId : (child2Id == "" ? x.child1Id == child1Id : (child3Id == "" ? x.child2Id == child2Id : (child4Id == "" ? x.child3Id == child3Id : x.child4Id == child4Id))))).Where(p => p.PlacementStatus.Trim().ToUpper() == "PREPARE-CONTAIN").Count(), - Contain = x.PlacementProfiles.Where(x => x.Draft == true).Where(x => rootId == "" ? true : (child1Id == "" ? x.rootId == rootId : (child2Id == "" ? x.child1Id == child1Id : (child3Id == "" ? x.child2Id == child2Id : (child4Id == "" ? x.child3Id == child3Id : x.child4Id == child4Id))))).Where(p => p.PlacementStatus.Trim().ToUpper() == "CONTAIN").Count(), + Report = x.PlacementProfiles.Where(x => x.Draft == true).Where(x => rootId == "" ? true : (child1Id == "" ? x.rootId == rootId : (child2Id == "" ? x.child1Id == child1Id : (child3Id == "" ? x.child2Id == child2Id : (child4Id == "" ? x.child3Id == child3Id : x.child4Id == child4Id))))).Where(p => p.PlacementStatus.Trim().ToUpper() == "REPORT").Count(), + Done = x.PlacementProfiles.Where(x => x.Draft == true).Where(x => rootId == "" ? true : (child1Id == "" ? x.rootId == rootId : (child2Id == "" ? x.child1Id == child1Id : (child3Id == "" ? x.child2Id == child2Id : (child4Id == "" ? x.child3Id == child3Id : x.child4Id == child4Id))))).Where(p => p.PlacementStatus.Trim().ToUpper() == "DONE").Count(), Disclaim = x.PlacementProfiles.Where(x => x.Draft == true).Where(x => rootId == "" ? true : (child1Id == "" ? x.rootId == rootId : (child2Id == "" ? x.child1Id == child1Id : (child3Id == "" ? x.child2Id == child2Id : (child4Id == "" ? x.child3Id == child3Id : x.child4Id == child4Id))))).Where(p => p.PlacementStatus.Trim().ToUpper() == "DISCLAIM").Count(), }).FirstOrDefaultAsync(); if (placement == null) @@ -1455,7 +1457,7 @@ namespace BMA.EHR.Placement.Service.Controllers { var position = await _context.PlacementProfiles .Where(x => x.posmasterId != null) - .Where(x => x.PlacementStatus != "CONTAIN") + .Where(x => x.PlacementStatus != "DONE" && x.PlacementStatus != "REPORT") .Select(x => x.posmasterId) .ToListAsync(); return Success(position); @@ -1479,7 +1481,7 @@ namespace BMA.EHR.Placement.Service.Controllers .Where(x => x.Placement!.PlacementType!.Name != "สอบแข่งขัน") .Where(x => x.typeCommand.Trim().ToUpper() == "APPOINTED") .ToListAsync(); - placementProfiles.ForEach(profile => profile.PlacementStatus = "PREPARE-CONTAIN"); + placementProfiles.ForEach(profile => profile.PlacementStatus = "REPORT"); await _context.SaveChangesAsync(); return Success(); } @@ -1497,7 +1499,7 @@ namespace BMA.EHR.Placement.Service.Controllers { var placementProfiles = await _context.PlacementProfiles .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.PlacementStatus.ToUpper() == "PREPARE-CONTAIN") + .Where(x => x.PlacementStatus.ToUpper() == "REPORT") .ToListAsync(); placementProfiles.ForEach(profile => profile.PlacementStatus = "PREPARE-CONTAIN"); await _context.SaveChangesAsync(); @@ -1746,7 +1748,7 @@ namespace BMA.EHR.Placement.Service.Controllers var _result = await _res.Content.ReadAsStringAsync(); } // update placementstatus - placementProfile.PlacementStatus = "CONTAIN";//DONE + placementProfile.PlacementStatus = "DONE";//DONE await _context.SaveChangesAsync(); } @@ -1772,7 +1774,7 @@ namespace BMA.EHR.Placement.Service.Controllers .Where(x => x.Placement!.PlacementType!.Name != "สอบแข่งขัน") .Where(x => x.typeCommand.Trim().ToUpper() == "APPOINTED") .ToListAsync(); - placementProfiles.ForEach(profile => profile.PlacementStatus = "PREPARE-CONTAIN"); + placementProfiles.ForEach(profile => profile.PlacementStatus = "REPORT"); await _context.SaveChangesAsync(); return Success(); } @@ -1790,9 +1792,9 @@ namespace BMA.EHR.Placement.Service.Controllers { var placementProfiles = await _context.PlacementProfiles .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.PlacementStatus.ToUpper() == "PREPARE-CONTAIN") + .Where(x => x.PlacementStatus.ToUpper() == "REPORT") .ToListAsync(); - placementProfiles.ForEach(profile => profile.PlacementStatus = "PREPARE-CONTAIN"); + placementProfiles.ForEach(profile => profile.PlacementStatus = "PREPARE-CONTAI"); await _context.SaveChangesAsync(); return Success(); } @@ -2039,7 +2041,7 @@ namespace BMA.EHR.Placement.Service.Controllers var _result = await _res.Content.ReadAsStringAsync(); } // update placementstatus - placementProfile.PlacementStatus = "CONTAIN";//DONE + placementProfile.PlacementStatus = "DONE";//DONE await _context.SaveChangesAsync(); } @@ -2064,7 +2066,7 @@ namespace BMA.EHR.Placement.Service.Controllers .Where(x => x.Placement!.PlacementType!.Name == "แต่งตั้งข้าราชการ") .Where(x => x.typeCommand.Trim().ToUpper() == "APPOIN") .ToListAsync(); - placementProfiles.ForEach(profile => profile.PlacementStatus = "PREPARE-CONTAIN"); + placementProfiles.ForEach(profile => profile.PlacementStatus = "REPORT"); await _context.SaveChangesAsync(); return Success(); } @@ -2082,7 +2084,7 @@ namespace BMA.EHR.Placement.Service.Controllers { var placementProfiles = await _context.PlacementProfiles .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.PlacementStatus.ToUpper() == "PREPARE-CONTAIN") + .Where(x => x.PlacementStatus.ToUpper() == "REPORT") .ToListAsync(); placementProfiles.ForEach(profile => profile.PlacementStatus = "PREPARE-CONTAIN"); await _context.SaveChangesAsync(); @@ -2215,7 +2217,7 @@ namespace BMA.EHR.Placement.Service.Controllers var _result = await _res.Content.ReadAsStringAsync(); if (_res.IsSuccessStatusCode) { - data.ForEach(profile => profile.PlacementStatus = "CONTAIN"); + data.ForEach(profile => profile.PlacementStatus = "DONE"); await _context.SaveChangesAsync(); } } @@ -2240,7 +2242,7 @@ namespace BMA.EHR.Placement.Service.Controllers .Where(x => x.Placement!.PlacementType!.Name == "ย้ายข้าราชการ") .Where(x => x.typeCommand.Trim().ToUpper() == "MOVE") .ToListAsync(); - placementProfiles.ForEach(profile => profile.PlacementStatus = "PREPARE-CONTAIN"); + placementProfiles.ForEach(profile => profile.PlacementStatus = "REPORT"); await _context.SaveChangesAsync(); return Success(); } @@ -2258,7 +2260,7 @@ namespace BMA.EHR.Placement.Service.Controllers { var placementProfiles = await _context.PlacementProfiles .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.PlacementStatus.ToUpper() == "PREPARE-CONTAIN") + .Where(x => x.PlacementStatus.ToUpper() == "REPORT") .ToListAsync(); placementProfiles.ForEach(profile => profile.PlacementStatus = "PREPARE-CONTAIN"); await _context.SaveChangesAsync(); @@ -2389,7 +2391,7 @@ namespace BMA.EHR.Placement.Service.Controllers var _result = await _res.Content.ReadAsStringAsync(); if (_res.IsSuccessStatusCode) { - data.ForEach(profile => profile.PlacementStatus = "CONTAIN"); + data.ForEach(profile => profile.PlacementStatus = "DONE"); await _context.SaveChangesAsync(); } } @@ -2414,7 +2416,7 @@ namespace BMA.EHR.Placement.Service.Controllers .Where(x => x.Placement!.PlacementType!.Name == "เลื่อนข้าราชการ") .Where(x => x.typeCommand.Trim().ToUpper() == "SLIP") .ToListAsync(); - placementProfiles.ForEach(profile => profile.PlacementStatus = "PREPARE-CONTAIN"); + placementProfiles.ForEach(profile => profile.PlacementStatus = "REPORT"); await _context.SaveChangesAsync(); return Success(); } @@ -2432,7 +2434,7 @@ namespace BMA.EHR.Placement.Service.Controllers { var placementProfiles = await _context.PlacementProfiles .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.PlacementStatus.ToUpper() == "PREPARE-CONTAIN") + .Where(x => x.PlacementStatus.ToUpper() == "REPORT") .ToListAsync(); placementProfiles.ForEach(profile => profile.PlacementStatus = "PREPARE-CONTAIN"); await _context.SaveChangesAsync(); @@ -2563,7 +2565,7 @@ namespace BMA.EHR.Placement.Service.Controllers var _result = await _res.Content.ReadAsStringAsync(); if (_res.IsSuccessStatusCode) { - data.ForEach(profile => profile.PlacementStatus = "CONTAIN"); + data.ForEach(profile => profile.PlacementStatus = "DONE"); await _context.SaveChangesAsync(); } } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs index 1483572c..86fee36d 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs @@ -914,7 +914,7 @@ namespace BMA.EHR.Placement.Service.Controllers .Where(x => req.refIds.Contains(x.Id.ToString())) .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); - placementProfiles.ForEach(profile => profile.Status = "APPROVE"); + placementProfiles.ForEach(profile => profile.Status = "PENDING"); await _context.SaveChangesAsync(); return Success(); } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs index b2cf8359..ff68ddb1 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs @@ -495,6 +495,25 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// ลบส่งรายชื่อออกคำสั่ง C-PM-16 + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("command/report/delete")] + public async Task> PostReportDelete([FromBody] ReportPersonRequest req) + { + var placementProfiles = await _context.PlacementRepatriations + .Where(x => req.refIds.Contains(x.Id.ToString())) + .ToListAsync(); + placementProfiles.ForEach(profile => profile.Status = "APPROVE"); + await _context.SaveChangesAsync(); + return Success(); + } + /// /// ออกคำสั่ง C-PM-16 คำสั่งส่งตัวกลับ /// diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs index c447495f..57329436 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs @@ -793,7 +793,7 @@ namespace BMA.EHR.Placement.Service.Controllers .Where(x => req.refIds.Contains(x.Id.ToString())) .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); - placementProfiles.ForEach(profile => profile.Status = "REPORTREPORT"); + placementProfiles.ForEach(profile => profile.Status = "APPROVE"); await _context.SaveChangesAsync(); return Success(); } diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs index 8ec26491..33ccabb3 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs @@ -660,7 +660,7 @@ namespace BMA.EHR.Retirement.Service.Controllers .Where(x => req.refIds.Contains(x.Id.ToString())) .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); - placementProfiles.ForEach(profile => profile.Status = "APPROVE"); + placementProfiles.ForEach(profile => profile.Status = "WAITTING"); await _context.SaveChangesAsync(); return Success(); } @@ -815,7 +815,7 @@ namespace BMA.EHR.Retirement.Service.Controllers .Where(x => req.refIds.Contains(x.Id.ToString())) .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); - placementProfiles.ForEach(profile => profile.Status = "APPROVE"); + placementProfiles.ForEach(profile => profile.Status = "WAITTING"); await _context.SaveChangesAsync(); return Success(); } diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs index dc2b4cb9..2256fe75 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs @@ -1927,7 +1927,7 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda var placementProfiles = await _context.RetirementResigns .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); - placementProfiles.ForEach(profile => profile.Status = "DONECANCEL"); + placementProfiles.ForEach(profile => profile.Status = "REPORT"); await _context.SaveChangesAsync(); return Success(); } @@ -1945,9 +1945,9 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda { var placementProfiles = await _context.RetirementResigns .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Status.ToUpper() == "DONECANCEL") + .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); - placementProfiles.ForEach(profile => profile.Status = "DONE"); + placementProfiles.ForEach(profile => profile.Status = "DONECANCEL"); await _context.SaveChangesAsync(); return Success(); } From 037435b3bce0f681d81909590bf6429eb80f9a1d Mon Sep 17 00:00:00 2001 From: kittapath Date: Mon, 7 Oct 2024 23:23:00 +0700 Subject: [PATCH 35/42] noti report --- .../MessageQueue/NotificationRepository.cs | 48 +++++++++++++++++++ .../Controllers/NotifyController.cs | 40 ++++++---------- .../Controllers/PlacementController.cs | 4 ++ .../Controllers/PlacementOfficerController.cs | 1 + .../Requests/NotisRequest.cs | 16 +++++++ 5 files changed, 83 insertions(+), 26 deletions(-) create mode 100644 BMA.EHR.Placement.Service/Requests/NotisRequest.cs diff --git a/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs b/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs index 717069ce..633dcf2e 100644 --- a/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs +++ b/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs @@ -233,6 +233,54 @@ namespace BMA.EHR.Application.Repositories.MessageQueue throw; } } + + public async Task PushNotificationsAsync(Guid[] ReceiverUserIds, string Subject, string Body, string Payload = "", bool IsSendInbox = false, bool IsSendMail = false) + { + try + { + foreach (var ReceiverUserId in ReceiverUserIds) + { + _dbContext.Set().Add(new Notification + { + Body = Body, + ReceiverUserId = ReceiverUserId, + Type = "", + Payload = Payload, + CreatedFullName = FullName ?? "System Administrator", + CreatedUserId = UserId ?? "", + CreatedAt = DateTime.Now, + LastUpdateFullName = FullName ?? "System Administrator", + LastUpdateUserId = UserId ?? "", + LastUpdatedAt = DateTime.Now, + }); + if (IsSendInbox == true) + { + _dbContext.Set().Add(new Inbox + { + Subject = Subject, + Body = Body, + ReceiverUserId = ReceiverUserId, + Payload = Payload, + CreatedFullName = FullName ?? "System Administrator", + CreatedUserId = UserId ?? "", + CreatedAt = DateTime.Now, + LastUpdateFullName = FullName ?? "System Administrator", + LastUpdateUserId = UserId ?? "", + LastUpdatedAt = DateTime.Now, + }); + } + if (IsSendMail == true) + { + _emailSenderService.SendMail(Subject, Body, "kittapath@frappet.com"); + } + } + await _dbContext.SaveChangesAsync(); + } + catch + { + throw; + } + } public async Task PushNotificationAsyncV2(string? ReceiverUserId, string Subject, string Body, string Payload = "", bool IsSendInbox = false, bool IsSendMail = false) { try diff --git a/BMA.EHR.Placement.Service/Controllers/NotifyController.cs b/BMA.EHR.Placement.Service/Controllers/NotifyController.cs index 01a40ae3..2fdd8609 100644 --- a/BMA.EHR.Placement.Service/Controllers/NotifyController.cs +++ b/BMA.EHR.Placement.Service/Controllers/NotifyController.cs @@ -62,10 +62,6 @@ namespace BMA.EHR.Placement.Service.Controllers [HttpPost()] public async Task> UpdatePropertyByUser([FromBody] NotiRequest req) { - // var profile = await _context.Profiles.FirstOrDefaultAsync(x => x.Id == req.ReceiverUserId); - // if (profile == null) - // return Error(GlobalMessages.DataNotFound); - await _repositoryNoti.PushNotificationAsync( Guid.Parse(req.ReceiverUserId), req.Subject, @@ -81,10 +77,6 @@ namespace BMA.EHR.Placement.Service.Controllers [HttpPost("keycloak")] public async Task> UpdatePropertyByUserKeycloak([FromBody] NotiRequest req) { - // var profile = await _context.Profiles.FirstOrDefaultAsync(x => x.KeycloakId == req.ReceiverUserId); - // if (profile == null) - // return Error(GlobalMessages.DataNotFound); - var apiUrl = $"{_configuration["API"]}/org/profile/keycloakid/position/" + req.ReceiverUserId; using (var client = new HttpClient()) { @@ -112,18 +104,6 @@ namespace BMA.EHR.Placement.Service.Controllers [HttpPost("profile")] public async Task> UpdatePropertyByUserProfile([FromBody] NotiRequest req) { - // var profile = await _context.Profiles.FirstOrDefaultAsync(x => x.KeycloakId == req.ReceiverUserId); - // if (profile == null) - // return Error(GlobalMessages.DataNotFound); - - // var apiUrl = $"{_configuration["API"]}/org/profile/profileid/position/" + req.ReceiverUserId; - // using (var client = new HttpClient()) - // { - // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - // var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - // var _res = await client.SendAsync(_req); - // var _result = await _res.Content.ReadAsStringAsync(); - // var org = JsonConvert.DeserializeObject(_result); if (req.ReceiverUserId != null) { await _repositoryNoti.PushNotificationAsync( @@ -136,7 +116,20 @@ namespace BMA.EHR.Placement.Service.Controllers ); } return Success(); - // } + } + + [HttpPost("profiles")] + public async Task> UpdatePropertyByUserProfiles([FromBody] NotisRequest req) + { + await _repositoryNoti.PushNotificationsAsync( + req.ReceiverUserIds.Select(x => Guid.Parse(x)).ToArray(), + req.Subject, + req.Body, + req.Payload, + req.IsSendInbox, + req.IsSendMail + ); + return Success(); } [HttpPut("{id:length(36)}")] @@ -170,11 +163,6 @@ namespace BMA.EHR.Placement.Service.Controllers } return Success(); } - // var profile = await _context.Profiles.FirstOrDefaultAsync(x => x.KeycloakId == Guid.Parse(inbox.CreatedUserId)); - // if (profile == null) - // return Error(GlobalMessages.DataNotFound); - - return Success(); } [HttpPost("cronjob")] diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index 2aab3c38..3bb2f8ce 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -144,6 +144,7 @@ namespace BMA.EHR.Placement.Service.Controllers { Id = x.Id, PersonalId = x.Id, + x.profileId, Avatar = x.ProfileImg == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.ProfileImg.Id, FullName = $"{x.Prefix}{x.Firstname} {x.Lastname}", Prefix = x.Prefix, @@ -203,6 +204,7 @@ namespace BMA.EHR.Placement.Service.Controllers p.Lastname, p.IdCard, p.CitizenId, + p.profileId, p.ExamNumber, p.posmasterId, p.root, @@ -282,6 +284,7 @@ namespace BMA.EHR.Placement.Service.Controllers { Id = x.Id, PersonalId = x.Id, + x.profileId, Avatar = x.ProfileImg == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.ProfileImg.Id, FullName = $"{x.Prefix}{x.Firstname} {x.Lastname}", Prefix = x.Prefix, @@ -341,6 +344,7 @@ namespace BMA.EHR.Placement.Service.Controllers p.Lastname, p.IdCard, p.CitizenId, + p.profileId, p.ExamNumber, p.posmasterId, p.root, diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs index 95ea3a91..99268cd2 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs @@ -110,6 +110,7 @@ namespace BMA.EHR.Placement.Service.Controllers { p.Id, p.citizenId, + p.profileId, p.prefix, p.firstName, p.lastName, diff --git a/BMA.EHR.Placement.Service/Requests/NotisRequest.cs b/BMA.EHR.Placement.Service/Requests/NotisRequest.cs new file mode 100644 index 00000000..201bde0a --- /dev/null +++ b/BMA.EHR.Placement.Service/Requests/NotisRequest.cs @@ -0,0 +1,16 @@ +using BMA.EHR.Domain.Models.MetaData; +using Microsoft.EntityFrameworkCore; + +namespace BMA.EHR.Placement.Service.Requests +{ + public class NotisRequest + { + public string Subject { get; set; } + public string Body { get; set; } + public string Payload { get; set; } + public string[] ReceiverUserIds { get; set; } + public bool IsSendMail { get; set; } + public bool IsSendInbox { get; set; } + public bool IsSendNotification { get; set; } + } +} From 74655b87ffeacf619930de94cc587ee293f6a3bb Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 9 Oct 2024 16:17:41 +0700 Subject: [PATCH 36/42] no message --- .../Controllers/DisciplineSuspendController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BMA.EHR.Discipline.Service/Controllers/DisciplineSuspendController.cs b/BMA.EHR.Discipline.Service/Controllers/DisciplineSuspendController.cs index 13d77be1..ca57e9cd 100644 --- a/BMA.EHR.Discipline.Service/Controllers/DisciplineSuspendController.cs +++ b/BMA.EHR.Discipline.Service/Controllers/DisciplineSuspendController.cs @@ -86,7 +86,7 @@ namespace BMA.EHR.DisciplineSuspend.Service.Controllers Prefix = x.Prefix, FirstName = x.FirstName, LastName = x.LastName, - + ProfileId = x.PersonId, Organization = x.Organization, root = x.root, rootId = x.rootId, From 8ef340b75b5c2686f7f309a7d682dad5bfe81002 Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 9 Oct 2024 16:18:11 +0700 Subject: [PATCH 37/42] =?UTF-8?q?=E0=B8=AD=E0=B8=AD=E0=B8=81=E0=B8=84?= =?UTF-8?q?=E0=B8=B3=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87=2001=2002?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/PlacementController.cs | 305 ++++++++++++++++++ 1 file changed, 305 insertions(+) diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index 3bb2f8ce..56d6394a 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -1759,6 +1759,158 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// ออกคำสั่ง C-PM-01 บรรจุและแต่งตั้งผู้สอบแข่งขันได้ (NEW) + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("recruit/report/excecute-new")] + public async Task> PostReportExecuteRecruitNew([FromBody] ReportExecuteRequest req) + { + try + { + var placementProfile = await _context.PlacementProfiles + .Include(x => x.PlacementCertificates) + .Include(x => x.PlacementEducations) + .ThenInclude(x => x.EducationLevel) + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + + if (placementProfile == null) + return NotFound(); + + var resultData = (from p in placementProfile + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + bodyProfile = new + { + rank = string.Empty, + prefix = p.Prefix == null ? string.Empty : p.Prefix, + firstName = p.Firstname == null ? string.Empty : p.Firstname, + lastName = p.Lastname == null ? string.Empty : p.Lastname, + citizenId = p.CitizenId == null ? string.Empty : p.CitizenId, + position = p.positionName == null ? string.Empty : p.positionName, + posLevelId = p.posLevelId == null ? string.Empty : p.posLevelId, + posTypeId = p.posTypeId == null ? string.Empty : p.posTypeId, + email = p.Email == null ? string.Empty : p.Email, + phone = p.MobilePhone == null ? string.Empty : p.MobilePhone, + keycloak = string.Empty, + isProbation = true, + isLeave = false, + dateRetire = (DateTime?)null, + dateAppoint = r.commandAffectDate, + dateStart = r.commandAffectDate, + govAgeAbsent = 0, + govAgePlus = 0, + birthDate = p.DateOfBirth == null ? (DateTime?)null : p.DateOfBirth, + reasonSameDate = (DateTime?)null, + ethnicity = p.Race == null ? string.Empty : p.Race, + telephoneNumber = p.Telephone == null ? string.Empty : p.Telephone, + nationality = p.Nationality == null ? string.Empty : p.Nationality, + gender = p.Gender == null ? string.Empty : p.Gender, + relationship = p.Relationship == null ? string.Empty : p.Relationship, + religion = p.Religion == null ? string.Empty : p.Religion, + bloodGroup = string.Empty, + registrationAddress = p.RegistAddress == null ? string.Empty : p.RegistAddress, + registrationProvinceId = (String?)null, + registrationDistrictId = (String?)null, + registrationSubDistrictId = (String?)null, + registrationZipCode = p.RegistZipCode == null ? string.Empty : p.RegistZipCode, + currentAddress = p.CurrentAddress == null ? string.Empty : p.CurrentAddress, + currentProvinceId = (String?)null, + currentDistrictId = (String?)null, + currentSubDistrictId = (String?)null, + currentZipCode = p.CurrentZipCode == null ? string.Empty : p.CurrentZipCode + }, + bodyEducations = p.PlacementEducations.Select(e => new + { + profileId = string.Empty, + country = e.Country ?? string.Empty, + degree = e.Degree ?? string.Empty, + duration = e.Duration ?? string.Empty, + durationYear = e.DurationYear ?? null, + field = e.Field ?? string.Empty, + finishDate = e.FinishDate ?? null, + fundName = e.FundName ?? string.Empty, + gpa = e.Gpa ?? string.Empty, + institute = e.Institute ?? string.Empty, + other = e.Other ?? string.Empty, + startDate = e.StartDate ?? null, + endDate = e.EndDate ?? null, + educationLevel = e.EducationLevel?.Name ?? string.Empty, + educationLevelId = e.EducationLevel?.Id.ToString() ?? string.Empty, + positionPath = e.PositionPath?.Name ?? string.Empty, + positionPathId = e.PositionPath?.Id.ToString() ?? string.Empty, + isDate = e.IsDate ?? false, + isEducation = e.IsEducation ?? false, + note = e.Other ?? string.Empty + }).ToList(), + bodyCertificates = p.PlacementCertificates.Select(e => new + { + profileId = string.Empty, + expireDate = e.ExpireDate ?? null, + issueDate = e.IssueDate ?? null, + certificateNo = e.CertificateNo ?? string.Empty, + certificateType = e.CertificateType ?? string.Empty, + issuer = e.Issuer ?? string.Empty + }).ToList(), + bodySalarys = new + { + profileId = string.Empty, + date = r.commandAffectDate, + amount = p.Amount, + positionSalaryAmount = p.PositionSalaryAmount, + mouthSalaryAmount = p.MouthSalaryAmount, + posNo = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}" : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}" : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}" : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}" : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}" : "", + position = p.positionName == null ? string.Empty : p.positionName, + positionLine = string.Empty, + positionPathSide = string.Empty, + positionExecutive = string.Empty, + positionType = p.posTypeName == null ? string.Empty : p.posTypeName, + positionLevel = p.posLevelName == null ? string.Empty : p.posLevelName, + refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}", + templateDoc = r.templateDoc + }, + bodyPosition = new + { + posmasterId = p.posmasterId, + positionId = p.positionId + } + }).ToList(); + + var apiUrl = $"{_configuration["API"]}/org/command/excexute/create-officer-profile"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl); + var _res = await client.PostAsJsonAsync(apiUrl, new + { + data = resultData + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + // update placementstatus + placementProfile.ForEach(profile => profile.PlacementStatus = "DONE"); + await _context.SaveChangesAsync(); + return Success(); + } + catch + { + throw; + } + } /// /// ส่งรายชื่อออกคำสั่ง C-PM-02 @@ -2052,6 +2204,159 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// ออกคำสั่ง C-PM-02 บรรจุและแต่งตั้งผู้ได้รับคัดเลือก (NEW) + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("candidate/report/excecute-new")] + public async Task> PostReportExecuteCandidateNew([FromBody] ReportExecuteRequest req) + { + try + { + var placementProfile = await _context.PlacementProfiles + .Include(x => x.PlacementCertificates) + .Include(x => x.PlacementEducations) + .ThenInclude(x => x.EducationLevel) + .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) + .ToListAsync(); + + if (placementProfile == null) + return NotFound(); + + var resultData = (from p in placementProfile + join r in req.refIds + on p.Id.ToString() equals r.refId + select new + { + bodyProfile = new + { + rank = string.Empty, + prefix = p.Prefix == null ? string.Empty : p.Prefix, + firstName = p.Firstname == null ? string.Empty : p.Firstname, + lastName = p.Lastname == null ? string.Empty : p.Lastname, + citizenId = p.CitizenId == null ? string.Empty : p.CitizenId, + position = p.positionName == null ? string.Empty : p.positionName, + posLevelId = p.posLevelId == null ? string.Empty : p.posLevelId, + posTypeId = p.posTypeId == null ? string.Empty : p.posTypeId, + email = p.Email == null ? string.Empty : p.Email, + phone = p.MobilePhone == null ? string.Empty : p.MobilePhone, + keycloak = string.Empty, + isProbation = true, + isLeave = false, + dateRetire = (DateTime?)null, + dateAppoint = r.commandAffectDate, + dateStart = r.commandAffectDate, + govAgeAbsent = 0, + govAgePlus = 0, + birthDate = p.DateOfBirth == null ? (DateTime?)null : p.DateOfBirth, + reasonSameDate = (DateTime?)null, + ethnicity = p.Race == null ? string.Empty : p.Race, + telephoneNumber = p.Telephone == null ? string.Empty : p.Telephone, + nationality = p.Nationality == null ? string.Empty : p.Nationality, + gender = p.Gender == null ? string.Empty : p.Gender, + relationship = p.Relationship == null ? string.Empty : p.Relationship, + religion = p.Religion == null ? string.Empty : p.Religion, + bloodGroup = string.Empty, + registrationAddress = p.RegistAddress == null ? string.Empty : p.RegistAddress, + registrationProvinceId = (String?)null, + registrationDistrictId = (String?)null, + registrationSubDistrictId = (String?)null, + registrationZipCode = p.RegistZipCode == null ? string.Empty : p.RegistZipCode, + currentAddress = p.CurrentAddress == null ? string.Empty : p.CurrentAddress, + currentProvinceId = (String?)null, + currentDistrictId = (String?)null, + currentSubDistrictId = (String?)null, + currentZipCode = p.CurrentZipCode == null ? string.Empty : p.CurrentZipCode + }, + bodyEducations = p.PlacementEducations.Select(e => new + { + profileId = string.Empty, + country = e.Country ?? string.Empty, + degree = e.Degree ?? string.Empty, + duration = e.Duration ?? string.Empty, + durationYear = e.DurationYear ?? null, + field = e.Field ?? string.Empty, + finishDate = e.FinishDate ?? null, + fundName = e.FundName ?? string.Empty, + gpa = e.Gpa ?? string.Empty, + institute = e.Institute ?? string.Empty, + other = e.Other ?? string.Empty, + startDate = e.StartDate ?? null, + endDate = e.EndDate ?? null, + educationLevel = e.EducationLevel?.Name ?? string.Empty, + educationLevelId = e.EducationLevel?.Id.ToString() ?? string.Empty, + positionPath = e.PositionPath?.Name ?? string.Empty, + positionPathId = e.PositionPath?.Id.ToString() ?? string.Empty, + isDate = e.IsDate ?? false, + isEducation = e.IsEducation ?? false, + note = e.Other ?? string.Empty + }).ToList(), + bodyCertificates = p.PlacementCertificates.Select(e => new + { + profileId = string.Empty, + expireDate = e.ExpireDate ?? null, + issueDate = e.IssueDate ?? null, + certificateNo = e.CertificateNo ?? string.Empty, + certificateType = e.CertificateType ?? string.Empty, + issuer = e.Issuer ?? string.Empty + }).ToList(), + bodySalarys = new + { + profileId = string.Empty, + date = r.commandAffectDate, + amount = p.Amount, + positionSalaryAmount = p.PositionSalaryAmount, + mouthSalaryAmount = p.MouthSalaryAmount, + posNo = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}" : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}" : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}" : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}" : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}" : "", + position = p.positionName == null ? string.Empty : p.positionName, + positionLine = string.Empty, + positionPathSide = string.Empty, + positionExecutive = string.Empty, + positionType = p.posTypeName == null ? string.Empty : p.posTypeName, + positionLevel = p.posLevelName == null ? string.Empty : p.posLevelName, + refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}", + templateDoc = r.templateDoc + }, + bodyPosition = new + { + posmasterId = p.posmasterId, + positionId = p.positionId + } + }).ToList(); + + var apiUrl = $"{_configuration["API"]}/org/command/excexute/create-officer-profile"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl); + var _res = await client.PostAsJsonAsync(apiUrl, new + { + data = resultData + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + + // update placementstatus + placementProfile.ForEach(profile => profile.PlacementStatus = "DONE"); + await _context.SaveChangesAsync(); + return Success(); + } + catch + { + throw; + } + } + /// /// ส่งรายชื่อออกคำสั่ง C-PM-03 /// From c8b5c6eaa97e9eec0b340374d506fab7a21dcd4f Mon Sep 17 00:00:00 2001 From: kittapath Date: Thu, 10 Oct 2024 12:33:26 +0700 Subject: [PATCH 38/42] no message --- .../PlacementAppointmentController.cs | 12 +-- .../Controllers/PlacementController.cs | 80 +++++++++---------- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs index 22c0a386..4114a456 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs @@ -1242,7 +1242,7 @@ namespace BMA.EHR.Placement.Service.Controllers { var placementProfiles = await _context.PlacementAppointments .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.type == "EMPLOYEE") + // .Where(x => x.type == "EMPLOYEE") .ToListAsync(); placementProfiles.ForEach(profile => profile.Status = "REPORT"); await _context.SaveChangesAsync(); @@ -1262,7 +1262,7 @@ namespace BMA.EHR.Placement.Service.Controllers { var placementProfiles = await _context.PlacementAppointments .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.type == "EMPLOYEE") + // .Where(x => x.type == "EMPLOYEE") .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); placementProfiles.ForEach(profile => profile.Status = "PENDING"); @@ -1290,7 +1290,7 @@ namespace BMA.EHR.Placement.Service.Controllers { var report_data = (from p in _context.PlacementAppointments .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) - .Where(x => x.type == "EMPLOYEE") + // .Where(x => x.type == "EMPLOYEE") .ToList() join r in req.refIds on p.Id.ToString() equals r.refId @@ -1399,7 +1399,7 @@ namespace BMA.EHR.Placement.Service.Controllers { var placementProfiles = await _context.PlacementAppointments .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.type == "EMPLOYEE") + // .Where(x => x.type == "EMPLOYEE") .ToListAsync(); placementProfiles.ForEach(profile => profile.Status = "REPORT"); await _context.SaveChangesAsync(); @@ -1419,7 +1419,7 @@ namespace BMA.EHR.Placement.Service.Controllers { var placementProfiles = await _context.PlacementAppointments .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.type == "EMPLOYEE") + // .Where(x => x.type == "EMPLOYEE") .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); placementProfiles.ForEach(profile => profile.Status = "PENDING"); @@ -1447,7 +1447,7 @@ namespace BMA.EHR.Placement.Service.Controllers { var report_data = (from p in _context.PlacementAppointments .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) - .Where(x => x.type == "EMPLOYEE") + // .Where(x => x.type == "EMPLOYEE") .ToList() join r in req.refIds on p.Id.ToString() equals r.refId diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index 56d6394a..2b21d27e 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -1479,11 +1479,11 @@ namespace BMA.EHR.Placement.Service.Controllers public async Task> PostReportRecruit([FromBody] ReportPersonRequest req) { var placementProfiles = await _context.PlacementProfiles - .Include(x => x.Placement) - .ThenInclude(x => x.PlacementType) + // .Include(x => x.Placement) + // .ThenInclude(x => x.PlacementType) .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Placement!.PlacementType!.Name != "สอบแข่งขัน") - .Where(x => x.typeCommand.Trim().ToUpper() == "APPOINTED") + // .Where(x => x.Placement!.PlacementType!.Name != "สอบแข่งขัน") + // .Where(x => x.typeCommand.Trim().ToUpper() == "APPOINTED") .ToListAsync(); placementProfiles.ForEach(profile => profile.PlacementStatus = "REPORT"); await _context.SaveChangesAsync(); @@ -1529,11 +1529,11 @@ namespace BMA.EHR.Placement.Service.Controllers try { var report_data = (from p in _context.PlacementProfiles - .Include(x => x.Placement) - .ThenInclude(x => x.PlacementType) + // .Include(x => x.Placement) + // .ThenInclude(x => x.PlacementType) .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) - .Where(x => x.Placement!.PlacementType!.Name != "สอบแข่งขัน") - .Where(x => x.typeCommand.Trim().ToUpper() == "APPOINTED") + // .Where(x => x.Placement!.PlacementType!.Name != "สอบแข่งขัน") + // .Where(x => x.typeCommand.Trim().ToUpper() == "APPOINTED") .ToList() join r in req.refIds on p.Id.ToString() equals r.refId @@ -1924,11 +1924,11 @@ namespace BMA.EHR.Placement.Service.Controllers public async Task> PostReportCandidate([FromBody] ReportPersonRequest req) { var placementProfiles = await _context.PlacementProfiles - .Include(x => x.Placement) - .ThenInclude(x => x.PlacementType) + // .Include(x => x.Placement) + // .ThenInclude(x => x.PlacementType) .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Placement!.PlacementType!.Name != "สอบแข่งขัน") - .Where(x => x.typeCommand.Trim().ToUpper() == "APPOINTED") + // .Where(x => x.Placement!.PlacementType!.Name != "สอบแข่งขัน") + // .Where(x => x.typeCommand.Trim().ToUpper() == "APPOINTED") .ToListAsync(); placementProfiles.ForEach(profile => profile.PlacementStatus = "REPORT"); await _context.SaveChangesAsync(); @@ -1974,11 +1974,11 @@ namespace BMA.EHR.Placement.Service.Controllers try { var report_data = (from p in _context.PlacementProfiles - .Include(x => x.Placement) - .ThenInclude(x => x.PlacementType) + // .Include(x => x.Placement) + // .ThenInclude(x => x.PlacementType) .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) - .Where(x => x.Placement!.PlacementType!.Name != "สอบแข่งขัน") - .Where(x => x.typeCommand.Trim().ToUpper() == "APPOINTED") + // .Where(x => x.Placement!.PlacementType!.Name != "สอบแข่งขัน") + // .Where(x => x.typeCommand.Trim().ToUpper() == "APPOINTED") .ToList() join r in req.refIds on p.Id.ToString() equals r.refId @@ -2369,11 +2369,11 @@ namespace BMA.EHR.Placement.Service.Controllers public async Task> PostReportAppoint([FromBody] ReportPersonRequest req) { var placementProfiles = await _context.PlacementProfiles - .Include(x => x.Placement) - .ThenInclude(x => x.PlacementType) + // .Include(x => x.Placement) + // .ThenInclude(x => x.PlacementType) .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Placement!.PlacementType!.Name == "แต่งตั้งข้าราชการ") - .Where(x => x.typeCommand.Trim().ToUpper() == "APPOIN") + // .Where(x => x.Placement!.PlacementType!.Name == "แต่งตั้งข้าราชการ") + // .Where(x => x.typeCommand.Trim().ToUpper() == "APPOIN") .ToListAsync(); placementProfiles.ForEach(profile => profile.PlacementStatus = "REPORT"); await _context.SaveChangesAsync(); @@ -2419,11 +2419,11 @@ namespace BMA.EHR.Placement.Service.Controllers try { var report_data = (from p in _context.PlacementProfiles - .Include(x => x.Placement) - .ThenInclude(x => x.PlacementType) + // .Include(x => x.Placement) + // .ThenInclude(x => x.PlacementType) .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) - .Where(x => x.Placement!.PlacementType!.Name == "แต่งตั้งข้าราชการ") - .Where(x => x.typeCommand.Trim().ToUpper() == "APPOIN") + // .Where(x => x.Placement!.PlacementType!.Name == "แต่งตั้งข้าราชการ") + // .Where(x => x.typeCommand.Trim().ToUpper() == "APPOIN") .ToList() join r in req.refIds on p.Id.ToString() equals r.refId @@ -2545,11 +2545,11 @@ namespace BMA.EHR.Placement.Service.Controllers public async Task> PostReportMove([FromBody] ReportPersonRequest req) { var placementProfiles = await _context.PlacementProfiles - .Include(x => x.Placement) - .ThenInclude(x => x.PlacementType) + // .Include(x => x.Placement) + // .ThenInclude(x => x.PlacementType) .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Placement!.PlacementType!.Name == "ย้ายข้าราชการ") - .Where(x => x.typeCommand.Trim().ToUpper() == "MOVE") + // .Where(x => x.Placement!.PlacementType!.Name == "ย้ายข้าราชการ") + // .Where(x => x.typeCommand.Trim().ToUpper() == "MOVE") .ToListAsync(); placementProfiles.ForEach(profile => profile.PlacementStatus = "REPORT"); await _context.SaveChangesAsync(); @@ -2595,11 +2595,11 @@ namespace BMA.EHR.Placement.Service.Controllers try { var report_data = (from p in _context.PlacementProfiles - .Include(x => x.Placement) - .ThenInclude(x => x.PlacementType) + // .Include(x => x.Placement) + // .ThenInclude(x => x.PlacementType) .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) - .Where(x => x.Placement!.PlacementType!.Name == "แต่งตั้งข้าราชการ") - .Where(x => x.typeCommand.Trim().ToUpper() == "APPOIN") + // .Where(x => x.Placement!.PlacementType!.Name == "แต่งตั้งข้าราชการ") + // .Where(x => x.typeCommand.Trim().ToUpper() == "APPOIN") .ToList() join r in req.refIds on p.Id.ToString() equals r.refId @@ -2719,11 +2719,11 @@ namespace BMA.EHR.Placement.Service.Controllers public async Task> PostReportSlip([FromBody] ReportPersonRequest req) { var placementProfiles = await _context.PlacementProfiles - .Include(x => x.Placement) - .ThenInclude(x => x.PlacementType) + // .Include(x => x.Placement) + // .ThenInclude(x => x.PlacementType) .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Placement!.PlacementType!.Name == "เลื่อนข้าราชการ") - .Where(x => x.typeCommand.Trim().ToUpper() == "SLIP") + // .Where(x => x.Placement!.PlacementType!.Name == "เลื่อนข้าราชการ") + // .Where(x => x.typeCommand.Trim().ToUpper() == "SLIP") .ToListAsync(); placementProfiles.ForEach(profile => profile.PlacementStatus = "REPORT"); await _context.SaveChangesAsync(); @@ -2769,11 +2769,11 @@ namespace BMA.EHR.Placement.Service.Controllers try { var report_data = (from p in _context.PlacementProfiles - .Include(x => x.Placement) - .ThenInclude(x => x.PlacementType) + // .Include(x => x.Placement) + // .ThenInclude(x => x.PlacementType) .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) - .Where(x => x.Placement!.PlacementType!.Name == "เลื่อนข้าราชการ") - .Where(x => x.typeCommand.Trim().ToUpper() == "SLIP") + // .Where(x => x.Placement!.PlacementType!.Name == "เลื่อนข้าราชการ") + // .Where(x => x.typeCommand.Trim().ToUpper() == "SLIP") .ToList() join r in req.refIds on p.Id.ToString() equals r.refId From c694f08dbe5a921e5ee230a5e5caa1c3e50a5b51 Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 10 Oct 2024 13:45:43 +0700 Subject: [PATCH 39/42] no message --- .../Controllers/PlacementController.cs | 390 +----------------- .../Controllers/PlacementReceiveController.cs | 91 +++- 2 files changed, 75 insertions(+), 406 deletions(-) diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index 56d6394a..23f99565 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -1580,195 +1580,6 @@ namespace BMA.EHR.Placement.Service.Controllers /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpPost("recruit/report/excecute")] public async Task> PostReportExecuteRecruit([FromBody] ReportExecuteRequest req) - { - // create new profile - foreach (var recv in req.refIds) - { - // query placement Profile - var placementProfile = await _context.PlacementProfiles - .Include(x => x.PlacementCertificates) - .Include(x => x.PlacementEducations) - .ThenInclude(x => x.EducationLevel) - .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); - - if (placementProfile == null) - continue; - - /*ข้อมูล Profile ใหม่*/ - var apiUrl = $"{_configuration["API"]}/org/profile/all"; - var profileId = string.Empty; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl); - var _res = await client.PostAsJsonAsync(apiUrl, new - { - rank = string.Empty, - prefix = placementProfile.Prefix == null ? string.Empty : placementProfile.Prefix, - firstName = placementProfile.Firstname == null ? string.Empty : placementProfile.Firstname, - lastName = placementProfile.Lastname == null ? string.Empty : placementProfile.Lastname, - citizenId = placementProfile.CitizenId == null ? string.Empty : placementProfile.CitizenId, - position = placementProfile.positionName == null ? string.Empty : placementProfile.positionName, - posLevelId = placementProfile.posLevelId == null ? string.Empty : placementProfile.posLevelId, - posTypeId = placementProfile.posTypeId == null ? string.Empty : placementProfile.posTypeId, - email = placementProfile.Email == null ? string.Empty : placementProfile.Email, - phone = placementProfile.MobilePhone == null ? string.Empty : placementProfile.MobilePhone, - keycloak = string.Empty, - isProbation = true, - isLeave = false, - dateRetire = (DateTime?)null, - dateAppoint = recv.commandAffectDate, - dateStart = recv.commandAffectDate, - govAgeAbsent = 0, - govAgePlus = 0, - birthDate = placementProfile.DateOfBirth == null ? (DateTime?)null : placementProfile.DateOfBirth, - reasonSameDate = (DateTime?)null, - ethnicity = placementProfile.Race == null ? string.Empty : placementProfile.Race, - telephoneNumber = placementProfile.Telephone == null ? string.Empty : placementProfile.Telephone, - nationality = placementProfile.Nationality == null ? string.Empty : placementProfile.Nationality, - gender = placementProfile.Gender == null ? string.Empty : placementProfile.Gender, - relationship = placementProfile.Relationship == null ? string.Empty : placementProfile.Relationship, - religion = placementProfile.Religion == null ? string.Empty : placementProfile.Religion, - bloodGroup = string.Empty, - registrationAddress = placementProfile.RegistAddress == null ? string.Empty : placementProfile.RegistAddress, - registrationProvinceId = (String?)null, - registrationDistrictId = (String?)null, - registrationSubDistrictId = (String?)null, - registrationZipCode = placementProfile.RegistZipCode == null ? string.Empty : placementProfile.RegistZipCode, - currentAddress = placementProfile.CurrentAddress == null ? string.Empty : placementProfile.CurrentAddress, - currentProvinceId = (String?)null, - currentDistrictId = (String?)null, - currentSubDistrictId = (String?)null, - currentZipCode = placementProfile.CurrentZipCode == null ? string.Empty : placementProfile.CurrentZipCode, - }); - var _result = await _res.Content.ReadAsStringAsync(); - profileId = JsonConvert.DeserializeObject(_result).result; - } - - if (placementProfile.PlacementEducations != null) - { - var apiUrlEdu = $"{_configuration["API"]}/org/profile/educations"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - foreach (var edu in placementProfile.PlacementEducations) - { - var _res = await client.PostAsJsonAsync(apiUrlEdu, new - { - profileId = profileId, - country = edu.Country == null ? string.Empty : edu.Country, - degree = edu.Degree == null ? string.Empty : edu.Degree, - duration = edu.Duration == null ? string.Empty : edu.Duration, - durationYear = edu.DurationYear == null ? 0 : edu.DurationYear, - field = edu.Field == null ? string.Empty : edu.Field, - finishDate = edu.FinishDate == null ? (DateTime?)null : edu.FinishDate, - fundName = edu.FundName == null ? string.Empty : edu.FundName, - gpa = edu.Gpa == null ? string.Empty : edu.Gpa, - institute = edu.Institute == null ? string.Empty : edu.Institute, - other = edu.Other == null ? string.Empty : edu.Other, - startDate = edu.StartDate == null ? (DateTime?)null : edu.StartDate, - endDate = edu.EndDate == null ? (DateTime?)null : edu.EndDate, - educationLevel = edu.EducationLevel == null ? string.Empty : edu.EducationLevel.Name, - educationLevelId = string.Empty, - positionPath = edu.PositionPath == null ? null : edu.PositionPath, - positionPathId = string.Empty, - isDate = edu.IsDate, - isEducation = edu.IsEducation, - note = string.Empty, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - } - - if (placementProfile.PlacementCertificates != null) - { - var apiUrlCer = $"{_configuration["API"]}/org/profile/certificate"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - foreach (var cer in placementProfile.PlacementCertificates) - { - var _res = await client.PostAsJsonAsync(apiUrlCer, new - { - profileId = profileId, - expireDate = cer.ExpireDate == null ? (DateTime?)null : cer.ExpireDate, - issueDate = cer.IssueDate == null ? (DateTime?)null : cer.IssueDate, - certificateNo = cer.CertificateNo == null ? string.Empty : cer.CertificateNo, - certificateType = cer.CertificateType == null ? string.Empty : cer.CertificateType, - issuer = cer.Issuer == null ? string.Empty : cer.Issuer, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - } - - var apiUrlSalary = $"{_configuration["API"]}/org/profile/salary"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _res = await client.PostAsJsonAsync(apiUrlSalary, new - { - profileId = profileId, - date = recv.commandAffectDate, - amount = placementProfile.Amount, - positionSalaryAmount = placementProfile.PositionSalaryAmount, - mouthSalaryAmount = placementProfile.MouthSalaryAmount, - posNo = placementProfile.posMasterNo == null ? "" : - placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "", - position = placementProfile.positionName == null ? string.Empty : placementProfile.positionName, - positionLine = string.Empty, - positionPathSide = string.Empty, - positionExecutive = string.Empty, - positionType = placementProfile.posTypeName == null ? string.Empty : placementProfile.posTypeName, - positionLevel = placementProfile.posLevelName == null ? string.Empty : placementProfile.posLevelName, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - templateDoc = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - - var baseAPIOrg = _configuration["API"]; - var apiUrlOrg = $"{baseAPIOrg}/org/pos/report/current"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg); - var _res = await client.PostAsJsonAsync(apiUrlOrg, new - { - posmasterId = placementProfile.posmasterId, - positionId = placementProfile.positionId, - profileId = profileId, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - // update placementstatus - placementProfile.PlacementStatus = "DONE";//DONE - - await _context.SaveChangesAsync(); - } - return Success(); - } - - /// - /// ออกคำสั่ง C-PM-01 บรรจุและแต่งตั้งผู้สอบแข่งขันได้ (NEW) - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("recruit/report/excecute-new")] - public async Task> PostReportExecuteRecruitNew([FromBody] ReportExecuteRequest req) { try { @@ -1863,9 +1674,9 @@ namespace BMA.EHR.Placement.Service.Controllers { profileId = string.Empty, date = r.commandAffectDate, - amount = p.Amount, - positionSalaryAmount = p.PositionSalaryAmount, - mouthSalaryAmount = p.MouthSalaryAmount, + amount = r.amount, + positionSalaryAmount = r.positionSalaryAmount, + mouthSalaryAmount = r.mouthSalaryAmount, posNo = p.posMasterNo == null ? "" : p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}" : p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}" : @@ -2025,195 +1836,6 @@ namespace BMA.EHR.Placement.Service.Controllers /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpPost("candidate/report/excecute")] public async Task> PostReportExecuteCandidate([FromBody] ReportExecuteRequest req) - { - // create new profile - foreach (var recv in req.refIds) - { - // query placement Profile - var placementProfile = await _context.PlacementProfiles - .Include(x => x.PlacementCertificates) - .Include(x => x.PlacementEducations) - .ThenInclude(x => x.EducationLevel) - .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId)); - - if (placementProfile == null) - continue; - - /*ข้อมูล Profile ใหม่*/ - var apiUrl = $"{_configuration["API"]}/org/profile/all"; - var profileId = string.Empty; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl); - var _res = await client.PostAsJsonAsync(apiUrl, new - { - rank = string.Empty, - prefix = placementProfile.Prefix == null ? string.Empty : placementProfile.Prefix, - firstName = placementProfile.Firstname == null ? string.Empty : placementProfile.Firstname, - lastName = placementProfile.Lastname == null ? string.Empty : placementProfile.Lastname, - citizenId = placementProfile.CitizenId == null ? string.Empty : placementProfile.CitizenId, - position = placementProfile.positionName == null ? string.Empty : placementProfile.positionName, - posLevelId = placementProfile.posLevelId == null ? string.Empty : placementProfile.posLevelId, - posTypeId = placementProfile.posTypeId == null ? string.Empty : placementProfile.posTypeId, - email = placementProfile.Email == null ? string.Empty : placementProfile.Email, - phone = placementProfile.MobilePhone == null ? string.Empty : placementProfile.MobilePhone, - keycloak = string.Empty, - isProbation = true, - isLeave = false, - dateRetire = (DateTime?)null, - dateAppoint = recv.commandAffectDate, - dateStart = recv.commandAffectDate, - govAgeAbsent = 0, - govAgePlus = 0, - birthDate = placementProfile.DateOfBirth == null ? (DateTime?)null : placementProfile.DateOfBirth, - reasonSameDate = (DateTime?)null, - ethnicity = placementProfile.Race == null ? string.Empty : placementProfile.Race, - telephoneNumber = placementProfile.Telephone == null ? string.Empty : placementProfile.Telephone, - nationality = placementProfile.Nationality == null ? string.Empty : placementProfile.Nationality, - gender = placementProfile.Gender == null ? string.Empty : placementProfile.Gender, - relationship = placementProfile.Relationship == null ? string.Empty : placementProfile.Relationship, - religion = placementProfile.Religion == null ? string.Empty : placementProfile.Religion, - bloodGroup = string.Empty, - registrationAddress = placementProfile.RegistAddress == null ? string.Empty : placementProfile.RegistAddress, - registrationProvinceId = (String?)null, - registrationDistrictId = (String?)null, - registrationSubDistrictId = (String?)null, - registrationZipCode = placementProfile.RegistZipCode == null ? string.Empty : placementProfile.RegistZipCode, - currentAddress = placementProfile.CurrentAddress == null ? string.Empty : placementProfile.CurrentAddress, - currentProvinceId = (String?)null, - currentDistrictId = (String?)null, - currentSubDistrictId = (String?)null, - currentZipCode = placementProfile.CurrentZipCode == null ? string.Empty : placementProfile.CurrentZipCode, - }); - var _result = await _res.Content.ReadAsStringAsync(); - profileId = JsonConvert.DeserializeObject(_result).result; - } - - if (placementProfile.PlacementEducations != null) - { - var apiUrlEdu = $"{_configuration["API"]}/org/profile/educations"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - foreach (var edu in placementProfile.PlacementEducations) - { - var _res = await client.PostAsJsonAsync(apiUrlEdu, new - { - profileId = profileId, - country = edu.Country == null ? string.Empty : edu.Country, - degree = edu.Degree == null ? string.Empty : edu.Degree, - duration = edu.Duration == null ? string.Empty : edu.Duration, - durationYear = edu.DurationYear == null ? 0 : edu.DurationYear, - field = edu.Field == null ? string.Empty : edu.Field, - finishDate = edu.FinishDate == null ? (DateTime?)null : edu.FinishDate, - fundName = edu.FundName == null ? string.Empty : edu.FundName, - gpa = edu.Gpa == null ? string.Empty : edu.Gpa, - institute = edu.Institute == null ? string.Empty : edu.Institute, - other = edu.Other == null ? string.Empty : edu.Other, - startDate = edu.StartDate == null ? (DateTime?)null : edu.StartDate, - endDate = edu.EndDate == null ? (DateTime?)null : edu.EndDate, - educationLevel = edu.EducationLevel == null ? string.Empty : edu.EducationLevel.Name, - educationLevelId = string.Empty, - positionPath = edu.PositionPath == null ? null : edu.PositionPath, - positionPathId = string.Empty, - isDate = edu.IsDate, - isEducation = edu.IsEducation, - note = string.Empty, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - } - - if (placementProfile.PlacementCertificates != null) - { - var apiUrlCer = $"{_configuration["API"]}/org/profile/certificate"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - foreach (var cer in placementProfile.PlacementCertificates) - { - var _res = await client.PostAsJsonAsync(apiUrlCer, new - { - profileId = profileId, - expireDate = cer.ExpireDate == null ? (DateTime?)null : cer.ExpireDate, - issueDate = cer.IssueDate == null ? (DateTime?)null : cer.IssueDate, - certificateNo = cer.CertificateNo == null ? string.Empty : cer.CertificateNo, - certificateType = cer.CertificateType == null ? string.Empty : cer.CertificateType, - issuer = cer.Issuer == null ? string.Empty : cer.Issuer, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - } - - var apiUrlSalary = $"{_configuration["API"]}/org/profile/salary"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _res = await client.PostAsJsonAsync(apiUrlSalary, new - { - profileId = profileId, - date = recv.commandAffectDate, - amount = placementProfile.Amount, - positionSalaryAmount = placementProfile.PositionSalaryAmount, - mouthSalaryAmount = placementProfile.MouthSalaryAmount, - posNo = placementProfile.posMasterNo == null ? "" : - placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" : - placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "", - position = placementProfile.positionName == null ? string.Empty : placementProfile.positionName, - positionLine = string.Empty, - positionPathSide = string.Empty, - positionExecutive = string.Empty, - positionType = placementProfile.posTypeName == null ? string.Empty : placementProfile.posTypeName, - positionLevel = placementProfile.posLevelName == null ? string.Empty : placementProfile.posLevelName, - refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}", - templateDoc = recv.templateDoc, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - - var baseAPIOrg = _configuration["API"]; - var apiUrlOrg = $"{baseAPIOrg}/org/pos/report/current"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg); - var _res = await client.PostAsJsonAsync(apiUrlOrg, new - { - posmasterId = placementProfile.posmasterId, - positionId = placementProfile.positionId, - profileId = profileId, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - // update placementstatus - placementProfile.PlacementStatus = "DONE";//DONE - - await _context.SaveChangesAsync(); - } - return Success(); - } - - /// - /// ออกคำสั่ง C-PM-02 บรรจุและแต่งตั้งผู้ได้รับคัดเลือก (NEW) - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("candidate/report/excecute-new")] - public async Task> PostReportExecuteCandidateNew([FromBody] ReportExecuteRequest req) { try { @@ -2308,9 +1930,9 @@ namespace BMA.EHR.Placement.Service.Controllers { profileId = string.Empty, date = r.commandAffectDate, - amount = p.Amount, - positionSalaryAmount = p.PositionSalaryAmount, - mouthSalaryAmount = p.MouthSalaryAmount, + amount = r.amount, + positionSalaryAmount = r.positionSalaryAmount, + mouthSalaryAmount = r.mouthSalaryAmount, posNo = p.posMasterNo == null ? "" : p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}" : p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}" : diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs index 86fee36d..7a9f7c9d 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs @@ -998,31 +998,78 @@ namespace BMA.EHR.Placement.Service.Controllers on p.Id.ToString() equals r.refId select new { - profileId = p.profileId, - date = r.commandAffectDate, - amount = r.amount, - positionSalaryAmount = r.positionSalaryAmount, - mouthSalaryAmount = r.mouthSalaryAmount, - posNo = p.posMasterNo == null ? "" : - p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}" : - p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}" : - p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}" : - p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}" : - p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}" : "", - position = p.position, - positionLine = "", - positionPathSide = "", - positionExecutive = "", - positionType = p.posTypeName, - positionLevel = p.posLevelName, - refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}", - templateDoc = r.templateDoc, - posmasterId = p.posmasterId, - positionId = p.positionId, + bodyProfile = new + { + rank = string.Empty, + prefix = p.prefix == null ? string.Empty : p.prefix, + firstName = p.firstName == null ? string.Empty : p.firstName, + lastName = p.lastName == null ? string.Empty : p.lastName, + citizenId = p.citizenId == null ? string.Empty : p.citizenId, + position = p.position == null ? string.Empty : p.position, + posLevelId = p.posLevelId == null ? string.Empty : p.posLevelId, + posTypeId = p.posTypeId == null ? string.Empty : p.posTypeId, + email = (String?)null, + phone = (String?)null, + keycloak = string.Empty, + isProbation = true, + isLeave = false, + dateRetire = (DateTime?)null, + dateAppoint = r.commandAffectDate, + dateStart = r.commandAffectDate, + govAgeAbsent = 0, + govAgePlus = 0, + birthDate = p.DateOfBirth == null ? (DateTime?)null : p.DateOfBirth, + reasonSameDate = (DateTime?)null, + ethnicity = p.Race == null ? string.Empty : p.Race, + telephoneNumber = (String?)null, + nationality = p.Nationality == null ? string.Empty : p.Nationality, + gender = p.Gender == null ? string.Empty : p.Gender, + relationship = p.Relationship == null ? string.Empty : p.Relationship, + religion = p.Religion == null ? string.Empty : p.Religion, + bloodGroup = string.Empty, + registrationAddress = (String?)null, + registrationProvinceId = (String?)null, + registrationDistrictId = (String?)null, + registrationSubDistrictId = (String?)null, + registrationZipCode = (String?)null, + currentAddress = (String?)null, + currentProvinceId = (String?)null, + currentDistrictId = (String?)null, + currentSubDistrictId = (String?)null, + currentZipCode = (String?)null, + }, + bodySalarys = new + { + profileId = string.Empty, + date = r.commandAffectDate, + amount = r.amount, + positionSalaryAmount = r.positionSalaryAmount, + mouthSalaryAmount = r.mouthSalaryAmount, + posNo = p.posMasterNo == null ? "" : + p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}" : + p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}" : + p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}" : + p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}" : + p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}" : "", + position = p.position == null ? string.Empty : p.position, + positionLine = string.Empty, + positionPathSide = string.Empty, + positionExecutive = string.Empty, + positionType = p.posTypeName == null ? string.Empty : p.posTypeName, + positionLevel = p.posLevelName == null ? string.Empty : p.posLevelName, + refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}", + templateDoc = r.templateDoc + }, + bodyPosition = new + { + posmasterId = p.posmasterId, + positionId = p.positionId + } }).ToList(); var baseAPIOrg = _configuration["API"]; - var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current"; + //var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current"; + var apiUrlOrg = $"{_configuration["API"]}/org/command/excexute/create-officer-profile"; using (var client = new HttpClient()) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); From edd5bfe0c271e7eb6e14dbf0b8924f83e07deecd Mon Sep 17 00:00:00 2001 From: kittapath Date: Thu, 10 Oct 2024 19:26:01 +0700 Subject: [PATCH 40/42] no message --- .../Controllers/DisciplineResultController.cs | 32 +++--- .../PlacementAppointmentController.cs | 86 ++++++---------- .../Controllers/PlacementController.cs | 99 +++++++++---------- .../Controllers/PlacementOfficerController.cs | 5 +- .../Controllers/PlacementReceiveController.cs | 17 ++-- .../PlacementTransferController.cs | 17 ++-- .../Controllers/RetirementOtherController.cs | 44 ++++----- .../Controllers/RetirementOutController.cs | 2 +- .../Controllers/RetirementResignController.cs | 48 --------- 9 files changed, 126 insertions(+), 224 deletions(-) diff --git a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs index 749394de..e05bd0ad 100644 --- a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs +++ b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs @@ -771,7 +771,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers { var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Status.ToUpper() == "REPORT") + // .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); data.ForEach(profile => profile.Status = "NEW"); await _context.SaveChangesAsync(); @@ -863,7 +863,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers { var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Status.ToUpper() == "REPORT") + // .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); data.ForEach(profile => profile.Status = "NEW"); await _context.SaveChangesAsync(); @@ -964,7 +964,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers { var data = await _context.DisciplineReport_Profiles .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Status.ToUpper() == "REPORT") + // .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); data.ForEach(profile => profile.Status = "PENDING"); await _context.SaveChangesAsync(); @@ -995,7 +995,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers try { var data = await _context.DisciplineReport_Profiles - .Where(x => x.Status == "REPORT") + // .Where(x => x.Status == "REPORT") .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) .ToListAsync(); @@ -1032,7 +1032,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers { var data = await _context.DisciplineReport_Profiles .Include(x => x.DisciplineDisciplinary) - .Where(x => x.Status == "REPORT") + // .Where(x => x.Status == "REPORT") .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) .ToListAsync(); var resultData = (from p in data @@ -1114,7 +1114,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers { var data = await _context.DisciplineReport_Profiles .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Status.ToUpper() == "REPORT") + // .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); data.ForEach(profile => profile.Status = "PENDING"); await _context.SaveChangesAsync(); @@ -1140,7 +1140,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers var data = await _context.DisciplineReport_Profiles .Include(x => x.DisciplineDisciplinary) - .Where(x => x.Status == "REPORT") + // .Where(x => x.Status == "REPORT") .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) .ToListAsync(); var resultData = (from p in data @@ -1222,7 +1222,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers { var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Status.ToUpper() == "REPORT") + // .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); data.ForEach(profile => profile.Status = "NEW"); await _context.SaveChangesAsync(); @@ -1329,7 +1329,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers { var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Status.ToUpper() == "REPORT") + // .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); data.ForEach(profile => profile.Status = "NEW"); await _context.SaveChangesAsync(); @@ -1436,7 +1436,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers { var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Status.ToUpper() == "REPORT") + // .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); data.ForEach(profile => profile.Status = "NEW"); await _context.SaveChangesAsync(); @@ -1543,7 +1543,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers { var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Status.ToUpper() == "REPORT") + // .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); data.ForEach(profile => profile.Status = "NEW"); await _context.SaveChangesAsync(); @@ -1650,7 +1650,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers { var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.StatusDiscard.ToUpper() == "REPORT") + // .Where(x => x.StatusDiscard.ToUpper() == "REPORT") .ToListAsync(); data.ForEach(profile => profile.StatusDiscard = "NEW"); await _context.SaveChangesAsync(); @@ -1764,13 +1764,13 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers { var data1 = await _context.DisciplineInvestigate_ProfileComplaints .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.IsReport == "REPORT") + // .Where(x => x.IsReport == "REPORT") .ToListAsync(); data1.ForEach(profile => profile.IsReport = "NEW"); var data2 = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.IsReport == "REPORT") + // .Where(x => x.IsReport == "REPORT") .ToListAsync(); data2.ForEach(profile => profile.IsReport = "NEW"); @@ -1797,7 +1797,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers { var data = await _context.DisciplineInvestigate_ProfileComplaints .Include(x => x.DisciplineInvestigate) - .Where(x => x.IsReport == "REPORT") + // .Where(x => x.IsReport == "REPORT") .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) .ToListAsync(); string? _null = null; @@ -1838,7 +1838,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers var data1 = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates .Include(x => x.DisciplineDisciplinary) - .Where(x => x.IsReport == "REPORT") + // .Where(x => x.IsReport == "REPORT") .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) .ToListAsync(); var resultData1 = (from p in data1 diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs index 4114a456..c6070a06 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs @@ -775,7 +775,7 @@ namespace BMA.EHR.Placement.Service.Controllers { var placementProfiles = await _context.PlacementAppointments .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Status.ToUpper() == "REPORT") + // .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); placementProfiles.ForEach(profile => profile.Status = "PENDING"); await _context.SaveChangesAsync(); @@ -808,21 +808,18 @@ namespace BMA.EHR.Placement.Service.Controllers orderby r.Sequence select new { - Education = p.EducationOld == null ? "-" : p.EducationOld, - Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + No = r.Sequence.ToString().ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - OldOc = p.rootOld == null ? "" : p.rootOld, - OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, - OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, + Education = p.EducationOld == null ? "-" : p.EducationOld, + OldOc = (p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld) + "/" + (p.rootOld == null ? "" : p.rootOld), OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, + OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), - OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), - NewOc = p.root == null ? "" : p.root, - NewPositionName = p.position == null ? "" : p.position, - NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, + LeaveDate = "", + NewOc = (p.position == null ? "" : p.position) + "/" + (p.root == null ? "" : p.root), NewPositionType = p.posTypeName == null ? "" : p.posTypeName, + NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, NewPositionNumber = p.posMasterNo == null ? "" : p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : @@ -831,7 +828,6 @@ namespace BMA.EHR.Placement.Service.Controllers p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), - Reason = p.Reason == null ? "-" : p.Reason, RemarkHorizontal = r.RemarkHorizontal, RemarkVertical = r.RemarkVertical, }).ToList(); @@ -937,7 +933,7 @@ namespace BMA.EHR.Placement.Service.Controllers { var placementProfiles = await _context.PlacementAppointments .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Status.ToUpper() == "REPORT") + // .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); placementProfiles.ForEach(profile => profile.Status = "PENDING"); await _context.SaveChangesAsync(); @@ -970,21 +966,18 @@ namespace BMA.EHR.Placement.Service.Controllers orderby r.Sequence select new { - Education = p.EducationOld == null ? "-" : p.EducationOld, - Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + No = r.Sequence.ToString().ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - OldOc = p.rootOld == null ? "" : p.rootOld, - OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, - OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, + Education = p.EducationOld == null ? "-" : p.EducationOld, + OldOc = (p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld) + "/" + (p.rootOld == null ? "" : p.rootOld), OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, + OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), - OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), - NewOc = p.root == null ? "" : p.root, - NewPositionName = p.position == null ? "" : p.position, - NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, + LeaveDate = "", + NewOc = (p.position == null ? "" : p.position) + "/" + (p.root == null ? "" : p.root), NewPositionType = p.posTypeName == null ? "" : p.posTypeName, + NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, NewPositionNumber = p.posMasterNo == null ? "" : p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : @@ -993,7 +986,6 @@ namespace BMA.EHR.Placement.Service.Controllers p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), - Reason = p.Reason == null ? "-" : p.Reason, RemarkHorizontal = r.RemarkHorizontal, RemarkVertical = r.RemarkVertical, }).ToList(); @@ -1099,7 +1091,7 @@ namespace BMA.EHR.Placement.Service.Controllers { var placementProfiles = await _context.PlacementAppointments .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Status.ToUpper() == "REPORT") + // .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); placementProfiles.ForEach(profile => profile.Status = "PENDING"); await _context.SaveChangesAsync(); @@ -1132,21 +1124,18 @@ namespace BMA.EHR.Placement.Service.Controllers orderby r.Sequence select new { - Education = p.EducationOld == null ? "-" : p.EducationOld, - Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + No = r.Sequence.ToString().ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - OldOc = p.rootOld == null ? "" : p.rootOld, - OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, - OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, + Education = p.EducationOld == null ? "-" : p.EducationOld, + OldOc = (p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld) + "/" + (p.rootOld == null ? "" : p.rootOld), OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, + OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), - OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), - NewOc = p.root == null ? "" : p.root, - NewPositionName = p.position == null ? "" : p.position, - NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, + LeaveDate = "", + NewOc = (p.position == null ? "" : p.position) + "/" + (p.root == null ? "" : p.root), NewPositionType = p.posTypeName == null ? "" : p.posTypeName, + NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, NewPositionNumber = p.posMasterNo == null ? "" : p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : @@ -1155,7 +1144,6 @@ namespace BMA.EHR.Placement.Service.Controllers p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), - Reason = p.Reason == null ? "-" : p.Reason, RemarkHorizontal = r.RemarkHorizontal, RemarkVertical = r.RemarkVertical, }).ToList(); @@ -1263,7 +1251,7 @@ namespace BMA.EHR.Placement.Service.Controllers var placementProfiles = await _context.PlacementAppointments .Where(x => req.refIds.Contains(x.Id.ToString())) // .Where(x => x.type == "EMPLOYEE") - .Where(x => x.Status.ToUpper() == "REPORT") + // .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); placementProfiles.ForEach(profile => profile.Status = "PENDING"); await _context.SaveChangesAsync(); @@ -1297,16 +1285,13 @@ namespace BMA.EHR.Placement.Service.Controllers orderby r.Sequence select new { - Seq = r.Sequence.ToString().ToThaiNumber(), + No = r.Sequence.ToString().ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - Organization = p.rootOld, - OldOrganization = p.OrganizationOld, - OldPositionName = p.positionOld, + OldOrganization = (p.positionOld == null ? "" : p.positionOld) + "/" + (p.OrganizationOld == null ? "" : p.OrganizationOld), OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld.ToThaiNumber(), OldPositionNumber = p.PositionNumberOld == null ? null : p.PositionNumberOld.ToThaiNumber(), OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), - NewOc = p.root == null ? "" : p.root, - NewPositionName = p.position == null ? "" : p.position, + NewOc = (p.position == null ? "" : p.position) + "/" + (p.root == null ? "" : p.root), NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName.ToThaiNumber(), NewPositionNumber = p.posMasterNo == null ? "" : p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : @@ -1315,7 +1300,6 @@ namespace BMA.EHR.Placement.Service.Controllers p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), - Reason = p.Reason == null ? "-" : p.Reason, RemarkHorizontal = r.RemarkHorizontal, RemarkVertical = r.RemarkVertical, }).ToList(); @@ -1420,7 +1404,7 @@ namespace BMA.EHR.Placement.Service.Controllers var placementProfiles = await _context.PlacementAppointments .Where(x => req.refIds.Contains(x.Id.ToString())) // .Where(x => x.type == "EMPLOYEE") - .Where(x => x.Status.ToUpper() == "REPORT") + // .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); placementProfiles.ForEach(profile => profile.Status = "PENDING"); await _context.SaveChangesAsync(); @@ -1454,17 +1438,12 @@ namespace BMA.EHR.Placement.Service.Controllers orderby r.Sequence select new { - Seq = r.Sequence.ToString().ToThaiNumber(), + No = r.Sequence.ToString().ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - Organization = p.OrganizationPositionOld, - OldOrganization = p.OrganizationOld, - OldPositionName = p.positionOld, - OldPositionLevel = p.PositionLevelOld, + OldOc = (p.positionOld == null ? "" : p.positionOld) + "/" + (p.OrganizationOld == null ? "" : p.OrganizationOld), OldPositionNumber = p.PositionNumberOld == null ? null : p.PositionNumberOld.ToThaiNumber(), OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), - NewOc = p.root == null ? "" : p.root, - NewPositionName = p.position == null ? "" : p.position, - NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, + NewOc = (p.position == null ? "" : p.position) + "/" + (p.root == null ? "" : p.root), NewPositionNumber = p.posMasterNo == null ? "" : p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : @@ -1472,7 +1451,6 @@ namespace BMA.EHR.Placement.Service.Controllers p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() : p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), - Reason = p.Reason == null ? "-" : p.Reason, RemarkHorizontal = r.RemarkHorizontal, RemarkVertical = r.RemarkVertical, }).ToList(); diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index e5d17e45..170de44a 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -1503,7 +1503,7 @@ namespace BMA.EHR.Placement.Service.Controllers { var placementProfiles = await _context.PlacementProfiles .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.PlacementStatus.ToUpper() == "REPORT") + // .Where(x => x.PlacementStatus.ToUpper() == "REPORT") .ToListAsync(); placementProfiles.ForEach(profile => profile.PlacementStatus = "PREPARE-CONTAIN"); await _context.SaveChangesAsync(); @@ -1529,7 +1529,8 @@ namespace BMA.EHR.Placement.Service.Controllers try { var report_data = (from p in _context.PlacementProfiles - // .Include(x => x.Placement) + .Include(x => x.Placement) + .Include(x => x.PlacementEducations) // .ThenInclude(x => x.PlacementType) .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) // .Where(x => x.Placement!.PlacementType!.Name != "สอบแข่งขัน") @@ -1540,15 +1541,16 @@ namespace BMA.EHR.Placement.Service.Controllers orderby r.Sequence select new { + No = r.Sequence.ToString().ToThaiNumber(), + FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" : p.PlacementEducations.FirstOrDefault().Degree, - Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), - FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - Oc = p.root == null ? "" : p.root, PositionName = p.positionName == null ? "" : p.positionName, - PositionLevel = p.posLevelName == null ? "" : p.posLevelName, + ExamNumber = p.ExamNumber == null ? "0" : p.ExamNumber.Value.ToString().ToThaiNumber(), + PlacementName = $"{p.Placement.Name.ToThaiNumber()} ครั้งที่ {p.Placement.Round.ToThaiNumber()}/{p.Placement.Year.ToThaiYear().ToString().ToThaiNumber()}", + Oc = (p.positionName == null ? "" : p.positionName) + "/" + (p.root == null ? "" : p.root), PositionType = p.posTypeName == null ? "" : p.posTypeName, + PositionLevel = p.posLevelName == null ? "" : p.posLevelName, PositionNumber = p.posMasterNo == null ? "" : p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : @@ -1557,8 +1559,6 @@ namespace BMA.EHR.Placement.Service.Controllers p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", Salary = r.Amount == null ? "0" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber().ToThaiNumber(), AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), - ExamNumber = p.ExamNumber == null ? "0" : p.ExamNumber.Value.ToString().ToThaiNumber(), - PlacementName = $"{p.Placement.Name.ToThaiNumber()} ครั้งที่ {p.Placement.Round.ToThaiNumber()}/{p.Placement.Year.ToThaiYear().ToString().ToThaiNumber()}", RemarkHorizontal = r.RemarkHorizontal, RemarkVertical = r.RemarkVertical, }).ToList(); @@ -1759,7 +1759,7 @@ namespace BMA.EHR.Placement.Service.Controllers { var placementProfiles = await _context.PlacementProfiles .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.PlacementStatus.ToUpper() == "REPORT") + // .Where(x => x.PlacementStatus.ToUpper() == "REPORT") .ToListAsync(); placementProfiles.ForEach(profile => profile.PlacementStatus = "PREPARE-CONTAI"); await _context.SaveChangesAsync(); @@ -1785,7 +1785,8 @@ namespace BMA.EHR.Placement.Service.Controllers try { var report_data = (from p in _context.PlacementProfiles - // .Include(x => x.Placement) + .Include(x => x.Placement) + .Include(x => x.PlacementEducations) // .ThenInclude(x => x.PlacementType) .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) // .Where(x => x.Placement!.PlacementType!.Name != "สอบแข่งขัน") @@ -1796,15 +1797,16 @@ namespace BMA.EHR.Placement.Service.Controllers orderby r.Sequence select new { - Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" : - p.PlacementEducations.FirstOrDefault().Degree, - Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + No = r.Sequence.ToString().ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - Oc = p.root == null ? "" : p.root, + Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" : + p.PlacementEducations.FirstOrDefault().Degree, PositionName = p.positionName == null ? "" : p.positionName, - PositionLevel = p.posLevelName == null ? "" : p.posLevelName, + ExamNumber = p.ExamNumber == null ? "0" : p.ExamNumber.Value.ToString().ToThaiNumber(), + PlacementName = $"{p.Placement.Name.ToThaiNumber()} ครั้งที่ {p.Placement.Round.ToThaiNumber()}/{p.Placement.Year.ToThaiYear().ToString().ToThaiNumber()}", + Oc = (p.positionName == null ? "" : p.positionName) + "/" + (p.root == null ? "" : p.root), PositionType = p.posTypeName == null ? "" : p.posTypeName, + PositionLevel = p.posLevelName == null ? "" : p.posLevelName, PositionNumber = p.posMasterNo == null ? "" : p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : @@ -1813,8 +1815,6 @@ namespace BMA.EHR.Placement.Service.Controllers p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", Salary = r.Amount == null ? "0" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber().ToThaiNumber(), AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), - ExamNumber = p.ExamNumber == null ? "0" : p.ExamNumber.Value.ToString().ToThaiNumber(), - PlacementName = $"{p.Placement.Name.ToThaiNumber()} ครั้งที่ {p.Placement.Round.ToThaiNumber()}/{p.Placement.Year.ToThaiYear().ToString().ToThaiNumber()}", RemarkHorizontal = r.RemarkHorizontal, RemarkVertical = r.RemarkVertical, }).ToList(); @@ -2015,7 +2015,7 @@ namespace BMA.EHR.Placement.Service.Controllers { var placementProfiles = await _context.PlacementProfiles .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.PlacementStatus.ToUpper() == "REPORT") + // .Where(x => x.PlacementStatus.ToUpper() == "REPORT") .ToListAsync(); placementProfiles.ForEach(profile => profile.PlacementStatus = "PREPARE-CONTAIN"); await _context.SaveChangesAsync(); @@ -2041,7 +2041,7 @@ namespace BMA.EHR.Placement.Service.Controllers try { var report_data = (from p in _context.PlacementProfiles - // .Include(x => x.Placement) + .Include(x => x.PlacementEducations) // .ThenInclude(x => x.PlacementType) .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) // .Where(x => x.Placement!.PlacementType!.Name == "แต่งตั้งข้าราชการ") @@ -2052,16 +2052,13 @@ namespace BMA.EHR.Placement.Service.Controllers orderby r.Sequence select new { + No = r.Sequence.ToString().ToThaiNumber(), + FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" : p.PlacementEducations.FirstOrDefault().Degree, - Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), - FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - OldOc = p.rootOld == null ? "" : p.rootOld, - Probation = "", - OldPositionName = p.positionNameOld == null ? "" : p.positionNameOld, - OldPositionLevel = p.posLevelNameOld == null ? "" : p.posLevelNameOld, + OldOc = (p.positionNameOld == null ? "" : p.positionNameOld) + "/" + (p.rootOld == null ? "" : p.rootOld), OldPositionType = p.posTypeNameOld == null ? "" : p.posTypeNameOld, + OldPositionLevel = p.posLevelNameOld == null ? "" : p.posLevelNameOld, OldPositionNumber = p.posMasterNoOld == null ? "" : p.nodeOld == "4" ? $"{p.child4ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : p.nodeOld == "3" ? $"{p.child3ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : @@ -2069,11 +2066,9 @@ namespace BMA.EHR.Placement.Service.Controllers p.nodeOld == "1" ? $"{p.child1ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : p.nodeOld == "0" ? $"{p.rootShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : "", OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), - - NewOc = p.root == null ? "" : p.root, - NewPositionName = p.positionName == null ? "" : p.positionName, - NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, + NewOc = (p.positionName == null ? "" : p.positionName) + "/" + (p.root == null ? "" : p.root), NewPositionType = p.posTypeName == null ? "" : p.posTypeName, + NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, NewPositionNumber = p.posMasterNo == null ? "" : p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : @@ -2083,7 +2078,7 @@ namespace BMA.EHR.Placement.Service.Controllers NewSalary = p.Amount == null ? "" : p.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), RemarkHorizontal = r.RemarkHorizontal, - RemarkVertical = r.RemarkVertical + RemarkVertical = r.RemarkVertical, }).ToList(); return Success(report_data); } @@ -2191,7 +2186,7 @@ namespace BMA.EHR.Placement.Service.Controllers { var placementProfiles = await _context.PlacementProfiles .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.PlacementStatus.ToUpper() == "REPORT") + // .Where(x => x.PlacementStatus.ToUpper() == "REPORT") .ToListAsync(); placementProfiles.ForEach(profile => profile.PlacementStatus = "PREPARE-CONTAIN"); await _context.SaveChangesAsync(); @@ -2217,7 +2212,7 @@ namespace BMA.EHR.Placement.Service.Controllers try { var report_data = (from p in _context.PlacementProfiles - // .Include(x => x.Placement) + .Include(x => x.PlacementEducations) // .ThenInclude(x => x.PlacementType) .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) // .Where(x => x.Placement!.PlacementType!.Name == "แต่งตั้งข้าราชการ") @@ -2228,15 +2223,13 @@ namespace BMA.EHR.Placement.Service.Controllers orderby r.Sequence select new { + No = r.Sequence.ToString().ToThaiNumber(), + FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" : p.PlacementEducations.FirstOrDefault().Degree, - Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), - FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - OldOc = p.rootOld == null ? "" : p.rootOld, - OldPositionName = p.positionNameOld == null ? "" : p.positionNameOld, - OldPositionLevel = p.posLevelNameOld == null ? "" : p.posLevelNameOld, + OldOc = (p.positionNameOld == null ? "" : p.positionNameOld) + "/" + (p.rootOld == null ? "" : p.rootOld), OldPositionType = p.posTypeNameOld == null ? "" : p.posTypeNameOld, + OldPositionLevel = p.posLevelNameOld == null ? "" : p.posLevelNameOld, OldPositionNumber = p.posMasterNoOld == null ? "" : p.nodeOld == "4" ? $"{p.child4ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : p.nodeOld == "3" ? $"{p.child3ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : @@ -2244,10 +2237,9 @@ namespace BMA.EHR.Placement.Service.Controllers p.nodeOld == "1" ? $"{p.child1ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : p.nodeOld == "0" ? $"{p.rootShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : "", OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), - NewOc = p.root == null ? "" : p.root, - NewPositionName = p.positionName == null ? "" : p.positionName, - NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, + NewOc = (p.positionName == null ? "" : p.positionName) + "/" + (p.root == null ? "" : p.root), NewPositionType = p.posTypeName == null ? "" : p.posTypeName, + NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, NewPositionNumber = p.posMasterNo == null ? "" : p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : @@ -2365,7 +2357,7 @@ namespace BMA.EHR.Placement.Service.Controllers { var placementProfiles = await _context.PlacementProfiles .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.PlacementStatus.ToUpper() == "REPORT") + // .Where(x => x.PlacementStatus.ToUpper() == "REPORT") .ToListAsync(); placementProfiles.ForEach(profile => profile.PlacementStatus = "PREPARE-CONTAIN"); await _context.SaveChangesAsync(); @@ -2391,7 +2383,7 @@ namespace BMA.EHR.Placement.Service.Controllers try { var report_data = (from p in _context.PlacementProfiles - // .Include(x => x.Placement) + .Include(x => x.PlacementEducations) // .ThenInclude(x => x.PlacementType) .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) // .Where(x => x.Placement!.PlacementType!.Name == "เลื่อนข้าราชการ") @@ -2402,15 +2394,13 @@ namespace BMA.EHR.Placement.Service.Controllers orderby r.Sequence select new { + No = r.Sequence.ToString().ToThaiNumber(), + FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" : p.PlacementEducations.FirstOrDefault().Degree, - Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), - FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - OldOc = p.rootOld == null ? "" : p.rootOld, - OldPositionName = p.positionNameOld == null ? "" : p.positionNameOld, - OldPositionLevel = p.posLevelNameOld == null ? "" : p.posLevelNameOld, + OldOc = (p.positionNameOld == null ? "" : p.positionNameOld) + "/" + (p.rootOld == null ? "" : p.rootOld), OldPositionType = p.posTypeNameOld == null ? "" : p.posTypeNameOld, + OldPositionLevel = p.posLevelNameOld == null ? "" : p.posLevelNameOld, OldPositionNumber = p.posMasterNoOld == null ? "" : p.nodeOld == "4" ? $"{p.child4ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : p.nodeOld == "3" ? $"{p.child3ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : @@ -2418,10 +2408,9 @@ namespace BMA.EHR.Placement.Service.Controllers p.nodeOld == "1" ? $"{p.child1ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : p.nodeOld == "0" ? $"{p.rootShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : "", OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), - NewOc = p.root == null ? "" : p.root, - NewPositionName = p.positionName == null ? "" : p.positionName, - NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, + NewOc = (p.positionName == null ? "" : p.positionName) + "/" + (p.root == null ? "" : p.root), NewPositionType = p.posTypeName == null ? "" : p.posTypeName, + NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, NewPositionNumber = p.posMasterNo == null ? "" : p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs index 99268cd2..02dfe7d6 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs @@ -602,7 +602,7 @@ namespace BMA.EHR.Placement.Service.Controllers { var placementProfiles = await _context.PlacementOfficers .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Status.ToUpper() == "REPORT") + // .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); placementProfiles.ForEach(profile => profile.Status = "APPROVE"); await _context.SaveChangesAsync(); @@ -635,8 +635,7 @@ namespace BMA.EHR.Placement.Service.Controllers orderby r.Sequence select new { - Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + No = r.Sequence.ToString().ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", PositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, Organization = p.Organization == null ? "" : p.Organization, diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs index 7a9f7c9d..a912f42a 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs @@ -912,7 +912,7 @@ namespace BMA.EHR.Placement.Service.Controllers { var placementProfiles = await _context.PlacementReceives .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Status.ToUpper() == "REPORT") + // .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); placementProfiles.ForEach(profile => profile.Status = "PENDING"); await _context.SaveChangesAsync(); @@ -945,20 +945,16 @@ namespace BMA.EHR.Placement.Service.Controllers orderby r.Sequence select new { - Education = p.EducationOld == null ? "-" : p.EducationOld, - Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + No = r.Sequence.ToString().ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + Education = p.EducationOld == null ? "-" : p.EducationOld, OldOc = p.OrganizationPositionOld ?? "", - OldPositionName = p.OrganizationPositionOld ?? "", - OldPositionLevel = p.PositionLevelOld ?? "", OldPositionType = p.PositionTypeOld ?? "", - OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), + OldPositionLevel = p.PositionLevelOld ?? "", OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), - NewOc = p.root == null ? "" : p.root, - NewPositionName = p.position == null ? "" : p.position, - NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, + NewOc = (p.position == null ? "" : p.position) + "/" + (p.root == null ? "" : p.root), NewPositionType = p.posTypeName == null ? "" : p.posTypeName, + NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName, NewPositionNumber = p.posMasterNo == null ? "" : p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() : p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() : @@ -967,7 +963,6 @@ namespace BMA.EHR.Placement.Service.Controllers p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "", NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(), - Reason = p.Reason == null ? "-" : p.Reason, RemarkHorizontal = r.RemarkHorizontal, RemarkVertical = r.RemarkVertical, }).ToList(); diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs index 57329436..65361663 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs @@ -791,7 +791,7 @@ namespace BMA.EHR.Placement.Service.Controllers { var placementProfiles = await _context.PlacementTransfers .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Status.ToUpper() == "REPORT") + // .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); placementProfiles.ForEach(profile => profile.Status = "APPROVE"); await _context.SaveChangesAsync(); @@ -824,19 +824,18 @@ namespace BMA.EHR.Placement.Service.Controllers orderby r.Sequence select new { - Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + No = r.Sequence.ToString().ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - Organization = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, - PositionName = p.PositionOld == null ? "" : p.PositionOld, - PositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, + Oc = (p.PositionOld == null ? "" : p.PositionOld) + "/" + (p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld), PositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, + PositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), Salary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), - ActiveDate = p.Date == null ? "" : p.Date.Value.ToThaiShortDate2().ToThaiNumber(), - //ReceiveOrganizationName = r.Command!.ReceiveOrganizationName ?? "", ReceiveOrganizationName = "", - Reason = p.Reason ?? "" + ActiveDate = p.Date == null ? "" : p.Date.Value.ToThaiShortDate2().ToThaiNumber(), + Reason = p.Reason ?? "", + RemarkHorizontal = r.RemarkHorizontal, + RemarkVertical = r.RemarkVertical, }).ToList(); return Success(report_data); } diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs index 33ccabb3..6a2af848 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs @@ -658,7 +658,7 @@ namespace BMA.EHR.Retirement.Service.Controllers { var placementProfiles = await _context.RetirementOthers .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Status.ToUpper() == "REPORT") + // .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); placementProfiles.ForEach(profile => profile.Status = "WAITTING"); await _context.SaveChangesAsync(); @@ -691,26 +691,21 @@ namespace BMA.EHR.Retirement.Service.Controllers orderby r.Sequence select new { - Education = p.EducationOld == null ? "-" : p.EducationOld, - Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + No = r.Sequence.ToString().ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - OldOc = p.rootOld == null ? "" : p.rootOld, - OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, - OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, + Education = p.EducationOld == null ? "-" : p.EducationOld, + OldOc = (p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld) + "/" + (p.rootOld == null ? "" : p.rootOld), OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, + OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), - OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), - NewOc = p.rootOld == null ? "" : p.rootOld, - NewPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, - NewPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, + LeaveDate = "", + NewOc = (p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld) + "/" + (p.rootOld == null ? "" : p.rootOld), NewPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, + NewPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, NewPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), AppointDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), - LeaveDate = p.LeaveDate == null ? "" : p.LeaveDate.Value.ToThaiShortDate2().ToThaiNumber(), - Reason = p.Reason == null ? "-" : p.Reason, RemarkHorizontal = r.RemarkHorizontal, RemarkVertical = r.RemarkVertical, }).ToList(); @@ -813,7 +808,7 @@ namespace BMA.EHR.Retirement.Service.Controllers { var placementProfiles = await _context.RetirementOthers .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Status.ToUpper() == "REPORT") + // .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); placementProfiles.ForEach(profile => profile.Status = "WAITTING"); await _context.SaveChangesAsync(); @@ -846,27 +841,22 @@ namespace BMA.EHR.Retirement.Service.Controllers orderby r.Sequence select new { - Education = p.EducationOld == null ? "-" : p.EducationOld, - Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), + No = r.Sequence.ToString().ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - OldOc = p.rootOld == null ? "" : p.rootOld, - OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, - OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, + Education = p.EducationOld == null ? "-" : p.EducationOld, + OldOc = (p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld) + "/" + (p.rootOld == null ? "" : p.rootOld), OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, + OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), - OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), - NewOc = p.rootOld == null ? "" : p.rootOld, - NewPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, - NewPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, + LeaveDate = "", + MilitaryDate = p.MilitaryDate == null ? "" : p.MilitaryDate.Value.ToThaiShortDate2().ToThaiNumber(), + NewOc = (p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld) + "/" + (p.rootOld == null ? "" : p.rootOld), NewPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, + NewPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, NewPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), AppointDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), - LeaveDate = p.LeaveDate == null ? "" : p.LeaveDate.Value.ToThaiShortDate2().ToThaiNumber(), - MilitaryDate = p.MilitaryDate == null ? "" : p.MilitaryDate.Value.ToThaiShortDate2().ToThaiNumber(), - Reason = p.Reason == null ? "-" : p.Reason, RemarkHorizontal = r.RemarkHorizontal, RemarkVertical = r.RemarkVertical, }).ToList(); diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs index ec8982d5..887cc1f3 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs @@ -499,7 +499,7 @@ namespace BMA.EHR.Retirement.Service.Controllers { var placementProfiles = await _context.RetirementResigns .Where(x => req.refIds.Contains(x.Id.ToString())) - .Where(x => x.Status.ToUpper() == "REPORT") + // .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); placementProfiles.ForEach(profile => profile.Status = "APPROVE"); await _context.SaveChangesAsync(); diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs index 2256fe75..a5f7f0c3 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs @@ -1810,54 +1810,6 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda return Success(); } - /// - /// เอกสารแนบท้าย C-PM-23 - /// - /// Record Id ของคำสั่ง - /// pdf, docx หรือ xlsx - /// - /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPost("employee/report/attachment")] - [AllowAnonymous] - [ProducesResponseType(StatusCodes.Status200OK)] - [ProducesResponseType(StatusCodes.Status401Unauthorized)] - [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> PostReportEmployeeAttachment([FromBody] ReportAttachmentRequest req) - { - try - { - var report_data = (from p in _context.RetirementResigns - .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) - .ToList() - join r in req.refIds - on p.Id.ToString() equals r.refId - orderby r.Sequence - select new - { - Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), - FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", - Organization = p.OrganizationPositionOld ?? "", - PositionName = p.PositionOld ?? "", - PositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld.ToThaiNumber(), - PositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld.ToThaiNumber(), - PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), - Salary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), - RetireDate = p.ActiveDate == null ? "" : p.ActiveDate.Value.ToThaiFullDate3().ToThaiNumber(), - CommandYear = r.CommandYear.ToThaiYear().ToString().ToThaiNumber(), - RemarkHorizontal = r.RemarkHorizontal, - RemarkVertical = r.RemarkVertical, - }).ToList(); - return Success(report_data); - } - catch - { - throw; - } - } - /// /// ออกคำสั่ง C-PM-23 คำสั่งให้ลูกจ้างออกจากราชการ /// From 7f0ced5a2d16f91627255a16e04606c2eee51663 Mon Sep 17 00:00:00 2001 From: Bright Date: Tue, 15 Oct 2024 13:58:36 +0700 Subject: [PATCH 41/42] =?UTF-8?q?fix=20=E0=B9=81=E0=B8=95=E0=B9=88?= =?UTF-8?q?=E0=B8=87=E0=B8=95=E0=B8=B1=E0=B9=89=E0=B8=87-=E0=B9=80?= =?UTF-8?q?=E0=B8=A5=E0=B8=B7=E0=B9=88=E0=B8=AD=E0=B8=99-=E0=B8=A2?= =?UTF-8?q?=E0=B9=89=E0=B8=B2=E0=B8=A2=20=E0=B9=84=E0=B8=A1=E0=B9=88?= =?UTF-8?q?=E0=B8=AA=E0=B9=88=E0=B8=87=E0=B9=80=E0=B8=87=E0=B8=B4=E0=B8=99?= =?UTF-8?q?=E0=B9=80=E0=B8=94=E0=B8=B7=E0=B8=AD=E0=B8=99=E0=B8=9B=E0=B8=B1?= =?UTF-8?q?=E0=B8=88=E0=B8=88=E0=B8=B8=E0=B8=9A=E0=B8=B1=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/PlacementAppointmentController.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs index c6070a06..42dfbc66 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs @@ -482,6 +482,7 @@ namespace BMA.EHR.Placement.Service.Controllers (org.result.child1 == null ? "" : org.result.child1 + "/") + (org.result.root == null ? "" : org.result.root); placementAppointment.OrganizationPositionOld = org.result.position + "-" + placementAppointment.OrganizationOld; + placementAppointment.AmountOld = org.result.salary; } await _context.PlacementAppointments.AddAsync(placementAppointment); await _context.SaveChangesAsync(); From ab4fb64f83636ac0d9cb7cbfb50e0b38c03e9da2 Mon Sep 17 00:00:00 2001 From: kittapath Date: Tue, 15 Oct 2024 14:22:30 +0700 Subject: [PATCH 42/42] no message --- .../Controllers/DisciplineResultController.cs | 8 ++++---- .../Controllers/PlacementController.cs | 19 +++++++++++++------ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs index e05bd0ad..ea26afc1 100644 --- a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs +++ b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs @@ -1625,7 +1625,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); - data.ForEach(profile => profile.StatusDiscard = "REPORT"); + data.ForEach(profile => profile.Status = "REPORT"); await _context.SaveChangesAsync(); return Success(); } @@ -1650,9 +1650,9 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers { var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates .Where(x => req.refIds.Contains(x.Id.ToString())) - // .Where(x => x.StatusDiscard.ToUpper() == "REPORT") + // .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); - data.ForEach(profile => profile.StatusDiscard = "NEW"); + data.ForEach(profile => profile.Status = "NEW"); await _context.SaveChangesAsync(); return Success(); } @@ -1709,7 +1709,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers var _result = await _res.Content.ReadAsStringAsync(); if (_res.IsSuccessStatusCode) { - data.ForEach(profile => { profile.StatusDiscard = "NEW"; profile.CommandTypeId = null; }); + data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; }); await _context.SaveChangesAsync(); } } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index 170de44a..339c8281 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -1710,11 +1710,13 @@ namespace BMA.EHR.Placement.Service.Controllers data = resultData }); var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) + { + placementProfile.ForEach(profile => profile.PlacementStatus = "DONE"); + await _context.SaveChangesAsync(); + } } - // update placementstatus - placementProfile.ForEach(profile => profile.PlacementStatus = "DONE"); - await _context.SaveChangesAsync(); return Success(); } catch @@ -1966,11 +1968,16 @@ namespace BMA.EHR.Placement.Service.Controllers data = resultData }); var _result = await _res.Content.ReadAsStringAsync(); + if (_res.IsSuccessStatusCode) + { + placementProfile.ForEach(profile => profile.PlacementStatus = "DONE"); + await _context.SaveChangesAsync(); + } } - // update placementstatus - placementProfile.ForEach(profile => profile.PlacementStatus = "DONE"); - await _context.SaveChangesAsync(); + // // update placementstatus + // placementProfile.ForEach(profile => profile.PlacementStatus = "DONE"); + // await _context.SaveChangesAsync(); return Success(); } catch