From b19ea831b66045207a33b3a5b01ace7032ce821f Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Fri, 4 Aug 2023 17:32:33 +0700 Subject: [PATCH 1/5] fix incorrect api endpoint --- BMA.EHR.Command.Service/Controllers/OrderController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs index 1da064da..7e6f8154 100644 --- a/BMA.EHR.Command.Service/Controllers/OrderController.cs +++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs @@ -547,7 +547,7 @@ namespace BMA.EHR.Command.Service.Controllers /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpGet("persons/{personalId}")] + [HttpGet("copy-order/{orderId}")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] From 10207e76f07f1dd65137c26e7bc28067c8e0e1d2 Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Mon, 7 Aug 2023 11:53:11 +0700 Subject: [PATCH 2/5] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B8=A3?= =?UTF-8?q?=E0=B8=B2=E0=B8=A2=E0=B8=8A=E0=B8=B7=E0=B9=88=E0=B8=AD=E0=B9=81?= =?UTF-8?q?=E0=B8=99=E0=B8=9A=E0=B8=97=E0=B9=89=E0=B8=B2=E0=B8=A2=E0=B9=84?= =?UTF-8?q?=E0=B8=A1=E0=B9=88=E0=B9=81=E0=B8=AA=E0=B8=94=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApplicationServicesRegistration.cs | 1 + .../Commands/CommandRepository.cs | 27 +++++++-- .../Repositories/UserProfileRepository.cs | 55 +++++++++++++++++++ .../Controllers/OrderController.cs | 31 ++++++++--- .../Organizations/OrganizationEntity.cs | 7 +-- 5 files changed, 106 insertions(+), 15 deletions(-) create mode 100644 BMA.EHR.Application/Repositories/UserProfileRepository.cs diff --git a/BMA.EHR.Application/ApplicationServicesRegistration.cs b/BMA.EHR.Application/ApplicationServicesRegistration.cs index 831d94a5..afabdaa2 100644 --- a/BMA.EHR.Application/ApplicationServicesRegistration.cs +++ b/BMA.EHR.Application/ApplicationServicesRegistration.cs @@ -18,6 +18,7 @@ namespace BMA.EHR.Application services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); return services; } diff --git a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs index 2be308d1..d683dacd 100644 --- a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs +++ b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs @@ -5,10 +5,8 @@ using BMA.EHR.Domain.Models.MetaData; using BMA.EHR.Domain.Models.Organizations; using BMA.EHR.Domain.Models.Placement; using BMA.EHR.Domain.Shared; -using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Http; using Microsoft.EntityFrameworkCore; -using System.Transactions; using Command = BMA.EHR.Domain.Models.Commands.Core.Command; namespace BMA.EHR.Application.Repositories.Commands @@ -93,7 +91,7 @@ namespace BMA.EHR.Application.Repositories.Commands throw new Exception(GlobalMessages.CommandNotFound); else { - if (command.Receivers != null || command!.Receivers!.Count > 0) + if (command.Receivers != null && command!.Receivers!.Count > 0) { return command.Receivers; } @@ -110,9 +108,10 @@ namespace BMA.EHR.Application.Repositories.Commands // 2. Query var appointPeople = await _dbContext.Set() + .Include(x => x.Prefix) .Include(x => x.OrganizationPosition) .ThenInclude(x => x.Organization) - //.Where(x => x.OrganizationPosition.Organization.Id ) + //.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId) .Where(x => !otherCommandReceivers.Contains(x.CitizenId!)) .Where(x => x.PlacementStatus.Trim().ToUpper() == "PREPARE-CONTAIN") .Where(x => x.Draft! == true) @@ -624,6 +623,26 @@ namespace BMA.EHR.Application.Repositories.Commands } } + //public async Task GetRootOcIdAsync(Guid ocId) + //{ + // try + // { + // var data = await _dbContext.Set().AsQueryable() + + + // .FirstOrDefaultAsync(o => o.Id == ocId); + + // if(data == null) + // throw new Exception(GlobalMessages.OrganizationNotFound); + + // return data.Government!.Id + // } + // catch + // { + // throw; + // } + //} + #endregion } diff --git a/BMA.EHR.Application/Repositories/UserProfileRepository.cs b/BMA.EHR.Application/Repositories/UserProfileRepository.cs new file mode 100644 index 00000000..544f01b8 --- /dev/null +++ b/BMA.EHR.Application/Repositories/UserProfileRepository.cs @@ -0,0 +1,55 @@ +using BMA.EHR.Application.Common.Interfaces; +using BMA.EHR.Domain.Models.HR; +using BMA.EHR.Domain.Models.Organizations; +using BMA.EHR.Domain.Shared; +using Microsoft.AspNetCore.Http; +using Microsoft.EntityFrameworkCore; + +namespace BMA.EHR.Application.Repositories +{ + public class UserProfileRepository : GenericRepository + { + #region " Fields " + + private readonly IApplicationDBContext _dbContext; + private readonly IHttpContextAccessor _httpContextAccessor; + + #endregion + + #region " Costructor and Destructor " + + public UserProfileRepository(IApplicationDBContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor) + { + _dbContext = dbContext; + _httpContextAccessor = httpContextAccessor; + } + + #endregion + + #region " Methods " + + public Guid GetUserOCId(Guid keycloakId) + { + try + { + var data = _dbContext.Set() + .Include(x => x.Profile) + .Include(x => x.OrganizationPosition) + .ThenInclude(x => x.Organization) + .Where(x => x.Profile!.KeycloakId == keycloakId) + .FirstOrDefault(); + + if (data == null) + throw new Exception(GlobalMessages.DataNotFound); + + return data.OrganizationPosition!.Organization!.Id; + } + catch + { + throw; + } + } + + #endregion + } +} diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs index 7e6f8154..e76d7b34 100644 --- a/BMA.EHR.Command.Service/Controllers/OrderController.cs +++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs @@ -1,16 +1,13 @@ -using Amazon.S3.Model.Internal.MarshallTransformations; -using BMA.EHR.Application.Repositories; +using BMA.EHR.Application.Repositories; using BMA.EHR.Application.Repositories.Commands; using BMA.EHR.Application.Requests.Commands; using BMA.EHR.Command.Service.Requests; using BMA.EHR.Domain.Common; using BMA.EHR.Domain.Extensions; using BMA.EHR.Domain.Models.Commands.Core; -using BMA.EHR.Domain.Models.MetaData; using BMA.EHR.Domain.Shared; using BMA.EHR.Infrastructure.Persistence; using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Components.Forms; using Microsoft.AspNetCore.Mvc; using Swashbuckle.AspNetCore.Annotations; using System.Security.Claims; @@ -35,6 +32,7 @@ namespace BMA.EHR.Command.Service.Controllers private readonly PrefixRepository _prefixRepository; private readonly CommandTypeRepository _commandTypeRepository; private readonly CommandStatusRepository _commandStatusRepository; + private readonly UserProfileRepository _userProfileRepository; #endregion @@ -47,7 +45,8 @@ namespace BMA.EHR.Command.Service.Controllers IHttpContextAccessor httpContextAccessor, PrefixRepository prefixRepository, CommandTypeRepository commandTypeRepository, - CommandStatusRepository commandStatusRepository) + CommandStatusRepository commandStatusRepository, + UserProfileRepository userProfileRepository) { _repository = repository; _context = context; @@ -57,6 +56,7 @@ namespace BMA.EHR.Command.Service.Controllers _prefixRepository = prefixRepository; _commandTypeRepository = commandTypeRepository; _commandStatusRepository = commandStatusRepository; + _userProfileRepository = userProfileRepository; } #endregion @@ -69,6 +69,17 @@ namespace BMA.EHR.Command.Service.Controllers private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1"); + private Guid OcId + { + get + { + if (UserId != null || UserId != "") + return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!)); + else + return Guid.Empty; + } + } + #endregion #region " Methods " @@ -382,7 +393,9 @@ namespace BMA.EHR.Command.Service.Controllers ConclusionRegisterDate = req.conclusionRegisterDate, ConclusionResultNo = req.conclusionResultNo, ConclusionResultDate = req.conclusionResultDate, - CommandAffectDate = req.orderDate + CommandAffectDate = req.orderDate, + OwnerGovId = OcId + }; var result = await _repository.AddAsync(inserted); @@ -496,6 +509,7 @@ namespace BMA.EHR.Command.Service.Controllers { // TODO : หาค่า Education มาแสดง var receivers = (await _repository.GetReceiverByCommmandIdAsync(orderId)) + .OrderBy(x => x.Sequence) .Select(r => new { personId = r.Id, @@ -515,8 +529,11 @@ namespace BMA.EHR.Command.Service.Controllers } /// - /// PM7-27 : ข้อมูลเลือกรายชื่อออกคำสั่ง + /// PM7-27 : ข้อมูลเลือกรายชื่อออกคำสั่ง ** ยังไม่ได้กรองหน่วยงาน ** /// + /// + /// ** ยังไม่ได้กรองหน่วยงาน ** + /// /// Record Id ของผู้รับคำสั่งในรายการบัญชีแนบท้าย /// /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ diff --git a/BMA.EHR.Domain/Models/Organizations/OrganizationEntity.cs b/BMA.EHR.Domain/Models/Organizations/OrganizationEntity.cs index 21fb8e24..d67abbe9 100644 --- a/BMA.EHR.Domain/Models/Organizations/OrganizationEntity.cs +++ b/BMA.EHR.Domain/Models/Organizations/OrganizationEntity.cs @@ -1,8 +1,7 @@ -using Microsoft.EntityFrameworkCore; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using BMA.EHR.Domain.Models.Base; +using BMA.EHR.Domain.Models.Base; using BMA.EHR.Domain.Models.MetaData; +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations.Schema; namespace BMA.EHR.Domain.Models.Organizations { From c6ddcf0bfa4ca9f4380e53fd44a1202f6b568f46 Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Mon, 7 Aug 2023 13:48:29 +0700 Subject: [PATCH 3/5] Change Code --- .../Repositories/Commands/CommandRepository.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs index d683dacd..79a2eb89 100644 --- a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs +++ b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs @@ -628,14 +628,14 @@ namespace BMA.EHR.Application.Repositories.Commands // try // { // var data = await _dbContext.Set().AsQueryable() - - + + // .FirstOrDefaultAsync(o => o.Id == ocId); - // if(data == null) + // if (data == null) // throw new Exception(GlobalMessages.OrganizationNotFound); - // return data.Government!.Id + // return data // } // catch // { From 72c53c2e42bdeecb5da5aa3a1a734205dd60cc98 Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Mon, 7 Aug 2023 14:57:23 +0700 Subject: [PATCH 4/5] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1=20api=20=E0=B9=81=E0=B8=AA=E0=B8=94=E0=B8=87=E0=B8=82?= =?UTF-8?q?=E0=B9=89=E0=B8=AD=E0=B8=A1=E0=B8=B9=E0=B8=A5=E0=B9=80=E0=B8=87?= =?UTF-8?q?=E0=B8=B4=E0=B8=99=E0=B9=80=E0=B8=94=E0=B8=B7=E0=B8=AD=E0=B8=99?= =?UTF-8?q?=E0=B8=97=E0=B8=B5=E0=B9=88=E0=B8=9A=E0=B8=B1=E0=B8=99=E0=B8=97?= =?UTF-8?q?=E0=B8=B6=E0=B8=81=E0=B9=83=E0=B8=99=E0=B8=A3=E0=B8=B0=E0=B8=9A?= =?UTF-8?q?=E0=B8=9A=E0=B8=AA=E0=B8=A3=E0=B8=A3=E0=B8=AB=E0=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Commands/CommandRepository.cs | 199 +++++++++++++----- .../Responses/CommandInfoResponse.cs | 11 + .../Responses/PlacementSalaryResponse.cs | 11 + .../Controllers/OrderController.cs | 55 ++++- .../Responses/CommandReceiverResponse.cs | 25 +++ BMA.EHR.Domain/Shared/GlobalMessages.cs | 2 + 6 files changed, 236 insertions(+), 67 deletions(-) create mode 100644 BMA.EHR.Application/Responses/CommandInfoResponse.cs create mode 100644 BMA.EHR.Application/Responses/PlacementSalaryResponse.cs create mode 100644 BMA.EHR.Command.Service/Responses/CommandReceiverResponse.cs diff --git a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs index 79a2eb89..be7817a9 100644 --- a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs +++ b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs @@ -1,5 +1,7 @@ using BMA.EHR.Application.Common.Interfaces; using BMA.EHR.Application.Requests.Commands; +using BMA.EHR.Application.Responses; +using BMA.EHR.Domain.Extensions; using BMA.EHR.Domain.Models.Commands.Core; using BMA.EHR.Domain.Models.MetaData; using BMA.EHR.Domain.Models.Organizations; @@ -33,6 +35,77 @@ namespace BMA.EHR.Application.Repositories.Commands #region " Methods " + #region " Private " + + private async Task GetReceiverForByCommndTypeAsync(Command command) + { + switch (command.CommandType.Category.Trim().ToUpper()) + { + case "C-PM-01": + await GetReceiver01(command); + break; + default: throw new Exception(GlobalMessages.MethodForCommandTypeNotImplement); + } + } + + /// + /// C-PM-01 + /// + /// + /// + private async Task GetReceiver01(Command command) + { + try + { + // 1. หารายชื่อที่ถูกเลือกไปแล้ว ในประเภทเดียวกัน + var otherCommandReceivers = await _dbContext.Set() + .Include(x => x.Command) + .ThenInclude(x => x.CommandType) + .Where(x => x.Command.CommandType.CommandCode.Trim().ToUpper() == "C-PM-01") + .Where(x => x.Id != command.Id) + .Select(x => x.CitizenId) + .ToListAsync(); + + // 2. Query + var appointPeople = await _dbContext.Set() + .Include(x => x.Prefix) + .Include(x => x.OrganizationPosition) + .ThenInclude(x => x.Organization) + //.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId) + .Where(x => !otherCommandReceivers.Contains(x.CitizenId!)) + .Where(x => x.PlacementStatus.Trim().ToUpper() == "PREPARE-CONTAIN") + .Where(x => x.Draft! == true) + .OrderBy(x => x.ExamNumber) + .ToListAsync(); + + // 3. Create new Record + var seq = 1; + foreach (var item in appointPeople) + { + + var receiver = new CommandReceiver + { + Sequence = seq, + CitizenId = item.CitizenId!, + Prefix = item.Prefix!.Name, + FirstName = item.Firstname!, + LastName = item.Lastname!, + RefPlacementProfileId = item.Id + }; + seq++; + + command.Receivers.Add(receiver); + } + await _dbContext.SaveChangesAsync(); + } + catch + { + throw; + } + } + + #endregion + #region " Override " public override async Task GetByIdAsync(Guid id) @@ -97,49 +170,10 @@ namespace BMA.EHR.Application.Repositories.Commands } else { - // 1. หารายชื่อที่ถูกเลือกไปแล้ว ในประเภทเดียวกัน - var otherCommandReceivers = await _dbContext.Set() - .Include(x => x.Command) - .ThenInclude(x => x.CommandType) - .Where(x => x.Command.CommandType.CommandCode.Trim().ToUpper() == "C-PM-01") - .Where(x => x.Id != Id) - .Select(x => x.CitizenId) - .ToListAsync(); - - // 2. Query - var appointPeople = await _dbContext.Set() - .Include(x => x.Prefix) - .Include(x => x.OrganizationPosition) - .ThenInclude(x => x.Organization) - //.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId) - .Where(x => !otherCommandReceivers.Contains(x.CitizenId!)) - .Where(x => x.PlacementStatus.Trim().ToUpper() == "PREPARE-CONTAIN") - .Where(x => x.Draft! == true) - .OrderBy(x => x.ExamNumber) - .ToListAsync(); - - // 3. Create new Record - var seq = 1; - foreach (var item in appointPeople) - { - - var receiver = new CommandReceiver - { - Sequence = seq, - CitizenId = item.CitizenId!, - Prefix = item.Prefix!.Name, - FirstName = item.Firstname!, - LastName = item.Lastname!, - RefPlacementProfileId = item.Id - }; - seq++; - - command.Receivers.Add(receiver); - } - await _dbContext.SaveChangesAsync(); + await GetReceiverForByCommndTypeAsync(command); // query for new list - return command.Receivers; + return command.Receivers!; } } } @@ -559,6 +593,30 @@ namespace BMA.EHR.Application.Repositories.Commands #region " Placement " + public async Task GetPlacementSalaryAsync(Guid placementProfileId) + { + try + { + var placementProfile = await _dbContext.Set() + .FirstOrDefaultAsync(p => p.Id == placementProfileId); + + if (placementProfile == null) + throw new Exception($"Invalid placement profile: {placementProfileId}"); + + return new PlacementSalaryResponse + { + SalaryAmount = placementProfile.Amount ?? 0, + PositionSalaryAmount = placementProfile.PositionSalaryAmount ?? 0, + MonthSalaryAmount = placementProfile.MouthSalaryAmount ?? 0 + }; + + } + catch + { + throw; + } + } + public async Task UpdatePlacementSalaryAsync(Guid placementProfileId, UpdatePlacementSalaryRequest req) { try @@ -604,7 +662,30 @@ namespace BMA.EHR.Application.Repositories.Commands #endregion - public async Task UpdateCommandInfo(Guid id, string orderNo, string orderYear, DateTime signDate) + #region " Command Info " + + public async Task GetCommandInfoAsync(Guid id) + { + try + { + var command = await _dbContext.Set().FirstOrDefaultAsync(x => x.Id == id); + if (command == null) + throw new Exception(GlobalMessages.CommandNotFound); + + return new CommandInfoResponse + { + SignDate = command.CommandExcecuteDate.Value, + OrderNo = command.CommandNo, + OrderYear = command.CommandYear, + }; + } + catch + { + throw; + } + } + + public async Task UpdateCommandInfoAsync(Guid id, string orderNo, string orderYear, DateTime signDate) { try { @@ -623,25 +704,27 @@ namespace BMA.EHR.Application.Repositories.Commands } } - //public async Task GetRootOcIdAsync(Guid ocId) - //{ - // try - // { - // var data = await _dbContext.Set().AsQueryable() + #endregion + public async Task GetRootOcIdAsync(Guid ocId) + { + try + { + var data = await _dbContext.Set().AsQueryable() + .Include(x => x.OrganizationAgency) + .Include(x => x.OrganizationGovernmentAgency) + .FirstOrDefaultAsync(o => o.Id == ocId); - // .FirstOrDefaultAsync(o => o.Id == ocId); + if (data == null) + throw new Exception(GlobalMessages.OrganizationNotFound); - // if (data == null) - // throw new Exception(GlobalMessages.OrganizationNotFound); - - // return data - // } - // catch - // { - // throw; - // } - //} + return data.OrganizationAgency!.Id; + } + catch + { + throw; + } + } #endregion diff --git a/BMA.EHR.Application/Responses/CommandInfoResponse.cs b/BMA.EHR.Application/Responses/CommandInfoResponse.cs new file mode 100644 index 00000000..7ee7f3f7 --- /dev/null +++ b/BMA.EHR.Application/Responses/CommandInfoResponse.cs @@ -0,0 +1,11 @@ +namespace BMA.EHR.Application.Responses +{ + public class CommandInfoResponse + { + public string OrderNo { get; set; } = string.Empty; + + public string OrderYear { get; set; } = string.Empty; + + public DateTime SignDate { get; set; } = DateTime.Now; + } +} diff --git a/BMA.EHR.Application/Responses/PlacementSalaryResponse.cs b/BMA.EHR.Application/Responses/PlacementSalaryResponse.cs new file mode 100644 index 00000000..456743f4 --- /dev/null +++ b/BMA.EHR.Application/Responses/PlacementSalaryResponse.cs @@ -0,0 +1,11 @@ +namespace BMA.EHR.Application.Responses +{ + public class PlacementSalaryResponse + { + public double SalaryAmount { get; set; } = 0; + + public double PositionSalaryAmount { get; set; } = 0; + + public double MonthSalaryAmount { get; set; } = 0; + } +} diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs index e76d7b34..d5f3b382 100644 --- a/BMA.EHR.Command.Service/Controllers/OrderController.cs +++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs @@ -2,6 +2,7 @@ using BMA.EHR.Application.Repositories.Commands; using BMA.EHR.Application.Requests.Commands; using BMA.EHR.Command.Service.Requests; +using BMA.EHR.Command.Service.Responses; using BMA.EHR.Domain.Common; using BMA.EHR.Domain.Extensions; using BMA.EHR.Domain.Models.Commands.Core; @@ -510,16 +511,26 @@ namespace BMA.EHR.Command.Service.Controllers // TODO : หาค่า Education มาแสดง var receivers = (await _repository.GetReceiverByCommmandIdAsync(orderId)) .OrderBy(x => x.Sequence) - .Select(r => new + .Select(r => new CommandReceiverResponse { - personId = r.Id, - sequence = r.Sequence, - idCard = r.CitizenId, - name = $"{r.Prefix!}{r.FirstName!} {r.LastName!}", - selectStatus = true, - education = "" // ยังหาไม่เจอว่าอยุ่ field ไหน + RefRecordId = r.RefPlacementProfileId!.Value, + PersonalId = r.Id, + Sequence = r.Sequence, + IdCard = r.CitizenId, + Name = $"{r.Prefix!}{r.FirstName!} {r.LastName!}", + SelectStatus = true, + Education = "" // ยังหาไม่เจอว่าอยุ่ field ไหน }).ToList(); + foreach (var r in receivers) + { + var salary = await _repository.GetPlacementSalaryAsync(r.RefRecordId); + + r.SalaryAmount = salary.SalaryAmount; + r.PositionSalaryAmount = salary.PositionSalaryAmount; + r.MonthSalaryAmount = salary.MonthSalaryAmount; + } + return Success(receivers); } catch @@ -899,7 +910,7 @@ namespace BMA.EHR.Command.Service.Controllers { try { - await _repository.UpdateCommandInfo(orderId, req.OrderNo, req.OrderYear, req.SignDate); + await _repository.UpdateCommandInfoAsync(orderId, req.OrderNo, req.OrderYear, req.SignDate); return Success(); } catch @@ -908,6 +919,32 @@ namespace BMA.EHR.Command.Service.Controllers } } + /// + /// อ่านข้อมูลเงินเดือนสำหรับผู้บรรจุ จากข้อมูลระบบสรรหา + /// + /// Record Id ของผู้รับคำสั่งในบัญชีแนบท้าย + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("salary/{personalId}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> GetPlacementSalaryAsync(Guid personalId) + { + try + { + var data = await _repository.GetPlacementSalaryAsync(personalId); + + return Success(data); + } + catch + { + throw; + } + } + /// /// บันทึกข้อมูลเงินเดือนสำหรับผู้บรรจุ /// @@ -916,7 +953,7 @@ namespace BMA.EHR.Command.Service.Controllers /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpPut("salary/{id}")] + [HttpPut("salary/{personalId}")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] diff --git a/BMA.EHR.Command.Service/Responses/CommandReceiverResponse.cs b/BMA.EHR.Command.Service/Responses/CommandReceiverResponse.cs new file mode 100644 index 00000000..e6bd9a7f --- /dev/null +++ b/BMA.EHR.Command.Service/Responses/CommandReceiverResponse.cs @@ -0,0 +1,25 @@ +namespace BMA.EHR.Command.Service.Responses +{ + public class CommandReceiverResponse + { + public Guid RefRecordId { get; set; } = Guid.Empty; + + public Guid PersonalId { get; set; } = Guid.Empty; + + public int Sequence { get; set; } = 0; + + public string IdCard { get; set; } = string.Empty; + + public string Name { get; set; } = string.Empty; + + public bool SelectStatus { get; set; } = true; + + public string Education { get; set; } = string.Empty; + + public double SalaryAmount { get; set; } = 0; + + public double PositionSalaryAmount { get; set; } = 0; + + public double MonthSalaryAmount { get; set; } = 0; + } +} diff --git a/BMA.EHR.Domain/Shared/GlobalMessages.cs b/BMA.EHR.Domain/Shared/GlobalMessages.cs index e1ac1005..177b035e 100644 --- a/BMA.EHR.Domain/Shared/GlobalMessages.cs +++ b/BMA.EHR.Domain/Shared/GlobalMessages.cs @@ -88,6 +88,8 @@ public static readonly string CommandNotFound = "ไม่พบรายการคำสั่งนี้ในระบบ โปรดตรวจความถูกต้อง"; + public static readonly string MethodForCommandTypeNotImplement = "Method for this command type not implement!"; + #endregion } From 4098b602ee66a2151258b49ee23fffcd336e0fa8 Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Mon, 7 Aug 2023 16:17:18 +0700 Subject: [PATCH 5/5] =?UTF-8?q?fix=20bug=20api=20=E0=B9=81=E0=B8=AA?= =?UTF-8?q?=E0=B8=94=E0=B8=87=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=81=E0=B8=B2?= =?UTF-8?q?=E0=B8=A3=E0=B9=80=E0=B8=87=E0=B8=B4=E0=B8=99=E0=B9=80=E0=B8=94?= =?UTF-8?q?=E0=B8=B7=E0=B8=AD=E0=B8=99=E0=B8=88=E0=B8=B2=E0=B8=81=E0=B8=A3?= =?UTF-8?q?=E0=B8=B0=E0=B8=9A=E0=B8=9A=E0=B8=AA=E0=B8=A3=E0=B8=A3=E0=B8=AB?= =?UTF-8?q?=E0=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BMA.EHR.Command.Service/Controllers/OrderController.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs index d5f3b382..6008cb04 100644 --- a/BMA.EHR.Command.Service/Controllers/OrderController.cs +++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs @@ -935,7 +935,9 @@ namespace BMA.EHR.Command.Service.Controllers { try { - var data = await _repository.GetPlacementSalaryAsync(personalId); + var record = await _repository.GetCommandReceiverAsync(personalId); + + var data = await _repository.GetPlacementSalaryAsync(record!.RefPlacementProfileId!.Value); return Success(data); }