From 4785aad08c88b8ad02091cafb71c04e36055afc3 Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Wed, 5 Mar 2025 15:10:16 +0700 Subject: [PATCH 1/3] updated salary position of user --- src/controllers/ProfileSalaryController.ts | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/controllers/ProfileSalaryController.ts b/src/controllers/ProfileSalaryController.ts index 5780e4fc..2407809b 100644 --- a/src/controllers/ProfileSalaryController.ts +++ b/src/controllers/ProfileSalaryController.ts @@ -37,7 +37,7 @@ export class ProfileSalaryController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const record = await this.salaryRepo.find({ - where: { profileId: profile.id }, + where: { profileId: profile.id, commandCode: In(["5", "6", "7"]) }, order: { order: "ASC" }, }); return new HttpSuccess(record); @@ -50,7 +50,25 @@ export class ProfileSalaryController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const record = await this.salaryRepo.find({ - where: { profileId: profile.id }, + where: { + profileId: profile.id, + commandCode: In([ + "0", + "9", + "1", + "2", + "3", + "4", + "8", + "10", + "11", + "12", + "13", + "14", + "15", + "16", + ]), + }, order: { order: "ASC" }, }); return new HttpSuccess(record); From 8b8375fe43bdc06ee90c08e79387444988d4c111 Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 5 Mar 2025 15:15:50 +0700 Subject: [PATCH 2/3] =?UTF-8?q?=E0=B9=81=E0=B8=9F=E0=B9=89=E0=B8=9B?= =?UTF-8?q?=E0=B8=A3=E0=B8=B0=E0=B8=A7=E0=B8=B1=E0=B8=95=E0=B8=B4=E0=B9=81?= =?UTF-8?q?=E0=B8=9A=E0=B8=9A=E0=B8=A2=E0=B9=88=E0=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileController.ts | 274 ++++++++++++------ src/controllers/ProfileEmployeeController.ts | 28 +- .../ProfileEmployeeTempController.ts | 7 +- 3 files changed, 205 insertions(+), 104 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 12582e36..a18aca6c 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -31,7 +31,7 @@ import { UpdateProfileMother, UpdateProfileCouple, } from "../entities/Profile"; -import { Brackets, IsNull, Like, Not } from "typeorm"; +import { Brackets, In, IsNull, Like, Not } from "typeorm"; import { OrgRevision } from "../entities/OrgRevision"; import { PosMaster } from "../entities/PosMaster"; import { PosLevel } from "../entities/PosLevel"; @@ -116,12 +116,11 @@ export class ProfileController extends Controller { private profileLeaveRepository = AppDataSource.getRepository(ProfileLeave); private posMasterActRepository = AppDataSource.getRepository(PosMasterAct); private profileChildrenRepository = AppDataSource.getRepository(ProfileChildren); - private changeNameRepository = AppDataSource.getRepository(ProfileChangeName); - private profileActpositionRepo = AppDataSource.getRepository(ProfileActposition); - private dutyRepository = AppDataSource.getRepository(ProfileDuty); - private profileAssessmentsRepository = AppDataSource.getRepository(ProfileAssessment); - private profileAbilityRepo = AppDataSource.getRepository(ProfileAbility); - + private changeNameRepository = AppDataSource.getRepository(ProfileChangeName); + private profileActpositionRepo = AppDataSource.getRepository(ProfileActposition); + private dutyRepository = AppDataSource.getRepository(ProfileDuty); + private profileAssessmentsRepository = AppDataSource.getRepository(ProfileAssessment); + private profileAbilityRepo = AppDataSource.getRepository(ProfileAbility); /** * report ประวัติแบบย่อ ข้าราชการ @@ -254,8 +253,11 @@ export class ProfileController extends Controller { "orgChild4", "positionExecutive", ], - where: { profileId: id }, - order: { commandDateAffect: "ASC" }, + where: { + profileId: id, + commandCode: In(["1", "2", "3", "4", "8", "10", "11", "12", "15", "16"]), + }, + order: { order: "ASC" }, }); const salarys = @@ -271,6 +273,7 @@ export class ProfileController extends Controller { orgChild2: item.orgChild2, orgChild3: item.orgChild3, orgChild4: item.orgChild4, + positionCee: item.positionCee, positionExecutive: item.positionExecutive, })) : [ @@ -877,7 +880,15 @@ export class ProfileController extends Controller { @Get("kk1/{id}") public async getKk1new(@Path() id: string, @Request() req: RequestWithUser) { const profiles = await this.profileRepo.findOne({ - relations: ["currentSubDistrict", "currentDistrict", "currentProvince","registrationSubDistrict", "registrationDistrict", "registrationProvince", "profileAvatars"], + relations: [ + "currentSubDistrict", + "currentDistrict", + "currentProvince", + "registrationSubDistrict", + "registrationDistrict", + "registrationProvince", + "profileAvatars", + ], order: { profileAvatars: { createdAt: "ASC" }, }, @@ -1014,10 +1025,18 @@ export class ProfileController extends Controller { ? cert_raw.slice(-2).map((item) => ({ certificateType: item.certificateType ?? null, issuer: item.issuer ?? null, - certificateNo: item.certificateNo?Extension.ToThaiNumber(item.certificateNo):null, - issueDate: item.issueDate?Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.issueDate)):null, - expireDate: item.expireDate?Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.expireDate)):null, - issueToExpireDate: item.issueDate?Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.issueDate)):"" + item.expireDate?" - " + Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.expireDate)): null, + certificateNo: item.certificateNo ? Extension.ToThaiNumber(item.certificateNo) : null, + issueDate: item.issueDate + ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.issueDate)) + : null, + expireDate: item.expireDate + ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.expireDate)) + : null, + issueToExpireDate: item.issueDate + ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.issueDate)) + : "" + item.expireDate + ? " - " + Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.expireDate)) + : null, })) : [ { @@ -1074,8 +1093,9 @@ export class ProfileController extends Controller { const disciplines = discipline_raw.length > 0 ? discipline_raw.slice(-2).map((item) => ({ - disciplineYear: - item.refCommandDate?Extension.ToThaiNumber(new Date(item.refCommandDate).getFullYear().toString()):null, + disciplineYear: item.refCommandDate + ? Extension.ToThaiNumber(new Date(item.refCommandDate).getFullYear().toString()) + : null, disciplineDetail: item.detail ?? null, refNo: Extension.ToThaiNumber(item.refCommandNo) ?? null, })) @@ -1248,14 +1268,14 @@ export class ProfileController extends Controller { where: { profileId: id }, }); const children = - children_raw.length > 0 - ? children_raw.map((item,index) => ({ - no: Extension.ToThaiNumber((index+1).toString()), + children_raw.length > 0 + ? children_raw.map((item, index) => ({ + no: Extension.ToThaiNumber((index + 1).toString()), childrenPrefix: item.childrenPrefix, childrenFirstName: item.childrenFirstName, childrenLastName: item.childrenLastName, childrenFullName: `${item.childrenPrefix}${item.childrenFirstName} ${item.childrenLastName}`, - childrenLive: item.childrenLive == true?"มีชีวิต":"ถึงแก่กรรม", + childrenLive: item.childrenLive == true ? "มีชีวิต" : "ถึงแก่กรรม", })) : [ { @@ -1272,9 +1292,11 @@ export class ProfileController extends Controller { order: { createdAt: "ASC" }, }); const changeName = - changeName_raw.length > 0 + changeName_raw.length > 0 ? changeName_raw.map((item) => ({ - createdAt: item.createdAt?Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.createdAt)):null, + createdAt: item.createdAt + ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.createdAt)) + : null, status: item.status, prefix: item.prefix, firstName: item.firstName, @@ -1289,22 +1311,32 @@ export class ProfileController extends Controller { lastName: "-", }, ]; - + const position_raw = await this.salaryRepo.find({ where: { profileId: id }, order: { order: "ASC" }, }); const positionList = - position_raw.length > 0 + position_raw.length > 0 ? position_raw.map((item) => ({ - commandDateAffect: item.commandDateAffect?Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateAffect)):"", - commandDateSign: item.commandDateSign?Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateSign)):"", - posNo: item.posNoAbb?Extension.ToThaiNumber(item.posNoAbb):"" + item.posNo?Extension.ToThaiNumber(item.posNo):"", + commandDateAffect: item.commandDateAffect + ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateAffect)) + : "", + commandDateSign: item.commandDateSign + ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateSign)) + : "", + posNo: item.posNoAbb + ? Extension.ToThaiNumber(item.posNoAbb) + : "" + item.posNo + ? Extension.ToThaiNumber(item.posNo) + : "", position: item.positionName, posType: item.positionType, - posLevel: item.positionLevel?Extension.ToThaiNumber(item.positionLevel):"", - amount: item.amount?Extension.ToThaiNumber(Number(item.amount).toLocaleString()):"", - positionSalaryAmount: item.positionSalaryAmount?Extension.ToThaiNumber(Number(item.positionSalaryAmount).toLocaleString()):"", + posLevel: item.positionLevel ? Extension.ToThaiNumber(item.positionLevel) : "", + amount: item.amount ? Extension.ToThaiNumber(Number(item.amount).toLocaleString()) : "", + positionSalaryAmount: item.positionSalaryAmount + ? Extension.ToThaiNumber(Number(item.positionSalaryAmount).toLocaleString()) + : "", })) : [ { @@ -1325,11 +1357,17 @@ export class ProfileController extends Controller { order: { createdAt: "ASC" }, }); const actposition = - actposition_raw.length > 0 + actposition_raw.length > 0 ? actposition_raw.map((item) => ({ - date: item.dateStart?Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateStart)):"" + item.dateEnd?" - " + Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateEnd)):"", - refCommandDate: item.refCommandDate?Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.refCommandDate)):"", - refCommandNo: item.refCommandNo?Extension.ToThaiNumber(item.refCommandNo):"", + date: item.dateStart + ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateStart)) + : "" + item.dateEnd + ? " - " + Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateEnd)) + : "", + refCommandDate: item.refCommandDate + ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.refCommandDate)) + : "", + refCommandNo: item.refCommandNo ? Extension.ToThaiNumber(item.refCommandNo) : "", position: item.position, posNo: item.posNo, })) @@ -1347,75 +1385,126 @@ export class ProfileController extends Controller { order: { createdAt: "ASC" }, }); const duty = - duty_raw.length > 0 + duty_raw.length > 0 ? duty_raw.map((item) => ({ - date: item.dateStart?Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateStart)):"" + item.dateEnd?" - " + Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateEnd)):"", - refCommandDate: item.refCommandDate?Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.refCommandDate)):"", - refCommandNo: item.refCommandNo?Extension.ToThaiNumber(item.refCommandNo):"", - })) - : [ - { - date: "-", - refCommandDate: "-", - refCommandNo: "-", - }, - ]; + date: item.dateStart + ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateStart)) + : "" + item.dateEnd + ? " - " + Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateEnd)) + : "", + refCommandDate: item.refCommandDate + ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.refCommandDate)) + : "", + refCommandNo: item.refCommandNo ? Extension.ToThaiNumber(item.refCommandNo) : "", + })) + : [ + { + date: "-", + refCommandDate: "-", + refCommandNo: "-", + }, + ]; const assessments_raw = await this.profileAssessmentsRepository.find({ where: { profileId: id }, order: { createdAt: "ASC" }, }); const assessments = - assessments_raw.length > 0 + assessments_raw.length > 0 ? assessments_raw.map((item) => ({ - year: item.year?Extension.ToThaiNumber(item.year):"", - period: item.period && item.period == "APR"?"เมษายน":"ตุลาคม", - point1: item.point1?Extension.ToThaiNumber((item.point1).toString()):"", - point1Total: item.point1Total?Extension.ToThaiNumber((item.point1Total).toString()):"", - point2: item.point2?Extension.ToThaiNumber((item.point2).toString()):"", - point2Total: item.point2Total?Extension.ToThaiNumber((item.point2Total).toString()):"", - pointSum: item.pointSum?Extension.ToThaiNumber((item.pointSum).toString()):"", - pointSumTh: item.pointSum?Extension.textPoint(item.pointSum):"", - })) - : [ - { - year: "-", - period: "-", - point1: "-", - point2: "-", - pointSum: "-", - pointSumTh: "-", - }, - ]; + year: item.year ? Extension.ToThaiNumber(item.year) : "", + period: item.period && item.period == "APR" ? "เมษายน" : "ตุลาคม", + point1: item.point1 ? Extension.ToThaiNumber(item.point1.toString()) : "", + point1Total: item.point1Total + ? Extension.ToThaiNumber(item.point1Total.toString()) + : "", + point2: item.point2 ? Extension.ToThaiNumber(item.point2.toString()) : "", + point2Total: item.point2Total + ? Extension.ToThaiNumber(item.point2Total.toString()) + : "", + pointSum: item.pointSum ? Extension.ToThaiNumber(item.pointSum.toString()) : "", + pointSumTh: item.pointSum ? Extension.textPoint(item.pointSum) : "", + })) + : [ + { + year: "-", + period: "-", + point1: "-", + point2: "-", + pointSum: "-", + pointSumTh: "-", + }, + ]; const profileAbility_raw = await this.profileAbilityRepo.find({ where: { profileId: id }, order: { createdAt: "ASC" }, }); const profileAbility = - profileAbility_raw.length > 0 + profileAbility_raw.length > 0 ? profileAbility_raw.map((item) => ({ - field: item.field?item.field:"", - detail: item.detail?item.detail:"", - })) - : [ - { - field: "-", - detail: "-", - }, - ]; - const sum = profiles?Extension.ToThaiNumber((Number(profiles.amount) + Number(profiles.positionSalaryAmount) + Number(profiles.mouthSalaryAmount) + Number(profiles.amountSpecial)).toLocaleString()):""; - const fullCurrentAddress = profiles?Extension.ToThaiNumber(profiles.currentAddress + " ตำบล/แขวง " + profiles.currentSubDistrict.name + " อำเภอ/เขต " + profiles.currentDistrict.name + " จังหวัด " + profiles.currentProvince.name + profiles.currentZipCode):""; - const fullRegistrationAddress = profiles?Extension.ToThaiNumber(profiles.registrationAddress + " ตำบล/แขวง " + profiles.registrationSubDistrict.name + " อำเภอ/เขต " + profiles.registrationDistrict.name + " จังหวัด " + profiles.registrationProvince.name + profiles.registrationZipCode):""; + field: item.field ? item.field : "", + detail: item.detail ? item.detail : "", + })) + : [ + { + field: "-", + detail: "-", + }, + ]; + const sum = profiles + ? Extension.ToThaiNumber( + ( + Number(profiles.amount) + + Number(profiles.positionSalaryAmount) + + Number(profiles.mouthSalaryAmount) + + Number(profiles.amountSpecial) + ).toLocaleString(), + ) + : ""; + const fullCurrentAddress = profiles + ? Extension.ToThaiNumber( + profiles.currentAddress + + " ตำบล/แขวง " + + profiles.currentSubDistrict.name + + " อำเภอ/เขต " + + profiles.currentDistrict.name + + " จังหวัด " + + profiles.currentProvince.name + + profiles.currentZipCode, + ) + : ""; + const fullRegistrationAddress = profiles + ? Extension.ToThaiNumber( + profiles.registrationAddress + + " ตำบล/แขวง " + + profiles.registrationSubDistrict.name + + " อำเภอ/เขต " + + profiles.registrationDistrict.name + + " จังหวัด " + + profiles.registrationProvince.name + + profiles.registrationZipCode, + ) + : ""; const data = { fullName: `${profiles?.prefix}${profiles?.firstName} ${profiles?.lastName}`, prefix: profiles?.prefix != null ? profiles.prefix : "", firstName: profiles?.firstName != null ? profiles.firstName : "", lastName: profiles?.lastName != null ? profiles.lastName : "", position: profiles?.position != null ? profiles.position : "", - amount: profiles?.amount != null ? Extension.ToThaiNumber(profiles.amount.toLocaleString()) : "", - positionSalaryAmount: profiles?.positionSalaryAmount != null ? Extension.ToThaiNumber(profiles.positionSalaryAmount.toLocaleString()) : "", - mouthSalaryAmount: profiles?.mouthSalaryAmount != null ? Extension.ToThaiNumber(profiles.mouthSalaryAmount.toLocaleString()) : "", - amountSpecial: profiles?.amountSpecial != null ? Extension.ToThaiNumber(profiles.amountSpecial.toLocaleString()) : "", - salarySum:sum, + amount: + profiles?.amount != null ? Extension.ToThaiNumber(profiles.amount.toLocaleString()) : "", + positionSalaryAmount: + profiles?.positionSalaryAmount != null + ? Extension.ToThaiNumber(profiles.positionSalaryAmount.toLocaleString()) + : "", + mouthSalaryAmount: + profiles?.mouthSalaryAmount != null + ? Extension.ToThaiNumber(profiles.mouthSalaryAmount.toLocaleString()) + : "", + amountSpecial: + profiles?.amountSpecial != null + ? Extension.ToThaiNumber(profiles.amountSpecial.toLocaleString()) + : "", + salarySum: sum, ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, birthDate: profiles?.birthDate ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.birthDate)) @@ -1435,14 +1524,16 @@ export class ProfileController extends Controller { profileFamilyFather?.fatherLastName ? `${profileFamilyFather?.fatherPrefix ?? ""}${profileFamilyFather?.fatherFirstName ?? ""} ${profileFamilyFather?.fatherLastName ?? ""}`.trim() : null, - fatherLive:profileFamilyFather && profileFamilyFather?.fatherLive == true?"มีชีวิต":"ถึงแก่กรรม", + fatherLive: + profileFamilyFather && profileFamilyFather?.fatherLive == true ? "มีชีวิต" : "ถึงแก่กรรม", motherFullName: profileFamilyMother?.motherPrefix || profileFamilyMother?.motherFirstName || profileFamilyMother?.motherLastName ? `${profileFamilyMother?.motherPrefix ?? ""}${profileFamilyMother?.motherFirstName ?? ""} ${profileFamilyMother?.motherLastName ?? ""}`.trim() : null, - motherLive:profileFamilyMother && profileFamilyMother?.motherLive == true?"มีชีวิต":"ถึงแก่กรรม", + motherLive: + profileFamilyMother && profileFamilyMother?.motherLive == true ? "มีชีวิต" : "ถึงแก่กรรม", coupleFullName: profileFamilyCouple?.couplePrefix || profileFamilyCouple?.coupleFirstName || @@ -1450,7 +1541,8 @@ export class ProfileController extends Controller { ? `${profileFamilyCouple?.couplePrefix ?? ""}${profileFamilyCouple?.coupleFirstName ?? ""} ${profileFamilyCouple?.coupleLastName ?? ""}`.trim() : null, coupleLastNameOld: profileFamilyCouple?.coupleLastNameOld ?? null, - coupleLive:profileFamilyCouple && profileFamilyCouple?.coupleLive == true?"มีชีวิต":"ถึงแก่กรรม", + coupleLive: + profileFamilyCouple && profileFamilyCouple?.coupleLive == true ? "มีชีวิต" : "ถึงแก่กรรม", currentAddress: profiles.currentAddress != null ? Extension.ToThaiNumber(profiles.currentAddress) : "", currentSubDistrict: @@ -1466,12 +1558,12 @@ export class ProfileController extends Controller { ? Extension.ToThaiNumber(profiles.currentProvince.name) : "", currentZipcode: - profiles.currentZipCode != null - ? Extension.ToThaiNumber(profiles.currentZipCode) - : "", + profiles.currentZipCode != null ? Extension.ToThaiNumber(profiles.currentZipCode) : "", fullCurrentAddress: fullCurrentAddress, registrationAddress: - profiles.registrationAddress != null ? Extension.ToThaiNumber(profiles.registrationAddress) : "", + profiles.registrationAddress != null + ? Extension.ToThaiNumber(profiles.registrationAddress) + : "", registrationSubDistrict: profiles.registrationSubDistrict != null ? Extension.ToThaiNumber(profiles.registrationSubDistrict.name) diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 9669f637..e1a1f707 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -246,8 +246,11 @@ export class ProfileEmployeeController extends Controller { "positionCee", "positionExecutive", ], - where: { profileEmployeeId: id }, - order: { commandDateAffect: "ASC" }, + where: { + profileEmployeeId: id, + commandCode: In(["1", "2", "3", "4", "8", "10", "11", "12", "15", "16"]), + }, + order: { order: "ASC" }, }); const salarys = salary_raw.length > 1 @@ -2443,9 +2446,10 @@ export class ProfileEmployeeController extends Controller { dateRetireLaw: profile.dateRetireLaw, posMaster: posMaster == null ? null : posMaster.posMasterNo, posMasterNo: posMaster == null ? null : posMaster.posMasterNo, - posLevelName: profile.posLevel == null && profile.posType == null - ? null - : `${profile.posType.posTypeShortName} ${profile.posLevel.posLevelName}`, + posLevelName: + profile.posLevel == null && profile.posType == null + ? null + : `${profile.posType.posTypeShortName} ${profile.posLevel.posLevelName}`, posLevelRank: profile.posLevel == null ? null : profile.posLevel.posLevelRank, posLevelId: profile.posLevel == null ? null : profile.posLevel.id, posTypeName: profile.posType == null ? null : profile.posType.posTypeName, @@ -2836,9 +2840,10 @@ export class ProfileEmployeeController extends Controller { posTypeId: item.posTypeId, posTypeName: item.posType?.posTypeName, posLevelId: item.posLevelId, - posLevelName: item.posLevel == null && item.posType == null - ? null - : `${item.posType?.posTypeShortName} ${item.posLevel?.posLevelName}`, + posLevelName: + item.posLevel == null && item.posType == null + ? null + : `${item.posType?.posTypeShortName} ${item.posLevel?.posLevelName}`, educationDegree: latestProfileEducation != null && latestProfileEducation.educationLevel != null ? latestProfileEducation.educationLevel @@ -4637,9 +4642,10 @@ export class ProfileEmployeeController extends Controller { posTypeId: item.posTypeId, posTypeName: item.posType?.posTypeName, posLevelId: item.posLevelId, - posLevelName: item.posLevel == null && item.posType == null - ? null - : `${item.posType?.posTypeShortName} ${item.posLevel?.posLevelName}`, + posLevelName: + item.posLevel == null && item.posType == null + ? null + : `${item.posType?.posTypeShortName} ${item.posLevel?.posLevelName}`, educationDegree: latestProfileEducation != null && latestProfileEducation.educationLevel != null ? latestProfileEducation.educationLevel diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index e0187366..eb090a7d 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -241,8 +241,11 @@ export class ProfileEmployeeTempController extends Controller { "positionCee", "positionExecutive", ], - where: { profileEmployeeId: id }, - order: { commandDateAffect: "ASC" }, + where: { + profileEmployeeId: id, + commandCode: In(["1", "2", "3", "4", "8", "10", "11", "12", "15", "16"]), + }, + order: { order: "ASC" }, }); const salarys = salary_raw.length > 1 From 53e19272d86459efb087dd5a959993d7ff177caf Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 5 Mar 2025 16:07:14 +0700 Subject: [PATCH 3/3] migrate --- src/entities/TenureLevelEmployee.ts | 88 +++++++++++++++++++ src/entities/TenureLevelOfficer.ts | 88 +++++++++++++++++++ src/entities/TenurePositionEmployee.ts | 71 +++++++++++++++ src/entities/TenurePositionOfficer.ts | 71 +++++++++++++++ .../1741164808500-addNewTable05032025.ts | 21 +++++ 5 files changed, 339 insertions(+) create mode 100644 src/entities/TenureLevelEmployee.ts create mode 100644 src/entities/TenureLevelOfficer.ts create mode 100644 src/entities/TenurePositionEmployee.ts create mode 100644 src/entities/TenurePositionOfficer.ts create mode 100644 src/migration/1741164808500-addNewTable05032025.ts diff --git a/src/entities/TenureLevelEmployee.ts b/src/entities/TenureLevelEmployee.ts new file mode 100644 index 00000000..36ae0176 --- /dev/null +++ b/src/entities/TenureLevelEmployee.ts @@ -0,0 +1,88 @@ +import { + Entity, + Column, + OneToMany, + JoinColumn, + ManyToOne, + Double, + ManyToMany, + JoinTable, +} from "typeorm"; +import { EntityBase } from "./base/Base"; + + +@Entity("tenureLevelEmployee") +export class TenureLevelEmployee extends EntityBase { + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง profileEmployee", + default: null, + }) + profileEmployeeId: string; + + @Column({ + nullable: true, + comment: "ระดับซี", + default: null, + length: 255, + }) + positionCee: string; + + @Column({ + nullable: true, + comment: "จำนวนวัน", + default: null, + }) + days_diff: number; + + @Column({ + nullable: true, + comment: "จำนวนปีดำรงตำแหน่งงปัจจุบัน", + default: null, + }) + Years: number; + + @Column({ + nullable: true, + comment: "จำนวนเดือนดำรงตำแหน่งงปัจจุบัน", + default: null, + }) + Months: number; + + @Column({ + nullable: true, + comment: "จำนวนวันดำรงตำแหน่งงปัจจุบัน", + default: null, + }) + Days: number; + + @Column({ + nullable: true, + comment: "ชื่อประเภทตำแหน่ง", + default: null, + length: 255, + }) + positionType: string; + + @Column({ + nullable: true, + comment: "ชื่อระดับตำแหน่ง", + default: null, + length: 255, + }) + positionLevel: string; +} + +export class CreateTenureLevelOfficer { + profileEmployeeId: string; + positionCee: string | null; + days_diff: number | null; + Years: number | null; + Months: number | null; + Days: number | null; + positionType: string | null; + positionLevel: string | null; +} + + diff --git a/src/entities/TenureLevelOfficer.ts b/src/entities/TenureLevelOfficer.ts new file mode 100644 index 00000000..d6df2399 --- /dev/null +++ b/src/entities/TenureLevelOfficer.ts @@ -0,0 +1,88 @@ +import { + Entity, + Column, + OneToMany, + JoinColumn, + ManyToOne, + Double, + ManyToMany, + JoinTable, +} from "typeorm"; +import { EntityBase } from "./base/Base"; + + +@Entity("tenureLevelOfficer") +export class TenureLevelOfficer extends EntityBase { + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง Profile", + default: null, + }) + profileId: string; + + @Column({ + nullable: true, + comment: "ระดับซี", + default: null, + length: 255, + }) + positionCee: string; + + @Column({ + nullable: true, + comment: "จำนวนวัน", + default: null, + }) + days_diff: number; + + @Column({ + nullable: true, + comment: "จำนวนปีดำรงตำแหน่งงปัจจุบัน", + default: null, + }) + Years: number; + + @Column({ + nullable: true, + comment: "จำนวนเดือนดำรงตำแหน่งงปัจจุบัน", + default: null, + }) + Months: number; + + @Column({ + nullable: true, + comment: "จำนวนวันดำรงตำแหน่งงปัจจุบัน", + default: null, + }) + Days: number; + + @Column({ + nullable: true, + comment: "ชื่อประเภทตำแหน่ง", + default: null, + length: 255, + }) + positionType: string; + + @Column({ + nullable: true, + comment: "ชื่อระดับตำแหน่ง", + default: null, + length: 255, + }) + positionLevel: string; +} + +export class CreateTenureLevelOfficer { + profileId: string; + positionCee: string | null; + days_diff: number | null; + Years: number | null; + Months: number | null; + Days: number | null; + positionType: string | null; + positionLevel: string | null; +} + + diff --git a/src/entities/TenurePositionEmployee.ts b/src/entities/TenurePositionEmployee.ts new file mode 100644 index 00000000..a246cbd0 --- /dev/null +++ b/src/entities/TenurePositionEmployee.ts @@ -0,0 +1,71 @@ +import { + Entity, + Column, + OneToMany, + JoinColumn, + ManyToOne, + Double, + ManyToMany, + JoinTable, +} from "typeorm"; +import { EntityBase } from "./base/Base"; + + +@Entity("tenurePositionEmployee") +export class TenurePositionEmployee extends EntityBase { + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง ProfileEmployee", + default: null, + }) + profileEmployeeId: string; + + @Column({ + nullable: true, + comment: "ชื่อตำแหน่ง", + default: null, + length: 255, + }) + positionName: string; + + @Column({ + nullable: true, + comment: "จำนวนวัน", + default: null, + }) + days_diff: number; + + @Column({ + nullable: true, + comment: "จำนวนปีดำรงตำแหน่งงปัจจุบัน", + default: null, + }) + Years: number; + + @Column({ + nullable: true, + comment: "จำนวนเดือนดำรงตำแหน่งงปัจจุบัน", + default: null, + }) + Months: number; + + @Column({ + nullable: true, + comment: "จำนวนวันดำรงตำแหน่งงปัจจุบัน", + default: null, + }) + Days: number; + +} + +export class CreateTenurePositionEmployee { + profileEmployeeId: string; + positionName: string | null; + days_diff: number | null; + Years: number | null; + Months: number | null; + Days: number | null; +} + + diff --git a/src/entities/TenurePositionOfficer.ts b/src/entities/TenurePositionOfficer.ts new file mode 100644 index 00000000..3d4efe43 --- /dev/null +++ b/src/entities/TenurePositionOfficer.ts @@ -0,0 +1,71 @@ +import { + Entity, + Column, + OneToMany, + JoinColumn, + ManyToOne, + Double, + ManyToMany, + JoinTable, +} from "typeorm"; +import { EntityBase } from "./base/Base"; + + +@Entity("tenurePositionOfficer") +export class TenurePositionOfficer extends EntityBase { + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง Profile", + default: null, + }) + profileId: string; + + @Column({ + nullable: true, + comment: "ชื่อตำแหน่ง", + default: null, + length: 255, + }) + positionName: string; + + @Column({ + nullable: true, + comment: "จำนวนวัน", + default: null, + }) + days_diff: number; + + @Column({ + nullable: true, + comment: "จำนวนปีดำรงตำแหน่งงปัจจุบัน", + default: null, + }) + Years: number; + + @Column({ + nullable: true, + comment: "จำนวนเดือนดำรงตำแหน่งงปัจจุบัน", + default: null, + }) + Months: number; + + @Column({ + nullable: true, + comment: "จำนวนวันดำรงตำแหน่งงปัจจุบัน", + default: null, + }) + Days: number; + +} + +export class CreateTenurePositionOfficer { + profileId: string; + positionName: string | null; + days_diff: number | null; + Years: number | null; + Months: number | null; + Days: number | null; +} + + diff --git a/src/migration/1741164808500-addNewTable05032025.ts b/src/migration/1741164808500-addNewTable05032025.ts new file mode 100644 index 00000000..3d7539ec --- /dev/null +++ b/src/migration/1741164808500-addNewTable05032025.ts @@ -0,0 +1,21 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddNewTable050320251741164808500 implements MigrationInterface { + name = 'AddNewTable050320251741164808500' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE TABLE \`tenurePositionEmployee\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`profileEmployeeId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง ProfileEmployee', \`positionName\` varchar(255) NULL COMMENT 'ชื่อตำแหน่ง', \`days_diff\` int NULL COMMENT 'จำนวนวัน', \`Years\` int NULL COMMENT 'จำนวนปีดำรงตำแหน่งงปัจจุบัน', \`Months\` int NULL COMMENT 'จำนวนเดือนดำรงตำแหน่งงปัจจุบัน', \`Days\` int NULL COMMENT 'จำนวนวันดำรงตำแหน่งงปัจจุบัน', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`CREATE TABLE \`tenurePositionOfficer\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`profileId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง Profile', \`positionName\` varchar(255) NULL COMMENT 'ชื่อตำแหน่ง', \`days_diff\` int NULL COMMENT 'จำนวนวัน', \`Years\` int NULL COMMENT 'จำนวนปีดำรงตำแหน่งงปัจจุบัน', \`Months\` int NULL COMMENT 'จำนวนเดือนดำรงตำแหน่งงปัจจุบัน', \`Days\` int NULL COMMENT 'จำนวนวันดำรงตำแหน่งงปัจจุบัน', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`CREATE TABLE \`tenureLevelEmployee\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`profileEmployeeId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง profileEmployee', \`positionCee\` varchar(255) NULL COMMENT 'ระดับซี', \`days_diff\` int NULL COMMENT 'จำนวนวัน', \`Years\` int NULL COMMENT 'จำนวนปีดำรงตำแหน่งงปัจจุบัน', \`Months\` int NULL COMMENT 'จำนวนเดือนดำรงตำแหน่งงปัจจุบัน', \`Days\` int NULL COMMENT 'จำนวนวันดำรงตำแหน่งงปัจจุบัน', \`positionType\` varchar(255) NULL COMMENT 'ชื่อประเภทตำแหน่ง', \`positionLevel\` varchar(255) NULL COMMENT 'ชื่อระดับตำแหน่ง', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`CREATE TABLE \`tenureLevelOfficer\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`profileId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง Profile', \`positionCee\` varchar(255) NULL COMMENT 'ระดับซี', \`days_diff\` int NULL COMMENT 'จำนวนวัน', \`Years\` int NULL COMMENT 'จำนวนปีดำรงตำแหน่งงปัจจุบัน', \`Months\` int NULL COMMENT 'จำนวนเดือนดำรงตำแหน่งงปัจจุบัน', \`Days\` int NULL COMMENT 'จำนวนวันดำรงตำแหน่งงปัจจุบัน', \`positionType\` varchar(255) NULL COMMENT 'ชื่อประเภทตำแหน่ง', \`positionLevel\` varchar(255) NULL COMMENT 'ชื่อระดับตำแหน่ง', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`DROP TABLE \`tenureLevelOfficer\``); + await queryRunner.query(`DROP TABLE \`tenureLevelEmployee\``); + await queryRunner.query(`DROP TABLE \`tenurePositionOfficer\``); + await queryRunner.query(`DROP TABLE \`tenurePositionEmployee\``); + } + +} \ No newline at end of file