test dumb
This commit is contained in:
parent
8e967a1fa8
commit
27fd503d9e
8 changed files with 342 additions and 77 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
|
||||
|
|
@ -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