รายงานคำสั่ง c-pm-21

This commit is contained in:
Suphonchai Phoonsawat 2023-09-05 12:02:25 +07:00
parent 0c1a8f29cc
commit 33da6f2d70
4 changed files with 161 additions and 4 deletions

View file

@ -5,6 +5,7 @@ using BMA.EHR.Application.Responses.Reports;
using BMA.EHR.Domain.Extensions;
using BMA.EHR.Domain.Models.Commands.Core;
using BMA.EHR.Domain.Models.HR;
using BMA.EHR.Domain.Models.OrganizationEmployee;
using BMA.EHR.Domain.Models.Placement;
using BMA.EHR.Domain.Models.Retirement;
using BMA.EHR.Domain.Shared;
@ -856,6 +857,53 @@ namespace BMA.EHR.Application.Repositories.Commands
}
}
public async Task<List<CommandType21Response>> GetCommandType21AttachmentAsync(Guid id)
{
try
{
var raw_data = await _dbContext.Set<CommandReceiver>()
.Include(c => c.Command)
.Where(c => c.Command.Id == id)
.ToListAsync();
if (raw_data == null)
{
throw new Exception(GlobalMessages.CommandNotFound);
}
var report_data = (from r in raw_data
join p in _dbContext.Set<OrganizationEmployeeProfile>()
.Include(x => x.Profile)
.ThenInclude(x => x.Position)
.Include(x => x.Profile)
.ThenInclude(x => x.PositionLevel)
.Include(x => x.Profile)
.ThenInclude(x => x.PositionType)
.Include(x => x.Profile)
.ThenInclude(x => x.PosNo)
on r.RefPlacementProfileId equals p.Id
select new CommandType21Response
{
CitizenId = r.CitizenId,
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
Organization = p.Profile!.EmployeeOc,
PositionName = p.Profile.Position == null ? "" : p.Profile.Position.Name,
PositionLevel = p.Profile.PositionLevel == null ? "" : p.Profile.PositionLevel.Name,
PositionType = p.Profile.PositionType == null ? "" : p.Profile.PositionType.Name,
PositionNumber = p.Profile.PosNo == null ? "" : p.Profile.PosNo.Name,
Salary = r.Amount == null ? 0 : r.Amount.Value,
RetireDate = p.Profile.BirthDate.CalculateRetireDate().ToThaiFullDate3()
})
.ToList();
return report_data;
}
catch
{
throw;
}
}
#endregion
}
}