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(); + } } }