no message

This commit is contained in:
Kittapath 2024-07-26 15:52:32 +07:00
parent 7c7ae7db41
commit 692f74c48c
6 changed files with 614 additions and 192 deletions

View file

@ -56,6 +56,11 @@ import { SubDistrictImport } from "../entities/SubDistrictImport";
import { Province } from "../entities/Province"; import { Province } from "../entities/Province";
import { District } from "../entities/District"; import { District } from "../entities/District";
import { SubDistrict } from "../entities/SubDistrict"; 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") @Route("api/v1/org/upload")
@Tags("UPLOAD") @Tags("UPLOAD")
@ -72,6 +77,13 @@ export class ImportDataController extends Controller {
private posTypeRepo = AppDataSource.getRepository(PosType); private posTypeRepo = AppDataSource.getRepository(PosType);
private HR_POSITION_OFFICERRepo = AppDataSource.getRepository(HR_POSITION_OFFICER); private HR_POSITION_OFFICERRepo = AppDataSource.getRepository(HR_POSITION_OFFICER);
private HR_PERSONAL_OFFICER_FAMILYRepo = AppDataSource.getRepository(HR_PERSONAL_OFFICER_FAMILY); 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 educationMisRepo = AppDataSource.getRepository(EducationMis);
private provincsRepo = AppDataSource.getRepository(ProvinceImport); private provincsRepo = AppDataSource.getRepository(ProvinceImport);
@ -696,26 +708,42 @@ export class ImportDataController extends Controller {
* @summary * @summary
*/ */
@Post("uploadProfileEducation-Officer") @Post("uploadProfileEducation-Officer")
@UseInterceptors(FileInterceptor("file")) async UploadFileSQLEducation(@Request() request: { user: Record<string, any> }) {
async UploadFileSQLEducation( let rowCount = 0;
@UploadedFile() file: Express.Multer.File,
@Request() request: { user: Record<string, any> },
) {
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);
let educations: any = []; let educations: any = [];
let null_: any = null; let null_: any = null;
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();
await Promise.all( await Promise.all(
getEducations.map(async (item: any) => { profiles.map(async (_item) => {
const education = new ProfileEducation(); const existingProfile = await this.HR_EDUCATIONRepo.find({
const existingProfile = await this.profileRepo.findOne({ where: { CIT: _item.citizenId },
where: { citizenId: item.ID }, select: [
"CIT",
"EDUCATION_CODE",
"START_EDUCATION_YEAR",
"EDUCATION_YEAR",
"EDUCATION_NAME",
"INSTITUE",
],
}); });
if (!existingProfile) {
return; educations = await [];
} await Promise.all(
existingProfile.map(async (item) => {
rowCount++;
const education = new ProfileEducation();
const educationCode = await this.educationMisRepo.findOne({ const educationCode = await this.educationMisRepo.findOne({
where: { EDUCATION_CODE: item.EDUCATION_CODE }, where: { EDUCATION_CODE: item.EDUCATION_CODE },
}); });
@ -730,7 +758,7 @@ export class ImportDataController extends Controller {
: null_; : null_;
endDate = endDate ? new Date(endDate, 0, 1) : null_; endDate = endDate ? new Date(endDate, 0, 1) : null_;
education.profileId = existingProfile.id; education.profileId = _item.id;
education.degree = educationCode ? educationCode.EDUCATION_NAME : ""; education.degree = educationCode ? educationCode.EDUCATION_NAME : "";
education.institute = item.INSTITUE; education.institute = item.INSTITUE;
education.startDate = startDate; education.startDate = startDate;
@ -743,6 +771,11 @@ export class ImportDataController extends Controller {
}), }),
); );
await this.educationRepository.save(educations); await this.educationRepository.save(educations);
}),
);
}
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
// await this.educationRepository.save(educations);
return new HttpSuccess(); return new HttpSuccess();
} }
@ -750,26 +783,42 @@ export class ImportDataController extends Controller {
* @summary * @summary
*/ */
@Post("uploadProfileEducation-Employee") @Post("uploadProfileEducation-Employee")
@UseInterceptors(FileInterceptor("file")) async UploadFileSQLEducationEmp(@Request() request: { user: Record<string, any> }) {
async UploadFileSQLEducationEmp( let rowCount = 0;
@UploadedFile() file: Express.Multer.File,
@Request() request: { user: Record<string, any> },
) {
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);
let educations: any = []; let educations: any = [];
let null_: any = null; let null_: any = null;
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();
await Promise.all( await Promise.all(
getEducations.map(async (item: any) => { profiles.map(async (_item) => {
const education = new ProfileEducation(); const existingProfile = await this.HR_EDUCATION_EMPRepo.find({
const existingProfile = await this.profileEmpRepo.findOne({ where: { CIT: _item.citizenId },
where: { citizenId: item.ID }, select: [
"CIT",
"EDUCATION_CODE",
"START_EDUCATION_YEAR",
"EDUCATION_YEAR",
"EDUCATION_NAME",
"INSTITUE",
],
}); });
if (!existingProfile) {
return; educations = await [];
} await Promise.all(
existingProfile.map(async (item) => {
rowCount++;
const education = new ProfileEducation();
const educationCode = await this.educationMisRepo.findOne({ const educationCode = await this.educationMisRepo.findOne({
where: { EDUCATION_CODE: item.EDUCATION_CODE }, where: { EDUCATION_CODE: item.EDUCATION_CODE },
}); });
@ -784,7 +833,7 @@ export class ImportDataController extends Controller {
: null_; : null_;
endDate = endDate ? new Date(endDate, 0, 1) : null_; endDate = endDate ? new Date(endDate, 0, 1) : null_;
education.profileEmployeeId = existingProfile.id; education.profileEmployeeId = _item.id;
education.degree = educationCode ? educationCode.EDUCATION_NAME : ""; education.degree = educationCode ? educationCode.EDUCATION_NAME : "";
education.institute = item.INSTITUE; education.institute = item.INSTITUE;
education.startDate = startDate; education.startDate = startDate;
@ -797,6 +846,11 @@ export class ImportDataController extends Controller {
}), }),
); );
await this.educationRepository.save(educations); await this.educationRepository.save(educations);
}),
);
}
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
// await this.educationRepository.save(educations);
return new HttpSuccess(); return new HttpSuccess();
} }
@ -900,34 +954,43 @@ export class ImportDataController extends Controller {
* @summary - * @summary -
*/ */
@Post("uploadProfileAddress-Officer") @Post("uploadProfileAddress-Officer")
@UseInterceptors(FileInterceptor("file")) async UploadFileSQLAddress(@Request() request: { user: Record<string, any> }) {
async UploadFileSQLAddress( let rowCount = 0;
@UploadedFile() file: Express.Multer.File, let profileDatas: any = [];
@Request() request: { user: Record<string, any> },
) {
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);
let null_: any = null; let null_: any = null;
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( await Promise.all(
getAddress.map(async (item: any) => { 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 provinceRegis_: any = null;
let districtRegis_: any = null; let districtRegis_: any = null;
let subDistrictRegis_: any = null; let subDistrictRegis_: any = null;
let provinceCurr_: any = null; let provinceCurr_: any = null;
let districtCurr_: any = null; let districtCurr_: any = null;
let subDistrictCurr_: any = null; let subDistrictCurr_: any = null;
const existingProfile = await this.profileRepo.findOne({
where: { citizenId: item.ID },
});
if (!existingProfile) {
return;
} else {
//registration address //registration address
if (item["PROVINCE_CODE"]) { if (existingProfile.PROVINCE_CODE) {
provinceRegis_ = await this.provincsRepo.findOne({ provinceRegis_ = await this.provincsRepo.findOne({
where: { PROVINCE_CODE: item["PROVINCE_CODE"] }, where: { PROVINCE_CODE: existingProfile.PROVINCE_CODE },
}); });
if (provinceRegis_) { if (provinceRegis_) {
let provinceId = await this.provinceIdRepo.findOne({ let provinceId = await this.provinceIdRepo.findOne({
@ -935,13 +998,13 @@ export class ImportDataController extends Controller {
name: provinceRegis_.PROVINCE_NAME, 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({ districtRegis_ = await this.amphurRepo.findOne({
where: { where: {
AMPHUR_CODE: item["AMPHUR_CODE"], AMPHUR_CODE: existingProfile.AMPHUR_CODE,
PROVINCE_CODE: provinceRegis_.PROVINCE_CODE, PROVINCE_CODE: provinceRegis_.PROVINCE_CODE,
}, },
}); });
@ -951,13 +1014,13 @@ export class ImportDataController extends Controller {
name: districtRegis_.AMPHUR_NAME, 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({ subDistrictRegis_ = await this.subDistrictRepo.findOne({
where: { where: {
DISTRICT_CODE: item["DISTRICT_CODE"], DISTRICT_CODE: existingProfile.DISTRICT_CODE,
AMPHUR_CODE: districtRegis_.AMPHUR_CODE, AMPHUR_CODE: districtRegis_.AMPHUR_CODE,
PROVINCE_CODE: provinceRegis_.PROVINCE_CODE, PROVINCE_CODE: provinceRegis_.PROVINCE_CODE,
}, },
@ -968,13 +1031,13 @@ export class ImportDataController extends Controller {
name: subDistrictRegis_.DISTRICT_NAME, name: subDistrictRegis_.DISTRICT_NAME,
}, },
}); });
existingProfile.registrationSubDistrictId = subDistrictId ? subDistrictId.id : null_; _item.registrationSubDistrictId = subDistrictId ? subDistrictId.id : null_;
} }
} }
//current address //current address
if (item["CONTACT_PROVINCE_CODE"]) { if (existingProfile.CONTACT_PROVINCE_CODE) {
provinceCurr_ = await this.provincsRepo.findOne({ provinceCurr_ = await this.provincsRepo.findOne({
where: { PROVINCE_CODE: item["CONTACT_PROVINCE_CODE"] }, where: { PROVINCE_CODE: existingProfile.CONTACT_PROVINCE_CODE },
}); });
if (provinceCurr_) { if (provinceCurr_) {
let provinceId = await this.provinceIdRepo.findOne({ let provinceId = await this.provinceIdRepo.findOne({
@ -982,13 +1045,13 @@ export class ImportDataController extends Controller {
name: provinceCurr_.PROVINCE_NAME, 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({ districtCurr_ = await this.amphurRepo.findOne({
where: { where: {
AMPHUR_CODE: item["CONTACT_AMPHUR_CODE"], AMPHUR_CODE: existingProfile.CONTACT_AMPHUR_CODE,
PROVINCE_CODE: provinceCurr_.PROVINCE_CODE, PROVINCE_CODE: provinceCurr_.PROVINCE_CODE,
}, },
}); });
@ -998,13 +1061,13 @@ export class ImportDataController extends Controller {
name: districtCurr_.AMPHUR_NAME, 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({ subDistrictCurr_ = await this.subDistrictRepo.findOne({
where: { where: {
DISTRICT_CODE: item["CONTACT_DISTRICT_CODE"], DISTRICT_CODE: existingProfile.CONTACT_DISTRICT_CODE,
AMPHUR_CODE: districtCurr_.AMPHUR_CODE, AMPHUR_CODE: districtCurr_.AMPHUR_CODE,
PROVINCE_CODE: provinceCurr_.PROVINCE_CODE, PROVINCE_CODE: provinceCurr_.PROVINCE_CODE,
}, },
@ -1015,21 +1078,21 @@ export class ImportDataController extends Controller {
name: subDistrictCurr_.DISTRICT_NAME, name: subDistrictCurr_.DISTRICT_NAME,
}, },
}); });
existingProfile.currentSubDistrictId = subDistrictId ? subDistrictId.id : null_; _item.currentSubDistrictId = subDistrictId ? subDistrictId.id : null_;
} }
} }
existingProfile.registrationAddress = item.H_NUMBER; _item.registrationAddress = existingProfile.H_NUMBER;
existingProfile.registrationZipCode = item.ZIPCODE; _item.registrationZipCode = existingProfile.ZIPCODE;
existingProfile.currentAddress = item.CONTACT_H_NUMBER; _item.currentAddress = existingProfile.CONTACT_H_NUMBER;
existingProfile.currentZipCode = item.CONTACT_ZIPCODE; _item.currentZipCode = existingProfile.CONTACT_ZIPCODE;
existingProfile.createdUserId = request.user.sub; _item.lastUpdateUserId = request.user.sub;
existingProfile.createdFullName = request.user.name; _item.lastUpdateFullName = request.user.name;
existingProfile.lastUpdateUserId = request.user.sub; profileDatas.push(_item);
existingProfile.lastUpdateFullName = request.user.name;
await this.profileRepo.save(existingProfile);
}
}), }),
); );
await this.profileRepo.save(profileDatas);
}
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
return new HttpSuccess(); return new HttpSuccess();
} }
@ -1037,34 +1100,43 @@ export class ImportDataController extends Controller {
* @summary - * @summary -
*/ */
@Post("uploadProfileAddress-Employee") @Post("uploadProfileAddress-Employee")
@UseInterceptors(FileInterceptor("file")) async UploadFileSQLAddressEmp(@Request() request: { user: Record<string, any> }) {
async UploadFileSQLAddressEmp( let rowCount = 0;
@UploadedFile() file: Express.Multer.File, let profileDatas: any = [];
@Request() request: { user: Record<string, any> },
) {
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);
let null_: any = null; let null_: any = null;
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( await Promise.all(
getAddress.map(async (item: any) => { 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 provinceRegis_: any = null;
let districtRegis_: any = null; let districtRegis_: any = null;
let subDistrictRegis_: any = null; let subDistrictRegis_: any = null;
let provinceCurr_: any = null; let provinceCurr_: any = null;
let districtCurr_: any = null; let districtCurr_: any = null;
let subDistrictCurr_: any = null; let subDistrictCurr_: any = null;
const existingProfileEmp = await this.profileEmpRepo.findOne({
where: { citizenId: item.ID },
});
if (!existingProfileEmp) {
return;
} else {
//registration address //registration address
if (item["PROVINCE_CODE"]) { if (existingProfile.PROVINCE_CODE) {
provinceRegis_ = await this.provincsRepo.findOne({ provinceRegis_ = await this.provincsRepo.findOne({
where: { PROVINCE_CODE: item["PROVINCE_CODE"] }, where: { PROVINCE_CODE: existingProfile.PROVINCE_CODE },
}); });
if (provinceRegis_) { if (provinceRegis_) {
let provinceId = await this.provinceIdRepo.findOne({ let provinceId = await this.provinceIdRepo.findOne({
@ -1072,13 +1144,13 @@ export class ImportDataController extends Controller {
name: provinceRegis_.PROVINCE_NAME, 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({ districtRegis_ = await this.amphurRepo.findOne({
where: { where: {
AMPHUR_CODE: item["AMPHUR_CODE"], AMPHUR_CODE: existingProfile.AMPHUR_CODE,
PROVINCE_CODE: provinceRegis_.PROVINCE_CODE, PROVINCE_CODE: provinceRegis_.PROVINCE_CODE,
}, },
}); });
@ -1088,13 +1160,13 @@ export class ImportDataController extends Controller {
name: districtRegis_.AMPHUR_NAME, 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({ subDistrictRegis_ = await this.subDistrictRepo.findOne({
where: { where: {
DISTRICT_CODE: item["DISTRICT_CODE"], DISTRICT_CODE: existingProfile.DISTRICT_CODE,
AMPHUR_CODE: districtRegis_.AMPHUR_CODE, AMPHUR_CODE: districtRegis_.AMPHUR_CODE,
PROVINCE_CODE: provinceRegis_.PROVINCE_CODE, PROVINCE_CODE: provinceRegis_.PROVINCE_CODE,
}, },
@ -1105,15 +1177,13 @@ export class ImportDataController extends Controller {
name: subDistrictRegis_.DISTRICT_NAME, name: subDistrictRegis_.DISTRICT_NAME,
}, },
}); });
existingProfileEmp.registrationSubDistrictId = subDistrictId _item.registrationSubDistrictId = subDistrictId ? subDistrictId.id : null_;
? subDistrictId.id
: null_;
} }
} }
//current address //current address
if (item["CONTACT_PROVINCE_CODE"]) { if (existingProfile.CONTACT_PROVINCE_CODE) {
provinceCurr_ = await this.provincsRepo.findOne({ provinceCurr_ = await this.provincsRepo.findOne({
where: { PROVINCE_CODE: item["CONTACT_PROVINCE_CODE"] }, where: { PROVINCE_CODE: existingProfile.CONTACT_PROVINCE_CODE },
}); });
if (provinceCurr_) { if (provinceCurr_) {
let provinceId = await this.provinceIdRepo.findOne({ let provinceId = await this.provinceIdRepo.findOne({
@ -1121,13 +1191,13 @@ export class ImportDataController extends Controller {
name: provinceCurr_.PROVINCE_NAME, 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({ districtCurr_ = await this.amphurRepo.findOne({
where: { where: {
AMPHUR_CODE: item["CONTACT_AMPHUR_CODE"], AMPHUR_CODE: existingProfile.CONTACT_AMPHUR_CODE,
PROVINCE_CODE: provinceCurr_.PROVINCE_CODE, PROVINCE_CODE: provinceCurr_.PROVINCE_CODE,
}, },
}); });
@ -1137,13 +1207,13 @@ export class ImportDataController extends Controller {
name: districtCurr_.AMPHUR_NAME, 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({ subDistrictCurr_ = await this.subDistrictRepo.findOne({
where: { where: {
DISTRICT_CODE: item["CONTACT_DISTRICT_CODE"], DISTRICT_CODE: existingProfile.CONTACT_DISTRICT_CODE,
AMPHUR_CODE: districtCurr_.AMPHUR_CODE, AMPHUR_CODE: districtCurr_.AMPHUR_CODE,
PROVINCE_CODE: provinceCurr_.PROVINCE_CODE, PROVINCE_CODE: provinceCurr_.PROVINCE_CODE,
}, },
@ -1154,21 +1224,21 @@ export class ImportDataController extends Controller {
name: subDistrictCurr_.DISTRICT_NAME, name: subDistrictCurr_.DISTRICT_NAME,
}, },
}); });
existingProfileEmp.currentSubDistrictId = subDistrictId ? subDistrictId.id : null_; _item.currentSubDistrictId = subDistrictId ? subDistrictId.id : null_;
} }
} }
existingProfileEmp.registrationAddress = item.H_NUMBER; _item.registrationAddress = existingProfile.H_NUMBER;
existingProfileEmp.registrationZipCode = item.ZIPCODE; _item.registrationZipCode = existingProfile.ZIPCODE;
existingProfileEmp.currentAddress = item.CONTACT_H_NUMBER; _item.currentAddress = existingProfile.CONTACT_H_NUMBER;
existingProfileEmp.currentZipCode = item.CONTACT_ZIPCODE; _item.currentZipCode = existingProfile.CONTACT_ZIPCODE;
existingProfileEmp.createdUserId = request.user.sub; _item.lastUpdateUserId = request.user.sub;
existingProfileEmp.createdFullName = request.user.name; _item.lastUpdateFullName = request.user.name;
existingProfileEmp.lastUpdateUserId = request.user.sub; profileDatas.push(_item);
existingProfileEmp.lastUpdateFullName = request.user.name;
await this.profileEmpRepo.save(existingProfileEmp);
}
}), }),
); );
await this.profileEmpRepo.save(profileDatas);
}
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
return new HttpSuccess(); return new HttpSuccess();
} }
} }

View file

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

View file

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

View file

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

View file

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

View file

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