Merge branch 'develop' into work
This commit is contained in:
commit
684a0200b3
4 changed files with 322 additions and 2 deletions
|
|
@ -16,9 +16,7 @@ using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Text;
|
|
||||||
using Command = BMA.EHR.Domain.Models.Commands.Core.Command;
|
using Command = BMA.EHR.Domain.Models.Commands.Core.Command;
|
||||||
using Profile = BMA.EHR.Domain.Models.HR.Profile;
|
using Profile = BMA.EHR.Domain.Models.HR.Profile;
|
||||||
|
|
||||||
|
|
@ -146,6 +144,12 @@ namespace BMA.EHR.Application.Repositories.Commands
|
||||||
case "C-PM-21":
|
case "C-PM-21":
|
||||||
result = await GetReceiver21Async(command);
|
result = await GetReceiver21Async(command);
|
||||||
break;
|
break;
|
||||||
|
case "C-PM-22":
|
||||||
|
result = await GetReceiver22Async(command);
|
||||||
|
break;
|
||||||
|
case "C-PM-23":
|
||||||
|
result = await GetReceiver23Async(command);
|
||||||
|
break;
|
||||||
default: throw new Exception(GlobalMessages.MethodForCommandTypeNotImplement);
|
default: throw new Exception(GlobalMessages.MethodForCommandTypeNotImplement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1202,6 +1206,7 @@ namespace BMA.EHR.Application.Repositories.Commands
|
||||||
.ThenInclude(x => x.Prefix)
|
.ThenInclude(x => x.Prefix)
|
||||||
//.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId)
|
//.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId)
|
||||||
.Where(x => !otherCommandReceivers.Contains(x.Profile!.CitizenId!))
|
.Where(x => !otherCommandReceivers.Contains(x.Profile!.CitizenId!))
|
||||||
|
.Where(x => x.Profile.ProfileType == "officer")
|
||||||
.Where(x => x.Status.Trim().ToUpper() == "REPORT")
|
.Where(x => x.Status.Trim().ToUpper() == "REPORT")
|
||||||
.OrderBy(x => x.Profile!.CitizenId)
|
.OrderBy(x => x.Profile!.CitizenId)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
@ -1464,6 +1469,129 @@ namespace BMA.EHR.Application.Repositories.Commands
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// C-PM-22 - คำสั่งจ้างและแต่งตั้งลูกจ้างประจำ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task<List<CommandReceiver>> GetReceiver22Async(Command command)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = new List<CommandReceiver>();
|
||||||
|
// TODO : ต้องมา list คนตามประเภทอีกครั้งนึง
|
||||||
|
|
||||||
|
// 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-22")
|
||||||
|
.Where(x => x.Command.Id != command.Id)
|
||||||
|
.Select(x => x.CitizenId)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
// 2. Query
|
||||||
|
var appointPeople = await _dbContext.Set<PlacementAppointment>()
|
||||||
|
.Include(x => x.CommandType)
|
||||||
|
.Include(x => x.Prefix)
|
||||||
|
.Include(x => x.OrganizationPosition)
|
||||||
|
.ThenInclude(x => x!.Organization)
|
||||||
|
.Include(x => x.Profile)
|
||||||
|
//.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId)
|
||||||
|
.Where(x => !otherCommandReceivers.Contains(x.CitizenId!))
|
||||||
|
.Where(x => x.Status.Trim().ToUpper() == "REPORT")
|
||||||
|
.Where(x => x.CommandType!.Id == command.CommandType!.Id)
|
||||||
|
.Where(x => x.Profile.ProfileType == "employee")
|
||||||
|
.OrderBy(x => x.CitizenId)
|
||||||
|
.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,
|
||||||
|
Amount = item.AmountOld,
|
||||||
|
};
|
||||||
|
seq++;
|
||||||
|
|
||||||
|
result.Add(receiver);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// C-PM-23 - คำสั่งให้ลูกจ้างออกจากราชการ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task<List<CommandReceiver>> GetReceiver23Async(Command command)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = new List<CommandReceiver>();
|
||||||
|
// TODO : ต้องมา list คนตามประเภทอีกครั้งนึง
|
||||||
|
|
||||||
|
// 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-23")
|
||||||
|
.Where(x => x.Command.Id != command.Id)
|
||||||
|
.Select(x => x.CitizenId)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
// 2. Query
|
||||||
|
var appointPeople = await _dbContext.Set<RetirementResign>()
|
||||||
|
.Include(x => x.Profile)
|
||||||
|
.ThenInclude(x => x.Prefix)
|
||||||
|
//.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId)
|
||||||
|
.Where(x => !otherCommandReceivers.Contains(x.Profile!.CitizenId!))
|
||||||
|
.Where(x => x.Profile.ProfileType == "employee")
|
||||||
|
.Where(x => x.Status.Trim().ToUpper() == "REPORT")
|
||||||
|
.OrderBy(x => x.Profile!.CitizenId)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
// 3. Create new Record
|
||||||
|
var seq = 1;
|
||||||
|
foreach (var item in appointPeople)
|
||||||
|
{
|
||||||
|
var receiver = new CommandReceiver
|
||||||
|
{
|
||||||
|
Sequence = seq,
|
||||||
|
CitizenId = item.Profile!.CitizenId!,
|
||||||
|
Prefix = item.Profile!.Prefix!.Name,
|
||||||
|
FirstName = item.Profile!.FirstName!,
|
||||||
|
LastName = item.Profile!.LastName!,
|
||||||
|
RefPlacementProfileId = item.Id,
|
||||||
|
Amount = item.AmountOld,
|
||||||
|
};
|
||||||
|
seq++;
|
||||||
|
|
||||||
|
result.Add(receiver);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region " Execute and Deploy "
|
#region " Execute and Deploy "
|
||||||
|
|
@ -5905,6 +6033,11 @@ namespace BMA.EHR.Application.Repositories.Commands
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Regenerate Json File "
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
|
|
@ -260,6 +260,8 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
case "C-PM-19":
|
case "C-PM-19":
|
||||||
case "C-PM-20":
|
case "C-PM-20":
|
||||||
case "C-PM-21":
|
case "C-PM-21":
|
||||||
|
case "C-PM-22":
|
||||||
|
case "C-PM-23":
|
||||||
{
|
{
|
||||||
if (command.CommandNo != "" &&
|
if (command.CommandNo != "" &&
|
||||||
command.CommandYear != null &&
|
command.CommandYear != null &&
|
||||||
|
|
@ -2636,6 +2638,188 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region " C-PM-22 "
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-22
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpPost("c-pm-22/detail")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> PostType22Async([FromBody] CreateCommandGroup0Request req)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
||||||
|
|
||||||
|
var inserted = new Domain.Models.Commands.Core.Command
|
||||||
|
{
|
||||||
|
CommandNo = req.orderNo,
|
||||||
|
CommandYear = req.orderYear.ToString(),
|
||||||
|
CommandSubject = req.orderTitle,
|
||||||
|
CommandTypeId = req.orderTypeValue,
|
||||||
|
IssuerOrganizationId = req.orderBy,
|
||||||
|
IssuerOrganizationName = req.orderByOrganizationName,
|
||||||
|
AuthorizedUserFullName = req.signatoryBy,
|
||||||
|
AuthorizedPosition = req.signatoryPosition,
|
||||||
|
|
||||||
|
CommandAffectDate = req.orderDate,
|
||||||
|
OwnerGovId = OcId,
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = await _repository.AddAsync(inserted);
|
||||||
|
|
||||||
|
return Success(result);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-22
|
||||||
|
/// </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("c-pm-22/detail/{orderId}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> PutType22Async(Guid orderId, [FromBody] CreateCommandGroup0Request req)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var order = await _repository.GetByIdAsync(orderId);
|
||||||
|
if (order == null)
|
||||||
|
throw new Exception(GlobalMessages.CommandNotFound);
|
||||||
|
|
||||||
|
|
||||||
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
||||||
|
var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
||||||
|
|
||||||
|
order.CommandNo = req.orderNo;
|
||||||
|
order.CommandYear = req.orderYear.ToString();
|
||||||
|
order.CommandSubject = req.orderTitle;
|
||||||
|
order.CommandType = commandType!;
|
||||||
|
order.IssuerOrganizationId = req.orderBy;
|
||||||
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
||||||
|
order.AuthorizedUserFullName = req.signatoryBy;
|
||||||
|
order.AuthorizedPosition = req.signatoryPosition;
|
||||||
|
order.CommandStatus = status!;
|
||||||
|
order.CommandAffectDate = req.orderDate;
|
||||||
|
|
||||||
|
var result = await _repository.UpdateAsync(order);
|
||||||
|
|
||||||
|
return Success(result);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " C-PM-23 "
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-23
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpPost("c-pm-23/detail")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> PostType23Async([FromBody] CreateCommandGroup0Request req)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
||||||
|
|
||||||
|
var inserted = new Domain.Models.Commands.Core.Command
|
||||||
|
{
|
||||||
|
CommandNo = req.orderNo,
|
||||||
|
CommandYear = req.orderYear.ToString(),
|
||||||
|
CommandSubject = req.orderTitle,
|
||||||
|
CommandTypeId = req.orderTypeValue,
|
||||||
|
IssuerOrganizationId = req.orderBy,
|
||||||
|
IssuerOrganizationName = req.orderByOrganizationName,
|
||||||
|
AuthorizedUserFullName = req.signatoryBy,
|
||||||
|
AuthorizedPosition = req.signatoryPosition,
|
||||||
|
|
||||||
|
CommandAffectDate = req.orderDate,
|
||||||
|
OwnerGovId = OcId,
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = await _repository.AddAsync(inserted);
|
||||||
|
|
||||||
|
return Success(result);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-23
|
||||||
|
/// </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("c-pm-23/detail/{orderId}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> PutType23Async(Guid orderId, [FromBody] CreateCommandGroup0Request req)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var order = await _repository.GetByIdAsync(orderId);
|
||||||
|
if (order == null)
|
||||||
|
throw new Exception(GlobalMessages.CommandNotFound);
|
||||||
|
|
||||||
|
|
||||||
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
||||||
|
var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
||||||
|
|
||||||
|
order.CommandNo = req.orderNo;
|
||||||
|
order.CommandYear = req.orderYear.ToString();
|
||||||
|
order.CommandSubject = req.orderTitle;
|
||||||
|
order.CommandType = commandType!;
|
||||||
|
order.IssuerOrganizationId = req.orderBy;
|
||||||
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
||||||
|
order.AuthorizedUserFullName = req.signatoryBy;
|
||||||
|
order.AuthorizedPosition = req.signatoryPosition;
|
||||||
|
order.CommandStatus = status!;
|
||||||
|
order.CommandAffectDate = req.orderDate;
|
||||||
|
|
||||||
|
var result = await _repository.UpdateAsync(order);
|
||||||
|
|
||||||
|
return Success(result);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -30,6 +30,9 @@ namespace BMA.EHR.Domain.Models.Commands.Core
|
||||||
[Column(TypeName = "text"), Comment("หมายเหตุ")]
|
[Column(TypeName = "text"), Comment("หมายเหตุ")]
|
||||||
public string Comment { get; set; } = string.Empty;
|
public string Comment { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Column(TypeName = "text"), Comment("หมายเหตุแนวนอน")]
|
||||||
|
public string Comment2 { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Comment("รหัสอ้างอิงไปยังข้อมูลผู้บรรจุ")]
|
[Comment("รหัสอ้างอิงไปยังข้อมูลผู้บรรจุ")]
|
||||||
public Guid? RefPlacementProfileId { get; set; }
|
public Guid? RefPlacementProfileId { get; set; }
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue