From dcd324fd3766656269cb027ad25aaca85335fad4 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Tue, 28 May 2024 10:47:34 +0700 Subject: [PATCH 1/4] migrate --- ...867925436-update_table_profile_add_duty.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/migration/1716867925436-update_table_profile_add_duty.ts diff --git a/src/migration/1716867925436-update_table_profile_add_duty.ts b/src/migration/1716867925436-update_table_profile_add_duty.ts new file mode 100644 index 00000000..bb24c61b --- /dev/null +++ b/src/migration/1716867925436-update_table_profile_add_duty.ts @@ -0,0 +1,20 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableProfileAddDuty1716867925436 implements MigrationInterface { + name = 'UpdateTableProfileAddDuty1716867925436' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profile\` ADD \`dutyTimeId\` varchar(40) NULL COMMENT 'ไอดีรอบลงเวลาล่าสุด'`); + await queryRunner.query(`ALTER TABLE \`profile\` ADD \`dutyTimeEffectiveDate\` datetime NULL COMMENT 'รอบลงเวลาล่าสุด'`); + await queryRunner.query(`ALTER TABLE \`profileHistory\` ADD \`dutyTimeId\` varchar(40) NULL COMMENT 'ไอดีรอบลงเวลาล่าสุด'`); + await queryRunner.query(`ALTER TABLE \`profileHistory\` ADD \`dutyTimeEffectiveDate\` datetime NULL COMMENT 'รอบลงเวลาล่าสุด'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileHistory\` DROP COLUMN \`dutyTimeEffectiveDate\``); + await queryRunner.query(`ALTER TABLE \`profileHistory\` DROP COLUMN \`dutyTimeId\``); + await queryRunner.query(`ALTER TABLE \`profile\` DROP COLUMN \`dutyTimeEffectiveDate\``); + await queryRunner.query(`ALTER TABLE \`profile\` DROP COLUMN \`dutyTimeId\``); + } + +} From 3debbe1602bce728e2242c779739d427619a2f27 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Tue, 28 May 2024 12:02:41 +0700 Subject: [PATCH 2/4] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=20list=20report?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileController.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index d8ccaab6..e722cb21 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -183,7 +183,9 @@ export class ProfileController extends Controller { profile.dateRetire != null ? Extension.ToThaiNumber(Extension.ToThaiFullDate(profile.dateRetire)) : "", - RegistrationAddress: `${_regisAddres}${_subDistrict}${_district}${_province}${registrationZipCode}`, + RegistrationAddress: Extension.ToThaiNumber( + `${_regisAddres}${_subDistrict}${_district}${_province}${registrationZipCode}`, + ), SalaryAmount: profile.profileSalary.length > 0 && profile.profileSalary[0].amount != null ? Extension.ToThaiNumber(profile.profileSalary[0].amount.toLocaleString()) @@ -193,7 +195,10 @@ export class ProfileController extends Controller { profile.profileEducations[profile.profileEducations.length - 1].institute != null ? profile.profileEducations[profile.profileEducations.length - 1].institute : "", - AppointText: profile.dateAppoint != null ? profile.dateAppoint : "", + AppointText: + profile.dateAppoint != null + ? Extension.ToThaiNumber(Extension.ToThaiFullDate(profile.dateAppoint)) + : "", SalaryDate: profile.profileSalary.length > 0 && profile.profileSalary[0].date != null ? Extension.ToThaiNumber(Extension.ToThaiFullDate(profile.profileSalary[0].date)) From f3318a9bab62e7ceac6a67fdcf4a38fb72d55909 Mon Sep 17 00:00:00 2001 From: AnandaTon Date: Tue, 28 May 2024 12:05:12 +0700 Subject: [PATCH 3/4] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84?= =?UTF-8?q?=E0=B8=82=20id=20=E0=B9=80=E0=B8=9B=E0=B9=87=E0=B8=99=20profile?= =?UTF-8?q?Id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileController.ts | 36 +++++++++++++------- src/controllers/ProfileEmployeeController.ts | 27 ++++++++------- 2 files changed, 38 insertions(+), 25 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index d8ccaab6..5c6b32f8 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -240,17 +240,17 @@ export class ProfileController extends Controller { }); const profileFamilyCouple = await this.profileFamilyCoupleRepository.findOne({ - where: { id }, + where: { profileId: id }, select: ["couplePrefix", "coupleFirstName", "coupleLastNameOld"], }); const profileFamilyMother = await this.profileFamilyMotherRepository.findOne({ - where: { id }, + where: { profileId: id }, select: ["motherPrefix", "motherFirstName", "motherLastName"], }); const profileFamilyFather = await this.profileFamilyFatherRepository.findOne({ - where: { id }, + where: { profileId: id }, select: ["fatherPrefix", "fatherFirstName", "fatherLastName"], }); @@ -319,21 +319,24 @@ export class ProfileController extends Controller { Province: "", Telephone: profiles?.telephoneNumber ?? null, CoupleLastNameOld: profileFamilyCouple?.coupleLastNameOld ?? null, - CouplePrefix: profileFamilyCouple?.couplePrefix ?? null, + CouplePrefix: + profileFamilyCouple?.couplePrefix != null ? profileFamilyCouple.couplePrefix : "", CoupleFullName: profileFamilyCouple?.couplePrefix || profileFamilyCouple?.coupleFirstName || profileFamilyCouple?.coupleLastNameOld ? `${profileFamilyCouple?.couplePrefix ?? ""} ${profileFamilyCouple?.coupleFirstName ?? ""} ${profileFamilyCouple?.coupleLastNameOld ?? ""}`.trim() : null, - FatherPrefix: profileFamilyFather?.fatherPrefix ?? null, + FatherPrefix: + profileFamilyFather?.fatherPrefix != null ? profileFamilyFather.fatherPrefix : "", FatherFullName: profileFamilyFather?.fatherPrefix || profileFamilyFather?.fatherFirstName || profileFamilyFather?.fatherLastName ? `${profileFamilyFather?.fatherPrefix ?? ""} ${profileFamilyFather?.fatherFirstName ?? ""} ${profileFamilyFather?.fatherLastName ?? ""}`.trim() : null, - MotherPrefix: profileFamilyMother?.motherPrefix ?? null, + MotherPrefix: + profileFamilyMother?.motherPrefix != null ? profileFamilyMother.motherPrefix : "", MotherFullName: profileFamilyMother?.motherPrefix || profileFamilyMother?.motherFirstName || @@ -358,7 +361,7 @@ export class ProfileController extends Controller { CertificateType: item.certificateType ?? null, Issuer: item.issuer ?? null, CertificateNo: item.certificateNo ?? null, - IssueDate: item.issueDate ?? null, + IssueDate: Extension.ToThaiShortDate(item.issueDate) ?? null, })); const trainings = await this.trainingRepository.find({ select: ["startDate", "endDate", "place", "department"], @@ -366,8 +369,8 @@ export class ProfileController extends Controller { }); const training = trainings.map((item) => ({ institute: item.department ?? null, - start: item.startDate ?? null, - end: item.endDate ?? null, + start: Extension.ToThaiShortDate(item.startDate) ?? null, + end: Extension.ToThaiShortDate(item.endDate) ?? null, level: "", degree: "", field: item.place ?? null, @@ -378,7 +381,7 @@ export class ProfileController extends Controller { where: { profileId: id }, }); const discipline = disciplines.map((item) => ({ - DisciplineYear: item.refCommandDate ?? null, + DisciplineYear: new Date(item.refCommandDate).getFullYear() ?? null, DisciplineDetail: item.detail ?? null, RefNo: item.refCommandNo ?? null, })); @@ -389,8 +392,8 @@ export class ProfileController extends Controller { }); const education = educations.map((item) => ({ Institute: item.institute ?? null, - Start: item.startDate ?? null, - End: item.endDate ?? null, + Start: new Date(item.startDate).getFullYear() ?? null, + End: new Date(item.endDate).getFullYear() ?? null, Level: item.educationLevel ?? null, Degree: item.degree ?? null, Field: item.field ?? null, @@ -420,7 +423,14 @@ export class ProfileController extends Controller { FullName: `${profiles?.prefix} ${profiles?.firstName} ${profiles?.lastName}`, OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, })); - return new HttpSuccess({ profile, cert, training, discipline, education, salary }); + return new HttpSuccess({ + profile, + cert, + training, + discipline, + education, + salary, + }); } /** * diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index b9bf56b8..cec130a3 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -247,17 +247,17 @@ export class ProfileEmployeeController extends Controller { }); const profileFamilyCouple = await this.profileFamilyCoupleRepository.findOne({ - where: { id }, + where: { profileEmployeeId: id }, select: ["couplePrefix", "coupleFirstName", "coupleLastNameOld"], }); const profileFamilyMother = await this.profileFamilyMotherRepository.findOne({ - where: { id }, + where: { profileEmployeeId: id }, select: ["motherPrefix", "motherFirstName", "motherLastName"], }); const profileFamilyFather = await this.profileFamilyFatherRepository.findOne({ - where: { id }, + where: { profileEmployeeId: id }, select: ["fatherPrefix", "fatherFirstName", "fatherLastName"], }); @@ -337,21 +337,24 @@ export class ProfileEmployeeController extends Controller { Province: "", Telephone: profiles?.telephoneNumber ?? null, CoupleLastNameOld: profileFamilyCouple?.coupleLastNameOld ?? null, - CouplePrefix: profileFamilyCouple?.couplePrefix ?? null, + CouplePrefix: + profileFamilyCouple?.couplePrefix != null ? profileFamilyCouple.couplePrefix : "", CoupleFullName: profileFamilyCouple?.couplePrefix || profileFamilyCouple?.coupleFirstName || profileFamilyCouple?.coupleLastNameOld ? `${profileFamilyCouple?.couplePrefix ?? ""} ${profileFamilyCouple?.coupleFirstName ?? ""} ${profileFamilyCouple?.coupleLastNameOld ?? ""}`.trim() : null, - FatherPrefix: profileFamilyFather?.fatherPrefix ?? null, + FatherPrefix: + profileFamilyFather?.fatherPrefix != null ? profileFamilyFather.fatherPrefix : "", FatherFullName: profileFamilyFather?.fatherPrefix || profileFamilyFather?.fatherFirstName || profileFamilyFather?.fatherLastName ? `${profileFamilyFather?.fatherPrefix ?? ""} ${profileFamilyFather?.fatherFirstName ?? ""} ${profileFamilyFather?.fatherLastName ?? ""}`.trim() : null, - MotherPrefix: profileFamilyMother?.motherPrefix ?? null, + MotherPrefix: + profileFamilyMother?.motherPrefix != null ? profileFamilyMother.motherPrefix : "", MotherFullName: profileFamilyMother?.motherPrefix || profileFamilyMother?.motherFirstName || @@ -376,7 +379,7 @@ export class ProfileEmployeeController extends Controller { CertificateType: item.certificateType ?? null, Issuer: item.issuer ?? null, CertificateNo: item.certificateNo ?? null, - IssueDate: item.issueDate ?? null, + IssueDate: Extension.ToThaiShortDate(item.issueDate) ?? null, })); const trainings = await this.trainingRepository.find({ select: ["startDate", "endDate", "place", "department"], @@ -384,8 +387,8 @@ export class ProfileEmployeeController extends Controller { }); const training = trainings.map((item) => ({ institute: item.department ?? null, - start: item.startDate ?? null, - end: item.endDate ?? null, + start: Extension.ToThaiShortDate(item.startDate) ?? null, + end: Extension.ToThaiShortDate(item.endDate) ?? null, level: "", degree: "", field: item.place ?? null, @@ -396,7 +399,7 @@ export class ProfileEmployeeController extends Controller { where: { profileEmployeeId: id }, }); const discipline = disciplines.map((item) => ({ - DisciplineYear: item.refCommandDate ?? null, + DisciplineYear: new Date(item.refCommandDate).getFullYear() ?? null, DisciplineDetail: item.detail ?? null, RefNo: item.refCommandNo ?? null, })); @@ -407,8 +410,8 @@ export class ProfileEmployeeController extends Controller { }); const education = educations.map((item) => ({ Institute: item.institute ?? null, - Start: item.startDate ?? null, - End: item.endDate ?? null, + Start: new Date(item.startDate).getFullYear() ?? null, + End: new Date(item.endDate).getFullYear() ?? null, Level: item.educationLevel ?? null, Degree: item.degree ?? null, Field: item.field ?? null, From b1d6888f584e78c3a126470e7a252a5dc07dc5e1 Mon Sep 17 00:00:00 2001 From: AnandaTon Date: Tue, 28 May 2024 12:52:08 +0700 Subject: [PATCH 4/4] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84?= =?UTF-8?q?=E0=B8=82=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1=E0=B9=80?= =?UTF-8?q?=E0=B8=95=E0=B8=B4=E0=B8=A1=20kk1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileController.ts | 6 +++--- src/controllers/ProfileEmployeeController.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 16f64aaf..aec3db55 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -310,13 +310,13 @@ export class ProfileController extends Controller { BirthDay: profiles?.birthDate ? new Date(profiles.birthDate).getDate() : null, BirthDayText: profiles.birthDate != null - ? Extension.ToThaiNumber(Extension.ToThaiFullDate(profiles.birthDate)) + ? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate)) : "", BirthMonth: profiles?.birthDate ? new Date(profiles.birthDate).getMonth() + 1 : null, // Months are zero-based BirthYear: profiles?.birthDate ? new Date(profiles.birthDate).getFullYear() : null, BirthYearText: profiles.birthDate != null - ? Extension.ToThaiNumber(Extension.ToThaiFullDate(profiles.birthDate)) + ? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate)) : "", Address: "", District: "", @@ -417,7 +417,7 @@ export class ProfileController extends Controller { }); const salary = salarys.map((item) => ({ - SalaryDate: item.date ?? null, + SalaryDate: Extension.ToThaiShortDate(item.date) ?? null, Position: item.position ?? null, PosNo: item.posNo ?? null, Salary: "", diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index cec130a3..dbee92c5 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -323,13 +323,13 @@ export class ProfileEmployeeController extends Controller { BirthDay: profiles?.birthDate ? new Date(profiles.birthDate).getDate() : null, BirthDayText: profiles.birthDate != null - ? Extension.ToThaiNumber(Extension.ToThaiFullDate(profiles.birthDate)) + ? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate)) : "", BirthMonth: profiles?.birthDate ? new Date(profiles.birthDate).getMonth() + 1 : null, // Months are zero-based BirthYear: profiles?.birthDate ? new Date(profiles.birthDate).getFullYear() : null, BirthYearText: profiles.birthDate != null - ? Extension.ToThaiNumber(Extension.ToThaiFullDate(profiles.birthDate)) + ? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate)) : "", Address: "", District: "", @@ -430,7 +430,7 @@ export class ProfileEmployeeController extends Controller { }); const salary = salarys.map((item) => ({ - SalaryDate: item.date ?? null, + SalaryDate: Extension.ToThaiShortDate(item.date) ?? null, Position: item.position ?? null, PosNo: item.posNo ?? null, Salary: "",