แก้ import data
This commit is contained in:
parent
5d223d4b69
commit
94e5561b2b
1 changed files with 42 additions and 39 deletions
|
|
@ -115,11 +115,16 @@ export class ImportDataController extends Controller {
|
||||||
// if (item["FLAG_PERSON_TYPExxxx"] != "1") {
|
// if (item["FLAG_PERSON_TYPExxxx"] != "1") {
|
||||||
// continue;
|
// continue;
|
||||||
// }
|
// }
|
||||||
|
if (new Date(item["RET_YEAR"]).getFullYear() >= 2567) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const existingProfile = await this.profileRepo.findOne({
|
const existingProfile = await this.profileRepo.findOne({
|
||||||
where: { citizenId: item["ID"] },
|
where: { citizenId: item["ID"] },
|
||||||
});
|
});
|
||||||
if (existingProfile) {
|
if (existingProfile) {
|
||||||
continue;
|
profile.id = existingProfile.id;
|
||||||
|
// continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item["TYPE"]) {
|
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.citizenId = item["ID"] == "" ? "" : item["ID"];
|
||||||
profile.rank = item["RANK_NAME"] == "" ? null : item["RANK_NAME"];
|
profile.rank = item["RANK_NAME"] == "" ? null : item["RANK_NAME"];
|
||||||
profile.prefix = item["RANK_NAME"] == "" ? null : item["RANK_NAME"];
|
profile.prefix = item["RANK_NAME"] == "" ? null : item["RANK_NAME"];
|
||||||
profile.firstName = item["FNAME"] == "" ? null : item["FNAME"];
|
profile.firstName = item["FNAME"] == "" ? null : item["FNAME"];
|
||||||
profile.lastName = item["LNAME"] == "" ? null : item["LNAME"];
|
profile.lastName = item["LNAME"] == "" ? null : item["LNAME"];
|
||||||
profile.gender = item["SEX"] == "1" ? "ชาย" : item["SEX"] == "2" ? "หญิง" : null_;
|
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 =
|
profile.dateAppoint =
|
||||||
item["BEGIN_ENTRY_DATE"] == ""
|
item["BEGIN_ENTRY_DATE"] == "" ? null_ : new Date(item["BEGIN_ENTRY_DATE"]);
|
||||||
? null_
|
|
||||||
: Extension.ConvertToDateTime(item["BEGIN_ENTRY_DATE"]);
|
|
||||||
profile.dateStart =
|
profile.dateStart =
|
||||||
item["BEGIN_ENTRY_DATE"] == ""
|
item["BEGIN_ENTRY_DATE"] == "" ? null_ : new Date(item["BEGIN_ENTRY_DATE"]);
|
||||||
? null_
|
|
||||||
: Extension.ConvertToDateTime(item["BEGIN_ENTRY_DATE"]);
|
|
||||||
profile.dateRetire = dateRetire == null ? null_ : calculateRetireDate(dateRetire);
|
profile.dateRetire = dateRetire == null ? null_ : calculateRetireDate(dateRetire);
|
||||||
profile.dateRetireLaw = dateRetire == null ? null_ : calculateRetireLaw(dateRetire);
|
profile.dateRetireLaw = dateRetire == null ? null_ : calculateRetireLaw(dateRetire);
|
||||||
profile.position = item["WORK_LINE_NAME"] == "" ? null : item["WORK_LINE_NAME"];
|
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.lastUpdateFullName = request.user.name;
|
||||||
profile.createdAt = new Date();
|
profile.createdAt = new Date();
|
||||||
profile.lastUpdatedAt = new Date();
|
profile.lastUpdatedAt = new Date();
|
||||||
profiles.push(profile);
|
// profiles.push(profile);
|
||||||
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
||||||
|
|
||||||
if (profiles.length === BATCH_SIZE) {
|
// if (profiles.length === BATCH_SIZE) {
|
||||||
await this.profileRepo.save(profiles);
|
await this.profileRepo.save(profile);
|
||||||
profiles = await [];
|
// profiles = await [];
|
||||||
if (global.gc) {
|
// if (global.gc) {
|
||||||
global.gc();
|
// global.gc();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
// )
|
// )
|
||||||
// );
|
// );
|
||||||
console.log(rowCount);
|
// console.log(rowCount);
|
||||||
await this.profileRepo.save(profiles);
|
// await this.profileRepo.save(profiles);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -216,14 +217,18 @@ export class ImportDataController extends Controller {
|
||||||
if (item["FLAG_PERSON_TYPE"] != "6") {
|
if (item["FLAG_PERSON_TYPE"] != "6") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (new Date(item["RET_YEAR"]).getFullYear() >= 2567) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const existingProfile = await this.profileEmpRepo.findOne({
|
const existingProfile = await this.profileEmpRepo.findOne({
|
||||||
where: { citizenId: item["ID"] },
|
where: { citizenId: item["ID"] },
|
||||||
});
|
});
|
||||||
if (existingProfile) {
|
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.citizenId = item["ID"] == "" ? "" : item["ID"];
|
||||||
profileEmp.employeeClass =
|
profileEmp.employeeClass =
|
||||||
|
|
@ -233,13 +238,10 @@ export class ImportDataController extends Controller {
|
||||||
profileEmp.firstName = item["FNAME"] == "" ? null : item["FNAME"];
|
profileEmp.firstName = item["FNAME"] == "" ? null : item["FNAME"];
|
||||||
profileEmp.lastName = item["LNAME"] == "" ? null : item["LNAME"];
|
profileEmp.lastName = item["LNAME"] == "" ? null : item["LNAME"];
|
||||||
profileEmp.gender = item["SEX"] == "1" ? "ชาย" : item["SEX"] == "2" ? "หญิง" : null_;
|
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 =
|
profileEmp.dateAppoint =
|
||||||
item["BEGIN_ENTRY_DATE"] == ""
|
item["BEGIN_ENTRY_DATE"] == "" ? null_ : new Date(item["BEGIN_ENTRY_DATE"]);
|
||||||
? null_
|
profileEmp.dateStart = item["MP_FORCE_DATE"] == "" ? null_ : new Date(item["MP_FORCE_DATE"]);
|
||||||
: Extension.ConvertToDateTime(item["BEGIN_ENTRY_DATE"]);
|
|
||||||
profileEmp.dateStart =
|
|
||||||
item["MP_FORCE_DATE"] == "" ? null_ : Extension.ConvertToDateTime(item["MP_FORCE_DATE"]);
|
|
||||||
profileEmp.dateRetire = dateRetire == null ? null_ : calculateRetireDate(dateRetire);
|
profileEmp.dateRetire = dateRetire == null ? null_ : calculateRetireDate(dateRetire);
|
||||||
profileEmp.dateRetireLaw = dateRetire == null ? null_ : calculateRetireLaw(dateRetire);
|
profileEmp.dateRetireLaw = dateRetire == null ? null_ : calculateRetireLaw(dateRetire);
|
||||||
profileEmp.position = item["WORK_LINE_NAME"] == "" ? null : item["WORK_LINE_NAME"];
|
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.lastUpdateFullName = request.user.name;
|
||||||
profileEmp.createdAt = new Date();
|
profileEmp.createdAt = new Date();
|
||||||
profileEmp.lastUpdatedAt = new Date();
|
profileEmp.lastUpdatedAt = new Date();
|
||||||
profiles.push(profileEmp);
|
// profiles.push(profileEmp);
|
||||||
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
||||||
|
|
||||||
if (profiles.length === BATCH_SIZE) {
|
// if (profiles.length === BATCH_SIZE) {
|
||||||
await this.profileEmpRepo.save(profiles);
|
await this.profileEmpRepo.save(profileEmp);
|
||||||
profiles = await [];
|
// profiles = await [];
|
||||||
if (global.gc) {
|
// if (global.gc) {
|
||||||
global.gc();
|
// global.gc();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
console.log(rowCount);
|
// console.log(rowCount);
|
||||||
await this.profileEmpRepo.save(profiles);
|
// await this.profileEmpRepo.save(profiles);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -413,9 +415,10 @@ export class ImportDataController extends Controller {
|
||||||
existingProfile.map(async (item) => {
|
existingProfile.map(async (item) => {
|
||||||
rowCount++;
|
rowCount++;
|
||||||
const profileSalary = new ProfileSalary();
|
const profileSalary = new ProfileSalary();
|
||||||
|
|
||||||
profileSalary.date =
|
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 =
|
const SALARY: any =
|
||||||
item.SALARY == null || item.SALARY == "" ? null_ : Number(item.SALARY);
|
item.SALARY == null || item.SALARY == "" ? null_ : Number(item.SALARY);
|
||||||
profileSalary.amount = SALARY;
|
profileSalary.amount = SALARY;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue