From b9316ab2cc1e9abedd21842b4e74971e3ccb415b Mon Sep 17 00:00:00 2001 From: Kittapath Date: Wed, 31 Jul 2024 10:57:24 +0700 Subject: [PATCH 1/2] no message --- src/controllers/ImportDataController.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/controllers/ImportDataController.ts b/src/controllers/ImportDataController.ts index 7412d2cd..742496ff 100644 --- a/src/controllers/ImportDataController.ts +++ b/src/controllers/ImportDataController.ts @@ -248,19 +248,19 @@ export class ImportDataController extends Controller { profileEmp.createdFullName = request.user.name; profileEmp.lastUpdateUserId = request.user.sub; profileEmp.lastUpdateFullName = request.user.name; - // profiles.push(profileEmp); + profiles.push(profileEmp); console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); - // if (profiles.length === BATCH_SIZE) { - await this.profileEmpRepo.save(profileEmp); - // profiles = await []; - // if (global.gc) { - // global.gc(); - // } - // } + if (profiles.length === BATCH_SIZE) { + await this.profileEmpRepo.save(profiles); + profiles = await []; + if (global.gc) { + global.gc(); + } + } } console.log(rowCount); - // await this.profileEmpRepo.save(profiles); + await this.profileEmpRepo.save(profiles); return new HttpSuccess(); } @@ -338,7 +338,7 @@ export class ImportDataController extends Controller { profileSalary.lastUpdateFullName = request.user.name; profileSalarys.push(profileSalary); // await this.salaryRepository.save(profileSalary); - if (profiles.length === BATCH_SIZE) { + if (profileSalarys.length === BATCH_SIZE) { await this.salaryRepository.save(profileSalarys); profileSalarys = await []; } From 463c1f96692041009c4c5ea0aae41958e4f12e19 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Wed, 31 Jul 2024 15:34:50 +0700 Subject: [PATCH 2/2] no message --- src/controllers/ImportDataController.ts | 40 ++++++++++++------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/controllers/ImportDataController.ts b/src/controllers/ImportDataController.ts index 742496ff..25ef7697 100644 --- a/src/controllers/ImportDataController.ts +++ b/src/controllers/ImportDataController.ts @@ -109,12 +109,12 @@ export class ImportDataController extends Controller { let type_: any = null; let level_: any = null; const profile = new Profile(); - if (item["FLAG_RETIRE_STATUS"] != "" && item["FLAG_RETIRE_STATUS"] != null) { - continue; - } - if (item["FLAG_PERSON_TYPE"] != "1") { - continue; - } + // if (item["FLAG_RETIRE_STATUSxxxx"] != "" && item["FLAG_RETIRE_STATUSxxxx"] != null) { + // continue; + // } + // if (item["FLAG_PERSON_TYPExxxx"] != "1") { + // continue; + // } const existingProfile = await this.profileRepo.findOne({ where: { citizenId: item["ID"] }, }); @@ -122,29 +122,29 @@ export class ImportDataController extends Controller { continue; } - if (item["MP_CEE_TYPE"]) { + if (item["TYPE"]) { type_ = await this.posTypeRepo.findOne({ - where: { posTypeName: item["MP_CEE_TYPE"] }, + where: { posTypeName: item["TYPE"] }, }); } - if (item["MP_CEE_POSITION"]) { + if (item["LEVEL"]) { if (type_ == null) { level_ = await this.posLevelRepo.findOne({ where: { - posLevelName: item["MP_CEE_POSITION"], + posLevelName: item["LEVEL"], }, }); } else { level_ = await this.posLevelRepo.findOne({ where: { - posLevelName: item["MP_CEE_POSITION"], + posLevelName: item["LEVEL"], posTypeId: type_.id, }, }); } } - let dateRetire = Extension.ConvertToDateTime(item["MP_FORCE_DATE"]); + let dateRetire = Extension.ConvertToDateTime(item["BORN"]); profile.citizenId = item["ID"] == "" ? "" : item["ID"]; profile.rank = item["RANK_NAME"] == "" ? null : item["RANK_NAME"]; profile.prefix = item["RANK_NAME"] == "" ? null : item["RANK_NAME"]; @@ -157,20 +157,20 @@ export class ImportDataController extends Controller { ? null_ : Extension.ConvertToDateTime(item["BEGIN_ENTRY_DATE"]); profile.dateStart = - item["MP_FORCE_DATE"] == "" ? null_ : Extension.ConvertToDateTime(item["MP_FORCE_DATE"]); + item["BEGIN_ENTRY_DATE"] == "" + ? null_ + : Extension.ConvertToDateTime(item["BEGIN_ENTRY_DATE"]); profile.dateRetire = dateRetire == null ? null_ : calculateRetireDate(dateRetire); profile.dateRetireLaw = dateRetire == null ? null_ : calculateRetireLaw(dateRetire); profile.position = item["WORK_LINE_NAME"] == "" ? null : item["WORK_LINE_NAME"]; profile.posTypeId = - type_ != null && type_.posTypeName == item["MP_CEE_TYPE"] && type_ ? type_.id : null; + type_ != null && type_.posTypeName == item["TYPE"] && type_ ? type_.id : null; profile.posLevelId = - level_ != null && level_.posLevelName == item["MP_CEE_POSITION"] && level_ - ? level_.id - : null; + level_ != null && level_.posLevelName == item["LEVEL"] && level_ ? level_.id : null; profile.relationship = - item["MARRIAGE_STATE"] == "" ? "" : Extension.CheckRelationship(item["MARRIAGE_STATE"]); - profile.isLeave = - item["FLAG_RETIRE_STATUS"] == "" || item["FLAG_RETIRE_STATUS"] == null ? false : true; + item["สถานภาพ"] == "" ? "" : Extension.CheckRelationship(item["สถานภาพ"]); + // profile.isLeave = + // item["FLAG_RETIRE_STATUSxxxx"] == "" || item["FLAG_RETIRE_STATUSxxxx"] == null ? false : true; profile.createdUserId = request.user.sub; profile.createdFullName = request.user.name; profile.lastUpdateUserId = request.user.sub;