clear data
This commit is contained in:
parent
b2fd959162
commit
0bbf61b94a
3 changed files with 108 additions and 37 deletions
|
|
@ -14,7 +14,7 @@ import {
|
||||||
UploadedFile,
|
UploadedFile,
|
||||||
} from "tsoa";
|
} from "tsoa";
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { AppDataSource } from "../database/data-source";
|
||||||
import { Brackets, Double } from "typeorm";
|
import { Brackets, Double, In, Not } from "typeorm";
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import HttpSuccess from "../interfaces/http-success";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
import HttpStatusCode from "../interfaces/http-status";
|
||||||
|
|
@ -336,19 +336,20 @@ export class ImportDataController extends Controller {
|
||||||
profileSalary.createdFullName = request.user.name;
|
profileSalary.createdFullName = request.user.name;
|
||||||
profileSalary.lastUpdateUserId = request.user.sub;
|
profileSalary.lastUpdateUserId = request.user.sub;
|
||||||
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 (profileSalarys.length === BATCH_SIZE) {
|
// if (profileSalarys.length === BATCH_SIZE) {
|
||||||
await this.salaryRepository.save(profileSalarys);
|
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
||||||
profileSalarys = await [];
|
await this.salaryRepository.save(profileSalary);
|
||||||
}
|
// profileSalarys = await [];
|
||||||
|
// }
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
// await this.salaryRepository.save(profileSalarys);
|
// await this.salaryRepository.save(profileSalarys);
|
||||||
// profileSalarys = await [];
|
// profileSalarys = await [];
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
await this.salaryRepository.save(profileSalarys);
|
// await this.salaryRepository.save(profileSalarys);
|
||||||
// }
|
// }
|
||||||
console.log(rowCount);
|
console.log(rowCount);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
|
|
@ -427,13 +428,13 @@ export class ImportDataController extends Controller {
|
||||||
profileSalary.createdFullName = request.user.name;
|
profileSalary.createdFullName = request.user.name;
|
||||||
profileSalary.lastUpdateUserId = request.user.sub;
|
profileSalary.lastUpdateUserId = request.user.sub;
|
||||||
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 (profileSalarys.length === BATCH_SIZE) {
|
// if (profileSalarys.length === BATCH_SIZE) {
|
||||||
await this.salaryRepository.save(profileSalarys);
|
|
||||||
profileSalarys = await [];
|
|
||||||
}
|
|
||||||
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
||||||
|
await this.salaryRepository.save(profileSalary);
|
||||||
|
// profileSalarys = await [];
|
||||||
|
// }
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
// await this.salaryRepository.save(profileSalarys);
|
// await this.salaryRepository.save(profileSalarys);
|
||||||
|
|
@ -441,7 +442,7 @@ export class ImportDataController extends Controller {
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
// }
|
// }
|
||||||
await this.salaryRepository.save(profileSalarys);
|
// await this.salaryRepository.save(profileSalarys);
|
||||||
console.log(rowCount);
|
console.log(rowCount);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
@ -550,7 +551,7 @@ export class ImportDataController extends Controller {
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
// }
|
// }
|
||||||
console.log(rowCount);
|
// console.log(rowCount);
|
||||||
|
|
||||||
// await Promise.all([
|
// await Promise.all([
|
||||||
// this.profileFamilyFatherRepository.save(fathers),
|
// this.profileFamilyFatherRepository.save(fathers),
|
||||||
|
|
@ -665,7 +666,7 @@ export class ImportDataController extends Controller {
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
// }
|
// }
|
||||||
console.log(rowCount);
|
// console.log(rowCount);
|
||||||
|
|
||||||
// await Promise.all([
|
// await Promise.all([
|
||||||
// this.profileFamilyFatherRepository.save(fathers),
|
// this.profileFamilyFatherRepository.save(fathers),
|
||||||
|
|
@ -768,6 +769,7 @@ export class ImportDataController extends Controller {
|
||||||
education.lastUpdateUserId = request.user.sub;
|
education.lastUpdateUserId = request.user.sub;
|
||||||
education.lastUpdateFullName = request.user.name;
|
education.lastUpdateFullName = request.user.name;
|
||||||
// await educations.push(await education);
|
// await educations.push(await education);
|
||||||
|
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
||||||
await this.educationRepository.save(await education);
|
await this.educationRepository.save(await education);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
@ -776,7 +778,7 @@ export class ImportDataController extends Controller {
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
// }
|
// }
|
||||||
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
// console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
||||||
// await this.educationRepository.save(educations);
|
// await this.educationRepository.save(educations);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
@ -840,14 +842,16 @@ export class ImportDataController extends Controller {
|
||||||
education.createdFullName = request.user.name;
|
education.createdFullName = request.user.name;
|
||||||
education.lastUpdateUserId = request.user.sub;
|
education.lastUpdateUserId = request.user.sub;
|
||||||
education.lastUpdateFullName = request.user.name;
|
education.lastUpdateFullName = request.user.name;
|
||||||
educations.push(education);
|
// educations.push(education);
|
||||||
|
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
||||||
|
await this.educationRepository.save(education);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
await this.educationRepository.save(educations);
|
// await this.educationRepository.save(educations);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
// }
|
// }
|
||||||
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
// console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
||||||
// await this.educationRepository.save(educations);
|
// await this.educationRepository.save(educations);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
@ -1086,15 +1090,18 @@ export class ImportDataController extends Controller {
|
||||||
_item.registrationZipCode = existingProfile.ZIPCODE;
|
_item.registrationZipCode = existingProfile.ZIPCODE;
|
||||||
_item.currentAddress = existingProfile.CONTACT_H_NUMBER;
|
_item.currentAddress = existingProfile.CONTACT_H_NUMBER;
|
||||||
_item.currentZipCode = existingProfile.CONTACT_ZIPCODE;
|
_item.currentZipCode = existingProfile.CONTACT_ZIPCODE;
|
||||||
|
_item.createdUserId = request.user.sub;
|
||||||
|
_item.createdFullName = request.user.name;
|
||||||
_item.lastUpdateUserId = request.user.sub;
|
_item.lastUpdateUserId = request.user.sub;
|
||||||
_item.lastUpdateFullName = request.user.name;
|
_item.lastUpdateFullName = request.user.name;
|
||||||
// profileDatas.push(_item);
|
// profileDatas.push(_item);
|
||||||
|
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
||||||
await this.profileRepo.save(_item);
|
await this.profileRepo.save(_item);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
// await this.profileRepo.save(profileDatas);
|
// await this.profileRepo.save(profileDatas);
|
||||||
// }
|
// }
|
||||||
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
// console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1152,7 +1159,7 @@ export class ImportDataController extends Controller {
|
||||||
_item.registrationProvinceId = provinceId ? provinceId.id : null_;
|
_item.registrationProvinceId = provinceId ? provinceId.id : null_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (existingProfile.AMPHUR_CODE) {
|
if (existingProfile.AMPHUR_CODE && provinceRegis_) {
|
||||||
districtRegis_ = await this.amphurRepo.findOne({
|
districtRegis_ = await this.amphurRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
AMPHUR_CODE: existingProfile.AMPHUR_CODE,
|
AMPHUR_CODE: existingProfile.AMPHUR_CODE,
|
||||||
|
|
@ -1168,7 +1175,7 @@ export class ImportDataController extends Controller {
|
||||||
_item.registrationDistrictId = districtId ? districtId.id : null_;
|
_item.registrationDistrictId = districtId ? districtId.id : null_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (existingProfile.DISTRICT_CODE) {
|
if (existingProfile.DISTRICT_CODE && districtRegis_ && provinceRegis_) {
|
||||||
subDistrictRegis_ = await this.subDistrictRepo.findOne({
|
subDistrictRegis_ = await this.subDistrictRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
DISTRICT_CODE: existingProfile.DISTRICT_CODE,
|
DISTRICT_CODE: existingProfile.DISTRICT_CODE,
|
||||||
|
|
@ -1199,7 +1206,7 @@ export class ImportDataController extends Controller {
|
||||||
_item.currentProvinceId = provinceId ? provinceId.id : null_;
|
_item.currentProvinceId = provinceId ? provinceId.id : null_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (existingProfile.CONTACT_AMPHUR_CODE) {
|
if (existingProfile.CONTACT_AMPHUR_CODE && provinceCurr_) {
|
||||||
districtCurr_ = await this.amphurRepo.findOne({
|
districtCurr_ = await this.amphurRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
AMPHUR_CODE: existingProfile.CONTACT_AMPHUR_CODE,
|
AMPHUR_CODE: existingProfile.CONTACT_AMPHUR_CODE,
|
||||||
|
|
@ -1215,7 +1222,7 @@ export class ImportDataController extends Controller {
|
||||||
_item.currentDistrictId = districtId ? districtId.id : null_;
|
_item.currentDistrictId = districtId ? districtId.id : null_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (existingProfile.CONTACT_DISTRICT_CODE) {
|
if (existingProfile.CONTACT_DISTRICT_CODE && districtCurr_ && provinceCurr_) {
|
||||||
subDistrictCurr_ = await this.subDistrictRepo.findOne({
|
subDistrictCurr_ = await this.subDistrictRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
DISTRICT_CODE: existingProfile.CONTACT_DISTRICT_CODE,
|
DISTRICT_CODE: existingProfile.CONTACT_DISTRICT_CODE,
|
||||||
|
|
@ -1236,15 +1243,79 @@ export class ImportDataController extends Controller {
|
||||||
_item.registrationZipCode = existingProfile.ZIPCODE;
|
_item.registrationZipCode = existingProfile.ZIPCODE;
|
||||||
_item.currentAddress = existingProfile.CONTACT_H_NUMBER;
|
_item.currentAddress = existingProfile.CONTACT_H_NUMBER;
|
||||||
_item.currentZipCode = existingProfile.CONTACT_ZIPCODE;
|
_item.currentZipCode = existingProfile.CONTACT_ZIPCODE;
|
||||||
|
_item.createdUserId = request.user.sub;
|
||||||
|
_item.createdFullName = request.user.name;
|
||||||
_item.lastUpdateUserId = request.user.sub;
|
_item.lastUpdateUserId = request.user.sub;
|
||||||
_item.lastUpdateFullName = request.user.name;
|
_item.lastUpdateFullName = request.user.name;
|
||||||
// profileDatas.push(_item);
|
// profileDatas.push(_item);
|
||||||
|
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
||||||
await this.profileEmpRepo.save(_item);
|
await this.profileEmpRepo.save(_item);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
// await this.profileEmpRepo.save(profileDatas);
|
// await this.profileEmpRepo.save(profileDatas);
|
||||||
// }
|
// }
|
||||||
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
// console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @summary ทะเบียนประวัติ ข้าราชการ
|
||||||
|
*/
|
||||||
|
@Post("cleardataupload")
|
||||||
|
async ClearDataUpload(@Request() request: { user: Record<string, any> }) {
|
||||||
|
const profileOff = await this.profileRepo.find({
|
||||||
|
select: ["citizenId"],
|
||||||
|
});
|
||||||
|
const profileEmp = await this.profileEmpRepo.find({
|
||||||
|
select: ["citizenId"],
|
||||||
|
});
|
||||||
|
const _profileOff = profileOff.map((x) => x.citizenId);
|
||||||
|
const _profileEmp = profileEmp.map((x) => x.citizenId);
|
||||||
|
const allId = _profileOff.concat(_profileEmp);
|
||||||
|
|
||||||
|
for (var i = 1; i <= 1000; i++) {
|
||||||
|
const HR_POSITION_OFFICER = await this.HR_POSITION_OFFICERRepo.find({
|
||||||
|
where: { CIT: Not(In(allId)) },
|
||||||
|
take: 1000,
|
||||||
|
skip: 0,
|
||||||
|
});
|
||||||
|
this.HR_POSITION_OFFICERRepo.remove(HR_POSITION_OFFICER);
|
||||||
|
// const HR_PERSONAL_OFFICER_FAMILY = await this.HR_PERSONAL_OFFICER_FAMILYRepo.find({
|
||||||
|
// where: { CIT: Not(In(allId)) },
|
||||||
|
// take: 1000,
|
||||||
|
// skip: 0,
|
||||||
|
// });
|
||||||
|
// this.HR_PERSONAL_OFFICER_FAMILYRepo.remove(HR_PERSONAL_OFFICER_FAMILY);
|
||||||
|
// const HR_EDUCATION = await this.HR_EDUCATIONRepo.find({
|
||||||
|
// where: { CIT: Not(In(allId)) },
|
||||||
|
// take: 1000,
|
||||||
|
// skip: 0,
|
||||||
|
// });
|
||||||
|
// this.HR_EDUCATIONRepo.remove(HR_EDUCATION);
|
||||||
|
// const HR_PERSONAL_OFFICER_ADDRESS = await this.HR_PERSONAL_OFFICER_ADDRESSRepo.find({
|
||||||
|
// where: { CIT: Not(In(allId)) },
|
||||||
|
// take: 1000,
|
||||||
|
// skip: 0,
|
||||||
|
// });
|
||||||
|
// this.HR_PERSONAL_OFFICER_ADDRESSRepo.remove(HR_PERSONAL_OFFICER_ADDRESS);
|
||||||
|
// const HR_EDUCATION_EMP = await this.HR_EDUCATION_EMPRepo.find({
|
||||||
|
// where: { CIT: Not(In(allId)) },
|
||||||
|
// take: 1000,
|
||||||
|
// skip: 0,
|
||||||
|
// });
|
||||||
|
// this.HR_EDUCATION_EMPRepo.remove(HR_EDUCATION_EMP);
|
||||||
|
// const HR_PERSONAL_EMP_ADDRESS = await this.HR_PERSONAL_EMP_ADDRESSRepo.find({
|
||||||
|
// where: { CIT: Not(In(allId)) },
|
||||||
|
// take: 1000,
|
||||||
|
// skip: 0,
|
||||||
|
// });
|
||||||
|
// this.HR_PERSONAL_EMP_ADDRESSRepo.remove(HR_PERSONAL_EMP_ADDRESS);
|
||||||
|
// const HR_PERSONAL_EMP_FAMILY = await this.HR_PERSONAL_EMP_FAMILYRepo.find({
|
||||||
|
// where: { CIT: Not(In(allId)) },
|
||||||
|
// take: 1000,
|
||||||
|
// skip: 0,
|
||||||
|
// });
|
||||||
|
// this.HR_PERSONAL_EMP_FAMILYRepo.remove(HR_PERSONAL_EMP_FAMILY);
|
||||||
|
}
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,12 @@ export class HR_EDUCATION {
|
||||||
})
|
})
|
||||||
EDUCATION_YEAR: string;
|
EDUCATION_YEAR: string;
|
||||||
|
|
||||||
@Column({
|
// @Column({
|
||||||
nullable: true,
|
// nullable: true,
|
||||||
type: "text",
|
// type: "text",
|
||||||
default: null,
|
// default: null,
|
||||||
})
|
// })
|
||||||
EDUCATION_NAME: string;
|
// EDUCATION_NAME: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,12 @@ export class HR_EDUCATION_EMP {
|
||||||
})
|
})
|
||||||
EDUCATION_YEAR: string;
|
EDUCATION_YEAR: string;
|
||||||
|
|
||||||
@Column({
|
// @Column({
|
||||||
nullable: true,
|
// nullable: true,
|
||||||
type: "text",
|
// type: "text",
|
||||||
default: null,
|
// default: null,
|
||||||
})
|
// })
|
||||||
EDUCATION_NAME: string;
|
// EDUCATION_NAME: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue