From cfb50383575472e156ff639e7bbe80b09446469f Mon Sep 17 00:00:00 2001 From: kittapath Date: Tue, 11 Mar 2025 10:03:55 +0700 Subject: [PATCH] import edu mis --- src/controllers/ImportDataController.ts | 48 ++++++++++++++++++++----- src/entities/HR_EDUCATION.ts | 7 ++++ 2 files changed, 46 insertions(+), 9 deletions(-) diff --git a/src/controllers/ImportDataController.ts b/src/controllers/ImportDataController.ts index b8cc0c07..ca8689c7 100644 --- a/src/controllers/ImportDataController.ts +++ b/src/controllers/ImportDataController.ts @@ -1242,14 +1242,15 @@ export class ImportDataController extends Controller { for (const _item of profiles) { const existingProfile = await this.HR_EDUCATIONRepo.find({ where: { CIT: _item.citizenId }, - select: [ - "CIT", - "EDUCATION_CODE", - "START_EDUCATION_YEAR", - "EDUCATION_YEAR", - "INSTITUE", - "EDUCATION_SEQ", - ], + // select: [ + // "CIT", + // "EDUCATION_CODE", + // "START_EDUCATION_YEAR", + // "EDUCATION_YEAR", + // "INSTITUE", + // "EDUCATION_SEQ", + // ], + order: { EDUCATION_SEQ: "ASC" }, }); const educationLevel = await this.profileEducationRepo.findOne({ @@ -1281,7 +1282,36 @@ export class ImportDataController extends Controller { ? Extension.ConvertToDateTimeV2(item.EDUCATION_YEAR) : _null; // endDate = endDate ? new Date(endDate, 0, 1) : _null; - + if (item.FLAG_EDUCATION == "1") { + const checkData = await this.HR_EDUCATIONRepo.find({ + where: { CIT: _item.citizenId, FLAG_EDUCATION: "1" }, + order: { EDUCATION_SEQ: "DESC" }, + }); + if ((checkData.length > 1 && checkData[0].id == item.id) || checkData.length == 1) { + education.isEducation = true; + const findIsHigh = await this.HR_EDUCATIONRepo.findOne({ + where: { CIT: _item.citizenId, FLAG_EDUCATION: "3" }, + }); + if (findIsHigh == null) { + education.isHigh = true; + } + } + } else if (item.FLAG_EDUCATION == "2") { + } else if (item.FLAG_EDUCATION == "3") { + const checkData = await this.HR_EDUCATIONRepo.find({ + where: { CIT: _item.citizenId, FLAG_EDUCATION: "3" }, + order: { EDUCATION_SEQ: "DESC" }, + }); + if ((checkData.length > 1 && checkData[0].id == item.id) || checkData.length == 1) { + education.isHigh = true; + const findIsEducation = await this.HR_EDUCATIONRepo.findOne({ + where: { CIT: _item.citizenId, FLAG_EDUCATION: "1" }, + }); + if (findIsEducation == null) { + education.isEducation = true; + } + } + } education.level = educationLevel == null ? 1 : educationLevel.level + 1; education.profileId = _item.id; education.degree = educationCode ? educationCode.EDUCATION_NAME : _null; diff --git a/src/entities/HR_EDUCATION.ts b/src/entities/HR_EDUCATION.ts index 5f4e34f4..57614548 100644 --- a/src/entities/HR_EDUCATION.ts +++ b/src/entities/HR_EDUCATION.ts @@ -66,4 +66,11 @@ export class HR_EDUCATION { default: null, }) MAJOR_CODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + FLAG_EDUCATION: string; }