ค้นหาผู้เกียวข้องคำสั่ง

This commit is contained in:
DESKTOP-2S5P7D1\Windows 10 2023-09-06 11:52:48 +07:00
parent 83e1e41c62
commit e340beb79d
3 changed files with 27 additions and 21 deletions

View file

@ -3737,28 +3737,34 @@ namespace BMA.EHR.Application.Repositories.Commands
#endregion #endregion
public async Task<dynamic> GetCommandProfileAsync(Guid commandTypeId, int year, string? posno) public async Task<dynamic> GetCommandProfileAsync(string commandType, int year, string? posno)
{ {
try try
{ {
var commandType = await _dbContext.Set<CommandType>() var data = (from r in await _dbContext.Set<ProfileSalary>()
.FirstOrDefaultAsync(x => x.Id == commandTypeId); .Include(x => x.Profile)
.ThenInclude(x => x.Prefix)
if (commandType == null) .Include(x => x.Profile)
throw new Exception(GlobalMessages.CommandTypeNotFound); .ThenInclude(x => x.PosNo)
.Include(x => x.Profile)
var profile = await _dbContext.Set<Profile>() .ThenInclude(x => x.Position)
.Where(x => x.CitizenId == "0000000000001") .ToListAsync()
.Select(x => new where r.CommandTypeName == commandType
{ where r.CommandNo.Contains((year + 543).ToString())
Id = x.Id, where posno == null || posno == "" ? r.Id != null : r.CommandNo.Contains(posno)
CitizenId = x.CitizenId, where r.Profile != null
FullName = $"{x.Prefix.Name}{x.FirstName} {x.LastName}", select new
PosNo = x.PosNo == null ? null : x.PosNo.Name, {
Position = x.Position == null ? null : x.Position.Name, Id = r.Profile.Id,
}) CitizenId = r.Profile.CitizenId,
.ToListAsync(); FullName = $"{r.Profile.Prefix.Name}{r.Profile.FirstName} {r.Profile.LastName}",
return profile; PosNo = r.Profile.PosNo == null ? null : r.Profile.PosNo.Name,
Position = r.Profile.Position == null ? null : r.Profile.Position.Name,
})
.Distinct()
.OrderBy(x => x.CitizenId)
.ToList();
return data;
} }
catch catch
{ {

View file

@ -2,7 +2,7 @@
{ {
public class SearchProfileCommandRequest public class SearchProfileCommandRequest
{ {
public Guid CommandTypeId { get; set; } public string CommandType { get; set; }
public int Year { get; set; } public int Year { get; set; }

View file

@ -3439,7 +3439,7 @@ namespace BMA.EHR.Command.Service.Controllers
{ {
try try
{ {
var data = await _repository.GetCommandProfileAsync(req.CommandTypeId, req.Year, req.Posno); var data = await _repository.GetCommandProfileAsync(req.CommandType, req.Year, req.Posno);
return Success(data); return Success(data);
} }