Merge branch 'develop' into work

This commit is contained in:
Kittapath 2023-08-03 09:36:36 +07:00
commit 1e405e8958
35 changed files with 73678 additions and 57 deletions

View file

@ -13,7 +13,7 @@ namespace BMA.EHR.Application
services.AddTransient<PlacementRepository>();
services.AddTransient<OrganizationEmployeeRepository>();
services.AddTransient<MessageQueueRepository>();
services.AddTransient<PlacementCommandRepository>();
services.AddTransient<CommandRepository>();
services.AddTransient<CommandTypeRepository>();
services.AddTransient<CommandStatusRepository>();
services.AddTransient<InsigniaPeriodsRepository>();

View file

@ -0,0 +1,359 @@
using Amazon.S3.Model.Internal.MarshallTransformations;
using BMA.EHR.Application.Common.Interfaces;
using BMA.EHR.Domain.Models.Commands.Core;
using BMA.EHR.Domain.Models.Organizations;
using BMA.EHR.Domain.Models.Placement;
using BMA.EHR.Domain.Shared;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Command = BMA.EHR.Domain.Models.Commands.Core.Command;
namespace BMA.EHR.Application.Repositories.Commands
{
public class CommandRepository : GenericRepository<Guid, Command>
{
#region " Fields "
private readonly IApplicationDBContext _dbContext;
private readonly IHttpContextAccessor _httpContextAccessor;
#endregion
#region " Constructor and Destuctor "
public CommandRepository(IApplicationDBContext dbContext,
IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
{
_dbContext = dbContext;
_httpContextAccessor = httpContextAccessor;
}
#endregion
#region " Methods "
#region " Override "
public override async Task<Command?> GetByIdAsync(Guid id)
{
return await _dbContext.Set<Command>()
.Include(x => x.Placement)
.Include(x => x.CommandType)
.FirstOrDefaultAsync(x => x.Id == id);
}
#endregion
public async Task<List<CommandReceiver>> GetReceiverByCommmandIdAsync(Guid Id)
{
try
{
var command = await _dbContext.Set<Command>()
.Include(x => x.Receivers)
.Include(x => x.CommandType)
.FirstOrDefaultAsync(x => x.Id == Id);
if (command == null)
throw new Exception(GlobalMessages.CommandNotFound);
else
{
if (command.Receivers != null || command!.Receivers!.Count > 0)
{
return command.Receivers;
}
else
{
// 1. หารายชื่อที่ถูกเลือกไปแล้ว ในประเภทเดียวกัน
var otherCommandReceivers = await _dbContext.Set<CommandReceiver>()
.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<PlacementProfile>()
.Include(x => x.OrganizationPosition)
.ThenInclude(x => x.Organization)
//.Where(x => x.OrganizationPosition.Organization.Id )
.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();
// query for new list
return command.Receivers;
}
}
}
catch
{
throw;
}
}
public async Task<CommandReceiver> DeleteCommandReceiverAsync(Guid personalId)
{
try
{
var deleted = await _dbContext.Set<CommandReceiver>()
.FirstOrDefaultAsync(x => x.Id == personalId);
if (deleted == null)
throw new Exception(GlobalMessages.DataNotFound);
_dbContext.Set<CommandReceiver>().Remove(deleted);
await _dbContext.SaveChangesAsync();
return deleted;
}
catch
{
throw;
}
}
public async Task<List<CommandDeployment>> GetDeploymentByCommandIdAsync(Guid id)
{
try
{
var command = await _dbContext.Set<Command>()
.Include(x => x.Deployments)
.FirstOrDefaultAsync(x => x.Id == id);
if (command == null)
throw new Exception(GlobalMessages.CommandNotFound);
else
{
if (command.Deployments != null || command!.Deployments!.Count > 0)
{
return command.Deployments;
}
else
{
var orgPos = await _dbContext.Set<ProfilePosition>()
.Include(x => x.Profile)
.ThenInclude(x => x!.Prefix)
.Include(x => x.OrganizationPosition)
.ThenInclude(x => x!.Organization)
.ThenInclude(x => x!.OrganizationOrganization)
.Include(x => x.OrganizationPosition)
.ThenInclude(x => x!.PositionMaster)
.ThenInclude(x => x!.PositionPath)
.Where(x => x.OrganizationPosition!.IsDirector! == true)
.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId)
.FirstOrDefaultAsync();
if (orgPos != null)
{
if (orgPos.Profile != null)
{
var dp = new CommandDeployment
{
Sequence = 1,
ReceiveUserId = orgPos!.Profile!.Id!.ToString("D"),
CitizenId = orgPos!.Profile!.CitizenId!,
Prefix = orgPos!.Profile!.Prefix!.Name,
FirstName = orgPos!.Profile!.FirstName!,
LastName = orgPos!.Profile!.LastName!,
IsSendInbox = true,
IsSendMail = true,
IsSendNotification = true,
OrganizationName = orgPos!.OrganizationPosition!.Organization!.OrganizationOrganization!.Name,
PositionName = orgPos!.OrganizationPosition!.PositionMaster!.PositionPath!.Name
};
command.Deployments.Add(dp);
}
await _dbContext.SaveChangesAsync();
}
// query for new list
return command.Deployments;
}
}
}
catch
{
throw;
}
}
public async Task<List<ProfilePosition>> GetProfileByOrganizationIdAsync(Guid orgId)
{
try
{
var orgProfiles = await _dbContext.Set<ProfilePosition>()
.Include(x => x.Profile)
.ThenInclude(x => x!.Prefix)
.Include(x => x.OrganizationPosition)
.ThenInclude(x => x!.Organization)
.ThenInclude(x => x!.OrganizationOrganization)
.Include(x => x.OrganizationPosition)
.ThenInclude(x => x!.PositionMaster)
.ThenInclude(x => x!.PositionPath)
.Where(x => x.OrganizationPosition!.Organization!.Id == orgId)
.ToListAsync();
return orgProfiles;
}
catch
{
throw;
}
}
public async Task CreateCommandDeploymentAsync(Guid commandId, List<CommandDeployment> deploy)
{
try
{
var command = await _dbContext.Set<Command>()
.Include(x => x.Deployments)
.FirstOrDefaultAsync(x => x.Id == commandId);
if (command == null)
throw new Exception(GlobalMessages.CommandNotFound);
else
{
var lastSeq = 0;
var dep = command.Deployments.OrderByDescending(x => x.Sequence).FirstOrDefault();
if (dep == null) lastSeq = 1;
else lastSeq = dep.Sequence;
foreach (var dep2 in deploy)
{
dep2.Sequence = lastSeq;
lastSeq++;
}
command.Deployments.AddRange(deploy);
await _dbContext.SaveChangesAsync();
}
}
catch
{
throw;
}
}
public async Task UpdatCommandDeploymentAsync(List<CommandDeployment> deploys)
{
try
{
foreach (var dp in deploys)
{
var updated = await _dbContext.Set<CommandDeployment>().FirstOrDefaultAsync(x => x.Id == dp.Id);
if (updated != null)
{
updated.IsSendMail = dp.IsSendMail;
updated.IsSendInbox = dp.IsSendInbox;
}
}
await _dbContext.SaveChangesAsync();
}
catch
{
throw;
}
}
public async Task DeleteCommandDeploymentAsync(Guid id)
{
try
{
var deleted = await _dbContext.Set<CommandDeployment>().FirstOrDefaultAsync(x => x.Id == id);
if (deleted == null)
throw new Exception(GlobalMessages.DataNotFound);
_dbContext.Set<CommandDeployment>().Remove(deleted);
await _dbContext.SaveChangesAsync();
}
catch
{
throw;
}
}
public async Task<CommandDeployment?> GetCommandDeploymentById(Guid id)
{
try
{
var data = await _dbContext.Set<CommandDeployment>().FirstOrDefaultAsync(x => x.Id == id);
return data;
}
catch
{
throw;
}
}
#region " Documents "
public async Task<List<CommandDocument>> GetCommandDocumentAsync(Guid id)
{
try
{
var docs = await _dbContext.Set<CommandDocument>()
.Include(x => x.Command)
.Include(x => x.Document)
.Where(x => x.Command.Id == id)
.ToListAsync();
return docs;
}
catch
{
throw;
}
}
#endregion
public async Task UpdateCommandInfo(Guid id, string orderNo, string orderYear, DateTime signDate)
{
try
{
var command = await _dbContext.Set<Command>().FirstOrDefaultAsync(x => x.Id == id);
if(command == null)
throw new Exception(GlobalMessages.CommandNotFound);
command.CommandExcecuteDate = signDate;
command.CommandNo = orderNo;
command.CommandYear = orderYear;
await _dbContext.SaveChangesAsync();
}
catch
{
throw;
}
}
#endregion
}
}

View file

@ -1,27 +0,0 @@
using BMA.EHR.Application.Common.Interfaces;
using BMA.EHR.Domain.Models.Commands.Core;
using Microsoft.AspNetCore.Http;
namespace BMA.EHR.Application.Repositories.Commands
{
public class PlacementCommandRepository : GenericRepository<Guid, Command>
{
#region " Fields "
private readonly IApplicationDBContext _dbContext;
private readonly IHttpContextAccessor _httpContextAccessor;
#endregion
#region " Constructor and Destuctor "
public PlacementCommandRepository(IApplicationDBContext dbContext,
IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
{
_dbContext = dbContext;
_httpContextAccessor = httpContextAccessor;
}
#endregion
}
}

View file

@ -37,17 +37,17 @@ namespace BMA.EHR.Application.Repositories
#region " Methods "
public async Task<IReadOnlyList<T>> GetAllAsync()
public virtual async Task<IReadOnlyList<T>> GetAllAsync()
{
return await _dbSet.ToListAsync();
}
public async Task<T?> GetByIdAsync(S id)
public virtual async Task<T?> GetByIdAsync(S id)
{
return await _dbSet.FindAsync(id);
}
public async Task<T> AddAsync(T entity)
public virtual async Task<T> AddAsync(T entity)
{
//if (entity is IAuditableEntity)
//{
@ -63,7 +63,7 @@ namespace BMA.EHR.Application.Repositories
return entity;
}
public async Task<T> UpdateAsync(T entity)
public virtual async Task<T> UpdateAsync(T entity)
{
//if (entity is IAuditableEntity)
//{
@ -78,7 +78,7 @@ namespace BMA.EHR.Application.Repositories
return entity;
}
public async Task DeleteAsync(T entity)
public virtual async Task DeleteAsync(T entity)
{
_dbSet.Remove(entity);
await _dbContext.SaveChangesAsync();

View file

@ -1,11 +1,14 @@
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;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
using System.Security.Claims;
@ -22,27 +25,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
@ -187,7 +193,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,
@ -203,6 +209,49 @@ namespace BMA.EHR.Command.Service.Controllers
}
}
/// <summary>
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง
/// </summary>
/// <returns></returns>
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> PostAsync([FromBody] CreateCommandRequest req)
{
try
{
var inserted = new Domain.Models.Commands.Core.Command
{
CommandNo = req.orderNo.ToString(),
CommandYear = req.orderYear.ToString(),
CommandSubject = req.orderTitle,
PositionName = req.registerPosition,
CommandTypeId = req.orderTypeValue,
IssuerOrganizationId = req.orderBy,
AuthorizedUserFullName = req.signatoryBy,
AuthorizedPosition = req.signatoryPosition,
PlacementId = req.examRound,
ConclusionRegisterNo = req.conclusionRegisterNo,
ConclusionRegisterDate = req.conclusionRegisterDate,
ConclusionResultNo = req.conclusionResultNo,
ConclusionResultDate = req.conclusionResultDate
};
var result = await _repository.AddAsync(inserted);
return Success(result);
}
catch
{
throw;
}
}
/// <summary>
/// PM7-24 : dropdown รอบการสอบ หน้ารายละเอียดการออกคำสั่ง
/// </summary>
@ -235,6 +284,316 @@ namespace BMA.EHR.Command.Service.Controllers
}
}
/// <summary>
/// PM7-26 : ข้อมูลเลือกรายชื่อออกคำสั่ง
/// </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/{orderId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetCommandReceiverAsync(Guid orderId)
{
try
{
// 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)
{
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
});
}
await _repository.CreateCommandDeploymentAsync(orderId, deploys);
return Success();
}
catch
{
throw;
}
}
/// <summary>
/// PM7-32 : บันทึกช่องทางการส่งสำเนาคำสั่ง
/// </summary>
/// <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)
{
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
{
throw;
}
}
#region " Documents "
/// <summary>
/// PM7-34 : ข้อมูลรายละเอียดคำสั่งและแนบท้าย
/// </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("attachment/{orderId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetCommandAttatchmentAsync(Guid orderId)
{
try
{
var command = await _repository.GetByIdAsync(orderId);
if(command == null)
throw new Exception(GlobalMessages.CommandNotFound);
var documents = await _repository.GetCommandDocumentAsync(orderId);
var cover = documents.Where(x => x.Category.Trim().ToLower() == "cover").FirstOrDefault();
var attach = documents.Where(x => x.Category.Trim().ToLower() == "attachment").FirstOrDefault();
var result = new
{
orderNo=command.CommandNo,
orderYear=command.CommandYear,
signDate = command.CommandExcecuteDate,
orderFileUrl = cover == null ? null : _documentService.ImagesPath(cover.Document.ObjectRefId),
attachmentFileUrl = attach == null ? null : _documentService.ImagesPath(attach.Document.ObjectRefId),
};
return Success(result);
}
catch
{
throw;
}
}
#endregion
/// <summary>
/// PM7-37 : บันทึกข้อมูลคำสั่งและแนบท้าย
/// </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("attachment/{orderId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> UpdateCommandExecuteAsync(Guid orderId, [FromBody] UpdateCommandExecuteRequest req)
{
try
{
await _repository.UpdateCommandInfo(orderId, req.OrderNo, req.OrderYear, req.SignDate);
return Success();
}
catch
{
throw;
}
}
#endregion
}
}

