ออกคำสั่ง

This commit is contained in:
kittapath 2024-10-04 22:43:49 +07:00
parent a8bd7e3dab
commit 61b6f77d85
2 changed files with 2 additions and 504 deletions

View file

@ -6575,507 +6575,5 @@ namespace BMA.EHR.Command.Service.Controllers
}
#endregion
/// <summary>
/// ส่งรายชื่อออกคำสั่ง C-PM-11
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("command11/report")]
public async Task<ActionResult<ResponseObject>> PostReportCommand11([FromBody] ReportPersonRequest req_)
{
try
{
var resultData = new List<CommandReceiver>();
var baseAPI = _configuration["Node:API"];
var apiUrl = $"{baseAPI}/report/pass";
var response = new PassProbationResponse();
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
response = JsonConvert.DeserializeObject<PassProbationResponse>(result);
var seq = 1;
foreach (var d in response!.data)
{
var _baseAPI = _configuration["API"];
var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.person.id}";
using (var _client = new HttpClient())
{
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
_client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
var _res = await _client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
if (org == null || org.result == null)
continue;
var receiver = new CommandReceiver
{
Sequence = seq,
CitizenId = org.result.citizenId == null ? "" : org.result.citizenId,
Prefix = org.result.prefix == null ? "" : org.result.prefix,
FirstName = org.result.firstName == null ? "" : org.result.firstName,
LastName = org.result.lastName == null ? "" : org.result.lastName,
RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId),
};
seq++;
resultData.Add(receiver);
}
}
}
return Success();
}
catch
{
throw;
}
}
/// <summary>
/// ออกคำสั่ง C-PM-11 คำสั่งให้ข้าราชการที่มีผลการทดลองปฏิบัติหน้าที่ราชการไม่ต่ำกว่ามาตรฐานที่กำหนดรับราชการต่อไป
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("command11/report/excecute")]
public async Task<ActionResult<ResponseObject>> PostReportCommand11Execute([FromBody] ReportExecuteRequest req)
{
// create new profile
foreach (var recv in req.refIds)
{
var baseAPI = _configuration["API"];
var apiUrl = $"{baseAPI}/org/profile/command11/{recv.refId}";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
profileId = recv.refId,
date = recv.commandAffectDate,
refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
salaryRef = recv.templateDoc,
});
var _result = await _res.Content.ReadAsStringAsync();
}
}
return Success();
}
/// <summary>
/// ส่งรายชื่อออกคำสั่ง C-PM-12
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("command12/report")]
public async Task<ActionResult<ResponseObject>> PostReportCommand12([FromBody] ReportPersonRequest req_)
{
try
{
var resultData = new List<CommandReceiver>();
var baseAPI = _configuration["Node:API"];
var apiUrl = $"{baseAPI}/report/not-pass";
var response = new PassProbationResponse();
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
response = JsonConvert.DeserializeObject<PassProbationResponse>(result);
var seq = 1;
foreach (var d in response!.data)
{
var _baseAPI = _configuration["API"];
var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.person.id}";
using (var _client = new HttpClient())
{
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
_client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
var _res = await _client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
if (org == null || org.result == null)
continue;
var receiver = new CommandReceiver
{
Sequence = seq,
CitizenId = org.result.citizenId == null ? "" : org.result.citizenId,
Prefix = org.result.prefix == null ? "" : org.result.prefix,
FirstName = org.result.firstName == null ? "" : org.result.firstName,
LastName = org.result.lastName == null ? "" : org.result.lastName,
RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId),
};
seq++;
resultData.Add(receiver);
}
}
}
return Success();
}
catch
{
throw;
}
}
/// <summary>
/// ออกคำสั่ง C-PM-12 คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("command12/report/excecute")]
public async Task<ActionResult<ResponseObject>> PostReportCommand12Execute([FromBody] ReportExecuteRequest req)
{
// create new profile
foreach (var recv in req.refIds)
{
var baseAPI = _configuration["API"];
var apiUrl = $"{baseAPI}/org/profile/command12/{recv.refId}";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
profileId = recv.refId,
date = recv.commandAffectDate,
refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
salaryRef = recv.templateDoc,
});
var _result = await _res.Content.ReadAsStringAsync();
}
}
return Success();
}
/// <summary>
/// ส่งรายชื่อออกคำสั่ง C-PM-21
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("command21/report")]
public async Task<ActionResult<ResponseObject>> PostReportcommand21([FromBody] ReportPersonRequest req_)
{
try
{
var resultData = new List<CommandReceiver>();
var baseAPI = _configuration["API"];
var apiUrl = $"{baseAPI}/org/profile-employee/report-temp";
var response = new PassSalaryResponse();
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
response = JsonConvert.DeserializeObject<PassSalaryResponse>(result);
var seq = 1;
foreach (var d in response!.result)
{
var receiver = new CommandReceiver
{
Sequence = seq,
CitizenId = d.citizenId,
Prefix = d.prefix == null ? "" : d.prefix,
FirstName = d.firstName == null ? "" : d.firstName,
LastName = d.lastName == null ? "" : d.lastName,
RefPlacementProfileId = d.id,
RefDisciplineId = d.id,
Organization = d.organization,
PositionName = d.positionName,
PositionLevel = d.positionLevel,
PositionType = d.positionType,
PositionNumber = d.positionNumber,
BirthDate = d.birthDate,
};
seq++;
resultData.Add(receiver);
}
}
return Success();
}
catch
{
throw;
}
}
/// <summary>
/// ออกคำสั่ง C-PM-21 คำสั่งแต่งตั้งลูกจ้างชั่วคราวเป็นลูกจ้างประจำ
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("command21/report/excecute")]
public async Task<ActionResult<ResponseObject>> PostReportCommand21Execute([FromBody] ReportExecuteRequest req)
{
var data = req.refIds.Select(x => new
{
id = x.refId,
amount = x.amount,
positionSalaryAmount = x.positionSalaryAmount,
mouthSalaryAmount = x.mouthSalaryAmount,
refCommandNo = $"{x.commandNo}/{x.commandYear.ToThaiYear()}",
templateDoc = x.templateDoc,
});
var baseAPI = _configuration["API"];
var apiUrl = $"{baseAPI}/org/profile-employee/report/resume";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
}
return Success();
}
/// <summary>
/// ส่งรายชื่อออกคำสั่ง C-PM-38
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("command38/report")]
public async Task<ActionResult<ResponseObject>> PostReportCommand38([FromBody] ReportPersonRequest req)
{
try
{
// var resultData = new List<CommandReceiver>();
// var baseAPI = _configuration["API"];
// foreach (var id in req.refIds)
// {
// var apiUrl = $"{baseAPI}/salary/report/command/38/{id}";
// var response = new PassSalaryResponse();
// using (var client = new HttpClient())
// {
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
// client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
// var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
// var res = await client.SendAsync(_req);
// // var result = await res.Content.ReadAsStringAsync();
// // response = JsonConvert.DeserializeObject<PassSalaryResponse>(result);
// // var seq = 1;
// // foreach (var d in response!.result)
// // {
// // var receiver = new CommandReceiver
// // {
// // Sequence = seq,
// // CitizenId = d.citizenId,
// // Prefix = d.prefix == null ? "" : d.prefix,
// // FirstName = d.firstName,
// // LastName = d.lastName,
// // RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId),
// // RefDisciplineId = d.id,
// // };
// // seq++;
// // resultData.Add(receiver);
// // }
// }
// }
return Success();
}
catch
{
throw;
}
}
/// <summary>
/// ออกคำสั่ง C-PM-38 แต่งตั้งข้าราชการให้ดำรงตำแหน่ง
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("command38/report/excecute")]
public async Task<ActionResult<ResponseObject>> PostReportCommand38Execute([FromBody] ReportExecuteRequest req)
{
return Success();
}
/// <summary>
/// ส่งรายชื่อออกคำสั่ง C-PM-40
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("command40/report")]
public async Task<ActionResult<ResponseObject>> PostReportCommand40([FromBody] ReportPersonRequest req)
{
try
{
// var resultData = new List<CommandReceiver>();
// var baseAPI = _configuration["API"];
// var apiUrl = $"{baseAPI}/org/pos/act/profile";
// var response = new PassSalaryResponse();
// using (var client = new HttpClient())
// {
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
// client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
// var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
// var res = await client.SendAsync(_req);
// // var result = await res.Content.ReadAsStringAsync();
// // response = JsonConvert.DeserializeObject<PassSalaryResponse>(result);
// // var seq = 1;
// // foreach (var d in response!.result)
// // {
// // var receiver = new CommandReceiver
// // {
// // Sequence = seq,
// // CitizenId = d.citizenId,
// // Prefix = d.prefix == null ? "" : d.prefix,
// // FirstName = d.firstName,
// // LastName = d.lastName,
// // RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId),
// // RefDisciplineId = d.id,
// // };
// // seq++;
// // resultData.Add(receiver);
// // }
// }
return Success();
}
catch
{
throw;
}
}
/// <summary>
/// เอกสารแนบท้าย C-PM-40
/// </summary>
/// <param name="id">Record Id ของคำสั่ง</param>
/// <param name="exportType">pdf, docx หรือ xlsx</param>
/// <returns></returns>
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("command40/report/attachment")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> PostReportCommand40Attachment([FromBody] ReportAttachmentRequest req)
{
try
{
var data = new List<CommandType40Response>();
var no = 1;
foreach (var d in req.refIds)
{
var apiUrl = $"{_configuration["API"]}/org/pos/act/{d.refId}";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
var org = JsonConvert.DeserializeObject<dynamic>(_result);
if (org == null || org.result == null)
continue;
var receiver = new CommandType40Response
{
no = no.ToString().ToThaiNumber(),
fullName = $"{org.result.prefix}{org.result.firstName} {org.result.lastName}",
organization = org.result.organization,
position = org.result.position,
postype = org.result.postype,
poslevel = org.result.poslevel,
organizationNew = org.result.organizationNew,
// dateStart = d.Command.ActStartDate == null ? "-" : d.Command.ActStartDate.Value.ToThaiFullDate3().ToThaiNumber(),
// dateEnd = d.Command.ActEndDate == null ? "-" : d.Command.ActEndDate.Value.ToThaiFullDate3().ToThaiNumber(),
dateStart = "xxx",
dateEnd = "xxx",
order = org.result.order,
};
no = no + 1;
data.Add(receiver);
}
}
return Success(data);
}
catch
{
throw;
}
}
/// <summary>
/// ออกคำสั่ง C-PM-40 คำสั่งให้ข้าราชการรักษาการในตำแหน่ง
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("command40/report/excecute")]
public async Task<ActionResult<ResponseObject>> PostReportCommand40Execute([FromBody] ReportExecuteRequest req)
{
return Success();
}
}
}