Merge branch 'develop' into adiDev

This commit is contained in:
AdisakKanthawilang 2024-05-28 13:35:59 +07:00
commit 2b0c20556d
3 changed files with 71 additions and 33 deletions

View file

@ -183,7 +183,9 @@ export class ProfileController extends Controller {
profile.dateRetire != null profile.dateRetire != null
? Extension.ToThaiNumber(Extension.ToThaiFullDate(profile.dateRetire)) ? Extension.ToThaiNumber(Extension.ToThaiFullDate(profile.dateRetire))
: "", : "",
RegistrationAddress: `${_regisAddres}${_subDistrict}${_district}${_province}${registrationZipCode}`, RegistrationAddress: Extension.ToThaiNumber(
`${_regisAddres}${_subDistrict}${_district}${_province}${registrationZipCode}`,
),
SalaryAmount: SalaryAmount:
profile.profileSalary.length > 0 && profile.profileSalary[0].amount != null profile.profileSalary.length > 0 && profile.profileSalary[0].amount != null
? Extension.ToThaiNumber(profile.profileSalary[0].amount.toLocaleString()) ? 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 != null
? profile.profileEducations[profile.profileEducations.length - 1].institute ? profile.profileEducations[profile.profileEducations.length - 1].institute
: "", : "",
AppointText: profile.dateAppoint != null ? profile.dateAppoint : "", AppointText:
profile.dateAppoint != null
? Extension.ToThaiNumber(Extension.ToThaiFullDate(profile.dateAppoint))
: "",
SalaryDate: SalaryDate:
profile.profileSalary.length > 0 && profile.profileSalary[0].date != null profile.profileSalary.length > 0 && profile.profileSalary[0].date != null
? Extension.ToThaiNumber(Extension.ToThaiFullDate(profile.profileSalary[0].date)) ? Extension.ToThaiNumber(Extension.ToThaiFullDate(profile.profileSalary[0].date))
@ -240,17 +245,17 @@ export class ProfileController extends Controller {
}); });
const profileFamilyCouple = await this.profileFamilyCoupleRepository.findOne({ const profileFamilyCouple = await this.profileFamilyCoupleRepository.findOne({
where: { id }, where: { profileId: id },
select: ["couplePrefix", "coupleFirstName", "coupleLastNameOld"], select: ["couplePrefix", "coupleFirstName", "coupleLastNameOld"],
}); });
const profileFamilyMother = await this.profileFamilyMotherRepository.findOne({ const profileFamilyMother = await this.profileFamilyMotherRepository.findOne({
where: { id }, where: { profileId: id },
select: ["motherPrefix", "motherFirstName", "motherLastName"], select: ["motherPrefix", "motherFirstName", "motherLastName"],
}); });
const profileFamilyFather = await this.profileFamilyFatherRepository.findOne({ const profileFamilyFather = await this.profileFamilyFatherRepository.findOne({
where: { id }, where: { profileId: id },
select: ["fatherPrefix", "fatherFirstName", "fatherLastName"], select: ["fatherPrefix", "fatherFirstName", "fatherLastName"],
}); });
@ -305,13 +310,13 @@ export class ProfileController extends Controller {
BirthDay: profiles?.birthDate ? new Date(profiles.birthDate).getDate() : null, BirthDay: profiles?.birthDate ? new Date(profiles.birthDate).getDate() : null,
BirthDayText: BirthDayText:
profiles.birthDate != null 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 BirthMonth: profiles?.birthDate ? new Date(profiles.birthDate).getMonth() + 1 : null, // Months are zero-based
BirthYear: profiles?.birthDate ? new Date(profiles.birthDate).getFullYear() : null, BirthYear: profiles?.birthDate ? new Date(profiles.birthDate).getFullYear() : null,
BirthYearText: BirthYearText:
profiles.birthDate != null profiles.birthDate != null
? Extension.ToThaiNumber(Extension.ToThaiFullDate(profiles.birthDate)) ? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate))
: "", : "",
Address: "", Address: "",
District: "", District: "",
@ -319,21 +324,24 @@ export class ProfileController extends Controller {
Province: "", Province: "",
Telephone: profiles?.telephoneNumber ?? null, Telephone: profiles?.telephoneNumber ?? null,
CoupleLastNameOld: profileFamilyCouple?.coupleLastNameOld ?? null, CoupleLastNameOld: profileFamilyCouple?.coupleLastNameOld ?? null,
CouplePrefix: profileFamilyCouple?.couplePrefix ?? null, CouplePrefix:
profileFamilyCouple?.couplePrefix != null ? profileFamilyCouple.couplePrefix : "",
CoupleFullName: CoupleFullName:
profileFamilyCouple?.couplePrefix || profileFamilyCouple?.couplePrefix ||
profileFamilyCouple?.coupleFirstName || profileFamilyCouple?.coupleFirstName ||
profileFamilyCouple?.coupleLastNameOld profileFamilyCouple?.coupleLastNameOld
? `${profileFamilyCouple?.couplePrefix ?? ""} ${profileFamilyCouple?.coupleFirstName ?? ""} ${profileFamilyCouple?.coupleLastNameOld ?? ""}`.trim() ? `${profileFamilyCouple?.couplePrefix ?? ""} ${profileFamilyCouple?.coupleFirstName ?? ""} ${profileFamilyCouple?.coupleLastNameOld ?? ""}`.trim()
: null, : null,
FatherPrefix: profileFamilyFather?.fatherPrefix ?? null, FatherPrefix:
profileFamilyFather?.fatherPrefix != null ? profileFamilyFather.fatherPrefix : "",
FatherFullName: FatherFullName:
profileFamilyFather?.fatherPrefix || profileFamilyFather?.fatherPrefix ||
profileFamilyFather?.fatherFirstName || profileFamilyFather?.fatherFirstName ||
profileFamilyFather?.fatherLastName profileFamilyFather?.fatherLastName
? `${profileFamilyFather?.fatherPrefix ?? ""} ${profileFamilyFather?.fatherFirstName ?? ""} ${profileFamilyFather?.fatherLastName ?? ""}`.trim() ? `${profileFamilyFather?.fatherPrefix ?? ""} ${profileFamilyFather?.fatherFirstName ?? ""} ${profileFamilyFather?.fatherLastName ?? ""}`.trim()
: null, : null,
MotherPrefix: profileFamilyMother?.motherPrefix ?? null, MotherPrefix:
profileFamilyMother?.motherPrefix != null ? profileFamilyMother.motherPrefix : "",
MotherFullName: MotherFullName:
profileFamilyMother?.motherPrefix || profileFamilyMother?.motherPrefix ||
profileFamilyMother?.motherFirstName || profileFamilyMother?.motherFirstName ||
@ -358,7 +366,7 @@ export class ProfileController extends Controller {
CertificateType: item.certificateType ?? null, CertificateType: item.certificateType ?? null,
Issuer: item.issuer ?? null, Issuer: item.issuer ?? null,
CertificateNo: item.certificateNo ?? null, CertificateNo: item.certificateNo ?? null,
IssueDate: item.issueDate ?? null, IssueDate: Extension.ToThaiShortDate(item.issueDate) ?? null,
})); }));
const trainings = await this.trainingRepository.find({ const trainings = await this.trainingRepository.find({
select: ["startDate", "endDate", "place", "department"], select: ["startDate", "endDate", "place", "department"],
@ -366,8 +374,8 @@ export class ProfileController extends Controller {
}); });
const training = trainings.map((item) => ({ const training = trainings.map((item) => ({
institute: item.department ?? null, institute: item.department ?? null,
start: item.startDate ?? null, start: Extension.ToThaiShortDate(item.startDate) ?? null,
end: item.endDate ?? null, end: Extension.ToThaiShortDate(item.endDate) ?? null,
level: "", level: "",
degree: "", degree: "",
field: item.place ?? null, field: item.place ?? null,
@ -378,7 +386,7 @@ export class ProfileController extends Controller {
where: { profileId: id }, where: { profileId: id },
}); });
const discipline = disciplines.map((item) => ({ const discipline = disciplines.map((item) => ({
DisciplineYear: item.refCommandDate ?? null, DisciplineYear: new Date(item.refCommandDate).getFullYear() ?? null,
DisciplineDetail: item.detail ?? null, DisciplineDetail: item.detail ?? null,
RefNo: item.refCommandNo ?? null, RefNo: item.refCommandNo ?? null,
})); }));
@ -389,8 +397,8 @@ export class ProfileController extends Controller {
}); });
const education = educations.map((item) => ({ const education = educations.map((item) => ({
Institute: item.institute ?? null, Institute: item.institute ?? null,
Start: item.startDate ?? null, Start: new Date(item.startDate).getFullYear() ?? null,
End: item.endDate ?? null, End: new Date(item.endDate).getFullYear() ?? null,
Level: item.educationLevel ?? null, Level: item.educationLevel ?? null,
Degree: item.degree ?? null, Degree: item.degree ?? null,
Field: item.field ?? null, Field: item.field ?? null,
@ -409,7 +417,7 @@ export class ProfileController extends Controller {
}); });
const salary = salarys.map((item) => ({ const salary = salarys.map((item) => ({
SalaryDate: item.date ?? null, SalaryDate: Extension.ToThaiShortDate(item.date) ?? null,
Position: item.position ?? null, Position: item.position ?? null,
PosNo: item.posNo ?? null, PosNo: item.posNo ?? null,
Salary: "", Salary: "",
@ -420,7 +428,14 @@ export class ProfileController extends Controller {
FullName: `${profiles?.prefix} ${profiles?.firstName} ${profiles?.lastName}`, FullName: `${profiles?.prefix} ${profiles?.firstName} ${profiles?.lastName}`,
OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
})); }));
return new HttpSuccess({ profile, cert, training, discipline, education, salary }); return new HttpSuccess({
profile,
cert,
training,
discipline,
education,
salary,
});
} }
/** /**
* *

View file

@ -247,17 +247,17 @@ export class ProfileEmployeeController extends Controller {
}); });
const profileFamilyCouple = await this.profileFamilyCoupleRepository.findOne({ const profileFamilyCouple = await this.profileFamilyCoupleRepository.findOne({
where: { id }, where: { profileEmployeeId: id },
select: ["couplePrefix", "coupleFirstName", "coupleLastNameOld"], select: ["couplePrefix", "coupleFirstName", "coupleLastNameOld"],
}); });
const profileFamilyMother = await this.profileFamilyMotherRepository.findOne({ const profileFamilyMother = await this.profileFamilyMotherRepository.findOne({
where: { id }, where: { profileEmployeeId: id },
select: ["motherPrefix", "motherFirstName", "motherLastName"], select: ["motherPrefix", "motherFirstName", "motherLastName"],
}); });
const profileFamilyFather = await this.profileFamilyFatherRepository.findOne({ const profileFamilyFather = await this.profileFamilyFatherRepository.findOne({
where: { id }, where: { profileEmployeeId: id },
select: ["fatherPrefix", "fatherFirstName", "fatherLastName"], select: ["fatherPrefix", "fatherFirstName", "fatherLastName"],
}); });
@ -323,13 +323,13 @@ export class ProfileEmployeeController extends Controller {
BirthDay: profiles?.birthDate ? new Date(profiles.birthDate).getDate() : null, BirthDay: profiles?.birthDate ? new Date(profiles.birthDate).getDate() : null,
BirthDayText: BirthDayText:
profiles.birthDate != null 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 BirthMonth: profiles?.birthDate ? new Date(profiles.birthDate).getMonth() + 1 : null, // Months are zero-based
BirthYear: profiles?.birthDate ? new Date(profiles.birthDate).getFullYear() : null, BirthYear: profiles?.birthDate ? new Date(profiles.birthDate).getFullYear() : null,
BirthYearText: BirthYearText:
profiles.birthDate != null profiles.birthDate != null
? Extension.ToThaiNumber(Extension.ToThaiFullDate(profiles.birthDate)) ? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate))
: "", : "",
Address: "", Address: "",
District: "", District: "",
@ -337,21 +337,24 @@ export class ProfileEmployeeController extends Controller {
Province: "", Province: "",
Telephone: profiles?.telephoneNumber ?? null, Telephone: profiles?.telephoneNumber ?? null,
CoupleLastNameOld: profileFamilyCouple?.coupleLastNameOld ?? null, CoupleLastNameOld: profileFamilyCouple?.coupleLastNameOld ?? null,
CouplePrefix: profileFamilyCouple?.couplePrefix ?? null, CouplePrefix:
profileFamilyCouple?.couplePrefix != null ? profileFamilyCouple.couplePrefix : "",
CoupleFullName: CoupleFullName:
profileFamilyCouple?.couplePrefix || profileFamilyCouple?.couplePrefix ||
profileFamilyCouple?.coupleFirstName || profileFamilyCouple?.coupleFirstName ||
profileFamilyCouple?.coupleLastNameOld profileFamilyCouple?.coupleLastNameOld
? `${profileFamilyCouple?.couplePrefix ?? ""} ${profileFamilyCouple?.coupleFirstName ?? ""} ${profileFamilyCouple?.coupleLastNameOld ?? ""}`.trim() ? `${profileFamilyCouple?.couplePrefix ?? ""} ${profileFamilyCouple?.coupleFirstName ?? ""} ${profileFamilyCouple?.coupleLastNameOld ?? ""}`.trim()
: null, : null,
FatherPrefix: profileFamilyFather?.fatherPrefix ?? null, FatherPrefix:
profileFamilyFather?.fatherPrefix != null ? profileFamilyFather.fatherPrefix : "",
FatherFullName: FatherFullName:
profileFamilyFather?.fatherPrefix || profileFamilyFather?.fatherPrefix ||
profileFamilyFather?.fatherFirstName || profileFamilyFather?.fatherFirstName ||
profileFamilyFather?.fatherLastName profileFamilyFather?.fatherLastName
? `${profileFamilyFather?.fatherPrefix ?? ""} ${profileFamilyFather?.fatherFirstName ?? ""} ${profileFamilyFather?.fatherLastName ?? ""}`.trim() ? `${profileFamilyFather?.fatherPrefix ?? ""} ${profileFamilyFather?.fatherFirstName ?? ""} ${profileFamilyFather?.fatherLastName ?? ""}`.trim()
: null, : null,
MotherPrefix: profileFamilyMother?.motherPrefix ?? null, MotherPrefix:
profileFamilyMother?.motherPrefix != null ? profileFamilyMother.motherPrefix : "",
MotherFullName: MotherFullName:
profileFamilyMother?.motherPrefix || profileFamilyMother?.motherPrefix ||
profileFamilyMother?.motherFirstName || profileFamilyMother?.motherFirstName ||
@ -376,7 +379,7 @@ export class ProfileEmployeeController extends Controller {
CertificateType: item.certificateType ?? null, CertificateType: item.certificateType ?? null,
Issuer: item.issuer ?? null, Issuer: item.issuer ?? null,
CertificateNo: item.certificateNo ?? null, CertificateNo: item.certificateNo ?? null,
IssueDate: item.issueDate ?? null, IssueDate: Extension.ToThaiShortDate(item.issueDate) ?? null,
})); }));
const trainings = await this.trainingRepository.find({ const trainings = await this.trainingRepository.find({
select: ["startDate", "endDate", "place", "department"], select: ["startDate", "endDate", "place", "department"],
@ -384,8 +387,8 @@ export class ProfileEmployeeController extends Controller {
}); });
const training = trainings.map((item) => ({ const training = trainings.map((item) => ({
institute: item.department ?? null, institute: item.department ?? null,
start: item.startDate ?? null, start: Extension.ToThaiShortDate(item.startDate) ?? null,
end: item.endDate ?? null, end: Extension.ToThaiShortDate(item.endDate) ?? null,
level: "", level: "",
degree: "", degree: "",
field: item.place ?? null, field: item.place ?? null,
@ -396,7 +399,7 @@ export class ProfileEmployeeController extends Controller {
where: { profileEmployeeId: id }, where: { profileEmployeeId: id },
}); });
const discipline = disciplines.map((item) => ({ const discipline = disciplines.map((item) => ({
DisciplineYear: item.refCommandDate ?? null, DisciplineYear: new Date(item.refCommandDate).getFullYear() ?? null,
DisciplineDetail: item.detail ?? null, DisciplineDetail: item.detail ?? null,
RefNo: item.refCommandNo ?? null, RefNo: item.refCommandNo ?? null,
})); }));
@ -407,8 +410,8 @@ export class ProfileEmployeeController extends Controller {
}); });
const education = educations.map((item) => ({ const education = educations.map((item) => ({
Institute: item.institute ?? null, Institute: item.institute ?? null,
Start: item.startDate ?? null, Start: new Date(item.startDate).getFullYear() ?? null,
End: item.endDate ?? null, End: new Date(item.endDate).getFullYear() ?? null,
Level: item.educationLevel ?? null, Level: item.educationLevel ?? null,
Degree: item.degree ?? null, Degree: item.degree ?? null,
Field: item.field ?? null, Field: item.field ?? null,
@ -427,7 +430,7 @@ export class ProfileEmployeeController extends Controller {
}); });
const salary = salarys.map((item) => ({ const salary = salarys.map((item) => ({
SalaryDate: item.date ?? null, SalaryDate: Extension.ToThaiShortDate(item.date) ?? null,
Position: item.position ?? null, Position: item.position ?? null,
PosNo: item.posNo ?? null, PosNo: item.posNo ?? null,
Salary: "", Salary: "",

View file

@ -0,0 +1,20 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableProfileAddDuty1716867925436 implements MigrationInterface {
name = 'UpdateTableProfileAddDuty1716867925436'
public async up(queryRunner: QueryRunner): Promise<void> {
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<void> {
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\``);
}
}