diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs
index 6e8a2c35..aec3d5f0 100644
--- a/BMA.EHR.Command.Service/Controllers/OrderController.cs
+++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs
@@ -6647,7 +6647,7 @@ namespace BMA.EHR.Command.Service.Controllers
}
///
- /// ออกคำสั่ง C-PM-11
+ /// ออกคำสั่ง C-PM-11 คำสั่งให้ข้าราชการที่มีผลการทดลองปฏิบัติหน้าที่ราชการไม่ต่ำกว่ามาตรฐานที่กำหนดรับราชการต่อไป
///
///
///
@@ -6750,7 +6750,7 @@ namespace BMA.EHR.Command.Service.Controllers
}
///
- /// ออกคำสั่ง C-PM-12
+ /// ออกคำสั่ง C-PM-12 คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด
///
///
///
@@ -6803,7 +6803,7 @@ namespace BMA.EHR.Command.Service.Controllers
}
///
- /// ออกคำสั่ง C-PM-19
+ /// ออกคำสั่ง C-PM-19 คำสั่งปลดออกจากราชการ
///
///
///
@@ -6875,7 +6875,7 @@ namespace BMA.EHR.Command.Service.Controllers
}
///
- /// ออกคำสั่ง C-PM-20
+ /// ออกคำสั่ง C-PM-20 คำสั่งไล่ออกจากราชการ
///
///
///
@@ -6989,7 +6989,7 @@ namespace BMA.EHR.Command.Service.Controllers
}
///
- /// ออกคำสั่ง C-PM-21
+ /// ออกคำสั่ง C-PM-21 คำสั่งแต่งตั้งลูกจ้างชั่วคราวเป็นลูกจ้างประจำ
///
///
///
@@ -7020,1076 +7020,6 @@ namespace BMA.EHR.Command.Service.Controllers
return Success();
}
- ///
- /// ส่งรายชื่อออกคำสั่ง C-PM-25
- ///
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPost("command25/report")]
- public async Task> PostReportCommand25([FromBody] ReportPersonRequest req_)
- {
- try
- {
- var resultData = new List();
- var baseAPI = _configuration["API"];
-
- foreach (var id in req_.refIds)
- {
- var apiUrl = $"{baseAPI}/discipline/result/report/stop/{id}";
- var commandType = await _context.Set()
- .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-25")
- .FirstOrDefaultAsync();
- var response = new PassDisciplineResponse();
- using (var client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
- var res = await client.SendAsync(req);
- var result = await res.Content.ReadAsStringAsync();
-
- response = JsonConvert.DeserializeObject(result);
-
- var seq = 1;
- foreach (var d in response!.result)
- {
- if (commandType == null || commandType.Id != d.commandId)
- continue;
- var _baseAPI = _configuration["API"];
- var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}";
- using (var _client = new HttpClient())
- {
- _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
- var _res = await _client.SendAsync(_req);
- var _result = await _res.Content.ReadAsStringAsync();
-
- var org = JsonConvert.DeserializeObject(_result);
-
- if (org == null || org.result == null)
- continue;
-
- var receiver = new CommandReceiver
- {
- Sequence = seq,
- CitizenId = org.result.citizenId == null ? "" : org.result.citizenId,
- Prefix = org.result.prefix == null ? "" : org.result.prefix,
- FirstName = org.result.firstName == null ? "" : org.result.firstName,
- LastName = org.result.lastName == null ? "" : org.result.lastName,
- RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId),
- RefDisciplineId = d.id,
- Amount = 0,
- };
- seq++;
- resultData.Add(receiver);
- }
- }
- }
- }
- return Success();
- }
- catch
- {
- throw;
- }
- }
-
- ///
- /// เอกสารแนบท้าย C-PM-25
- ///
- /// Record Id ของคำสั่ง
- /// pdf, docx หรือ xlsx
- ///
- /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPost("command25/report/attachment")]
- [AllowAnonymous]
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status401Unauthorized)]
- [ProducesResponseType(StatusCodes.Status500InternalServerError)]
- public async Task> PostReportCommand25Attachment([FromBody] ReportAttachmentRequest req)
- {
- try
- {
- foreach (var d in req.refIds)
- {
- var apiUrl = $"{_configuration["API"]}/discipline/result/report/find/{d.refId}";
- using (var client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
- var _res = await client.SendAsync(_req);
- var _result = await _res.Content.ReadAsStringAsync();
-
- var org = JsonConvert.DeserializeObject(_result);
-
- if (org == null || org.result == null)
- continue;
- var receiver = new CommandType23Response
- {
- fullName = $"{d.Prefix}{d.FirstName} {d.LastName}",
- positionname = org.result.position,
- positionno = org.result.posNo == null ? null : org.result.posNo.ToThaiNumber(),
- organizationname = org.result.organization,
- salary = org.result.salary == null ? null : org.result.salary.Value.ToNumericNoDecimalText().ToString(),
- };
-
- return Success(receiver);
- }
- }
- return null;
- }
- catch
- {
- throw;
- }
- }
-
- ///
- /// ออกคำสั่ง C-PM-25
- ///
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPost("command25/report/excecute")]
- public async Task> PostReportCommand25Execute([FromBody] ReportExecuteRequest req)
- {
- var data = req.refIds.Select(x => new
- {
- Id = x.refId,
- CommandAffectDate = x.commandAffectDate,
- CommandNo = x.commandNo,
- CommandYear = x.commandYear.ToThaiYear(),
- Detail = "คำสั่งลงโทษ พักจากราชการ"
- });
-
- var baseAPI = _configuration["API"];
- var apiUrl = $"{baseAPI}/discipline/result/report/stop/resume";
- using (var client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
- var result = await res.Content.ReadAsStringAsync();
- }
- foreach (var recv in req.refIds)
- {
- var apiUrl2 = $"{baseAPI}/org/profile/command25/{recv.refId}";
- using (var client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _res = await client.PostAsJsonAsync(apiUrl2, new
- {
- profileId = recv.refId,
- date = recv.commandAffectDate,
- refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
- salaryRef = recv.templateDoc,
- });
- var _result = await _res.Content.ReadAsStringAsync();
- }
- }
- return Success();
- }
-
- ///
- /// ส่งรายชื่อออกคำสั่ง C-PM-26
- ///
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPost("command26/report")]
- public async Task> PostReportCommand26([FromBody] ReportPersonRequest req_)
- {
- try
- {
- var resultData = new List();
- var baseAPI = _configuration["API"];
-
- foreach (var id in req_.refIds)
- {
- var apiUrl = $"{baseAPI}/discipline/result/report/stop/{id}";
-
- var commandType = await _context.Set()
- .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-26")
- .FirstOrDefaultAsync();
- var response = new PassDisciplineResponse();
- using (var client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
- var res = await client.SendAsync(req);
- var result = await res.Content.ReadAsStringAsync();
-
- response = JsonConvert.DeserializeObject(result);
-
- var seq = 1;
- foreach (var d in response!.result)
- {
- if (commandType == null || commandType.Id != d.commandId)
- continue;
- var _baseAPI = _configuration["API"];
- var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}";
- using (var _client = new HttpClient())
- {
- _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
- var _res = await _client.SendAsync(_req);
- var _result = await _res.Content.ReadAsStringAsync();
-
- var org = JsonConvert.DeserializeObject(_result);
-
- if (org == null || org.result == null)
- continue;
-
- var receiver = new CommandReceiver
- {
- Sequence = seq,
- CitizenId = org.result.citizenId == null ? "" : org.result.citizenId,
- Prefix = org.result.prefix == null ? "" : org.result.prefix,
- FirstName = org.result.firstName == null ? "" : org.result.firstName,
- LastName = org.result.lastName == null ? "" : org.result.lastName,
- RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId),
- RefDisciplineId = d.id,
- Amount = 0,
- };
- seq++;
- resultData.Add(receiver);
- }
- }
- }
- }
- return Success();
- }
- catch
- {
- throw;
- }
- }
-
- ///
- /// ออกคำสั่ง C-PM-26
- ///
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPost("command26/report/excecute")]
- public async Task> PostReportCommand26Execute([FromBody] ReportExecuteRequest req)
- {
- var data = req.refIds.Select(x => new
- {
- Id = x.refId,
- CommandAffectDate = x.commandAffectDate,
- CommandNo = x.commandNo,
- CommandYear = x.commandYear.ToThaiYear(),
- Detail = "คำสั่งลงโทษ ให้ออกจากราชการไว้ก่อน"
- });
-
- var baseAPI = _configuration["API"];
- var apiUrl = $"{baseAPI}/discipline/result/report/stop/resume";
- using (var client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
- var result = await res.Content.ReadAsStringAsync();
- }
- foreach (var recv in req.refIds)
- {
- var apiUrl2 = $"{baseAPI}/org/profile/command26/{recv.refId}";
- using (var client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _res = await client.PostAsJsonAsync(apiUrl2, new
- {
- profileId = recv.refId,
- date = recv.commandAffectDate,
- refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
- salaryRef = recv.templateDoc,
- });
- var _result = await _res.Content.ReadAsStringAsync();
- }
- }
- return Success();
- }
-
- ///
- /// ส่งรายชื่อออกคำสั่ง C-PM-27
- ///
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPost("command27/report")]
- public async Task> PostReportCommand27([FromBody] ReportPersonRequest req_)
- {
- try
- {
- var resultData = new List();
- var baseAPI = _configuration["API"];
-
- foreach (var id in req_.refIds)
- {
- var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}";
-
- var commandType = await _context.Set()
- .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-27")
- .FirstOrDefaultAsync();
- var response = new PassDisciplineResponse();
- using (var client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
- var res = await client.SendAsync(req);
- var result = await res.Content.ReadAsStringAsync();
-
- response = JsonConvert.DeserializeObject(result);
-
- var seq = 1;
- foreach (var d in response!.result)
- {
- if (commandType == null || commandType.Id != d.commandId)
- continue;
- var _baseAPI = _configuration["API"];
- var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}";
- using (var _client = new HttpClient())
- {
- _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
- var _res = await _client.SendAsync(_req);
- var _result = await _res.Content.ReadAsStringAsync();
-
- var org = JsonConvert.DeserializeObject(_result);
-
- if (org == null || org.result == null)
- continue;
-
- var receiver = new CommandReceiver
- {
- Sequence = seq,
- CitizenId = org.result.citizenId == null ? "" : org.result.citizenId,
- Prefix = org.result.prefix == null ? "" : org.result.prefix,
- FirstName = org.result.firstName == null ? "" : org.result.firstName,
- LastName = org.result.lastName == null ? "" : org.result.lastName,
- RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId),
- RefDisciplineId = d.id,
- Amount = 0,
- };
- seq++;
- resultData.Add(receiver);
- }
- }
- }
- }
- return Success();
- }
- catch
- {
- throw;
- }
- }
-
- ///
- /// ออกคำสั่ง C-PM-27
- ///
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPost("command27/report/excecute")]
- public async Task> PostReportCommand27Execute([FromBody] ReportExecuteRequest req)
- {
- var data = req.refIds.Select(x => new
- {
- Id = x.refId,
- CommandAffectDate = x.commandAffectDate,
- CommandNo = x.commandNo,
- CommandYear = x.commandYear.ToThaiYear(),
- Detail = "คำสั่งลงโทษ ลงโทษ ภาคทัณฑ์"
- });
-
- var baseAPI = _configuration["API"];
- var apiUrl = $"{baseAPI}/discipline/result/report/up/resume";
- using (var client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
- var result = await res.Content.ReadAsStringAsync();
- }
- foreach (var recv in req.refIds)
- {
- var apiUrl2 = $"{baseAPI}/org/profile/command27/{recv.refId}";
- using (var client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _res = await client.PostAsJsonAsync(apiUrl2, new
- {
- profileId = recv.refId,
- date = recv.commandAffectDate,
- refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
- salaryRef = recv.templateDoc,
- });
- var _result = await _res.Content.ReadAsStringAsync();
- }
- }
- return Success();
- }
-
- ///
- /// ส่งรายชื่อออกคำสั่ง C-PM-28
- ///
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPost("command28/report")]
- public async Task> PostReportCommand28([FromBody] ReportPersonRequest req_)
- {
- try
- {
- var resultData = new List();
- var baseAPI = _configuration["API"];
-
- foreach (var id in req_.refIds)
- {
- var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}";
-
- var commandType = await _context.Set()
- .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-28")
- .FirstOrDefaultAsync();
- var response = new PassDisciplineResponse();
- using (var client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
- var res = await client.SendAsync(req);
- var result = await res.Content.ReadAsStringAsync();
-
- response = JsonConvert.DeserializeObject(result);
-
- var seq = 1;
- foreach (var d in response!.result)
- {
- if (commandType == null || commandType.Id != d.commandId)
- continue;
- var _baseAPI = _configuration["API"];
- var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}";
- using (var _client = new HttpClient())
- {
- _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
- var _res = await _client.SendAsync(_req);
- var _result = await _res.Content.ReadAsStringAsync();
-
- var org = JsonConvert.DeserializeObject(_result);
-
- if (org == null || org.result == null)
- continue;
-
- var receiver = new CommandReceiver
- {
- Sequence = seq,
- CitizenId = org.result.citizenId == null ? "" : org.result.citizenId,
- Prefix = org.result.prefix == null ? "" : org.result.prefix,
- FirstName = org.result.firstName == null ? "" : org.result.firstName,
- LastName = org.result.lastName == null ? "" : org.result.lastName,
- RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId),
- RefDisciplineId = d.id,
- Amount = 0,
- };
- seq++;
- resultData.Add(receiver);
- }
- }
- }
- }
- return Success();
- }
- catch
- {
- throw;
- }
- }
-
- ///
- /// ออกคำสั่ง C-PM-28
- ///
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPost("command28/report/excecute")]
- public async Task> PostReportCommand28Execute([FromBody] ReportExecuteRequest req)
- {
- var data = req.refIds.Select(x => new
- {
- Id = x.refId,
- CommandAffectDate = x.commandAffectDate,
- CommandNo = x.commandNo,
- CommandYear = x.commandYear.ToThaiYear(),
- Detail = "คำสั่งลงโทษ ตัดเงินเดือน"
- });
-
- var baseAPI = _configuration["API"];
- var apiUrl = $"{baseAPI}/discipline/result/report/up/resume";
- using (var client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
- var result = await res.Content.ReadAsStringAsync();
- }
- foreach (var recv in req.refIds)
- {
- var apiUrl2 = $"{baseAPI}/org/profile/command28/{recv.refId}";
- using (var client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _res = await client.PostAsJsonAsync(apiUrl2, new
- {
- profileId = recv.refId,
- date = recv.commandAffectDate,
- refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
- salaryRef = recv.templateDoc,
- });
- var _result = await _res.Content.ReadAsStringAsync();
- }
- }
- return Success();
- }
-
- ///
- /// ส่งรายชื่อออกคำสั่ง C-PM-29
- ///
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPost("command29/report")]
- public async Task> PostReportCommand29([FromBody] ReportPersonRequest req_)
- {
- try
- {
- var resultData = new List();
- var baseAPI = _configuration["API"];
-
- foreach (var id in req_.refIds)
- {
- var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}";
-
- var commandType = await _context.Set()
- .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-29")
- .FirstOrDefaultAsync();
- var response = new PassDisciplineResponse();
- using (var client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
- var res = await client.SendAsync(req);
- var result = await res.Content.ReadAsStringAsync();
-
- response = JsonConvert.DeserializeObject(result);
-
- var seq = 1;
- foreach (var d in response!.result)
- {
- if (commandType == null || commandType.Id != d.commandId)
- continue;
- var _baseAPI = _configuration["API"];
- var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}";
- using (var _client = new HttpClient())
- {
- _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
- var _res = await _client.SendAsync(_req);
- var _result = await _res.Content.ReadAsStringAsync();
-
- var org = JsonConvert.DeserializeObject(_result);
-
- if (org == null || org.result == null)
- continue;
-
- var receiver = new CommandReceiver
- {
- Sequence = seq,
- CitizenId = org.result.citizenId == null ? "" : org.result.citizenId,
- Prefix = org.result.prefix == null ? "" : org.result.prefix,
- FirstName = org.result.firstName == null ? "" : org.result.firstName,
- LastName = org.result.lastName == null ? "" : org.result.lastName,
- RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId),
- RefDisciplineId = d.id,
- Amount = 0,
- };
- seq++;
- resultData.Add(receiver);
- }
- }
- }
- }
- return Success();
- }
- catch
- {
- throw;
- }
- }
-
- ///
- /// ออกคำสั่ง C-PM-29
- ///
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPost("command29/report/excecute")]
- public async Task> PostReportCommand29Execute([FromBody] ReportExecuteRequest req)
- {
- var data = req.refIds.Select(x => new
- {
- Id = x.refId,
- CommandAffectDate = x.commandAffectDate,
- CommandNo = x.commandNo,
- CommandYear = x.commandYear.ToThaiYear(),
- Detail = "คำสั่งลงโทษ ลดขั้นเงินเดือน"
- });
-
- var baseAPI = _configuration["API"];
- var apiUrl = $"{baseAPI}/discipline/result/report/up/resume";
- using (var client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
- var result = await res.Content.ReadAsStringAsync();
- }
- foreach (var recv in req.refIds)
- {
- var apiUrl2 = $"{baseAPI}/org/profile/command29/{recv.refId}";
- using (var client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _res = await client.PostAsJsonAsync(apiUrl2, new
- {
- profileId = recv.refId,
- date = recv.commandAffectDate,
- refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
- salaryRef = recv.templateDoc,
- });
- var _result = await _res.Content.ReadAsStringAsync();
- }
- }
- return Success();
- }
-
- ///
- /// ส่งรายชื่อออกคำสั่ง C-PM-30
- ///
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPost("command30/report")]
- public async Task> PostReportCommand30([FromBody] ReportPersonRequest req_)
- {
- try
- {
- var resultData = new List();
- var baseAPI = _configuration["API"];
-
- foreach (var id in req_.refIds)
- {
- var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}";
-
- var commandType = await _context.Set()
- .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-30")
- .FirstOrDefaultAsync();
- var response = new PassDisciplineResponse();
- using (var client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
- var res = await client.SendAsync(req);
- var result = await res.Content.ReadAsStringAsync();
-
- response = JsonConvert.DeserializeObject(result);
-
- var seq = 1;
- foreach (var d in response!.result)
- {
- if (commandType == null || commandType.Id != d.commandId)
- continue;
- var _baseAPI = _configuration["API"];
- var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}";
- using (var _client = new HttpClient())
- {
- _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
- var _res = await _client.SendAsync(_req);
- var _result = await _res.Content.ReadAsStringAsync();
-
- var org = JsonConvert.DeserializeObject(_result);
-
- if (org == null || org.result == null)
- continue;
-
- var receiver = new CommandReceiver
- {
- Sequence = seq,
- CitizenId = org.result.citizenId == null ? "" : org.result.citizenId,
- Prefix = org.result.prefix == null ? "" : org.result.prefix,
- FirstName = org.result.firstName == null ? "" : org.result.firstName,
- LastName = org.result.lastName == null ? "" : org.result.lastName,
- RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId),
- RefDisciplineId = d.id,
- Amount = 0,
- };
- seq++;
- resultData.Add(receiver);
- }
- }
- }
- }
- return Success();
- }
- catch
- {
- throw;
- }
- }
-
- ///
- /// ออกคำสั่ง C-PM-30
- ///
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPost("command30/report/excecute")]
- public async Task> PostReportCommand30Execute([FromBody] ReportExecuteRequest req)
- {
- var data = req.refIds.Select(x => new
- {
- Id = x.refId,
- CommandAffectDate = x.commandAffectDate,
- CommandNo = x.commandNo,
- CommandYear = x.commandYear.ToThaiYear(),
- Detail = "คำสั่งเพิ่มโทษ"
- });
-
- var baseAPI = _configuration["API"];
- var apiUrl = $"{baseAPI}/discipline/result/report/up/resume";
- using (var client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
- var result = await res.Content.ReadAsStringAsync();
- }
- foreach (var recv in req.refIds)
- {
- var apiUrl2 = $"{baseAPI}/org/profile/command30/{recv.refId}";
- using (var client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _res = await client.PostAsJsonAsync(apiUrl2, new
- {
- profileId = recv.refId,
- date = recv.commandAffectDate,
- refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
- salaryRef = recv.templateDoc,
- });
- var _result = await _res.Content.ReadAsStringAsync();
- }
- }
- return Success();
- }
-
- ///
- /// ส่งรายชื่อออกคำสั่ง C-PM-31
- ///
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPost("command31/report")]
- public async Task> PostReportCommand31([FromBody] ReportPersonRequest req_)
- {
- try
- {
- var resultData = new List();
- var baseAPI = _configuration["API"];
-
- foreach (var id in req_.refIds)
- {
- var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}";
-
- var commandType = await _context.Set()
- .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-31")
- .FirstOrDefaultAsync();
- var response = new PassDisciplineResponse();
- using (var client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
- var res = await client.SendAsync(req);
- var result = await res.Content.ReadAsStringAsync();
-
- response = JsonConvert.DeserializeObject(result);
-
- var seq = 1;
- foreach (var d in response!.result)
- {
- if (commandType == null || commandType.Id != d.commandId)
- continue;
- var _baseAPI = _configuration["API"];
- var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}";
- using (var _client = new HttpClient())
- {
- _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
- var _res = await _client.SendAsync(_req);
- var _result = await _res.Content.ReadAsStringAsync();
-
- var org = JsonConvert.DeserializeObject(_result);
-
- if (org == null || org.result == null)
- continue;
-
- var receiver = new CommandReceiver
- {
- Sequence = seq,
- CitizenId = org.result.citizenId == null ? "" : org.result.citizenId,
- Prefix = org.result.prefix == null ? "" : org.result.prefix,
- FirstName = org.result.firstName == null ? "" : org.result.firstName,
- LastName = org.result.lastName == null ? "" : org.result.lastName,
- RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId),
- RefDisciplineId = d.id,
- Amount = 0,
- };
- seq++;
- resultData.Add(receiver);
- }
- }
- }
- }
- return Success();
- }
- catch
- {
- throw;
- }
- }
-
- ///
- /// ออกคำสั่ง C-PM-31
- ///
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPost("command31/report/excecute")]
- public async Task> PostReportCommand31Execute([FromBody] ReportExecuteRequest req)
- {
- var data = req.refIds.Select(x => new
- {
- Id = x.refId,
- CommandAffectDate = x.commandAffectDate,
- CommandNo = x.commandNo,
- CommandYear = x.commandYear.ToThaiYear(),
- Detail = "คำสั่งงดโทษ"
- });
-
- var baseAPI = _configuration["API"];
- var apiUrl = $"{baseAPI}/discipline/result/report/up/resume";
- using (var client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
- var result = await res.Content.ReadAsStringAsync();
- }
- foreach (var recv in req.refIds)
- {
- var apiUrl2 = $"{baseAPI}/org/profile/command31/{recv.refId}";
- using (var client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _res = await client.PostAsJsonAsync(apiUrl2, new
- {
- profileId = recv.refId,
- date = recv.commandAffectDate,
- refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
- salaryRef = recv.templateDoc,
- });
- var _result = await _res.Content.ReadAsStringAsync();
- }
- }
- return Success();
- }
-
- ///
- /// ส่งรายชื่อออกคำสั่ง C-PM-32
- ///
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPost("command32/report")]
- public async Task> PostReportCommand32([FromBody] ReportPersonRequest req_)
- {
- try
- {
- var resultData = new List();
- var baseAPI = _configuration["API"];
-
- foreach (var id in req_.refIds)
- {
- var apiUrl = $"{baseAPI}/discipline/result/report/reject/{id}";
-
- var response = new PassDisciplineResponse();
- using (var client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
- var res = await client.SendAsync(req);
- var result = await res.Content.ReadAsStringAsync();
-
- response = JsonConvert.DeserializeObject(result);
-
- var seq = 1;
- foreach (var d in response!.result)
- {
- var _baseAPI = _configuration["API"];
- var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}";
- using (var _client = new HttpClient())
- {
- _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
- var _res = await _client.SendAsync(_req);
- var _result = await _res.Content.ReadAsStringAsync();
-
- var org = JsonConvert.DeserializeObject(_result);
-
- if (org == null || org.result == null)
- continue;
-
- var receiver = new CommandReceiver
- {
- Sequence = seq,
- CitizenId = org.result.citizenId == null ? "" : org.result.citizenId,
- Prefix = org.result.prefix == null ? "" : org.result.prefix,
- FirstName = org.result.firstName == null ? "" : org.result.firstName,
- LastName = org.result.lastName == null ? "" : org.result.lastName,
- RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId),
- RefDisciplineId = d.id,
- Amount = 0,
- };
- seq++;
- resultData.Add(receiver);
- }
- }
- }
- }
- return Success();
- }
- catch
- {
- throw;
- }
- }
-
- ///
- /// ออกคำสั่ง C-PM-32
- ///
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPost("command32/report/excecute")]
- public async Task> PostReportCommand32Execute([FromBody] ReportExecuteRequest req)
- {
- var data = req.refIds.Select(x => new
- {
- Id = x.refId,
- CommandAffectDate = x.commandAffectDate,
- CommandNo = x.commandNo,
- CommandYear = x.commandYear.ToThaiYear(),
- Detail = "คำสั่งยุติเรื่อง"
- });
-
- var baseAPI = _configuration["API"];
- var apiUrl = $"{baseAPI}/discipline/result/report/reject/resume";
- using (var client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
- var result = await res.Content.ReadAsStringAsync();
- }
- foreach (var recv in req.refIds)
- {
- var apiUrl2 = $"{baseAPI}/org/profile/command32/{recv.refId}";
- using (var client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _res = await client.PostAsJsonAsync(apiUrl2, new
- {
- profileId = recv.refId,
- date = recv.commandAffectDate,
- refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
- salaryRef = recv.templateDoc,
- });
- var _result = await _res.Content.ReadAsStringAsync();
- }
- }
- return Success();
- }
-
///
/// ส่งรายชื่อออกคำสั่ง C-PM-33
///
@@ -8149,7 +7079,7 @@ namespace BMA.EHR.Command.Service.Controllers
}
///
- /// ออกคำสั่ง C-PM-33
+ /// ออกคำสั่ง C-PM-33 เลื่อนเงินเดือนและให้ข้าราชการกรุงเทพมหานครสามัญ ได้รับเงินเดือนสูงกว่าขั้นสูงของตำแหน่งที่ได้รับแต่งตั้ง
///
///
///
@@ -8237,7 +7167,7 @@ namespace BMA.EHR.Command.Service.Controllers
}
///
- /// ออกคำสั่ง C-PM-34
+ /// ออกคำสั่ง C-PM-34 ให้ข้าราชการกรุงเทพมหานครสามัญได้รับค่าตอบแทนพิเศษ
///
///
///
@@ -8325,7 +7255,7 @@ namespace BMA.EHR.Command.Service.Controllers
}
///
- /// ออกคำสั่ง C-PM-35
+ /// ออกคำสั่ง C-PM-35 เลื่อนเงินเดือนและให้ข้าราชการกรุงเทพมหานครสามัญที่เกษียณอายุราชการ ในสิ้นปีงบประมาณ พ.ศ.……… ได้รับเงินเดือนสูงกว่าขั้นสูงของตำแหน่งที่ได้รับแต่งตั้ง
///
///
///
@@ -8413,7 +7343,7 @@ namespace BMA.EHR.Command.Service.Controllers
}
///
- /// ออกคำสั่ง C-PM-36
+ /// ออกคำสั่ง C-PM-36 เลื่อนขั้นค่าจ้างและให้ลูกจ้างประจำกรุงเทพมหานครได้รับอัตราค่าจ้างสูงกว่าอัตราค่าจ้างขั้นสูงของตำแหน่งที่ได้รับแต่งตั้งในแต่ละระดับ
///
///
///
@@ -8501,7 +7431,7 @@ namespace BMA.EHR.Command.Service.Controllers
}
///
- /// ออกคำสั่ง C-PM-37
+ /// ออกคำสั่ง C-PM-37 ให้ลูกจ้างประจำกรุงเทพมหานครได้รับค่าตอบแทนพิเศษ
///
///
///
@@ -8588,7 +7518,7 @@ namespace BMA.EHR.Command.Service.Controllers
}
///
- /// ออกคำสั่ง C-PM-38
+ /// ออกคำสั่ง C-PM-38 แต่งตั้งข้าราชการให้ดำรงตำแหน่ง
///
///
///
@@ -8718,7 +7648,7 @@ namespace BMA.EHR.Command.Service.Controllers
}
///
- /// ออกคำสั่ง C-PM-40
+ /// ออกคำสั่ง C-PM-40 คำสั่งให้ข้าราชการรักษาการในตำแหน่ง
///
///
///
diff --git a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs
index 0210a48a..2363f19f 100644
--- a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs
+++ b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs
@@ -1,6 +1,7 @@
using BMA.EHR.Application.Repositories;
using BMA.EHR.Application.Repositories.MessageQueue;
using BMA.EHR.Discipline.Service.Requests;
+using BMA.EHR.Domain.Extensions;
using BMA.EHR.Domain.Common;
using BMA.EHR.Domain.Models.Commands.Core;
using BMA.EHR.Domain.Models.Discipline;
@@ -738,5 +739,1168 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
return Success(data1);
}
+
+
+
+
+
+
+ ///
+ /// ส่งรายชื่อออกคำสั่ง C-PM-25
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost("command25/report")]
+ public async Task> PostReportCommand25([FromBody] ReportPersonRequest req_)
+ {
+ try
+ {
+ var resultData = new List();
+ var baseAPI = _configuration["API"];
+
+ foreach (var id in req_.refIds)
+ {
+ var apiUrl = $"{baseAPI}/discipline/result/report/stop/{id}";
+ var commandType = await _context.Set()
+ .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-25")
+ .FirstOrDefaultAsync();
+ var response = new PassDisciplineResponse();
+ using (var client = new HttpClient())
+ {
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
+ var res = await client.SendAsync(req);
+ var result = await res.Content.ReadAsStringAsync();
+
+ response = JsonConvert.DeserializeObject(result);
+
+ var seq = 1;
+ foreach (var d in response!.result)
+ {
+ if (commandType == null || commandType.Id != d.commandId)
+ continue;
+ var _baseAPI = _configuration["API"];
+ var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}";
+ using (var _client = new HttpClient())
+ {
+ _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
+ var _res = await _client.SendAsync(_req);
+ var _result = await _res.Content.ReadAsStringAsync();
+
+ var org = JsonConvert.DeserializeObject(_result);
+
+ if (org == null || org.result == null)
+ continue;
+
+ var receiver = new CommandReceiver
+ {
+ Sequence = seq,
+ CitizenId = org.result.citizenId == null ? "" : org.result.citizenId,
+ Prefix = org.result.prefix == null ? "" : org.result.prefix,
+ FirstName = org.result.firstName == null ? "" : org.result.firstName,
+ LastName = org.result.lastName == null ? "" : org.result.lastName,
+ RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId),
+ RefDisciplineId = d.id,
+ Amount = 0,
+ };
+ seq++;
+ resultData.Add(receiver);
+ }
+ }
+ }
+ }
+ return Success();
+ }
+ catch
+ {
+ throw;
+ }
+ }
+
+ ///
+ /// เอกสารแนบท้าย C-PM-25
+ ///
+ /// Record Id ของคำสั่ง
+ /// pdf, docx หรือ xlsx
+ ///
+ /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost("command25/report/attachment")]
+ [AllowAnonymous]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status401Unauthorized)]
+ [ProducesResponseType(StatusCodes.Status500InternalServerError)]
+ public async Task> PostReportCommand25Attachment([FromBody] ReportAttachmentRequest req)
+ {
+ try
+ {
+ foreach (var d in req.refIds)
+ {
+ var apiUrl = $"{_configuration["API"]}/discipline/result/report/find/{d.refId}";
+ using (var client = new HttpClient())
+ {
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
+ var _res = await client.SendAsync(_req);
+ var _result = await _res.Content.ReadAsStringAsync();
+
+ var org = JsonConvert.DeserializeObject(_result);
+
+ if (org == null || org.result == null)
+ continue;
+ var receiver = new CommandType23Response
+ {
+ fullName = $"{d.Prefix}{d.FirstName} {d.LastName}",
+ positionname = org.result.position,
+ positionno = org.result.posNo == null ? null : org.result.posNo.ToThaiNumber(),
+ organizationname = org.result.organization,
+ salary = org.result.salary == null ? null : org.result.salary.Value.ToNumericNoDecimalText().ToString(),
+ };
+
+ return Success(receiver);
+ }
+ }
+ return null;
+ }
+ catch
+ {
+ throw;
+ }
+ }
+
+ ///
+ /// ออกคำสั่ง C-PM-25 คำสั่งพักจากราชการ
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost("command25/report/excecute")]
+ public async Task> PostReportCommand25Execute([FromBody] ReportExecuteRequest req)
+ {
+ var data = await _context.DisciplineReport_Profiles
+ .Include(x => x.DisciplineDisciplinary)
+ .Where(x => x.Status == "REPORT")
+ .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
+ .ToListAsync();
+ var resultData = (from p in data
+ join r in req.refIds
+ on p.Id.ToString() equals r.refId
+ select new
+ {
+ profileId = p.PersonId,
+ date = r.commandAffectDate,
+ refCommandNo = $"{r.commandNo}/{r.commandYear}",
+ salaryRef = r.templateDoc,
+ isLeave = true,
+ leaveReason = "ได้รับโทษทางวินัย พักจากราชการ",
+ dateLeave = r.commandAffectDate,
+ refCommandDate = DateTime.Now,
+ detail = p.DisciplineDisciplinary.Title,
+ level = p.DisciplineDisciplinary.DisciplinaryFaultLevel,
+ unStigma = "คำสั่งลงโทษ พักจากราชการ",
+ }).ToList();
+
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
+ using (var client = new HttpClient())
+ {
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
+ {
+ data = resultData,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ if (_res.IsSuccessStatusCode)
+ {
+ data.ForEach(profile => profile.Status = "DONE");
+ await _context.SaveChangesAsync();
+ }
+ }
+ return Success();
+ }
+
+ ///
+ /// ส่งรายชื่อออกคำสั่ง C-PM-26
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost("command26/report")]
+ public async Task> PostReportCommand26([FromBody] ReportPersonRequest req_)
+ {
+ try
+ {
+ var resultData = new List();
+ var baseAPI = _configuration["API"];
+
+ foreach (var id in req_.refIds)
+ {
+ var apiUrl = $"{baseAPI}/discipline/result/report/stop/{id}";
+
+ var commandType = await _context.Set()
+ .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-26")
+ .FirstOrDefaultAsync();
+ var response = new PassDisciplineResponse();
+ using (var client = new HttpClient())
+ {
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
+ var res = await client.SendAsync(req);
+ var result = await res.Content.ReadAsStringAsync();
+
+ response = JsonConvert.DeserializeObject(result);
+
+ var seq = 1;
+ foreach (var d in response!.result)
+ {
+ if (commandType == null || commandType.Id != d.commandId)
+ continue;
+ var _baseAPI = _configuration["API"];
+ var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}";
+ using (var _client = new HttpClient())
+ {
+ _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
+ var _res = await _client.SendAsync(_req);
+ var _result = await _res.Content.ReadAsStringAsync();
+
+ var org = JsonConvert.DeserializeObject(_result);
+
+ if (org == null || org.result == null)
+ continue;
+
+ var receiver = new CommandReceiver
+ {
+ Sequence = seq,
+ CitizenId = org.result.citizenId == null ? "" : org.result.citizenId,
+ Prefix = org.result.prefix == null ? "" : org.result.prefix,
+ FirstName = org.result.firstName == null ? "" : org.result.firstName,
+ LastName = org.result.lastName == null ? "" : org.result.lastName,
+ RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId),
+ RefDisciplineId = d.id,
+ Amount = 0,
+ };
+ seq++;
+ resultData.Add(receiver);
+ }
+ }
+ }
+ }
+ return Success();
+ }
+ catch
+ {
+ throw;
+ }
+ }
+
+ ///
+ /// ออกคำสั่ง C-PM-26 คำสั่งให้ออกจากราชการไว้ก่อน
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost("command26/report/excecute")]
+ public async Task> PostReportCommand26Execute([FromBody] ReportExecuteRequest req)
+ {
+
+ var data = await _context.DisciplineReport_Profiles
+ .Include(x => x.DisciplineDisciplinary)
+ .Where(x => x.Status == "REPORT")
+ .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
+ .ToListAsync();
+ var resultData = (from p in data
+ join r in req.refIds
+ on p.Id.ToString() equals r.refId
+ select new
+ {
+ profileId = p.PersonId,
+ date = r.commandAffectDate,
+ refCommandNo = $"{r.commandNo}/{r.commandYear}",
+ salaryRef = r.templateDoc,
+ isLeave = true,
+ leaveReason = "ได้รับโทษทางวินัย ให้ออกจากราชการไว้ก่อน",
+ dateLeave = r.commandAffectDate,
+ refCommandDate = DateTime.Now,
+ detail = p.DisciplineDisciplinary.Title,
+ level = p.DisciplineDisciplinary.DisciplinaryFaultLevel,
+ unStigma = "คำสั่งลงโทษ ให้ออกจากราชการไว้ก่อน",
+ }).ToList();
+
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
+ using (var client = new HttpClient())
+ {
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
+ {
+ data = resultData,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ if (_res.IsSuccessStatusCode)
+ {
+ data.ForEach(profile => profile.Status = "DONE");
+ await _context.SaveChangesAsync();
+ }
+ }
+ return Success();
+ }
+
+ ///
+ /// ส่งรายชื่อออกคำสั่ง C-PM-27
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost("command27/report")]
+ public async Task> PostReportCommand27([FromBody] ReportPersonRequest req_)
+ {
+ try
+ {
+ var resultData = new List();
+ var baseAPI = _configuration["API"];
+
+ foreach (var id in req_.refIds)
+ {
+ var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}";
+
+ var commandType = await _context.Set()
+ .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-27")
+ .FirstOrDefaultAsync();
+ var response = new PassDisciplineResponse();
+ using (var client = new HttpClient())
+ {
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
+ var res = await client.SendAsync(req);
+ var result = await res.Content.ReadAsStringAsync();
+
+ response = JsonConvert.DeserializeObject(result);
+
+ var seq = 1;
+ foreach (var d in response!.result)
+ {
+ if (commandType == null || commandType.Id != d.commandId)
+ continue;
+ var _baseAPI = _configuration["API"];
+ var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}";
+ using (var _client = new HttpClient())
+ {
+ _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
+ var _res = await _client.SendAsync(_req);
+ var _result = await _res.Content.ReadAsStringAsync();
+
+ var org = JsonConvert.DeserializeObject(_result);
+
+ if (org == null || org.result == null)
+ continue;
+
+ var receiver = new CommandReceiver
+ {
+ Sequence = seq,
+ CitizenId = org.result.citizenId == null ? "" : org.result.citizenId,
+ Prefix = org.result.prefix == null ? "" : org.result.prefix,
+ FirstName = org.result.firstName == null ? "" : org.result.firstName,
+ LastName = org.result.lastName == null ? "" : org.result.lastName,
+ RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId),
+ RefDisciplineId = d.id,
+ Amount = 0,
+ };
+ seq++;
+ resultData.Add(receiver);
+ }
+ }
+ }
+ }
+ return Success();
+ }
+ catch
+ {
+ throw;
+ }
+ }
+
+ ///
+ /// ออกคำสั่ง C-PM-27 คำสั่งลงโทษ ภาคทัณฑ์
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost("command27/report/excecute")]
+ public async Task> PostReportCommand27Execute([FromBody] ReportExecuteRequest req)
+ {
+ var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
+ .Include(x => x.DisciplineDisciplinary)
+ .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
+ .ToListAsync();
+ string? _null = null;
+ var resultData = (from p in data
+ join r in req.refIds
+ on p.Id.ToString() equals r.refId
+ select new
+ {
+ profileId = p.PersonId,
+ date = r.commandAffectDate,
+ refCommandNo = $"{r.commandNo}/{r.commandYear}",
+ salaryRef = r.templateDoc,
+ isLeave = _null,
+ leaveReason = _null,
+ dateLeave = _null,
+ refCommandDate = DateTime.Now,
+ detail = p.DisciplineDisciplinary.Title,
+ level = p.DisciplineDisciplinary.DisciplinaryFaultLevel,
+ unStigma = "คำสั่งลงโทษ ลงโทษ ภาคทัณฑ์",
+ }).ToList();
+
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
+ using (var client = new HttpClient())
+ {
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
+ {
+ data = resultData,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ if (_res.IsSuccessStatusCode)
+ {
+ data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; });
+ await _context.SaveChangesAsync();
+ }
+ }
+ return Success();
+ }
+
+ ///
+ /// ส่งรายชื่อออกคำสั่ง C-PM-28
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost("command28/report")]
+ public async Task> PostReportCommand28([FromBody] ReportPersonRequest req_)
+ {
+ try
+ {
+ var resultData = new List();
+ var baseAPI = _configuration["API"];
+
+ foreach (var id in req_.refIds)
+ {
+ var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}";
+
+ var commandType = await _context.Set()
+ .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-28")
+ .FirstOrDefaultAsync();
+ var response = new PassDisciplineResponse();
+ using (var client = new HttpClient())
+ {
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
+ var res = await client.SendAsync(req);
+ var result = await res.Content.ReadAsStringAsync();
+
+ response = JsonConvert.DeserializeObject(result);
+
+ var seq = 1;
+ foreach (var d in response!.result)
+ {
+ if (commandType == null || commandType.Id != d.commandId)
+ continue;
+ var _baseAPI = _configuration["API"];
+ var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}";
+ using (var _client = new HttpClient())
+ {
+ _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
+ var _res = await _client.SendAsync(_req);
+ var _result = await _res.Content.ReadAsStringAsync();
+
+ var org = JsonConvert.DeserializeObject(_result);
+
+ if (org == null || org.result == null)
+ continue;
+
+ var receiver = new CommandReceiver
+ {
+ Sequence = seq,
+ CitizenId = org.result.citizenId == null ? "" : org.result.citizenId,
+ Prefix = org.result.prefix == null ? "" : org.result.prefix,
+ FirstName = org.result.firstName == null ? "" : org.result.firstName,
+ LastName = org.result.lastName == null ? "" : org.result.lastName,
+ RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId),
+ RefDisciplineId = d.id,
+ Amount = 0,
+ };
+ seq++;
+ resultData.Add(receiver);
+ }
+ }
+ }
+ }
+ return Success();
+ }
+ catch
+ {
+ throw;
+ }
+ }
+
+ ///
+ /// ออกคำสั่ง C-PM-28 คำสั่งลงโทษ ตัดเงินเดือน
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost("command28/report/excecute")]
+ public async Task> PostReportCommand28Execute([FromBody] ReportExecuteRequest req)
+ {
+ var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
+ .Include(x => x.DisciplineDisciplinary)
+ .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
+ .ToListAsync();
+ string? _null = null;
+ var resultData = (from p in data
+ join r in req.refIds
+ on p.Id.ToString() equals r.refId
+ select new
+ {
+ profileId = p.PersonId,
+ date = r.commandAffectDate,
+ refCommandNo = $"{r.commandNo}/{r.commandYear}",
+ salaryRef = r.templateDoc,
+ isLeave = _null,
+ leaveReason = _null,
+ dateLeave = _null,
+ refCommandDate = DateTime.Now,
+ detail = p.DisciplineDisciplinary.Title,
+ level = p.DisciplineDisciplinary.DisciplinaryFaultLevel,
+ unStigma = "คำสั่งลงโทษ ตัดเงินเดือน"
+ }).ToList();
+
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
+ using (var client = new HttpClient())
+ {
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
+ {
+ data = resultData,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ if (_res.IsSuccessStatusCode)
+ {
+ data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; });
+ await _context.SaveChangesAsync();
+ }
+ }
+ return Success();
+ }
+
+ ///
+ /// ส่งรายชื่อออกคำสั่ง C-PM-29
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost("command29/report")]
+ public async Task> PostReportCommand29([FromBody] ReportPersonRequest req_)
+ {
+ try
+ {
+ var resultData = new List();
+ var baseAPI = _configuration["API"];
+
+ foreach (var id in req_.refIds)
+ {
+ var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}";
+
+ var commandType = await _context.Set()
+ .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-29")
+ .FirstOrDefaultAsync();
+ var response = new PassDisciplineResponse();
+ using (var client = new HttpClient())
+ {
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
+ var res = await client.SendAsync(req);
+ var result = await res.Content.ReadAsStringAsync();
+
+ response = JsonConvert.DeserializeObject(result);
+
+ var seq = 1;
+ foreach (var d in response!.result)
+ {
+ if (commandType == null || commandType.Id != d.commandId)
+ continue;
+ var _baseAPI = _configuration["API"];
+ var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}";
+ using (var _client = new HttpClient())
+ {
+ _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
+ var _res = await _client.SendAsync(_req);
+ var _result = await _res.Content.ReadAsStringAsync();
+
+ var org = JsonConvert.DeserializeObject(_result);
+
+ if (org == null || org.result == null)
+ continue;
+
+ var receiver = new CommandReceiver
+ {
+ Sequence = seq,
+ CitizenId = org.result.citizenId == null ? "" : org.result.citizenId,
+ Prefix = org.result.prefix == null ? "" : org.result.prefix,
+ FirstName = org.result.firstName == null ? "" : org.result.firstName,
+ LastName = org.result.lastName == null ? "" : org.result.lastName,
+ RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId),
+ RefDisciplineId = d.id,
+ Amount = 0,
+ };
+ seq++;
+ resultData.Add(receiver);
+ }
+ }
+ }
+ }
+ return Success();
+ }
+ catch
+ {
+ throw;
+ }
+ }
+
+ ///
+ /// ออกคำสั่ง C-PM-29 คำสั่งลงโทษ ลดขั้นเงินเดือน
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost("command29/report/excecute")]
+ public async Task> PostReportCommand29Execute([FromBody] ReportExecuteRequest req)
+ {
+ var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
+ .Include(x => x.DisciplineDisciplinary)
+ .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
+ .ToListAsync();
+ string? _null = null;
+ var resultData = (from p in data
+ join r in req.refIds
+ on p.Id.ToString() equals r.refId
+ select new
+ {
+ profileId = p.PersonId,
+ date = r.commandAffectDate,
+ refCommandNo = $"{r.commandNo}/{r.commandYear}",
+ salaryRef = r.templateDoc,
+ isLeave = _null,
+ leaveReason = _null,
+ dateLeave = _null,
+ refCommandDate = DateTime.Now,
+ detail = p.DisciplineDisciplinary.Title,
+ level = p.DisciplineDisciplinary.DisciplinaryFaultLevel,
+ unStigma = "คำสั่งลงโทษ ลดขั้นเงินเดือน"
+ }).ToList();
+
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
+ using (var client = new HttpClient())
+ {
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
+ {
+ data = resultData,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ if (_res.IsSuccessStatusCode)
+ {
+ data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; });
+ await _context.SaveChangesAsync();
+ }
+ }
+ return Success();
+ }
+
+ ///
+ /// ส่งรายชื่อออกคำสั่ง C-PM-30
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost("command30/report")]
+ public async Task> PostReportCommand30([FromBody] ReportPersonRequest req_)
+ {
+ try
+ {
+ var resultData = new List();
+ var baseAPI = _configuration["API"];
+
+ foreach (var id in req_.refIds)
+ {
+ var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}";
+
+ var commandType = await _context.Set()
+ .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-30")
+ .FirstOrDefaultAsync();
+ var response = new PassDisciplineResponse();
+ using (var client = new HttpClient())
+ {
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
+ var res = await client.SendAsync(req);
+ var result = await res.Content.ReadAsStringAsync();
+
+ response = JsonConvert.DeserializeObject(result);
+
+ var seq = 1;
+ foreach (var d in response!.result)
+ {
+ if (commandType == null || commandType.Id != d.commandId)
+ continue;
+ var _baseAPI = _configuration["API"];
+ var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}";
+ using (var _client = new HttpClient())
+ {
+ _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
+ var _res = await _client.SendAsync(_req);
+ var _result = await _res.Content.ReadAsStringAsync();
+
+ var org = JsonConvert.DeserializeObject(_result);
+
+ if (org == null || org.result == null)
+ continue;
+
+ var receiver = new CommandReceiver
+ {
+ Sequence = seq,
+ CitizenId = org.result.citizenId == null ? "" : org.result.citizenId,
+ Prefix = org.result.prefix == null ? "" : org.result.prefix,
+ FirstName = org.result.firstName == null ? "" : org.result.firstName,
+ LastName = org.result.lastName == null ? "" : org.result.lastName,
+ RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId),
+ RefDisciplineId = d.id,
+ Amount = 0,
+ };
+ seq++;
+ resultData.Add(receiver);
+ }
+ }
+ }
+ }
+ return Success();
+ }
+ catch
+ {
+ throw;
+ }
+ }
+
+ ///
+ /// ออกคำสั่ง C-PM-30 คำสั่งเพิ่มโทษ
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost("command30/report/excecute")]
+ public async Task> PostReportCommand30Execute([FromBody] ReportExecuteRequest req)
+ {
+ var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
+ .Include(x => x.DisciplineDisciplinary)
+ .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
+ .ToListAsync();
+ string? _null = null;
+ var resultData = (from p in data
+ join r in req.refIds
+ on p.Id.ToString() equals r.refId
+ select new
+ {
+ profileId = p.PersonId,
+ date = r.commandAffectDate,
+ refCommandNo = $"{r.commandNo}/{r.commandYear}",
+ salaryRef = r.templateDoc,
+ isLeave = _null,
+ leaveReason = _null,
+ dateLeave = _null,
+ refCommandDate = DateTime.Now,
+ detail = p.DisciplineDisciplinary.Title,
+ level = p.DisciplineDisciplinary.DisciplinaryFaultLevel,
+ unStigma = "คำสั่งเพิ่มโทษ"
+ }).ToList();
+
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
+ using (var client = new HttpClient())
+ {
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
+ {
+ data = resultData,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ if (_res.IsSuccessStatusCode)
+ {
+ data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; });
+ await _context.SaveChangesAsync();
+ }
+ }
+ return Success();
+ }
+
+ ///
+ /// ส่งรายชื่อออกคำสั่ง C-PM-31
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost("command31/report")]
+ public async Task> PostReportCommand31([FromBody] ReportPersonRequest req_)
+ {
+ try
+ {
+ var resultData = new List();
+ var baseAPI = _configuration["API"];
+
+ foreach (var id in req_.refIds)
+ {
+ var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}";
+
+ var commandType = await _context.Set()
+ .Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-31")
+ .FirstOrDefaultAsync();
+ var response = new PassDisciplineResponse();
+ using (var client = new HttpClient())
+ {
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
+ var res = await client.SendAsync(req);
+ var result = await res.Content.ReadAsStringAsync();
+
+ response = JsonConvert.DeserializeObject(result);
+
+ var seq = 1;
+ foreach (var d in response!.result)
+ {
+ if (commandType == null || commandType.Id != d.commandId)
+ continue;
+ var _baseAPI = _configuration["API"];
+ var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}";
+ using (var _client = new HttpClient())
+ {
+ _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
+ var _res = await _client.SendAsync(_req);
+ var _result = await _res.Content.ReadAsStringAsync();
+
+ var org = JsonConvert.DeserializeObject(_result);
+
+ if (org == null || org.result == null)
+ continue;
+
+ var receiver = new CommandReceiver
+ {
+ Sequence = seq,
+ CitizenId = org.result.citizenId == null ? "" : org.result.citizenId,
+ Prefix = org.result.prefix == null ? "" : org.result.prefix,
+ FirstName = org.result.firstName == null ? "" : org.result.firstName,
+ LastName = org.result.lastName == null ? "" : org.result.lastName,
+ RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId),
+ RefDisciplineId = d.id,
+ Amount = 0,
+ };
+ seq++;
+ resultData.Add(receiver);
+ }
+ }
+ }
+ }
+ return Success();
+ }
+ catch
+ {
+ throw;
+ }
+ }
+
+ ///
+ /// ออกคำสั่ง C-PM-31 คำสั่งงดโทษ
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost("command31/report/excecute")]
+ public async Task> PostReportCommand31Execute([FromBody] ReportExecuteRequest req)
+ {
+ var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
+ .Include(x => x.DisciplineDisciplinary)
+ .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
+ .ToListAsync();
+ string? _null = null;
+ var resultData = (from p in data
+ join r in req.refIds
+ on p.Id.ToString() equals r.refId
+ select new
+ {
+ profileId = p.PersonId,
+ date = r.commandAffectDate,
+ refCommandNo = $"{r.commandNo}/{r.commandYear}",
+ salaryRef = r.templateDoc,
+ isLeave = _null,
+ leaveReason = _null,
+ dateLeave = _null,
+ refCommandDate = DateTime.Now,
+ detail = p.DisciplineDisciplinary.Title,
+ level = p.DisciplineDisciplinary.DisciplinaryFaultLevel,
+ unStigma = "คำสั่งงดโทษ"
+ }).ToList();
+
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
+ using (var client = new HttpClient())
+ {
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
+ {
+ data = resultData,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ if (_res.IsSuccessStatusCode)
+ {
+ data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; });
+ await _context.SaveChangesAsync();
+ }
+ }
+ return Success();
+ }
+
+ ///
+ /// ส่งรายชื่อออกคำสั่ง C-PM-32
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost("command32/report")]
+ public async Task> PostReportCommand32([FromBody] ReportPersonRequest req_)
+ {
+ try
+ {
+ var resultData = new List();
+ var baseAPI = _configuration["API"];
+
+ foreach (var id in req_.refIds)
+ {
+ var apiUrl = $"{baseAPI}/discipline/result/report/reject/{id}";
+
+ var response = new PassDisciplineResponse();
+ using (var client = new HttpClient())
+ {
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
+ var res = await client.SendAsync(req);
+ var result = await res.Content.ReadAsStringAsync();
+
+ response = JsonConvert.DeserializeObject(result);
+
+ var seq = 1;
+ foreach (var d in response!.result)
+ {
+ var _baseAPI = _configuration["API"];
+ var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}";
+ using (var _client = new HttpClient())
+ {
+ _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ _client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
+ var _res = await _client.SendAsync(_req);
+ var _result = await _res.Content.ReadAsStringAsync();
+
+ var org = JsonConvert.DeserializeObject(_result);
+
+ if (org == null || org.result == null)
+ continue;
+
+ var receiver = new CommandReceiver
+ {
+ Sequence = seq,
+ CitizenId = org.result.citizenId == null ? "" : org.result.citizenId,
+ Prefix = org.result.prefix == null ? "" : org.result.prefix,
+ FirstName = org.result.firstName == null ? "" : org.result.firstName,
+ LastName = org.result.lastName == null ? "" : org.result.lastName,
+ RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId),
+ RefDisciplineId = d.id,
+ Amount = 0,
+ };
+ seq++;
+ resultData.Add(receiver);
+ }
+ }
+ }
+ }
+ return Success();
+ }
+ catch
+ {
+ throw;
+ }
+ }
+
+ ///
+ /// ออกคำสั่ง C-PM-32 คำสั่งยุติเรื่อง
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost("command32/report/excecute")]
+ public async Task> PostReportCommand32Execute([FromBody] ReportExecuteRequest req)
+ {
+ var data = await _context.DisciplineInvestigate_ProfileComplaints
+ .Include(x => x.DisciplineInvestigate)
+ .Where(x => x.IsReport == "REPORT")
+ .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
+ .ToListAsync();
+ string? _null = null;
+ dynamic? resultData = null;
+ if (data.Count != 0)
+ {
+ resultData = (from p in data
+ join r in req.refIds
+ on p.Id.ToString() equals r.refId
+ select new
+ {
+ profileId = p.PersonId,
+ date = r.commandAffectDate,
+ refCommandNo = $"{r.commandNo}/{r.commandYear}",
+ salaryRef = r.templateDoc,
+ isLeave = false,
+ leaveReason = _null,
+ dateLeave = _null,
+ refCommandDate = DateTime.Now,
+ detail = p.DisciplineInvestigate.Title,
+ level = "",
+ unStigma = "คำสั่งยุติเรื่อง"
+ }).ToList();
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
+ using (var client = new HttpClient())
+ {
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
+ {
+ data = resultData,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ if (_res.IsSuccessStatusCode)
+ {
+ data.ForEach(profile => profile.IsReport = "NEW");
+ await _context.SaveChangesAsync();
+ }
+ }
+ }
+ else
+ {
+ var data1 = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
+ .Include(x => x.DisciplineDisciplinary)
+ .Where(x => x.IsReport == "REPORT")
+ .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
+ .ToListAsync();
+ resultData = (from p in data1
+ join r in req.refIds
+ on p.Id.ToString() equals r.refId
+ select new
+ {
+ profileId = p.PersonId,
+ date = r.commandAffectDate,
+ refCommandNo = $"{r.commandNo}/{r.commandYear}",
+ salaryRef = r.templateDoc,
+ isLeave = false,
+ leaveReason = _null,
+ dateLeave = _null,
+ refCommandDate = DateTime.Now,
+ detail = p.DisciplineDisciplinary.Title,
+ level = p.DisciplineDisciplinary.DisciplinaryFaultLevel,
+ unStigma = "คำสั่งยุติเรื่อง"
+ }).ToList();
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
+ using (var client = new HttpClient())
+ {
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
+ {
+ data = resultData,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ if (_res.IsSuccessStatusCode)
+ {
+ data1.ForEach(profile => profile.IsReport = "NEW");
+ await _context.SaveChangesAsync();
+ }
+ }
+ }
+
+ return Success();
+ }
}
}
diff --git a/BMA.EHR.Discipline.Service/Requests/ReportAttachmentRequest.cs b/BMA.EHR.Discipline.Service/Requests/ReportAttachmentRequest.cs
new file mode 100644
index 00000000..e371d927
--- /dev/null
+++ b/BMA.EHR.Discipline.Service/Requests/ReportAttachmentRequest.cs
@@ -0,0 +1,25 @@
+using BMA.EHR.Domain.Models.MetaData;
+using Microsoft.EntityFrameworkCore;
+
+namespace BMA.EHR.Discipline.Service.Requests
+{
+ public class ReportAttachmentRequest
+ {
+ public ReportAttachmentRequestObj[] refIds { get; set; }
+ }
+ public class ReportAttachmentRequestObj
+ {
+ public string? refId { get; set; }
+ public int? Sequence { get; set; }
+ public string? CitizenId { get; set; }
+ public string? Prefix { get; set; }
+ public string? FirstName { get; set; }
+ public string? LastName { get; set; }
+ public double? Amount { get; set; }
+ public double? PositionSalaryAmount { get; set; }
+ public double? MouthSalaryAmount { get; set; }
+ public string? RemarkHorizontal { get; set; }
+ public string? RemarkVertical { get; set; }
+ public int CommandYear { get; set; }
+ }
+}
diff --git a/BMA.EHR.Discipline.Service/Requests/ReportExecuteRequest.cs b/BMA.EHR.Discipline.Service/Requests/ReportExecuteRequest.cs
new file mode 100644
index 00000000..c7446828
--- /dev/null
+++ b/BMA.EHR.Discipline.Service/Requests/ReportExecuteRequest.cs
@@ -0,0 +1,21 @@
+using BMA.EHR.Domain.Models.MetaData;
+using Microsoft.EntityFrameworkCore;
+
+namespace BMA.EHR.Discipline.Service.Requests
+{
+ public class ReportExecuteRequest
+ {
+ public ReportExecuteRequestObj[] refIds { get; set; }
+ }
+ public class ReportExecuteRequestObj
+ {
+ public string? refId { get; set; }
+ public DateTime commandAffectDate { get; set; }
+ public string? commandNo { get; set; }
+ public int commandYear { get; set; }
+ public string? templateDoc { get; set; }
+ public double? amount { get; set; }
+ public double? positionSalaryAmount { get; set; }
+ public double? mouthSalaryAmount { get; set; }
+ }
+}
diff --git a/BMA.EHR.Discipline.Service/Requests/ReportPersonRequest.cs b/BMA.EHR.Discipline.Service/Requests/ReportPersonRequest.cs
new file mode 100644
index 00000000..f393a864
--- /dev/null
+++ b/BMA.EHR.Discipline.Service/Requests/ReportPersonRequest.cs
@@ -0,0 +1,10 @@
+using BMA.EHR.Domain.Models.MetaData;
+using Microsoft.EntityFrameworkCore;
+
+namespace BMA.EHR.Discipline.Service.Requests
+{
+ public class ReportPersonRequest
+ {
+ public string[] refIds { get; set; }
+ }
+}
diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs
index 5a93eb6a..c7fd9ad3 100644
--- a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs
+++ b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs
@@ -824,7 +824,7 @@ namespace BMA.EHR.Placement.Service.Controllers
}
///
- /// ออกคำสั่ง C-PM-05
+ /// ออกคำสั่ง C-PM-05 คำสั่งแต่งตั้ง
///
///
///
@@ -834,68 +834,53 @@ namespace BMA.EHR.Placement.Service.Controllers
[HttpPost("appoint/report/excecute")]
public async Task> PostReportExecuteAppoint([FromBody] ReportExecuteRequest req)
{
- // create new profile
- foreach (var recv in req.refIds)
+ var data = await _context.PlacementAppointments
+ .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
+ .ToListAsync();
+ var resultData = (from p in data
+ join r in req.refIds
+ on p.Id.ToString() equals r.refId
+ select new
+ {
+ profileId = p.profileId,
+ date = r.commandAffectDate,
+ amount = r.amount,
+ positionSalaryAmount = r.positionSalaryAmount,
+ mouthSalaryAmount = r.mouthSalaryAmount,
+ posNo = p.posMasterNo == null ? "" :
+ p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}" :
+ p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}" :
+ p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}" :
+ p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}" :
+ p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}" : "",
+ position = p.position,
+ positionLine = "",
+ positionPathSide = "",
+ positionExecutive = "",
+ positionType = p.posTypeName,
+ positionLevel = p.posLevelName,
+ refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
+ templateDoc = r.templateDoc,
+ posmasterId = p.posmasterId,
+ positionId = p.positionId,
+ }).ToList();
+
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current";
+ using (var client = new HttpClient())
{
- var placementProfile = await _context.PlacementAppointments
- .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId));
- if (placementProfile == null)
- continue;
-
- if (placementProfile == null)
- throw new Exception(GlobalMessages.DataNotFound);
- var baseAPI = _configuration["API"];
- var apiUrlSalary = $"{baseAPI}/org/profile/salary";
- using (var client = new HttpClient())
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
- var _res = await client.PostAsJsonAsync(apiUrlSalary, new
- {
- profileId = placementProfile.profileId,
- date = recv.commandAffectDate,
- amount = recv.amount,
- positionSalaryAmount = recv.positionSalaryAmount,
- mouthSalaryAmount = recv.mouthSalaryAmount,
- posNo = placementProfile.posMasterNo == null ? "" :
- placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "",
- position = placementProfile.position,
- positionLine = "",
- positionPathSide = "",
- positionExecutive = "",
- positionType = placementProfile.posTypeName,
- positionLevel = placementProfile.posLevelName,
- refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
- templateDoc = recv.templateDoc,
- });
- var _result = await _res.Content.ReadAsStringAsync();
- }
-
- var baseAPIOrg = _configuration["API"];
- var apiUrlOrg = $"{baseAPIOrg}/org/pos/report/current";
- using (var client = new HttpClient())
+ data = resultData,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ if (_res.IsSuccessStatusCode)
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg);
- var _res = await client.PostAsJsonAsync(apiUrlOrg, new
- {
- posmasterId = placementProfile.posmasterId,
- positionId = placementProfile.positionId,
- profileId = placementProfile.profileId,
- });
- var _result = await _res.Content.ReadAsStringAsync();
+ data.ForEach(profile => profile.Status = "DONE");
+ await _context.SaveChangesAsync();
}
-
- // update placementstatus
- placementProfile.Status = "DONE";
-
- await _context.SaveChangesAsync();
}
return Success();
}
@@ -981,7 +966,7 @@ namespace BMA.EHR.Placement.Service.Controllers
}
///
- /// ออกคำสั่ง C-PM-06
+ /// ออกคำสั่ง C-PM-06 เลื่อนข้าราชการ
///
///
///
@@ -991,68 +976,53 @@ namespace BMA.EHR.Placement.Service.Controllers
[HttpPost("slip/report/excecute")]
public async Task> PostReportExecuteSlip([FromBody] ReportExecuteRequest req)
{
- // create new profile
- foreach (var recv in req.refIds)
+ var data = await _context.PlacementAppointments
+ .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
+ .ToListAsync();
+ var resultData = (from p in data
+ join r in req.refIds
+ on p.Id.ToString() equals r.refId
+ select new
+ {
+ profileId = p.profileId,
+ date = r.commandAffectDate,
+ amount = r.amount,
+ positionSalaryAmount = r.positionSalaryAmount,
+ mouthSalaryAmount = r.mouthSalaryAmount,
+ posNo = p.posMasterNo == null ? "" :
+ p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}" :
+ p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}" :
+ p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}" :
+ p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}" :
+ p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}" : "",
+ position = p.position,
+ positionLine = "",
+ positionPathSide = "",
+ positionExecutive = "",
+ positionType = p.posTypeName,
+ positionLevel = p.posLevelName,
+ refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
+ templateDoc = r.templateDoc,
+ posmasterId = p.posmasterId,
+ positionId = p.positionId,
+ }).ToList();
+
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current";
+ using (var client = new HttpClient())
{
- var placementProfile = await _context.PlacementAppointments
- .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId));
- if (placementProfile == null)
- continue;
-
- if (placementProfile == null)
- throw new Exception(GlobalMessages.DataNotFound);
- var baseAPI = _configuration["API"];
- var apiUrlSalary = $"{baseAPI}/org/profile/salary";
- using (var client = new HttpClient())
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
- var _res = await client.PostAsJsonAsync(apiUrlSalary, new
- {
- profileId = placementProfile.profileId,
- date = recv.commandAffectDate,
- amount = recv.amount,
- positionSalaryAmount = recv.positionSalaryAmount,
- mouthSalaryAmount = recv.mouthSalaryAmount,
- posNo = placementProfile.posMasterNo == null ? "" :
- placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "",
- position = placementProfile.position,
- positionLine = "",
- positionPathSide = "",
- positionExecutive = "",
- positionType = placementProfile.posTypeName,
- positionLevel = placementProfile.posLevelName,
- refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
- templateDoc = recv.templateDoc,
- });
- var _result = await _res.Content.ReadAsStringAsync();
- }
-
- var baseAPIOrg = _configuration["API"];
- var apiUrlOrg = $"{baseAPIOrg}/org/pos/report/current";
- using (var client = new HttpClient())
+ data = resultData,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ if (_res.IsSuccessStatusCode)
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg);
- var _res = await client.PostAsJsonAsync(apiUrlOrg, new
- {
- posmasterId = placementProfile.posmasterId,
- positionId = placementProfile.positionId,
- profileId = placementProfile.profileId,
- });
- var _result = await _res.Content.ReadAsStringAsync();
+ data.ForEach(profile => profile.Status = "DONE");
+ await _context.SaveChangesAsync();
}
-
- // update placementstatus
- placementProfile.Status = "DONE";
-
- await _context.SaveChangesAsync();
}
return Success();
}
@@ -1138,7 +1108,7 @@ namespace BMA.EHR.Placement.Service.Controllers
}
///
- /// ออกคำสั่ง C-PM-07
+ /// ออกคำสั่ง C-PM-07 ย้ายข้าราชการ
///
///
///
@@ -1148,65 +1118,53 @@ namespace BMA.EHR.Placement.Service.Controllers
[HttpPost("move/report/excecute")]
public async Task> PostReportExecuteMove([FromBody] ReportExecuteRequest req)
{
- // create new profile
- foreach (var recv in req.refIds)
+ var data = await _context.PlacementAppointments
+ .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
+ .ToListAsync();
+ var resultData = (from p in data
+ join r in req.refIds
+ on p.Id.ToString() equals r.refId
+ select new
+ {
+ profileId = p.profileId,
+ date = r.commandAffectDate,
+ amount = r.amount,
+ positionSalaryAmount = r.positionSalaryAmount,
+ mouthSalaryAmount = r.mouthSalaryAmount,
+ posNo = p.posMasterNo == null ? "" :
+ p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}" :
+ p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}" :
+ p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}" :
+ p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}" :
+ p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}" : "",
+ position = p.position,
+ positionLine = "",
+ positionPathSide = "",
+ positionExecutive = "",
+ positionType = p.posTypeName,
+ positionLevel = p.posLevelName,
+ refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
+ templateDoc = r.templateDoc,
+ posmasterId = p.posmasterId,
+ positionId = p.positionId,
+ }).ToList();
+
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current";
+ using (var client = new HttpClient())
{
- var placementProfile = await _context.PlacementAppointments
- .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId));
- if (placementProfile == null)
- continue;
- var baseAPI = _configuration["API"];
- var apiUrlSalary = $"{baseAPI}/org/profile/salary";
- using (var client = new HttpClient())
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
- var _res = await client.PostAsJsonAsync(apiUrlSalary, new
- {
- profileId = placementProfile.profileId,
- date = recv.commandAffectDate,
- amount = recv.amount,
- positionSalaryAmount = recv.positionSalaryAmount,
- mouthSalaryAmount = recv.mouthSalaryAmount,
- posNo = placementProfile.posMasterNo == null ? "" :
- placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "",
- position = placementProfile.position,
- positionLine = "",
- positionPathSide = "",
- positionExecutive = "",
- positionType = placementProfile.posTypeName,
- positionLevel = placementProfile.posLevelName,
- refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
- templateDoc = recv.templateDoc,
- });
- var _result = await _res.Content.ReadAsStringAsync();
- }
-
- var baseAPIOrg = _configuration["API"];
- var apiUrlOrg = $"{baseAPIOrg}/org/pos/report/current";
- using (var client = new HttpClient())
+ data = resultData,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ if (_res.IsSuccessStatusCode)
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg);
- var _res = await client.PostAsJsonAsync(apiUrlOrg, new
- {
- posmasterId = placementProfile.posmasterId,
- positionId = placementProfile.positionId,
- profileId = placementProfile.profileId,
- });
- var _result = await _res.Content.ReadAsStringAsync();
+ data.ForEach(profile => profile.Status = "DONE");
+ await _context.SaveChangesAsync();
}
-
- // update placementstatus
- placementProfile.Status = "DONE";
-
- await _context.SaveChangesAsync();
}
return Success();
}
@@ -1289,7 +1247,7 @@ namespace BMA.EHR.Placement.Service.Controllers
}
///
- /// ออกคำสั่ง C-PM-22
+ /// ออกคำสั่ง C-PM-22 คำสั่งปรับระดับชั้นงาน
///
///
///
@@ -1299,63 +1257,50 @@ namespace BMA.EHR.Placement.Service.Controllers
[HttpPost("employee-appoint/report/excecute")]
public async Task> PostReportExecuteEmployeeAppoint([FromBody] ReportExecuteRequest req)
{
- // create new profile
- foreach (var recv in req.refIds)
+ var data = await _context.PlacementAppointments
+ .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
+ .ToListAsync();
+ var resultData = (from p in data
+ join r in req.refIds
+ on p.Id.ToString() equals r.refId
+ select new
+ {
+ profileId = p.profileId,
+ date = r.commandAffectDate,
+ amount = r.amount,
+ positionSalaryAmount = r.positionSalaryAmount,
+ mouthSalaryAmount = r.mouthSalaryAmount,
+ posNo = p.posMasterNo == null ? "" :
+ p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}" :
+ p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}" :
+ p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}" :
+ p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}" :
+ p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}" : "",
+ position = p.position,
+ positionType = p.posTypeName,
+ positionLevel = p.posLevelName,
+ refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
+ templateDoc = r.templateDoc,
+ posmasterId = p.posmasterId,
+ positionId = p.positionId,
+ }).ToList();
+
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-employee-current";
+ using (var client = new HttpClient())
{
- var data = await _context.PlacementAppointments
- .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId));
- if (data == null)
- continue;
-
- var baseAPI = _configuration["API"];
- var apiUrlSalary = $"{baseAPI}/org/profile-employee/salary";
- using (var client = new HttpClient())
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
- var _res = await client.PostAsJsonAsync(apiUrlSalary, new
- {
- profileEmployeeId = data.profileId,
- date = recv.commandAffectDate,
- amount = recv.amount,
- positionSalaryAmount = recv.positionSalaryAmount,
- mouthSalaryAmount = recv.mouthSalaryAmount,
- posNo = data.posMasterNo == null ? "" :
- data.node == 4 ? $"{data.child4ShortName}{data.posMasterNo}" :
- data.node == 3 ? $"{data.child3ShortName}{data.posMasterNo}" :
- data.node == 2 ? $"{data.child2ShortName}{data.posMasterNo}" :
- data.node == 1 ? $"{data.child1ShortName}{data.posMasterNo}" :
- data.node == 0 ? $"{data.rootShortName}{data.posMasterNo}" : "",
- position = data.position,
- positionType = data.posTypeName,
- positionLevel = data.posLevelName,
- refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
- templateDoc = recv.templateDoc,
- });
- var _result = await _res.Content.ReadAsStringAsync();
- }
-
- var baseAPIOrg = _configuration["API"];
- var apiUrlOrg = $"{baseAPIOrg}/org/employee/pos/report/current";
- using (var client = new HttpClient())
+ data = resultData,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ if (_res.IsSuccessStatusCode)
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg);
- var _res = await client.PostAsJsonAsync(apiUrlOrg, new
- {
- posmasterId = data.posmasterId,
- positionId = data.positionId,
- profileId = data.profileId,
- });
- var _result = await _res.Content.ReadAsStringAsync();
+ data.ForEach(profile => profile.Status = "DONE");
+ await _context.SaveChangesAsync();
}
-
- // update placementstatus
- data.Status = "DONE";
-
- await _context.SaveChangesAsync();
}
return Success();
}
@@ -1438,7 +1383,7 @@ namespace BMA.EHR.Placement.Service.Controllers
}
///
- /// ออกคำสั่ง C-PM-24
+ /// ออกคำสั่ง C-PM-24 คำสั่งย้ายลูกจ้างประจำ
///
///
///
@@ -1448,63 +1393,50 @@ namespace BMA.EHR.Placement.Service.Controllers
[HttpPost("employee-move/report/excecute")]
public async Task> PostReportExecuteEmployeeMove([FromBody] ReportExecuteRequest req)
{
- // create new profile
- foreach (var recv in req.refIds)
+ var data = await _context.PlacementAppointments
+ .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
+ .ToListAsync();
+ var resultData = (from p in data
+ join r in req.refIds
+ on p.Id.ToString() equals r.refId
+ select new
+ {
+ profileId = p.profileId,
+ date = r.commandAffectDate,
+ amount = r.amount,
+ positionSalaryAmount = r.positionSalaryAmount,
+ mouthSalaryAmount = r.mouthSalaryAmount,
+ posNo = p.posMasterNo == null ? "" :
+ p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}" :
+ p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}" :
+ p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}" :
+ p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}" :
+ p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}" : "",
+ position = p.position,
+ positionType = p.posTypeName,
+ positionLevel = p.posLevelName,
+ refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
+ templateDoc = r.templateDoc,
+ posmasterId = p.posmasterId,
+ positionId = p.positionId,
+ }).ToList();
+
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-employee-current";
+ using (var client = new HttpClient())
{
- var data = await _context.PlacementAppointments
- .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId));
-
- if (data == null)
- throw new Exception(GlobalMessages.DataNotFound);
- var baseAPI = _configuration["API"];
- var apiUrlSalary = $"{baseAPI}/org/profile-employee/salary";
- using (var client = new HttpClient())
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
- var _res = await client.PostAsJsonAsync(apiUrlSalary, new
- {
- profileEmployeeId = data.profileId,
- date = recv.commandAffectDate,
- amount = recv.amount,
- positionSalaryAmount = recv.positionSalaryAmount,
- mouthSalaryAmount = recv.mouthSalaryAmount,
- posNo = data.posMasterNo == null ? "" :
- data.node == 4 ? $"{data.child4ShortName}{data.posMasterNo}" :
- data.node == 3 ? $"{data.child3ShortName}{data.posMasterNo}" :
- data.node == 2 ? $"{data.child2ShortName}{data.posMasterNo}" :
- data.node == 1 ? $"{data.child1ShortName}{data.posMasterNo}" :
- data.node == 0 ? $"{data.rootShortName}{data.posMasterNo}" : "",
- position = data.position,
- positionType = data.posTypeName,
- positionLevel = data.posLevelName,
- refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
- templateDoc = recv.templateDoc,
- });
- var _result = await _res.Content.ReadAsStringAsync();
- }
-
- var baseAPIOrg = _configuration["API"];
- var apiUrlOrg = $"{baseAPIOrg}/org/employee/pos/report/current";
- using (var client = new HttpClient())
+ data = resultData,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ if (_res.IsSuccessStatusCode)
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg);
- var _res = await client.PostAsJsonAsync(apiUrlOrg, new
- {
- posmasterId = data.posmasterId,
- positionId = data.positionId,
- profileId = data.profileId,
- });
- var _result = await _res.Content.ReadAsStringAsync();
+ data.ForEach(profile => profile.Status = "DONE");
+ await _context.SaveChangesAsync();
}
-
- // update placementstatus
- data.Status = "DONE";
-
- await _context.SaveChangesAsync();
}
return Success();
}
diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs
index 6cdcbc75..067dae21 100644
--- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs
+++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs
@@ -1545,7 +1545,7 @@ namespace BMA.EHR.Placement.Service.Controllers
}
///
- /// ออกคำสั่ง C-PM-01
+ /// ออกคำสั่ง C-PM-01 บรรจุและแต่งตั้งผู้สอบแข่งขันได้
///
///
///
@@ -1818,7 +1818,7 @@ namespace BMA.EHR.Placement.Service.Controllers
}
///
- /// ออกคำสั่ง C-PM-02
+ /// ออกคำสั่ง C-PM-02 บรรจุและแต่งตั้งผู้ได้รับคัดเลือก
///
///
///
@@ -2101,7 +2101,7 @@ namespace BMA.EHR.Placement.Service.Controllers
}
///
- /// ออกคำสั่ง C-PM-03
+ /// ออกคำสั่ง C-PM-03 แต่งตั้งข้าราชการ
///
///
///
@@ -2111,66 +2111,53 @@ namespace BMA.EHR.Placement.Service.Controllers
[HttpPost("appoint/report/excecute")]
public async Task> PostReportExecuteAppoint([FromBody] ReportExecuteRequest req)
{
- // create new profile
- foreach (var recv in req.refIds)
+ var data = await _context.PlacementProfiles
+ .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
+ .ToListAsync();
+ var resultData = (from p in data
+ join r in req.refIds
+ on p.Id.ToString() equals r.refId
+ select new
+ {
+ profileId = p.profileId,
+ date = r.commandAffectDate,
+ amount = r.amount,
+ positionSalaryAmount = r.positionSalaryAmount,
+ mouthSalaryAmount = r.mouthSalaryAmount,
+ posNo = p.posMasterNo == null ? "" :
+ p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}" :
+ p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}" :
+ p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}" :
+ p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}" :
+ p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}" : "",
+ position = p.positionName,
+ positionLine = "",
+ positionPathSide = "",
+ positionExecutive = "",
+ positionType = p.posTypeName,
+ positionLevel = p.posLevelName,
+ refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
+ templateDoc = r.templateDoc,
+ posmasterId = p.posmasterId,
+ positionId = p.positionId,
+ }).ToList();
+
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current";
+ using (var client = new HttpClient())
{
- var placementProfile = await _context.PlacementProfiles
- .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId));
- if (placementProfile == null)
- continue;
-
- var baseAPI = _configuration["API"];
- var apiUrlSalary = $"{baseAPI}/org/profile/salary";
- using (var client = new HttpClient())
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
- var _res = await client.PostAsJsonAsync(apiUrlSalary, new
- {
- profileId = placementProfile.profileId,
- date = recv.commandAffectDate,
- amount = recv.amount,
- positionSalaryAmount = recv.positionSalaryAmount,
- mouthSalaryAmount = recv.mouthSalaryAmount,
- posNo = placementProfile.posMasterNo == null ? "" :
- placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "",
- position = placementProfile.positionName,
- positionLine = "",
- positionPathSide = "",
- positionExecutive = "",
- positionType = placementProfile.posTypeName,
- positionLevel = placementProfile.posLevelName,
- refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
- templateDoc = recv.templateDoc,
- });
- var _result = await _res.Content.ReadAsStringAsync();
- }
-
- var baseAPIOrg = _configuration["API"];
- var apiUrlOrg = $"{baseAPIOrg}/org/pos/report/current";
- using (var client = new HttpClient())
+ data = resultData,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ if (_res.IsSuccessStatusCode)
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg);
- var _res = await client.PostAsJsonAsync(apiUrlOrg, new
- {
- posmasterId = placementProfile.posmasterId,
- positionId = placementProfile.positionId,
- profileId = placementProfile.profileId,
- });
- var _result = await _res.Content.ReadAsStringAsync();
+ data.ForEach(profile => profile.PlacementStatus = "CONTAIN");
+ await _context.SaveChangesAsync();
}
-
- // update placementstatus
- placementProfile.PlacementStatus = "CONTAIN";
-
- await _context.SaveChangesAsync();
}
return Success();
}
@@ -2268,7 +2255,7 @@ namespace BMA.EHR.Placement.Service.Controllers
}
///
- /// ออกคำสั่ง C-PM-04
+ /// ออกคำสั่ง C-PM-04 ย้ายข้าราชการ
///
///
///
@@ -2278,66 +2265,53 @@ namespace BMA.EHR.Placement.Service.Controllers
[HttpPost("move/report/excecute")]
public async Task> PostReportExecuteMove([FromBody] ReportExecuteRequest req)
{
- // create new profile
- foreach (var recv in req.refIds)
+ var data = await _context.PlacementProfiles
+ .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
+ .ToListAsync();
+ var resultData = (from p in data
+ join r in req.refIds
+ on p.Id.ToString() equals r.refId
+ select new
+ {
+ profileId = p.profileId,
+ date = r.commandAffectDate,
+ amount = r.amount,
+ positionSalaryAmount = r.positionSalaryAmount,
+ mouthSalaryAmount = r.mouthSalaryAmount,
+ posNo = p.posMasterNo == null ? "" :
+ p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}" :
+ p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}" :
+ p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}" :
+ p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}" :
+ p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}" : "",
+ position = p.positionName,
+ positionLine = "",
+ positionPathSide = "",
+ positionExecutive = "",
+ positionType = p.posTypeName,
+ positionLevel = p.posLevelName,
+ refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
+ templateDoc = r.templateDoc,
+ posmasterId = p.posmasterId,
+ positionId = p.positionId,
+ }).ToList();
+
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current";
+ using (var client = new HttpClient())
{
- var placementProfile = await _context.PlacementProfiles
- .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId));
- if (placementProfile == null)
- continue;
-
- var baseAPI = _configuration["API"];
- var apiUrlSalary = $"{baseAPI}/org/profile/salary";
- using (var client = new HttpClient())
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
- var _res = await client.PostAsJsonAsync(apiUrlSalary, new
- {
- profileId = placementProfile.profileId,
- date = recv.commandAffectDate,
- amount = recv.amount,
- positionSalaryAmount = recv.positionSalaryAmount,
- mouthSalaryAmount = recv.mouthSalaryAmount,
- posNo = placementProfile.posMasterNo == null ? "" :
- placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "",
- position = placementProfile.positionName,
- positionLine = "",
- positionPathSide = "",
- positionExecutive = "",
- positionType = placementProfile.posTypeName,
- positionLevel = placementProfile.posLevelName,
- refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
- templateDoc = recv.templateDoc,
- });
- var _result = await _res.Content.ReadAsStringAsync();
- }
-
- var baseAPIOrg = _configuration["API"];
- var apiUrlOrg = $"{baseAPIOrg}/org/pos/report/current";
- using (var client = new HttpClient())
+ data = resultData,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ if (_res.IsSuccessStatusCode)
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg);
- var _res = await client.PostAsJsonAsync(apiUrlOrg, new
- {
- posmasterId = placementProfile.posmasterId,
- positionId = placementProfile.positionId,
- profileId = placementProfile.profileId,
- });
- var _result = await _res.Content.ReadAsStringAsync();
+ data.ForEach(profile => profile.PlacementStatus = "CONTAIN");
+ await _context.SaveChangesAsync();
}
-
- // update placementstatus
- placementProfile.PlacementStatus = "CONTAIN";
-
- await _context.SaveChangesAsync();
}
return Success();
}
@@ -2435,7 +2409,7 @@ namespace BMA.EHR.Placement.Service.Controllers
}
///
- /// ออกคำสั่ง C-PM-39
+ /// ออกคำสั่ง C-PM-39 เลื่อนข้าราชการ
///
///
///
@@ -2445,66 +2419,53 @@ namespace BMA.EHR.Placement.Service.Controllers
[HttpPost("slip/report/excecute")]
public async Task> PostReportExecuteSlip([FromBody] ReportExecuteRequest req)
{
- // create new profile
- foreach (var recv in req.refIds)
+ var data = await _context.PlacementProfiles
+ .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
+ .ToListAsync();
+ var resultData = (from p in data
+ join r in req.refIds
+ on p.Id.ToString() equals r.refId
+ select new
+ {
+ profileId = p.profileId,
+ date = r.commandAffectDate,
+ amount = r.amount,
+ positionSalaryAmount = r.positionSalaryAmount,
+ mouthSalaryAmount = r.mouthSalaryAmount,
+ posNo = p.posMasterNo == null ? "" :
+ p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}" :
+ p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}" :
+ p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}" :
+ p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}" :
+ p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}" : "",
+ position = p.positionName,
+ positionLine = "",
+ positionPathSide = "",
+ positionExecutive = "",
+ positionType = p.posTypeName,
+ positionLevel = p.posLevelName,
+ refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
+ templateDoc = r.templateDoc,
+ posmasterId = p.posmasterId,
+ positionId = p.positionId,
+ }).ToList();
+
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current";
+ using (var client = new HttpClient())
{
- var placementProfile = await _context.PlacementProfiles
- .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId));
- if (placementProfile == null)
- continue;
-
- var baseAPI = _configuration["API"];
- var apiUrlSalary = $"{baseAPI}/org/profile/salary";
- using (var client = new HttpClient())
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
- var _res = await client.PostAsJsonAsync(apiUrlSalary, new
- {
- profileId = placementProfile.profileId,
- date = recv.commandAffectDate,
- amount = recv.amount,
- positionSalaryAmount = recv.positionSalaryAmount,
- mouthSalaryAmount = recv.mouthSalaryAmount,
- posNo = placementProfile.posMasterNo == null ? "" :
- placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "",
- position = placementProfile.positionName,
- positionLine = "",
- positionPathSide = "",
- positionExecutive = "",
- positionType = placementProfile.posTypeName,
- positionLevel = placementProfile.posLevelName,
- refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
- templateDoc = recv.templateDoc,
- });
- var _result = await _res.Content.ReadAsStringAsync();
- }
-
- var baseAPIOrg = _configuration["API"];
- var apiUrlOrg = $"{baseAPIOrg}/org/pos/report/current";
- using (var client = new HttpClient())
+ data = resultData,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ if (_res.IsSuccessStatusCode)
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg);
- var _res = await client.PostAsJsonAsync(apiUrlOrg, new
- {
- posmasterId = placementProfile.posmasterId,
- positionId = placementProfile.positionId,
- profileId = placementProfile.profileId,
- });
- var _result = await _res.Content.ReadAsStringAsync();
+ data.ForEach(profile => profile.PlacementStatus = "CONTAIN");
+ await _context.SaveChangesAsync();
}
-
- // update placementstatus
- placementProfile.PlacementStatus = "CONTAIN";
-
- await _context.SaveChangesAsync();
}
return Success();
}
diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs
index 4528957d..1cd048e4 100644
--- a/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs
+++ b/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs
@@ -634,7 +634,7 @@ namespace BMA.EHR.Placement.Service.Controllers
}
///
- /// ออกคำสั่ง C-PM-15
+ /// ออกคำสั่ง C-PM-15 คำสั่งให้ช่วยราชการ
///
///
///
@@ -644,46 +644,46 @@ namespace BMA.EHR.Placement.Service.Controllers
[HttpPost("command/report/excecute")]
public async Task> PostReportExecute([FromBody] ReportExecuteRequest req)
{
- // create new profile
- foreach (var recv in req.refIds)
+ var data = await _context.PlacementOfficers
+ .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
+ .ToListAsync();
+ var resultData = (from p in data
+ join r in req.refIds
+ on p.Id.ToString() equals r.refId
+ select new
+ {
+ profileId = p.profileId,
+ date = r.commandAffectDate,
+ amount = r.amount,
+ positionSalaryAmount = r.positionSalaryAmount,
+ mouthSalaryAmount = r.mouthSalaryAmount,
+ posNo = p.PositionNumberOld,
+ position = p.PositionOld,
+ positionLine = "",
+ positionPathSide = "",
+ positionExecutive = "",
+ positionType = p.PositionTypeOld,
+ positionLevel = p.PositionLevelOld,
+ refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
+ templateDoc = r.templateDoc,
+ }).ToList();
+
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary";
+ using (var client = new HttpClient())
{
- var data = await _context.PlacementOfficers
- .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId));
-
- if (data == null)
- throw new Exception(GlobalMessages.DataNotFound);
-
- var baseAPI = _configuration["API"];
- var apiUrlSalary = $"{baseAPI}/org/profile/salary";
- using (var client = new HttpClient())
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
- var _res = await client.PostAsJsonAsync(apiUrlSalary, new
- {
- profileId = data.profileId,
- date = recv.commandAffectDate,
- amount = recv.amount,
- positionSalaryAmount = recv.positionSalaryAmount,
- mouthSalaryAmount = recv.mouthSalaryAmount,
- posNo = data.PositionNumberOld,
- position = data.PositionOld,
- positionLine = "",
- positionPathSide = "",
- positionExecutive = "",
- positionType = data.PositionTypeOld,
- positionLevel = data.PositionLevelOld,
- refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
- templateDoc = recv.templateDoc,
- });
- var _result = await _res.Content.ReadAsStringAsync();
+ data = resultData,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ if (_res.IsSuccessStatusCode)
+ {
+ data.ForEach(profile => profile.Status = "DONE");
+ await _context.SaveChangesAsync();
}
-
- // update placementstatus
- data.Status = "DONE";
-
- await _context.SaveChangesAsync();
}
return Success();
}
diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs
index a8c10381..a4c5bcd4 100644
--- a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs
+++ b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs
@@ -960,7 +960,7 @@ namespace BMA.EHR.Placement.Service.Controllers
}
///
- /// ออกคำสั่ง C-PM-14
+ /// ออกคำสั่ง C-PM-14 คำสั่งรับโอนข้าราชการกรุงเทพมหานครสามัญ
///
///
///
@@ -970,68 +970,53 @@ namespace BMA.EHR.Placement.Service.Controllers
[HttpPost("command/report/excecute")]
public async Task> PostReportExecute([FromBody] ReportExecuteRequest req)
{
- // create new profile
- foreach (var recv in req.refIds)
+ var data = await _context.PlacementReceives
+ .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
+ .ToListAsync();
+ var resultData = (from p in data
+ join r in req.refIds
+ on p.Id.ToString() equals r.refId
+ select new
+ {
+ profileId = p.profileId,
+ date = r.commandAffectDate,
+ amount = r.amount,
+ positionSalaryAmount = r.positionSalaryAmount,
+ mouthSalaryAmount = r.mouthSalaryAmount,
+ posNo = p.posMasterNo == null ? "" :
+ p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}" :
+ p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}" :
+ p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}" :
+ p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}" :
+ p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}" : "",
+ position = p.position,
+ positionLine = "",
+ positionPathSide = "",
+ positionExecutive = "",
+ positionType = p.posTypeName,
+ positionLevel = p.posLevelName,
+ refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
+ templateDoc = r.templateDoc,
+ posmasterId = p.posmasterId,
+ positionId = p.positionId,
+ }).ToList();
+
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current";
+ using (var client = new HttpClient())
{
- // query placement Profile
- var placementProfile = await _context.PlacementReceives
- .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId));
-
- if (placementProfile == null)
- throw new Exception(GlobalMessages.DataNotFound);
-
- var baseAPI = _configuration["API"];
- var apiUrlSalary = $"{baseAPI}/org/profile/salary";
- using (var client = new HttpClient())
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
- var _res = await client.PostAsJsonAsync(apiUrlSalary, new
- {
- profileId = placementProfile.profileId,
- date = recv.commandAffectDate,
- amount = recv.amount,
- positionSalaryAmount = recv.positionSalaryAmount,
- mouthSalaryAmount = recv.mouthSalaryAmount,
- posNo = placementProfile.posMasterNo == null ? "" :
- placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" :
- placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "",
- position = placementProfile.position,
- positionLine = "",
- positionPathSide = "",
- positionExecutive = "",
- positionType = placementProfile.posTypeName,
- positionLevel = placementProfile.posLevelName,
- refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
- templateDoc = recv.templateDoc,
- });
- var _result = await _res.Content.ReadAsStringAsync();
- }
-
- var baseAPIOrg = _configuration["API"];
- var apiUrlOrg = $"{baseAPIOrg}/org/pos/report/current";
- using (var client = new HttpClient())
+ data = resultData,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ if (_res.IsSuccessStatusCode)
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlOrg);
- var _res = await client.PostAsJsonAsync(apiUrlOrg, new
- {
- posmasterId = placementProfile.posmasterId,
- positionId = placementProfile.positionId,
- profileId = placementProfile.profileId,
- });
- var _result = await _res.Content.ReadAsStringAsync();
+ data.ForEach(profile => profile.Status = "DONE");
+ await _context.SaveChangesAsync();
}
-
- // update placementstatus
- placementProfile.Status = "DONE";
-
- await _context.SaveChangesAsync();
}
return Success();
}
diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs
index 0e7b2bde..b2cf8359 100644
--- a/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs
+++ b/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs
@@ -496,7 +496,7 @@ namespace BMA.EHR.Placement.Service.Controllers
}
///
- /// ออกคำสั่ง C-PM-16
+ /// ออกคำสั่ง C-PM-16 คำสั่งส่งตัวกลับ
///
///
///
@@ -506,46 +506,46 @@ namespace BMA.EHR.Placement.Service.Controllers
[HttpPost("command/report/excecute")]
public async Task> PostReportExecute([FromBody] ReportExecuteRequest req)
{
- // create new profile
- foreach (var recv in req.refIds)
+ var data = await _context.PlacementRepatriations
+ .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
+ .ToListAsync();
+ var resultData = (from p in data
+ join r in req.refIds
+ on p.Id.ToString() equals r.refId
+ select new
+ {
+ profileId = p.profileId,
+ date = r.commandAffectDate,
+ amount = r.amount,
+ positionSalaryAmount = r.positionSalaryAmount,
+ mouthSalaryAmount = r.mouthSalaryAmount,
+ posNo = p.PositionNumberOld,
+ position = p.PositionOld,
+ positionLine = "",
+ positionPathSide = "",
+ positionExecutive = "",
+ positionType = p.PositionTypeOld,
+ positionLevel = p.PositionLevelOld,
+ refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
+ templateDoc = r.templateDoc,
+ }).ToList();
+
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary";
+ using (var client = new HttpClient())
{
- var data = await _context.PlacementRepatriations
- .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId));
-
- if (data == null)
- throw new Exception(GlobalMessages.DataNotFound);
-
- var baseAPI = _configuration["API"];
- var apiUrlSalary = $"{baseAPI}/org/profile/salary";
- using (var client = new HttpClient())
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
- var _res = await client.PostAsJsonAsync(apiUrlSalary, new
- {
- profileId = data.profileId,
- date = recv.commandAffectDate,
- amount = recv.amount,
- positionSalaryAmount = recv.positionSalaryAmount,
- mouthSalaryAmount = recv.mouthSalaryAmount,
- posNo = data.PositionNumberOld,
- position = data.PositionOld,
- positionLine = "",
- positionPathSide = "",
- positionExecutive = "",
- positionType = data.PositionTypeOld,
- positionLevel = data.PositionLevelOld,
- refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
- templateDoc = recv.templateDoc,
- });
- var _result = await _res.Content.ReadAsStringAsync();
+ data = resultData,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ if (_res.IsSuccessStatusCode)
+ {
+ data.ForEach(profile => profile.Status = "DONE");
+ await _context.SaveChangesAsync();
}
-
- // update placementstatus
- data.Status = "DONE";
-
- await _context.SaveChangesAsync();
}
return Success();
}
diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs
index 5dda6f29..58c4a3a2 100644
--- a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs
+++ b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs
@@ -827,7 +827,7 @@ namespace BMA.EHR.Placement.Service.Controllers
}
///
- /// ออกคำสั่ง C-PM-13
+ /// ออกคำสั่ง C-PM-13 คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ
///
///
///
@@ -837,46 +837,46 @@ namespace BMA.EHR.Placement.Service.Controllers
[HttpPost("command/report/excecute")]
public async Task> PostReportExecute([FromBody] ReportExecuteRequest req)
{
- // create new profile
- foreach (var recv in req.refIds)
+ var data = await _context.PlacementTransfers
+ .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
+ .ToListAsync();
+ var resultData = (from p in data
+ join r in req.refIds
+ on p.Id.ToString() equals r.refId
+ select new
+ {
+ profileId = p.profileId,
+ date = r.commandAffectDate,
+ amount = r.amount,
+ positionSalaryAmount = r.positionSalaryAmount,
+ mouthSalaryAmount = r.mouthSalaryAmount,
+ posNo = p.PositionNumberOld,
+ position = p.PositionOld,
+ positionLine = "",
+ positionPathSide = "",
+ positionExecutive = "",
+ positionType = p.PositionTypeOld,
+ positionLevel = p.PositionLevelOld,
+ refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
+ templateDoc = r.templateDoc,
+ }).ToList();
+
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary";
+ using (var client = new HttpClient())
{
- var data = await _context.PlacementTransfers
- .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId));
-
- if (data == null)
- throw new Exception(GlobalMessages.DataNotFound);
-
- var baseAPI = _configuration["API"];
- var apiUrlSalary = $"{baseAPI}/org/profile/salary";
- using (var client = new HttpClient())
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
- var _res = await client.PostAsJsonAsync(apiUrlSalary, new
- {
- profileId = data.profileId,
- date = recv.commandAffectDate,
- amount = recv.amount,
- positionSalaryAmount = recv.positionSalaryAmount,
- mouthSalaryAmount = recv.mouthSalaryAmount,
- posNo = data.PositionNumberOld,
- position = data.PositionOld,
- positionLine = "",
- positionPathSide = "",
- positionExecutive = "",
- positionType = data.PositionTypeOld,
- positionLevel = data.PositionLevelOld,
- refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
- templateDoc = recv.templateDoc,
- });
- var _result = await _res.Content.ReadAsStringAsync();
+ data = resultData,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ if (_res.IsSuccessStatusCode)
+ {
+ data.ForEach(profile => profile.Status = "DONE");
+ await _context.SaveChangesAsync();
}
-
- // update placementstatus
- data.Status = "DONE";
-
- await _context.SaveChangesAsync();
}
return Success();
}
diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs
index 2713a01b..b3a130c8 100644
--- a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs
+++ b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs
@@ -703,7 +703,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
}
///
- /// ออกคำสั่ง C-PM-08
+ /// ออกคำสั่ง C-PM-08 บรรจุและแต่งตั้งข้าราชการกลับเข้ารับราชการ
///
///
///
@@ -713,62 +713,50 @@ namespace BMA.EHR.Retirement.Service.Controllers
[HttpPost("appoint/report/excecute")]
public async Task> PostReportExecuteAppoint([FromBody] ReportExecuteRequest req)
{
- // create new profile
- foreach (var recv in req.refIds)
+ var data = await _context.RetirementOthers
+ .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
+ .ToListAsync();
+ string? _null = null;
+ var resultData = (from p in data
+ join r in req.refIds
+ on p.Id.ToString() equals r.refId
+ select new
+ {
+ profileId = p.profileId,
+ date = r.commandAffectDate,
+ amount = r.amount,
+ positionSalaryAmount = r.positionSalaryAmount,
+ mouthSalaryAmount = r.mouthSalaryAmount,
+ posNo = p.PositionNumberOld,
+ position = p.PositionOld,
+ positionLine = "",
+ positionPathSide = "",
+ positionExecutive = "",
+ positionType = p.PositionTypeOld,
+ positionLevel = p.PositionLevelOld,
+ refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
+ templateDoc = r.templateDoc,
+ isLeave = false,
+ leaveReason = _null,
+ dateLeave = _null,
+ }).ToList();
+
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
+ using (var client = new HttpClient())
{
- var placementProfile = await _context.RetirementOthers
- .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId));
-
- if (placementProfile == null)
- throw new Exception(GlobalMessages.DataNotFound);
- var baseAPI = _configuration["API"];
- var apiUrlSalary = $"{baseAPI}/org/profile/salary";
- using (var client = new HttpClient())
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
- var _res = await client.PostAsJsonAsync(apiUrlSalary, new
- {
- profileId = placementProfile.profileId,
- date = recv.commandAffectDate,
- amount = recv.amount,
- positionSalaryAmount = recv.positionSalaryAmount,
- mouthSalaryAmount = recv.mouthSalaryAmount,
- posNo = placementProfile.PositionNumberOld,
- position = placementProfile.PositionOld,
- positionLine = "",
- positionPathSide = "",
- positionExecutive = "",
- positionType = placementProfile.PositionTypeOld,
- positionLevel = placementProfile.PositionLevelOld,
- refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
- templateDoc = recv.templateDoc,
- });
- var _result = await _res.Content.ReadAsStringAsync();
- }
-
- var baseAPILeave = _configuration["API"];
- var apiUrlLeave = $"{baseAPI}/org/profile/leave/{placementProfile.profileId}";
- using (var client = new HttpClient())
+ data = resultData,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ if (_res.IsSuccessStatusCode)
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlLeave);
- string? _null = null;
- var _res = await client.PostAsJsonAsync(apiUrlLeave, new
- {
- isLeave = false,
- leaveReason = _null,
- dateLeave = _null,
- });
- var _result = await _res.Content.ReadAsStringAsync();
+ data.ForEach(profile => profile.Status = "DONE");
+ await _context.SaveChangesAsync();
}
-
- // update placementstatus
- placementProfile.Status = "DONE";
-
- await _context.SaveChangesAsync();
}
return Success();
}
@@ -851,7 +839,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
}
///
- /// ออกคำสั่ง C-PM-09
+ /// ออกคำสั่ง C-PM-09 คำสั่งบรรจุและแต่งตั้งผู้ออกไปรับราชการทหารกลับเข้ารับราชการ
///
///
///
@@ -861,62 +849,50 @@ namespace BMA.EHR.Retirement.Service.Controllers
[HttpPost("out/report/excecute")]
public async Task> PostReportExecuteOut([FromBody] ReportExecuteRequest req)
{
- // create new profile
- foreach (var recv in req.refIds)
+ var data = await _context.RetirementOthers
+ .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
+ .ToListAsync();
+ string? _null = null;
+ var resultData = (from p in data
+ join r in req.refIds
+ on p.Id.ToString() equals r.refId
+ select new
+ {
+ profileId = p.profileId,
+ date = r.commandAffectDate,
+ amount = r.amount,
+ positionSalaryAmount = r.positionSalaryAmount,
+ mouthSalaryAmount = r.mouthSalaryAmount,
+ posNo = p.PositionNumberOld,
+ position = p.PositionOld,
+ positionLine = "",
+ positionPathSide = "",
+ positionExecutive = "",
+ positionType = p.PositionTypeOld,
+ positionLevel = p.PositionLevelOld,
+ refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
+ templateDoc = r.templateDoc,
+ isLeave = false,
+ leaveReason = _null,
+ dateLeave = _null,
+ }).ToList();
+
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
+ using (var client = new HttpClient())
{
- var placementProfile = await _context.RetirementOthers
- .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId));
-
- if (placementProfile == null)
- throw new Exception(GlobalMessages.DataNotFound);
- var baseAPI = _configuration["API"];
- var apiUrlSalary = $"{baseAPI}/org/profile/salary";
- using (var client = new HttpClient())
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
- var _res = await client.PostAsJsonAsync(apiUrlSalary, new
- {
- profileId = placementProfile.profileId,
- date = recv.commandAffectDate,
- amount = recv.amount,
- positionSalaryAmount = recv.positionSalaryAmount,
- mouthSalaryAmount = recv.mouthSalaryAmount,
- posNo = placementProfile.PositionNumberOld,
- position = placementProfile.PositionOld,
- positionLine = "",
- positionPathSide = "",
- positionExecutive = "",
- positionType = placementProfile.PositionTypeOld,
- positionLevel = placementProfile.PositionLevelOld,
- refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
- templateDoc = recv.templateDoc,
- });
- var _result = await _res.Content.ReadAsStringAsync();
- }
-
- var baseAPILeave = _configuration["API"];
- var apiUrlLeave = $"{baseAPI}/org/profile/leave/{placementProfile.profileId}";
- using (var client = new HttpClient())
+ data = resultData,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ if (_res.IsSuccessStatusCode)
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlLeave);
- string? _null = null;
- var _res = await client.PostAsJsonAsync(apiUrlLeave, new
- {
- isLeave = false,
- leaveReason = _null,
- dateLeave = _null,
- });
- var _result = await _res.Content.ReadAsStringAsync();
+ data.ForEach(profile => profile.Status = "DONE");
+ await _context.SaveChangesAsync();
}
-
- // update placementstatus
- placementProfile.Status = "DONE";
-
- await _context.SaveChangesAsync();
}
return Success();
}
diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs
index 979de96d..d059ad26 100644
--- a/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs
+++ b/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs
@@ -487,7 +487,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
}
///
- /// ออกคำสั่ง C-PM-18
+ /// ออกคำสั่ง C-PM-18 คำสั่งให้ออกจากราชการ
///
///
///
@@ -497,62 +497,49 @@ namespace BMA.EHR.Retirement.Service.Controllers
[HttpPost("command/report/excecute")]
public async Task> PostReportExecuteLeave([FromBody] ReportExecuteRequest req)
{
- // create new profile
- foreach (var recv in req.refIds)
+ var data = await _context.RetirementOuts
+ .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
+ .ToListAsync();
+ var resultData = (from p in data
+ join r in req.refIds
+ on p.Id.ToString() equals r.refId
+ select new
+ {
+ profileId = p.profileId,
+ date = r.commandAffectDate,
+ amount = r.amount,
+ positionSalaryAmount = r.positionSalaryAmount,
+ mouthSalaryAmount = r.mouthSalaryAmount,
+ posNo = p.PositionNumberOld,
+ position = p.PositionOld,
+ positionLine = "",
+ positionPathSide = "",
+ positionExecutive = "",
+ positionType = p.PositionTypeOld,
+ positionLevel = p.PositionLevelOld,
+ refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
+ templateDoc = r.templateDoc,
+ isLeave = true,
+ leaveReason = "ให้ออกจากราชการ",
+ dateLeave = r.commandAffectDate,
+ }).ToList();
+
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
+ using (var client = new HttpClient())
{
- var data = await _context.RetirementOuts
- .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId));
-
- if (data == null)
- throw new Exception(GlobalMessages.DataNotFound);
-
- var baseAPI = _configuration["API"];
- var apiUrl = $"{baseAPI}/org/profile/leave/{data.profileId}";
-
- using (var client = new HttpClient())
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
- var _res = await client.PostAsJsonAsync(apiUrl, new
- {
- isLeave = true,
- leaveReason = "ให้ออกจากราชการ",
- dateLeave = recv.commandAffectDate,
- });
- var _result = await _res.Content.ReadAsStringAsync();
- }
-
- var apiUrlSalary = $"{baseAPI}/org/profile/salary";
- using (var client = new HttpClient())
+ data = resultData,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ if (_res.IsSuccessStatusCode)
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
- var _res = await client.PostAsJsonAsync(apiUrlSalary, new
- {
- profileId = data.profileId,
- date = recv.commandAffectDate,
- amount = recv.amount,
- positionSalaryAmount = recv.positionSalaryAmount,
- mouthSalaryAmount = recv.mouthSalaryAmount,
- posNo = data.PositionNumberOld,
- position = data.PositionOld,
- positionLine = "",
- positionPathSide = "",
- positionExecutive = "",
- positionType = data.PositionTypeOld,
- positionLevel = data.PositionLevelOld,
- refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
- templateDoc = recv.templateDoc,
- });
- var _result = await _res.Content.ReadAsStringAsync();
+ data.ForEach(profile => profile.Status = "DONE");
+ await _context.SaveChangesAsync();
}
-
- // update placementstatus
- data.Status = "DONE";
-
- await _context.SaveChangesAsync();
}
return Success();
}
diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs
index 0873422a..277025a4 100644
--- a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs
+++ b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs
@@ -1695,7 +1695,7 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda
}
///
- /// ออกคำสั่ง C-PM-17
+ /// ออกคำสั่ง C-PM-17 คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ
///
///
///
@@ -1705,62 +1705,49 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda
[HttpPost("command/report/excecute")]
public async Task> PostReportExecute([FromBody] ReportExecuteRequest req)
{
- // create new profile
- foreach (var recv in req.refIds)
+ var data = await _context.RetirementResigns
+ .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
+ .ToListAsync();
+ var resultData = (from p in data
+ join r in req.refIds
+ on p.Id.ToString() equals r.refId
+ select new
+ {
+ profileId = p.profileId,
+ date = r.commandAffectDate,
+ amount = r.amount,
+ positionSalaryAmount = r.positionSalaryAmount,
+ mouthSalaryAmount = r.mouthSalaryAmount,
+ posNo = p.PositionNumberOld,
+ position = p.PositionOld,
+ positionLine = "",
+ positionPathSide = "",
+ positionExecutive = "",
+ positionType = p.PositionTypeOld,
+ positionLevel = p.PositionLevelOld,
+ refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
+ templateDoc = r.templateDoc,
+ isLeave = true,
+ leaveReason = "ลาออกจากราชการ",
+ dateLeave = r.commandAffectDate,
+ }).ToList();
+
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
+ using (var client = new HttpClient())
{
- var data = await _context.RetirementResigns
- .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId));
-
- if (data == null)
- throw new Exception(GlobalMessages.DataNotFound);
-
- var baseAPI = _configuration["API"];
- var apiUrl = $"{baseAPI}/org/profile/leave/{data.profileId}";
-
- using (var client = new HttpClient())
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
- var _res = await client.PostAsJsonAsync(apiUrl, new
- {
- isLeave = true,
- leaveReason = "ลาออกจากราชการ",
- dateLeave = recv.commandAffectDate,
- });
- var _result = await _res.Content.ReadAsStringAsync();
- }
-
- var apiUrlSalary = $"{baseAPI}/org/profile/salary";
- using (var client = new HttpClient())
+ data = resultData,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ if (_res.IsSuccessStatusCode)
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
- var _res = await client.PostAsJsonAsync(apiUrlSalary, new
- {
- profileId = data.profileId,
- date = recv.commandAffectDate,
- amount = recv.amount,
- positionSalaryAmount = recv.positionSalaryAmount,
- mouthSalaryAmount = recv.mouthSalaryAmount,
- posNo = data.PositionNumberOld,
- position = data.PositionOld,
- positionLine = "",
- positionPathSide = "",
- positionExecutive = "",
- positionType = data.PositionTypeOld,
- positionLevel = data.PositionLevelOld,
- refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
- templateDoc = recv.templateDoc,
- });
- var _result = await _res.Content.ReadAsStringAsync();
+ data.ForEach(profile => profile.Status = "DONE");
+ await _context.SaveChangesAsync();
}
-
- // update placementstatus
- data.Status = "DONE";
-
- await _context.SaveChangesAsync();
}
return Success();
}
@@ -1833,7 +1820,7 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda
}
///
- /// ออกคำสั่ง C-PM-23
+ /// ออกคำสั่ง C-PM-23 คำสั่งให้ลูกจ้างออกจากราชการ
///
///
///
@@ -1843,36 +1830,46 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda
[HttpPost("employee/report/excecute")]
public async Task> PostReportExecuteEmployee([FromBody] ReportExecuteRequest req)
{
- // create new profile
- foreach (var recv in req.refIds)
+ var data = await _context.RetirementResigns
+ .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
+ .ToListAsync();
+ var resultData = (from p in data
+ join r in req.refIds
+ on p.Id.ToString() equals r.refId
+ select new
+ {
+ profileId = p.profileId,
+ date = r.commandAffectDate,
+ amount = r.amount,
+ positionSalaryAmount = r.positionSalaryAmount,
+ mouthSalaryAmount = r.mouthSalaryAmount,
+ posNo = p.PositionNumberOld,
+ position = p.PositionOld,
+ positionType = p.PositionTypeOld,
+ positionLevel = p.PositionLevelOld,
+ refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
+ templateDoc = r.templateDoc,
+ isLeave = true,
+ leaveReason = "ลาออกจากราชการ",
+ dateLeave = r.commandAffectDate,
+ }).ToList();
+
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-employee-leave";
+ using (var client = new HttpClient())
{
- var data = await _context.RetirementResigns
- .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId));
-
- if (data == null)
- throw new Exception(GlobalMessages.DataNotFound);
-
- var baseAPI = _configuration["API"];
- var apiUrl = $"{baseAPI}/org/profile-employee/salary/{data.profileId}";
-
- using (var client = new HttpClient())
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Put, apiUrl);
- var _res = await client.PutAsJsonAsync(apiUrl, new
- {
- isLeave = true,
- leaveReason = "ลาออกจากราชการ",
- dateLeave = recv.commandAffectDate,
- });
- var _result = await _res.Content.ReadAsStringAsync();
+ data = resultData,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ if (_res.IsSuccessStatusCode)
+ {
+ data.ForEach(profile => profile.Status = "DONE");
+ await _context.SaveChangesAsync();
}
-
- // update placementstatus
- data.Status = "DONE";
-
- await _context.SaveChangesAsync();
}
return Success();
}
@@ -1945,7 +1942,7 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda
}
///
- /// ออกคำสั่ง C-PM-41
+ /// ออกคำสั่ง C-PM-41 คำสั่งยกเลิกการลาออก
///
///
///
@@ -1955,63 +1952,50 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda
[HttpPost("leave-cancel/report/excecute")]
public async Task> PostReportExecuteLeaveCancel([FromBody] ReportExecuteRequest req)
{
- // create new profile
- foreach (var recv in req.refIds)
+ var data = await _context.RetirementResigns
+ .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
+ .ToListAsync();
+ string? _null = null;
+ var resultData = (from p in data
+ join r in req.refIds
+ on p.Id.ToString() equals r.refId
+ select new
+ {
+ profileId = p.profileId,
+ date = r.commandAffectDate,
+ amount = r.amount,
+ positionSalaryAmount = r.positionSalaryAmount,
+ mouthSalaryAmount = r.mouthSalaryAmount,
+ posNo = p.PositionNumberOld,
+ position = p.PositionOld,
+ positionLine = "",
+ positionPathSide = "",
+ positionExecutive = "",
+ positionType = p.PositionTypeOld,
+ positionLevel = p.PositionLevelOld,
+ refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
+ templateDoc = r.templateDoc,
+ isLeave = false,
+ leaveReason = _null,
+ dateLeave = _null,
+ }).ToList();
+
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
+ using (var client = new HttpClient())
{
- var data = await _context.RetirementResigns
- .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId));
-
- if (data == null)
- throw new Exception(GlobalMessages.DataNotFound);
-
- var baseAPI = _configuration["API"];
- var apiUrl = $"{baseAPI}/org/profile/leave/{data.profileId}";
-
- using (var client = new HttpClient())
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
- string? _null = null;
- var _res = await client.PostAsJsonAsync(apiUrl, new
- {
- isLeave = false,
- leaveReason = _null,
- dateLeave = _null,
- });
- var _result = await _res.Content.ReadAsStringAsync();
- }
-
- var apiUrlSalary = $"{baseAPI}/org/profile/salary";
- using (var client = new HttpClient())
+ data = resultData,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ if (_res.IsSuccessStatusCode)
{
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
- client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
- var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
- var _res = await client.PostAsJsonAsync(apiUrlSalary, new
- {
- profileId = data.profileId,
- date = recv.commandAffectDate,
- amount = recv.amount,
- positionSalaryAmount = recv.positionSalaryAmount,
- mouthSalaryAmount = recv.mouthSalaryAmount,
- posNo = data.PositionNumberOld,
- position = data.PositionOld,
- positionLine = "",
- positionPathSide = "",
- positionExecutive = "",
- positionType = data.PositionTypeOld,
- positionLevel = data.PositionLevelOld,
- refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
- templateDoc = recv.templateDoc,
- });
- var _result = await _res.Content.ReadAsStringAsync();
+ data.ForEach(profile => profile.Status = "DONEREJECT");
+ await _context.SaveChangesAsync();
}
-
- // update placementstatus
- data.Status = "DONEREJECT";
-
- await _context.SaveChangesAsync();
}
return Success();
}