diff --git a/.github/workflows/release_insignia.yaml b/.github/workflows/release_insignia.yaml index cf64e4ef..4d41ff08 100644 --- a/.github/workflows/release_insignia.yaml +++ b/.github/workflows/release_insignia.yaml @@ -73,18 +73,18 @@ jobs: - uses: snow-actions/line-notify@v1.1.0 if: success() with: - access_token: ${{ secrets.TOKEN_LINE }} - message: | - -Success✅✅✅ - Image: ${{env.IMAGE_NAME}} - Version: ${{ steps.gen_ver.outputs.IMAGE_VER }} - By: ${{secrets.DOCKER_USER}} + access_token: ${{ env.TOKEN_LINE }} + message: | + -Success✅✅✅ + Image: ${{env.IMAGE_NAME}} + Version: ${{ github.event.inputs.IMAGE_VER }} + By: ${{secrets.DOCKER_USER}} - uses: snow-actions/line-notify@v1.1.0 if: failure() with: - access_token: ${{ secrets.TOKEN_LINE }} - message: | - -Failure❌❌❌ - Image: ${{env.IMAGE_NAME}} - Version: ${{ steps.gen_ver.outputs.IMAGE_VER }} - By: ${{secrets.DOCKER_USER}} \ No newline at end of file + access_token: ${{ env.TOKEN_LINE }} + message: | + -Failure❌❌❌ + Image: ${{env.IMAGE_NAME}} + Version: ${{ github.event.inputs.IMAGE_VER }} + By: ${{secrets.DOCKER_USER}} \ No newline at end of file diff --git a/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs b/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs index 7785e6ce..807112ff 100644 --- a/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs +++ b/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs @@ -994,12 +994,12 @@ namespace BMA.EHR.Application.Repositories.Reports { var insigniaPeriods = await _dbContext.Set() .AsQueryable() - .Include(x => x.InsigniaRequests) - .Include(x => x.ReliefDoc) + .Include(x => x.InsigniaRequests) + .Include(x => x.ReliefDoc) .ToListAsync(); foreach (var insigniaPeriod in insigniaPeriods) { - if (insigniaPeriod.EndDate.Date.AddDays(5) < DateTime.Now.Date) + if (insigniaPeriod.EndDate.Date.AddDays(5) > DateTime.Now.Date) continue; insigniaPeriod.IsLock = true; var insigniaNote = await _dbContext.Set() @@ -1103,14 +1103,15 @@ namespace BMA.EHR.Application.Repositories.Reports .ToListAsync(); foreach (var insigniaPeriod in insigniaPeriods) { - if (insigniaPeriod.StartDate == DateTime.Now.Date) + if (insigniaPeriod.StartDate >= DateTime.Now.Date) continue; //var organizationType = await _dbContext.Set().Where(x => x.Name == "หน่วยงาน").FirstOrDefaultAsync(); //if (organizationType == null) // continue; //var organizations = await _dbContext.Set().Where(x => x.OrganizationType == organizationType).ToListAsync(); - var organizations = await _userProfileRepository.GetActiveRootLatestAsync(AccessToken); - Console.WriteLine(JsonConvert.SerializeObject(organizations)); + var organizations = await _userProfileRepository.GetActiveRootLatestAsync(null); + if(organizations == null) + continue; foreach (var organization in organizations) { if (organization == null) diff --git a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs index 264d7355..4f6f38b4 100644 --- a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs +++ b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs @@ -377,7 +377,7 @@ namespace BMA.EHR.Insignia.Service.Controllers Document = result.Document, Items = new List() }; - GetIsOfficerDto RoleInsignia = await _userProfileRepository.GetIsOfficerRootAsync(AccessToken, "INSIGNIA"); + GetIsOfficerDto RoleInsignia = await _userProfileRepository.GetIsOfficerRootAsync(AccessToken, "SYS_INSIGNIA_MANAGE"); if (RoleInsignia.isOfficer == true && result.RequestStatus != "st6") return Success(resend); if (RoleInsignia.isDirector == true && (result.RequestStatus == "st1" || result.RequestStatus == "st2")) @@ -976,7 +976,7 @@ namespace BMA.EHR.Insignia.Service.Controllers var orgAllCount = await _context.InsigniaRequests .Where(x => x.Period == insigniaPeriod) .ToListAsync(); - GetIsOfficerDto RoleInsignia = await _userProfileRepository.GetIsOfficerRootAsync(AccessToken, "INSIGNIA"); + GetIsOfficerDto RoleInsignia = await _userProfileRepository.GetIsOfficerRootAsync(AccessToken, "SYS_INSIGNIA_MANAGE"); var allUserUser = await _context.InsigniaRequests .Where(x => x.Period == insigniaPeriod) .Where(x => RoleInsignia.isOfficer == true ? x.RequestStatus == "st6" : (RoleInsignia.isDirector == true ? (x.RequestStatus != "st1" && x.RequestStatus != "st2") : x.Id != null)) diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs index 635a8e6f..60af42f5 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs @@ -525,7 +525,6 @@ namespace BMA.EHR.Placement.Service.Controllers if (org == null || org.result == null) return Error("ไม่พบหน่วยงานนี้ในระบบ", 404); - uppdated.root = org.result.root; uppdated.rootId = org.result.rootId; uppdated.rootShortName = org.result.rootShortName; @@ -543,6 +542,18 @@ namespace BMA.EHR.Placement.Service.Controllers uppdated.child4ShortName = req.node <= 3 ? null : org.result.child4ShortName; } + var apiUrlUpdate = $"{_configuration["API"]}/org/pos/officer/master-old/book"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _resUpdate = await client.PostAsJsonAsync(apiUrlUpdate, new + { + posMasterOldId = uppdated.posmasterId, + posMasterId = req.posmasterId, + profileId = req.profileId, + }); + } uppdated.typeCommand = req.typeCommand == null ? null : req.typeCommand.Trim().ToUpper(); uppdated.posmasterId = req.posmasterId; uppdated.node = req.node; diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentEmployeeController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentEmployeeController.cs index bad1918c..b02dcaca 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentEmployeeController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentEmployeeController.cs @@ -574,6 +574,18 @@ namespace BMA.EHR.Placement.Service.Controllers uppdated.child4ShortName = req.node <= 3 ? null : org.result.child4ShortName; } + var apiUrlUpdate = $"{_configuration["API"]}/org/pos/employee/master-old/book"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _resUpdate = await client.PostAsJsonAsync(apiUrlUpdate, new + { + posMasterOldId = uppdated.posmasterId, + posMasterId = req.posmasterId, + profileId = req.profileId, + }); + } uppdated.typeCommand = req.typeCommand == null ? null : req.typeCommand.Trim().ToUpper(); uppdated.posmasterId = req.posmasterId; uppdated.node = req.node; diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index e7ce9971..e9362685 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -884,6 +884,18 @@ namespace BMA.EHR.Placement.Service.Controllers person.child4ShortName = req.node <= 3 ? null : org.result.child4ShortName; } + + var apiUrlUpdate = $"{_configuration["API"]}/org/pos/officer/master/book"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _resUpdate = await client.PostAsJsonAsync(apiUrlUpdate, new + { + posMasterId = req.posmasterId, + profileId = req.profileId, + }); + } person.Draft = false; person.typeCommand = req.typeCommand == null ? null : req.typeCommand.Trim().ToUpper(); person.ReportingDate = req.reportingDate; @@ -1254,6 +1266,16 @@ namespace BMA.EHR.Placement.Service.Controllers if (profile == null) return Error(GlobalMessages.DataNotFound, 404); + var apiUrlUpdate = $"{_configuration["API"]}/org/pos/officer/master/clear"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _resUpdate = await client.PostAsJsonAsync(apiUrlUpdate, new + { + posMasterId = profile.posmasterId, + }); + } profile.root = null; profile.rootId = null; profile.rootShortName = null; diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs index 08936630..5f7560be 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs @@ -643,6 +643,18 @@ namespace BMA.EHR.Placement.Service.Controllers uppdated.child4ShortName = req.node <= 3 ? null : org.result.child4ShortName; } + var apiUrlUpdate = $"{_configuration["API"]}/org/pos/officer/master-old/book"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); + var _resUpdate = await client.PostAsJsonAsync(apiUrlUpdate, new + { + posMasterOldId = uppdated.posmasterId, + posMasterId = req.posmasterId, + profileId = req.profileId, + }); + } uppdated.posmasterId = req.posmasterId; uppdated.node = req.node; uppdated.nodeId = req.nodeId; diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementDeceasedController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementDeceasedController.cs index 01bcd391..91202163 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementDeceasedController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementDeceasedController.cs @@ -81,39 +81,25 @@ namespace BMA.EHR.Retirement.Service.Controllers [HttpGet()] public async Task> GetList() { - var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_PASSAWAY"); + var getPermission = await _permission.GetPermissionOrgAPIAsync("LIST", "SYS_PASSAWAY", UserId); var jsonData = JsonConvert.DeserializeObject(getPermission); if (jsonData["status"]?.ToString() != "200") { return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); } - var rootId = ""; - var child1Id = ""; - var child2Id = ""; - var child3Id = ""; - var child4Id = ""; - var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); - var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var _res = await client.SendAsync(_req); - var _result = await _res.Content.ReadAsStringAsync(); - var org = JsonConvert.DeserializeObject(_result); - - if (org == null || org.result == null) - return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404); - rootId = org.result.rootId == null ? "" : org.result.rootId; - child1Id = org.result.child1Id == null ? "" : org.result.child1Id; - child2Id = org.result.child2Id == null ? "" : org.result.child2Id; - child3Id = org.result.child3Id == null ? "" : org.result.child3Id; - child4Id = org.result.child4Id == null ? "" : org.result.child4Id; - - var retirementDeceaseds = await _context.RetirementDeceaseds.AsQueryable() - .OrderByDescending(x => x.CreatedAt) - .Where(x => rootId == "" ? true : (child1Id == "" ? x.rootId == rootId : (child2Id == "" ? x.child1Id == child1Id : (child3Id == "" ? x.child2Id == child2Id : (child4Id == "" ? x.child3Id == child3Id : x.child4Id == child4Id))))) + string?[] rootId = jsonData?.result?.rootId ?? null; + string?[] child1Id = jsonData?.result?.child1Id ?? null; + string?[] child2Id = jsonData?.result?.child2Id ?? null; + string?[] child3Id = jsonData?.result?.child3Id ?? null; + string?[] child4Id = jsonData?.result?.child4Id ?? null; + var retirementDeceaseds = await _context.RetirementDeceaseds.AsQueryable() + .OrderByDescending(x => x.CreatedAt) + .Where(x => rootId == null ? true : rootId.Contains(x.rootId)) + .Where(x => child1Id == null ? true : child1Id.Contains(x.child1Id)) + .Where(x => child2Id == null ? true : child2Id.Contains(x.child2Id)) + .Where(x => child3Id == null ? true : child3Id.Contains(x.child3Id)) + .Where(x => child4Id == null ? true : child4Id.Contains(x.child4Id)) .Select(p => new { p.Id, @@ -140,36 +126,7 @@ namespace BMA.EHR.Retirement.Service.Controllers p.IsActive, }) .ToListAsync(); - // var _retirementDeceaseds = new List(); - // foreach (var data in retirementDeceaseds) - // { - // var _data = new - // { - // data.Id, - // data.ProfileId, - // data.Prefix, - // data.FirstName, - // data.LastName, - // data.Position, - // data.PositionExecutive, - // data.PositionType, - // data.PositionLine, - // data.PositionLevel, - // data.Organization, - // data.Number, - // data.Date, - // data.Location, - // data.Reason, - // data.FileName, - // PathName = data.PathName == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(data.PathName), - // data.IsActive, - // data.CreatedAt, - // }; - // _retirementDeceaseds.Add(_data); - // } return Success(retirementDeceaseds); - } - } ///