Merge branch 'develop' into adiDev

This commit is contained in:
AdisakKanthawilang 2025-02-03 18:16:18 +07:00
commit 252fe0ff9a
12 changed files with 1022 additions and 111 deletions

View file

@ -27,7 +27,7 @@ namespace BMA.EHR.Application
services.AddTransient<OrganizationCommonRepository>();
services.AddTransient<InboxRepository>();
services.AddTransient<NotificationRepository>();
services.AddTransient<RetirementRepository>();
//services.AddTransient<RetirementRepository>();
services.AddTransient<RetireReportRepository>();
services.AddTransient<InsigniaReportRepository>();
services.AddTransient<CommandReportRepository>();

View file

@ -909,7 +909,7 @@ namespace BMA.EHR.Application.Repositories.Reports
var developComplete2 = evaluate_assign.result.evaluate.develop_complete == 0
? "🗹"
: "☐";
var passResult1 = evaluate_assign.result.evaluate.pass_result == 1
var passResult1 = evaluate_assign.result.evaluate.pass_result == 1 || evaluate_assign.result.evaluate.pass_result == 4
? no == 1 ? "🗹 ไม่ต่ำกว่ามาตรฐานที่กำหนดเห็นควรให้ทดลองปฏิบัติหน้าที่ราชการต่อไป" : "🗹 ไม่ต่ำกว่ามาตรฐานที่กำหนด เห็นควรให้รับราชการต่อไป"
: no == 1 ? "☐ ไม่ต่ำกว่ามาตรฐานที่กำหนดเห็นควรให้ทดลองปฏิบัติหน้าที่ราชการต่อไป" : "☐ ไม่ต่ำกว่ามาตรฐานที่กำหนด เห็นควรให้รับราชการต่อไป";
var passResult2 = evaluate_assign.result.evaluate.pass_result == 2
@ -919,7 +919,7 @@ namespace BMA.EHR.Application.Repositories.Reports
? $"🗹 เห็นควรให้ขยายเวลาทดลองปฏิบัติหน้าที่ราชการต่อไปอีก {expandMonth} เดือน"
: "☐ เห็นควรให้ขยายเวลาทดลองปฏิบัติหน้าที่ราชการต่อไปอีก.....เดือน";
var passResult = evaluate_assign.result.evaluate.pass_result == 1
var passResult = evaluate_assign.result.evaluate.pass_result == 1 || evaluate_assign.result.evaluate.pass_result == 4
? no == 1 ? "เห็นควรให้ทดลองปฏิบัติหน้าที่ราชการต่อไป" : "เห็นควรให้รับราชการต่อไป"
: evaluate_assign.result.evaluate.pass_result == 2
? "เห็นควรให้ออกจากราชการ"
@ -937,7 +937,7 @@ namespace BMA.EHR.Application.Repositories.Reports
return new
{
EvaluateDateStart = string.IsNullOrEmpty(evaluate_assign.result.evaluate.date_start.ToString()) ? "-" : evaluate_assign.result.evaluate.date_start.ToThaiFullDate().ToString().ToThaiNumber(),
EvaluateDateFinish = string.IsNullOrEmpty(evaluate_assign.result.evaluate.date_start.ToString()) ? "-" : evaluate_assign.result.evaluate.date_start.ToThaiFullDate().ToString().ToThaiNumber(),
EvaluateDateFinish = string.IsNullOrEmpty(evaluate_assign.result.evaluate.date_finish.ToString()) ? "-" : evaluate_assign.result.evaluate.date_finish.ToThaiFullDate().ToString().ToThaiNumber(),
Position = string.IsNullOrEmpty(evaluate_assign.result.experimentee.Position) ? string.Empty : evaluate_assign.result.experimentee.Position,
PositionLevel = string.IsNullOrEmpty(evaluate_assign.result.experimentee.PositionLevelName) ? "-" : evaluate_assign.result.experimentee.PositionLevelName,
Department = string.IsNullOrEmpty(evaluate_assign.result.experimentee.Department) ? string.Empty : evaluate_assign.result.experimentee.Department,
@ -949,8 +949,8 @@ namespace BMA.EHR.Application.Repositories.Reports
ChairmanPosition = string.IsNullOrEmpty(evaluate_assign.result.chairman.Position) ? string.Empty : evaluate_assign.result.chairman.Position,
ChairmanDate = string.IsNullOrEmpty(evaluate_assign.result.evaluate.chairman_dated.ToString()) ? "-" : evaluate_assign.result.evaluate?.chairman_dated?.ToThaiFullDate().ToString().ToThaiNumber(),
CommanderName = string.IsNullOrEmpty(evaluate_assign.result.commander.name) ? string.Empty : evaluate_assign.result.commander.name,
CommanderPosition = string.IsNullOrEmpty(evaluate_assign.result.commander.Position) ? string.Empty : evaluate_assign.result.commander.Position,
CommanderDate = string.IsNullOrEmpty(evaluate_assign.result.evaluate.director1_dated.ToString()) ? "-" : evaluate_assign.result.evaluate?.director1_dated?.ToThaiFullDate().ToString().ToThaiNumber(),
CommanderPosition = string.IsNullOrEmpty(evaluate_assign.result.commander.position) ? string.Empty : evaluate_assign.result.commander.position,
CommanderDate = string.IsNullOrEmpty(evaluate_assign.result.commander.dated.ToString()) ? "-" : evaluate_assign.result.commander.dated?.ToThaiFullDate().ToString().ToThaiNumber(),
Name = evaluate_assign.result.experimentee.name,
RoundNo = no.ToString().ToThaiNumber(),
DateStart = evaluate_assign.result.assign.date_start != string.Empty ? dateStart_ : "-",

View file

@ -105,42 +105,53 @@ namespace BMA.EHR.Application.Repositories
}
//เกษียณอายุราชการ
public async Task ExecuteRetirement()
//public async Task ExecuteRetirement()
//{
// var retirePeriodOfficer = await _dbContext.Set<RetirementPeriod>()
// .Include(x => x.RetirementRawProfiles.Where(y => y.Remove != "REMOVE"))
// .Where(x => x.Year == DateTime.Now.Year)
// .Where(x => x.Type.Trim().ToUpper().Contains("OFFICER"))
// .FirstOrDefaultAsync();
// if (retirePeriodOfficer == null)
// return;
// var body = new
// {
// data = retirePeriodOfficer.RetirementRawProfiles
// .Select(x => new
// {
// profileId = x.profileId
// })
// .ToList()
// };
// //ข้าราชการ
// //var apiUrl = $"{_configuration["API"]}/org/unauthorize/retirement";
// using (var client = new HttpClient())
// {
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
// client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
// var jsonBody = JsonConvert.SerializeObject(body);
// var content = new StringContent(jsonBody, Encoding.UTF8, "application/json");
// var _req = new HttpRequestMessage(HttpMethod.Patch, apiUrl)
// {
// Content = content
// };
// var response = await client.SendAsync(_req);
// var responseContent = await response.Content.ReadAsStringAsync();
// if (!response.IsSuccessStatusCode)
// {
// }
// }
//}
public void TestMethod()
{
var retirePeriodOfficer = await _dbContext.Set<RetirementPeriod>()
.Include(x => x.RetirementRawProfiles.Where(y => y.Remove != "REMOVE"))
.Where(x => x.Year == /*DateTime.Now.Year*/2026)
.Where(x => x.Type.Trim().ToUpper().Contains("OFFICER"))
.FirstOrDefaultAsync();
var body = retirePeriodOfficer.RetirementProfiles
.Select(x => new {
profileId = x.profileId,
//lastUpdateUserId = UserId,
//lastUpdateFullName = FullName,
})
.ToList();
//ข้าราชการ
//var apiUrl = $"{_configuration["API"]}/org/unauthorize/retirement";
var apiUrl = $"http://localhost:13001/api/v1/org/unauthorize/retirement";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var jsonBody = JsonConvert.SerializeObject(body);
var content = new StringContent(jsonBody, Encoding.UTF8, "application/json");
var _req = new HttpRequestMessage(HttpMethod.Patch, apiUrl)
{
Content = content
};
var response = await client.SendAsync(_req);
var responseContent = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode)
{
}
}
return;
}
}
}

View file

@ -19,15 +19,19 @@ namespace BMA.EHR.Application.Responses
public class Commander
{
public string personal_id { get; set; }
// public string personal_id { get; set; }
public string name { get; set; }
public string PositionId { get; set; }
public string PositionLevelId { get; set; }
public string PositionLineId { get; set; }
public string Position { get; set; }
public string Department { get; set; }
public string OrganizationOrganization { get; set; }
public string Oc { get; set; }
// public string PositionId { get; set; }
// public string PositionLevelId { get; set; }
// public string PositionLineId { get; set; }
public string position { get; set; }
// public string Department { get; set; }
// public string OrganizationOrganization { get; set; }
// public string Oc { get; set; }
public DateTime? dated { get; set; }
public string posLevel { get; set; }
public string posType { get; set; }
}
public class Chairman

View file

@ -18,6 +18,7 @@ using Newtonsoft.Json.Linq;
using Swashbuckle.AspNetCore.Annotations;
using System.Net.Http.Headers;
using System.Security.Claims;
using System.Security.Policy;
namespace BMA.EHR.Leave.Service.Controllers
{
@ -883,7 +884,7 @@ namespace BMA.EHR.Leave.Service.Controllers
break;
case "LV-005":
// fix issue : ระบบลา (ขรก.) >> ลาพักผ่อน (กรณีรับราชการไม่ถึง 6 เดือน) #838
var leavePrevYear = (await _leaveRequestRepository.GetSumApproveLeaveAsync(thisYear -1)).Where(x => x.LeaveTypeCode == "LV-005" && x.KeycloakUserId == userId).FirstOrDefault();
var leavePrevYear = (await _leaveRequestRepository.GetSumApproveLeaveAsync(thisYear - 1)).Where(x => x.LeaveTypeCode == "LV-005" && x.KeycloakUserId == userId).FirstOrDefault();
//var leavePrevYearRemain = 10 - (leavePrevYear == null ? 0 : leavePrevYear.SumLeaveDay); // หายอดวันลาที่เหลือของปีก่อน
if (govAge >= 180)
@ -1827,15 +1828,18 @@ namespace BMA.EHR.Leave.Service.Controllers
//var sumHoliday = await _holidayRepository.GetHolidayCountAsync(rawData.LeaveStartDate, rawData.LeaveEndDate, category);
//var sumWeekend = _holidayRepository.GetWeekEndCount(rawData.LeaveStartDate, rawData.LeaveEndDate, category);
// fix issue : ระบบการลา>>สังกัด ฝ่าย (เอา / ออก เปลี่ยนเป็นว่าง) #1131
var orgName = rawData.Root ?? "";
if (rawData.Child1 != null && rawData.Child1 != "")
orgName += $"/{rawData.Child1}";
orgName += $" {rawData.Child1}";
if (rawData.Child2 != null && rawData.Child2 != "")
orgName += $"/{rawData.Child2}";
orgName += $" {rawData.Child2}";
if (rawData.Child3 != null && rawData.Child3 != "")
orgName += $"/{rawData.Child3}";
orgName += $" {rawData.Child3}";
if (rawData.Child4 != null && rawData.Child4 != "")
orgName += $"/{rawData.Child4}";
orgName += $" {rawData.Child4}";
var result = new GetLeaveRequestForAdminByIdDto
{
@ -1972,6 +1976,8 @@ namespace BMA.EHR.Leave.Service.Controllers
var rejectList = await _leaveRequestRepository.GetSumRejectLeaveAsync(thisYear);
var deleteList = await _leaveRequestRepository.GetSumDeleteLeaveAsync(thisYear);
var approvePrevYear = await _leaveRequestRepository.GetSumApproveLeaveAsync(thisYear - 1);
var result = new List<dynamic>();
foreach (var leaveType in leaveTypes)
{
@ -1987,12 +1993,43 @@ namespace BMA.EHR.Leave.Service.Controllers
var deleteData = deleteList.FirstOrDefault(x => x.KeycloakUserId == userId && x.LeaveTypeId == leaveType.Id);
var delete = deleteData == null ? 0 : deleteData.SumLeaveDay;
// fix issue : SIT ระบบบันทึกการลา>> สิทธิ์การลา(โอนสิทธิ์การลา) #974
var extendLeave = 0.0;
var leaveLimit = leaveType.Limit;
if (leaveType.Code == "LV-005")
{
var apprvPrevData = approvePrevYear.FirstOrDefault(x => x.KeycloakUserId == userId && x.LeaveTypeId == leaveType.Id);
var apprvPrev = apprvPrevData == null ? 0 : approveData.SumLeaveDay;
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
var govAge = (profile?.DateStart?.Date ?? DateTime.Now.Date).DiffDay(DateTime.Now.Date);
if (govAge >= 180)
{
if (govAge >= 3650)
{
// ถ้าอายุราชการเกิน 10 ปี ได้บวกเพิ่มอีก 10 วัน
extendLeave = 30 - apprvPrev; // หายอดวันลาที่เหลือของปีก่อน
if (extendLeave >= 20) extendLeave = 20;
}
else
{
extendLeave = 20 - apprvPrev; // หายอดวันลาที่เหลือของปีก่อน
if (extendLeave >= 10) extendLeave = 10;
}
}
else
leaveLimit = 0;
}
var data = new
{
Id = leaveType.Id,
LeaveTypeName = leaveType.Name,
LeaveLimit = leaveType.Limit,
LeaveExtend = 0,
LeaveLimit = leaveLimit,
LeaveExtend = extendLeave,
leavePercent = Math.Round((approve * 100.0) / leaveType.Limit, 2),
LeaveCountSend = send,
LeaveCountApprove = approve,

View file

@ -15,6 +15,7 @@ using System.Net.Http.Headers;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
using BMA.EHR.Application.Repositories.Reports;
namespace BMA.EHR.Placement.Service.Controllers
{
@ -33,6 +34,8 @@ namespace BMA.EHR.Placement.Service.Controllers
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IConfiguration _configuration;
private readonly PermissionRepository _permission;
private readonly CandidateReportRepository _service;
private readonly MinIOExamService _minIOExamService;
public PlacementController(PlacementRepository repository,
NotificationRepository repositoryNoti,
@ -40,7 +43,9 @@ namespace BMA.EHR.Placement.Service.Controllers
MinIOService documentService,
IHttpContextAccessor httpContextAccessor,
IConfiguration configuration,
PermissionRepository permission)
PermissionRepository permission,
CandidateReportRepository service,
MinIOExamService minIOExamService)
{
_repository = repository;
_repositoryNoti = repositoryNoti;
@ -49,6 +54,8 @@ namespace BMA.EHR.Placement.Service.Controllers
_httpContextAccessor = httpContextAccessor;
_configuration = configuration;
_permission = permission;
_service = service;
_minIOExamService = minIOExamService;
}
#region " Properties "
@ -3281,5 +3288,91 @@ namespace BMA.EHR.Placement.Service.Controllers
};
return Success(data);
}
#region
/// <summary>
/// ใบสมัคร
/// </summary>
/// <param name="Id">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>
[HttpGet("candidate/{exportType}/{Id}")]
[AllowAnonymous]
public async Task<ActionResult<ResponseObject>> GetExamCandidate([FromRoute] Guid Id, string exportType = "pdf")
{
var candidate = await _service.GetExamCandidateAsync(Id);
var careers = await _service.GetExamCareerCandidateAsync(Id);
var avatar = await _service.GetExamAvatarCandidateAsync(Id);
if (candidate != null)
{
var picContent = avatar == null ? null : await _minIOExamService.ImagesPath(avatar);
var mapData = new
{
Id = candidate.GetType().GetProperty("Id").GetValue(candidate),
AvatarId = candidate.GetType().GetProperty("AvatarId").GetValue(candidate),
PeriodExamName = candidate.GetType().GetProperty("PeriodExamName").GetValue(candidate),
PeriodExamRound = candidate.GetType().GetProperty("PeriodExamRound").GetValue(candidate),
PeriodExamYear = candidate.GetType().GetProperty("PeriodExamYear").GetValue(candidate),
PositionName = candidate.GetType().GetProperty("PositionName").GetValue(candidate),
PositionLevelName = candidate.GetType().GetProperty("PositionLevelName").GetValue(candidate),
FullName = candidate.GetType().GetProperty("FullName").GetValue(candidate),
Nationality = candidate.GetType().GetProperty("Nationality").GetValue(candidate),
Religion = candidate.GetType().GetProperty("Religion").GetValue(candidate),
CitizenId = candidate.GetType().GetProperty("CitizenId").GetValue(candidate),
DateOfBirth = candidate.GetType().GetProperty("DateOfBirth").GetValue(candidate),
Age = candidate.GetType().GetProperty("Age").GetValue(candidate),
EducationLevelExamName = candidate.GetType().GetProperty("EducationLevelExamName").GetValue(candidate),
EducationName = candidate.GetType().GetProperty("EducationName").GetValue(candidate),
EducationMajor = candidate.GetType().GetProperty("EducationMajor").GetValue(candidate),
EducationLocation = candidate.GetType().GetProperty("EducationLocation").GetValue(candidate),
EducationEndDate = candidate.GetType().GetProperty("EducationEndDate").GetValue(candidate),
EducationScores = candidate.GetType().GetProperty("EducationScores").GetValue(candidate),
EducationType = candidate.GetType().GetProperty("EducationType").GetValue(candidate),
EducationLevelHighName = candidate.GetType().GetProperty("EducationLevelHighName").GetValue(candidate),
ExamIdenNumber = candidate.GetType().GetProperty("ExamIdenNumber").GetValue(candidate),
OccupationPositionType = candidate.GetType().GetProperty("OccupationPositionType").GetValue(candidate),
OccupationPosition = candidate.GetType().GetProperty("OccupationPosition").GetValue(candidate),
OccupationSalary = candidate.GetType().GetProperty("OccupationSalary").GetValue(candidate),
OccupationGroup = candidate.GetType().GetProperty("OccupationGroup").GetValue(candidate),
OccupationPile = candidate.GetType().GetProperty("OccupationPile").GetValue(candidate),
OccupationOrg = candidate.GetType().GetProperty("OccupationOrg").GetValue(candidate),
OccupationTelephone = candidate.GetType().GetProperty("OccupationTelephone").GetValue(candidate),
CareersTotal = candidate.GetType().GetProperty("CareersTotal").GetValue(candidate),
RegistAddress = candidate.GetType().GetProperty("RegistAddress").GetValue(candidate),
RegistProvinceName = candidate.GetType().GetProperty("RegistProvinceName").GetValue(candidate),
RegistDistrictName = candidate.GetType().GetProperty("RegistDistrictName").GetValue(candidate),
RegistSubDistrictName = candidate.GetType().GetProperty("RegistSubDistrictName").GetValue(candidate),
RegistZipCode = candidate.GetType().GetProperty("RegistZipCode").GetValue(candidate),
CurrentAddress = candidate.GetType().GetProperty("CurrentAddress").GetValue(candidate),
CurrentProvinceName = candidate.GetType().GetProperty("CurrentProvinceName").GetValue(candidate),
CurrentDistrictName = candidate.GetType().GetProperty("CurrentDistrictName").GetValue(candidate),
CurrentSubDistrictName = candidate.GetType().GetProperty("CurrentSubDistrictName").GetValue(candidate),
CurrentZipCode = candidate.GetType().GetProperty("CurrentZipCode").GetValue(candidate),
Telephone = candidate.GetType().GetProperty("Telephone").GetValue(candidate),
Email = candidate.GetType().GetProperty("Email").GetValue(candidate),
ContactFullName = candidate.GetType().GetProperty("ContactFullName").GetValue(candidate),
ContactRelations = candidate.GetType().GetProperty("ContactRelations").GetValue(candidate),
ContactTel = candidate.GetType().GetProperty("ContactTel").GetValue(candidate),
RegisterDate = candidate.GetType().GetProperty("RegisterDate").GetValue(candidate),
Url = picContent ?? "https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg",
Careers = careers,
};
var data = new
{
template = "ผลสอบคัดเลือกรายบุคคล",
reportName = "docx-report",
data = mapData
};
return Success(data);
}
else
{
return NotFound();
}
}
#endregion
}
}

View file

@ -0,0 +1,404 @@
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.Shared;
using BMA.EHR.Infrastructure.Persistence;
using BMA.EHR.Placement.Service.Requests;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Swashbuckle.AspNetCore.Annotations;
using System.Net.Http.Headers;
using System.Security.Claims;
namespace BMA.EHR.Placement.Service.Controllers
{
[Route("api/v{version:apiVersion}/placement/probation")]
[ApiVersion("1.0")]
[ApiController]
[Produces("application/json")]
[Authorize]
[SwaggerTag("report ทดลองงาน")]
public class PlacementProbationController : BaseController
{
private readonly ApplicationDBContext _context;
private readonly MinIOService _documentService;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IConfiguration _configuration;
private readonly PermissionRepository _permission;
private readonly ProbationReportRepository _repository;
public PlacementProbationController(
ApplicationDBContext context,
MinIOService documentService,
IHttpContextAccessor httpContextAccessor,
IConfiguration configuration,
PermissionRepository permiss,
ProbationReportRepository repository)
{
_context = context;
_documentService = documentService;
_httpContextAccessor = httpContextAccessor;
_configuration = configuration;
_permission = permiss;
_repository = repository;
}
#region " Properties "
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
private string? token => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
#endregion
#region 13-
/// <summary>
/// 13-แบบมอบหมายงานการทดลองปฏิบัติหน้าที่ราชการ
/// </summary>
/// <param name="id">assign 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>
[HttpGet("13/{exportType}/{id}")]
public async Task<ActionResult<ResponseObject>> GetProbationReportAsync(Guid id, string exportType = "pdf")
{
try
{
string authorizationHeader = Request.Headers["Authorization"];
string token = string.Empty;
if (!string.IsNullOrEmpty(authorizationHeader) && authorizationHeader.StartsWith("Bearer "))
{
token = authorizationHeader.Substring("Bearer ".Length).Trim();
var probation = await _repository.GetProbationAssignAsync(id, token);
if (probation != null)
{
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 = "probation-13",
reportName = "docx-report",
data = probation
};
return Success(data);
}
else
{
return NotFound();
}
}
else
{
return Unauthorized();
}
}
catch
{
throw;
}
}
#endregion
#region 14-
/// <summary>
/// 14-แบบบันทึกผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้ดูแล
/// </summary>
/// <param name="id">evaluate 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>
[HttpGet("14/{exportType}/{id}")]
public async Task<ActionResult<ResponseObject>> GetProbation14ConvertReportAsync(Guid id, string exportType = "pdf")
{
try
{
string authorizationHeader = Request.Headers["Authorization"];
string token = string.Empty;
if (!string.IsNullOrEmpty(authorizationHeader) && authorizationHeader.StartsWith("Bearer "))
{
token = authorizationHeader.Substring("Bearer ".Length).Trim();
var evaluateRecord = await _repository.GetEvaluateRecord14_15Async(id, token);
if (evaluateRecord != null)
{
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 = "probation-14",
reportName = "docx-report",
data = evaluateRecord
};
return Success(data);
}
else
{
return NotFound();
}
}
else
{
return Unauthorized();
}
}
catch
{
throw;
}
}
#endregion
#region 15-
/// <summary>
/// 15-แบบบันทึกผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้บังคับบัญชา
/// </summary>
/// <param name="id">evaluate 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>
[HttpGet("15/{exportType}/{id}")]
public async Task<ActionResult<ResponseObject>> GetProbation15ConvertReportAsync(Guid id, string exportType = "pdf")
{
try
{
string authorizationHeader = Request.Headers["Authorization"];
string token = string.Empty;
if (!string.IsNullOrEmpty(authorizationHeader) && authorizationHeader.StartsWith("Bearer "))
{
token = authorizationHeader.Substring("Bearer ".Length).Trim();
var evaluateRecord = await _repository.GetEvaluateRecord14_15Async(id, token);
if (evaluateRecord != null)
{
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 = "probation-15",
reportName = "docx-report",
data = evaluateRecord
};
return Success(data);
}
else
{
return NotFound();
}
}
else
{
return Unauthorized();
}
}
catch
{
throw;
}
}
#endregion
#region 16-
/// <summary>
/// 16-แบบประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้บังคับบัญชา
/// </summary>
/// <param name="id">evaluate 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>
[HttpGet("16/{exportType}/{id}")]
public async Task<ActionResult<ResponseObject>> GetProbation16ConvertReportAsync(Guid id, string exportType = "pdf")
{
try
{
string authorizationHeader = Request.Headers["Authorization"];
string token = string.Empty;
if (!string.IsNullOrEmpty(authorizationHeader) && authorizationHeader.StartsWith("Bearer "))
{
token = authorizationHeader.Substring("Bearer ".Length).Trim();
var evaluateAssign = await _repository.GetEvaluateAssignAsync(id, token);
if (evaluateAssign != null)
{
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 = "probation-16",
reportName = "docx-report",
data = evaluateAssign
};
return Success(data);
}
else
{
return NotFound();
}
}
else
{
return Unauthorized();
}
}
catch
{
throw;
}
}
#endregion
#region 17-
/// <summary>
/// 17-แบบประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับคณะกรรมการ
/// </summary>
/// <param name="id">evaluate 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>
[HttpGet("17/{exportType}/{id}")]
public async Task<ActionResult<ResponseObject>> GetProbation17ConvertReportAsync(Guid id, string exportType = "pdf")
{
try
{
string authorizationHeader = Request.Headers["Authorization"];
string token = string.Empty;
if (!string.IsNullOrEmpty(authorizationHeader) && authorizationHeader.StartsWith("Bearer "))
{
token = authorizationHeader.Substring("Bearer ".Length).Trim();
var evaluateAssign = await _repository.GetEvaluateChairmanAssignAsync(id, token);
if (evaluateAssign != null)
{
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 = "probation-17",
reportName = "docx-report",
data = evaluateAssign
};
return Success(data);
}
else
{
return NotFound();
}
}
else
{
return Unauthorized();
}
}
catch
{
throw;
}
}
#endregion
#region 18-
/// <summary>
/// 18-แบบรายงานการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับประธาน และ กรณีขยายเวลา
/// </summary>
/// <param name="id">assign 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>
[HttpGet("18/{exportType}/{id}/{no}")]
public async Task<ActionResult<ResponseObject>> GetProbation19ConvertReportAsync(Guid id, int no, string exportType = "pdf")
{
try
{
string authorizationHeader = Request.Headers["Authorization"];
string token = string.Empty;
if (!string.IsNullOrEmpty(authorizationHeader) && authorizationHeader.StartsWith("Bearer "))
{
token = authorizationHeader.Substring("Bearer ".Length).Trim();
var evaluateAssign = await _repository.GetEvaluateResultAssignAsync(id, no, token);
if (evaluateAssign != null)
{
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 = no == 1 ? "probation-18-1" : "probation-18-2",
reportName = "docx-report",
data = evaluateAssign
};
return Success(data);
}
else
{
return NotFound();
}
}
else
{
return Unauthorized();
}
}
catch
{
throw;
}
}
#endregion
}
}

View file

@ -14,6 +14,7 @@ using Swashbuckle.AspNetCore.Annotations;
using System.Net.Http.Headers;
using System.Security.Claims;
using Newtonsoft.Json.Linq;
using BMA.EHR.Application.Repositories.Reports;
namespace BMA.EHR.Placement.Service.Controllers
{
@ -32,6 +33,7 @@ namespace BMA.EHR.Placement.Service.Controllers
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IConfiguration _configuration;
private readonly PermissionRepository _permission;
private readonly TransferReportRepository _service;
public PlacementTransferController(PlacementRepository repository,
NotificationRepository repositoryNoti,
@ -39,7 +41,8 @@ namespace BMA.EHR.Placement.Service.Controllers
MinIOService documentService,
IHttpContextAccessor httpContextAccessor,
IConfiguration configuration,
PermissionRepository permission)
PermissionRepository permission,
TransferReportRepository service)
{
_repository = repository;
_repositoryNoti = repositoryNoti;
@ -48,6 +51,7 @@ namespace BMA.EHR.Placement.Service.Controllers
_httpContextAccessor = httpContextAccessor;
_configuration = configuration;
_permission = permission;
_service = service;
}
#region " Properties "
@ -927,5 +931,192 @@ namespace BMA.EHR.Placement.Service.Controllers
}
return Success();
}
#region
/// <summary>
/// คําร้องขอโอนไปถึงส่วนราชการอื่นนอก กรุงเทพมหานครที่ข้าราชการประสงค์ขอโอน
/// </summary>
/// <param name="id">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>
[HttpGet("21/{exportType}/{id}")]
public async Task<ActionResult<ResponseObject>> GetTransfer1ConvertReportAsync(Guid id, string exportType = "pdf")
{
try
{
var data = await _service.GetData1Transfer(id);
var result = new
{
template = "transfer1",
reportName = "docx-report",
data = data
};
return Success(result);
}
catch
{
throw;
}
}
#endregion
#region
/// <summary>
/// หนังสือแจ้งสํานักงานการเจ้าหน้าที่ สํานักปลัดกรุงเทพมหานคร ให้ทราบตําแหน่งและตําแหน่งเลขที่ที่ดําเนินการให้โอน
/// </summary>
/// <param name="id">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>
[HttpGet("22/{exportType}/{id}")]
public async Task<ActionResult<ResponseObject>> GetTransfer2ConvertReportAsync(Guid id, string exportType = "pdf")
{
try
{
var data = await _service.GetData2Transfer(id);
var result = new
{
template = "transfer2",
reportName = "docx-report",
data = data
};
return Success(result);
}
catch
{
throw;
}
}
#endregion
#region
/// <summary>
/// หนังสือยินยอมให้โอนและวันที่พร้อมจะให้โอนไปยัง หน่วยงานที่รับโอน
/// </summary>
/// <param name = "id" > 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>
[HttpGet("23/{exportType}/{id}")]
public async Task<ActionResult<ResponseObject>> GetTransfer3ConvertReportAsync(Guid id, string exportType = "pdf")
{
try
{
var data = await _service.GetData3Transfer(id);
var result = new
{
template = "transfer3",
reportName = "docx-report",
data = data
};
return Success(result);
}
catch
{
throw;
}
}
#endregion
#region
/// <summary>
/// หนังสือแจ้งสหกรณ์ออมทรัพย์กรุงเทพมหานครเพื่อขอ ตรวจสอบภาระหนี้สินสหกรณ์ออมทรัพย์
/// </summary>
/// <param name="id">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>
[HttpGet("24/{exportType}/{id}")]
public async Task<ActionResult<ResponseObject>> GetTransfer4ConvertReportAsync(Guid id, string exportType = "pdf")
{
try
{
var data = await _service.GetData4Transfer(id);
var result = new
{
template = "transfer4",
reportName = "docx-report",
data = data
};
return Success(result);
}
catch
{
throw;
}
}
#endregion
#region
/// <summary>
/// หนังสือถึงสํานักงานการเจ้าหน้าที่ สํานักปลัดกรุงเทพมหานครเพื่อขอตรวจสอบพฤติการณ์ทางวินัย และภาระหนี้สินสวัสดิการ
/// </summary>
/// <param name="id">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>
[HttpGet("25/{exportType}/{id}")]
public async Task<ActionResult<ResponseObject>> GetTransfer5ConvertReportAsync(Guid id, string exportType = "pdf")
{
try
{
var data = await _service.GetData5Transfer(id);
var result = new
{
template = "transfer5",
reportName = "docx-report",
data = data
};
return Success(result);
}
catch
{
throw;
}
}
#endregion
#region
/// <summary>
/// หนังสือถึงสถาบันพัฒนาข้าราชการกรุงเทพมหานครเพื่อขอตรวจสอบเรื่องภาระผูกพันการรับทุนและการลา ศึกษาต่อกับทางกรุงเทพมหานคร
/// </summary>
/// <param name="id">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>
[HttpGet("26/{exportType}/{id}")]
public async Task<ActionResult<ResponseObject>> GetTransfer6ConvertReportAsync(Guid id, string exportType = "pdf")
{
try
{
var data = await _service.GetData6Transfer(id);
var result = new
{
template = "transfer6",
reportName = "docx-report",
data = data
};
return Success(result);
}
catch
{
throw;
}
}
#endregion
}
}

View file

@ -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",
@ -1999,44 +2003,110 @@ namespace BMA.EHR.Retirement.Service.Controllers
return Success(data);
}
//เกษียณอายุราชการ
//public async Task ExecuteRetirement()
//{
// var retirePeriodOfficer = await _context.RetirementPeriods
// .Include(x => x.RetirementRawProfiles.Where(y => y.Remove != "REMOVE"))
// .Where(x => x.Year == /*DateTime.Now.Year*/2026)
// .Where(x => x.Type.Trim().ToUpper().Contains("OFFICER"))
// .FirstOrDefaultAsync();
/// <summary>
/// เกษียณอายุราชการ
/// </summary>
/// <param name="type">ประเภทUser(officer,employee)(ตัวใหญ่หรือเล็กก็ได้)</param>
/// <param name="year">ปีงบประมาณ(ค.ศ.)</param>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("update-status/{type}/{year}")]
public async Task<ActionResult<ResponseObject>> UpdateStatusRetirement(string type, int year)
{
var retirePeriodOfficer = await _context.RetirementPeriods
.Include(x => x.RetirementRawProfiles.Where(y => y.Remove != "REMOVE"))
.Where(x => x.Year == year && x.Type.Trim().ToUpper().Contains(type))
.FirstOrDefaultAsync();
// var body = retirePeriodOfficer.RetirementProfiles
// .Select(x => new
// {
// profileId = x.profileId,
// //lastUpdateUserId = UserId,
// //lastUpdateFullName = FullName,
// })
// .ToList();
if (retirePeriodOfficer == null)
return Error("ไม่พบรอบประกาศเกษียณอายุราชการ");
// //ข้าราชการ
// //var apiUrl = $"{_configuration["API"]}/org/unauthorize/retirement";
// var apiUrl = $"http://localhost:13001/api/v1/org/unauthorize/retirement";
// using (var client = new HttpClient())
// {
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
// client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
// var jsonBody = JsonConvert.SerializeObject(body);
// var content = new StringContent(jsonBody, Encoding.UTF8, "application/json");
// var _req = new HttpRequestMessage(HttpMethod.Patch, apiUrl)
// {
// Content = content
// };
// var response = await client.SendAsync(_req);
// var responseContent = await response.Content.ReadAsStringAsync();
// if (!response.IsSuccessStatusCode)
// {
var data = retirePeriodOfficer.RetirementRawProfiles
.Select(x => new
{
profileId = x.profileId
})
.ToList();
// }
// }
//}
return Success(data);
}
#region 31- & 32-
/// <summary>
/// 31-ประกาศเกษียณข้าราชการ & 32-ประกาศเกษียณลูกจ้างประจำ
/// </summary>
/// <param name="Id">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>
[HttpGet("31/{exportType}/{Id}")]
public async Task<ActionResult<ResponseObject>> 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
}
}

View file

@ -3,10 +3,6 @@ using BMA.EHR.Application.Repositories.MessageQueue;
using BMA.EHR.Application.Repositories.Reports;
using BMA.EHR.Application.Responses;
using BMA.EHR.Domain.Common;
using BMA.EHR.Domain.Extensions;
using BMA.EHR.Domain.Models.HR;
using BMA.EHR.Domain.Models.MetaData;
using BMA.EHR.Domain.Models.Notifications;
using BMA.EHR.Domain.Models.Retirement;
using BMA.EHR.Domain.Shared;
using BMA.EHR.Infrastructure.Persistence;
@ -18,10 +14,7 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Swashbuckle.AspNetCore.Annotations;
using System.Net.Http.Headers;
using System.Reflection.Metadata;
using System.Security.Claims;
using System.Security.Cryptography;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
namespace BMA.EHR.Retirement.Service.Controllers
{
@ -747,5 +740,63 @@ namespace BMA.EHR.Retirement.Service.Controllers
return Success();
}
/// <summary>
/// 36-บันทึกเวียนแจ้งการถึงแก่กรรม
/// </summary>
/// <param name="id">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>
[HttpGet("36/{exportType}/{id}")]
public async Task<ActionResult<ResponseObject>> GetDeceasedReportAsync(Guid id, string exportType = "pdf")
{
try
{
var head = await _repositoryRetireReport.GetHeadRetirementDeceasedAsync(id);
var detail = await _repositoryRetireReport.GetRetirementDeceasedAsync(id);
if (detail != null && head != null)
{
var mergeData = new
{
Oc = head.GetType().GetProperty("Oc").GetValue(head),
Number = head.GetType().GetProperty("Number").GetValue(head),
Date = head.GetType().GetProperty("Date").GetValue(head),
Subject = head.GetType().GetProperty("Subject").GetValue(head),
Send = head.GetType().GetProperty("Send").GetValue(head),
FullName = detail.GetType().GetProperty("FullName").GetValue(detail),
Position = detail.GetType().GetProperty("Position").GetValue(detail),
Reason = detail.GetType().GetProperty("Reason").GetValue(detail),
DeceasedDate = detail.GetType().GetProperty("Date").GetValue(detail),
CurrentDate = detail.GetType().GetProperty("CurrentDate").GetValue(detail),
DeceasedNumber = detail.GetType().GetProperty("Number").GetValue(detail),
Location = detail.GetType().GetProperty("Location").GetValue(detail),
};
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 = "deceased",
reportName = "docx-report",
data = mergeData
};
return Success(data);
}
else
{
return NotFound();
}
}
catch
{
throw;
}
}
}
}

View file

@ -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-
/// <summary>
/// 33-แบบฟอร์มหนังสือขอลาออกจากราชการ
/// </summary>
/// <param name="id">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>
[HttpGet("33/{exportType}/{id}")]
public async Task<ActionResult<ResponseObject>> 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
}
}

View file

@ -82,13 +82,14 @@ var builder = WebApplication.CreateBuilder(args);
.SetIsOriginAllowedToAllowWildcardSubdomains();
}));
// Add services to the container.
builder.Services.AddApplication();
builder.Services.AddPersistence(builder.Configuration);
builder.Services.AddLeaveApplication();
builder.Services.AddPersistence(builder.Configuration);
builder.Services.AddLeavePersistence(builder.Configuration);
builder.Services.AddHttpClient();
builder.Services.AddControllers(options =>
{
options.SuppressAsyncSuffixInActionNames = false;
@ -108,6 +109,7 @@ var builder = WebApplication.CreateBuilder(args);
options.UseMySql(disciplineConnection, ServerVersion.AutoDetect(disciplineConnection)));
builder.Services.AddHealthChecks();
// Add Hangfire services.
builder.Services.AddHangfire(configuration => configuration
.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
@ -159,18 +161,20 @@ var app = builder.Build();
app.UseStaticFiles();
app.MapControllers();
app.UseMiddleware<ErrorHandlerMiddleware>();
app.UseHangfireDashboard("/hangfire", new DashboardOptions()
{
Authorization = new[] { new CustomAuthorizeFilter() }
});
var manager = new RecurringJobManager();
if (manager != null)
{
//manager.AddOrUpdate("แจ้งเตือนระบบปลดออก", Job.FromExpression<RetirementRepository>(x => x.NotifyDischarge()), Cron.Daily(Int32.Parse(builder.Configuration["KeycloakCron:Hour"]), Int32.Parse(builder.Configuration["KeycloakCron:Minute"])), TimeZoneInfo.Local);
//manager.AddOrUpdate("แจ้งเตือนระบบไล่ออก", Job.FromExpression<RetirementRepository>(x => x.NotifyExpulsion()), Cron.Daily(Int32.Parse(builder.Configuration["KeycloakCron:Hour"]), Int32.Parse(builder.Configuration["KeycloakCron:Minute"])), TimeZoneInfo.Local);
//manager.AddOrUpdate("แจ้งเตือนระบบให้ออก", Job.FromExpression<RetirementRepository>(x => x.NotifyOut()), Cron.Daily(Int32.Parse(builder.Configuration["KeycloakCron:Hour"]), Int32.Parse(builder.Configuration["KeycloakCron:Minute"])), TimeZoneInfo.Local);
manager.AddOrUpdate("อัพเดทสถานะเกษียณอายุราชการ", Job.FromExpression<RetirementRepository>(x => x.ExecuteRetirement()), Cron.Yearly(10, 1, 0, 0), TimeZoneInfo.Local);
//manager.AddOrUpdate("Test อัพเดทสถานะเกษียณอายุราชการ", Job.FromExpression<RetirementController>(x => x.ExecuteRetirement()), Cron.Yearly(10, 1, 0, 0), TimeZoneInfo.Local);
//manager.AddOrUpdate("อัพเดทสถานะเกษียณอายุราชการ", Job.FromExpression<RetirementRepository>(x => x.ExecuteRetirement()), Cron.Yearly(10, 1, 0, 0), TimeZoneInfo.Local);
manager.AddOrUpdate("ทดสอบ", Job.FromExpression<RetirementRepository>(x => x.TestMethod()), Cron.Yearly(10, 1, 0, 0), TimeZoneInfo.Local);
}
// apply migrations