เพิ่มรายการดึงรายชื่อผู้รับคำสั่ง ขาด 10-11-12
รอถามอุ๋ย
This commit is contained in:
parent
85f7099c11
commit
7cd2f7d82f
1 changed files with 796 additions and 1 deletions
|
|
@ -9,6 +9,7 @@ using BMA.EHR.Domain.Models.MetaData;
|
||||||
using BMA.EHR.Domain.Models.Notifications;
|
using BMA.EHR.Domain.Models.Notifications;
|
||||||
using BMA.EHR.Domain.Models.Organizations;
|
using BMA.EHR.Domain.Models.Organizations;
|
||||||
using BMA.EHR.Domain.Models.Placement;
|
using BMA.EHR.Domain.Models.Placement;
|
||||||
|
using BMA.EHR.Domain.Models.Retirement;
|
||||||
using BMA.EHR.Domain.Shared;
|
using BMA.EHR.Domain.Shared;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
@ -82,6 +83,45 @@ namespace BMA.EHR.Application.Repositories.Commands
|
||||||
case "C-PM-04":
|
case "C-PM-04":
|
||||||
result = await GetReceiver04Async(command);
|
result = await GetReceiver04Async(command);
|
||||||
break;
|
break;
|
||||||
|
case "C-PM-05":
|
||||||
|
result = await GetReceiver05Async(command);
|
||||||
|
break;
|
||||||
|
case "C-PM-06":
|
||||||
|
result = await GetReceiver06Async(command);
|
||||||
|
break;
|
||||||
|
case "C-PM-07":
|
||||||
|
result = await GetReceiver07Async(command);
|
||||||
|
break;
|
||||||
|
case "C-PM-08":
|
||||||
|
result = await GetReceiver08Async(command);
|
||||||
|
break;
|
||||||
|
case "C-PM-09":
|
||||||
|
result = await GetReceiver09Async(command);
|
||||||
|
break;
|
||||||
|
case "C-PM-13":
|
||||||
|
result = await GetReceiver13Async(command);
|
||||||
|
break;
|
||||||
|
case "C-PM-14":
|
||||||
|
result = await GetReceiver14Async(command);
|
||||||
|
break;
|
||||||
|
case "C-PM-15":
|
||||||
|
result = await GetReceiver15Async(command);
|
||||||
|
break;
|
||||||
|
case "C-PM-16":
|
||||||
|
result = await GetReceiver16Async(command);
|
||||||
|
break;
|
||||||
|
case "C-PM-17":
|
||||||
|
result = await GetReceiver17Async(command);
|
||||||
|
break;
|
||||||
|
case "C-PM-18":
|
||||||
|
result = await GetReceiver18Async(command);
|
||||||
|
break;
|
||||||
|
case "C-PM-19":
|
||||||
|
result = await GetReceiver19Async(command);
|
||||||
|
break;
|
||||||
|
case "C-PM-20":
|
||||||
|
result = await GetReceiver20Async(command);
|
||||||
|
break;
|
||||||
default: throw new Exception(GlobalMessages.MethodForCommandTypeNotImplement);
|
default: throw new Exception(GlobalMessages.MethodForCommandTypeNotImplement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -299,7 +339,7 @@ namespace BMA.EHR.Application.Repositories.Commands
|
||||||
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-03")
|
.Where(x => x.Command.CommandType.CommandCode.Trim().ToUpper() == "C-PM-04")
|
||||||
.Where(x => x.Command.Id != command.Id)
|
.Where(x => x.Command.Id != command.Id)
|
||||||
.Select(x => x.CitizenId)
|
.Select(x => x.CitizenId)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
@ -349,6 +389,761 @@ namespace BMA.EHR.Application.Repositories.Commands
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// C-PM-05 - คำสั่งแต่งตั้ง
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task<List<CommandReceiver>> GetReceiver05Async(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-05")
|
||||||
|
.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)
|
||||||
|
//.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)
|
||||||
|
.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
|
||||||
|
};
|
||||||
|
seq++;
|
||||||
|
|
||||||
|
result.Add(receiver);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// C-PM-06 - คำสั่งเลื่อน
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task<List<CommandReceiver>> GetReceiver06Async(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-06")
|
||||||
|
.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)
|
||||||
|
//.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)
|
||||||
|
.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
|
||||||
|
};
|
||||||
|
seq++;
|
||||||
|
|
||||||
|
result.Add(receiver);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// C-PM-07 - คำสั่งย้าย
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task<List<CommandReceiver>> GetReceiver07Async(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-07")
|
||||||
|
.Where(x => x.Command.Id != command.Id)
|
||||||
|
.Select(x => x.CitizenId)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
// 2. Query
|
||||||
|
var appointPeople = await _dbContext.Set<PlacementRelocation>()
|
||||||
|
.Include(x => x.Prefix)
|
||||||
|
.Include(x => x.OrganizationPosition)
|
||||||
|
.ThenInclude(x => x!.Organization)
|
||||||
|
//.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId)
|
||||||
|
.Where(x => !otherCommandReceivers.Contains(x.CitizenId!))
|
||||||
|
.Where(x => x.Status.Trim().ToUpper() == "REPORT")
|
||||||
|
.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
|
||||||
|
};
|
||||||
|
seq++;
|
||||||
|
|
||||||
|
result.Add(receiver);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// C-PM-08 - คำสั่งบรรจุและแต่งตั้งข้าราชการฯ กลับเข้ารับราชการ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task<List<CommandReceiver>> GetReceiver08Async(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-08")
|
||||||
|
.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)
|
||||||
|
//.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)
|
||||||
|
.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
|
||||||
|
};
|
||||||
|
seq++;
|
||||||
|
|
||||||
|
result.Add(receiver);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// C-PM-09 - คำสั่งบรรจุและแต่งตั้งผู้ออกไปรับราชการทหารกลับเข้ารับราชการ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task<List<CommandReceiver>> GetReceiver09Async(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-09")
|
||||||
|
.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)
|
||||||
|
//.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)
|
||||||
|
.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
|
||||||
|
};
|
||||||
|
seq++;
|
||||||
|
|
||||||
|
result.Add(receiver);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// C-PM-13 - คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task<List<CommandReceiver>> GetReceiver13Async(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-13")
|
||||||
|
.Where(x => x.Command.Id != command.Id)
|
||||||
|
.Select(x => x.CitizenId)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
// 2. Query
|
||||||
|
var appointPeople = await _dbContext.Set<PlacementTransfer>()
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// C-PM-14 - คำสั่งรับโอนข้าราชการกรุงเทพมหานครสามัญ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task<List<CommandReceiver>> GetReceiver14Async(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-14")
|
||||||
|
.Where(x => x.Command.Id != command.Id)
|
||||||
|
.Select(x => x.CitizenId)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
// 2. Query
|
||||||
|
var appointPeople = await _dbContext.Set<PlacementReceive>()
|
||||||
|
.Include(x => x.Prefix)
|
||||||
|
.Include(x => x.OrganizationPosition)
|
||||||
|
.ThenInclude(x => x!.Organization)
|
||||||
|
//.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId)
|
||||||
|
.Where(x => !otherCommandReceivers.Contains(x.CitizenId!))
|
||||||
|
.Where(x => x.Status.Trim().ToUpper() == "REPORT")
|
||||||
|
.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
|
||||||
|
};
|
||||||
|
seq++;
|
||||||
|
|
||||||
|
result.Add(receiver);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// C-PM-15 - คำสั่งให้ช่วยราชการ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task<List<CommandReceiver>> GetReceiver15Async(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-15")
|
||||||
|
.Where(x => x.Command.Id != command.Id)
|
||||||
|
.Select(x => x.CitizenId)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
// 2. Query
|
||||||
|
var appointPeople = await _dbContext.Set<PlacementOfficer>()
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// C-PM-16 - คำสั่งส่งตัวกลับ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task<List<CommandReceiver>> GetReceiver16Async(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-16")
|
||||||
|
.Where(x => x.Command.Id != command.Id)
|
||||||
|
.Select(x => x.CitizenId)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
// 2. Query
|
||||||
|
var appointPeople = await _dbContext.Set<PlacementRepatriation>()
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// C-PM-17 - คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task<List<CommandReceiver>> GetReceiver17Async(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-17")
|
||||||
|
.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.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// C-PM-18 - คำสั่งให้ออกจากราชการ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task<List<CommandReceiver>> GetReceiver18Async(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-18")
|
||||||
|
.Where(x => x.Command.Id != command.Id)
|
||||||
|
.Select(x => x.CitizenId)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
// 2. Query
|
||||||
|
var appointPeople = await _dbContext.Set<RetirementOut>()
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// C-PM-19 - คำสั่งปลดออกจากราชการ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task<List<CommandReceiver>> GetReceiver19Async(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-19")
|
||||||
|
.Where(x => x.Command.Id != command.Id)
|
||||||
|
.Select(x => x.CitizenId)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
// 2. Query
|
||||||
|
var appointPeople = await _dbContext.Set<RetirementDischarge>()
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// C-PM-20 - คำสั่งไล่ออกจากราชการ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task<List<CommandReceiver>> GetReceiver20Async(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-20")
|
||||||
|
.Where(x => x.Command.Id != command.Id)
|
||||||
|
.Select(x => x.CitizenId)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
// 2. Query
|
||||||
|
var appointPeople = await _dbContext.Set<RetirementExpulsion>()
|
||||||
|
.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
|
#endregion
|
||||||
|
|
||||||
#region " Execute and Deploy "
|
#region " Execute and Deploy "
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue