1398 lines
90 KiB
C#
1398 lines
90 KiB
C#
using System.Net.Http.Headers;
|
|
using BMA.EHR.Application.Common.Interfaces;
|
|
using BMA.EHR.Application.Responses;
|
|
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;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace BMA.EHR.Application.Repositories.Commands
|
|
{
|
|
public class CommandReportRepository : GenericRepository<Guid, Command>
|
|
{
|
|
#region " Fields "
|
|
|
|
private readonly IApplicationDBContext _dbContext;
|
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
|
private readonly OrganizationCommonRepository _organizationCommonRepository;
|
|
private readonly UserProfileRepository _userProfileRepository;
|
|
private readonly IConfiguration _configuration;
|
|
|
|
#endregion
|
|
|
|
#region " Constructor and Destuctor "
|
|
|
|
public CommandReportRepository(IApplicationDBContext dbContext,
|
|
IHttpContextAccessor httpContextAccessor,
|
|
OrganizationCommonRepository organizationCommonRepository,
|
|
IConfiguration configuration,
|
|
UserProfileRepository userProfileRepository) : base(dbContext, httpContextAccessor)
|
|
{
|
|
_dbContext = dbContext;
|
|
_httpContextAccessor = httpContextAccessor;
|
|
_organizationCommonRepository = organizationCommonRepository;
|
|
_userProfileRepository = userProfileRepository;
|
|
_configuration = configuration;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " Properties "
|
|
|
|
protected Guid UserOrganizationId
|
|
{
|
|
get
|
|
{
|
|
if (UserId != null || UserId != "")
|
|
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!), AccessToken);
|
|
else
|
|
return Guid.Empty;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " Methods "
|
|
|
|
public async Task<List<CommandType01Response>> GetCommandType01AttachmentAsync(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<PlacementProfile>()
|
|
.Include(x => x.PlacementEducations)
|
|
.Include(x => x.Placement)
|
|
// .Include(x => x.OrganizationPosition)
|
|
// .ThenInclude(x => x.Organization)
|
|
// .Include(x => x.PositionPath)
|
|
// .Include(x => x.PositionLevel)
|
|
// .Include(x => x.PositionNumber)
|
|
// .Include(x => x.PositionType)
|
|
on r.RefPlacementProfileId equals p.Id
|
|
orderby r.Sequence
|
|
select new CommandType01Response
|
|
{
|
|
Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" :
|
|
p.PlacementEducations.FirstOrDefault().Degree,
|
|
Seq = r.Sequence.ToString().ToThaiNumber(),
|
|
CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(),
|
|
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
|
Oc = p.root == null ? "" : p.root,
|
|
PositionName = p.positionName == null ? "" : p.positionName,
|
|
PositionLevel = p.posLevelName == null ? "" : p.posLevelName,
|
|
PositionType = p.posTypeName == null ? "" : p.posTypeName,
|
|
PositionNumber = p.posMasterNo == null ? "" :
|
|
p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "",
|
|
Salary = p.Amount == null ? "0" : p.Amount.Value.ToNumericNoDecimalText().ToThaiNumber().ToThaiNumber(),
|
|
AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(),
|
|
ExamNumber = p.ExamNumber == null ? "0" : p.ExamNumber.Value.ToString().ToThaiNumber(),
|
|
PlacementName = $"{p.Placement.Name.ToThaiNumber()} ครั้งที่ {p.Placement.Round.ToThaiNumber()}/{p.Placement.Year.ToThaiYear().ToString().ToThaiNumber()}",
|
|
RemarkHorizontal = p.RemarkHorizontal,
|
|
RemarkVertical = p.RemarkVertical,
|
|
}).ToList();
|
|
|
|
return report_data;
|
|
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<CommandType01Response>> GetCommandType02AttachmentAsync(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<PlacementProfile>()
|
|
.Include(x => x.PlacementEducations)
|
|
.Include(x => x.Placement)
|
|
.Include(x => x.OrganizationPosition)
|
|
.ThenInclude(x => x.Organization)
|
|
.Include(x => x.PositionPath)
|
|
.Include(x => x.PositionLevel)
|
|
.Include(x => x.PositionNumber)
|
|
.Include(x => x.PositionType)
|
|
on r.RefPlacementProfileId equals p.Id
|
|
orderby r.Sequence
|
|
select new CommandType01Response
|
|
{
|
|
Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" :
|
|
p.PlacementEducations.FirstOrDefault().Degree,
|
|
Seq = r.Sequence.ToString().ToThaiNumber(),
|
|
CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(),
|
|
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
|
Oc = p.root == null ? "" : p.root,
|
|
PositionName = p.positionName == null ? "" : p.positionName,
|
|
PositionLevel = p.posLevelName == null ? "" : p.posLevelName,
|
|
PositionType = p.posTypeName == null ? "" : p.posTypeName,
|
|
PositionNumber = p.posMasterNo == null ? "" :
|
|
p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "",
|
|
Salary = p.Amount == null ? "" : p.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(),
|
|
ExamNumber = p.ExamNumber == null ? "" : p.ExamNumber.Value.ToString().ToThaiNumber(),
|
|
PlacementName = $"{p.Placement.Name.ToThaiNumber()} ครั้งที่ {p.Placement.Round.ToThaiNumber()}/{p.Placement.Year.ToThaiYear().ToString().ToThaiNumber()}",
|
|
RemarkHorizontal = p.RemarkHorizontal,
|
|
RemarkVertical = p.RemarkVertical,
|
|
}).ToList();
|
|
|
|
return report_data;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<CommandType03Response>> GetCommandType03AttachmentAsync(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<PlacementProfile>()
|
|
.Include(x => x.PlacementEducations)
|
|
.Include(x => x.Placement)
|
|
.Include(x => x.OrganizationPosition)
|
|
.ThenInclude(x => x.Organization)
|
|
.Include(x => x.PositionPath)
|
|
.Include(x => x.PositionLevel)
|
|
.Include(x => x.PositionNumber)
|
|
.Include(x => x.PositionType)
|
|
on r.RefPlacementProfileId equals p.Id
|
|
orderby r.Sequence
|
|
select new CommandType03Response
|
|
{
|
|
Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" :
|
|
p.PlacementEducations.FirstOrDefault().Degree,
|
|
Seq = r.Sequence.ToString().ToThaiNumber(),
|
|
CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(),
|
|
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
|
OldOc = p.rootOld == null ? "" : p.rootOld,
|
|
//Probation = pf.IsProbation ? "(อยู่ระหว่างปฏิบัติหน้าที่ราชการ)" : "",
|
|
Probation = "",
|
|
OldPositionName = p.positionNameOld == null ? "" : p.positionNameOld,
|
|
OldPositionLevel = p.posLevelNameOld == null ? "" : p.posLevelNameOld,
|
|
OldPositionType = p.posTypeNameOld == null ? "" : p.posTypeNameOld,
|
|
OldPositionNumber = p.posMasterNoOld == null ? "" :
|
|
p.nodeOld == "4" ? $"{p.child4ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() :
|
|
p.nodeOld == "3" ? $"{p.child3ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() :
|
|
p.nodeOld == "2" ? $"{p.child2ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() :
|
|
p.nodeOld == "1" ? $"{p.child1ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() :
|
|
p.nodeOld == "0" ? $"{p.rootShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : "",
|
|
OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
|
|
NewOc = p.root == null ? "" : p.root,
|
|
NewPositionName = p.positionName == null ? "" : p.positionName,
|
|
NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName,
|
|
NewPositionType = p.posTypeName == null ? "" : p.posTypeName,
|
|
NewPositionNumber = p.posMasterNo == null ? "" :
|
|
p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "",
|
|
NewSalary = p.Amount == null ? "" : p.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(),
|
|
RemarkHorizontal = p.RemarkHorizontal,
|
|
RemarkVertical = p.RemarkVertical,
|
|
})
|
|
.ToList();
|
|
|
|
return report_data;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<CommandType03Response>> GetCommandType04AttachmentAsync(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<PlacementProfile>()
|
|
.Include(x => x.PlacementEducations)
|
|
.Include(x => x.Placement)
|
|
.Include(x => x.OrganizationPosition)
|
|
.ThenInclude(x => x.Organization)
|
|
.Include(x => x.PositionPath)
|
|
.Include(x => x.PositionLevel)
|
|
.Include(x => x.PositionNumber)
|
|
.Include(x => x.PositionType)
|
|
on r.RefPlacementProfileId equals p.Id
|
|
orderby r.Sequence
|
|
select new CommandType03Response
|
|
{
|
|
Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" :
|
|
p.PlacementEducations.FirstOrDefault().Degree,
|
|
Seq = r.Sequence.ToString().ToThaiNumber(),
|
|
CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(),
|
|
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
|
OldOc = p.rootOld == null ? "" : p.rootOld,
|
|
OldPositionName = p.positionNameOld == null ? "" : p.positionNameOld,
|
|
OldPositionLevel = p.posLevelNameOld == null ? "" : p.posLevelNameOld,
|
|
OldPositionType = p.posTypeNameOld == null ? "" : p.posTypeNameOld,
|
|
OldPositionNumber = p.posMasterNoOld == null ? "" :
|
|
p.nodeOld == "4" ? $"{p.child4ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() :
|
|
p.nodeOld == "3" ? $"{p.child3ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() :
|
|
p.nodeOld == "2" ? $"{p.child2ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() :
|
|
p.nodeOld == "1" ? $"{p.child1ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() :
|
|
p.nodeOld == "0" ? $"{p.rootShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : "",
|
|
OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
NewOc = p.root == null ? "" : p.root,
|
|
NewPositionName = p.positionName == null ? "" : p.positionName,
|
|
NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName,
|
|
NewPositionType = p.posTypeName == null ? "" : p.posTypeName,
|
|
NewPositionNumber = p.posMasterNo == null ? "" :
|
|
p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "",
|
|
NewSalary = p.Amount == null ? "" : p.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber()
|
|
})
|
|
.ToList();
|
|
|
|
return report_data;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<CommandType03Response>> GetCommandType39AttachmentAsync(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<PlacementProfile>()
|
|
.Include(x => x.PlacementEducations)
|
|
.Include(x => x.Placement)
|
|
.Include(x => x.OrganizationPosition)
|
|
.ThenInclude(x => x.Organization)
|
|
.Include(x => x.PositionPath)
|
|
.Include(x => x.PositionLevel)
|
|
.Include(x => x.PositionNumber)
|
|
.Include(x => x.PositionType)
|
|
on r.RefPlacementProfileId equals p.Id
|
|
orderby r.Sequence
|
|
select new CommandType03Response
|
|
{
|
|
Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" :
|
|
p.PlacementEducations.FirstOrDefault().Degree,
|
|
Seq = r.Sequence.ToString().ToThaiNumber(),
|
|
CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(),
|
|
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
|
OldOc = p.rootOld == null ? "" : p.rootOld,
|
|
OldPositionName = p.positionNameOld == null ? "" : p.positionNameOld,
|
|
OldPositionLevel = p.posLevelNameOld == null ? "" : p.posLevelNameOld,
|
|
OldPositionType = p.posTypeNameOld == null ? "" : p.posTypeNameOld,
|
|
OldPositionNumber = p.posMasterNoOld == null ? "" :
|
|
p.nodeOld == "4" ? $"{p.child4ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() :
|
|
p.nodeOld == "3" ? $"{p.child3ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() :
|
|
p.nodeOld == "2" ? $"{p.child2ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() :
|
|
p.nodeOld == "1" ? $"{p.child1ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() :
|
|
p.nodeOld == "0" ? $"{p.rootShortNameOld}{p.posMasterNoOld}".ToThaiNumber() : "",
|
|
OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
NewOc = p.root == null ? "" : p.root,
|
|
NewPositionName = p.positionName == null ? "" : p.positionName,
|
|
NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName,
|
|
NewPositionType = p.posTypeName == null ? "" : p.posTypeName,
|
|
NewPositionNumber = p.posMasterNo == null ? "" :
|
|
p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "",
|
|
NewSalary = p.Amount == null ? "" : p.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber()
|
|
})
|
|
.ToList();
|
|
|
|
return report_data;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<CommandType03Response>> GetCommandType05_06AttachmentAsync(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<PlacementAppointment>()
|
|
// .Include(x => x.OrganizationPosition)
|
|
// .ThenInclude(x => x.Organization)
|
|
// .Include(x => x.PositionPath)
|
|
// .Include(x => x.PositionLevel)
|
|
// .Include(x => x.PositionNumber)
|
|
// .Include(x => x.PositionType)
|
|
on r.RefPlacementProfileId equals p.Id
|
|
// join pf in _dbContext.Set<Profile>()
|
|
// .Include(x => x.Position)
|
|
// .Include(x => x.PositionLevel)
|
|
// .Include(x => x.PositionType)
|
|
// .Include(x => x.PosNo)
|
|
// .Include(x => x.Salaries)
|
|
// .Include(x => x.Educations)
|
|
// on r.CitizenId equals pf.CitizenId
|
|
orderby r.Sequence
|
|
select new CommandType03Response
|
|
{
|
|
Education = p.EducationOld == null ? "-" : p.EducationOld,
|
|
Seq = r.Sequence.ToString().ToThaiNumber(),
|
|
CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(),
|
|
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
|
OldOc = p.rootOld == null ? "" : p.rootOld,
|
|
OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld,
|
|
OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld,
|
|
OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld,
|
|
OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(),
|
|
OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(),
|
|
NewOc = p.root == null ? "" : p.root,
|
|
NewPositionName = p.position == null ? "" : p.position,
|
|
NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName,
|
|
NewPositionType = p.posTypeName == null ? "" : p.posTypeName,
|
|
NewPositionNumber = p.posMasterNo == null ? "" :
|
|
p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "",
|
|
NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(),
|
|
Reason = p.Reason == null ? "-" : p.Reason,
|
|
})
|
|
.ToList();
|
|
|
|
return report_data;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<CommandType03Response>> GetCommandType07AttachmentAsync(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<PlacementAppointment>()
|
|
// .Include(x => x.OrganizationPosition)
|
|
// .ThenInclude(x => x.Organization)
|
|
// .Include(x => x.PositionPath)
|
|
// .Include(x => x.PositionLevel)
|
|
// .Include(x => x.PositionNumber)
|
|
// .Include(x => x.PositionType)
|
|
on r.RefPlacementProfileId equals p.Id
|
|
// join pf in _dbContext.Set<Profile>()
|
|
// .Include(x => x.Position)
|
|
// .Include(x => x.PositionLevel)
|
|
// .Include(x => x.PositionType)
|
|
// .Include(x => x.PosNo)
|
|
// .Include(x => x.Salaries)
|
|
// .Include(x => x.Educations)
|
|
// on r.CitizenId equals pf.CitizenId
|
|
orderby r.Sequence
|
|
select new CommandType03Response
|
|
{
|
|
// Education = pf.Educations == null || pf.Educations.Count == 0 ? "" :
|
|
// pf.Educations.OrderByDescending(x => x.StartDate).FirstOrDefault().Degree,
|
|
Education = p.EducationOld == null ? "-" : p.EducationOld,
|
|
Seq = r.Sequence.ToString().ToThaiNumber(),
|
|
CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(),
|
|
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
|
OldOc = p.rootOld == null ? "" : p.rootOld,
|
|
OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld,
|
|
OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld,
|
|
OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld,
|
|
OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(),
|
|
OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(),
|
|
NewOc = p.root == null ? "" : p.root,
|
|
NewPositionName = p.position == null ? "" : p.position,
|
|
NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName,
|
|
NewPositionType = p.posTypeName == null ? "" : p.posTypeName,
|
|
NewPositionNumber = p.posMasterNo == null ? "" :
|
|
p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "",
|
|
NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(),
|
|
Reason = p.Reason == null ? "-" : p.Reason,
|
|
})
|
|
.ToList();
|
|
|
|
return report_data;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<CommandType03Response>> GetCommandType08AttachmentAsync(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<RetirementOther>()
|
|
on r.RefPlacementProfileId equals p.Id
|
|
orderby r.Sequence
|
|
select new CommandType03Response
|
|
{
|
|
Education = p.EducationOld == null ? "-" : p.EducationOld,
|
|
Seq = r.Sequence.ToString().ToThaiNumber(),
|
|
CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(),
|
|
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
|
OldOc = p.rootOld == null ? "" : p.rootOld,
|
|
OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld,
|
|
OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld,
|
|
OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld,
|
|
OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(),
|
|
OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(),
|
|
NewOc = p.rootOld == null ? "" : p.rootOld,
|
|
NewPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld,
|
|
NewPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld,
|
|
NewPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld,
|
|
NewPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(),
|
|
NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
AppointDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(),
|
|
LeaveDate = p.LeaveDate == null ? "" : p.LeaveDate.Value.ToThaiShortDate2().ToThaiNumber(),
|
|
Reason = p.Reason == null ? "-" : p.Reason,
|
|
})
|
|
.ToList();
|
|
|
|
return report_data;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<CommandType03Response>> GetCommandType09AttachmentAsync(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<RetirementOther>()
|
|
on r.RefPlacementProfileId equals p.Id
|
|
orderby r.Sequence
|
|
select new CommandType03Response
|
|
{
|
|
Education = p.EducationOld == null ? "-" : p.EducationOld,
|
|
Seq = r.Sequence.ToString().ToThaiNumber(),
|
|
CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(),
|
|
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
|
OldOc = p.rootOld == null ? "" : p.rootOld,
|
|
OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld,
|
|
OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld,
|
|
OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld,
|
|
OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(),
|
|
OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(),
|
|
NewOc = p.rootOld == null ? "" : p.rootOld,
|
|
NewPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld,
|
|
NewPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld,
|
|
NewPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld,
|
|
NewPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(),
|
|
NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
AppointDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(),
|
|
LeaveDate = p.LeaveDate == null ? "" : p.LeaveDate.Value.ToThaiShortDate2().ToThaiNumber(),
|
|
MilitaryDate = p.MilitaryDate == null ? "" : p.MilitaryDate.Value.ToThaiShortDate2().ToThaiNumber(),
|
|
Reason = p.Reason == null ? "-" : p.Reason,
|
|
})
|
|
.ToList();
|
|
|
|
return report_data;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<CommandType11Response>> GetCommandType11Async(Guid id)
|
|
{
|
|
try
|
|
{
|
|
var raw_data = await _dbContext.Set<CommandReceiver>()
|
|
.Include(c => c.Command)
|
|
.Where(c => c.Command.Id == id)
|
|
.Select(r => new CommandType11Response
|
|
{
|
|
CommandNo = r.Command.CommandNo.ToThaiNumber(),
|
|
CommandYear = r.Command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(),
|
|
CommandAffectDate = r.Command.CommandAffectDate == null ? "" : r.Command.CommandAffectDate.Value.ToThaiFullDate3().ToThaiNumber(),
|
|
IssuerOrganizationName = r.Command.IssuerOrganizationName,
|
|
AuthorizedUserFullName = r.Command.AuthorizedUserFullName,
|
|
AuthorizedPosition = r.Command.AuthorizedPosition,
|
|
CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(),
|
|
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
|
PlacementCommandIssuer = r.Command.PlacementCommandIssuer ?? "",
|
|
PlacementCommandNo = r.Command.PlacementCommandNo == null ? "" : r.Command.PlacementCommandNo.ToThaiNumber(),
|
|
PlacementCommandDate = r.Command.PlacementCommandDate == null ? "" : r.Command.PlacementCommandDate.Value.ToThaiFullDate3().ToThaiNumber(),
|
|
Subject = $"เรื่อง {r.Command.CommandSubject}",
|
|
})
|
|
.ToListAsync();
|
|
if (raw_data == null)
|
|
{
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
}
|
|
|
|
return raw_data;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<CommandType11Response>> GetCommandType12Async(Guid id)
|
|
{
|
|
try
|
|
{
|
|
var raw_data = await _dbContext.Set<CommandReceiver>()
|
|
.Include(c => c.Command)
|
|
.Where(c => c.Command.Id == id)
|
|
.Select(r => new CommandType11Response
|
|
{
|
|
CommandNo = r.Command.CommandNo.ToThaiNumber(),
|
|
CommandYear = r.Command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(),
|
|
CommandAffectDate = r.Command.CommandAffectDate == null ? "" : r.Command.CommandAffectDate.Value.ToThaiFullDate3().ToThaiNumber(),
|
|
IssuerOrganizationName = r.Command.IssuerOrganizationName,
|
|
AuthorizedUserFullName = r.Command.AuthorizedUserFullName,
|
|
AuthorizedPosition = r.Command.AuthorizedPosition,
|
|
CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(),
|
|
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
|
PlacementCommandIssuer = r.Command.PlacementCommandIssuer ?? "",
|
|
PlacementCommandNo = r.Command.PlacementCommandNo == null ? "" : r.Command.PlacementCommandNo.ToThaiNumber(),
|
|
PlacementCommandDate = r.Command.PlacementCommandDate == null ? "" : r.Command.PlacementCommandDate.Value.ToThaiFullDate3().ToThaiNumber(),
|
|
Subject = $"เรื่อง {r.Command.CommandSubject}",
|
|
})
|
|
.ToListAsync();
|
|
if (raw_data == null)
|
|
{
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
}
|
|
|
|
return raw_data;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<CommandType13Response>> GetCommandType13AttachmentAsync(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<PlacementTransfer>()
|
|
on r.RefPlacementProfileId equals p.Id
|
|
orderby r.Sequence
|
|
select new CommandType13Response
|
|
{
|
|
Seq = r.Sequence.ToString().ToThaiNumber(),
|
|
CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(),
|
|
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
|
Organization = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld,
|
|
PositionName = p.PositionOld == null ? "" : p.PositionOld,
|
|
PositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld,
|
|
PositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld,
|
|
PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(),
|
|
Salary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
//Salary = pf.Salaries == null || pf.Salaries.Count == 0 ? "" : pf.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
ActiveDate = p.Date == null ? "" : p.Date.Value.ToThaiShortDate2().ToThaiNumber(),
|
|
ReceiveOrganizationName = r.Command!.ReceiveOrganizationName ?? "",
|
|
Reason = p.Reason ?? ""
|
|
})
|
|
.ToList();
|
|
|
|
return report_data;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<CommandType03Response>> GetCommandType14AttachmentAsync(Guid id)
|
|
{
|
|
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<PlacementReceive>()
|
|
// .Include(x => x.OrganizationPosition)
|
|
// .ThenInclude(x => x.Organization)
|
|
// .Include(x => x.PositionPath)
|
|
// .Include(x => x.PositionLevel)
|
|
// .Include(x => x.PositionNumber)
|
|
// .Include(x => x.PositionType)
|
|
on r.RefPlacementProfileId equals p.Id
|
|
orderby r.Sequence
|
|
select new CommandType03Response
|
|
{
|
|
Education = p.EducationOld == null ? "-" : p.EducationOld,
|
|
Seq = r.Sequence.ToString().ToThaiNumber(),
|
|
CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(),
|
|
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
|
OldOc = p.OrganizationPositionOld ?? "",
|
|
OldPositionName = p.OrganizationPositionOld ?? "",
|
|
OldPositionLevel = p.PositionLevelOld ?? "",
|
|
OldPositionType = p.PositionTypeOld ?? "",
|
|
OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(),
|
|
OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
NewOc = p.root == null ? "" : p.root,
|
|
NewPositionName = p.position == null ? "" : p.position,
|
|
NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName,
|
|
NewPositionType = p.posTypeName == null ? "" : p.posTypeName,
|
|
NewPositionNumber = p.posMasterNo == null ? "" :
|
|
p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "",
|
|
NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(),
|
|
Reason = p.Reason == null ? "-" : p.Reason,
|
|
})
|
|
.ToList();
|
|
|
|
return report_data;
|
|
}
|
|
|
|
public async Task<List<CommandType15Response>> GetCommandType15AttachmentAsync(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<PlacementOfficer>()
|
|
//.Include(p => p.Profile)
|
|
//.ThenInclude(p => p.Position)
|
|
on r.RefPlacementProfileId equals p.Id
|
|
orderby r.Sequence
|
|
select new CommandType15Response
|
|
{
|
|
Seq = r.Sequence.ToString().ToThaiNumber(),
|
|
CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(),
|
|
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
|
PositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld,
|
|
// PositionName = p.Profile.Position == null ? "" : p.Profile.Position.Name,
|
|
Organization = p.Organization == null ? "" : p.Organization,
|
|
StartDate = p.DateStart == null ? "" : p.DateStart.Value.ToThaiShortDate2().ToThaiNumber(),
|
|
EndDate = p.DateEnd == null ? "" : p.DateEnd.Value.ToThaiShortDate2().ToThaiNumber(),
|
|
Reason = p.Reason == null ? "" : p.Reason.ToThaiNumber()
|
|
})
|
|
.ToList();
|
|
|
|
return report_data;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<CommandType16Response>> GetCommandType16Async(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<PlacementRepatriation>()
|
|
//.Include(p => p.Profile)
|
|
//.ThenInclude(p => p.Position)
|
|
//.Include(p => p.Profile)
|
|
//.ThenInclude(p => p.Salaries)
|
|
//.Include(p => p.Profile)
|
|
//.ThenInclude(p => p.Prefix)
|
|
on r.RefPlacementProfileId equals p.Id
|
|
orderby r.Sequence
|
|
select new CommandType16Response
|
|
{
|
|
CommandNo = r.Command.CommandNo.ToThaiNumber(),
|
|
CommandYear = r.Command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(),
|
|
CommandAffectDate = r.Command.CommandAffectDate == null ? "" : r.Command.CommandAffectDate.Value.ToThaiFullDate3().ToThaiNumber(),
|
|
IssuerOrganizationName = r.Command.IssuerOrganizationName,
|
|
AuthorizedUserFullName = r.Command.AuthorizedUserFullName,
|
|
AuthorizedPosition = r.Command.AuthorizedPosition,
|
|
GovAidCommandNo = r.Command.GovAidCommandNo == null ? "" : r.Command.GovAidCommandNo.ToThaiNumber(),
|
|
GovAidCommandDate = r.Command.GovAidCommandDate == null ? "" :
|
|
r.Command.GovAidCommandDate.Value.ToThaiFullDate3().ToThaiNumber(),
|
|
StartDate = p.Date == null ? "" : p.Date.Value.ToThaiFullDate3().ToThaiNumber(),
|
|
ActiveDate = p.DateRepatriation == null ? "" : p.DateRepatriation.Value.ToThaiFullDate3().ToThaiNumber(),
|
|
FullName = $"{p.prefix}{p.firstName!} {p.lastName!}",
|
|
Subject = $"เรื่อง {r.Command.CommandSubject}",
|
|
})
|
|
.ToList();
|
|
|
|
return report_data;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<CommandType17Response>> GetCommandType17AttachmentAsync(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<RetirementResign>()
|
|
//.Include(p => p.Profile)
|
|
//.ThenInclude(p => p.Position)
|
|
//.Include(p => p.Profile)
|
|
//.ThenInclude(p => p.Salaries)
|
|
on r.RefPlacementProfileId equals p.Id
|
|
orderby r.Sequence
|
|
select new CommandType17Response
|
|
{
|
|
Seq = r.Sequence.ToString().ToThaiNumber(),
|
|
CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(),
|
|
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
|
PositionName = p.PositionOld ?? "",
|
|
Organization = p.OrganizationPositionOld ?? "",
|
|
PositionLevel = p.PositionLevelOld ?? "",
|
|
PositionType = p.PositionTypeOld ?? "",
|
|
PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(),
|
|
ActiveDate = p.ActiveDate == null ? "" : p.ActiveDate.Value.ToThaiShortDate2().ToThaiNumber(),
|
|
Salary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
//Salary = p.Profile.Salaries == null || p.Profile.Salaries.Count == 0 ? "" : p.Profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
Remark = p.Reason ?? "",
|
|
RemarkHorizontal = p.RemarkHorizontal,
|
|
})
|
|
.ToList();
|
|
|
|
return report_data;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<CommandType18Response>> GetCommandType18Async(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<RetirementOut>()
|
|
// .Include(p => p.Profile)
|
|
// .ThenInclude(p => p.Position)
|
|
// .Include(p => p.Profile)
|
|
// .ThenInclude(p => p.Salaries)
|
|
on r.RefPlacementProfileId equals p.Id
|
|
orderby r.Sequence
|
|
select new CommandType18Response
|
|
{
|
|
CommandNo = r.Command.CommandNo.ToThaiNumber(),
|
|
CommandYear = r.Command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(),
|
|
CommandAffectDate = r.Command.CommandAffectDate == null ? "" : r.Command.CommandAffectDate.Value.ToThaiFullDate3().ToThaiNumber(),
|
|
IssuerOrganizationName = r.Command.IssuerOrganizationName,
|
|
AuthorizedUserFullName = r.Command.AuthorizedUserFullName,
|
|
AuthorizedPosition = r.Command.AuthorizedPosition,
|
|
CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(),
|
|
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
|
// PositionName = p.Profile.Position == null ? "" : p.Profile.Position.Name,
|
|
Organization = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld,
|
|
PositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld,
|
|
PositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld,
|
|
PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(),
|
|
Salary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
//Salary = p.Profile.Salaries == null || p.Profile.Salaries.Count == 0 ? "" : p.Profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
Fault = r.Command.Fault == null ? "" : r.Command.Fault.ToThaiNumber(),
|
|
GuiltyBasis = r.Command.GuiltyBasis == null ? "" : r.Command.GuiltyBasis.ToThaiNumber(),
|
|
ConclusionFireNo = r.Command.ConclusionFireNo == null ? "" : r.Command!.ConclusionFireNo.ToThaiNumber(),
|
|
ConclusionFireDate = r.Command.ConclusionFireDate == null ? "" : r.Command.ConclusionFireDate.Value.ToThaiFullDate3().ToThaiNumber(),
|
|
ConclusionFireResolution = r.Command.ConclusionFireResolution == null ? "" : r.Command.ConclusionFireResolution.ToThaiNumber(),
|
|
Subject = $"เรื่อง {r.Command.CommandSubject}",
|
|
})
|
|
.ToList();
|
|
|
|
return report_data;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<CommandType18Response>> GetCommandType19Async(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<RetirementDischarge>()
|
|
.Include(p => p.Profile)
|
|
.ThenInclude(p => p.Position)
|
|
.Include(p => p.Profile)
|
|
.ThenInclude(p => p.Salaries)
|
|
on r.RefPlacementProfileId equals p.Id
|
|
orderby r.Sequence
|
|
select new CommandType18Response
|
|
{
|
|
CommandNo = r.Command.CommandNo.ToThaiNumber(),
|
|
CommandYear = r.Command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(),
|
|
CommandAffectDate = r.Command.CommandAffectDate == null ? "" : r.Command.CommandAffectDate.Value.ToThaiFullDate3().ToThaiNumber(),
|
|
IssuerOrganizationName = r.Command.IssuerOrganizationName,
|
|
AuthorizedUserFullName = r.Command.AuthorizedUserFullName,
|
|
AuthorizedPosition = r.Command.AuthorizedPosition,
|
|
CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(),
|
|
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
|
PositionName = p.Profile.Position == null ? "" : p.Profile.Position.Name,
|
|
Organization = p.OrganizationPositionOld ?? "",
|
|
PositionLevel = p.PositionLevelOld ?? "",
|
|
PositionType = p.PositionTypeOld ?? "",
|
|
PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(),
|
|
Salary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
//Salary = p.Profile.Salaries == null || p.Profile.Salaries.Count == 0 ? "" : p.Profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
Fault = r.Command.Fault == null ? "" : r.Command.Fault.ToThaiNumber(),
|
|
GuiltyBasis = r.Command.GuiltyBasis == null ? "" : r.Command.GuiltyBasis.ToThaiNumber(),
|
|
ConclusionFireNo = r.Command.ConclusionFireNo == null ? "" : r.Command!.ConclusionFireNo.ToThaiNumber(),
|
|
ConclusionFireDate = r.Command.ConclusionFireDate == null ? "" : r.Command.ConclusionFireDate.Value.ToThaiFullDate3().ToThaiNumber(),
|
|
ConclusionFireResolution = r.Command.ConclusionFireResolution == null ? "" : r.Command.ConclusionFireResolution.ToThaiNumber(),
|
|
Subject = $"เรื่อง {r.Command.CommandSubject}",
|
|
})
|
|
.ToList();
|
|
|
|
return report_data;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<CommandType18Response>> GetCommandType20Async(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<RetirementExpulsion>()
|
|
.Include(p => p.Profile)
|
|
.ThenInclude(p => p.Position)
|
|
.Include(p => p.Profile)
|
|
.ThenInclude(p => p.Salaries)
|
|
on r.RefPlacementProfileId equals p.Id
|
|
select new CommandType18Response
|
|
{
|
|
CommandNo = r.Command.CommandNo.ToThaiNumber(),
|
|
CommandYear = r.Command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(),
|
|
CommandAffectDate = r.Command.CommandAffectDate == null ? "" : r.Command.CommandAffectDate.Value.ToThaiFullDate3().ToThaiNumber(),
|
|
IssuerOrganizationName = r.Command.IssuerOrganizationName,
|
|
AuthorizedUserFullName = r.Command.AuthorizedUserFullName,
|
|
AuthorizedPosition = r.Command.AuthorizedPosition,
|
|
CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(),
|
|
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
|
PositionName = p.Profile.Position == null ? "" : p.Profile.Position.Name,
|
|
Organization = p.OrganizationPositionOld ?? "",
|
|
PositionLevel = p.PositionLevelOld ?? "",
|
|
PositionType = p.PositionTypeOld ?? "",
|
|
PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(),
|
|
Salary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
//Salary = p.Profile.Salaries == null || p.Profile.Salaries.Count == 0 ? "" : p.Profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
Fault = r.Command.Fault == null ? "" : r.Command.Fault.ToThaiNumber(),
|
|
GuiltyBasis = r.Command.GuiltyBasis == null ? "" : r.Command.GuiltyBasis.ToThaiNumber(),
|
|
ConclusionFireNo = r.Command.ConclusionFireNo == null ? "" : r.Command!.ConclusionFireNo.ToThaiNumber(),
|
|
ConclusionFireDate = r.Command.ConclusionFireDate == null ? "" : r.Command.ConclusionFireDate.Value.ToThaiFullDate3().ToThaiNumber(),
|
|
ConclusionFireResolution = r.Command.ConclusionFireResolution == null ? "" : r.Command.ConclusionFireResolution.ToThaiNumber()
|
|
})
|
|
.ToList();
|
|
|
|
return report_data;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
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)
|
|
// .Include(x => x.OrgEmployee)
|
|
// .ThenInclude(x => x.OrganizationAgency)
|
|
// .ThenInclude(x => x.OrganizationOrganization)
|
|
// //.Include(x => x.OrgEmployee)
|
|
// //.ThenInclude(x => x.PosNo)
|
|
// .Include(x => x.OrgEmployee)
|
|
// .ThenInclude(x => x.PositionEmployeePosition)
|
|
// .Include(x => x.OrgEmployee)
|
|
// .ThenInclude(x => x.OrganizationPositionEmployeeLevels)
|
|
// .ThenInclude(x => x.PositionEmployeeLevel)
|
|
// on r.RefPlacementProfileId equals p.Id
|
|
orderby r.Sequence
|
|
select new CommandType21Response
|
|
{
|
|
Seq = r.Sequence.ToString().ToThaiNumber(),
|
|
CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(),
|
|
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
|
Organization = r.Organization == null ? "" : r.Organization.ToThaiNumber(),
|
|
PositionName = r.PositionName == null ? "" : r.PositionName.ToThaiNumber(),
|
|
PositionLevel = r.PositionLevel == null ? "" : r.PositionLevel.ToThaiNumber(),
|
|
PositionType = r.PositionType == null ? "" : r.PositionType.ToThaiNumber(),
|
|
PositionNumber = r.PositionNumber == null ? "" : r.PositionNumber.ToThaiNumber(),
|
|
Salary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
RetireDate = r.BirthDate == null ? "" : r.BirthDate.Value.CalculateRetireDate().ToThaiFullDate3().ToThaiNumber(),
|
|
CommandYear = r.Command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber()
|
|
})
|
|
.ToList();
|
|
|
|
return report_data;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<CommandType22Response>> GetCommandType22AttachmentAsync(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<PlacementAppointment>()
|
|
// .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)
|
|
// .Include(x => x.OrgEmployee)
|
|
// .ThenInclude(x => x.OrganizationAgency)
|
|
// .ThenInclude(x => x.OrganizationOrganization)
|
|
// //.Include(x => x.OrgEmployee)
|
|
// //.ThenInclude(x => x.PosNo)
|
|
// .Include(x => x.OrgEmployee)
|
|
// .ThenInclude(x => x.PositionEmployeePosition)
|
|
// .Include(x => x.OrgEmployee)
|
|
// .ThenInclude(x => x.OrganizationPositionEmployeeLevels)
|
|
// .ThenInclude(x => x.PositionEmployeeLevel)
|
|
on r.RefPlacementProfileId equals p.Id
|
|
orderby r.Sequence
|
|
select new CommandType22Response
|
|
{
|
|
Seq = r.Sequence.ToString().ToThaiNumber(),
|
|
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
|
Organization = p.rootOld,
|
|
OldPositionName = p.OrganizationPositionOld,
|
|
OldPositionLevel = p.PositionLevelOld,
|
|
OldPositionNumber = p.PositionNumberOld == null ? null : p.PositionNumberOld.ToThaiNumber(),
|
|
OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
NewOc = p.root == null ? "" : p.root,
|
|
NewPositionName = p.position == null ? "" : p.position,
|
|
NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName,
|
|
// NewPositionType = p.posTypeName == null ? "" : p.posTypeName,
|
|
NewPositionNumber = p.posMasterNo == null ? "" :
|
|
p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "",
|
|
NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
Reason = p.Reason == null ? "-" : p.Reason,
|
|
})
|
|
.ToList();
|
|
|
|
return report_data;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<CommandType21Response>> GetCommandType23AttachmentAsync(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<RetirementResign>()
|
|
//.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)
|
|
|
|
|
|
//.Include(x => x.Profile)
|
|
//.ThenInclude(x => x.PositionEmployeePosition)
|
|
//.Include(x => x.Profile)
|
|
//.ThenInclude(x => x.PositionEmployeeLevel)
|
|
//.Include(x => x.OrgEmployee)
|
|
//.ThenInclude(x => x.OrganizationAgency)
|
|
//.ThenInclude(x => x.OrganizationOrganization)
|
|
//.Include(x => x.OrgEmployee)
|
|
//.ThenInclude(x => x.PosNo)
|
|
//.Include(x => x.OrgEmployee)
|
|
//.ThenInclude(x => x.PositionEmployeePosition)
|
|
//.Include(x => x.OrgEmployee)
|
|
//.ThenInclude(x => x.OrganizationPositionEmployeeLevels)
|
|
//.ThenInclude(x => x.PositionEmployeeLevel)
|
|
on r.RefPlacementProfileId equals p.Id
|
|
orderby r.Sequence
|
|
select new CommandType21Response
|
|
{
|
|
Seq = r.Sequence.ToString().ToThaiNumber(),
|
|
CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(),
|
|
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
|
Organization = p.OrganizationPositionOld ?? "",
|
|
PositionName = p.PositionOld ?? "",
|
|
PositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld.ToThaiNumber(),
|
|
PositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld.ToThaiNumber(),
|
|
PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(),
|
|
Salary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
RetireDate = p.ActiveDate == null ? "" : p.ActiveDate.Value.ToThaiFullDate3().ToThaiNumber(),
|
|
CommandYear = r.Command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(),
|
|
|
|
})
|
|
.ToList();
|
|
|
|
return report_data;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<List<CommandType22Response>> GetCommandType24AttachmentAsync(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<PlacementAppointment>()
|
|
// .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)
|
|
// .Include(x => x.OrgEmployee)
|
|
// .ThenInclude(x => x.OrganizationAgency)
|
|
// .ThenInclude(x => x.OrganizationOrganization)
|
|
// //.Include(x => x.OrgEmployee)
|
|
// //.ThenInclude(x => x.PosNo)
|
|
// .Include(x => x.OrgEmployee)
|
|
// .ThenInclude(x => x.PositionEmployeePosition)
|
|
// .Include(x => x.OrgEmployee)
|
|
// .ThenInclude(x => x.OrganizationPositionEmployeeLevels)
|
|
// .ThenInclude(x => x.PositionEmployeeLevel)
|
|
on r.RefPlacementProfileId equals p.Id
|
|
orderby r.Sequence
|
|
select new CommandType22Response
|
|
{
|
|
Seq = r.Sequence.ToString().ToThaiNumber(),
|
|
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
|
Organization = p.OrganizationPositionOld,
|
|
OldPositionName = p.OrganizationPositionOld,
|
|
OldPositionLevel = p.PositionLevelOld,
|
|
OldPositionNumber = p.PositionNumberOld == null ? null : p.PositionNumberOld.ToThaiNumber(),
|
|
OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
NewOc = p.root == null ? "" : p.root,
|
|
NewPositionName = p.position == null ? "" : p.position,
|
|
NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName,
|
|
// NewPositionType = p.posTypeName == null ? "" : p.posTypeName,
|
|
NewPositionNumber = p.posMasterNo == null ? "" :
|
|
p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() :
|
|
p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "",
|
|
NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
|
Reason = p.Reason == null ? "-" : p.Reason,
|
|
})
|
|
.ToList();
|
|
|
|
return report_data;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<CommandType23Response?> GetCommandType25AttachmentAsync(Guid id, string token)
|
|
{
|
|
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);
|
|
}
|
|
foreach (var d in raw_data)
|
|
{
|
|
var apiUrl = $"{_configuration["API"]}/discipline/result/report/find/{d.RefDisciplineId}/{d.RefPlacementProfileId}";
|
|
using (var client = new HttpClient())
|
|
{
|
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
|
var _res = await client.SendAsync(_req);
|
|
var _result = await _res.Content.ReadAsStringAsync();
|
|
|
|
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
|
|
|
|
if (org == null || org.result == null)
|
|
continue;
|
|
var receiver = new CommandType23Response
|
|
{
|
|
fullName = $"{org.result.prefix}{org.result.firstName} {org.result.lastName}",
|
|
positionname = org.result.position,
|
|
positionno = org.result.posNo == null ? null : org.result.posNo.ToThaiNumber(),
|
|
organizationname = org.result.organization,
|
|
salary = org.result.salary == null ? null : org.result.salary.Value.ToNumericNoDecimalText().ToString(),
|
|
};
|
|
|
|
return receiver;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|