โหลดใบรับรอง
This commit is contained in:
parent
9284a89cb4
commit
e44a255b53
4 changed files with 81 additions and 16 deletions
|
|
@ -11,6 +11,8 @@ using BMA.EHR.Organization.Service.Extensions;
|
||||||
// using BMA.EHR.Core;
|
// using BMA.EHR.Core;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace BMA.EHR.Report.Service.Controllers
|
namespace BMA.EHR.Report.Service.Controllers
|
||||||
{
|
{
|
||||||
|
|
@ -28,6 +30,7 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
private readonly IWebHostEnvironment _hostingEnvironment;
|
private readonly IWebHostEnvironment _hostingEnvironment;
|
||||||
private readonly IConfiguration _configuration;
|
private readonly IConfiguration _configuration;
|
||||||
private readonly string space = "ㅤ";
|
private readonly string space = "ㅤ";
|
||||||
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
@ -35,13 +38,16 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
|
|
||||||
public ExamReportController(ExamDbContext context,
|
public ExamReportController(ExamDbContext context,
|
||||||
IWebHostEnvironment hostingEnvironment,
|
IWebHostEnvironment hostingEnvironment,
|
||||||
|
IHttpContextAccessor httpContextAccessor,
|
||||||
IConfiguration configuration)
|
IConfiguration configuration)
|
||||||
{
|
{
|
||||||
this._context = context;
|
this._context = context;
|
||||||
this._hostingEnvironment = hostingEnvironment;
|
this._hostingEnvironment = hostingEnvironment;
|
||||||
this._configuration = configuration;
|
this._configuration = configuration;
|
||||||
|
this._httpContextAccessor = httpContextAccessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string? token => _httpContextAccessor.HttpContext.Request.Headers["Authorization"];
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region " Methods "
|
#region " Methods "
|
||||||
|
|
@ -108,6 +114,34 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var _data = await _context.Disables.AsQueryable()
|
||||||
|
.Include(x => x.PeriodExam)
|
||||||
|
.Where(x => x.PeriodExam.Id == id)
|
||||||
|
.Where(x => x.ExamId == examId)
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
if (_data == null)
|
||||||
|
return Error("ไม่พบข้อมูลในระบบ");
|
||||||
|
|
||||||
|
if (_data.AuthName == null || _data.AuthName == "")
|
||||||
|
{
|
||||||
|
var apiUrl = $"{_configuration["API"]}/org/find/head/officer";
|
||||||
|
using (var client = new HttpClient())
|
||||||
|
{
|
||||||
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
|
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||||
|
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||||
|
var _res = await client.SendAsync(_req);
|
||||||
|
var _result = await _res.Content.ReadAsStringAsync();
|
||||||
|
if (_res.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
var org = JsonConvert.DeserializeObject<dynamic>(_result);
|
||||||
|
_data.AuthName = org.result.name == null ? "" : org.result.name;
|
||||||
|
_data.AuthPosition = org.result.position == null ? "" : org.result.position;
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var data = await _context.Disables.AsQueryable()
|
var data = await _context.Disables.AsQueryable()
|
||||||
.Include(x => x.PeriodExam)
|
.Include(x => x.PeriodExam)
|
||||||
.Where(x => x.PeriodExam.Id == id)
|
.Where(x => x.PeriodExam.Id == id)
|
||||||
|
|
@ -453,7 +487,7 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
SumScore = sr == null
|
SumScore = sr == null
|
||||||
? "๐"
|
? "๐"
|
||||||
//: (((sr.SumA > 0 ? sr.SumA : 0) + /*sr.SumB +*/ (sr.SumC > 0 ? sr.SumC : 0)).ToString()).ToThaiNumber(),
|
//: (((sr.SumA > 0 ? sr.SumA : 0) + /*sr.SumB +*/ (sr.SumC > 0 ? sr.SumC : 0)).ToString()).ToThaiNumber(),
|
||||||
: (((sr.SumA > 0 ? sr.SumA : 0) + (sr.SumB > 0 ? sr.SumB : 0 ) + (sr.SumC > 0 ? sr.SumC : 0)).ToString()).ToThaiNumber(),
|
: (((sr.SumA > 0 ? sr.SumA : 0) + (sr.SumB > 0 ? sr.SumB : 0) + (sr.SumC > 0 ? sr.SumC : 0)).ToString()).ToThaiNumber(),
|
||||||
})
|
})
|
||||||
.OrderBy(x => x.Number)
|
.OrderBy(x => x.Number)
|
||||||
.Where(x => x.Id == id)
|
.Where(x => x.Id == id)
|
||||||
|
|
|
||||||
|
|
@ -75,23 +75,34 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var name = "";
|
var _data = await _context.Recruits.AsQueryable()
|
||||||
var position = "";
|
.Include(x => x.RecruitImport)
|
||||||
var apiUrl = $"{_configuration["API"]}/org/find/head/officer";
|
.Where(x => x.RecruitImport.Id == id)
|
||||||
using (var client = new HttpClient())
|
.Where(x => x.ExamId == examId)
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
if (_data == null)
|
||||||
|
return Error("ไม่พบข้อมูลในระบบ");
|
||||||
|
|
||||||
|
if (_data.AuthName == null || _data.AuthName == "")
|
||||||
{
|
{
|
||||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
var apiUrl = $"{_configuration["API"]}/org/find/head/officer";
|
||||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
using (var client = new HttpClient())
|
||||||
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
|
||||||
var _res = await client.SendAsync(_req);
|
|
||||||
var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
if (_res.IsSuccessStatusCode)
|
|
||||||
{
|
{
|
||||||
var org = JsonConvert.DeserializeObject<dynamic>(_result);
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
name = org.result.rootId == null ? "" : org.result.rootId;
|
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||||
position = org.result.rootId == null ? "" : org.result.rootId;
|
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||||
|
var _res = await client.SendAsync(_req);
|
||||||
|
var _result = await _res.Content.ReadAsStringAsync();
|
||||||
|
if (_res.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
var org = JsonConvert.DeserializeObject<dynamic>(_result);
|
||||||
|
_data.AuthName = org.result.name == null ? "" : org.result.name;
|
||||||
|
_data.AuthPosition = org.result.position == null ? "" : org.result.position;
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var data = await _context.Recruits.AsQueryable()
|
var data = await _context.Recruits.AsQueryable()
|
||||||
.Include(x => x.RecruitImport)
|
.Include(x => x.RecruitImport)
|
||||||
.Where(x => x.RecruitImport.Id == id)
|
.Where(x => x.RecruitImport.Id == id)
|
||||||
|
|
@ -109,8 +120,8 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
FullName = $"{p.Prefix}{p.FirstName} {p.LastName}",
|
FullName = $"{p.Prefix}{p.FirstName} {p.LastName}",
|
||||||
ExamResult = sr == null ? "" : sr.ExamStatus,
|
ExamResult = sr == null ? "" : sr.ExamStatus,
|
||||||
EndDate = p.RecruitImport.RegisterEndDate == null ? "-" : p.RecruitImport.RegisterEndDate.Value.ToThaiFullDate3(),
|
EndDate = p.RecruitImport.RegisterEndDate == null ? "-" : p.RecruitImport.RegisterEndDate.Value.ToThaiFullDate3(),
|
||||||
AuthName = name,
|
AuthName = p.AuthName,
|
||||||
AuthPosition = position
|
AuthPosition = p.AuthPosition
|
||||||
})
|
})
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
if (data == null)
|
if (data == null)
|
||||||
|
|
|
||||||
|
|
@ -78,5 +78,15 @@ namespace BMA.EHR.Recurit.Exam.Service.Models.Disables
|
||||||
public DateTime ApplyDate { get; set; }
|
public DateTime ApplyDate { get; set; }
|
||||||
|
|
||||||
public string? PositionName { get; set; }
|
public string? PositionName { get; set; }
|
||||||
|
public string? PositionType { get; set; }
|
||||||
|
public string? PositionLevel { get; set; }
|
||||||
|
public string? AuthName { get; set; }
|
||||||
|
public string? AuthPosition { get; set; }
|
||||||
|
|
||||||
|
[Comment("บัญชีสอบ")]
|
||||||
|
public string? HddPosition { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Comment("ประเภทการสอบภาค ก.")]
|
||||||
|
public string? typeTest { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,5 +78,15 @@ namespace BMA.EHR.Recruit.Service.Models.Recruits
|
||||||
public DateTime ApplyDate { get; set; }
|
public DateTime ApplyDate { get; set; }
|
||||||
|
|
||||||
public string? PositionName { get; set; }
|
public string? PositionName { get; set; }
|
||||||
|
public string? PositionType { get; set; }
|
||||||
|
public string? PositionLevel { get; set; }
|
||||||
|
public string? AuthName { get; set; }
|
||||||
|
public string? AuthPosition { get; set; }
|
||||||
|
|
||||||
|
[Comment("บัญชีสอบ")]
|
||||||
|
public string? HddPosition { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Comment("ประเภทการสอบภาค ก.")]
|
||||||
|
public string? typeTest { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue