Merge branch 'develop' into dev
This commit is contained in:
commit
532c1034bc
6 changed files with 1700 additions and 36 deletions
|
|
@ -473,6 +473,23 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
|||
CreatedUserId = UserId ?? "",
|
||||
CreatedFullName = FullName ?? "System Administrator",
|
||||
};
|
||||
|
||||
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);
|
||||
import.AuthName = org.result.name == null ? "" : org.result.name;
|
||||
import.AuthPosition = org.result.position == null ? "" : org.result.position;
|
||||
}
|
||||
}
|
||||
|
||||
await _context.RecruitImports.AddAsync(import);
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
|
|
@ -1337,8 +1354,8 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
|||
// preload recruits ทั้งหมดของครั้งเดียว และ Group ExamId เอาเฉพาะ key ที่ไม่ซ้ำ
|
||||
var recruitsDict = await _context.Recruits
|
||||
.Where(x => x.RecruitImport.Id == rec_import.Id)
|
||||
.GroupBy(x => x.ExamId)
|
||||
.Where(g => g.Count() == 1)
|
||||
.GroupBy(x => x.ExamId)
|
||||
.Where(g => g.Count() == 1)
|
||||
.Select(g => g.First())
|
||||
.ToDictionaryAsync(x => x.ExamId, x => x);
|
||||
|
||||
|
|
@ -1397,26 +1414,10 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
|||
// .Include(x => x.RecruitImport)
|
||||
// .Where(x => x.RecruitImport == rec_import && x.ExamId == r.ExamId)
|
||||
// .FirstOrDefaultAsync();
|
||||
|
||||
|
||||
// ใช้ dictionary lookup แทน query DB ทีละรอบ
|
||||
if (!string.IsNullOrEmpty(r.ExamId) && recruitsDict.TryGetValue(r.ExamId, out var recruit))
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
r.CitizenId = workSheet?.Cells[row, 3]?.GetValue<string>();
|
||||
|
||||
// ภาคความรู้ความสามารถที่ใช้เฉพาะตำแหน่ง
|
||||
|
|
@ -1467,9 +1468,9 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
|||
|
||||
imported.Scores.Add(r);
|
||||
}
|
||||
|
||||
|
||||
row++;
|
||||
|
||||
|
||||
} // end of sheet loop
|
||||
} // end of all file loop
|
||||
}
|
||||
|
|
@ -1577,7 +1578,7 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
|||
var file = Request.Form.Files[0];
|
||||
using (var stream = file.OpenReadStream())
|
||||
using (var c_package = new ExcelPackage(stream))
|
||||
{
|
||||
{
|
||||
foreach (var workSheet in c_package.Workbook.Worksheets)
|
||||
{
|
||||
var totalRows = workSheet.Dimension.Rows;
|
||||
|
|
@ -1591,7 +1592,7 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
|||
row++;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (score.TryGetValue(examId, out var existingScore))
|
||||
{
|
||||
existingScore.Number = workSheet?.Cells[row, 1]?.GetValue<string>();
|
||||
|
|
@ -1824,7 +1825,7 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
|||
ProfileID = p.CitizenId,
|
||||
p.Prefix,
|
||||
FullName = $"{p.FirstName} {p.LastName}",
|
||||
DateOfBirth = p.DateOfBirth != null
|
||||
DateOfBirth = p.DateOfBirth != null
|
||||
? p.DateOfBirth != DateTime.MinValue
|
||||
? p.DateOfBirth.ToThaiShortDate()
|
||||
: ""
|
||||
|
|
@ -1832,10 +1833,10 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
|||
Gender = p.Gendor,
|
||||
Degree = p.Educations.First().Degree,
|
||||
Major = p.Educations.First().Major,
|
||||
CertificateNo = p.Certificates.Count > 0
|
||||
CertificateNo = p.Certificates.Count > 0
|
||||
? p.Certificates.First().CertificateNo ?? ""
|
||||
: "",
|
||||
CertificateIssueDate = p.Certificates.Count > 0
|
||||
CertificateIssueDate = p.Certificates.Count > 0
|
||||
? p.Certificates.First().IssueDate != DateTime.MinValue
|
||||
? p.Certificates.First().IssueDate.ToThaiShortDate()
|
||||
: ""
|
||||
|
|
@ -1854,8 +1855,8 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
|||
Score = sr == null ? 0.0 : sr.TotalScore,
|
||||
Number = sr == null ? "" : sr.Number,
|
||||
ExamCount = _recruitService.GetExamCount(p.CitizenId),
|
||||
ScoreExpire = p.RecruitImport.AnnouncementDate == null
|
||||
? ""
|
||||
ScoreExpire = p.RecruitImport.AnnouncementDate == null
|
||||
? ""
|
||||
: p.RecruitImport.AnnouncementDate != DateTime.MinValue
|
||||
? p.RecruitImport.AnnouncementDate.Value.AddYears(2).ToThaiShortDate()
|
||||
: "",
|
||||
|
|
|
|||
1601
Migrations/20250915084717_update_table_period_add_authname.Designer.cs
generated
Normal file
1601
Migrations/20250915084717_update_table_period_add_authname.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,62 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BMA.EHR.Recruit.Service.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class update_table_period_add_authname : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "AuthName",
|
||||
table: "Recruits");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "AuthPosition",
|
||||
table: "Recruits");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "AuthName",
|
||||
table: "RecruitImports",
|
||||
type: "longtext",
|
||||
nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "AuthPosition",
|
||||
table: "RecruitImports",
|
||||
type: "longtext",
|
||||
nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "AuthName",
|
||||
table: "RecruitImports");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "AuthPosition",
|
||||
table: "RecruitImports");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "AuthName",
|
||||
table: "Recruits",
|
||||
type: "longtext",
|
||||
nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "AuthPosition",
|
||||
table: "Recruits",
|
||||
type: "longtext",
|
||||
nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -65,12 +65,6 @@ namespace BMA.EHR.Recruit.Service.Migrations
|
|||
b.Property<DateTime>("ApplyDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("AuthName")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("AuthPosition")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<DateTime>("CitizenCardExpireDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
|
|
@ -631,6 +625,12 @@ namespace BMA.EHR.Recruit.Service.Migrations
|
|||
.HasColumnOrder(6)
|
||||
.HasComment("วันเริ่มประกาศ");
|
||||
|
||||
b.Property<string>("AuthName")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("AuthPosition")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnOrder(100)
|
||||
|
|
|
|||
|
|
@ -79,8 +79,6 @@ namespace BMA.EHR.Recruit.Service.Models.Recruits
|
|||
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;
|
||||
|
|
|
|||
|
|
@ -54,6 +54,8 @@ namespace BMA.EHR.Recruit.Service.Models.Recruits
|
|||
public List<Recruit> Recruits { get; set; } = new List<Recruit>();
|
||||
|
||||
public ScoreImport ScoreImport { get; set; }
|
||||
public string? AuthName { get; set; }
|
||||
public string? AuthPosition { get; set; }
|
||||
|
||||
public List<RecruitImportHistory> ImportHostories { get; set; } = new List<RecruitImportHistory>();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue