ออกคำสั่ง

This commit is contained in:
kittapath 2024-10-04 15:36:34 +07:00
parent 604b234c4b
commit 1290da7211
14 changed files with 1979 additions and 2004 deletions

View file

@ -703,7 +703,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
}
/// <summary>
/// ออกคำสั่ง C-PM-08
/// ออกคำสั่ง C-PM-08 บรรจุและแต่งตั้งข้าราชการกลับเข้ารับราชการ
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
@ -713,62 +713,50 @@ namespace BMA.EHR.Retirement.Service.Controllers
[HttpPost("appoint/report/excecute")]
public async Task<ActionResult<ResponseObject>> 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
}
/// <summary>
/// ออกคำสั่ง C-PM-09
/// ออกคำสั่ง C-PM-09 คำสั่งบรรจุและแต่งตั้งผู้ออกไปรับราชการทหารกลับเข้ารับราชการ
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
@ -861,62 +849,50 @@ namespace BMA.EHR.Retirement.Service.Controllers
[HttpPost("out/report/excecute")]
public async Task<ActionResult<ResponseObject>> 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();
}