Merge branch 'develop' into work

This commit is contained in:
Kittapath 2023-08-08 11:05:04 +07:00
commit 4bb0af5404
7 changed files with 12936 additions and 21 deletions

View file

@ -16,7 +16,7 @@ env:
TOKEN_LINE: uxuK5hDzS2DsoC5piJBrWRLiz8GgY7iMZZldOWsDDF0
jobs:
# act workflow_dispatch -W .github/workflows/release.yaml --input IMAGE_VER=test-v6.1 -s DOCKER_USER=sorawit -s DOCKER_PASS=P@ssword -s SSH_PASSWORD=P@ssw0rd
# act workflow_dispatch -W .github/workflows/release_command.yaml --input IMAGE_VER=test-v6.1 -s DOCKER_USER=sorawit -s DOCKER_PASS=P@ssword -s SSH_PASSWORD=P@ssw0rd
release-dev:
runs-on: ubuntu-latest
steps:

View file

@ -37,15 +37,23 @@ namespace BMA.EHR.Application.Repositories.Commands
#region " Private "
private async Task GetReceiverForByCommndTypeAsync(Command command)
#region " List Receiver "
private async Task<List<CommandReceiver>> GetReceiverForByCommndTypeAsync(Command command)
{
switch (command.CommandType.Category.Trim().ToUpper())
var result = new List<CommandReceiver>();
switch (command.CommandType.CommandCode.Trim().ToUpper())
{
case "C-PM-01":
await GetReceiver01(command);
case "C-PM-02":
case "C-PM-03":
result = await GetReceiver01(command);
break;
default: throw new Exception(GlobalMessages.MethodForCommandTypeNotImplement);
}
return result;
}
/// <summary>
@ -53,10 +61,13 @@ namespace BMA.EHR.Application.Repositories.Commands
/// </summary>
/// <param name="command"></param>
/// <returns></returns>
private async Task GetReceiver01(Command command)
private async Task<List<CommandReceiver>> GetReceiver01(Command command)
{
try
{
var result = new List<CommandReceiver>();
// 1. หารายชื่อที่ถูกเลือกไปแล้ว ในประเภทเดียวกัน
var otherCommandReceivers = await _dbContext.Set<CommandReceiver>()
.Include(x => x.Command)
@ -70,7 +81,7 @@ namespace BMA.EHR.Application.Repositories.Commands
var appointPeople = await _dbContext.Set<PlacementProfile>()
.Include(x => x.Prefix)
.Include(x => x.OrganizationPosition)
.ThenInclude(x => x.Organization)
.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")
@ -94,9 +105,10 @@ namespace BMA.EHR.Application.Repositories.Commands
};
seq++;
command.Receivers.Add(receiver);
result.Add(receiver);
}
await _dbContext.SaveChangesAsync();
return result;
}
catch
{
@ -106,6 +118,13 @@ namespace BMA.EHR.Application.Repositories.Commands
#endregion
#region " Execute and Deploy "
#endregion
#endregion
#region " Override "
public override async Task<Command?> GetByIdAsync(Guid id)
@ -151,10 +170,80 @@ namespace BMA.EHR.Application.Repositories.Commands
#region " Command Receiver "
public async Task SaveSelectedReceiverAsync(Guid id, List<Guid> selected)
{
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);
var appointPeople = await _dbContext.Set<PlacementProfile>()
.Include(x => x.Prefix)
.Include(x => x.OrganizationPosition)
.ThenInclude(x => x!.Organization)
//.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId)
.Where(x => selected.Contains(x.Id))
.OrderBy(x => x.ExamNumber)
.ToListAsync();
_dbContext.Set<CommandReceiver>().RemoveRange(command.Receivers);
await _dbContext.SaveChangesAsync();
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;
}
}
public async Task<List<CommandReceiver>> GetReceiverForCommandAsync(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
return await GetReceiverForByCommndTypeAsync(command);
}
catch
{
throw;
}
}
public async Task<List<CommandReceiver>> GetReceiverByCommmandIdAsync(Guid Id)
{
try
{
// ปรับใหม่ให้อ่านจาก database ล้วนๆ
var command = await _dbContext.Set<Command>()
.Include(x => x.Receivers)
.Include(x => x.CommandType)
@ -170,10 +259,8 @@ namespace BMA.EHR.Application.Repositories.Commands
}
else
{
await GetReceiverForByCommndTypeAsync(command);
// query for new list
return command.Receivers!;
// returrn empty list
return new List<CommandReceiver>();
}
}
}
@ -711,14 +798,14 @@ namespace BMA.EHR.Application.Repositories.Commands
try
{
var data = await _dbContext.Set<OrganizationEntity>().AsQueryable()
.Include(x => x.OrganizationAgency)
.Include(x => x.OrganizationGovernmentAgency)
//.Include(x => x.OrganizationAgency)
//.Include(x => x.OrganizationGovernmentAgency)
.FirstOrDefaultAsync(o => o.Id == ocId);
if (data == null)
throw new Exception(GlobalMessages.OrganizationNotFound);
return data.OrganizationAgency!.Id;
return data.OrganizationAgencyId!.Value;
}
catch
{

View file

@ -1,4 +1,5 @@
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.Application.Requests.Commands;
using BMA.EHR.Command.Service.Requests;
@ -493,7 +494,7 @@ namespace BMA.EHR.Command.Service.Controllers
}
/// <summary>
/// PM7-26 : ข้อมูลเลือกรายชื่อออกคำสั่ง
/// PM7-26 : ข้อมูลเลือกรายชื่อออกคำสั่ง ** ยังไม่ได้กรองหน่วยงาน ** ** แสดงรายการจากระบบบรรจุ **
/// </summary>
/// <param name="orderId">Record Id ของคำสั่ง</param>
/// <returns></returns>
@ -509,8 +510,57 @@ namespace BMA.EHR.Command.Service.Controllers
try
{
// TODO : หาค่า Education มาแสดง
var receivers = (await _repository.GetReceiverByCommmandIdAsync(orderId))
var existed = await _repository.GetReceiverByCommmandIdAsync(orderId);
var receivers = (await _repository.GetReceiverForCommandAsync(orderId))
.OrderBy(x => x.Sequence)
.Select(r => new CommandReceiverResponse
{
RefRecordId = r.RefPlacementProfileId!.Value,
PersonalId = r.Id,
Sequence = r.Sequence,
IdCard = r.CitizenId,
Name = $"{r.Prefix!}{r.FirstName!} {r.LastName!}",
SelectStatus = existed.FirstOrDefault(x => x.RefPlacementProfileId!.Value == r.RefPlacementProfileId!.Value) != null,
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
{
throw;
}
}
/// <summary>
/// ข้อมูลเลือกรายชื่อออกคำสั่ง ** ที่ได้เลือกเอาไว้แล้ว **
/// </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-selected/{orderId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetCommandSelectReceiverAsync(Guid orderId)
{
try
{
var receivers = (await _repository.GetReceiverByCommmandIdAsync(orderId))
.OrderBy(x => x.Sequence)
.Select(r => new CommandReceiverResponse
{
RefRecordId = r.RefPlacementProfileId!.Value,
@ -540,7 +590,33 @@ namespace BMA.EHR.Command.Service.Controllers
}
/// <summary>
/// PM7-27 : ข้อมูลเลือกรายชื่อออกคำสั่ง ** ยังไม่ได้กรองหน่วยงาน **
/// บันทึกข้อมูลเลือกรายชื่อออกคำสั่ง ** ที่ได้เลือกเอาไว้แล้ว **
/// </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("persons/{orderId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> SaveCommandSelectReceiverAsync(Guid orderId,[FromBody] List<Guid> selected)
{
try
{
await _repository.SaveSelectedReceiverAsync(orderId, selected);
return Success();
}
catch
{
throw;
}
}
/// <summary>
/// PM7-27 : ลบข้อมูลเลือกรายชื่อออกคำสั่ง
/// </summary>
/// <remarks>
/// ** ยังไม่ได้กรองหน่วยงาน **
@ -935,8 +1011,8 @@ namespace BMA.EHR.Command.Service.Controllers
{
try
{
var record = await _repository.GetCommandReceiverAsync(personalId);
var record = await _repository.GetCommandReceiverAsync(personalId);
var data = await _repository.GetPlacementSalaryAsync(record!.RefPlacementProfileId!.Value);
return Success(data);

View file

@ -49,9 +49,16 @@ namespace BMA.EHR.Domain.Models.HR
[Comment("ตำแหน่ง (รายละเอียด)")]
public string? SalaryClass { get; set; }
[Comment("เอกสารอ้างอิง")]
public string? SalaryRef { get; set; }
public virtual List<ProfileSalaryHistory> ProfileSalaryHistorys { get; set; } = new List<ProfileSalaryHistory>();
public virtual Profile? Profile { get; set; }
[Comment("เลขที่คำสั่ง")]
public string CommandNo { get; set; }
[Comment("ประเภทคำสั่ง")]
public string CommandTypeName { get; set; }
}
}

File diff suppressed because it is too large Load diff

View file

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

View file

@ -4403,6 +4403,16 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("double")
.HasComment("เงินเดือน");
b.Property<string>("CommandNo")
.IsRequired()
.HasColumnType("longtext")
.HasComment("เลขที่คำสั่ง");
b.Property<string>("CommandTypeName")
.IsRequired()
.HasColumnType("longtext")
.HasComment("ประเภทคำสั่ง");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)