ออกคำสั่ง
This commit is contained in:
parent
139969b324
commit
1374757bf2
8 changed files with 560 additions and 3 deletions
|
|
@ -766,5 +766,76 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
}
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ออกคำสั่ง C-PM-18
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("leave/report/excecute")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportExecuteLeave([FromBody] ReportExecuteRequest req)
|
||||
{
|
||||
// create new profile
|
||||
foreach (var recv in req.refIds)
|
||||
{
|
||||
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 _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())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
|
||||
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
|
||||
{
|
||||
profileId = data.profileId,
|
||||
date = recv.commandAffectDate,
|
||||
amount = recv.amount,
|
||||
positionSalaryAmount = recv.positionSalaryAmount,
|
||||
mouthSalaryAmount = recv.mouthSalaryAmount,
|
||||
posNo = data.PositionNumberOld,
|
||||
position = data.PositionOld,
|
||||
positionLine = "",
|
||||
positionPathSide = "",
|
||||
positionExecutive = "",
|
||||
positionType = data.PositionTypeOld,
|
||||
positionLevel = data.PositionLevelOld,
|
||||
refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
|
||||
templateDoc = recv.templateDoc,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
}
|
||||
|
||||
// update placementstatus
|
||||
data.Status = "DONE";
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
return Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue