api คำสั่งอนุญาตให้ลาออกไปรับราชการทหาร #248
All checks were successful
Build & Deploy Retirement Service / build (push) Successful in 3m4s
All checks were successful
Build & Deploy Retirement Service / build (push) Successful in 3m4s
This commit is contained in:
parent
d75cf39d7b
commit
7d2be029b6
2 changed files with 195 additions and 1 deletions
8
.gitignore
vendored
8
.gitignore
vendored
|
|
@ -373,4 +373,10 @@ MigrationBackup/
|
||||||
.ionide/
|
.ionide/
|
||||||
|
|
||||||
# Fody - auto-generated XML schema
|
# Fody - auto-generated XML schema
|
||||||
FodyWeavers.xsd
|
FodyWeavers.xsd
|
||||||
|
|
||||||
|
# VS Code C# Dev Kit cache
|
||||||
|
*.lscache
|
||||||
|
|
||||||
|
# Claude Code
|
||||||
|
.claude/
|
||||||
|
|
@ -2975,6 +2975,194 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
return Success();
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ส่งรายชื่อออกคำสั่ง C-PM-48
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpPost("command48/report")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> PostReport48([FromBody] ReportPersonRequest req)
|
||||||
|
{
|
||||||
|
var resigns = await _context.RetirementResigns
|
||||||
|
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||||
|
.ToListAsync();
|
||||||
|
resigns.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// ลบรายชื่อออกคำสั่ง C-PM-48
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpPost("command48/report/delete")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> PostReportDelete48([FromBody] ReportPersonRequest req)
|
||||||
|
{
|
||||||
|
var resigns = await _context.RetirementResigns
|
||||||
|
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||||
|
.Where(x => x.Status.ToUpper() == "REPORT")
|
||||||
|
.ToListAsync();
|
||||||
|
resigns.ForEach(profile => profile.Status = "APPROVE");
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// เอกสารแนบท้าย C-PM-48
|
||||||
|
/// </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("command48/report/attachment")]
|
||||||
|
[AllowAnonymous]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> PostReportAttachment48([FromBody] ReportAttachmentRequest req)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var report_data = (from p in _context.RetirementResigns
|
||||||
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||||
|
.ToList()
|
||||||
|
join r in req.refIds
|
||||||
|
on p.Id.ToString() equals r.refId
|
||||||
|
orderby r.Sequence
|
||||||
|
select new
|
||||||
|
{
|
||||||
|
No = r.Sequence.ToString().ToThaiNumber(),
|
||||||
|
CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(),
|
||||||
|
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
||||||
|
PositionName = p.PositionOld ?? "-",
|
||||||
|
Organization = p.OrganizationPositionOld ?? "-",
|
||||||
|
PositionLevel = p.PositionLevelOld ?? "-",
|
||||||
|
PositionType = p.PositionTypeOld ?? "-",
|
||||||
|
PositionNumber = p.PositionNumberOld == null ? "-" : p.PositionNumberOld.ToThaiNumber(),
|
||||||
|
ActiveDate = p.ActiveDate == null ? "-" : p.ActiveDate.Value.ToThaiShortDate2().ToThaiNumber(),
|
||||||
|
Salary = p.AmountOld == null ? "-" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
||||||
|
Remark = p.Reason ?? "-",
|
||||||
|
RemarkHorizontal = r.RemarkHorizontal == null ? "-" : r.RemarkHorizontal.ToThaiNumber(),
|
||||||
|
RemarkVertical = r.RemarkVertical == null ? "-" : r.RemarkVertical.ToThaiNumber()
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
var result = new List<dynamic>();
|
||||||
|
|
||||||
|
foreach (var r in report_data)
|
||||||
|
{
|
||||||
|
result.Add(r);
|
||||||
|
string? _null = null;
|
||||||
|
if (r.RemarkHorizontal != null && r.RemarkHorizontal != "")
|
||||||
|
{
|
||||||
|
result.Add(new
|
||||||
|
{
|
||||||
|
No = _null,
|
||||||
|
FullName = r.RemarkHorizontal,
|
||||||
|
CitizenId = _null,
|
||||||
|
PositionName = _null,
|
||||||
|
Organization = _null,
|
||||||
|
PositionLevel = _null,
|
||||||
|
PositionType = _null,
|
||||||
|
PositionNumber = _null,
|
||||||
|
ActiveDate = _null,
|
||||||
|
Salary = _null,
|
||||||
|
Remark = _null,
|
||||||
|
RemarkHorizontal = _null,
|
||||||
|
RemarkVertical = _null,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Success(result);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ออกคำสั่ง C-PM-48 คำสั่งอนุญาตให้ลาออกไปรับราชการทหาร
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpPost("command48/report/excecute")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> PostReportExecute48([FromBody] ReportExecuteRequest req)
|
||||||
|
{
|
||||||
|
var data = await _context.RetirementResigns
|
||||||
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||||
|
.ToListAsync();
|
||||||
|
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
||||||
|
data.ForEach(profile => profile.Status = "DONE");
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
var resultData = (from p in data
|
||||||
|
join r in req.refIds
|
||||||
|
on p.Id.ToString() equals r.refId
|
||||||
|
select new
|
||||||
|
{
|
||||||
|
profileId = p.profileId,
|
||||||
|
amount = r.amount,
|
||||||
|
amountSpecial = r.amountSpecial,
|
||||||
|
positionSalaryAmount = r.positionSalaryAmount,
|
||||||
|
mouthSalaryAmount = r.mouthSalaryAmount,
|
||||||
|
positionExecutive = p.PositionExecutiveOld,
|
||||||
|
positionExecutiveField = p.positionExecutiveFieldOld,
|
||||||
|
positionArea = p.positionAreaOld,
|
||||||
|
positionType = p.PositionTypeOld,
|
||||||
|
positionLevel = p.PositionLevelOld,
|
||||||
|
isLeave = p.IsCancel == true ? false : true,
|
||||||
|
leaveReason = p.ReasonResign == "อื่น ๆ"
|
||||||
|
? string.IsNullOrWhiteSpace(p.Remark) ? p.ReasonResign : $"{p.ReasonResign}({p.Remark})"
|
||||||
|
: p.ReasonResign,
|
||||||
|
dateLeave = r.commandDateAffect,
|
||||||
|
commandId = r.commandId,
|
||||||
|
isGovernment = false,
|
||||||
|
orgRoot = p.rootOld,
|
||||||
|
orgChild1 = p.child1Old,
|
||||||
|
orgChild2 = p.child2Old,
|
||||||
|
orgChild3 = p.child3Old,
|
||||||
|
orgChild4 = p.child4Old,
|
||||||
|
commandNo = r.commandNo,
|
||||||
|
commandYear = r.commandYear,
|
||||||
|
posNo = p.posMasterNoOld?.ToString(),
|
||||||
|
posNoAbb = p.child4ShortNameOld != null ? $"{p.child4ShortNameOld}" :
|
||||||
|
p.child3ShortNameOld != null ? $"{p.child3ShortNameOld}" :
|
||||||
|
p.child2ShortNameOld != null ? $"{p.child2ShortNameOld}" :
|
||||||
|
p.child1ShortNameOld != null ? $"{p.child1ShortNameOld}" :
|
||||||
|
p.rootShortNameOld != null ? $"{p.rootShortNameOld}" : "",
|
||||||
|
commandDateAffect = r.commandDateAffect,
|
||||||
|
commandDateSign = r.commandDateSign,
|
||||||
|
positionName = p.PositionOld,
|
||||||
|
commandCode = r.commandCode,
|
||||||
|
commandName = r.commandName,
|
||||||
|
remark = r.remark,
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
var baseAPIOrg = _configuration["API"];
|
||||||
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
|
||||||
|
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,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ส่งรายชื่อออกคำสั่ง C-PM-41
|
/// ส่งรายชื่อออกคำสั่ง C-PM-41
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue