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 ///