diff --git a/.gitignore b/.gitignore
index 7391825f..f60d8ec1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -373,4 +373,10 @@ MigrationBackup/
.ionide/
# Fody - auto-generated XML schema
-FodyWeavers.xsd
\ No newline at end of file
+FodyWeavers.xsd
+
+# VS Code C# Dev Kit cache
+*.lscache
+
+# Claude Code
+.claude/
\ No newline at end of file
diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs
index 2dd451ab..03871f9f 100644
--- a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs
+++ b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs
@@ -2975,6 +2975,194 @@ namespace BMA.EHR.Retirement.Service.Controllers
return Success();
}
+ ///
+ /// ส่งรายชื่อออกคำสั่ง C-PM-48
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost("command48/report")]
+ public async Task> 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();
+ }
+ ///
+ /// ลบรายชื่อออกคำสั่ง C-PM-48
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost("command48/report/delete")]
+ public async Task> 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();
+ }
+
+ ///
+ /// เอกสารแนบท้าย C-PM-48
+ ///
+ /// Record Id ของคำสั่ง
+ /// pdf, docx หรือ xlsx
+ ///
+ /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost("command48/report/attachment")]
+ [AllowAnonymous]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status401Unauthorized)]
+ [ProducesResponseType(StatusCodes.Status500InternalServerError)]
+ public async Task> 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();
+
+ 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;
+ }
+ }
+
+ ///
+ /// ออกคำสั่ง C-PM-48 คำสั่งอนุญาตให้ลาออกไปรับราชการทหาร
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost("command48/report/excecute")]
+ public async Task> 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();
+ }
+
///
/// ส่งรายชื่อออกคำสั่ง C-PM-41
///