report ใบสมัครสอบ

This commit is contained in:
Kittapath 2023-10-13 06:19:30 +07:00
parent 4d634413d0
commit 05a06e6431
7 changed files with 474 additions and 79 deletions

View file

@ -59,28 +59,37 @@ namespace BMA.EHR.Application.Repositories.Reports
var monthDiff = 0;
var dayDiff = 0;
var sb = new StringBuilder();
// foreach (var career in careers)
// {
// var rangeObj = career.DurationStart.CalculateBetweenDateV2Value(career.DurationEnd);
// yearDiff = yearDiff + rangeObj.years;
// monthDiff = monthDiff + rangeObj.months;
// dayDiff = dayDiff + rangeObj.days;
// if (dayDiff >= 30)
// {
// monthDiff = monthDiff + (int)(dayDiff / 30);
// dayDiff = dayDiff % 30;
// }
// if (monthDiff >= 12)
// {
// yearDiff = yearDiff + (int)(monthDiff / 12);
// monthDiff = monthDiff % 12;
// }
// sb.Clear();
// sb.Append(yearDiff == 0 ? "" : $"{yearDiff} ปี ");
// sb.Append(monthDiff == 0 ? "" : $"{monthDiff} เดือน ");
// sb.Append(dayDiff == 0 ? "" : $"{dayDiff} วัน ");
// sb.ToString();
// }
foreach (var career in careers)
{
if (career.DurationEnd < career.DurationStart)
{
var rangeObj = career.DurationEnd.CalculateBetweenDateV2Value(career.DurationStart);
yearDiff = yearDiff + rangeObj.years;
monthDiff = monthDiff + rangeObj.months;
dayDiff = dayDiff + rangeObj.days;
}
else
{
var rangeObj = career.DurationStart.CalculateBetweenDateV2Value(career.DurationEnd);
yearDiff = yearDiff + rangeObj.years;
monthDiff = monthDiff + rangeObj.months;
dayDiff = dayDiff + rangeObj.days;
}
if (dayDiff >= 30)
{
monthDiff = monthDiff + (int)(dayDiff / 30);
dayDiff = dayDiff % 30;
}
if (monthDiff >= 12)
{
yearDiff = yearDiff + (int)(monthDiff / 12);
monthDiff = monthDiff % 12;
}
sb.Clear();
sb.Append(yearDiff == 0 ? "" : $"{yearDiff} ปี ");
sb.Append(monthDiff == 0 ? "" : $"{monthDiff} เดือน ");
sb.Append(dayDiff == 0 ? "" : $"{dayDiff} วัน ");
}
var data = await _dbExamContext.Set<Candidate>().AsQueryable()
.Where(x => x.Id == id)
@ -88,64 +97,65 @@ namespace BMA.EHR.Application.Repositories.Reports
{
p.Id,
AvatarId = p.ProfileImg == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.ProfileImg.Id,
ExamIdenNumber = p.ExamIdenNumber,
PositionName = p.PositionExam == null ? "" : p.PositionExam.PositionName,
PeriodExamName = p.PeriodExam == null ? "" : p.PeriodExam.Name,
PeriodExamRound = p.PeriodExam == null ? "" : p.PeriodExam.Round.ToString(),
PeriodExamYear = p.PeriodExam == null ? "" : p.PeriodExam.Year.ToString(),
ExamIdenNumber = p.ExamIdenNumber == null ? "-" : p.ExamIdenNumber,
PositionName = p.PositionExam == null ? "-" : p.PositionExam.PositionName,
PositionLevelName = p.PositionExam == null ? "-" : p.PositionExam.PositionLevelName,
PeriodExamName = p.PeriodExam == null ? "-" : p.PeriodExam.Name,
PeriodExamRound = p.PeriodExam == null ? "-" : p.PeriodExam.Round.ToString(),
PeriodExamYear = p.PeriodExam == null ? "-" : p.PeriodExam.Year.ToString(),
FullName = $"{p.PrefixName}{p.FirstName} {p.LastName}",
Religion = p.ReligionName,
Nationality = p.Nationality,
DateOfBirth = p.DateOfBirth == null ? "" : p.DateOfBirth.Value.ToThaiShortDate2(),
Age = p.DateOfBirth == null ? "" : p.DateOfBirth.Value.CalculateAgeStrV2(0, 0),
CitizenId = p.CitizenId,
Religion = p.ReligionName == null ? "-" : p.ReligionName,
Nationality = p.Nationality == null ? "-" : p.Nationality,
DateOfBirth = p.DateOfBirth == null ? "-" : p.DateOfBirth.Value.ToThaiFullDate2(),
Age = p.DateOfBirth == null ? "-" : p.DateOfBirth.Value.CalculateAgeStrV2(0, 0),
CitizenId = p.CitizenId == null ? "-" : p.CitizenId,
EducationLevelExamName = p.Educations.FirstOrDefault() == null ? "" : p.Educations.FirstOrDefault().EducationLevelExamName,
EducationName = p.Educations.FirstOrDefault() == null ? "" : p.Educations.FirstOrDefault().EducationName,
EducationMajor = p.Educations.FirstOrDefault() == null ? "" : p.Educations.FirstOrDefault().EducationMajor,
EducationLocation = p.Educations.FirstOrDefault() == null ? "" : p.Educations.FirstOrDefault().EducationLocation,
EducationEndDate = p.Educations.FirstOrDefault() == null || p.Educations.FirstOrDefault().EducationEndDate == null ? "" : p.Educations.FirstOrDefault().EducationEndDate.Value.ToThaiShortDate2(),
EducationScores = p.Educations.FirstOrDefault() == null ? "" : p.Educations.FirstOrDefault().EducationScores,
EducationType = p.Educations.FirstOrDefault() == null ? "" : p.Educations.FirstOrDefault().EducationType,
EducationLevelHighName = p.Educations.FirstOrDefault() == null ? "" : p.Educations.FirstOrDefault().EducationLevelHighName,
EducationLevelExamName = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationLevelExamName,
EducationName = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationName,
EducationMajor = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationMajor,
EducationLocation = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationLocation,
EducationEndDate = p.Educations.FirstOrDefault() == null || p.Educations.FirstOrDefault().EducationEndDate == null ? "-" : p.Educations.FirstOrDefault().EducationEndDate.Value.ToThaiFullDate2(),
EducationScores = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationScores,
EducationType = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationType,
EducationLevelHighName = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationLevelHighName,
OccupationPositionType = p.OccupationPositionType == "other" ? "ผู้ปฏิบัติงานอื่นในกรุงเทพมหานคร" : (p.OccupationPositionType == "temp" ? "ลูกจ้างชั่วคราว" : (p.OccupationPositionType == "perm" ? "ลูกจ้างประจำ" : "-")),
OccupationPosition = p.OccupationPosition,
OccupationSalary = p.OccupationSalary,
OccupationGroup = p.OccupationGroup,
OccupationPile = p.OccupationPile,
OccupationOrg = p.OccupationOrg,
OccupationTelephone = p.OccupationTelephone,
OccupationPosition = p.OccupationPosition == null ? "-" : p.OccupationPosition,
OccupationSalary = p.OccupationSalary == null ? "-" : p.OccupationSalary.ToString(),
OccupationGroup = p.OccupationGroup == null ? "-" : p.OccupationGroup,
OccupationPile = p.OccupationPile == null ? "-" : p.OccupationPile,
OccupationOrg = p.OccupationOrg == null ? "-" : p.OccupationOrg,
OccupationTelephone = p.OccupationTelephone == null ? "-" : p.OccupationTelephone,
CareersTotal = sb,
Careers = p.Careers.Select(y => new
{
Position = y.Position,
Type = y.Type,
DurationStart = y.DurationStart.ToThaiShortDate2(),
DurationEnd = y.DurationEnd.ToThaiShortDate2(),
RangeDate = y.RangeDate,
}).ToList(),
CareersTotal = sb.ToString(),
// Careers = p.Careers.Select(y => new
// {
// Position = y.Position,
// Type = y.Type,
// DurationStart = y.DurationStart.ToThaiShortDate2(),
// DurationEnd = y.DurationEnd.ToThaiShortDate2(),
// RangeDate = y.RangeDate,
// }).ToList(),
RegistAddress = p.RegistAddress,
RegistProvinceName = p.RegistProvinceName,
RegistDistrictName = p.RegistDistrictName,
RegistSubDistrictName = p.RegistSubDistrictName,
RegistZipCode = p.RegistZipCode,
CurrentAddress = p.CurrentAddress,
CurrentProvinceName = p.CurrentProvinceName,
CurrentSubDistrictName = p.CurrentSubDistrictName,
CurrentDistrictName = p.CurrentDistrictName,
CurrentZipCode = p.CurrentZipCode,
Telephone = p.Telephone,
Email = p.Email,
RegistAddress = p.RegistAddress == null ? "-" : p.RegistAddress,
RegistProvinceName = p.RegistProvinceName == null ? "-" : p.RegistProvinceName,
RegistDistrictName = p.RegistDistrictName == null ? "-" : p.RegistDistrictName,
RegistSubDistrictName = p.RegistSubDistrictName == null ? "-" : p.RegistSubDistrictName,
RegistZipCode = p.RegistZipCode == null ? "-" : p.RegistZipCode,
CurrentAddress = p.CurrentAddress == null ? "-" : p.CurrentAddress,
CurrentProvinceName = p.CurrentProvinceName == null ? "-" : p.CurrentProvinceName,
CurrentSubDistrictName = p.CurrentSubDistrictName == null ? "-" : p.CurrentSubDistrictName,
CurrentDistrictName = p.CurrentDistrictName == null ? "-" : p.CurrentDistrictName,
CurrentZipCode = p.CurrentZipCode == null ? "-" : p.CurrentZipCode,
Telephone = p.Telephone == null ? "-" : p.Telephone,
Email = p.Email == null ? "-" : p.Email,
ContactFullName = $"{p.ContactPrefixName}{p.ContactFirstname} {p.ContactLastname}",
ContactRelations = p.ContactRelations,
ContactTel = p.ContactTel,
ContactRelations = p.ContactRelations == null ? "-" : p.ContactRelations,
ContactTel = p.ContactTel == null ? "-" : p.ContactTel,
RegisterDate = p.RegisterDate == null ? "" : p.RegisterDate.Value.ToThaiFullDate(),
RegisterDate = p.RegisterDate == null ? "-" : p.RegisterDate.Value.ToThaiFullDate(),
})
.FirstOrDefaultAsync();
@ -155,7 +165,7 @@ namespace BMA.EHR.Application.Repositories.Reports
}
public async Task<dynamic> GetExamCareerCandidateAsync(Guid id)
{
var data = await _dbExamContext.Set<Career>().AsQueryable()
var items = await _dbExamContext.Set<Career>().AsQueryable()
.Where(x => x.Candidate != null)
.Where(x => x.Candidate.Id == id)
.Select(p => new
@ -167,6 +177,22 @@ namespace BMA.EHR.Application.Repositories.Reports
RangeDate = p.RangeDate,
})
.ToListAsync();
int retVal = 1;
var data = new List<dynamic>();
foreach (var item in items)
{
var _data = new
{
Position = item.Position,
Type = item.Type,
DurationStart = item.DurationStart,
DurationEnd = item.DurationEnd,
RangeDate = item.RangeDate,
Index = retVal,
};
data.Add(_data);
retVal++;
}
return data;
}