add position
This commit is contained in:
parent
b1aeec71e7
commit
54d8deec37
5 changed files with 3155 additions and 18 deletions
|
|
@ -26,6 +26,7 @@ using System.Security.Claims;
|
|||
using System.Text;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using System.Net.Http.Headers;
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||
{
|
||||
|
|
@ -48,6 +49,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
private readonly PermissionRepository _permission;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly ILogger<DisableController> _logger;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -61,6 +63,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
PeriodExamService periodExamService,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
ILogger<DisableController> logger,
|
||||
IConfiguration configuration,
|
||||
PermissionRepository permission)
|
||||
{
|
||||
_context = context;
|
||||
|
|
@ -70,6 +73,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
_disableService = disableService;
|
||||
_periodExamService = periodExamService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_configuration = configuration;
|
||||
_logger = logger;
|
||||
_permission = permission;
|
||||
}
|
||||
|
|
@ -81,6 +85,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||
|
||||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||
private string? token => _httpContextAccessor.HttpContext.Request.Headers["Authorization"];
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -122,22 +127,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
return sb.ToString();
|
||||
}
|
||||
|
||||
private int GetExamCountTe(string citizenId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var count = _context.Candidates.AsQueryable()
|
||||
.Where(x => x.CitizenId == citizenId)
|
||||
.Count();
|
||||
|
||||
return count;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<int> GetExamCount(Guid exam)
|
||||
{
|
||||
try
|
||||
|
|
@ -1432,6 +1421,26 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
|
||||
imported.Scores.Add(r);
|
||||
row++;
|
||||
var recruit = await _context.Disables.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.PeriodExam == rec_import && x.ExamId == r.ExamId);
|
||||
if (recruit != null)
|
||||
{
|
||||
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);
|
||||
recruit.AuthName = org.result.name == null ? "" : org.result.name;
|
||||
recruit.AuthPosition = org.result.position == null ? "" : org.result.position;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1675,7 +1684,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
Score = sr == null ? 0 : sr.SumA + sr.SumB + sr.SumC,
|
||||
Number = sr == null ? "" : sr.Number,
|
||||
CitizenId = p.CitizenId,
|
||||
ExamCount = GetExamCountTe(p.CitizenId),
|
||||
ExamCount = _disableService.GetExamCount(p.CitizenId),
|
||||
ScoreExpire = p.PeriodExam.AnnouncementDate == null ? "" : p.PeriodExam.AnnouncementDate.Value.AddYears(2).ToThaiShortDate(),
|
||||
ScoreResult = sr == null ? null : new
|
||||
{
|
||||
|
|
@ -1697,7 +1706,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
})
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
return Success(new { data, ExamCount = data == null || data.CitizenId == "" ? 0 : GetExamCountTe(data.CitizenId) });
|
||||
// return Success(new { data, ExamCount = data == null || data.CitizenId == "" ? 0 : GetExamCountTe(data.CitizenId) });
|
||||
return Success(data);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue