Receive and Deploy Command
This commit is contained in:
parent
297b1efb57
commit
4e8b7ea32b
24 changed files with 49003 additions and 87 deletions
|
|
@ -1,8 +1,11 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using Amazon.S3.Model.Internal.MarshallTransformations;
|
||||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Application.Repositories.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;
|
||||
|
|
@ -24,27 +27,30 @@ namespace BMA.EHR.Command.Service.Controllers
|
|||
{
|
||||
#region " Fields "
|
||||
|
||||
private readonly PlacementCommandRepository _repository;
|
||||
private readonly CommandRepository _repository;
|
||||
private readonly PlacementRepository _placementRepository;
|
||||
private readonly ApplicationDBContext _context;
|
||||
private readonly MinIOService _documentService;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly GenericRepository<Guid, Prefix> _prefixRepository;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Constuctor and Destructor "
|
||||
|
||||
public OrderController(PlacementCommandRepository repository,
|
||||
public OrderController(CommandRepository repository,
|
||||
PlacementRepository placementRepository,
|
||||
ApplicationDBContext context,
|
||||
MinIOService documentService,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
GenericRepository<Guid, Prefix> prefixRepository)
|
||||
{
|
||||
_repository = repository;
|
||||
_context = context;
|
||||
_documentService = documentService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_placementRepository = placementRepository;
|
||||
_prefixRepository = prefixRepository;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -189,7 +195,7 @@ namespace BMA.EHR.Command.Service.Controllers
|
|||
orderBy = data.IssuerOrganizationId,
|
||||
signatoryBy = data.AuthorizedUserFullName,
|
||||
signatoryPosition = data.AuthorizedPosition,
|
||||
examRound = data.ExamRoundId,
|
||||
examRound = data.Placement.Round,
|
||||
registerPosition = "",
|
||||
conclusionRegisterNo = data.ConclusionRegisterNo,
|
||||
conclusionRegisterDate = data.ConclusionRegisterDate,
|
||||
|
|
@ -231,7 +237,7 @@ namespace BMA.EHR.Command.Service.Controllers
|
|||
IssuerOrganizationId = req.orderBy,
|
||||
AuthorizedUserFullName = req.signatoryBy,
|
||||
AuthorizedPosition = req.signatoryPosition,
|
||||
ExamRoundId = req.examRound,
|
||||
PlacementId = req.examRound,
|
||||
ConclusionRegisterNo = req.conclusionRegisterNo,
|
||||
ConclusionRegisterDate = req.conclusionRegisterDate,
|
||||
ConclusionResultNo = req.conclusionResultNo,
|
||||
|
|
@ -292,21 +298,228 @@ namespace BMA.EHR.Command.Service.Controllers
|
|||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[AllowAnonymous]
|
||||
public async Task<ActionResult<ResponseObject>> GetCommandReceiver(Guid orderId)
|
||||
public async Task<ActionResult<ResponseObject>> GetCommandReceiverAsync(Guid orderId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var receivers = await _repository.GetReceiverByCommmandIdAsync(orderId);
|
||||
if (receivers.Count() > 0)
|
||||
// TODO : หาค่า Education มาแสดง
|
||||
var receivers = (await _repository.GetReceiverByCommmandIdAsync(orderId))
|
||||
.Select(r => new
|
||||
{
|
||||
personId = r.Id,
|
||||
sequence = r.Sequence,
|
||||
idCard = r.CitizenId,
|
||||
name = $"{r.Prefix!}{r.FirstName!} {r.LastName!}",
|
||||
selectStatus = true,
|
||||
education = "" // ยังหาไม่เจอว่าอยุ่ field ไหน
|
||||
}).ToList();
|
||||
|
||||
return Success(receivers);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PM7-27 : ข้อมูลเลือกรายชื่อออกคำสั่ง
|
||||
/// </summary>
|
||||
/// <param name="personalId">Record Id ของผู้รับคำสั่งในรายการบัญชีแนบท้าย</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpDelete("persons/{personalId}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> DeleteCommandReceiverAsync(Guid personalId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var receiver = await _repository.DeleteCommandReceiverAsync(personalId);
|
||||
return Success(receiver);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PM7-28 : ข้อมูลเลือกรายชื่อส่งสำเนาคำสั่ง
|
||||
/// </summary>
|
||||
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("persons/{personalId}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetCommandDeploymentAsync(Guid orderId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var deployments = (await _repository.GetDeploymentByCommandIdAsync(orderId))
|
||||
.Select(x => new
|
||||
{
|
||||
personalId = x.Id,
|
||||
sequence = x.Sequence,
|
||||
selectStatus = true,
|
||||
idCard = x.CitizenId,
|
||||
name = $"{x.Prefix}{x.FirstName} {x.LastName}",
|
||||
position = x.PositionName,
|
||||
unit = x.OrganizationName,
|
||||
emailChannel = x.IsSendMail,
|
||||
inboxChannel = x.IsSendInbox
|
||||
})
|
||||
.ToList();
|
||||
|
||||
return Success(deployments);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PM7-30 : popup - เลือกรายชื่อส่งสำเนาคำสั่ง
|
||||
/// </summary>
|
||||
/// <param name="organizationId">Record Id ของหน่วยงาน</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("copy-order/persons/{organizationId}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetPeopleByOrganizationIdAsync(Guid organizationId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var people = (await _repository.GetProfileByOrganizationIdAsync(organizationId))
|
||||
.Select(x => new
|
||||
{
|
||||
profileId = x.Profile!.Id,
|
||||
idCard = x.Profile!.CitizenId,
|
||||
name = $"{x.Profile!.Prefix!.Name}{x.Profile!.FirstName} {x.Profile!.LastName}",
|
||||
position = x.OrganizationPosition!.PositionMaster!.PositionPath!.Name,
|
||||
unit = x.OrganizationPosition!.Organization!.OrganizationOrganization!.Name,
|
||||
prefixId = x.Profile!.Prefix!.Id,
|
||||
firstName = x.Profile!.FirstName,
|
||||
lastName = x.Profile!.LastName
|
||||
})
|
||||
.ToList();
|
||||
|
||||
return Success(people);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PM7-31 : เพิ่มรายชื่อคนที่ต้องการส่งสำเนาคำสั่ง
|
||||
/// </summary>
|
||||
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("copy-order/persons/{orderId}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> CreateCommandDeploymentAsync(Guid orderId, [FromBody] List<CreateCommandDeploymentRequest> req)
|
||||
{
|
||||
try
|
||||
{
|
||||
// transform req
|
||||
var deploys = new List<CommandDeployment>();
|
||||
foreach (var p in req)
|
||||
{
|
||||
return Success(receivers);
|
||||
var prefix = await _prefixRepository.GetByIdAsync(p.PrefixId);
|
||||
deploys.Add(new CommandDeployment
|
||||
{
|
||||
CitizenId = p.IdCard,
|
||||
Prefix = prefix.Name,
|
||||
FirstName = p.FirstName,
|
||||
LastName = p.LastName,
|
||||
OrganizationName = p.Unit,
|
||||
PositionName = p.Position
|
||||
});
|
||||
}
|
||||
else
|
||||
|
||||
await _repository.CreateCommandDeploymentAsync(orderId, deploys);
|
||||
|
||||
return Success();
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PM7-32 : บันทึกช่องทางการส่งสำเนาคำสั่ง
|
||||
/// </summary>
|
||||
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("copy-order")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> UpdateCommandDeploymentAsync([FromBody] List<UpdateCommandDeploymentRequest> req)
|
||||
{
|
||||
try
|
||||
{
|
||||
// transform
|
||||
var deploys = new List<CommandDeployment>();
|
||||
foreach(var p in req)
|
||||
{
|
||||
// ไม่เจอข้อมูลไปอ่านจากระบบสรรหาที่สง้รายชื่อมาแล้ว insert
|
||||
return Success();
|
||||
var updated = await _repository.GetCommandDeploymentById(p.PersonalId);
|
||||
updated!.IsSendInbox = p.InboxChannel;
|
||||
updated!.IsSendMail = p.EmailChannel;
|
||||
deploys.Add(updated);
|
||||
}
|
||||
|
||||
await _repository.UpdatCommandDeploymentAsync(deploys);
|
||||
|
||||
return Success();
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PM7-33 : ลบรายชื่อคนที่ต้องการส่งสำเนาคำสั่ง
|
||||
/// </summary>
|
||||
/// <param name="personalId">Record Id ของผู้รับสำเนาคำสั่ง</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpDelete("copy-order/{personalId}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> DeleteCommandDeloymentAsync(Guid personalId)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _repository.DeleteCommandDeploymentAsync(personalId);
|
||||
return Success();
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue