From e71103781cea67f1fd19bf6e7b1ca2375007f8fe Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Thu, 1 May 2025 13:14:38 +0700 Subject: [PATCH] update --- src/controllers/OrganizationUnauthorizeController.ts | 4 ++-- src/entities/view/viewEmployeePosMaster.ts | 11 +++++++++-- src/entities/view/viewPosMaster.ts | 11 +++++++++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/controllers/OrganizationUnauthorizeController.ts b/src/controllers/OrganizationUnauthorizeController.ts index 9fcaea84..234c2ec9 100644 --- a/src/controllers/OrganizationUnauthorizeController.ts +++ b/src/controllers/OrganizationUnauthorizeController.ts @@ -320,10 +320,10 @@ export class OrganizationUnauthorizeController extends Controller { const rootIds = [ "d7e98989-b5ce-47d6-93c3-ab63ed486348", "e0545eca-5d0a-4a1c-8bbd-e3e25c2521db", - "7ff1fbf2-cc9e-4f53-b83c-334967c27967", "26989ffa-d5ab-4bbd-ac97-130646cd1da6", "6f9b30e1-757a-40d5-b053-61eb1b91c0f0", "eaf65f33-25e9-4956-9dba-5d909f5eb595", + "a3efed2c-3f4b-476d-95e6-9f7e0585ae25", ]; const [findPosMaster, total] = await AppDataSource.getRepository(viewPosMaster) @@ -756,10 +756,10 @@ export class OrganizationUnauthorizeController extends Controller { const rootIds = [ "d7e98989-b5ce-47d6-93c3-ab63ed486348", "e0545eca-5d0a-4a1c-8bbd-e3e25c2521db", - "7ff1fbf2-cc9e-4f53-b83c-334967c27967", "26989ffa-d5ab-4bbd-ac97-130646cd1da6", "6f9b30e1-757a-40d5-b053-61eb1b91c0f0", "eaf65f33-25e9-4956-9dba-5d909f5eb595", + "a3efed2c-3f4b-476d-95e6-9f7e0585ae25", ]; const [findPosMaster, total] = await AppDataSource.getRepository(viewEmployeePosMaster) diff --git a/src/entities/view/viewEmployeePosMaster.ts b/src/entities/view/viewEmployeePosMaster.ts index 5811f8a2..53f565aa 100644 --- a/src/entities/view/viewEmployeePosMaster.ts +++ b/src/entities/view/viewEmployeePosMaster.ts @@ -78,8 +78,15 @@ import { ViewColumn, ViewEntity } from "typeorm"; position ON employeePosMaster.id = position.posMasterId LEFT JOIN posExecutive ON position.posExecutiveId = posExecutive.id - LEFT JOIN - profileDiscipline ON profileDiscipline.profileId = profileEmployee.id + LEFT JOIN ( + SELECT * + FROM profileDisciplineEmployee pd1 + WHERE pd1.date = ( + SELECT MAX(pd2.date) + FROM profileDisciplineEmployee pd2 + WHERE pd2.profileId = pd1.profileId + ) + ) AS profileDiscipline ON profileDiscipline.profileId = profileEmployee.id LEFT JOIN profileLeave ON profileLeave.profileId = profileEmployee.id LEFT JOIN diff --git a/src/entities/view/viewPosMaster.ts b/src/entities/view/viewPosMaster.ts index c070c7b5..1d102f02 100644 --- a/src/entities/view/viewPosMaster.ts +++ b/src/entities/view/viewPosMaster.ts @@ -75,8 +75,15 @@ import { ViewColumn, ViewEntity } from "typeorm"; position ON posMaster.id = position.posMasterId LEFT JOIN posExecutive ON position.posExecutiveId = posExecutive.id - LEFT JOIN - profileDiscipline ON profileDiscipline.profileId = profile.id + LEFT JOIN ( + SELECT * + FROM profileDiscipline pd1 + WHERE pd1.date = ( + SELECT MAX(pd2.date) + FROM profileDiscipline pd2 + WHERE pd2.profileId = pd1.profileId + ) + ) AS profileDiscipline ON profileDiscipline.profileId = profile.id LEFT JOIN profileLeave ON profileLeave.profileId = profile.id LEFT JOIN