diff --git a/BMA.EHR.Application/ApplicationServicesRegistration.cs b/BMA.EHR.Application/ApplicationServicesRegistration.cs index aa47f71f..312a2597 100644 --- a/BMA.EHR.Application/ApplicationServicesRegistration.cs +++ b/BMA.EHR.Application/ApplicationServicesRegistration.cs @@ -27,7 +27,7 @@ namespace BMA.EHR.Application services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); + //services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/BMA.EHR.Application/Repositories/Reports/ProbationReportRepository.cs b/BMA.EHR.Application/Repositories/Reports/ProbationReportRepository.cs index 57dd6284..1092385f 100644 --- a/BMA.EHR.Application/Repositories/Reports/ProbationReportRepository.cs +++ b/BMA.EHR.Application/Repositories/Reports/ProbationReportRepository.cs @@ -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_ : "-", diff --git a/BMA.EHR.Application/Repositories/RetirementRepository.cs b/BMA.EHR.Application/Repositories/RetirementRepository.cs index 20d96b3b..a771b89e 100644 --- a/BMA.EHR.Application/Repositories/RetirementRepository.cs +++ b/BMA.EHR.Application/Repositories/RetirementRepository.cs @@ -105,42 +105,53 @@ namespace BMA.EHR.Application.Repositories } //āđ€āļāļĐāļĩāļĒāļ“āļ­āļēāļĒāļļāļĢāļēāļŠāļāļēāļĢ - public async Task ExecuteRetirement() + //public async Task ExecuteRetirement() + //{ + // var retirePeriodOfficer = await _dbContext.Set() + // .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() - .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; } } } diff --git a/BMA.EHR.Application/Responses/EvaluateResultAssignResponse.cs b/BMA.EHR.Application/Responses/EvaluateResultAssignResponse.cs index ae940ec5..412e6bfc 100644 --- a/BMA.EHR.Application/Responses/EvaluateResultAssignResponse.cs +++ b/BMA.EHR.Application/Responses/EvaluateResultAssignResponse.cs @@ -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 diff --git a/BMA.EHR.Leave/Controllers/LeaveRequestController.cs b/BMA.EHR.Leave/Controllers/LeaveRequestController.cs index a4fc6fde..f7f322f3 100644 --- a/BMA.EHR.Leave/Controllers/LeaveRequestController.cs +++ b/BMA.EHR.Leave/Controllers/LeaveRequestController.cs @@ -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(); 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, diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index 817aaa7d..9b2b3b88 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -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 āđƒāļšāļŠāļĄāļąāļ„āļĢ + /// + /// āđƒāļšāļŠāļĄāļąāļ„āļĢ + /// + /// Id āļœāļđāđ‰āļŠāļĄāļąāļ„āļĢ + /// pdf, docx āļŦāļĢāļ·āļ­ xlsx + /// + /// āđ€āļĄāļ·āđˆāļ­āļ—āļģāļāļēāļĢāļ­āđˆāļēāļ™āļ‚āđ‰āļ­āļĄāļđāļĨāļˆāļēāļ Relational Database āļŠāļģāđ€āļĢāđ‡āļˆ + /// āđ„āļĄāđˆāđ„āļ”āđ‰ Login āđ€āļ‚āđ‰āļēāļĢāļ°āļšāļš + /// āđ€āļĄāļ·āđˆāļ­āđ€āļāļīāļ”āļ‚āđ‰āļ­āļœāļīāļ”āļžāļĨāļēāļ”āđƒāļ™āļāļēāļĢāļ—āļģāļ‡āļēāļ™ + [HttpGet("candidate/{exportType}/{Id}")] + [AllowAnonymous] + public async Task> 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 } } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementProbationController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementProbationController.cs new file mode 100644 index 00000000..e88b302b --- /dev/null +++ b/BMA.EHR.Placement.Service/Controllers/PlacementProbationController.cs @@ -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-āđāļšāļšāļĄāļ­āļšāļŦāļĄāļēāļĒāļ‡āļēāļ™āļāļēāļĢāļ—āļ”āļĨāļ­āļ‡āļ›āļāļīāļšāļąāļ•āļīāļŦāļ™āđ‰āļēāļ—āļĩāđˆāļĢāļēāļŠāļāļēāļĢ + /// + /// 13-āđāļšāļšāļĄāļ­āļšāļŦāļĄāļēāļĒāļ‡āļēāļ™āļāļēāļĢāļ—āļ”āļĨāļ­āļ‡āļ›āļāļīāļšāļąāļ•āļīāļŦāļ™āđ‰āļēāļ—āļĩāđˆāļĢāļēāļŠāļāļēāļĢ + /// + /// assign id āđāļšāļšāļĄāļ­āļšāļŦāļĄāļēāļĒāļ‡āļēāļ™āļāļēāļĢāļ—āļ”āļĨāļ­āļ‡āļ›āļāļīāļšāļąāļ•āļīāļŦāļ™āđ‰āļēāļ—āļĩāđˆāļĢāļēāļŠāļāļēāļĢ + /// pdf, docx āļŦāļĢāļ·āļ­ xlsx + /// + /// āđ€āļĄāļ·āđˆāļ­āļ—āļģāļāļēāļĢāļ­āđˆāļēāļ™āļ‚āđ‰āļ­āļĄāļđāļĨāļˆāļēāļ Relational Database āļŠāļģāđ€āļĢāđ‡āļˆ + /// āđ„āļĄāđˆāđ„āļ”āđ‰ Login āđ€āļ‚āđ‰āļēāļĢāļ°āļšāļš + /// āđ€āļĄāļ·āđˆāļ­āđ€āļāļīāļ”āļ‚āđ‰āļ­āļœāļīāļ”āļžāļĨāļēāļ”āđƒāļ™āļāļēāļĢāļ—āļģāļ‡āļēāļ™ + [HttpGet("13/{exportType}/{id}")] + public async Task> 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-āđāļšāļšāļšāļąāļ™āļ—āļķāļāļœāļĨāļāļēāļĢāļ—āļ”āļĨāļ­āļ‡āļ›āļāļīāļšāļąāļ•āļīāļŦāļ™āđ‰āļēāļ—āļĩāđˆāļĢāļēāļŠāļāļēāļĢ āļŠāļģāļŦāļĢāļąāļšāļœāļđāđ‰āļ”āļđāđāļĨ + /// + /// 14-āđāļšāļšāļšāļąāļ™āļ—āļķāļāļœāļĨāļāļēāļĢāļ—āļ”āļĨāļ­āļ‡āļ›āļāļīāļšāļąāļ•āļīāļŦāļ™āđ‰āļēāļ—āļĩāđˆāļĢāļēāļŠāļāļēāļĢ āļŠāļģāļŦāļĢāļąāļšāļœāļđāđ‰āļ”āļđāđāļĨ + /// + /// evaluate id + /// pdf, docx āļŦāļĢāļ·āļ­ xlsx + /// + /// āđ€āļĄāļ·āđˆāļ­āļ—āļģāļāļēāļĢāļ­āđˆāļēāļ™āļ‚āđ‰āļ­āļĄāļđāļĨāļˆāļēāļ Relational Database āļŠāļģāđ€āļĢāđ‡āļˆ + /// āđ„āļĄāđˆāđ„āļ”āđ‰ Login āđ€āļ‚āđ‰āļēāļĢāļ°āļšāļš + /// āđ€āļĄāļ·āđˆāļ­āđ€āļāļīāļ”āļ‚āđ‰āļ­āļœāļīāļ”āļžāļĨāļēāļ”āđƒāļ™āļāļēāļĢāļ—āļģāļ‡āļēāļ™ + [HttpGet("14/{exportType}/{id}")] + public async Task> 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-āđāļšāļšāļšāļąāļ™āļ—āļķāļāļœāļĨāļāļēāļĢāļ—āļ”āļĨāļ­āļ‡āļ›āļāļīāļšāļąāļ•āļīāļŦāļ™āđ‰āļēāļ—āļĩāđˆāļĢāļēāļŠāļāļēāļĢ āļŠāļģāļŦāļĢāļąāļšāļœāļđāđ‰āļšāļąāļ‡āļ„āļąāļšāļšāļąāļāļŠāļē + /// + /// 15-āđāļšāļšāļšāļąāļ™āļ—āļķāļāļœāļĨāļāļēāļĢāļ—āļ”āļĨāļ­āļ‡āļ›āļāļīāļšāļąāļ•āļīāļŦāļ™āđ‰āļēāļ—āļĩāđˆāļĢāļēāļŠāļāļēāļĢ āļŠāļģāļŦāļĢāļąāļšāļœāļđāđ‰āļšāļąāļ‡āļ„āļąāļšāļšāļąāļāļŠāļē + /// + /// evaluate id + /// pdf, docx āļŦāļĢāļ·āļ­ xlsx + /// + /// āđ€āļĄāļ·āđˆāļ­āļ—āļģāļāļēāļĢāļ­āđˆāļēāļ™āļ‚āđ‰āļ­āļĄāļđāļĨāļˆāļēāļ Relational Database āļŠāļģāđ€āļĢāđ‡āļˆ + /// āđ„āļĄāđˆāđ„āļ”āđ‰ Login āđ€āļ‚āđ‰āļēāļĢāļ°āļšāļš + /// āđ€āļĄāļ·āđˆāļ­āđ€āļāļīāļ”āļ‚āđ‰āļ­āļœāļīāļ”āļžāļĨāļēāļ”āđƒāļ™āļāļēāļĢāļ—āļģāļ‡āļēāļ™ + [HttpGet("15/{exportType}/{id}")] + public async Task> 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-āđāļšāļšāļ›āļĢāļ°āđ€āļĄāļīāļ™āļœāļĨāļāļēāļĢāļ—āļ”āļĨāļ­āļ‡āļ›āļāļīāļšāļąāļ•āļīāļŦāļ™āđ‰āļēāļ—āļĩāđˆāļĢāļēāļŠāļāļēāļĢ āļŠāļģāļŦāļĢāļąāļšāļœāļđāđ‰āļšāļąāļ‡āļ„āļąāļšāļšāļąāļāļŠāļē + /// + /// 16-āđāļšāļšāļ›āļĢāļ°āđ€āļĄāļīāļ™āļœāļĨāļāļēāļĢāļ—āļ”āļĨāļ­āļ‡āļ›āļāļīāļšāļąāļ•āļīāļŦāļ™āđ‰āļēāļ—āļĩāđˆāļĢāļēāļŠāļāļēāļĢ āļŠāļģāļŦāļĢāļąāļšāļœāļđāđ‰āļšāļąāļ‡āļ„āļąāļšāļšāļąāļāļŠāļē + /// + /// evaluate id + /// pdf, docx āļŦāļĢāļ·āļ­ xlsx + /// + /// āđ€āļĄāļ·āđˆāļ­āļ—āļģāļāļēāļĢāļ­āđˆāļēāļ™āļ‚āđ‰āļ­āļĄāļđāļĨāļˆāļēāļ Relational Database āļŠāļģāđ€āļĢāđ‡āļˆ + /// āđ„āļĄāđˆāđ„āļ”āđ‰ Login āđ€āļ‚āđ‰āļēāļĢāļ°āļšāļš + /// āđ€āļĄāļ·āđˆāļ­āđ€āļāļīāļ”āļ‚āđ‰āļ­āļœāļīāļ”āļžāļĨāļēāļ”āđƒāļ™āļāļēāļĢāļ—āļģāļ‡āļēāļ™ + [HttpGet("16/{exportType}/{id}")] + public async Task> 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-āđāļšāļšāļ›āļĢāļ°āđ€āļĄāļīāļ™āļœāļĨāļāļēāļĢāļ—āļ”āļĨāļ­āļ‡āļ›āļāļīāļšāļąāļ•āļīāļŦāļ™āđ‰āļēāļ—āļĩāđˆāļĢāļēāļŠāļāļēāļĢ āļŠāļģāļŦāļĢāļąāļšāļ„āļ“āļ°āļāļĢāļĢāļĄāļāļēāļĢ + /// + /// 17-āđāļšāļšāļ›āļĢāļ°āđ€āļĄāļīāļ™āļœāļĨāļāļēāļĢāļ—āļ”āļĨāļ­āļ‡āļ›āļāļīāļšāļąāļ•āļīāļŦāļ™āđ‰āļēāļ—āļĩāđˆāļĢāļēāļŠāļāļēāļĢ āļŠāļģāļŦāļĢāļąāļšāļ„āļ“āļ°āļāļĢāļĢāļĄāļāļēāļĢ + /// + /// evaluate id + /// pdf, docx āļŦāļĢāļ·āļ­ xlsx + /// + /// āđ€āļĄāļ·āđˆāļ­āļ—āļģāļāļēāļĢāļ­āđˆāļēāļ™āļ‚āđ‰āļ­āļĄāļđāļĨāļˆāļēāļ Relational Database āļŠāļģāđ€āļĢāđ‡āļˆ + /// āđ„āļĄāđˆāđ„āļ”āđ‰ Login āđ€āļ‚āđ‰āļēāļĢāļ°āļšāļš + /// āđ€āļĄāļ·āđˆāļ­āđ€āļāļīāļ”āļ‚āđ‰āļ­āļœāļīāļ”āļžāļĨāļēāļ”āđƒāļ™āļāļēāļĢāļ—āļģāļ‡āļēāļ™ + [HttpGet("17/{exportType}/{id}")] + public async Task> 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-āđāļšāļšāļĢāļēāļĒāļ‡āļēāļ™āļāļēāļĢāļ›āļĢāļ°āđ€āļĄāļīāļ™āļœāļĨāļāļēāļĢāļ—āļ”āļĨāļ­āļ‡āļ›āļāļīāļšāļąāļ•āļīāļŦāļ™āđ‰āļēāļ—āļĩāđˆāļĢāļēāļŠāļāļēāļĢ āļŠāļģāļŦāļĢāļąāļšāļ›āļĢāļ°āļ˜āļēāļ™ āđāļĨāļ° āļāļĢāļ“āļĩāļ‚āļĒāļēāļĒāđ€āļ§āļĨāļē + /// + /// 18-āđāļšāļšāļĢāļēāļĒāļ‡āļēāļ™āļāļēāļĢāļ›āļĢāļ°āđ€āļĄāļīāļ™āļœāļĨāļāļēāļĢāļ—āļ”āļĨāļ­āļ‡āļ›āļāļīāļšāļąāļ•āļīāļŦāļ™āđ‰āļēāļ—āļĩāđˆāļĢāļēāļŠāļāļēāļĢ āļŠāļģāļŦāļĢāļąāļšāļ›āļĢāļ°āļ˜āļēāļ™ āđāļĨāļ° āļāļĢāļ“āļĩāļ‚āļĒāļēāļĒāđ€āļ§āļĨāļē + /// + /// assign id āđāļšāļšāļĄāļ­āļšāļŦāļĄāļēāļĒāļ‡āļēāļ™āļāļēāļĢāļ—āļ”āļĨāļ­āļ‡āļ›āļāļīāļšāļąāļ•āļīāļŦāļ™āđ‰āļēāļ—āļĩāđˆāļĢāļēāļŠāļāļēāļĢ + /// pdf, docx āļŦāļĢāļ·āļ­ xlsx + /// + /// āđ€āļĄāļ·āđˆāļ­āļ—āļģāļāļēāļĢāļ­āđˆāļēāļ™āļ‚āđ‰āļ­āļĄāļđāļĨāļˆāļēāļ Relational Database āļŠāļģāđ€āļĢāđ‡āļˆ + /// āđ„āļĄāđˆāđ„āļ”āđ‰ Login āđ€āļ‚āđ‰āļēāļĢāļ°āļšāļš + /// āđ€āļĄāļ·āđˆāļ­āđ€āļāļīāļ”āļ‚āđ‰āļ­āļœāļīāļ”āļžāļĨāļēāļ”āđƒāļ™āļāļēāļĢāļ—āļģāļ‡āļēāļ™ + [HttpGet("18/{exportType}/{id}/{no}")] + public async Task> 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 + } +} diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs index b9adcb9a..cc4e4d06 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs @@ -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 āļ„āđāļēāļĢāđ‰āļ­āļ‡āļ‚āļ­āđ‚āļ­āļ™āđ„āļ›āļ–āļķāļ‡āļŠāđˆāļ§āļ™āļĢāļēāļŠāļāļēāļĢāļ­āļ·āđˆāļ™āļ™āļ­āļ āļāļĢāļļāļ‡āđ€āļ—āļžāļĄāļŦāļēāļ™āļ„āļĢāļ—āļĩāđˆāļ‚āđ‰āļēāļĢāļēāļŠāļāļēāļĢāļ›āļĢāļ°āļŠāļ‡āļ„āđŒāļ‚āļ­āđ‚āļ­āļ™ + /// + /// āļ„āđāļēāļĢāđ‰āļ­āļ‡āļ‚āļ­āđ‚āļ­āļ™āđ„āļ›āļ–āļķāļ‡āļŠāđˆāļ§āļ™āļĢāļēāļŠāļāļēāļĢāļ­āļ·āđˆāļ™āļ™āļ­āļ āļāļĢāļļāļ‡āđ€āļ—āļžāļĄāļŦāļēāļ™āļ„āļĢāļ—āļĩāđˆāļ‚āđ‰āļēāļĢāļēāļŠāļāļēāļĢāļ›āļĢāļ°āļŠāļ‡āļ„āđŒāļ‚āļ­āđ‚āļ­āļ™ + /// + /// id + /// pdf, docx āļŦāļĢāļ·āļ­ xlsx + /// + /// āđ€āļĄāļ·āđˆāļ­āļ—āļģāļāļēāļĢāļ­āđˆāļēāļ™āļ‚āđ‰āļ­āļĄāļđāļĨāļˆāļēāļ Relational Database āļŠāļģāđ€āļĢāđ‡āļˆ + /// āđ„āļĄāđˆāđ„āļ”āđ‰ Login āđ€āļ‚āđ‰āļēāļĢāļ°āļšāļš + /// āđ€āļĄāļ·āđˆāļ­āđ€āļāļīāļ”āļ‚āđ‰āļ­āļœāļīāļ”āļžāļĨāļēāļ”āđƒāļ™āļāļēāļĢāļ—āļģāļ‡āļēāļ™ + [HttpGet("21/{exportType}/{id}")] + public async Task> 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 āļŦāļ™āļąāļ‡āļŠāļ·āļ­āđāļˆāđ‰āļ‡āļŠāđāļēāļ™āļąāļāļ‡āļēāļ™āļāļēāļĢāđ€āļˆāđ‰āļēāļŦāļ™āđ‰āļēāļ—āļĩāđˆ āļŠāđāļēāļ™āļąāļāļ›āļĨāļąāļ”āļāļĢāļļāļ‡āđ€āļ—āļžāļĄāļŦāļēāļ™āļ„āļĢ āđƒāļŦāđ‰āļ—āļĢāļēāļšāļ•āđāļēāđāļŦāļ™āđˆāļ‡āđāļĨāļ°āļ•āđāļēāđāļŦāļ™āđˆāļ‡āđ€āļĨāļ‚āļ—āļĩāđˆāļ—āļĩāđˆāļ”āđāļēāđ€āļ™āļīāļ™āļāļēāļĢāđƒāļŦāđ‰āđ‚āļ­āļ™ + /// + /// āļŦāļ™āļąāļ‡āļŠāļ·āļ­āđāļˆāđ‰āļ‡āļŠāđāļēāļ™āļąāļāļ‡āļēāļ™āļāļēāļĢāđ€āļˆāđ‰āļēāļŦāļ™āđ‰āļēāļ—āļĩāđˆ āļŠāđāļēāļ™āļąāļāļ›āļĨāļąāļ”āļāļĢāļļāļ‡āđ€āļ—āļžāļĄāļŦāļēāļ™āļ„āļĢ āđƒāļŦāđ‰āļ—āļĢāļēāļšāļ•āđāļēāđāļŦāļ™āđˆāļ‡āđāļĨāļ°āļ•āđāļēāđāļŦāļ™āđˆāļ‡āđ€āļĨāļ‚āļ—āļĩāđˆāļ—āļĩāđˆāļ”āđāļēāđ€āļ™āļīāļ™āļāļēāļĢāđƒāļŦāđ‰āđ‚āļ­āļ™ + /// + /// id + /// pdf, docx āļŦāļĢāļ·āļ­ xlsx + /// + /// āđ€āļĄāļ·āđˆāļ­āļ—āļģāļāļēāļĢāļ­āđˆāļēāļ™āļ‚āđ‰āļ­āļĄāļđāļĨāļˆāļēāļ Relational Database āļŠāļģāđ€āļĢāđ‡āļˆ + /// āđ„āļĄāđˆāđ„āļ”āđ‰ Login āđ€āļ‚āđ‰āļēāļĢāļ°āļšāļš + /// āđ€āļĄāļ·āđˆāļ­āđ€āļāļīāļ”āļ‚āđ‰āļ­āļœāļīāļ”āļžāļĨāļēāļ”āđƒāļ™āļāļēāļĢāļ—āļģāļ‡āļēāļ™ + [HttpGet("22/{exportType}/{id}")] + public async Task> 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 āļŦāļ™āļąāļ‡āļŠāļ·āļ­āļĒāļīāļ™āļĒāļ­āļĄāđƒāļŦāđ‰āđ‚āļ­āļ™āđāļĨāļ°āļ§āļąāļ™āļ—āļĩāđˆāļžāļĢāđ‰āļ­āļĄāļˆāļ°āđƒāļŦāđ‰āđ‚āļ­āļ™āđ„āļ›āļĒāļąāļ‡ āļŦāļ™āđˆāļ§āļĒāļ‡āļēāļ™āļ—āļĩāđˆāļĢāļąāļšāđ‚āļ­āļ™ + /// + /// āļŦāļ™āļąāļ‡āļŠāļ·āļ­āļĒāļīāļ™āļĒāļ­āļĄāđƒāļŦāđ‰āđ‚āļ­āļ™āđāļĨāļ°āļ§āļąāļ™āļ—āļĩāđˆāļžāļĢāđ‰āļ­āļĄāļˆāļ°āđƒāļŦāđ‰āđ‚āļ­āļ™āđ„āļ›āļĒāļąāļ‡ āļŦāļ™āđˆāļ§āļĒāļ‡āļēāļ™āļ—āļĩāđˆāļĢāļąāļšāđ‚āļ­āļ™ + /// + /// id + /// pdf, docx āļŦāļĢāļ·āļ­ xlsx + /// + /// āđ€āļĄāļ·āđˆāļ­āļ—āļģāļāļēāļĢāļ­āđˆāļēāļ™āļ‚āđ‰āļ­āļĄāļđāļĨāļˆāļēāļ Relational Database āļŠāļģāđ€āļĢāđ‡āļˆ + /// āđ„āļĄāđˆāđ„āļ”āđ‰ Login āđ€āļ‚āđ‰āļēāļĢāļ°āļšāļš + /// āđ€āļĄāļ·āđˆāļ­āđ€āļāļīāļ”āļ‚āđ‰āļ­āļœāļīāļ”āļžāļĨāļēāļ”āđƒāļ™āļāļēāļĢāļ—āļģāļ‡āļēāļ™ + [HttpGet("23/{exportType}/{id}")] + public async Task> 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 āļŦāļ™āļąāļ‡āļŠāļ·āļ­āđāļˆāđ‰āļ‡āļŠāļŦāļāļĢāļ“āđŒāļ­āļ­āļĄāļ—āļĢāļąāļžāļĒāđŒāļāļĢāļļāļ‡āđ€āļ—āļžāļĄāļŦāļēāļ™āļ„āļĢāđ€āļžāļ·āđˆāļ­āļ‚āļ­ āļ•āļĢāļ§āļˆāļŠāļ­āļšāļ āļēāļĢāļ°āļŦāļ™āļĩāđ‰āļŠāļīāļ™āļŠāļŦāļāļĢāļ“āđŒāļ­āļ­āļĄāļ—āļĢāļąāļžāļĒāđŒ + /// + /// āļŦāļ™āļąāļ‡āļŠāļ·āļ­āđāļˆāđ‰āļ‡āļŠāļŦāļāļĢāļ“āđŒāļ­āļ­āļĄāļ—āļĢāļąāļžāļĒāđŒāļāļĢāļļāļ‡āđ€āļ—āļžāļĄāļŦāļēāļ™āļ„āļĢāđ€āļžāļ·āđˆāļ­āļ‚āļ­ āļ•āļĢāļ§āļˆāļŠāļ­āļšāļ āļēāļĢāļ°āļŦāļ™āļĩāđ‰āļŠāļīāļ™āļŠāļŦāļāļĢāļ“āđŒāļ­āļ­āļĄāļ—āļĢāļąāļžāļĒāđŒ + /// + /// id + /// pdf, docx āļŦāļĢāļ·āļ­ xlsx + /// + /// āđ€āļĄāļ·āđˆāļ­āļ—āļģāļāļēāļĢāļ­āđˆāļēāļ™āļ‚āđ‰āļ­āļĄāļđāļĨāļˆāļēāļ Relational Database āļŠāļģāđ€āļĢāđ‡āļˆ + /// āđ„āļĄāđˆāđ„āļ”āđ‰ Login āđ€āļ‚āđ‰āļēāļĢāļ°āļšāļš + /// āđ€āļĄāļ·āđˆāļ­āđ€āļāļīāļ”āļ‚āđ‰āļ­āļœāļīāļ”āļžāļĨāļēāļ”āđƒāļ™āļāļēāļĢāļ—āļģāļ‡āļēāļ™ + [HttpGet("24/{exportType}/{id}")] + public async Task> 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 āļŦāļ™āļąāļ‡āļŠāļ·āļ­āļ–āļķāļ‡āļŠāđāļēāļ™āļąāļāļ‡āļēāļ™āļāļēāļĢāđ€āļˆāđ‰āļēāļŦāļ™āđ‰āļēāļ—āļĩāđˆ āļŠāđāļēāļ™āļąāļāļ›āļĨāļąāļ”āļāļĢāļļāļ‡āđ€āļ—āļžāļĄāļŦāļēāļ™āļ„āļĢāđ€āļžāļ·āđˆāļ­āļ‚āļ­āļ•āļĢāļ§āļˆāļŠāļ­āļšāļžāļĪāļ•āļīāļāļēāļĢāļ“āđŒāļ—āļēāļ‡āļ§āļīāļ™āļąāļĒ āđāļĨāļ°āļ āļēāļĢāļ°āļŦāļ™āļĩāđ‰āļŠāļīāļ™āļŠāļ§āļąāļŠāļ”āļīāļāļēāļĢ + /// + /// āļŦāļ™āļąāļ‡āļŠāļ·āļ­āļ–āļķāļ‡āļŠāđāļēāļ™āļąāļāļ‡āļēāļ™āļāļēāļĢāđ€āļˆāđ‰āļēāļŦāļ™āđ‰āļēāļ—āļĩāđˆ āļŠāđāļēāļ™āļąāļāļ›āļĨāļąāļ”āļāļĢāļļāļ‡āđ€āļ—āļžāļĄāļŦāļēāļ™āļ„āļĢāđ€āļžāļ·āđˆāļ­āļ‚āļ­āļ•āļĢāļ§āļˆāļŠāļ­āļšāļžāļĪāļ•āļīāļāļēāļĢāļ“āđŒāļ—āļēāļ‡āļ§āļīāļ™āļąāļĒ āđāļĨāļ°āļ āļēāļĢāļ°āļŦāļ™āļĩāđ‰āļŠāļīāļ™āļŠāļ§āļąāļŠāļ”āļīāļāļēāļĢ + /// + /// id + /// pdf, docx āļŦāļĢāļ·āļ­ xlsx + /// + /// āđ€āļĄāļ·āđˆāļ­āļ—āļģāļāļēāļĢāļ­āđˆāļēāļ™āļ‚āđ‰āļ­āļĄāļđāļĨāļˆāļēāļ Relational Database āļŠāļģāđ€āļĢāđ‡āļˆ + /// āđ„āļĄāđˆāđ„āļ”āđ‰ Login āđ€āļ‚āđ‰āļēāļĢāļ°āļšāļš + /// āđ€āļĄāļ·āđˆāļ­āđ€āļāļīāļ”āļ‚āđ‰āļ­āļœāļīāļ”āļžāļĨāļēāļ”āđƒāļ™āļāļēāļĢāļ—āļģāļ‡āļēāļ™ + [HttpGet("25/{exportType}/{id}")] + public async Task> 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 āļŦāļ™āļąāļ‡āļŠāļ·āļ­āļ–āļķāļ‡āļŠāļ–āļēāļšāļąāļ™āļžāļąāļ’āļ™āļēāļ‚āđ‰āļēāļĢāļēāļŠāļāļēāļĢāļāļĢāļļāļ‡āđ€āļ—āļžāļĄāļŦāļēāļ™āļ„āļĢāđ€āļžāļ·āđˆāļ­āļ‚āļ­āļ•āļĢāļ§āļˆāļŠāļ­āļšāđ€āļĢāļ·āđˆāļ­āļ‡āļ āļēāļĢāļ°āļœāļđāļāļžāļąāļ™āļāļēāļĢāļĢāļąāļšāļ—āļļāļ™āđāļĨāļ°āļāļēāļĢāļĨāļē āļĻāļķāļāļĐāļēāļ•āđˆāļ­āļāļąāļšāļ—āļēāļ‡āļāļĢāļļāļ‡āđ€āļ—āļžāļĄāļŦāļēāļ™āļ„āļĢ + /// + /// āļŦāļ™āļąāļ‡āļŠāļ·āļ­āļ–āļķāļ‡āļŠāļ–āļēāļšāļąāļ™āļžāļąāļ’āļ™āļēāļ‚āđ‰āļēāļĢāļēāļŠāļāļēāļĢāļāļĢāļļāļ‡āđ€āļ—āļžāļĄāļŦāļēāļ™āļ„āļĢāđ€āļžāļ·āđˆāļ­āļ‚āļ­āļ•āļĢāļ§āļˆāļŠāļ­āļšāđ€āļĢāļ·āđˆāļ­āļ‡āļ āļēāļĢāļ°āļœāļđāļāļžāļąāļ™āļāļēāļĢāļĢāļąāļšāļ—āļļāļ™āđāļĨāļ°āļāļēāļĢāļĨāļē āļĻāļķāļāļĐāļēāļ•āđˆāļ­āļāļąāļšāļ—āļēāļ‡āļāļĢāļļāļ‡āđ€āļ—āļžāļĄāļŦāļēāļ™āļ„āļĢ + /// + /// id + /// pdf, docx āļŦāļĢāļ·āļ­ xlsx + /// + /// āđ€āļĄāļ·āđˆāļ­āļ—āļģāļāļēāļĢāļ­āđˆāļēāļ™āļ‚āđ‰āļ­āļĄāļđāļĨāļˆāļēāļ Relational Database āļŠāļģāđ€āļĢāđ‡āļˆ + /// āđ„āļĄāđˆāđ„āļ”āđ‰ Login āđ€āļ‚āđ‰āļēāļĢāļ°āļšāļš + /// āđ€āļĄāļ·āđˆāļ­āđ€āļāļīāļ”āļ‚āđ‰āļ­āļœāļīāļ”āļžāļĨāļēāļ”āđƒāļ™āļāļēāļĢāļ—āļģāļ‡āļēāļ™ + [HttpGet("26/{exportType}/{id}")] + public async Task> 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 } } diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementController.cs index 5d5b5306..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", @@ -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(); + /// + /// āđ€āļāļĐāļĩāļĒāļ“āļ­āļēāļĒāļļāļĢāļēāļŠāļāļēāļĢ + /// + /// āļ›āļĢāļ°āđ€āļ āļ—User(officer,employee)(āļ•āļąāļ§āđƒāļŦāļāđˆāļŦāļĢāļ·āļ­āđ€āļĨāđ‡āļāļāđ‡āđ„āļ”āđ‰) + /// āļ›āļĩāļ‡āļšāļ›āļĢāļ°āļĄāļēāļ“(āļ„.āļĻ.) + /// + /// + /// āļ„āđˆāļēāļ•āļąāļ§āđāļ›āļĢāļ—āļĩāđˆāļŠāđˆāļ‡āļĄāļēāđ„āļĄāđˆāļ–āļđāļāļ•āđ‰āļ­āļ‡ + /// āđ„āļĄāđˆāđ„āļ”āđ‰ Login āđ€āļ‚āđ‰āļēāļĢāļ°āļšāļš + /// āđ€āļĄāļ·āđˆāļ­āđ€āļāļīāļ”āļ‚āđ‰āļ­āļœāļīāļ”āļžāļĨāļēāļ”āđƒāļ™āļāļēāļĢāļ—āļģāļ‡āļēāļ™ + [HttpGet("update-status/{type}/{year}")] + public async Task> 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-āļ›āļĢāļ°āļāļēāļĻāđ€āļāļĐāļĩāļĒāļ“āļĨāļđāļāļˆāđ‰āļēāļ‡āļ›āļĢāļ°āļˆāļģ + /// + /// 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/RetirementDeceasedController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementDeceasedController.cs index 9ebcf854..7f47b570 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementDeceasedController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementDeceasedController.cs @@ -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(); } + /// + /// 36-āļšāļąāļ™āļ—āļķāļāđ€āļ§āļĩāļĒāļ™āđāļˆāđ‰āļ‡āļāļēāļĢāļ–āļķāļ‡āđāļāđˆāļāļĢāļĢāļĄ + /// + /// Id āļĢāļēāļĒāļāļēāļĢāļšāļąāļ™āļ—āļķāļāđ€āļ§āļĩāļĒāļ™āđāļˆāđ‰āļ‡āļāļēāļĢāļ–āļķāļ‡āđāļāđˆāļāļĢāļĢāļĄ + /// pdf, docx āļŦāļĢāļ·āļ­ xlsx + /// + /// āđ€āļĄāļ·āđˆāļ­āļ—āļģāļāļēāļĢāļ­āđˆāļēāļ™āļ‚āđ‰āļ­āļĄāļđāļĨāļˆāļēāļ Relational Database āļŠāļģāđ€āļĢāđ‡āļˆ + /// āđ„āļĄāđˆāđ„āļ”āđ‰ Login āđ€āļ‚āđ‰āļēāļĢāļ°āļšāļš + /// āđ€āļĄāļ·āđˆāļ­āđ€āļāļīāļ”āļ‚āđ‰āļ­āļœāļīāļ”āļžāļĨāļēāļ”āđƒāļ™āļāļēāļĢāļ—āļģāļ‡āļēāļ™ + [HttpGet("36/{exportType}/{id}")] + public async Task> 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; + } + } } } 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 } } diff --git a/BMA.EHR.Retirement.Service/Program.cs b/BMA.EHR.Retirement.Service/Program.cs index eb586a04..fc121e82 100644 --- a/BMA.EHR.Retirement.Service/Program.cs +++ b/BMA.EHR.Retirement.Service/Program.cs @@ -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(); + app.UseHangfireDashboard("/hangfire", new DashboardOptions() { Authorization = new[] { new CustomAuthorizeFilter() } }); + var manager = new RecurringJobManager(); if (manager != null) { //manager.AddOrUpdate("āđāļˆāđ‰āļ‡āđ€āļ•āļ·āļ­āļ™āļĢāļ°āļšāļšāļ›āļĨāļ”āļ­āļ­āļ", Job.FromExpression(x => x.NotifyDischarge()), Cron.Daily(Int32.Parse(builder.Configuration["KeycloakCron:Hour"]), Int32.Parse(builder.Configuration["KeycloakCron:Minute"])), TimeZoneInfo.Local); //manager.AddOrUpdate("āđāļˆāđ‰āļ‡āđ€āļ•āļ·āļ­āļ™āļĢāļ°āļšāļšāđ„āļĨāđˆāļ­āļ­āļ", Job.FromExpression(x => x.NotifyExpulsion()), Cron.Daily(Int32.Parse(builder.Configuration["KeycloakCron:Hour"]), Int32.Parse(builder.Configuration["KeycloakCron:Minute"])), TimeZoneInfo.Local); //manager.AddOrUpdate("āđāļˆāđ‰āļ‡āđ€āļ•āļ·āļ­āļ™āļĢāļ°āļšāļšāđƒāļŦāđ‰āļ­āļ­āļ", Job.FromExpression(x => x.NotifyOut()), Cron.Daily(Int32.Parse(builder.Configuration["KeycloakCron:Hour"]), Int32.Parse(builder.Configuration["KeycloakCron:Minute"])), TimeZoneInfo.Local); - manager.AddOrUpdate("āļ­āļąāļžāđ€āļ”āļ—āļŠāļ–āļēāļ™āļ°āđ€āļāļĐāļĩāļĒāļ“āļ­āļēāļĒāļļāļĢāļēāļŠāļāļēāļĢ", Job.FromExpression(x => x.ExecuteRetirement()), Cron.Yearly(10, 1, 0, 0), TimeZoneInfo.Local); - //manager.AddOrUpdate("Test āļ­āļąāļžāđ€āļ”āļ—āļŠāļ–āļēāļ™āļ°āđ€āļāļĐāļĩāļĒāļ“āļ­āļēāļĒāļļāļĢāļēāļŠāļāļēāļĢ", Job.FromExpression(x => x.ExecuteRetirement()), Cron.Yearly(10, 1, 0, 0), TimeZoneInfo.Local); + //manager.AddOrUpdate("āļ­āļąāļžāđ€āļ”āļ—āļŠāļ–āļēāļ™āļ°āđ€āļāļĐāļĩāļĒāļ“āļ­āļēāļĒāļļāļĢāļēāļŠāļāļēāļĢ", Job.FromExpression(x => x.ExecuteRetirement()), Cron.Yearly(10, 1, 0, 0), TimeZoneInfo.Local); + manager.AddOrUpdate("āļ—āļ”āļŠāļ­āļš", Job.FromExpression(x => x.TestMethod()), Cron.Yearly(10, 1, 0, 0), TimeZoneInfo.Local); } // apply migrations