From 94eb53bcc9edd6b9a62056a7e071dba5f916127a Mon Sep 17 00:00:00 2001 From: Bright Date: Fri, 31 Jan 2025 16:20:08 +0700 Subject: [PATCH] fix report & find commander --- src/controllers/ProfileController.ts | 11 ++++++++--- src/controllers/ReportController.ts | 4 +++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 779b4aca..2c234b72 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -1152,9 +1152,11 @@ export class ProfileController extends Controller { const profile = await this.profileRepo.findOne({ where: { keycloak: request.user.sub }, }); - const posMaster = await this.posMasterRepo.findOne({ - where: { current_holderId: profile?.id }, + where: { + current_holderId: profile?.id, + orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true }, + }, }); if (!posMaster) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลการครองตำแหน่ง"); const orgRoot = posMaster.orgRootId; @@ -1870,7 +1872,10 @@ export class ProfileController extends Controller { }); const posMaster = await this.posMasterRepo.findOne({ - where: { current_holderId: profile?.id }, + where: { + current_holderId: profile?.id, + orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true }, + }, }); if (!posMaster) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลการครองตำแหน่ง"); const orgRoot = posMaster.orgRootId; diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 35d96c19..1139f2d3 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -6603,6 +6603,7 @@ export class ReportController extends Controller { typeRank: [...new Set(x.positions.flatMap((y) => y.posType.posTypeRank))].join(""), level: [...new Set(x.positions.flatMap((y) => y.posLevel.posLevelName))].join(","), levelRank: [...new Set(x.positions.flatMap((y) => `${y.posType.posTypeRank}${y.posLevel.posLevelRank}`))].join(""), + positions: [...new Set(x.positions.flatMap((y) => y.positionName))].join(""), })) const groupedData = _posMaster.reduce((acc:any, curr:any) => { @@ -6621,8 +6622,9 @@ export class ReportController extends Controller { typeRank: parseInt(x.typeRank), level: x.level, levelRank: parseInt(x.levelRank), + total: x.total, - remark: "", + remark: x.positions, })) .sort((x, y) => { if (x.typeRank !== y.typeRank) {