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 System.Text;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
|
||||||
namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
{
|
{
|
||||||
|
|
@ -48,6 +49,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
private readonly PermissionRepository _permission;
|
private readonly PermissionRepository _permission;
|
||||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
private readonly ILogger<DisableController> _logger;
|
private readonly ILogger<DisableController> _logger;
|
||||||
|
private readonly IConfiguration _configuration;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
@ -61,6 +63,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
PeriodExamService periodExamService,
|
PeriodExamService periodExamService,
|
||||||
IHttpContextAccessor httpContextAccessor,
|
IHttpContextAccessor httpContextAccessor,
|
||||||
ILogger<DisableController> logger,
|
ILogger<DisableController> logger,
|
||||||
|
IConfiguration configuration,
|
||||||
PermissionRepository permission)
|
PermissionRepository permission)
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
|
|
@ -70,6 +73,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
_disableService = disableService;
|
_disableService = disableService;
|
||||||
_periodExamService = periodExamService;
|
_periodExamService = periodExamService;
|
||||||
_httpContextAccessor = httpContextAccessor;
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
_configuration = configuration;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_permission = permission;
|
_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? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||||
|
|
||||||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||||
|
private string? token => _httpContextAccessor.HttpContext.Request.Headers["Authorization"];
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
@ -122,22 +127,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
return sb.ToString();
|
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)
|
private async Task<int> GetExamCount(Guid exam)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
@ -1432,6 +1421,26 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
|
|
||||||
imported.Scores.Add(r);
|
imported.Scores.Add(r);
|
||||||
row++;
|
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,
|
Score = sr == null ? 0 : sr.SumA + sr.SumB + sr.SumC,
|
||||||
Number = sr == null ? "" : sr.Number,
|
Number = sr == null ? "" : sr.Number,
|
||||||
CitizenId = p.CitizenId,
|
CitizenId = p.CitizenId,
|
||||||
ExamCount = GetExamCountTe(p.CitizenId),
|
ExamCount = _disableService.GetExamCount(p.CitizenId),
|
||||||
ScoreExpire = p.PeriodExam.AnnouncementDate == null ? "" : p.PeriodExam.AnnouncementDate.Value.AddYears(2).ToThaiShortDate(),
|
ScoreExpire = p.PeriodExam.AnnouncementDate == null ? "" : p.PeriodExam.AnnouncementDate.Value.AddYears(2).ToThaiShortDate(),
|
||||||
ScoreResult = sr == null ? null : new
|
ScoreResult = sr == null ? null : new
|
||||||
{
|
{
|
||||||
|
|
@ -1697,7 +1706,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
})
|
})
|
||||||
.FirstOrDefaultAsync();
|
.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)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1007,6 +1007,12 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
|
||||||
b.Property<DateTime>("ApplyDate")
|
b.Property<DateTime>("ApplyDate")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("datetime(6)");
|
||||||
|
|
||||||
|
b.Property<string>("AuthName")
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("AuthPosition")
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
b.Property<DateTime>("CitizenCardExpireDate")
|
b.Property<DateTime>("CitizenCardExpireDate")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("datetime(6)");
|
||||||
|
|
||||||
|
|
|
||||||
3079
Migrations/20250218054707_update table Recruit add AuthName.Designer.cs
generated
Normal file
3079
Migrations/20250218054707_update table Recruit add AuthName.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,40 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace BMA.EHR.Recurit.Exam.Service.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class updatetableRecruitaddAuthName : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "AuthName",
|
||||||
|
table: "Disables",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "AuthPosition",
|
||||||
|
table: "Disables",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "AuthName",
|
||||||
|
table: "Disables");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "AuthPosition",
|
||||||
|
table: "Disables");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -80,5 +80,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Models.Disables
|
||||||
public string? PositionName { get; set; }//
|
public string? PositionName { get; set; }//
|
||||||
public string? PositionType { get; set; }
|
public string? PositionType { get; set; }
|
||||||
public string? PositionLevel { get; set; }
|
public string? PositionLevel { get; set; }
|
||||||
|
public string? AuthName { get; set; }
|
||||||
|
public string? AuthPosition { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue