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 type_: any = null;
let level_: any = null; let level_: any = null;
const profile = new Profile(); const profile = new Profile();
if (item["FLAG_RETIRE_STATUS"] != "" && item["FLAG_RETIRE_STATUS"] != null) { // if (item["FLAG_RETIRE_STATUSxxxx"] != "" && item["FLAG_RETIRE_STATUSxxxx"] != null) {
continue; // continue;
} // }
if (item["FLAG_PERSON_TYPE"] != "1") { // if (item["FLAG_PERSON_TYPExxxx"] != "1") {
continue; // continue;
} // }
const existingProfile = await this.profileRepo.findOne({ const existingProfile = await this.profileRepo.findOne({
where: { citizenId: item["ID"] }, where: { citizenId: item["ID"] },
}); });
@ -122,29 +122,29 @@ export class ImportDataController extends Controller {
continue; continue;
} }
if (item["MP_CEE_TYPE"]) { if (item["TYPE"]) {
type_ = await this.posTypeRepo.findOne({ 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) { if (type_ == null) {
level_ = await this.posLevelRepo.findOne({ level_ = await this.posLevelRepo.findOne({
where: { where: {
posLevelName: item["MP_CEE_POSITION"], posLevelName: item["LEVEL"],
}, },
}); });
} else { } else {
level_ = await this.posLevelRepo.findOne({ level_ = await this.posLevelRepo.findOne({
where: { where: {
posLevelName: item["MP_CEE_POSITION"], posLevelName: item["LEVEL"],
posTypeId: type_.id, posTypeId: type_.id,
}, },
}); });
} }
} }
let dateRetire = Extension.ConvertToDateTime(item["MP_FORCE_DATE"]); let dateRetire = Extension.ConvertToDateTime(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"];
@ -157,20 +157,20 @@ export class ImportDataController extends Controller {
? null_ ? null_
: Extension.ConvertToDateTime(item["BEGIN_ENTRY_DATE"]); : Extension.ConvertToDateTime(item["BEGIN_ENTRY_DATE"]);
profile.dateStart = 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.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"];
profile.posTypeId = 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 = profile.posLevelId =
level_ != null && level_.posLevelName == item["MP_CEE_POSITION"] && level_ level_ != null && level_.posLevelName == item["LEVEL"] && level_ ? level_.id : null;
? level_.id
: null;
profile.relationship = profile.relationship =
item["MARRIAGE_STATE"] == "" ? "" : Extension.CheckRelationship(item["MARRIAGE_STATE"]); item["สถานภาพ"] == "" ? "" : Extension.CheckRelationship(item["สถานภาพ"]);
profile.isLeave = // profile.isLeave =
item["FLAG_RETIRE_STATUS"] == "" || item["FLAG_RETIRE_STATUS"] == null ? false : true; // item["FLAG_RETIRE_STATUSxxxx"] == "" || item["FLAG_RETIRE_STATUSxxxx"] == null ? false : true;
profile.createdUserId = request.user.sub; profile.createdUserId = request.user.sub;
profile.createdFullName = request.user.name; profile.createdFullName = request.user.name;
profile.lastUpdateUserId = request.user.sub; profile.lastUpdateUserId = request.user.sub;
@ -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(profileEmp); await this.profileEmpRepo.save(profiles);
// 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();
} }
@ -338,7 +338,7 @@ export class ImportDataController extends Controller {
profileSalary.lastUpdateFullName = request.user.name; profileSalary.lastUpdateFullName = request.user.name;
profileSalarys.push(profileSalary); profileSalarys.push(profileSalary);
// await this.salaryRepository.save(profileSalary); // await this.salaryRepository.save(profileSalary);
if (profiles.length === BATCH_SIZE) { if (profileSalarys.length === BATCH_SIZE) {
await this.salaryRepository.save(profileSalarys); await this.salaryRepository.save(profileSalarys);
profileSalarys = await []; profileSalarys = await [];
} }