ออกคำสั่ง

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

@ -1695,7 +1695,7 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda
}
/// <summary>
/// ออกคำสั่ง C-PM-17
/// ออกคำสั่ง C-PM-17 คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
@ -1705,62 +1705,49 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda
[HttpPost("command/report/excecute")]
public async Task<ActionResult<ResponseObject>> 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
}
/// <summary>
/// ออกคำสั่ง C-PM-23
/// ออกคำสั่ง C-PM-23 คำสั่งให้ลูกจ้างออกจากราชการ
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
@ -1843,36 +1830,46 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda
[HttpPost("employee/report/excecute")]
public async Task<ActionResult<ResponseObject>> 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
}
/// <summary>
/// ออกคำสั่ง C-PM-41
/// ออกคำสั่ง C-PM-41 คำสั่งยกเลิกการลาออก
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
@ -1955,63 +1952,50 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda
[HttpPost("leave-cancel/report/excecute")]
public async Task<ActionResult<ResponseObject>> 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();
}