update issue #1529

This commit is contained in:
Bright 2025-06-12 11:42:05 +07:00
parent 9a7e654208
commit 79898c49bd

View file

@ -27,6 +27,7 @@ using System.Net.WebSockets;
using System.Security.Claims;
using System.Text;
using static System.Runtime.InteropServices.JavaScript.JSType;
using System.Globalization;
namespace BMA.EHR.Recruit.Service.Controllers
{
@ -1071,77 +1072,121 @@ namespace BMA.EHR.Recruit.Service.Controllers
if (cell1 == "" || cell1 == null) break;
var r = new Models.Recruits.Recruit();
r.ExamId = workSheet?.Cells[row, 0]?.GetValue<string>();
r.CitizenId = workSheet?.Cells[row, 11]?.GetValue<string>();
r.Prefix = workSheet?.Cells[row, 4]?.GetValue<string>() == "อื่น ๆ" ? workSheet?.Cells[row, 5]?.GetValue<string>() : workSheet?.Cells[row, 4]?.GetValue<string>();
r.FirstName = workSheet?.Cells[row, 6]?.GetValue<string>();
r.LastName = workSheet?.Cells[row, 7]?.GetValue<string>();
r.Gendor = workSheet?.Cells[row, 97]?.GetValue<string>();
r.National = workSheet?.Cells[row, 8]?.GetValue<string>().IsNull("");
r.Race = workSheet?.Cells[row, 9999]?.GetValue<string>().IsNull("");
r.Religion = workSheet?.Cells[row, 9]?.GetValue<string>().IsNull("");
r.DateOfBirth = Convert.ToDateTime(workSheet?.Cells[row, 10]?.GetValue<string>().ToDateTime(DateTimeFormat.Ymd, "-"));
r.Marry = workSheet?.Cells[row, 9999]?.GetValue<string>();
r.ExamId = workSheet?.Cells[row, 1]?.GetValue<string>() ?? "";
r.CitizenId = workSheet?.Cells[row, 12]?.GetValue<string>() ?? "";
r.Prefix = workSheet?.Cells[row, 5]?.GetValue<string>() == "อื่น ๆ" ? workSheet?.Cells[row, 6]?.GetValue<string>() ?? "" : workSheet?.Cells[row, 5]?.GetValue<string>() ?? "";
r.FirstName = workSheet?.Cells[row, 7]?.GetValue<string>() ?? "";
r.LastName = workSheet?.Cells[row, 8]?.GetValue<string>() ?? "";
r.Gendor = workSheet?.Cells[row, 98]?.GetValue<string>() ?? "";
r.National = workSheet?.Cells[row, 9]?.GetValue<string>() ?? "";
r.Race = workSheet?.Cells[row, 9999]?.GetValue<string>() ?? "";
r.Religion = workSheet?.Cells[row, 10]?.GetValue<string>() ?? "";
r.DateOfBirth = DateTime.TryParseExact(workSheet?.Cells[row, 11]?.GetValue<string>()?.Trim(), "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out var dob) && dob.Year > 2500 ? dob.AddYears(-543) : DateTime.MinValue;
r.Marry = workSheet?.Cells[row, 9999]?.GetValue<string>() ?? "";
r.Isspecial = "N";
r.CitizenCardIssuer = workSheet?.Cells[row, 9999]?.GetValue<string>();
r.CitizenCardIssuer = workSheet?.Cells[row, 9999]?.GetValue<string>() ?? "";
r.CitizenCardExpireDate = Convert.ToDateTime(workSheet?.Cells[row, 9999]?.GetValue<string>().ToDateTime(DateTimeFormat.Ymd, "-"));
r.ApplyDate = (DateTime)workSheet?.Cells[row, 9999]?.GetValue<DateTime>();
r.PositionName = workSheet?.Cells[row, 2]?.GetValue<string>().IsNull("");
r.PositionType = workSheet?.Cells[row, 9999]?.GetValue<string>().IsNull("");
r.PositionLevel = workSheet?.Cells[row, 9999]?.GetValue<string>().IsNull("");
r.PositionName = workSheet?.Cells[row, 3]?.GetValue<string>() ?? "";
r.PositionType = workSheet?.Cells[row, 9999]?.GetValue<string>() ?? "";
r.PositionLevel = workSheet?.Cells[row, 9999]?.GetValue<string>() ?? "";
r.CreatedAt = DateTime.Now;
r.CreatedUserId = UserId ?? "";
r.CreatedFullName = FullName ?? "System Administrator";
r.LastUpdatedAt = DateTime.Now;
r.LastUpdateUserId = UserId ?? "";
r.LastUpdateFullName = FullName ?? "System Administrator";
// address
r.Addresses.Add(new RecruitAddress()
// education
r.Educations.Add(new RecruitEducation()
{
Address = $"{(workSheet?.Cells[row, 48]?.GetValue<string>() ?? "")} {(workSheet?.Cells[row, 49]?.GetValue<string>() ?? "")}",
Moo = workSheet?.Cells[row, 50]?.GetValue<string>() ?? "",
Soi = workSheet?.Cells[row, 51]?.GetValue<string>() ?? "",
Road = workSheet?.Cells[row, 52]?.GetValue<string>() ?? "",
District = workSheet?.Cells[row, 53]?.GetValue<string>() ?? "",
Amphur = workSheet?.Cells[row, 54]?.GetValue<string>() ?? "",
Province = workSheet?.Cells[row, 55]?.GetValue<string>() ?? "",
ZipCode = workSheet?.Cells[row, 56]?.GetValue<string>() ?? "",
Telephone = workSheet?.Cells[row, 57]?.GetValue<string>() ?? "",
Mobile = workSheet?.Cells[row, 57]?.GetValue<string>() ?? "",
Address1 = $"{(workSheet?.Cells[row, 60]?.GetValue<string>() ?? "")} {(workSheet?.Cells[row, 61]?.GetValue<string>() ?? "")}",
Moo1 = workSheet?.Cells[row, 62]?.GetValue<string>() ?? "",
Soi1 = workSheet?.Cells[row, 63]?.GetValue<string>() ?? "",
Road1 = workSheet?.Cells[row, 64]?.GetValue<string>() ?? "",
District1 = workSheet?.Cells[row, 65]?.GetValue<string>() ?? "",
Amphur1 = workSheet?.Cells[row, 66]?.GetValue<string>() ?? "",
Province1 = workSheet?.Cells[row, 67]?.GetValue<string>() ?? "",
ZipCode1 = workSheet?.Cells[row, 68]?.GetValue<string>() ?? "",
});
// payment
r.Payments.Add(new RecruitPayment()
{
PaymentId = workSheet?.Cells[row, 103]?.GetValue<string>() ?? "",
CompanyCode = workSheet?.Cells[row, 104]?.GetValue<string>() ?? "",
TextFile = workSheet?.Cells[row, 105]?.GetValue<string>() ?? "",
BankCode = workSheet?.Cells[row, 106]?.GetValue<string>() ?? "",
AccountNumber = workSheet?.Cells[row, 107]?.GetValue<string>() ?? "",
TransDate = workSheet?.Cells[row, 108]?.GetValue<string>() ?? "",
TransTime = workSheet?.Cells[row, 109]?.GetValue<string>() ?? "",
CustomerName = workSheet?.Cells[row, 110]?.GetValue<string>() ?? "",
RefNo1 = workSheet?.Cells[row, 111]?.GetValue<string>() ?? "",
TermBranch = workSheet?.Cells[row, 112]?.GetValue<string>() ?? "",
TellerId = workSheet?.Cells[row, 113]?.GetValue<string>() ?? "",
CreditDebit = workSheet?.Cells[row, 114]?.GetValue<string>() ?? "",
PaymentType = workSheet?.Cells[row, 115]?.GetValue<string>(),
ChequeNo = workSheet?.Cells[row, 116]?.GetValue<string>() ?? "",
Amount = (decimal)workSheet?.Cells[row, 117]?.GetValue<decimal>(),
ChqueBankCode = workSheet?.Cells[row, 118]?.GetValue<string>() ?? ""
Degree = workSheet?.Cells[row, 18]?.GetValue<string>() ?? "",
Major = workSheet?.Cells[row, 19]?.GetValue<string>() == "อื่น ๆ" ? workSheet?.Cells[row, 20]?.GetValue<string>() ?? "" : workSheet?.Cells[row, 19]?.GetValue<string>() ?? "",
MajorGroupId = workSheet?.Cells[row, 9999]?.GetValue<string>() ?? "",
MajorGroupName = workSheet?.Cells[row, 9999]?.GetValue<string>() ?? "",
University = workSheet?.Cells[row, 21]?.GetValue<string>() == "อื่น ๆ" ? workSheet?.Cells[row, 22]?.GetValue<string>() ?? "" : workSheet?.Cells[row, 21]?.GetValue<string>() ?? "",
GPA = (double)workSheet?.Cells[row, 26]?.GetValue<double>(),
Specialist = workSheet?.Cells[row, 9999]?.GetValue<string>() ?? "",
HighDegree = workSheet?.Cells[row, 27]?.GetValue<string>() ?? "",
BachelorDate = DateTime.TryParseExact(workSheet?.Cells[row, 25]?.GetValue<string>()?.Trim(), "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out var bachelorDob) && bachelorDob.Year > 2500 ? bachelorDob.AddYears(-543) : DateTime.MinValue,
CreatedAt = DateTime.Now,
CreatedUserId = UserId ?? "",
CreatedFullName = FullName ?? "System Administrator",
LastUpdatedAt = DateTime.Now,
LastUpdateUserId = UserId ?? "",
LastUpdateFullName = FullName ?? "System Administrator"
});
// occupation
r.Occupations.Add(new RecruitOccupation()
{
Occupation = workSheet?.Cells[row, 32]?.GetValue<string>() ?? "",
Position = workSheet?.Cells[row, 36]?.GetValue<string>() ?? "",
Workplace = $"{(workSheet?.Cells[row, 35]?.GetValue<string>() ?? "")} {(workSheet?.Cells[row, 34]?.GetValue<string>() ?? "")}",
Occupation = workSheet?.Cells[row, 33]?.GetValue<string>() == "อื่น ๆ" ? workSheet?.Cells[row, 34]?.GetValue<string>() ?? "" : workSheet?.Cells[row, 33]?.GetValue<string>() ?? "",
Position = workSheet?.Cells[row, 37]?.GetValue<string>() ?? "",
Workplace = $"{(workSheet?.Cells[row, 36]?.GetValue<string>() ?? "")} {(workSheet?.Cells[row, 35]?.GetValue<string>() ?? "")}",
Telephone = workSheet?.Cells[row, 9999]?.GetValue<string>() ?? "",
WorkAge = workSheet?.Cells[row, 9999]?.GetValue<string>() ?? "",
CreatedAt = DateTime.Now,
CreatedUserId = UserId ?? "",
CreatedFullName = FullName ?? "System Administrator",
LastUpdatedAt = DateTime.Now,
LastUpdateUserId = UserId ?? "",
LastUpdateFullName = FullName ?? "System Administrator"
});
// address
r.Addresses.Add(new RecruitAddress()
{
Address = $"{(workSheet?.Cells[row, 49]?.GetValue<string>() ?? "")} {(workSheet?.Cells[row, 50]?.GetValue<string>() ?? "")}",
Moo = workSheet?.Cells[row, 51]?.GetValue<string>() ?? "",
Soi = workSheet?.Cells[row, 52]?.GetValue<string>() ?? "",
Road = workSheet?.Cells[row, 53]?.GetValue<string>() ?? "",
District = workSheet?.Cells[row, 54]?.GetValue<string>() ?? "",
Amphur = workSheet?.Cells[row, 55]?.GetValue<string>() ?? "",
Province = workSheet?.Cells[row, 56]?.GetValue<string>() ?? "",
ZipCode = workSheet?.Cells[row, 57]?.GetValue<string>() ?? "",
Telephone = workSheet?.Cells[row, 58]?.GetValue<string>() ?? "",
Mobile = workSheet?.Cells[row, 9999]?.GetValue<string>() ?? "",
Address1 = $"{(workSheet?.Cells[row, 61]?.GetValue<string>() ?? "")} {(workSheet?.Cells[row, 62]?.GetValue<string>() ?? "")}",
Moo1 = workSheet?.Cells[row, 63]?.GetValue<string>() ?? "",
Soi1 = workSheet?.Cells[row, 64]?.GetValue<string>() ?? "",
Road1 = workSheet?.Cells[row, 65]?.GetValue<string>() ?? "",
District1 = workSheet?.Cells[row, 66]?.GetValue<string>() ?? "",
Amphur1 = workSheet?.Cells[row, 67]?.GetValue<string>() ?? "",
Province1 = workSheet?.Cells[row, 68]?.GetValue<string>() ?? "",
ZipCode1 = workSheet?.Cells[row, 69]?.GetValue<string>() ?? "",
CreatedAt = DateTime.Now,
CreatedUserId = UserId ?? "",
CreatedFullName = FullName ?? "System Administrator",
LastUpdatedAt = DateTime.Now,
LastUpdateUserId = UserId ?? "",
LastUpdateFullName = FullName ?? "System Administrator"
});
// payment
r.Payments.Add(new RecruitPayment()
{
PaymentId = workSheet?.Cells[row, 104]?.GetValue<string>() ?? "",
CompanyCode = workSheet?.Cells[row, 105]?.GetValue<string>() ?? "",
TextFile = workSheet?.Cells[row, 106]?.GetValue<string>() ?? "",
BankCode = workSheet?.Cells[row, 107]?.GetValue<string>() ?? "",
AccountNumber = workSheet?.Cells[row, 108]?.GetValue<string>() ?? "",
TransDate = workSheet?.Cells[row, 109]?.GetValue<string>() ?? "",
TransTime = workSheet?.Cells[row, 110]?.GetValue<string>() ?? "",
CustomerName = workSheet?.Cells[row, 111]?.GetValue<string>() ?? "",
RefNo1 = workSheet?.Cells[row, 112]?.GetValue<string>() ?? "",
TermBranch = workSheet?.Cells[row, 113]?.GetValue<string>() ?? "",
TellerId = workSheet?.Cells[row, 114]?.GetValue<string>() ?? "",
CreditDebit = workSheet?.Cells[row, 115]?.GetValue<string>() ?? "",
PaymentType = workSheet?.Cells[row, 116]?.GetValue<string>(),
ChequeNo = workSheet?.Cells[row, 117]?.GetValue<string>() ?? "",
Amount = (decimal)workSheet?.Cells[row, 118]?.GetValue<decimal>(),
ChqueBankCode = workSheet?.Cells[row, 119]?.GetValue<string>() ?? "",
CreatedAt = DateTime.Now,
CreatedUserId = UserId ?? "",
CreatedFullName = FullName ?? "System Administrator",
LastUpdatedAt = DateTime.Now,
LastUpdateUserId = UserId ?? "",
LastUpdateFullName = FullName ?? "System Administrator"
});
// certificate
@ -1150,20 +1195,13 @@ namespace BMA.EHR.Recruit.Service.Controllers
CertificateNo = workSheet?.Cells[row, 9999]?.GetValue<string>() ?? "",
Description = workSheet?.Cells[row, 9999]?.GetValue<string>() ?? "",
IssueDate = Convert.ToDateTime(workSheet?.Cells[row, 9999]?.GetValue<string>().ToDateTime(DateTimeFormat.Ymd, "-")),
ExpiredDate = Convert.ToDateTime(workSheet?.Cells[row, 9999]?.GetValue<string>().ToDateTime(DateTimeFormat.Ymd, "-"))
});
r.Educations.Add(new RecruitEducation()
{
Degree = workSheet?.Cells[row, 17]?.GetValue<string>() ?? "",
Major = workSheet?.Cells[row, 9999]?.GetValue<string>() ?? "",
MajorGroupId = workSheet?.Cells[row, 9999]?.GetValue<string>() ?? "",
MajorGroupName = workSheet?.Cells[row, 9999]?.GetValue<string>() ?? "",
University = workSheet?.Cells[row, 20]?.GetValue<string>() == "อื่น ๆ" ? workSheet?.Cells[row, 21]?.GetValue<string>() : workSheet?.Cells[row, 20]?.GetValue<string>(),
GPA = (double)workSheet?.Cells[row, 25]?.GetValue<double>(),
Specialist = workSheet?.Cells[row, 9999]?.GetValue<string>() ?? "",
HighDegree = workSheet?.Cells[row, 26]?.GetValue<string>() ?? "",
BachelorDate = Convert.ToDateTime(workSheet?.Cells[row, 24]?.GetValue<string>().ToDateTime(DateTimeFormat.Ymd, "-"))
ExpiredDate = Convert.ToDateTime(workSheet?.Cells[row, 9999]?.GetValue<string>().ToDateTime(DateTimeFormat.Ymd, "-")),
CreatedAt = DateTime.Now,
CreatedUserId = UserId ?? "",
CreatedFullName = FullName ?? "System Administrator",
LastUpdatedAt = DateTime.Now,
LastUpdateUserId = UserId ?? "",
LastUpdateFullName = FullName ?? "System Administrator"
});
r.RecruitImport = imported;