Command C-PM-22, C-PM-23 เพิ่มการบะนทึกหน้าคำสั่ง และเลือกแนบท้าย
This commit is contained in:
parent
76aad42e9a
commit
2bfa6ae500
3 changed files with 314 additions and 0 deletions
|
|
@ -146,6 +146,12 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
case "C-PM-21":
|
||||
result = await GetReceiver21Async(command);
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
@ -1202,6 +1208,7 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
.ThenInclude(x => x.Prefix)
|
||||
//.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId)
|
||||
.Where(x => !otherCommandReceivers.Contains(x.Profile!.CitizenId!))
|
||||
.Where(x => x.Profile.ProfileType == "officer")
|
||||
.Where(x => x.Status.Trim().ToUpper() == "REPORT")
|
||||
.OrderBy(x => x.Profile!.CitizenId)
|
||||
.ToListAsync();
|
||||
|
|
@ -1464,6 +1471,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
|
||||
|
||||
#region " Execute and Deploy "
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue