Merge branch 'develop' of github.com:Frappet/bma-ehr-organization into develop

This commit is contained in:
Warunee Tamkoo 2024-08-01 15:54:16 +07:00
commit d51e6cf0f0

View file

@ -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;
@ -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 [];
}