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