From 8f6637a6565698766dad92ce351a48d7bfc097fb Mon Sep 17 00:00:00 2001 From: Adisak Date: Tue, 25 Nov 2025 13:36:17 +0700 Subject: [PATCH 1/2] =?UTF-8?q?=E0=B8=AD=E0=B8=B1=E0=B8=9E=E0=B9=80?= =?UTF-8?q?=E0=B8=94=E0=B8=97=20view=5Fpos=5Fmaster?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entities/view/viewPosMaster.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/entities/view/viewPosMaster.ts b/src/entities/view/viewPosMaster.ts index 58d341d3..c44aa2d6 100644 --- a/src/entities/view/viewPosMaster.ts +++ b/src/entities/view/viewPosMaster.ts @@ -78,14 +78,18 @@ import { ViewColumn, ViewEntity } from "typeorm"; LEFT JOIN posExecutive ON position.posExecutiveId = posExecutive.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 + SELECT * + FROM ( + SELECT + pd.*, + ROW_NUMBER() OVER ( + PARTITION BY profileId + ORDER BY date DESC, id DESC + ) AS rn + FROM profileDiscipline pd + ) t + WHERE rn = 1 + ) AS profileDiscipline ON profileDiscipline.profileId = profile.id LEFT JOIN ( SELECT pl1.* FROM profileLeave pl1 From 4c3d3dceffadb8e21e9d970e7b11c25db0d4907a Mon Sep 17 00:00:00 2001 From: harid Date: Tue, 25 Nov 2025 17:11:51 +0700 Subject: [PATCH 2/2] =?UTF-8?q?=E0=B8=AD=E0=B8=B1=E0=B8=9E=E0=B9=80?= =?UTF-8?q?=E0=B8=94=E0=B8=95=E0=B8=9F=E0=B8=B4=E0=B8=A5=E0=B8=94=E0=B9=8C?= =?UTF-8?q?=20prefixMain=20#2033?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/CommandController.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 3435a0c7..b6b5fc7d 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -6041,6 +6041,7 @@ export class CommandController extends Controller { profile.isProbation = item.bodyProfile.isProbation; //เพิ่มใหม่จากรับโอน profile.prefix = item.bodyProfile.prefix ?? null; + profile.prefixMain = item.bodyProfile.prefix ?? null; profile.firstName = item.bodyProfile.firstName ?? null; profile.lastName = item.bodyProfile.lastName ?? null; profile.birthDate = item.bodyProfile.birthDate ?? null; @@ -6093,6 +6094,7 @@ export class CommandController extends Controller { profile.amountSpecial = item.bodyProfile.amountSpecial ?? null; profile.isProbation = item.bodyProfile.isProbation; profile.prefix = item.bodyProfile.prefix ?? null; + profile.prefixMain = item.bodyProfile.prefix ?? null; profile.firstName = item.bodyProfile.firstName ?? null; profile.lastName = item.bodyProfile.lastName ?? null; profile.birthDate = item.bodyProfile.birthDate ?? null; @@ -6152,6 +6154,7 @@ export class CommandController extends Controller { item.bodyProfile.prefix && item.bodyProfile.prefix != "" ? item.bodyProfile.prefix : profile.prefix; + profile.prefixMain = item.bodyProfile.prefix ?? null; profile.firstName = item.bodyProfile.firstName && item.bodyProfile.firstName != "" ? item.bodyProfile.firstName