diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementController.cs
index 4336ee79..2927a3da 100644
--- a/BMA.EHR.Retirement.Service/Controllers/RetirementController.cs
+++ b/BMA.EHR.Retirement.Service/Controllers/RetirementController.cs
@@ -1,5 +1,6 @@
using BMA.EHR.Application.Repositories;
using BMA.EHR.Application.Repositories.MessageQueue;
+using BMA.EHR.Application.Repositories.Reports;
using BMA.EHR.Domain.Common;
using BMA.EHR.Domain.Extensions;
using BMA.EHR.Domain.Models.Retirement;
@@ -35,15 +36,17 @@ namespace BMA.EHR.Retirement.Service.Controllers
private readonly IConfiguration _configuration;
private readonly PermissionRepository _permission;
private readonly DisciplineDbContext _contextDiscipline;
+ private readonly RetireReportRepository _service;
public RetirementController(RetirementRepository repository,
NotificationRepository repositoryNoti,
ApplicationDBContext context,
MinIOService documentService,
IConfiguration configuration,
- OrganizationCommonRepository organizationCommonRepository,
+ OrganizationCommonRepository organizationCommonRepository,
IHttpContextAccessor httpContextAccessor,
PermissionRepository permission,
- DisciplineDbContext contextDiscipline)
+ DisciplineDbContext contextDiscipline,
+ RetireReportRepository service)
{
_repository = repository;
_repositoryNoti = repositoryNoti;
@@ -54,6 +57,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
_configuration = configuration;
_permission = permission;
_contextDiscipline = contextDiscipline;
+ _service = service;
}
#region " Properties "
@@ -991,7 +995,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
};
var dataRaw = new RetirementRawProfile
{
- Order = profileRawCount+1,
+ Order = profileRawCount + 1,
Remove = "ADD",
RetirementPeriod = retire,
CreatedFullName = FullName ?? "System Administrator",
@@ -1042,7 +1046,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
data.posExecutiveId = org.result.posExecutiveId;
data.posExecutiveName = org.result.posExecutiveName;
data.posNo = org.result.posNo;
-
+
dataRaw.profileId = org.result.profileId;
dataRaw.prefix = org.result.prefix;
dataRaw.firstName = org.result.firstName;
@@ -1104,7 +1108,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
};
var dataRaw = new RetirementRawProfile
{
- Order = profileRawCount+1,
+ Order = profileRawCount + 1,
Remove = "ADD",
RetirementPeriod = retire,
CreatedFullName = FullName ?? "System Administrator",
@@ -2021,12 +2025,88 @@ namespace BMA.EHR.Retirement.Service.Controllers
return Error("ไม่พบรอบประกาศเกษียณอายุราชการ");
var data = retirePeriodOfficer.RetirementRawProfiles
- .Select(x => new {
+ .Select(x => new
+ {
profileId = x.profileId
})
.ToList();
return Success(data);
}
+
+ #region 31-ประกาศเกษียณข้าราชการ & 32-ประกาศเกษียณลูกจ้างประจำ
+ ///
+ /// 31-ประกาศเกษียณข้าราชการ & 32-ประกาศเกษียณลูกจ้างประจำ
+ ///
+ /// Id ของรอบเกษียณ
+ /// pdf, docx หรือ xlsx
+ ///
+ /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpGet("31/{exportType}/{Id}")]
+ public async Task> GetProfileRetirement([FromRoute] Guid Id, string exportType = "pdf")
+ {
+ var retire = await _service.GetProfileRetirementdAsync(Id);
+ if (retire != null)
+ {
+ var reportfile = string.Empty;
+ exportType = exportType.Trim();
+ switch (retire.GetType().GetProperty("Type").GetValue(retire))
+ {
+ case "OFFICER":
+ if (string.IsNullOrEmpty(retire.GetType().GetProperty("TypeReport").GetValue(retire)))
+ {
+ reportfile = $"retire-1";
+ }
+ else if (retire.GetType().GetProperty("TypeReport").GetValue(retire) == "ADD" || retire.GetType().GetProperty("TypeReport").GetValue(retire) == "EDIT")
+ {
+ reportfile = $"retire-2";
+ }
+ else if (retire.GetType().GetProperty("TypeReport").GetValue(retire) == "REMOVE")
+ {
+ reportfile = $"retire-3";
+ }
+ else
+ {
+ return Error(retire.GetType().GetProperty("TypeReport").GetValue(retire));
+ }
+ break;
+ case "EMPLOYEE":
+ if (string.IsNullOrEmpty(retire.GetType().GetProperty("TypeReport").GetValue(retire)))
+ {
+ reportfile = $"retire-emp-1";
+ }
+ else if (retire.GetType().GetProperty("TypeReport").GetValue(retire) == "ADD" || retire.GetType().GetProperty("TypeReport").GetValue(retire) == "EDIT")
+ {
+ reportfile = $"retire-emp-2";
+ }
+ else if (retire.GetType().GetProperty("TypeReport").GetValue(retire) == "REMOVE")
+ {
+ reportfile = $"retire-emp-3";
+ }
+ else
+ {
+ return Error(retire.GetType().GetProperty("TypeReport").GetValue(retire));
+ }
+ break;
+ default:
+ return Error(retire.GetType().GetProperty("Type").GetValue(retire));
+ }
+
+ var data = new
+ {
+ template = reportfile,
+ reportName = "docx-report",
+ data = retire
+ };
+ return Success(data);
+ }
+ else
+ {
+ return NotFound();
+ }
+ }
+ #endregion
}
}
diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs
index 10a83322..5216110c 100644
--- a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs
+++ b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs
@@ -1,5 +1,7 @@
using BMA.EHR.Application.Repositories;
using BMA.EHR.Application.Repositories.MessageQueue;
+using BMA.EHR.Application.Repositories.Reports;
+using BMA.EHR.Application.Repositories.Reports;
using BMA.EHR.Domain.Common;
using BMA.EHR.Domain.Extensions;
using BMA.EHR.Domain.Models.Retirement;
@@ -32,6 +34,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IConfiguration _configuration;
private readonly PermissionRepository _permission;
+ private readonly RetireReportRepository _service;
public RetirementResignController(RetirementRepository repository,
NotificationRepository repositoryNoti,
@@ -39,7 +42,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
MinIOService documentService,
IHttpContextAccessor httpContextAccessor,
IConfiguration configuration,
- PermissionRepository permission)
+ PermissionRepository permission,
+ RetireReportRepository service)
{
_repository = repository;
_repositoryNoti = repositoryNoti;
@@ -48,6 +52,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
_httpContextAccessor = httpContextAccessor;
_configuration = configuration;
_permission = permission;
+ _service = service;
}
#region " Properties "
@@ -2642,5 +2647,46 @@ namespace BMA.EHR.Retirement.Service.Controllers
}
return Success();
}
+
+ #region 33-แบบฟอร์มหนังสือขอลาออกจากราชการ
+ ///
+ /// 33-แบบฟอร์มหนังสือขอลาออกจากราชการ
+ ///
+ /// id
+ /// pdf, docx หรือ xlsx
+ ///
+ /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpGet("33/{exportType}/{id}")]
+ public async Task> GetResign33ConvertReportAsync(Guid id, string exportType = "pdf")
+ {
+ try
+ {
+ var resign = await _service.GetResignByUser(id);
+ if (resign == null)
+ return NotFound();
+
+ var mimeType = "";
+ switch (exportType.Trim().ToLower())
+ {
+ case "pdf": mimeType = "application/pdf"; break;
+ case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break;
+ case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
+ }
+ var data = new
+ {
+ template = "resign",
+ reportName = "docx-report",
+ data = resign
+ };
+ return Success(data);
+ }
+ catch
+ {
+ throw;
+ }
+ }
+ #endregion
}
}