View file

@ -7,7 +7,12 @@ EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["BMA.EHR.Domain/BMA.EHR.Domain.csproj", "BMA.EHR.Domain/"]
COPY ["BMA.EHR.Application/BMA.EHR.Application.csproj", "BMA.EHR.Application/"]
COPY ["BMA.EHR.Infrastructure/BMA.EHR.Infrastructure.csproj", "BMA.EHR.Infrastructure/"]
COPY ["BMA.EHR.Command.Service/BMA.EHR.Command.Service.csproj", "BMA.EHR.Command.Service/"]
RUN dotnet restore "BMA.EHR.Command.Service/BMA.EHR.Command.Service.csproj"
COPY . .
WORKDIR "/src/BMA.EHR.Command.Service"

View file

@ -128,6 +128,7 @@ var app = builder.Build();
// seed default data
await CommandDataSeeder.SeedData(app);
await CommandDataSeeder.SeedCommandType(app);
app.Run();
}

View file

@ -0,0 +1,19 @@
namespace BMA.EHR.Command.Service.Requests
{
public class CreateCommandDeploymentRequest
{
public Guid ProfileId { get; set; } = Guid.Empty;
public string IdCard { get; set; } = string.Empty;
public Guid PrefixId { get; set;} = Guid.Empty;
public string FirstName { get; set;} = string.Empty;
public string LastName { get; set;} = string.Empty;
public string Position { get; set;} = string.Empty;
public string Unit { get; set;} = string.Empty;
}
}

View file

@ -0,0 +1,31 @@
namespace BMA.EHR.Command.Service.Requests
{
public class CreateCommandRequest
{
public Guid orderTypeValue { get; set; }
public string orderTitle { get; set; }
public int orderNo { get; set; }
public int orderYear { get; set; }
public Guid orderBy { get; set; }
public string signatoryBy { get; set; }
public string signatoryPosition { get; set; }
public Guid examRound { get; set; }
public string registerPosition { get; set; }
public string conclusionRegisterNo { get; set; }
public DateTime conclusionRegisterDate { get; set; }
public string conclusionResultNo { get; set; }
public DateTime conclusionResultDate { get; set; }
}
}

View file

@ -0,0 +1,11 @@
namespace BMA.EHR.Command.Service.Requests
{
public class UpdateCommandDeploymentRequest
{
public Guid PersonalId { get; set; } = Guid.Empty;
public bool EmailChannel { get; set; } = true;
public bool InboxChannel { get; set; } = true;
}
}

View file

@ -0,0 +1,11 @@
namespace BMA.EHR.Command.Service.Requests
{
public class UpdateCommandExecuteRequest
{
public string OrderNo { get; set; } = string.Empty;
public string OrderYear { get; set; } = string.Empty;
public DateTime SignDate { get; set; } = DateTime.Now.Date;
}
}

View file

@ -0,0 +1,31 @@
namespace BMA.EHR.Command.Service.Requests
{
public class UpdateCommandRequest
{
public Guid orderTypeValue { get; set; }
public string orderTitle { get; set; }
public int orderNo { get; set; }
public int orderYear { get; set; }
public Guid orderBy { get; set; }
public string signatoryBy { get; set; }
public string signatoryPosition { get; set; }
public Guid examRound { get; set; }
public string registerPosition { get; set; }
public string conclusionRegisterNo { get; set; }
public DateTime conclusionRegisterDate { get; set; }
public string conclusionResultNo { get; set; }
public DateTime conclusionResultDate { get; set; }
}
}

View file

@ -74,6 +74,7 @@ namespace BMA.EHR.Domain.Middlewares
responseModel.Message = GlobalMessages.ForbiddenAccess;
break;
default:
response.StatusCode = (int)HttpStatusCode.InternalServerError;
responseModel.Status = (int)HttpStatusCode.InternalServerError;
responseModel.Message = GlobalMessages.ExceptionOccured;
break;

View file

@ -1,11 +1,6 @@
using BMA.EHR.Domain.Models.Base;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BMA.EHR.Domain.Models.Commands.Core
{
@ -51,12 +46,12 @@ namespace BMA.EHR.Domain.Models.Commands.Core
[Required, MaxLength(500), Comment("คำสั่งเรื่อง")]
public string CommandSubject { get; set; } = string.Empty;
public virtual List<CommandDocument> Documents { get; set; } = new();
#region " For Placement Command "
[Required, Comment("อ้างอิงรอบการสอบ")]
public Guid ExamRoundId { get; set; }
public Guid PlacementId { get; set; }
public Placement.Placement Placement { get; set; }
[Required, Comment("ตำแหน่งที่บรรจุ")]
public string PositionName { get; set; } = string.Empty;
@ -74,5 +69,14 @@ namespace BMA.EHR.Domain.Models.Commands.Core
public DateTime ConclusionResultDate { get; set; } = DateTime.Now;
#endregion
public virtual List<CommandDocument> Documents { get; set; } = new();
public virtual List<CommandReceiver> Receivers { get; set; }
public virtual List<CommandDeployment> Deployments { get; set; }
[Required, Comment("รหัสส่วนราชการผู้ออกคำสั่ง")]
public virtual Guid OwnerGovId { get; set; } = Guid.Empty;
}
}

View file

@ -0,0 +1,47 @@
using BMA.EHR.Domain.Models.Base;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
namespace BMA.EHR.Domain.Models.Commands.Core
{
public class CommandDeployment : EntityBase
{
[Comment("รหัสอ้างอิงคำสั่ง")]
public Guid CommandId { get; set; } = Guid.Empty;
public Command Command { get; set; } = new();
[Required, Comment("รหัสอ้างอิงผู้ใช้งานระบบ")]
public string ReceiveUserId { get; set; } = string.Empty;
[Required, Comment("ลำดับ")]
public int Sequence { get; set; } = 0;
[MaxLength(13), Required, Comment("เลขประจำตัวประชาชน")]
public string CitizenId { get; set; } = string.Empty;
[MaxLength(50), Required, Comment("คำนำหน้านาม")]
public string Prefix { get; set; } = string.Empty;
[MaxLength(100), Required, Comment("ชื่อ")]
public string FirstName { get; set; } = string.Empty;
[MaxLength(100), Required, Comment("นามสกุล")]
public string LastName { get; set; } = string.Empty;
[Required, Comment("ส่งอีเมล์หรือไม่?")]
public bool IsSendMail { get; set; } = true;
[Required, Comment("ส่งกล่องข้อความหรือไม่?")]
public bool IsSendInbox { get; set; } = true;
[Required, Comment("ส่งแจ้งเตือนหรือไม่?")]
public bool IsSendNotification { get; set; } = true;
[Comment("ชื่อหน่วยงานของผู้รับสำเนาคำสั่ง")]
public string OrganizationName { get; set; } = string.Empty;
[Comment("ชื่อตำแหน่งของผู้รับสำเนาคำสั่ง")]
public string PositionName { get; set; } = string.Empty;
}
}

View file

@ -0,0 +1,36 @@
using BMA.EHR.Domain.Models.Base;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace BMA.EHR.Domain.Models.Commands.Core
{
public class CommandReceiver : EntityBase
{
[Comment("รหัสอ้างอิงคำสั่ง")]
public Guid CommandId { get; set; } = Guid.Empty;
public Command Command { get; set; } = new();
[Required, Comment("ลำดับในบัญชีแนบท้าย")]
public int Sequence { get; set; } = 0;
[MaxLength(13), Required, Comment("เลขประจำตัวประชาชน")]
public string CitizenId { get; set; } = string.Empty;
[MaxLength(50), Required, Comment("คำนำหน้านาม")]
public string Prefix { get; set; } = string.Empty;
[MaxLength(100), Required, Comment("ชื่อ")]
public string FirstName { get; set; } = string.Empty;
[MaxLength(100), Required, Comment("นามสกุล")]
public string LastName { get; set; } = string.Empty;
[Column(TypeName = "text"), Comment("หมายเหตุ")]
public string Comment { get; set; } = string.Empty;
[Comment("รหัสอ้างอิงไปยังข้อมูลผู้บรรจุ")]
public Guid? RefPlacementProfileId { get; set; }
}
}

View file

@ -11,5 +11,8 @@ namespace BMA.EHR.Domain.Models.Commands.Core
[Required, MaxLength(100), Comment("ประเภทคำสั่ง")]
public string Category { get; set; } = string.Empty;
[Comment("รหัสของประเภทคำสั่ง")]
public string CommandCode { get; set; } = string.Empty;
}
}

View file

@ -78,5 +78,11 @@
public static readonly string InvalidRetirementRequest = "ไม่พบข้อมูลการประกาศเกษียณอายุราชการ";
#endregion
#region " Command "
public static readonly string CommandNotFound = "ไม่พบรายการคำสั่งนี้ในระบบ โปรดตรวจความถูกต้อง";
#endregion
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,109 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddCommandDeployandReceiver : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "CommandDeployments",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
CreatedUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
LastUpdateUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdateFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
CommandId = table.Column<Guid>(type: "char(36)", nullable: false, comment: "รหัสอ้างอิงคำสั่ง", collation: "ascii_general_ci"),
ReceiveUserId = table.Column<string>(type: "longtext", nullable: false, comment: "รหัสอ้างอิงผู้ใช้งานระบบ")
.Annotation("MySql:CharSet", "utf8mb4"),
IsSendMail = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "ส่งอีเมล์หรือไม่?"),
IsSendInbox = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "ส่งกล่องข้อความหรือไม่?"),
IsSendNotification = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "ส่งแจ้งเตือนหรือไม่?")
},
constraints: table =>
{
table.PrimaryKey("PK_CommandDeployments", x => x.Id);
table.ForeignKey(
name: "FK_CommandDeployments_Commands_CommandId",
column: x => x.CommandId,
principalTable: "Commands",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "CommandReceivers",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
CreatedUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
LastUpdateUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdateFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
CommandId = table.Column<Guid>(type: "char(36)", nullable: false, comment: "รหัสอ้างอิงคำสั่ง", collation: "ascii_general_ci"),
Sequence = table.Column<int>(type: "int", nullable: false, comment: "ลำดับในบัญชีแนบท้าย"),
CitizenId = table.Column<string>(type: "varchar(13)", maxLength: 13, nullable: false, comment: "เลขประจำตัวประชาชน")
.Annotation("MySql:CharSet", "utf8mb4"),
Prefix = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "คำนำหน้านาม")
.Annotation("MySql:CharSet", "utf8mb4"),
FirstName = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false, comment: "ชื่อ")
.Annotation("MySql:CharSet", "utf8mb4"),
LastName = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false, comment: "นามสกุล")
.Annotation("MySql:CharSet", "utf8mb4"),
Comment = table.Column<string>(type: "text", nullable: false, comment: "หมายเหตุ")
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_CommandReceivers", x => x.Id);
table.ForeignKey(
name: "FK_CommandReceivers_Commands_CommandId",
column: x => x.CommandId,
principalTable: "Commands",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_CommandDeployments_CommandId",
table: "CommandDeployments",
column: "CommandId");
migrationBuilder.CreateIndex(
name: "IX_CommandReceivers_CommandId",
table: "CommandReceivers",
column: "CommandId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CommandDeployments");
migrationBuilder.DropTable(
name: "CommandReceivers");
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,32 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddOwnerGovIdtoCommandTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "OwnerGovId",
table: "Commands",
type: "char(36)",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
comment: "รหัสส่วนราชการผู้ออกคำสั่ง",
collation: "ascii_general_ci");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "OwnerGovId",
table: "Commands");
}
}
}

View file

@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddCommandCodetoCommandTypeTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "CommandCode",
table: "CommandTypes",
type: "longtext",
nullable: false,
comment: "รหัสของประเภทคำสั่ง")
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "CommandCode",
table: "CommandTypes");
}
}
}

View file

@ -0,0 +1,31 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddRefToPlacementProfiletoCommandReceiverTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "RefPlacementProfileId",
table: "CommandReceivers",
type: "char(36)",
nullable: true,
comment: "รหัสอ้างอิงไปยังข้อมูลผู้บรรจุ",
collation: "ascii_general_ci");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "RefPlacementProfileId",
table: "CommandReceivers");
}
}
}

View file

@ -0,0 +1,129 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddFieldtoCommandDeploymentTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "ExamRoundId",
table: "Commands",
newName: "PlacementId");
migrationBuilder.AddColumn<string>(
name: "CitizenId",
table: "CommandDeployments",
type: "varchar(13)",
maxLength: 13,
nullable: false,
defaultValue: "",
comment: "เลขประจำตัวประชาชน")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "FirstName",
table: "CommandDeployments",
type: "varchar(100)",
maxLength: 100,
nullable: false,
defaultValue: "",
comment: "ชื่อ")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "LastName",
table: "CommandDeployments",
type: "varchar(100)",
maxLength: 100,
nullable: false,
defaultValue: "",
comment: "นามสกุล")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "OrganizationName",
table: "CommandDeployments",
type: "longtext",
nullable: false,
comment: "ชื่อหน่วยงานของผู้รับสำเนาคำสั่ง")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "Prefix",
table: "CommandDeployments",
type: "varchar(50)",
maxLength: 50,
nullable: false,
defaultValue: "",
comment: "คำนำหน้านาม")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<int>(
name: "Sequence",
table: "CommandDeployments",
type: "int",
nullable: false,
defaultValue: 0,
comment: "ลำดับ");
migrationBuilder.CreateIndex(
name: "IX_Commands_PlacementId",
table: "Commands",
column: "PlacementId");
migrationBuilder.AddForeignKey(
name: "FK_Commands_Placements_PlacementId",
table: "Commands",
column: "PlacementId",
principalTable: "Placements",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Commands_Placements_PlacementId",
table: "Commands");
migrationBuilder.DropIndex(
name: "IX_Commands_PlacementId",
table: "Commands");
migrationBuilder.DropColumn(
name: "CitizenId",
table: "CommandDeployments");
migrationBuilder.DropColumn(
name: "FirstName",
table: "CommandDeployments");
migrationBuilder.DropColumn(
name: "LastName",
table: "CommandDeployments");
migrationBuilder.DropColumn(
name: "OrganizationName",
table: "CommandDeployments");
migrationBuilder.DropColumn(
name: "Prefix",
table: "CommandDeployments");
migrationBuilder.DropColumn(
name: "Sequence",
table: "CommandDeployments");
migrationBuilder.RenameColumn(
name: "PlacementId",
table: "Commands",
newName: "ExamRoundId");
}
}
}

View file

@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddPositionNametoCommandDeploymentTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "PositionName",
table: "CommandDeployments",
type: "longtext",
nullable: false,
comment: "ชื่อตำแหน่งของผู้รับสำเนาคำสั่ง")
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "PositionName",
table: "CommandDeployments");
}
}
}

View file

@ -113,10 +113,6 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<Guid>("ExamRoundId")
.HasColumnType("char(36)")
.HasComment("อ้างอิงรอบการสอบ");
b.Property<Guid>("IssuerOrganizationId")
.HasColumnType("char(36)")
.HasComment("รหัสอ้างอิงหน่วยงานที่ออกคำสั่ง");
@ -145,6 +141,14 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnOrder(102)
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.Property<Guid>("OwnerGovId")
.HasColumnType("char(36)")
.HasComment("รหัสส่วนราชการผู้ออกคำสั่ง");
b.Property<Guid>("PlacementId")
.HasColumnType("char(36)")
.HasComment("อ้างอิงรอบการสอบ");
b.Property<string>("PositionName")
.IsRequired()
.HasColumnType("longtext")
@ -156,9 +160,124 @@ namespace BMA.EHR.Infrastructure.Migrations
b.HasIndex("CommandTypeId");
b.HasIndex("PlacementId");
b.ToTable("Commands");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.CommandDeployment", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)")
.HasColumnOrder(0)
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<string>("CitizenId")
.IsRequired()
.HasMaxLength(13)
.HasColumnType("varchar(13)")
.HasComment("เลขประจำตัวประชาชน");
b.Property<Guid>("CommandId")
.HasColumnType("char(36)")
.HasComment("รหัสอ้างอิงคำสั่ง");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(104)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<string>("CreatedUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)")
.HasComment("ชื่อ");
b.Property<bool>("IsSendInbox")
.HasColumnType("tinyint(1)")
.HasComment("ส่งกล่องข้อความหรือไม่?");
b.Property<bool>("IsSendMail")
.HasColumnType("tinyint(1)")
.HasComment("ส่งอีเมล์หรือไม่?");
b.Property<bool>("IsSendNotification")
.HasColumnType("tinyint(1)")
.HasComment("ส่งแจ้งเตือนหรือไม่?");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)")
.HasComment("นามสกุล");
b.Property<string>("LastUpdateFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(105)
.HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
b.Property<string>("LastUpdateUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(103)
.HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
b.Property<DateTime?>("LastUpdatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(102)
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.Property<string>("OrganizationName")
.IsRequired()
.HasColumnType("longtext")
.HasComment("ชื่อหน่วยงานของผู้รับสำเนาคำสั่ง");
b.Property<string>("PositionName")
.IsRequired()
.HasColumnType("longtext")
.HasComment("ชื่อตำแหน่งของผู้รับสำเนาคำสั่ง");
b.Property<string>("Prefix")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("varchar(50)")
.HasComment("คำนำหน้านาม");
b.Property<string>("ReceiveUserId")
.IsRequired()
.HasColumnType("longtext")
.HasComment("รหัสอ้างอิงผู้ใช้งานระบบ");
b.Property<int>("Sequence")
.HasColumnType("int")
.HasComment("ลำดับ");
b.HasKey("Id");
b.HasIndex("CommandId");
b.ToTable("CommandDeployments");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.CommandDocument", b =>
{
b.Property<Guid>("Id")
@ -226,6 +345,101 @@ namespace BMA.EHR.Infrastructure.Migrations
b.ToTable("CommandDocuments");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.CommandReceiver", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)")
.HasColumnOrder(0)
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<string>("CitizenId")
.IsRequired()
.HasMaxLength(13)
.HasColumnType("varchar(13)")
.HasComment("เลขประจำตัวประชาชน");
b.Property<Guid>("CommandId")
.HasColumnType("char(36)")
.HasComment("รหัสอ้างอิงคำสั่ง");
b.Property<string>("Comment")
.IsRequired()
.HasColumnType("text")
.HasComment("หมายเหตุ");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(104)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<string>("CreatedUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)")
.HasComment("ชื่อ");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)")
.HasComment("นามสกุล");
b.Property<string>("LastUpdateFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(105)
.HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
b.Property<string>("LastUpdateUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(103)
.HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
b.Property<DateTime?>("LastUpdatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(102)
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.Property<string>("Prefix")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("varchar(50)")
.HasComment("คำนำหน้านาม");
b.Property<Guid?>("RefPlacementProfileId")
.HasColumnType("char(36)")
.HasComment("รหัสอ้างอิงไปยังข้อมูลผู้บรรจุ");
b.Property<int>("Sequence")
.HasColumnType("int")
.HasComment("ลำดับในบัญชีแนบท้าย");
b.HasKey("Id");
b.HasIndex("CommandId");
b.ToTable("CommandReceivers");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.CommandStatus", b =>
{
b.Property<Guid>("Id")
@ -303,6 +517,11 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("varchar(100)")
.HasComment("ประเภทคำสั่ง");
b.Property<string>("CommandCode")
.IsRequired()
.HasColumnType("longtext")
.HasComment("รหัสของประเภทคำสั่ง");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)
@ -10439,9 +10658,28 @@ namespace BMA.EHR.Infrastructure.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BMA.EHR.Domain.Models.Placement.Placement", "Placement")
.WithMany()
.HasForeignKey("PlacementId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CommandStatus");
b.Navigation("CommandType");
b.Navigation("Placement");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.CommandDeployment", b =>
{
b.HasOne("BMA.EHR.Domain.Models.Commands.Core.Command", "Command")
.WithMany("Deployments")
.HasForeignKey("CommandId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Command");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.CommandDocument", b =>
@ -10463,6 +10701,17 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Navigation("Document");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.CommandReceiver", b =>
{
b.HasOne("BMA.EHR.Domain.Models.Commands.Core.Command", "Command")
.WithMany("Receivers")
.HasForeignKey("CommandId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Command");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.HR.LimitTypeLeave", b =>
{
b.HasOne("BMA.EHR.Domain.Models.HR.LimitLeave", "LimitLeave")
@ -11599,7 +11848,11 @@ namespace BMA.EHR.Infrastructure.Migrations
modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.Command", b =>
{
b.Navigation("Deployments");
b.Navigation("Documents");
b.Navigation("Receivers");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.HR.LimitLeave", b =>

View file

@ -1,17 +1,16 @@
using BMA.EHR.Application.Common.Interfaces;
using BMA.EHR.Domain.Models.Commands.Core;
using BMA.EHR.Domain.Models.Documents;
using BMA.EHR.Domain.Models.HR;
using BMA.EHR.Domain.Models.Insignias;
using BMA.EHR.Domain.Models.MetaData;
using BMA.EHR.Domain.Models.OrganizationEmployee;
using BMA.EHR.Domain.Models.Notifications;
using BMA.EHR.Domain.Models.OrganizationEmployee;
using BMA.EHR.Domain.Models.Organizations;
using BMA.EHR.Domain.Models.Organizations.Report2;
using BMA.EHR.Domain.Models.Placement;
using Microsoft.EntityFrameworkCore;
using BMA.EHR.Domain.Models.Commands.Core;
using BMA.EHR.Domain.Models.Commands;
using BMA.EHR.Domain.Models.Insignias;
using BMA.EHR.Domain.Models.Retirement;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Infrastructure.Persistence
{
@ -272,9 +271,12 @@ namespace BMA.EHR.Infrastructure.Persistence
public DbSet<DeploymentChannel> DeploymentChannels { get; set; }
public DbSet<Command> Commands { get; set; }
public DbSet<CommandDeployment> CommandDeployments { get; set; }
public DbSet<CommandReceiver> CommandReceivers { get; set; }
#endregion
#region " Message Queue "

View file

@ -44,5 +44,42 @@ namespace BMA.EHR.Infrastructure.Persistence
}
}
}
public static async Task SeedCommandType(WebApplication app)
{
using var scope = app.Services.CreateScope();
var service = scope.ServiceProvider.GetRequiredService<CommandTypeRepository>();
if ((await service.GetAllAsync()).Count() == 0)
{
// read excels into object
var excelFile = "SeedCommand.xlsx";
using (var excel = new ExcelPackage(new FileInfo(excelFile)))
{
var workSheet = excel.Workbook.Worksheets.FirstOrDefault(x => x.Name.ToLower() == "commandtype");
var totalRows = workSheet?.Dimension.Rows;
int row = 2;
while (row <= totalRows)
{
var cell1 = workSheet?.Cells[row, 1]?.GetValue<string>();
if (cell1 == "" || cell1 == null) break;
var inserted = new CommandType
{
Id = Guid.Parse(workSheet?.Cells[row, 1]?.GetValue<string>()!),
Name = workSheet?.Cells[row, 2]?.GetValue<string>()!,
Category = workSheet?.Cells[row, 3]?.GetValue<string>()!,
CommandCode = workSheet?.Cells[row, 4]?.GetValue<string>()!
};
await service.AddAsync(inserted);
row++;
}
}
}
}
}
}

View file

@ -7,7 +7,6 @@ using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using System.Net.Http.Headers;
using Microsoft.AspNetCore.Hosting;
namespace BMA.EHR.Application.Repositories
{
@ -213,6 +212,7 @@ namespace BMA.EHR.Application.Repositories
}
#endregion
public List<Guid> GetAllIdByRoot(Guid? id)
{
try