edit name null_

This commit is contained in:
kittapath 2025-03-10 09:52:50 +07:00
parent fb96c44753
commit ed111475f8
6 changed files with 171 additions and 135 deletions

View file

@ -110,7 +110,7 @@ export class ImportDataController extends Controller {
// const filePath = path.resolve(__dirname, "OFFICER.csv"); // Corrected file path
// const readStream = fs.createReadStream(filePath).pipe(csvParser());
// let profiles: any = [];
let null_: any = null;
let _null: any = null;
let profile: any;
// await Promise.all(
// OFFICER.map(async (item) => {
@ -178,12 +178,12 @@ export class ImportDataController extends Controller {
: 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_ : new Date(item.BORN);
profile.dateAppoint = item.BEGIN_ENTRY_DATE == "" ? null_ : new Date(item.BEGIN_ENTRY_DATE);
profile.dateStart = 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.gender = item.SEX == "1" ? "ชาย" : item.SEX == "2" ? "หญิง" : _null;
profile.birthDate = item.BORN == "" ? _null : new Date(item.BORN);
profile.dateAppoint = item.BEGIN_ENTRY_DATE == "" ? _null : new Date(item.BEGIN_ENTRY_DATE);
profile.dateStart = 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;
profile.posTypeId =
type_ != null && type_.posTypeName == item.MP_CATEGORY && type_ ? type_.id : null;
@ -202,11 +202,11 @@ export class ImportDataController extends Controller {
// },
// },
// });
// profile.posLevelId = level?.id ?? null_;
// profile.posLevelId = level?.id ?? _null;
// const type = await this.posTypeRepo.findOne({
// where: { posTypeName: item.MP_Type },
// });
// profile.posTypeId = type?.id ?? null_;
// profile.posTypeId = type?.id ?? _null;
profile.amount = item.SALARY == "" ? 0 : Number(item.SALARY);
// profile.isLeave =
// item.FLAG_RETIRE_STATUSxxxx == "" || item.FLAG_RETIRE_STATUSxxxx == null ? false : true;
@ -247,7 +247,7 @@ export class ImportDataController extends Controller {
const filePath = path.resolve(__dirname, "EMP.csv"); // Corrected file path
const readStream = fs.createReadStream(filePath).pipe(csvParser());
let profiles: any = [];
let null_: any = null;
let _null: any = null;
let profileEmp: any;
for await (const item of readStream) {
@ -291,13 +291,13 @@ export class ImportDataController extends Controller {
: item["RANK_NAME"];
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_ : new Date(item["BORN"]);
profileEmp.gender = item["SEX"] == "1" ? "ชาย" : item["SEX"] == "2" ? "หญิง" : _null;
profileEmp.birthDate = item["BORN"] == "" ? _null : new Date(item["BORN"]);
profileEmp.dateAppoint =
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);
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"];
profileEmp.salaryLevel = item["SALARY_LEVEL_CODE"] == "" ? null : item["SALARY_LEVEL_CODE"];
profileEmp.relationship =
@ -332,7 +332,7 @@ export class ImportDataController extends Controller {
@Post("uploadProfileSalary-Officer")
async UploadFileSQLSalary(@Request() request: { user: Record<string, any> }) {
let rowCount = 0;
let null_: any = null;
let _null: any = null;
let sqlStatements: string[] = [];
const [profiles, total] = await AppDataSource.getRepository(Profile)
@ -392,14 +392,14 @@ export class ImportDataController extends Controller {
profileSalary.commandYear = item.cur_year > 2500 ? item.cur_year - 543 : item.cur_year;
profileSalary.commandDateSign =
item.mp_command_date == null
? null_
? _null
: new Date(item.mp_command_date.setDate(item.mp_command_date.getDate() + 1))
.toISOString()
.replace("T", " ")
.substring(0, 19);
profileSalary.commandDateAffect =
item.mp_pos_date == null
? null_
? _null
: new Date(item.mp_pos_date.setDate(item.mp_pos_date.getDate() + 1))
.toISOString()
.replace("T", " ")
@ -755,15 +755,15 @@ export class ImportDataController extends Controller {
const sal_pos_amount_1: any =
item.sal_pos_amount_1 == null || item.sal_pos_amount_1 == ""
? null_
? _null
: Number(item.sal_pos_amount_1);
const sal_pos_amount_2: any =
item.sal_pos_amount_2 == null || item.sal_pos_amount_2 == ""
? null_
? _null
: Number(item.sal_pos_amount_2);
profileSalary.positionSalaryAmount = sal_pos_amount_1 ?? sal_pos_amount_2;
const special_amt: any =
item.special_amt == null || item.special_amt == "" ? null_ : Number(item.special_amt);
item.special_amt == null || item.special_amt == "" ? _null : Number(item.special_amt);
profileSalary.amountSpecial = special_amt;
profileSalary.createdUserId = request.user.sub;
@ -842,7 +842,7 @@ export class ImportDataController extends Controller {
@Post("uploadProfileSalary-Employee")
async UploadFileSQLSalaryEmp(@Request() request: { user: Record<string, any> }) {
let rowCount = 0;
let null_: any = null;
let _null: any = null;
const [profiles, total] = await AppDataSource.getRepository(ProfileEmployee)
.createQueryBuilder("profile")
@ -891,15 +891,15 @@ export class ImportDataController extends Controller {
const sal_pos_amount_1: any =
item.sal_pos_amount_1 == null || item.sal_pos_amount_1 == ""
? null_
? _null
: Number(item.sal_pos_amount_1);
const sal_pos_amount_2: any =
item.sal_pos_amount_2 == null || item.sal_pos_amount_2 == ""
? null_
? _null
: Number(item.sal_pos_amount_2);
profileSalary.positionSalaryAmount = sal_pos_amount_1 ?? sal_pos_amount_2;
const special_amt: any =
item.special_amt == null || item.special_amt == "" ? null_ : Number(item.special_amt);
item.special_amt == null || item.special_amt == "" ? _null : Number(item.special_amt);
profileSalary.amountSpecial = special_amt;
profileSalary.commandId;
@ -1222,7 +1222,7 @@ export class ImportDataController extends Controller {
async UploadFileSQLEducation(@Request() request: { user: Record<string, any> }) {
let rowCount = 0;
let educations: any = [];
let null_: any = null;
let _null: any = null;
const [profiles, total] = await AppDataSource.getRepository(Profile)
.createQueryBuilder("profile")
.select(["profile.citizenId", "profile.id"])
@ -1274,22 +1274,22 @@ export class ImportDataController extends Controller {
let startDate = item.START_EDUCATION_YEAR
? Extension.ConvertToDateTimeV2(item.START_EDUCATION_YEAR)
: null_;
// startDate = startDate ? new Date(startDate, 0, 1) : null_;
: _null;
// startDate = startDate ? new Date(startDate, 0, 1) : _null;
let endDate = item.EDUCATION_YEAR
? Extension.ConvertToDateTimeV2(item.EDUCATION_YEAR)
: null_;
// endDate = endDate ? new Date(endDate, 0, 1) : null_;
: _null;
// endDate = endDate ? new Date(endDate, 0, 1) : _null;
education.level = educationLevel == null ? 1 : educationLevel.level + 1;
education.profileId = _item.id;
education.degree = educationCode ? educationCode.EDUCATION_NAME : null_;
education.field = hrMajorCode ? hrMajorCode.MAJOR_NAME : null_;
education.educationLevel = hrFundCourseCode ? hrFundCourseCode.FUND_COURSE_NAME : null_;
education.educationLevelId = hrFundCourseCode ? hrFundCourseCode.refId : null_;
education.degree = educationCode ? educationCode.EDUCATION_NAME : _null;
education.field = hrMajorCode ? hrMajorCode.MAJOR_NAME : _null;
education.educationLevel = hrFundCourseCode ? hrFundCourseCode.FUND_COURSE_NAME : _null;
education.educationLevelId = hrFundCourseCode ? hrFundCourseCode.refId : _null;
education.institute = item.INSTITUE;
education.level = item.EDUCATION_SEQ ? Number(item.EDUCATION_SEQ) : null_;
education.level = item.EDUCATION_SEQ ? Number(item.EDUCATION_SEQ) : _null;
education.startDate = startDate;
education.endDate = endDate;
education.createdUserId = request.user.sub;
@ -1318,7 +1318,7 @@ export class ImportDataController extends Controller {
async UploadFileSQLEducationEmp(@Request() request: { user: Record<string, any> }) {
let rowCount = 0;
let educations: any = [];
let null_: any = null;
let _null: any = null;
const [profiles, total] = await AppDataSource.getRepository(ProfileEmployee)
.createQueryBuilder("profile")
.select(["profile.citizenId", "profile.id"])
@ -1366,19 +1366,19 @@ export class ImportDataController extends Controller {
let startDate = item.START_EDUCATION_YEAR
? Extension.ConvertToDateTimeV2(item.START_EDUCATION_YEAR)
: null_;
// startDate = startDate ? new Date(startDate, 0, 1) : null_;
: _null;
// startDate = startDate ? new Date(startDate, 0, 1) : _null;
let endDate = item.EDUCATION_YEAR
? Extension.ConvertToDateTimeV2(item.EDUCATION_YEAR)
: null_;
// endDate = endDate ? new Date(endDate, 0, 1) : null_;
: _null;
// endDate = endDate ? new Date(endDate, 0, 1) : _null;
education.level = educationLevel == null ? 1 : educationLevel.level + 1;
education.profileEmployeeId = _item.id;
education.degree = educationCode ? educationCode.EDUCATION_NAME : "";
education.institute = item.INSTITUE;
education.level = item.EDUCATION_SEQ ? null_ : Number(item.EDUCATION_SEQ);
education.level = item.EDUCATION_SEQ ? _null : Number(item.EDUCATION_SEQ);
education.startDate = startDate;
education.endDate = endDate;
education.createdUserId = request.user.sub;
@ -1509,7 +1509,7 @@ export class ImportDataController extends Controller {
@Post("uploadProfileAddress-Officer")
async UploadFileSQLAddress(@Request() request: { user: Record<string, any> }) {
let rowCount = 0;
let null_: any = null;
let _null: any = null;
const [profiles, total] = await AppDataSource.getRepository(Profile)
.createQueryBuilder("profile")
.select(["profile.citizenId", "profile.id"])
@ -1559,7 +1559,7 @@ export class ImportDataController extends Controller {
});
await this.provinceIdRepo.save(provinceId);
}
_item.registrationProvinceId = provinceId ? provinceId.id : null_;
_item.registrationProvinceId = provinceId ? provinceId.id : _null;
if (AMPHUR_CODE) {
let districtRegis_ = await this.amphurRepo.findOne({
where: {
@ -1582,7 +1582,7 @@ export class ImportDataController extends Controller {
});
await this.provinceIdRepo.save(provinceId);
}
_item.registrationDistrictId = districtId ? districtId.id : null_;
_item.registrationDistrictId = districtId ? districtId.id : _null;
if (DISTRICT_CODE) {
let subDistrictRegis_ = await this.subDistrictRepo.findOne({
where: {
@ -1607,7 +1607,7 @@ export class ImportDataController extends Controller {
});
await this.provinceIdRepo.save(provinceId);
}
_item.registrationSubDistrictId = subDistrictId ? subDistrictId.id : null_;
_item.registrationSubDistrictId = subDistrictId ? subDistrictId.id : _null;
}
}
}
@ -1633,7 +1633,7 @@ export class ImportDataController extends Controller {
});
await this.provinceIdRepo.save(provinceId);
}
_item.currentProvinceId = provinceId ? provinceId.id : null_;
_item.currentProvinceId = provinceId ? provinceId.id : _null;
if (CONTACT_AMPHUR_CODE) {
let districtCurr_ = await this.amphurRepo.findOne({
where: {
@ -1656,7 +1656,7 @@ export class ImportDataController extends Controller {
});
await this.provinceIdRepo.save(provinceId);
}
_item.currentDistrictId = districtId ? districtId.id : null_;
_item.currentDistrictId = districtId ? districtId.id : _null;
if (CONTACT_DISTRICT_CODE) {
let subDistrictCurr_ = await this.subDistrictRepo.findOne({
where: {
@ -1681,7 +1681,7 @@ export class ImportDataController extends Controller {
});
await this.provinceIdRepo.save(provinceId);
}
_item.currentSubDistrictId = subDistrictId ? subDistrictId.id : null_;
_item.currentSubDistrictId = subDistrictId ? subDistrictId.id : _null;
}
}
}
@ -1711,7 +1711,7 @@ export class ImportDataController extends Controller {
async UploadFileSQLAddressEmp(@Request() request: { user: Record<string, any> }) {
let rowCount = 0;
let profileDatas: any = [];
let null_: any = null;
let _null: any = null;
const [profiles, total] = await AppDataSource.getRepository(ProfileEmployee)
.createQueryBuilder("profile")
.select(["profile.citizenId", "profile.id"])
@ -1755,7 +1755,7 @@ export class ImportDataController extends Controller {
name: provinceRegis_.PROVINCE_NAME,
},
});
_item.registrationProvinceId = provinceId ? provinceId.id : null_;
_item.registrationProvinceId = provinceId ? provinceId.id : _null;
}
}
if (existingProfile.AMPHUR_CODE && provinceRegis_) {
@ -1771,7 +1771,7 @@ export class ImportDataController extends Controller {
name: districtRegis_.AMPHUR_NAME,
},
});
_item.registrationDistrictId = districtId ? districtId.id : null_;
_item.registrationDistrictId = districtId ? districtId.id : _null;
}
}
if (existingProfile.DISTRICT_CODE && districtRegis_ && provinceRegis_) {
@ -1788,7 +1788,7 @@ export class ImportDataController extends Controller {
name: subDistrictRegis_.DISTRICT_NAME,
},
});
_item.registrationSubDistrictId = subDistrictId ? subDistrictId.id : null_;
_item.registrationSubDistrictId = subDistrictId ? subDistrictId.id : _null;
}
}
//current address
@ -1802,7 +1802,7 @@ export class ImportDataController extends Controller {
name: provinceCurr_.PROVINCE_NAME,
},
});
_item.currentProvinceId = provinceId ? provinceId.id : null_;
_item.currentProvinceId = provinceId ? provinceId.id : _null;
}
}
if (existingProfile.CONTACT_AMPHUR_CODE && provinceCurr_) {
@ -1818,7 +1818,7 @@ export class ImportDataController extends Controller {
name: districtCurr_.AMPHUR_NAME,
},
});
_item.currentDistrictId = districtId ? districtId.id : null_;
_item.currentDistrictId = districtId ? districtId.id : _null;
}
}
if (existingProfile.CONTACT_DISTRICT_CODE && districtCurr_ && provinceCurr_) {
@ -1835,7 +1835,7 @@ export class ImportDataController extends Controller {
name: subDistrictCurr_.DISTRICT_NAME,
},
});
_item.currentSubDistrictId = subDistrictId ? subDistrictId.id : null_;
_item.currentSubDistrictId = subDistrictId ? subDistrictId.id : _null;
}
}
_item.registrationAddress = existingProfile.H_NUMBER;
@ -2251,7 +2251,7 @@ export class ImportDataController extends Controller {
// .take(20)
.getManyAndCount();
let rowCount = 0;
let null_: any = null;
let _null: any = null;
let type_: any = null;
let level_: any = null;
const orgRevision = await this.orgRevisionRepo.findOne({
@ -2304,17 +2304,17 @@ export class ImportDataController extends Controller {
},
});
let posMaster = new PosMaster();
posMaster.orgRootId = orgRoot?.id ?? null_;
posMaster.orgChild1Id = orgChild1?.id ?? null_;
posMaster.orgChild2Id = orgChild2?.id ?? null_;
posMaster.orgChild3Id = orgChild3?.id ?? null_;
posMaster.orgRootId = orgRoot?.id ?? _null;
posMaster.orgChild1Id = orgChild1?.id ?? _null;
posMaster.orgChild2Id = orgChild2?.id ?? _null;
posMaster.orgChild3Id = orgChild3?.id ?? _null;
posMaster.statusReport = "PENDING";
posMaster.isCondition = false;
posMaster.isStaff = false;
posMaster.isDirector = false;
posMaster.isSit = false;
posMaster.current_holderId = existingProfile.id;
posMaster.posMasterNo = item.SALARY == "" ? null_ : Number(item.POS_NUM_CODE);
posMaster.posMasterNo = item.SALARY == "" ? _null : Number(item.POS_NUM_CODE);
posMaster.orgRevisionId = orgRevision.id;
posMaster.posMasterCreatedAt = new Date();
posMaster.createdUserId = request.user.sub;
@ -2372,7 +2372,7 @@ export class ImportDataController extends Controller {
let posExecutive = new PosExecutive();
posExecutive.posExecutivePriority =
posExecutiveOrder == null ? null_ : posExecutiveOrder.posExecutivePriority + 1;
posExecutiveOrder == null ? _null : posExecutiveOrder.posExecutivePriority + 1;
posExecutive.posExecutiveName = item.ADMIN_NAME;
posExecutive.createdUserId = request.user.sub;
posExecutive.createdFullName = request.user.name;
@ -2382,8 +2382,8 @@ export class ImportDataController extends Controller {
posExecutive.lastUpdatedAt = new Date();
await this.posExecutiveRepo.save(posExecutive);
}
position.posExecutiveId = posExecutive == null ? null_ : posExecutive.id;
position.positionName = item.WORK_LINE_NAME == "" ? null_ : item.WORK_LINE_NAME;
position.posExecutiveId = posExecutive == null ? _null : posExecutive.id;
position.positionName = item.WORK_LINE_NAME == "" ? _null : item.WORK_LINE_NAME;
position.posTypeId =
type_ != null && type_.posTypeName == item.MP_CATEGORY && type_ ? type_.id : null;
position.posLevelId =
@ -2399,7 +2399,7 @@ export class ImportDataController extends Controller {
@Post("uploadProfileSalary-OfficerEntry")
async UploadFileSQLSalaryEntry(@Request() request: { user: Record<string, any> }) {
let rowCount = 0;
let null_: any = null;
let _null: any = null;
let sqlStatements: string[] = [];
const [profiles, total] = await AppDataSource.getRepository(Profile)
@ -2444,7 +2444,7 @@ export class ImportDataController extends Controller {
profileSalary.commandDateAffect =
item.Date == null
? null_
? _null
: new Date(item.Date.setDate(item.Date.getDate() + 1))
.toISOString()
.replace("T", " ")
@ -2464,7 +2464,7 @@ export class ImportDataController extends Controller {
profileSalary.positionLevel = item.PositionLevelName;
profileSalary.positionCee = this.canConvertToInt(item.PositionLevelName)
? item.PositionLevelName
: null_;
: _null;
//xxxxxxxxxxxxxxxxx
profileSalary.positionType = item.PositionTypeName;
profileSalary.isEntry = true;