no message

This commit is contained in:
Kittapath 2024-07-31 09:43:23 +07:00
parent 99187d08b5
commit 603602adbc
2 changed files with 696 additions and 690 deletions

View file

@ -109,18 +109,18 @@ export class ImportDataController extends Controller {
let type_: any = null; let type_: any = null;
let level_: any = null; let level_: any = null;
const profile = new Profile(); const profile = new Profile();
const existingProfile = await this.profileRepo.findOne({
where: { citizenId: item["ID"] },
});
if (existingProfile) {
continue;
}
if (item["FLAG_RETIRE_STATUS"] != "" && item["FLAG_RETIRE_STATUS"] != null) { if (item["FLAG_RETIRE_STATUS"] != "" && item["FLAG_RETIRE_STATUS"] != null) {
continue; continue;
} }
if (item["FLAG_PERSON_TYPE"] != "1") { if (item["FLAG_PERSON_TYPE"] != "1") {
continue; continue;
} }
const existingProfile = await this.profileRepo.findOne({
where: { citizenId: item["ID"] },
});
if (existingProfile) {
continue;
}
if (item["MP_CEE_TYPE"]) { if (item["MP_CEE_TYPE"]) {
type_ = await this.posTypeRepo.findOne({ type_ = await this.posTypeRepo.findOne({
@ -180,7 +180,7 @@ export class ImportDataController extends Controller {
if (profiles.length === BATCH_SIZE) { if (profiles.length === BATCH_SIZE) {
await this.profileRepo.save(profiles); await this.profileRepo.save(profiles);
profiles = []; profiles = await [];
if (global.gc) { if (global.gc) {
global.gc(); global.gc();
} }
@ -208,18 +208,18 @@ export class ImportDataController extends Controller {
for await (const item of readStream) { for await (const item of readStream) {
rowCount++; rowCount++;
const profileEmp = new ProfileEmployee(); const profileEmp = new ProfileEmployee();
const existingProfile = await this.profileEmpRepo.findOne({ if (item["FLAG_RETIRE_STATUS"] != "" && item["FLAG_RETIRE_STATUS"] != null) {
where: { citizenId: item["ID"] },
});
console.log(item);
console.log(item["ID"]);
// console.log(existingProfile);
if (existingProfile) {
continue; continue;
} }
if (item["FLAG_PERSON_TYPE"] != "6") { if (item["FLAG_PERSON_TYPE"] != "6") {
continue; continue;
} }
const existingProfile = await this.profileEmpRepo.findOne({
where: { citizenId: item["ID"] },
});
if (existingProfile) {
continue;
}
let dateRetire = Extension.ConvertToDateTime(item["MP_FORCE_DATE"]); let dateRetire = Extension.ConvertToDateTime(item["MP_FORCE_DATE"]);
@ -248,19 +248,19 @@ export class ImportDataController extends Controller {
profileEmp.createdFullName = request.user.name; profileEmp.createdFullName = request.user.name;
profileEmp.lastUpdateUserId = request.user.sub; profileEmp.lastUpdateUserId = request.user.sub;
profileEmp.lastUpdateFullName = request.user.name; profileEmp.lastUpdateFullName = request.user.name;
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 = []; // 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();
} }
@ -273,18 +273,21 @@ export class ImportDataController extends Controller {
let profileSalarys: any = []; let profileSalarys: any = [];
let null_: any = null; let null_: any = null;
const [_profiles, total] = await AppDataSource.getRepository(Profile) const [profiles, total] = await AppDataSource.getRepository(Profile)
.createQueryBuilder("profile")
.select(["profile.id"])
.getManyAndCount();
for (var i = 1; i <= total / BATCH_SIZE; i++) {
const profiles = await AppDataSource.getRepository(Profile)
.createQueryBuilder("profile") .createQueryBuilder("profile")
.select(["profile.citizenId", "profile.id"]) .select(["profile.citizenId", "profile.id"])
.orderBy("profile.citizenId", "ASC") .orderBy("profile.citizenId", "ASC")
.skip((i - 1) * BATCH_SIZE) // .skip(0)
.take(BATCH_SIZE) // .take(20)
.getMany(); .getManyAndCount();
// for (var i = 1; i <= total / BATCH_SIZE; i++) {
// const profiles = await AppDataSource.getRepository(Profile)
// .createQueryBuilder("profile")
// .select(["profile.citizenId", "profile.id"])
// .orderBy("profile.citizenId", "ASC")
// .skip((i - 1) * BATCH_SIZE)
// .take(BATCH_SIZE)
// .getMany();
await Promise.all( await Promise.all(
profiles.map(async (_item) => { profiles.map(async (_item) => {
@ -306,7 +309,7 @@ export class ImportDataController extends Controller {
], ],
}); });
profileSalarys = await []; // profileSalarys = await [];
await Promise.all( await Promise.all(
existingProfile.map(async (item) => { existingProfile.map(async (item) => {
rowCount++; rowCount++;
@ -334,15 +337,21 @@ export class ImportDataController extends Controller {
profileSalary.lastUpdateUserId = request.user.sub; profileSalary.lastUpdateUserId = request.user.sub;
profileSalary.lastUpdateFullName = request.user.name; profileSalary.lastUpdateFullName = request.user.name;
profileSalarys.push(profileSalary); profileSalarys.push(profileSalary);
// await this.salaryRepository.save(profileSalary);
if (profiles.length === BATCH_SIZE) {
await this.salaryRepository.save(profileSalarys);
profileSalarys = await [];
}
}),
);
// await this.salaryRepository.save(profileSalarys);
// profileSalarys = await [];
}), }),
); );
await this.salaryRepository.save(profileSalarys); await this.salaryRepository.save(profileSalarys);
profileSalarys = []; // }
}),
);
}
console.log(rowCount); console.log(rowCount);
return new HttpSuccess(profileSalarys); return new HttpSuccess();
} }
/** /**
@ -354,18 +363,21 @@ export class ImportDataController extends Controller {
let profileSalarys: any = []; let profileSalarys: any = [];
let null_: any = null; let null_: any = null;
const [_profiles, total] = await AppDataSource.getRepository(ProfileEmployee) const [profiles, total] = await AppDataSource.getRepository(ProfileEmployee)
.createQueryBuilder("profile")
.select(["profile.id"])
.getManyAndCount();
for (var i = 1; i <= total / BATCH_SIZE; i++) {
const profiles = await AppDataSource.getRepository(ProfileEmployee)
.createQueryBuilder("profile") .createQueryBuilder("profile")
.select(["profile.citizenId", "profile.id"]) .select(["profile.citizenId", "profile.id"])
.orderBy("profile.citizenId", "ASC") .orderBy("profile.citizenId", "ASC")
.skip((i - 1) * BATCH_SIZE) // .skip(0)
.take(BATCH_SIZE) // .take(20)
.getMany(); .getManyAndCount();
// for (var i = 1; i <= total / BATCH_SIZE; i++) {
// const profiles = await AppDataSource.getRepository(ProfileEmployee)
// .createQueryBuilder("profile")
// .select(["profile.citizenId", "profile.id"])
// .orderBy("profile.citizenId", "ASC")
// .skip((i - 1) * BATCH_SIZE)
// .take(BATCH_SIZE)
// .getMany();
await Promise.all( await Promise.all(
profiles.map(async (_item) => { profiles.map(async (_item) => {
@ -416,16 +428,21 @@ export class ImportDataController extends Controller {
profileSalary.lastUpdateUserId = request.user.sub; profileSalary.lastUpdateUserId = request.user.sub;
profileSalary.lastUpdateFullName = request.user.name; profileSalary.lastUpdateFullName = request.user.name;
profileSalarys.push(profileSalary); profileSalarys.push(profileSalary);
// await this.salaryRepository.save(profileSalary);
if (profileSalarys.length === BATCH_SIZE) {
await this.salaryRepository.save(profileSalarys);
profileSalarys = await [];
}
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
}), }),
); );
await this.salaryRepository.save(profileSalarys); // await this.salaryRepository.save(profileSalarys);
profileSalarys = []; // profileSalarys = await [];
}), }),
); );
} // }
console.log(rowCount);
await this.salaryRepository.save(profileSalarys); await this.salaryRepository.save(profileSalarys);
console.log(rowCount);
return new HttpSuccess(); return new HttpSuccess();
} }
@ -439,18 +456,21 @@ export class ImportDataController extends Controller {
let mothers: any = []; let mothers: any = [];
let couples: any = []; let couples: any = [];
const [_profiles, total] = await AppDataSource.getRepository(Profile) const [profiles, total] = await AppDataSource.getRepository(Profile)
.createQueryBuilder("profile")
.select(["profile.id"])
.getManyAndCount();
for (var i = 1; i <= total / BATCH_SIZE; i++) {
const profiles = await AppDataSource.getRepository(Profile)
.createQueryBuilder("profile") .createQueryBuilder("profile")
.select(["profile.citizenId", "profile.id"]) .select(["profile.citizenId", "profile.id"])
.orderBy("profile.citizenId", "ASC") .orderBy("profile.citizenId", "ASC")
.skip((i - 1) * BATCH_SIZE) // .skip(0)
.take(BATCH_SIZE) // .take(20)
.getMany(); .getManyAndCount();
// for (var i = 1; i <= total / BATCH_SIZE; i++) {
// const profiles = await AppDataSource.getRepository(Profile)
// .createQueryBuilder("profile")
// .select(["profile.citizenId", "profile.id"])
// .orderBy("profile.citizenId", "ASC")
// .skip((i - 1) * BATCH_SIZE)
// .take(BATCH_SIZE)
// .getMany();
await Promise.all( await Promise.all(
profiles.map(async (_item) => { profiles.map(async (_item) => {
@ -475,11 +495,6 @@ export class ImportDataController extends Controller {
return; return;
} }
// fathers = await [];
// mothers = await [];
// couples = await [];
// await Promise.all(
// existingProfile.map(async (item) => {
rowCount++; rowCount++;
const profileFather = new ProfileFamilyFather(); const profileFather = new ProfileFamilyFather();
const profileMother = new ProfileFamilyMother(); const profileMother = new ProfileFamilyMother();
@ -515,47 +530,33 @@ export class ImportDataController extends Controller {
profileCouple.lastUpdateUserId = request.user.sub; profileCouple.lastUpdateUserId = request.user.sub;
profileCouple.lastUpdateFullName = request.user.name; profileCouple.lastUpdateFullName = request.user.name;
fathers.push(profileFather); // fathers.push(profileFather);
mothers.push(profileMother); // mothers.push(profileMother);
couples.push(profileCouple); // couples.push(profileCouple);
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
if (fathers.length === BATCH_SIZE) { // if (fathers.length === BATCH_SIZE) {
await this.profileFamilyFatherRepository.save(fathers); await this.profileFamilyFatherRepository.save(profileFather);
fathers = await []; // fathers = await [];
// if (global.gc) {
// global.gc();
// } // }
} // if (mothers.length === BATCH_SIZE) {
if (mothers.length === BATCH_SIZE) { await this.profileFamilyMotherRepository.save(profileMother);
await this.profileFamilyMotherRepository.save(mothers); // mothers = await [];
mothers = await [];
// if (global.gc) {
// global.gc();
// } // }
} // if (couples.length === BATCH_SIZE) {
if (couples.length === BATCH_SIZE) { await this.profileFamilyCoupleRepository.save(profileCouple);
await this.profileFamilyCoupleRepository.save(couples); // couples = await [];
couples = await [];
// if (global.gc) {
// global.gc();
// } // }
}
// }),
// );
// await this.salaryRepository.save(profileSalarys);
// profileSalarys = [];
}), }),
); );
}
// } // }
console.log(rowCount); console.log(rowCount);
await Promise.all([ // await Promise.all([
this.profileFamilyFatherRepository.save(fathers), // this.profileFamilyFatherRepository.save(fathers),
this.profileFamilyMotherRepository.save(mothers), // this.profileFamilyMotherRepository.save(mothers),
this.profileFamilyCoupleRepository.save(couples), // this.profileFamilyCoupleRepository.save(couples),
]); // ]);
return new HttpSuccess(); return new HttpSuccess();
} }
@ -570,18 +571,21 @@ export class ImportDataController extends Controller {
let mothers: any = []; let mothers: any = [];
let couples: any = []; let couples: any = [];
const [_profiles, total] = await AppDataSource.getRepository(ProfileEmployee) const [profiles, total] = await AppDataSource.getRepository(ProfileEmployee)
.createQueryBuilder("profile")
.select(["profile.id"])
.getManyAndCount();
for (var i = 1; i <= total / BATCH_SIZE; i++) {
const profiles = await AppDataSource.getRepository(ProfileEmployee)
.createQueryBuilder("profile") .createQueryBuilder("profile")
.select(["profile.citizenId", "profile.id"]) .select(["profile.citizenId", "profile.id"])
.orderBy("profile.citizenId", "ASC") .orderBy("profile.citizenId", "ASC")
.skip((i - 1) * BATCH_SIZE) // .skip(0)
.take(BATCH_SIZE) // .take(20)
.getMany(); .getManyAndCount();
// for (var i = 1; i <= total / BATCH_SIZE; i++) {
// const profiles = await AppDataSource.getRepository(ProfileEmployee)
// .createQueryBuilder("profile")
// .select(["profile.citizenId", "profile.id"])
// .orderBy("profile.citizenId", "ASC")
// .skip((i - 1) * BATCH_SIZE)
// .take(BATCH_SIZE)
// .getMany();
await Promise.all( await Promise.all(
profiles.map(async (_item) => { profiles.map(async (_item) => {
@ -641,33 +645,33 @@ export class ImportDataController extends Controller {
profileCouple.lastUpdateUserId = request.user.sub; profileCouple.lastUpdateUserId = request.user.sub;
profileCouple.lastUpdateFullName = request.user.name; profileCouple.lastUpdateFullName = request.user.name;
fathers.push(profileFather); // fathers.push(profileFather);
mothers.push(profileMother); // mothers.push(profileMother);
couples.push(profileCouple); // couples.push(profileCouple);
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
if (fathers.length === BATCH_SIZE) { // if (fathers.length === BATCH_SIZE) {
await this.profileFamilyFatherRepository.save(fathers); await this.profileFamilyFatherRepository.save(profileFather);
fathers = await []; // fathers = await [];
} // }
if (mothers.length === BATCH_SIZE) { // if (mothers.length === BATCH_SIZE) {
await this.profileFamilyMotherRepository.save(mothers); await this.profileFamilyMotherRepository.save(profileMother);
mothers = await []; // mothers = await [];
} // }
if (couples.length === BATCH_SIZE) { // if (couples.length === BATCH_SIZE) {
await this.profileFamilyCoupleRepository.save(couples); await this.profileFamilyCoupleRepository.save(profileCouple);
couples = await []; // couples = await [];
} // }
}), }),
); );
} // }
console.log(rowCount); console.log(rowCount);
await Promise.all([ // await Promise.all([
this.profileFamilyFatherRepository.save(fathers), // this.profileFamilyFatherRepository.save(fathers),
this.profileFamilyMotherRepository.save(mothers), // this.profileFamilyMotherRepository.save(mothers),
this.profileFamilyCoupleRepository.save(couples), // this.profileFamilyCoupleRepository.save(couples),
]); // ]);
return new HttpSuccess(); return new HttpSuccess();
} }
@ -712,34 +716,30 @@ export class ImportDataController extends Controller {
let rowCount = 0; let rowCount = 0;
let educations: any = []; let educations: any = [];
let null_: any = null; let null_: any = null;
const [_profiles, total] = await AppDataSource.getRepository(Profile) const [profiles, total] = await AppDataSource.getRepository(Profile)
.createQueryBuilder("profile")
.select(["profile.id"])
.getManyAndCount();
for (var i = 1; i <= total / BATCH_SIZE; i++) {
const profiles = await AppDataSource.getRepository(Profile)
.createQueryBuilder("profile") .createQueryBuilder("profile")
.select(["profile.citizenId", "profile.id"]) .select(["profile.citizenId", "profile.id"])
.orderBy("profile.citizenId", "ASC") .orderBy("profile.citizenId", "ASC")
.skip((i - 1) * BATCH_SIZE) // .skip(0)
.take(BATCH_SIZE) // .take(20)
.getMany(); .getManyAndCount();
// for (var i = 1; i <= 2; i++) {
// const profiles = await AppDataSource.getRepository(Profile)
// .createQueryBuilder("profile")
// .select(["profile.citizenId", "profile.id"])
// .orderBy("profile.citizenId", "ASC")
// .skip((i - 1) * 5)
// .take(5)
// .getMany();
await Promise.all( await Promise.all(
profiles.map(async (_item) => { profiles.map(async (_item) => {
const existingProfile = await this.HR_EDUCATIONRepo.find({ const existingProfile = await this.HR_EDUCATIONRepo.find({
where: { CIT: _item.citizenId }, where: { CIT: _item.citizenId },
select: [ select: ["CIT", "EDUCATION_CODE", "START_EDUCATION_YEAR", "EDUCATION_YEAR", "INSTITUE"],
"CIT",
"EDUCATION_CODE",
"START_EDUCATION_YEAR",
"EDUCATION_YEAR",
"EDUCATION_NAME",
"INSTITUE",
],
}); });
educations = await []; // educations = await [];
await Promise.all( await Promise.all(
existingProfile.map(async (item) => { existingProfile.map(async (item) => {
rowCount++; rowCount++;
@ -767,13 +767,15 @@ export class ImportDataController extends Controller {
education.createdFullName = request.user.name; education.createdFullName = request.user.name;
education.lastUpdateUserId = request.user.sub; education.lastUpdateUserId = request.user.sub;
education.lastUpdateFullName = request.user.name; education.lastUpdateFullName = request.user.name;
educations.push(education); // await educations.push(await education);
await this.educationRepository.save(await education);
}), }),
); );
await this.educationRepository.save(educations); // await this.educationRepository.save(educations);
// educations = await [];
}), }),
); );
} // }
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
// await this.educationRepository.save(educations); // await this.educationRepository.save(educations);
return new HttpSuccess(); return new HttpSuccess();
@ -787,31 +789,27 @@ export class ImportDataController extends Controller {
let rowCount = 0; let rowCount = 0;
let educations: any = []; let educations: any = [];
let null_: any = null; let null_: any = null;
const [_profiles, total] = await AppDataSource.getRepository(ProfileEmployee) const [profiles, total] = await AppDataSource.getRepository(ProfileEmployee)
.createQueryBuilder("profile")
.select(["profile.id"])
.getManyAndCount();
for (var i = 1; i <= total / BATCH_SIZE; i++) {
const profiles = await AppDataSource.getRepository(ProfileEmployee)
.createQueryBuilder("profile") .createQueryBuilder("profile")
.select(["profile.citizenId", "profile.id"]) .select(["profile.citizenId", "profile.id"])
.orderBy("profile.citizenId", "ASC") .orderBy("profile.citizenId", "ASC")
.skip((i - 1) * BATCH_SIZE) // .skip(0)
.take(BATCH_SIZE) // .take(20)
.getMany(); .getManyAndCount();
// for (var i = 1; i <= total / BATCH_SIZE; i++) {
// const profiles = await AppDataSource.getRepository(ProfileEmployee)
// .createQueryBuilder("profile")
// .select(["profile.citizenId", "profile.id"])
// .orderBy("profile.citizenId", "ASC")
// .skip((i - 1) * BATCH_SIZE)
// .take(BATCH_SIZE)
// .getMany();
await Promise.all( await Promise.all(
profiles.map(async (_item) => { profiles.map(async (_item) => {
const existingProfile = await this.HR_EDUCATION_EMPRepo.find({ const existingProfile = await this.HR_EDUCATION_EMPRepo.find({
where: { CIT: _item.citizenId }, where: { CIT: _item.citizenId },
select: [ select: ["CIT", "EDUCATION_CODE", "START_EDUCATION_YEAR", "EDUCATION_YEAR", "INSTITUE"],
"CIT",
"EDUCATION_CODE",
"START_EDUCATION_YEAR",
"EDUCATION_YEAR",
"EDUCATION_NAME",
"INSTITUE",
],
}); });
educations = await []; educations = await [];
@ -848,7 +846,7 @@ export class ImportDataController extends Controller {
await this.educationRepository.save(educations); await this.educationRepository.save(educations);
}), }),
); );
} // }
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
// await this.educationRepository.save(educations); // await this.educationRepository.save(educations);
return new HttpSuccess(); return new HttpSuccess();
@ -958,18 +956,21 @@ export class ImportDataController extends Controller {
let rowCount = 0; let rowCount = 0;
let profileDatas: any = []; let profileDatas: any = [];
let null_: any = null; let null_: any = null;
const [_profiles, total] = await AppDataSource.getRepository(Profile) const [profiles, total] = await AppDataSource.getRepository(Profile)
.createQueryBuilder("profile")
.select(["profile.id"])
.getManyAndCount();
for (var i = 1; i <= total / BATCH_SIZE; i++) {
const profiles = await AppDataSource.getRepository(Profile)
.createQueryBuilder("profile") .createQueryBuilder("profile")
.select(["profile.citizenId", "profile.id"])
.orderBy("profile.citizenId", "ASC") .orderBy("profile.citizenId", "ASC")
.skip((i - 1) * BATCH_SIZE) // .skip(0)
.take(BATCH_SIZE) // .take(20)
.getMany(); .getManyAndCount();
profileDatas = await []; // for (var i = 1; i <= 2; i++) {
// const profiles = await AppDataSource.getRepository(Profile)
// .createQueryBuilder("profile")
// .orderBy("profile.citizenId", "ASC")
// .skip((i - 1) * 5)
// .take(5)
// .getMany();
// profileDatas = await [];
await Promise.all( await Promise.all(
profiles.map(async (_item) => { profiles.map(async (_item) => {
const existingProfile = await this.HR_PERSONAL_OFFICER_ADDRESSRepo.findOne({ const existingProfile = await this.HR_PERSONAL_OFFICER_ADDRESSRepo.findOne({
@ -1087,11 +1088,12 @@ export class ImportDataController extends Controller {
_item.currentZipCode = existingProfile.CONTACT_ZIPCODE; _item.currentZipCode = existingProfile.CONTACT_ZIPCODE;
_item.lastUpdateUserId = request.user.sub; _item.lastUpdateUserId = request.user.sub;
_item.lastUpdateFullName = request.user.name; _item.lastUpdateFullName = request.user.name;
profileDatas.push(_item); // profileDatas.push(_item);
await this.profileRepo.save(_item);
}), }),
); );
await this.profileRepo.save(profileDatas); // await this.profileRepo.save(profileDatas);
} // }
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
return new HttpSuccess(); return new HttpSuccess();
} }
@ -1104,18 +1106,21 @@ export class ImportDataController extends Controller {
let rowCount = 0; let rowCount = 0;
let profileDatas: any = []; let profileDatas: any = [];
let null_: any = null; let null_: any = null;
const [_profiles, total] = await AppDataSource.getRepository(ProfileEmployee) const [profiles, total] = await AppDataSource.getRepository(ProfileEmployee)
.createQueryBuilder("profile")
.select(["profile.id"])
.getManyAndCount();
for (var i = 1; i <= total / BATCH_SIZE; i++) {
const profiles = await AppDataSource.getRepository(ProfileEmployee)
.createQueryBuilder("profile") .createQueryBuilder("profile")
.select(["profile.citizenId", "profile.id"])
.orderBy("profile.citizenId", "ASC") .orderBy("profile.citizenId", "ASC")
.skip((i - 1) * BATCH_SIZE) // .skip(0)
.take(BATCH_SIZE) // .take(20)
.getMany(); .getManyAndCount();
profileDatas = await []; // for (var i = 1; i <= total / BATCH_SIZE; i++) {
// const profiles = await AppDataSource.getRepository(ProfileEmployee)
// .createQueryBuilder("profile")
// .orderBy("profile.citizenId", "ASC")
// .skip((i - 1) * BATCH_SIZE)
// .take(BATCH_SIZE)
// .getMany();
// profileDatas = await [];
await Promise.all( await Promise.all(
profiles.map(async (_item) => { profiles.map(async (_item) => {
const existingProfile = await this.HR_PERSONAL_EMP_ADDRESSRepo.findOne({ const existingProfile = await this.HR_PERSONAL_EMP_ADDRESSRepo.findOne({
@ -1233,11 +1238,12 @@ export class ImportDataController extends Controller {
_item.currentZipCode = existingProfile.CONTACT_ZIPCODE; _item.currentZipCode = existingProfile.CONTACT_ZIPCODE;
_item.lastUpdateUserId = request.user.sub; _item.lastUpdateUserId = request.user.sub;
_item.lastUpdateFullName = request.user.name; _item.lastUpdateFullName = request.user.name;
profileDatas.push(_item); // profileDatas.push(_item);
await this.profileEmpRepo.save(_item);
}), }),
); );
await this.profileEmpRepo.save(profileDatas); // await this.profileEmpRepo.save(profileDatas);
} // }
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
return new HttpSuccess(); return new HttpSuccess();
} }

View file

@ -81,7 +81,7 @@ export class PermissionController extends Controller {
...getDetail, ...getDetail,
roles: roleAttrData, roles: roleAttrData,
}; };
redisClient.set("role_" + request.user.sub, JSON.stringify(reply)); redisClient.setex("role_" + request.user.sub, 86400, JSON.stringify(reply));
} }
return new HttpSuccess(reply); return new HttpSuccess(reply);
} }
@ -129,7 +129,7 @@ export class PermissionController extends Controller {
} }
const roleAttrData = await this.authRoleAttrRepo.find({ const roleAttrData = await this.authRoleAttrRepo.find({
select: ["authSysId"], select: ["authSysId"],
where: { authRoleId: authRole.id }, where: { authRoleId: authRole.id, attrIsList: true },
}); });
const getList = await this.authSysRepo.find({ const getList = await this.authSysRepo.find({
@ -150,8 +150,8 @@ export class PermissionController extends Controller {
}; };
}) })
.sort((a, b) => a.order - b.order); .sort((a, b) => a.order - b.order);
console.log(JSON.stringify(reply)); // console.log(JSON.stringify(reply));
redisClient.set("menu_" + request.user.sub, 30, JSON.stringify(reply)); redisClient.setex("menu_" + request.user.sub, 86400, JSON.stringify(reply));
} }
return new HttpSuccess(reply); return new HttpSuccess(reply);