From 5d4727761f0cd19ae5b64330aaad4704bae7c36f Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Tue, 1 Apr 2025 20:46:30 +0700 Subject: [PATCH 1/3] =?UTF-8?q?fix=20=E0=B8=9E=E0=B9=89=E0=B8=99=E0=B8=9E?= =?UTF-8?q?=E0=B8=99=E0=B8=B1=E0=B8=81=E0=B8=87=E0=B8=B2=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileEmployeeController.ts | 34 ++++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 666d0704..b096e7ec 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -1718,25 +1718,25 @@ export class ProfileEmployeeController extends Controller { if (orgRoot) { nodeCondition = "profileSalary.orgRoot = :orgRoot"; } - if (isAll == false) nodeAll = " AND profileSalary.orgChild1Id IS NULL"; + if (isAll == false) nodeAll = " AND profileSalary.orgChild1 IS NULL"; } else if (node === 1 && nodeId) { orgChild1 = await this.child1Repository.findOne({where: { id: nodeId }}); if (orgChild1) { nodeCondition = "profileSalary.orgChild1 = :orgChild1"; } - if (isAll == false) nodeAll = " AND profileSalary.orgChild2Id IS NULL"; + if (isAll == false) nodeAll = " AND profileSalary.orgChild2 IS NULL"; } else if (node === 2 && nodeId) { orgChild2 = await this.child2Repository.findOne({where: { id: nodeId }}); if (orgChild2) { nodeCondition = "profileSalary.orgChild2 = :orgChild2"; } - if (isAll == false) nodeAll = " AND profileSalary.orgChild3Id IS NULL"; + if (isAll == false) nodeAll = " AND profileSalary.orgChild3 IS NULL"; } else if (node === 3 && nodeId) { orgChild3 = await this.child3Repository.findOne({where: { id: nodeId }}); if (orgChild3) { nodeCondition = "profileSalary.orgChild3 = :orgChild3"; } - if (isAll == false) nodeAll = " AND profileSalary.orgChild4Id IS NULL"; + if (isAll == false) nodeAll = " AND profileSalary.orgChild4 IS NULL"; } else if (node === 4 && nodeId) { orgChild4 = await this.child4Repository.findOne({where: { id: nodeId }}); if (orgChild4) { @@ -1750,27 +1750,32 @@ export class ProfileEmployeeController extends Controller { if (orgRootPms) { pmsCondition = "profileSalary.orgRoot = :orgRoot"; } + if (isAll == false) nodeAll = " AND profileSalary.orgChild1 IS NULL"; } else if (_data.child1) { orgChild1Pms = await this.child1Repository.findOne({where: { id: _data.child1 }}); if (orgChild1Pms) { pmsCondition = "profileSalary.orgChild1 = :orgChild1"; } + if (isAll == false) nodeAll = " AND profileSalary.orgChild2 IS NULL"; } else if (_data.child2) { orgChild2Pms = await this.child2Repository.findOne({where: { id: _data.child2 }}); if (orgChild2Pms) { pmsCondition = "profileSalary.orgChild2 = :orgChild2"; } + if (isAll == false) nodeAll = " AND profileSalary.orgChild3 IS NULL"; } else if (_data.child3) { orgChild3Pms = await this.child3Repository.findOne({where: { id: _data.child3 }}); if (orgChild3Pms) { pmsCondition = "profileSalary.orgChild3 = :orgChild3"; } + if (isAll == false) nodeAll = " AND profileSalary.orgChild4 IS NULL"; } else if (_data.child4) { orgChild4Pms = await this.child4Repository.findOne({where: { id: _data.child4 }}); if (orgChild4Pms) { pmsCondition = "profileSalary.orgChild4 = :orgChild4"; } } + pmsCondition = pmsCondition + nodeAll; // const findRevision = await this.orgRevisionRepo.findOne({ // where: { orgRevisionIsCurrent: true }, // }); @@ -1800,6 +1805,7 @@ export class ProfileEmployeeController extends Controller { .orWhere("profileEmployee.isRetirement = :isRetirement", { isRetirement: true }); }) ) + .andWhere("profileEmployee.leaveCommandId Is NOT NULL") .andWhere("profileSalary.order = (SELECT MAX(ps.order) FROM profileSalary ps WHERE ps.profileEmployeeId = profileEmployee.id)") // .andWhere( @@ -1885,19 +1891,19 @@ export class ProfileEmployeeController extends Controller { }, ) .andWhere(pmsCondition, { - orgRoot: orgRootPms ? orgRootPms.orgRootName : undefined, - orgChild1: orgChild1Pms ? orgChild1Pms.orgChild1Name : undefined, - orgChild2: orgChild2Pms ? orgChild2Pms.orgChild2Name : undefined, - orgChild3: orgChild3Pms ? orgChild3Pms.orgChild3Name : undefined, - orgChild4: orgChild4Pms ? orgChild4Pms.orgChild4Name : undefined, + orgRootPms: orgRootPms ? orgRootPms.orgRootName : "", + orgChild1Pms: orgChild1Pms ? orgChild1Pms.orgChild1Name : "", + orgChild2Pms: orgChild2Pms ? orgChild2Pms.orgChild2Name : "", + orgChild3Pms: orgChild3Pms ? orgChild3Pms.orgChild3Name : "", + orgChild4Pms: orgChild4Pms ? orgChild4Pms.orgChild4Name : "", }) .andWhere(nodeCondition, { - orgRoot: orgRoot ? orgRoot.orgRootName : undefined, - orgChild1: orgChild1 ? orgChild1.orgChild1Name : undefined, - orgChild2: orgChild2 ? orgChild2.orgChild2Name : undefined, - orgChild3: orgChild3 ? orgChild3.orgChild3Name : undefined, - orgChild4: orgChild4 ? orgChild4.orgChild4Name : undefined, + orgRoot: orgRoot ? orgRoot.orgRootName : "", + orgChild1: orgChild1 ? orgChild1.orgChild1Name : "", + orgChild2: orgChild2 ? orgChild2.orgChild2Name : "", + orgChild3: orgChild3 ? orgChild3.orgChild3Name : "", + orgChild4: orgChild4 ? orgChild4.orgChild4Name : "", }) // .andWhere(`current_holders.orgRevisionId LIKE :orgRevisionId`, { // orgRevisionId: findRevision.id, From 7d23d00a0611189efacfc59a22d6d7b723857589 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 2 Apr 2025 10:01:00 +0700 Subject: [PATCH 2/3] add viewPosmaster --- src/entities/view/viewPosMaster.ts | 171 +++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 src/entities/view/viewPosMaster.ts diff --git a/src/entities/view/viewPosMaster.ts b/src/entities/view/viewPosMaster.ts new file mode 100644 index 00000000..40f7d2dc --- /dev/null +++ b/src/entities/view/viewPosMaster.ts @@ -0,0 +1,171 @@ +import { ViewColumn, ViewEntity } from "typeorm"; + +@ViewEntity({ + expression: `SELECT + posMaster.id, + posMaster.posMasterNoPrefix, + posMaster.posMasterNo, + posMaster.posMasterNoSuffix, + posMaster.orgRootId, + posMaster.orgChild1Id, + posMaster.orgChild2Id, + posMaster.orgChild3Id, + posMaster.orgChild4Id, + posMaster.current_holderId, + profile.id as profileId, + profile.prefix, + profile.firstName, + profile.lastName, + profile.citizenId, + profile.position, + profile.amount, + profile.dateRetire, + profile.birthDate, + orgRoot.id as rootId, + orgRoot.orgRootShortName, + orgChild1.id as child1Id, + orgChild1.orgChild1Name, + orgChild2.id as child2Id, + orgChild2.orgChild2Name, + orgChild3.id as child3Id, + orgChild3.orgChild3Name, + orgChild4.id as child4Id, + orgChild4.orgChild4Name, + position.id as positionId, + position.positionIsSelected, + position.posExecutiveId, + position.isSpecial, + posExecutive.id as posExecutiveId, + posExecutive.posExecutiveName, + profileDiscipline.id as profileDisciplineId, + profileDiscipline.date as disCriplineDate, + profileLeave.id as profileLeaveId, + profileAssessment.id as profileAssessmentId, + profileAssessment.pointSum, + posLevel.id as posLevelId, + posLevel.posLevelName, + posType.id as posTypeId, + posType.posTypeName + FROM + posMaster + LEFT JOIN + profile ON posMaster.current_holderId = profile.id + LEFT JOIN + orgRoot ON posMaster.orgRootId = orgRoot.id + LEFT JOIN + orgChild1 ON posMaster.orgChild1Id = orgChild1.id + LEFT JOIN + orgChild2 ON posMaster.orgChild2Id = orgChild2.id + LEFT JOIN + orgChild3 ON posMaster.orgChild3Id = orgChild3.id + LEFT JOIN + orgChild4 ON posMaster.orgChild4Id = orgChild4.id + LEFT JOIN + position ON posMaster.id = position.posMasterId + LEFT JOIN + posExecutive ON position.posExecutiveId = posExecutive.id + LEFT JOIN + profileDiscipline ON profileDiscipline.profileId = profile.id + LEFT JOIN + profileLeave ON profileLeave.profileId = profile.id + LEFT JOIN + profileAssessment ON profileAssessment.profileId = profile.id + LEFT JOIN + posLevel ON profile.posLevelId = posLevel.id + LEFT JOIN + posType ON profile.posTypeId = posType.id + WHERE + posMaster.current_holderId IS NOT NULL + ORDER BY + profile.citizenId ASC + `, +}) + +export class viewPosMaster { + @ViewColumn() + id: string; + @ViewColumn() + posMasterNoPrefix: string; + @ViewColumn() + posMasterNo: number; + @ViewColumn() + posMasterNoSuffix: string; + @ViewColumn() + orgRootId: string; + @ViewColumn() + orgChild1Id: string; + @ViewColumn() + orgChild2Id: string; + @ViewColumn() + orgChild3Id: string; + @ViewColumn() + orgChild4Id: string; + @ViewColumn() + current_holderId: string; + @ViewColumn() + profileId: string; + @ViewColumn() + prefix: string; + @ViewColumn() + firstName: string; + @ViewColumn() + lastName: string; + @ViewColumn() + citizenId: number; + @ViewColumn() + position: string; + @ViewColumn() + amount: number; + @ViewColumn() + dateRetire: Date; + @ViewColumn() + birthDate: Date; + @ViewColumn() + rootId: string; + @ViewColumn() + orgRootShortName: string; + @ViewColumn() + child1Id: string; + @ViewColumn() + orgChild1Name: string; + @ViewColumn() + child2Id: string; + @ViewColumn() + orgChild2Name: string; + @ViewColumn() + child3Id: string; + @ViewColumn() + orgChild3Name: string; + @ViewColumn() + child4Id: string; + @ViewColumn() + orgChild4Name: string; + @ViewColumn() + positionId: string; + @ViewColumn() + positionIsSelected: boolean; + @ViewColumn() + posExecutiveId: string; + @ViewColumn() + isSpecial: boolean; + @ViewColumn() + posExcutiveId: string; + @ViewColumn() + profileDisciplineId: string; + @ViewColumn() + disCriplineDate: Date; + @ViewColumn() + profileLeaveId: string; + @ViewColumn() + profileAssessmentId: string; + @ViewColumn() + pointSum: string; + @ViewColumn() + posLevelId: string; + @ViewColumn() + posLevelName: string; + @ViewColumn() + posTypeId: string; + @ViewColumn() + posTypeName: string; +} From 0a217642a0f34fcaeef11c859487ed838ea0efe1 Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 2 Apr 2025 10:10:21 +0700 Subject: [PATCH 3/3] =?UTF-8?q?fix=20bug=20=E0=B8=AD=E0=B8=AD=E0=B8=81?= =?UTF-8?q?=E0=B8=84=E0=B8=B3=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87=E0=B9=84?= =?UTF-8?q?=E0=B8=A1=E0=B9=88=E0=B8=9A=E0=B8=B1=E0=B8=99=E0=B8=97=E0=B8=B7?= =?UTF-8?q?=E0=B8=81=E0=B8=A5=E0=B8=87=E0=B8=97=E0=B8=B0=E0=B9=80=E0=B8=9A?= =?UTF-8?q?=E0=B8=B5=E0=B8=A2=E0=B8=99=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=A7?= =?UTF-8?q?=E0=B8=B1=E0=B8=95=E0=B8=B4=20(=E0=B9=80=E0=B8=9B=E0=B8=A5?= =?UTF-8?q?=E0=B8=B5=E0=B9=88=E0=B8=A2=E0=B8=99=20type=20=E0=B8=95?= =?UTF-8?q?=E0=B8=B1=E0=B8=A7=E0=B9=81=E0=B8=9B=E0=B8=A3=20refId)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entities/ProfileSalary.ts | 2 +- src/entities/ProfileSalaryTemp.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/entities/ProfileSalary.ts b/src/entities/ProfileSalary.ts index 4e10c0b5..63564aba 100644 --- a/src/entities/ProfileSalary.ts +++ b/src/entities/ProfileSalary.ts @@ -209,7 +209,7 @@ export class ProfileSalary extends EntityBase { comment: "refId", default: null, }) - refId: number; + refId: string; @Column({ comment: "วันที่", diff --git a/src/entities/ProfileSalaryTemp.ts b/src/entities/ProfileSalaryTemp.ts index 556fd584..f322045b 100644 --- a/src/entities/ProfileSalaryTemp.ts +++ b/src/entities/ProfileSalaryTemp.ts @@ -222,7 +222,7 @@ export class ProfileSalaryTemp extends EntityBase { comment: "refId", default: null, }) - refId: number; + refId: string; @Column({ comment: "วันที่",