From 692f74c48cd288129c1aac0f5b61675477f1b40b Mon Sep 17 00:00:00 2001 From: Kittapath Date: Fri, 26 Jul 2024 15:52:32 +0700 Subject: [PATCH] no message --- src/controllers/ImportDataController.ts | 454 +++++++++++--------- src/entities/HR_EDUCATION.ts | 48 +++ src/entities/HR_EDUCATION_EMP.ts | 48 +++ src/entities/HR_PERSONAL_EMP_ADDRESS.ts | 83 ++++ src/entities/HR_PERSONAL_EMP_FAMILY.ts | 90 ++++ src/entities/HR_PERSONAL_OFFICER_ADDRESS.ts | 83 ++++ 6 files changed, 614 insertions(+), 192 deletions(-) create mode 100644 src/entities/HR_EDUCATION.ts create mode 100644 src/entities/HR_EDUCATION_EMP.ts create mode 100644 src/entities/HR_PERSONAL_EMP_ADDRESS.ts create mode 100644 src/entities/HR_PERSONAL_EMP_FAMILY.ts create mode 100644 src/entities/HR_PERSONAL_OFFICER_ADDRESS.ts diff --git a/src/controllers/ImportDataController.ts b/src/controllers/ImportDataController.ts index 50af44f6..e568d191 100644 --- a/src/controllers/ImportDataController.ts +++ b/src/controllers/ImportDataController.ts @@ -56,6 +56,11 @@ import { SubDistrictImport } from "../entities/SubDistrictImport"; import { Province } from "../entities/Province"; import { District } from "../entities/District"; import { SubDistrict } from "../entities/SubDistrict"; +import { HR_EDUCATION } from "../entities/HR_EDUCATION"; +import { HR_PERSONAL_OFFICER_ADDRESS } from "../entities/HR_PERSONAL_OFFICER_ADDRESS"; +import { HR_EDUCATION_EMP } from "../entities/HR_EDUCATION_EMP"; +import { HR_PERSONAL_EMP_ADDRESS } from "../entities/HR_PERSONAL_EMP_ADDRESS"; +import { HR_PERSONAL_EMP_FAMILY } from "../entities/HR_PERSONAL_EMP_FAMILY"; @Route("api/v1/org/upload") @Tags("UPLOAD") @@ -72,6 +77,13 @@ export class ImportDataController extends Controller { private posTypeRepo = AppDataSource.getRepository(PosType); private HR_POSITION_OFFICERRepo = AppDataSource.getRepository(HR_POSITION_OFFICER); private HR_PERSONAL_OFFICER_FAMILYRepo = AppDataSource.getRepository(HR_PERSONAL_OFFICER_FAMILY); + private HR_EDUCATIONRepo = AppDataSource.getRepository(HR_EDUCATION); + private HR_PERSONAL_OFFICER_ADDRESSRepo = AppDataSource.getRepository( + HR_PERSONAL_OFFICER_ADDRESS, + ); + private HR_EDUCATION_EMPRepo = AppDataSource.getRepository(HR_EDUCATION_EMP); + private HR_PERSONAL_EMP_ADDRESSRepo = AppDataSource.getRepository(HR_PERSONAL_EMP_ADDRESS); + private HR_PERSONAL_EMP_FAMILYRepo = AppDataSource.getRepository(HR_PERSONAL_EMP_FAMILY); private educationMisRepo = AppDataSource.getRepository(EducationMis); private provincsRepo = AppDataSource.getRepository(ProvinceImport); @@ -696,53 +708,74 @@ export class ImportDataController extends Controller { * @summary ประวัติการศึกษา ข้าราชการ */ @Post("uploadProfileEducation-Officer") - @UseInterceptors(FileInterceptor("file")) - async UploadFileSQLEducation( - @UploadedFile() file: Express.Multer.File, - @Request() request: { user: Record }, - ) { - const workbook = xlsx.read(file.buffer, { type: "buffer" }); - const sheetName = workbook.SheetNames[0]; - const sheet = workbook.Sheets[sheetName]; - const getEducations = xlsx.utils.sheet_to_json(sheet); + async UploadFileSQLEducation(@Request() request: { user: Record }) { + let rowCount = 0; let educations: any = []; let null_: any = null; - await Promise.all( - getEducations.map(async (item: any) => { - const education = new ProfileEducation(); - const existingProfile = await this.profileRepo.findOne({ - where: { citizenId: item.ID }, - }); - if (!existingProfile) { - return; - } - const educationCode = await this.educationMisRepo.findOne({ - where: { EDUCATION_CODE: item.EDUCATION_CODE }, - }); + 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") + .select(["profile.citizenId", "profile.id"]) + .orderBy("profile.citizenId", "ASC") + .skip((i - 1) * BATCH_SIZE) + .take(BATCH_SIZE) + .getMany(); - let startDate = item.START_EDUCATION_YEAR - ? Extension.ConvertToDateTime(item.START_EDUCATION_YEAR) - : null_; - startDate = startDate ? new Date(startDate, 0, 1) : null_; + await Promise.all( + profiles.map(async (_item) => { + const existingProfile = await this.HR_EDUCATIONRepo.find({ + where: { CIT: _item.citizenId }, + select: [ + "CIT", + "EDUCATION_CODE", + "START_EDUCATION_YEAR", + "EDUCATION_YEAR", + "EDUCATION_NAME", + "INSTITUE", + ], + }); - let endDate = item.EDUCATION_YEAR - ? Extension.ConvertToDateTime(item.EDUCATION_YEAR) - : null_; - endDate = endDate ? new Date(endDate, 0, 1) : null_; + educations = await []; + await Promise.all( + existingProfile.map(async (item) => { + rowCount++; + const education = new ProfileEducation(); + const educationCode = await this.educationMisRepo.findOne({ + where: { EDUCATION_CODE: item.EDUCATION_CODE }, + }); - education.profileId = existingProfile.id; - education.degree = educationCode ? educationCode.EDUCATION_NAME : ""; - education.institute = item.INSTITUE; - education.startDate = startDate; - education.endDate = endDate; - education.createdUserId = request.user.sub; - education.createdFullName = request.user.name; - education.lastUpdateUserId = request.user.sub; - education.lastUpdateFullName = request.user.name; - educations.push(education); - }), - ); - await this.educationRepository.save(educations); + let startDate = item.START_EDUCATION_YEAR + ? Extension.ConvertToDateTime(item.START_EDUCATION_YEAR) + : null_; + startDate = startDate ? new Date(startDate, 0, 1) : null_; + + let endDate = item.EDUCATION_YEAR + ? Extension.ConvertToDateTime(item.EDUCATION_YEAR) + : null_; + endDate = endDate ? new Date(endDate, 0, 1) : null_; + + education.profileId = _item.id; + education.degree = educationCode ? educationCode.EDUCATION_NAME : ""; + education.institute = item.INSTITUE; + education.startDate = startDate; + education.endDate = endDate; + education.createdUserId = request.user.sub; + education.createdFullName = request.user.name; + education.lastUpdateUserId = request.user.sub; + education.lastUpdateFullName = request.user.name; + educations.push(education); + }), + ); + await this.educationRepository.save(educations); + }), + ); + } + console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); + // await this.educationRepository.save(educations); return new HttpSuccess(); } @@ -750,53 +783,74 @@ export class ImportDataController extends Controller { * @summary ประวัติการศึกษา ลูกจ้างประจำ */ @Post("uploadProfileEducation-Employee") - @UseInterceptors(FileInterceptor("file")) - async UploadFileSQLEducationEmp( - @UploadedFile() file: Express.Multer.File, - @Request() request: { user: Record }, - ) { - const workbook = xlsx.read(file.buffer, { type: "buffer" }); - const sheetName = workbook.SheetNames[0]; - const sheet = workbook.Sheets[sheetName]; - const getEducations = xlsx.utils.sheet_to_json(sheet); + async UploadFileSQLEducationEmp(@Request() request: { user: Record }) { + let rowCount = 0; let educations: any = []; let null_: any = null; - await Promise.all( - getEducations.map(async (item: any) => { - const education = new ProfileEducation(); - const existingProfile = await this.profileEmpRepo.findOne({ - where: { citizenId: item.ID }, - }); - if (!existingProfile) { - return; - } - const educationCode = await this.educationMisRepo.findOne({ - where: { EDUCATION_CODE: item.EDUCATION_CODE }, - }); + 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") + .select(["profile.citizenId", "profile.id"]) + .orderBy("profile.citizenId", "ASC") + .skip((i - 1) * BATCH_SIZE) + .take(BATCH_SIZE) + .getMany(); - let startDate = item.START_EDUCATION_YEAR - ? Extension.ConvertToDateTime(item.START_EDUCATION_YEAR) - : null_; - startDate = startDate ? new Date(startDate, 0, 1) : null_; + await Promise.all( + profiles.map(async (_item) => { + const existingProfile = await this.HR_EDUCATION_EMPRepo.find({ + where: { CIT: _item.citizenId }, + select: [ + "CIT", + "EDUCATION_CODE", + "START_EDUCATION_YEAR", + "EDUCATION_YEAR", + "EDUCATION_NAME", + "INSTITUE", + ], + }); - let endDate = item.EDUCATION_YEAR - ? Extension.ConvertToDateTime(item.EDUCATION_YEAR) - : null_; - endDate = endDate ? new Date(endDate, 0, 1) : null_; + educations = await []; + await Promise.all( + existingProfile.map(async (item) => { + rowCount++; + const education = new ProfileEducation(); + const educationCode = await this.educationMisRepo.findOne({ + where: { EDUCATION_CODE: item.EDUCATION_CODE }, + }); - education.profileEmployeeId = existingProfile.id; - education.degree = educationCode ? educationCode.EDUCATION_NAME : ""; - education.institute = item.INSTITUE; - education.startDate = startDate; - education.endDate = endDate; - education.createdUserId = request.user.sub; - education.createdFullName = request.user.name; - education.lastUpdateUserId = request.user.sub; - education.lastUpdateFullName = request.user.name; - educations.push(education); - }), - ); - await this.educationRepository.save(educations); + let startDate = item.START_EDUCATION_YEAR + ? Extension.ConvertToDateTime(item.START_EDUCATION_YEAR) + : null_; + startDate = startDate ? new Date(startDate, 0, 1) : null_; + + let endDate = item.EDUCATION_YEAR + ? Extension.ConvertToDateTime(item.EDUCATION_YEAR) + : null_; + endDate = endDate ? new Date(endDate, 0, 1) : null_; + + education.profileEmployeeId = _item.id; + education.degree = educationCode ? educationCode.EDUCATION_NAME : ""; + education.institute = item.INSTITUE; + education.startDate = startDate; + education.endDate = endDate; + education.createdUserId = request.user.sub; + education.createdFullName = request.user.name; + education.lastUpdateUserId = request.user.sub; + education.lastUpdateFullName = request.user.name; + educations.push(education); + }), + ); + await this.educationRepository.save(educations); + }), + ); + } + console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); + // await this.educationRepository.save(educations); return new HttpSuccess(); } @@ -900,34 +954,43 @@ export class ImportDataController extends Controller { * @summary ที่อยู่ตามทะเบียนบ้าน-ปัจจุบัน ข้าราชการ */ @Post("uploadProfileAddress-Officer") - @UseInterceptors(FileInterceptor("file")) - async UploadFileSQLAddress( - @UploadedFile() file: Express.Multer.File, - @Request() request: { user: Record }, - ) { - const workbook = xlsx.read(file.buffer, { type: "buffer" }); - const sheetName = workbook.SheetNames[0]; - const sheet = workbook.Sheets[sheetName]; - const getAddress = xlsx.utils.sheet_to_json(sheet); + async UploadFileSQLAddress(@Request() request: { user: Record }) { + let rowCount = 0; + let profileDatas: any = []; let null_: any = null; - await Promise.all( - getAddress.map(async (item: any) => { - let provinceRegis_: any = null; - let districtRegis_: any = null; - let subDistrictRegis_: any = null; - let provinceCurr_: any = null; - let districtCurr_: any = null; - let subDistrictCurr_: any = null; - const existingProfile = await this.profileRepo.findOne({ - where: { citizenId: item.ID }, - }); - if (!existingProfile) { - return; - } else { + 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") + .orderBy("profile.citizenId", "ASC") + .skip((i - 1) * BATCH_SIZE) + .take(BATCH_SIZE) + .getMany(); + profileDatas = await []; + await Promise.all( + profiles.map(async (_item) => { + const existingProfile = await this.HR_PERSONAL_OFFICER_ADDRESSRepo.findOne({ + where: { CIT: _item.citizenId }, + }); + + if (!existingProfile) { + return; + } + + rowCount++; + let provinceRegis_: any = null; + let districtRegis_: any = null; + let subDistrictRegis_: any = null; + let provinceCurr_: any = null; + let districtCurr_: any = null; + let subDistrictCurr_: any = null; //registration address - if (item["PROVINCE_CODE"]) { + if (existingProfile.PROVINCE_CODE) { provinceRegis_ = await this.provincsRepo.findOne({ - where: { PROVINCE_CODE: item["PROVINCE_CODE"] }, + where: { PROVINCE_CODE: existingProfile.PROVINCE_CODE }, }); if (provinceRegis_) { let provinceId = await this.provinceIdRepo.findOne({ @@ -935,13 +998,13 @@ export class ImportDataController extends Controller { name: provinceRegis_.PROVINCE_NAME, }, }); - existingProfile.registrationProvinceId = provinceId ? provinceId.id : null_; + _item.registrationProvinceId = provinceId ? provinceId.id : null_; } } - if (item["AMPHUR_CODE"]) { + if (existingProfile.AMPHUR_CODE) { districtRegis_ = await this.amphurRepo.findOne({ where: { - AMPHUR_CODE: item["AMPHUR_CODE"], + AMPHUR_CODE: existingProfile.AMPHUR_CODE, PROVINCE_CODE: provinceRegis_.PROVINCE_CODE, }, }); @@ -951,13 +1014,13 @@ export class ImportDataController extends Controller { name: districtRegis_.AMPHUR_NAME, }, }); - existingProfile.registrationDistrictId = districtId ? districtId.id : null_; + _item.registrationDistrictId = districtId ? districtId.id : null_; } } - if (item["DISTRICT_CODE"]) { + if (existingProfile.DISTRICT_CODE) { subDistrictRegis_ = await this.subDistrictRepo.findOne({ where: { - DISTRICT_CODE: item["DISTRICT_CODE"], + DISTRICT_CODE: existingProfile.DISTRICT_CODE, AMPHUR_CODE: districtRegis_.AMPHUR_CODE, PROVINCE_CODE: provinceRegis_.PROVINCE_CODE, }, @@ -968,13 +1031,13 @@ export class ImportDataController extends Controller { name: subDistrictRegis_.DISTRICT_NAME, }, }); - existingProfile.registrationSubDistrictId = subDistrictId ? subDistrictId.id : null_; + _item.registrationSubDistrictId = subDistrictId ? subDistrictId.id : null_; } } //current address - if (item["CONTACT_PROVINCE_CODE"]) { + if (existingProfile.CONTACT_PROVINCE_CODE) { provinceCurr_ = await this.provincsRepo.findOne({ - where: { PROVINCE_CODE: item["CONTACT_PROVINCE_CODE"] }, + where: { PROVINCE_CODE: existingProfile.CONTACT_PROVINCE_CODE }, }); if (provinceCurr_) { let provinceId = await this.provinceIdRepo.findOne({ @@ -982,13 +1045,13 @@ export class ImportDataController extends Controller { name: provinceCurr_.PROVINCE_NAME, }, }); - existingProfile.currentProvinceId = provinceId ? provinceId.id : null_; + _item.currentProvinceId = provinceId ? provinceId.id : null_; } } - if (item["CONTACT_AMPHUR_CODE"]) { + if (existingProfile.CONTACT_AMPHUR_CODE) { districtCurr_ = await this.amphurRepo.findOne({ where: { - AMPHUR_CODE: item["CONTACT_AMPHUR_CODE"], + AMPHUR_CODE: existingProfile.CONTACT_AMPHUR_CODE, PROVINCE_CODE: provinceCurr_.PROVINCE_CODE, }, }); @@ -998,13 +1061,13 @@ export class ImportDataController extends Controller { name: districtCurr_.AMPHUR_NAME, }, }); - existingProfile.currentDistrictId = districtId ? districtId.id : null_; + _item.currentDistrictId = districtId ? districtId.id : null_; } } - if (item["CONTACT_DISTRICT_CODE"]) { + if (existingProfile.CONTACT_DISTRICT_CODE) { subDistrictCurr_ = await this.subDistrictRepo.findOne({ where: { - DISTRICT_CODE: item["CONTACT_DISTRICT_CODE"], + DISTRICT_CODE: existingProfile.CONTACT_DISTRICT_CODE, AMPHUR_CODE: districtCurr_.AMPHUR_CODE, PROVINCE_CODE: provinceCurr_.PROVINCE_CODE, }, @@ -1015,21 +1078,21 @@ export class ImportDataController extends Controller { name: subDistrictCurr_.DISTRICT_NAME, }, }); - existingProfile.currentSubDistrictId = subDistrictId ? subDistrictId.id : null_; + _item.currentSubDistrictId = subDistrictId ? subDistrictId.id : null_; } } - existingProfile.registrationAddress = item.H_NUMBER; - existingProfile.registrationZipCode = item.ZIPCODE; - existingProfile.currentAddress = item.CONTACT_H_NUMBER; - existingProfile.currentZipCode = item.CONTACT_ZIPCODE; - existingProfile.createdUserId = request.user.sub; - existingProfile.createdFullName = request.user.name; - existingProfile.lastUpdateUserId = request.user.sub; - existingProfile.lastUpdateFullName = request.user.name; - await this.profileRepo.save(existingProfile); - } - }), - ); + _item.registrationAddress = existingProfile.H_NUMBER; + _item.registrationZipCode = existingProfile.ZIPCODE; + _item.currentAddress = existingProfile.CONTACT_H_NUMBER; + _item.currentZipCode = existingProfile.CONTACT_ZIPCODE; + _item.lastUpdateUserId = request.user.sub; + _item.lastUpdateFullName = request.user.name; + profileDatas.push(_item); + }), + ); + await this.profileRepo.save(profileDatas); + } + console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); return new HttpSuccess(); } @@ -1037,34 +1100,43 @@ export class ImportDataController extends Controller { * @summary ที่อยู่ตามทะเบียนบ้าน-ปัจจุบัน ลูกจ้างประจำ */ @Post("uploadProfileAddress-Employee") - @UseInterceptors(FileInterceptor("file")) - async UploadFileSQLAddressEmp( - @UploadedFile() file: Express.Multer.File, - @Request() request: { user: Record }, - ) { - const workbook = xlsx.read(file.buffer, { type: "buffer" }); - const sheetName = workbook.SheetNames[0]; - const sheet = workbook.Sheets[sheetName]; - const getAddress = xlsx.utils.sheet_to_json(sheet); + async UploadFileSQLAddressEmp(@Request() request: { user: Record }) { + let rowCount = 0; + let profileDatas: any = []; let null_: any = null; - await Promise.all( - getAddress.map(async (item: any) => { - let provinceRegis_: any = null; - let districtRegis_: any = null; - let subDistrictRegis_: any = null; - let provinceCurr_: any = null; - let districtCurr_: any = null; - let subDistrictCurr_: any = null; - const existingProfileEmp = await this.profileEmpRepo.findOne({ - where: { citizenId: item.ID }, - }); - if (!existingProfileEmp) { - return; - } else { + 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") + .orderBy("profile.citizenId", "ASC") + .skip((i - 1) * BATCH_SIZE) + .take(BATCH_SIZE) + .getMany(); + profileDatas = await []; + await Promise.all( + profiles.map(async (_item) => { + const existingProfile = await this.HR_PERSONAL_EMP_ADDRESSRepo.findOne({ + where: { CIT: _item.citizenId }, + }); + + if (!existingProfile) { + return; + } + + rowCount++; + let provinceRegis_: any = null; + let districtRegis_: any = null; + let subDistrictRegis_: any = null; + let provinceCurr_: any = null; + let districtCurr_: any = null; + let subDistrictCurr_: any = null; //registration address - if (item["PROVINCE_CODE"]) { + if (existingProfile.PROVINCE_CODE) { provinceRegis_ = await this.provincsRepo.findOne({ - where: { PROVINCE_CODE: item["PROVINCE_CODE"] }, + where: { PROVINCE_CODE: existingProfile.PROVINCE_CODE }, }); if (provinceRegis_) { let provinceId = await this.provinceIdRepo.findOne({ @@ -1072,13 +1144,13 @@ export class ImportDataController extends Controller { name: provinceRegis_.PROVINCE_NAME, }, }); - existingProfileEmp.registrationProvinceId = provinceId ? provinceId.id : null_; + _item.registrationProvinceId = provinceId ? provinceId.id : null_; } } - if (item["AMPHUR_CODE"]) { + if (existingProfile.AMPHUR_CODE) { districtRegis_ = await this.amphurRepo.findOne({ where: { - AMPHUR_CODE: item["AMPHUR_CODE"], + AMPHUR_CODE: existingProfile.AMPHUR_CODE, PROVINCE_CODE: provinceRegis_.PROVINCE_CODE, }, }); @@ -1088,13 +1160,13 @@ export class ImportDataController extends Controller { name: districtRegis_.AMPHUR_NAME, }, }); - existingProfileEmp.registrationDistrictId = districtId ? districtId.id : null_; + _item.registrationDistrictId = districtId ? districtId.id : null_; } } - if (item["DISTRICT_CODE"]) { + if (existingProfile.DISTRICT_CODE) { subDistrictRegis_ = await this.subDistrictRepo.findOne({ where: { - DISTRICT_CODE: item["DISTRICT_CODE"], + DISTRICT_CODE: existingProfile.DISTRICT_CODE, AMPHUR_CODE: districtRegis_.AMPHUR_CODE, PROVINCE_CODE: provinceRegis_.PROVINCE_CODE, }, @@ -1105,15 +1177,13 @@ export class ImportDataController extends Controller { name: subDistrictRegis_.DISTRICT_NAME, }, }); - existingProfileEmp.registrationSubDistrictId = subDistrictId - ? subDistrictId.id - : null_; + _item.registrationSubDistrictId = subDistrictId ? subDistrictId.id : null_; } } //current address - if (item["CONTACT_PROVINCE_CODE"]) { + if (existingProfile.CONTACT_PROVINCE_CODE) { provinceCurr_ = await this.provincsRepo.findOne({ - where: { PROVINCE_CODE: item["CONTACT_PROVINCE_CODE"] }, + where: { PROVINCE_CODE: existingProfile.CONTACT_PROVINCE_CODE }, }); if (provinceCurr_) { let provinceId = await this.provinceIdRepo.findOne({ @@ -1121,13 +1191,13 @@ export class ImportDataController extends Controller { name: provinceCurr_.PROVINCE_NAME, }, }); - existingProfileEmp.currentProvinceId = provinceId ? provinceId.id : null_; + _item.currentProvinceId = provinceId ? provinceId.id : null_; } } - if (item["CONTACT_AMPHUR_CODE"]) { + if (existingProfile.CONTACT_AMPHUR_CODE) { districtCurr_ = await this.amphurRepo.findOne({ where: { - AMPHUR_CODE: item["CONTACT_AMPHUR_CODE"], + AMPHUR_CODE: existingProfile.CONTACT_AMPHUR_CODE, PROVINCE_CODE: provinceCurr_.PROVINCE_CODE, }, }); @@ -1137,13 +1207,13 @@ export class ImportDataController extends Controller { name: districtCurr_.AMPHUR_NAME, }, }); - existingProfileEmp.currentDistrictId = districtId ? districtId.id : null_; + _item.currentDistrictId = districtId ? districtId.id : null_; } } - if (item["CONTACT_DISTRICT_CODE"]) { + if (existingProfile.CONTACT_DISTRICT_CODE) { subDistrictCurr_ = await this.subDistrictRepo.findOne({ where: { - DISTRICT_CODE: item["CONTACT_DISTRICT_CODE"], + DISTRICT_CODE: existingProfile.CONTACT_DISTRICT_CODE, AMPHUR_CODE: districtCurr_.AMPHUR_CODE, PROVINCE_CODE: provinceCurr_.PROVINCE_CODE, }, @@ -1154,21 +1224,21 @@ export class ImportDataController extends Controller { name: subDistrictCurr_.DISTRICT_NAME, }, }); - existingProfileEmp.currentSubDistrictId = subDistrictId ? subDistrictId.id : null_; + _item.currentSubDistrictId = subDistrictId ? subDistrictId.id : null_; } } - existingProfileEmp.registrationAddress = item.H_NUMBER; - existingProfileEmp.registrationZipCode = item.ZIPCODE; - existingProfileEmp.currentAddress = item.CONTACT_H_NUMBER; - existingProfileEmp.currentZipCode = item.CONTACT_ZIPCODE; - existingProfileEmp.createdUserId = request.user.sub; - existingProfileEmp.createdFullName = request.user.name; - existingProfileEmp.lastUpdateUserId = request.user.sub; - existingProfileEmp.lastUpdateFullName = request.user.name; - await this.profileEmpRepo.save(existingProfileEmp); - } - }), - ); + _item.registrationAddress = existingProfile.H_NUMBER; + _item.registrationZipCode = existingProfile.ZIPCODE; + _item.currentAddress = existingProfile.CONTACT_H_NUMBER; + _item.currentZipCode = existingProfile.CONTACT_ZIPCODE; + _item.lastUpdateUserId = request.user.sub; + _item.lastUpdateFullName = request.user.name; + profileDatas.push(_item); + }), + ); + await this.profileEmpRepo.save(profileDatas); + } + console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); return new HttpSuccess(); } } diff --git a/src/entities/HR_EDUCATION.ts b/src/entities/HR_EDUCATION.ts new file mode 100644 index 00000000..64fe5602 --- /dev/null +++ b/src/entities/HR_EDUCATION.ts @@ -0,0 +1,48 @@ +import { Entity, Column, OneToMany, OneToOne, PrimaryGeneratedColumn } from "typeorm"; + +@Entity("HR_EDUCATION") +export class HR_EDUCATION { + @Column({ + nullable: true, + type: "text", + default: null, + }) + CIT: string; + @PrimaryGeneratedColumn() + id!: number; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + EDUCATION_CODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + START_EDUCATION_YEAR: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + EDUCATION_YEAR: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + EDUCATION_NAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + INSTITUE: string; +} diff --git a/src/entities/HR_EDUCATION_EMP.ts b/src/entities/HR_EDUCATION_EMP.ts new file mode 100644 index 00000000..7dc106d4 --- /dev/null +++ b/src/entities/HR_EDUCATION_EMP.ts @@ -0,0 +1,48 @@ +import { Entity, Column, OneToMany, OneToOne, PrimaryGeneratedColumn } from "typeorm"; + +@Entity("HR_EDUCATION_EMP") +export class HR_EDUCATION_EMP { + @Column({ + nullable: true, + type: "text", + default: null, + }) + CIT: string; + @PrimaryGeneratedColumn() + id!: number; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + EDUCATION_CODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + START_EDUCATION_YEAR: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + EDUCATION_YEAR: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + EDUCATION_NAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + INSTITUE: string; +} diff --git a/src/entities/HR_PERSONAL_EMP_ADDRESS.ts b/src/entities/HR_PERSONAL_EMP_ADDRESS.ts new file mode 100644 index 00000000..9f4a4060 --- /dev/null +++ b/src/entities/HR_PERSONAL_EMP_ADDRESS.ts @@ -0,0 +1,83 @@ +import { Entity, Column, OneToMany, OneToOne, PrimaryGeneratedColumn } from "typeorm"; + +@Entity("HR_PERSONAL_EMP_ADDRESS") +export class HR_PERSONAL_EMP_ADDRESS { + @Column({ + nullable: true, + type: "text", + default: null, + }) + CIT: string; + @PrimaryGeneratedColumn() + id!: number; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + PROVINCE_CODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + AMPHUR_CODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + DISTRICT_CODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + CONTACT_PROVINCE_CODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + CONTACT_AMPHUR_CODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + CONTACT_DISTRICT_CODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + H_NUMBER: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + ZIPCODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + CONTACT_H_NUMBER: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + CONTACT_ZIPCODE: string; +} diff --git a/src/entities/HR_PERSONAL_EMP_FAMILY.ts b/src/entities/HR_PERSONAL_EMP_FAMILY.ts new file mode 100644 index 00000000..94be8567 --- /dev/null +++ b/src/entities/HR_PERSONAL_EMP_FAMILY.ts @@ -0,0 +1,90 @@ +import { Entity, Column, OneToMany, OneToOne, PrimaryGeneratedColumn } from "typeorm"; + +@Entity("HR_PERSONAL_EMP_FAMILY") +export class HR_PERSONAL_EMP_FAMILY { + @Column({ + nullable: true, + type: "text", + default: null, + }) + CIT: string; + @PrimaryGeneratedColumn() + id!: number; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + FATHER_RANK_NAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + FATHER_FNAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + FATHER_LNAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + MOTHER_RANK_NAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + MOTHER_FNAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + MOTHER_LNAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + SPOUSE_RANK_NAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + SPOUSE_FNAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + SPOUSE_LNAME: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + SPOUSE_ID: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + MARRIAGE_STATE: string; +} diff --git a/src/entities/HR_PERSONAL_OFFICER_ADDRESS.ts b/src/entities/HR_PERSONAL_OFFICER_ADDRESS.ts new file mode 100644 index 00000000..23eea039 --- /dev/null +++ b/src/entities/HR_PERSONAL_OFFICER_ADDRESS.ts @@ -0,0 +1,83 @@ +import { Entity, Column, OneToMany, OneToOne, PrimaryGeneratedColumn } from "typeorm"; + +@Entity("HR_PERSONAL_OFFICER_ADDRESS") +export class HR_PERSONAL_OFFICER_ADDRESS { + @Column({ + nullable: true, + type: "text", + default: null, + }) + CIT: string; + @PrimaryGeneratedColumn() + id!: number; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + PROVINCE_CODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + AMPHUR_CODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + DISTRICT_CODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + CONTACT_PROVINCE_CODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + CONTACT_AMPHUR_CODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + CONTACT_DISTRICT_CODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + H_NUMBER: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + ZIPCODE: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + CONTACT_H_NUMBER: string; + + @Column({ + nullable: true, + type: "text", + default: null, + }) + CONTACT_ZIPCODE: string; +}