ใบรับรอง
This commit is contained in:
parent
a6b236c413
commit
6a53a7f05e
1 changed files with 27 additions and 27 deletions
|
|
@ -1337,8 +1337,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,25 +1397,25 @@ 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;
|
||||
}
|
||||
}
|
||||
// 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 +1467,9 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
|||
|
||||
imported.Scores.Add(r);
|
||||
}
|
||||
|
||||
|
||||
row++;
|
||||
|
||||
|
||||
} // end of sheet loop
|
||||
} // end of all file loop
|
||||
}
|
||||
|
|
@ -1577,7 +1577,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 +1591,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 +1824,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 +1832,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 +1854,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()
|
||||
: "",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue