Merge branch 'develop' into work

This commit is contained in:
Kittapath 2023-08-16 15:14:59 +07:00
commit 6a0d548f22
2 changed files with 55 additions and 13 deletions

View file

@ -73,14 +73,14 @@ namespace BMA.EHR.Application.Repositories.Commands
try try
{ {
var result = new List<CommandReceiver>(); var result = new List<CommandReceiver>();
// TODO : ต้องมา list คนตามประเภทอีกครั้งนึง
// 1. หารายชื่อที่ถูกเลือกไปแล้ว ในประเภทเดียวกัน // 1. หารายชื่อที่ถูกเลือกไปแล้ว ในประเภทเดียวกัน
var otherCommandReceivers = await _dbContext.Set<CommandReceiver>() var otherCommandReceivers = await _dbContext.Set<CommandReceiver>()
.Include(x => x.Command) .Include(x => x.Command)
.ThenInclude(x => x.CommandType) .ThenInclude(x => x.CommandType)
.Where(x => x.Command.CommandType.CommandCode.Trim().ToUpper() == "C-PM-01") .Where(x => x.Command.CommandType.CommandCode.Trim().ToUpper().StartsWith("C-PM"))
.Where(x => x.Id != command.Id) .Where(x => x.Command.Id != command.Id)
.Select(x => x.CitizenId) .Select(x => x.CitizenId)
.ToListAsync(); .ToListAsync();
@ -306,24 +306,61 @@ namespace BMA.EHR.Application.Repositories.Commands
{ {
Order = 1, Order = 1,
Date = command.CommandAffectDate, Date = command.CommandAffectDate,
Amount = placementProfile.Amount, Amount = placementProfile.Amount == null ? 0 : placementProfile.Amount,
PositionSalaryAmount = placementProfile.PositionSalaryAmount, PositionSalaryAmount = placementProfile.PositionSalaryAmount == null ? 0 : placementProfile.PositionSalaryAmount,
MouthSalaryAmount = placementProfile.MouthSalaryAmount, MouthSalaryAmount = placementProfile.MouthSalaryAmount == null ? 0 : placementProfile.MouthSalaryAmount,
SalaryClass = "",
SalaryRef = "บรรจุและแต่งตั้งผู้สอบแข่งขันได้วุฒิ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}", SalaryRef = "บรรจุและแต่งตั้งผู้สอบแข่งขันได้วุฒิ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
OcId = oc == null ? Guid.Empty : oc.Id, OcId = oc == null ? Guid.Empty : oc.Id,
PositionExecutiveId = placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutive!.Id,
PositionExecutiveSideId = placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutiveSide!.Id,
PositionLevel = placementProfile.PositionLevel, PositionLevel = placementProfile.PositionLevel,
PositionLineId = placementProfile.PositionLine!.Id, PositionLineId = placementProfile.PositionLine!.Id,
PositionTypeId = placementProfile.PositionType!.Id, PositionTypeId = placementProfile.PositionType!.Id,
OrganizationShortNameId = placementProfile.OrganizationPosition!.Organization!.OrganizationShortName!.Id, OrganizationShortNameId = placementProfile.OrganizationPosition!.Organization!.OrganizationShortName!.Id,
PosNoId = positionNumber!.Id,
CommandNo = $"{command.CommandNo}/{command.CommandYear}", CommandNo = $"{command.CommandNo}/{command.CommandYear}",
CommandTypeName = command.CommandType.Name CommandTypeName = command.CommandType.Name,
PositionEmployeeGroupId = null,
PositionEmployeeLevelId = null,
PositionEmployeePositionId = null,
PositionEmployeePositionSideId = null,
PosNoEmployee = "",
PositionPathSideId = placementProfile.PositionPathSide! == null ? null : placementProfile.PositionPathSide!.Id,
PositionExecutiveId = placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutive! == null ? null : placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutive!.Id,
PositionExecutiveSideId = placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutiveSide! == null ? null : placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutiveSide!.Id,
CreatedAt = DateTime.Now,
CreatedFullName = FullName,
CreatedUserId = UserId,
LastUpdatedAt = DateTime.Now,
LastUpdateFullName = FullName,
LastUpdateUserId = UserId,
}; };
//if (placementProfile.PositionPathSide! != null)
//{
// salary.PositionPathSideId = placementProfile.PositionPathSide!.Id;
//}
//else
//if (placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutive! != null)
//{
// salary.PositionExecutiveId = placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutive!.Id;
//}
//if (placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutiveSide! != null)
//{
// salary.PositionExecutiveSideId = placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutiveSide!.Id;
//}
// add profile position // add profile position
var profilePosition = new ProfilePosition var profilePosition = new ProfilePosition
{ {
@ -394,7 +431,6 @@ namespace BMA.EHR.Application.Repositories.Commands
} }
} }
#endregion #endregion
#endregion #endregion
@ -615,12 +651,14 @@ namespace BMA.EHR.Application.Repositories.Commands
try try
{ {
var current = await _dbContext.Set<CommandReceiver>() var current = await _dbContext.Set<CommandReceiver>()
.Include(c => c.Command)
.FirstOrDefaultAsync(x => x.Id == personalId); .FirstOrDefaultAsync(x => x.Id == personalId);
if (current == null) if (current == null)
throw new Exception(GlobalMessages.DataNotFound); throw new Exception(GlobalMessages.DataNotFound);
var currentSeq = current.Sequence; var currentSeq = current.Sequence;
var commandID = current.Command!.Id;
switch (direction.Trim().ToLower()) switch (direction.Trim().ToLower())
{ {
@ -628,8 +666,10 @@ namespace BMA.EHR.Application.Repositories.Commands
{ {
// get prev record // get prev record
var prev = await _dbContext.Set<CommandReceiver>() var prev = await _dbContext.Set<CommandReceiver>()
.OrderByDescending(x => x.Sequence) .Include(c => c.Command)
.Where(x => x.Command.Id == commandID)
.Where(x => x.Sequence < currentSeq) .Where(x => x.Sequence < currentSeq)
.OrderByDescending(x => x.Sequence)
.Take(1) .Take(1)
.FirstOrDefaultAsync(); .FirstOrDefaultAsync();
@ -647,8 +687,10 @@ namespace BMA.EHR.Application.Repositories.Commands
{ {
// get next record // get next record
var next = await _dbContext.Set<CommandReceiver>() var next = await _dbContext.Set<CommandReceiver>()
.OrderBy(x => x.Sequence) .Include(c => c.Command)
.Where(x => x.Command.Id == commandID)
.Where(x => x.Sequence > currentSeq) .Where(x => x.Sequence > currentSeq)
.OrderBy(x => x.Sequence)
.Take(1) .Take(1)
.FirstOrDefaultAsync(); .FirstOrDefaultAsync();