Merge branch 'develop' into adiDev

This commit is contained in:
AdisakKanthawilang 2024-09-19 10:52:28 +07:00
commit 14b95392ff

View file

@ -115,11 +115,16 @@ export class ImportDataController extends Controller {
// if (item["FLAG_PERSON_TYPExxxx"] != "1") {
// continue;
// }
if (new Date(item["RET_YEAR"]).getFullYear() >= 2567) {
continue;
}
const existingProfile = await this.profileRepo.findOne({
where: { citizenId: item["ID"] },
});
if (existingProfile) {
continue;
profile.id = existingProfile.id;
// continue;
}
if (item["TYPE"]) {
@ -144,22 +149,18 @@ export class ImportDataController extends Controller {
}
}
let dateRetire = Extension.ConvertToDateTime(item["BORN"]);
let dateRetire = new Date(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"];
profile.firstName = item["FNAME"] == "" ? null : item["FNAME"];
profile.lastName = item["LNAME"] == "" ? null : item["LNAME"];
profile.gender = item["SEX"] == "1" ? "ชาย" : item["SEX"] == "2" ? "หญิง" : null_;
profile.birthDate = item["BORN"] == "" ? null_ : Extension.ConvertToDateTime(item["BORN"]);
profile.birthDate = item["BORN"] == "" ? null_ : new Date(item["BORN"]);
profile.dateAppoint =
item["BEGIN_ENTRY_DATE"] == ""
? null_
: Extension.ConvertToDateTime(item["BEGIN_ENTRY_DATE"]);
item["BEGIN_ENTRY_DATE"] == "" ? null_ : new Date(item["BEGIN_ENTRY_DATE"]);
profile.dateStart =
item["BEGIN_ENTRY_DATE"] == ""
? null_
: Extension.ConvertToDateTime(item["BEGIN_ENTRY_DATE"]);
item["BEGIN_ENTRY_DATE"] == "" ? null_ : new Date(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"];
@ -177,21 +178,21 @@ export class ImportDataController extends Controller {
profile.lastUpdateFullName = request.user.name;
profile.createdAt = new Date();
profile.lastUpdatedAt = new Date();
profiles.push(profile);
// profiles.push(profile);
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
if (profiles.length === BATCH_SIZE) {
await this.profileRepo.save(profiles);
profiles = await [];
if (global.gc) {
global.gc();
}
}
// if (profiles.length === BATCH_SIZE) {
await this.profileRepo.save(profile);
// profiles = await [];
// if (global.gc) {
// global.gc();
// }
// }
}
// )
// );
console.log(rowCount);
await this.profileRepo.save(profiles);
// console.log(rowCount);
// await this.profileRepo.save(profiles);
return new HttpSuccess();
}
@ -216,14 +217,18 @@ export class ImportDataController extends Controller {
if (item["FLAG_PERSON_TYPE"] != "6") {
continue;
}
if (new Date(item["RET_YEAR"]).getFullYear() >= 2567) {
continue;
}
const existingProfile = await this.profileEmpRepo.findOne({
where: { citizenId: item["ID"] },
});
if (existingProfile) {
continue;
profileEmp.id = existingProfile.id;
// continue;
}
let dateRetire = Extension.ConvertToDateTime(item["MP_FORCE_DATE"]);
let dateRetire = new Date(item["MP_FORCE_DATE"]);
profileEmp.citizenId = item["ID"] == "" ? "" : item["ID"];
profileEmp.employeeClass =
@ -233,13 +238,10 @@ export class ImportDataController extends Controller {
profileEmp.firstName = item["FNAME"] == "" ? null : item["FNAME"];
profileEmp.lastName = item["LNAME"] == "" ? null : item["LNAME"];
profileEmp.gender = item["SEX"] == "1" ? "ชาย" : item["SEX"] == "2" ? "หญิง" : null_;
profileEmp.birthDate = item["BORN"] == "" ? null_ : Extension.ConvertToDateTime(item["BORN"]);
profileEmp.birthDate = item["BORN"] == "" ? null_ : new Date(item["BORN"]);
profileEmp.dateAppoint =
item["BEGIN_ENTRY_DATE"] == ""
? null_
: Extension.ConvertToDateTime(item["BEGIN_ENTRY_DATE"]);
profileEmp.dateStart =
item["MP_FORCE_DATE"] == "" ? null_ : Extension.ConvertToDateTime(item["MP_FORCE_DATE"]);
item["BEGIN_ENTRY_DATE"] == "" ? null_ : new Date(item["BEGIN_ENTRY_DATE"]);
profileEmp.dateStart = item["MP_FORCE_DATE"] == "" ? null_ : new Date(item["MP_FORCE_DATE"]);
profileEmp.dateRetire = dateRetire == null ? null_ : calculateRetireDate(dateRetire);
profileEmp.dateRetireLaw = dateRetire == null ? null_ : calculateRetireLaw(dateRetire);
profileEmp.position = item["WORK_LINE_NAME"] == "" ? null : item["WORK_LINE_NAME"];
@ -252,19 +254,19 @@ export class ImportDataController extends Controller {
profileEmp.lastUpdateFullName = request.user.name;
profileEmp.createdAt = new Date();
profileEmp.lastUpdatedAt = new Date();
profiles.push(profileEmp);
// profiles.push(profileEmp);
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
if (profiles.length === BATCH_SIZE) {
await this.profileEmpRepo.save(profiles);
profiles = await [];
if (global.gc) {
global.gc();
}
}
// if (profiles.length === BATCH_SIZE) {
await this.profileEmpRepo.save(profileEmp);
// profiles = await [];
// if (global.gc) {
// global.gc();
// }
// }
}
console.log(rowCount);
await this.profileEmpRepo.save(profiles);
// console.log(rowCount);
// await this.profileEmpRepo.save(profiles);
return new HttpSuccess();
}
@ -413,9 +415,10 @@ export class ImportDataController extends Controller {
existingProfile.map(async (item) => {
rowCount++;
const profileSalary = new ProfileSalary();
profileSalary.date =
item.MP_POS_DATE == "" ? null_ : Extension.ConvertToDateTimeV2(item.MP_POS_DATE);
item.MP_POS_DATE == ""
? null_
: new Date(item.MP_POS_DATE.replace(" +0700 +07:00", ""));
const SALARY: any =
item.SALARY == null || item.SALARY == "" ? null_ : Number(item.SALARY);
profileSalary.amount = SALARY;