C-PM-21 คำสั่งแต่งตั้งลูกจ้างชั่วคราวเป็นลูกจ้างประจำ
This commit is contained in:
parent
3b24682301
commit
78cd9a8156
4 changed files with 162 additions and 1 deletions
|
|
@ -6,6 +6,7 @@ using BMA.EHR.Domain.Models.Commands.Core;
|
|||
using BMA.EHR.Domain.Models.HR;
|
||||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using BMA.EHR.Domain.Models.Notifications;
|
||||
using BMA.EHR.Domain.Models.OrganizationEmployee;
|
||||
using BMA.EHR.Domain.Models.Organizations;
|
||||
using BMA.EHR.Domain.Models.Placement;
|
||||
using BMA.EHR.Domain.Models.Retirement;
|
||||
|
|
@ -136,6 +137,9 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
case "C-PM-20":
|
||||
result = await GetReceiver20Async(command);
|
||||
break;
|
||||
case "C-PM-21":
|
||||
result = await GetReceiver21Async(command);
|
||||
break;
|
||||
default: throw new Exception(GlobalMessages.MethodForCommandTypeNotImplement);
|
||||
}
|
||||
|
||||
|
|
@ -1377,6 +1381,63 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// C-PM-21 - คำสั่งแต่งตั้งลูกจ้างชั่วคราวเป็นลูกจ้างประจำ
|
||||
/// </summary>
|
||||
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||
/// <returns></returns>
|
||||
private async Task<List<CommandReceiver>> GetReceiver21Async(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-21")
|
||||
.Where(x => x.Command.Id != command.Id)
|
||||
.Select(x => x.CitizenId)
|
||||
.ToListAsync();
|
||||
|
||||
// 2. Query
|
||||
var appointPeople = await _dbContext.Set<OrganizationEmployeeProfile>()
|
||||
.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.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
|
||||
};
|
||||
seq++;
|
||||
|
||||
result.Add(receiver);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Execute and Deploy "
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue