Merge branch 'develop' into working
This commit is contained in:
commit
18aa77b3ad
15 changed files with 20164 additions and 1615 deletions
|
|
@ -1,4 +1,6 @@
|
|||
using BMA.EHR.Application.Common.Interfaces;
|
||||
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;
|
||||
|
|
@ -9,6 +11,8 @@ 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
|
||||
{
|
||||
|
|
@ -20,6 +24,7 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly OrganizationCommonRepository _organizationCommonRepository;
|
||||
private readonly UserProfileRepository _userProfileRepository;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -28,12 +33,14 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
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
|
||||
|
|
@ -1029,39 +1036,39 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
}
|
||||
|
||||
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
|
||||
// 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.ToThaiNumber(),
|
||||
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
||||
Organization = p.OrgEmployee == null || p.OrgEmployee!.OrganizationAgency == null || p.OrgEmployee!.OrganizationAgency!.OrganizationOrganization == null ? "" : p.OrgEmployee!.OrganizationAgency!.OrganizationOrganization!.Name,
|
||||
PositionName = p.OrgEmployee == null || p.OrgEmployee.PositionEmployeePosition == null ? "" : p.OrgEmployee.PositionEmployeePosition.Name.ToThaiNumber(),
|
||||
PositionLevel = p.OrgEmployee == null || p.OrgEmployee.OrganizationPositionEmployeeLevels == null ? "" : p.OrgEmployee.OrganizationPositionEmployeeLevels.First().PositionEmployeeLevel.Name.ToThaiNumber(),
|
||||
PositionType = p.Profile.PositionType == null ? "" : p.Profile.PositionType.Name.ToThaiNumber(),
|
||||
PositionNumber = p.OrgEmployee.PosNo == null ? "" : p.OrgEmployee.PosNo.ToThaiNumber(),
|
||||
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 = p.Profile.BirthDate.CalculateRetireDate().ToThaiFullDate3().ToThaiNumber(),
|
||||
RetireDate = r.BirthDate == null ? "" : r.BirthDate.Value.CalculateRetireDate().ToThaiFullDate3().ToThaiNumber(),
|
||||
CommandYear = r.Command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber()
|
||||
})
|
||||
.ToList();
|
||||
|
|
@ -1274,7 +1281,7 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<CommandType23Response?> GetCommandType25AttachmentAsync(Guid id)
|
||||
public async Task<CommandType23Response?> GetCommandType25AttachmentAsync(Guid id, string token)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -1286,23 +1293,33 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
{
|
||||
throw new Exception(GlobalMessages.CommandNotFound);
|
||||
}
|
||||
var report_data = (from r in raw_data
|
||||
join pf in _dbContext.Set<Profile>()
|
||||
.Include(x => x.Position)
|
||||
.Include(x => x.PosNo)
|
||||
.Include(x => x.Salaries)
|
||||
on r.CitizenId equals pf.CitizenId
|
||||
orderby r.Sequence
|
||||
select new CommandType23Response
|
||||
{
|
||||
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
||||
Positionname = pf.Position == null ? "" : pf.Position.Name,
|
||||
Positionno = pf.PosNo == null ? "" : pf.PosNo.Name,
|
||||
Organizationname = pf.Oc == null ? "" : pf.Oc.Replace("/", " "),
|
||||
Salary = pf.Salaries == null || pf.Salaries.Count == 0 || pf.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount == null ? "" : pf.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
||||
}).FirstOrDefault();
|
||||
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();
|
||||
|
||||
return report_data;
|
||||
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,
|
||||
organizationname = org.result.organization,
|
||||
salary = org.result.salary == null ? null : org.result.salary.Value.ToNumericNoDecimalText().ToString(),
|
||||
};
|
||||
|
||||
return receiver;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue