From e1b4f9f9294576d55e7345d3fc86e45f0ee0a138 Mon Sep 17 00:00:00 2001 From: Adisak Date: Thu, 13 Nov 2025 13:13:03 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=82=E0=B8=AD=E0=B9=82=E0=B8=AD=E0=B8=99?= =?UTF-8?q?=E0=B8=A5=E0=B8=9A=E0=B8=84=E0=B8=99=20+=20=E0=B9=80=E0=B8=9E?= =?UTF-8?q?=E0=B8=B4=E0=B9=88=E0=B8=A1=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=A7?= =?UTF-8?q?=E0=B8=B1=E0=B8=95=E0=B8=B4=E0=B8=95=E0=B8=B3=E0=B9=81=E0=B8=AB?= =?UTF-8?q?=E0=B8=99=E0=B9=88=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/CommandController.ts | 57 ++++++---------------------- 1 file changed, 12 insertions(+), 45 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index aa4f6678..77e87ede 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -4175,39 +4175,7 @@ export class CommandController extends Controller { return new HttpSuccess(); } - @Get("testPosMaster/{profileId}") - public async newnwenew( - @Request() req:RequestWithUser, - @Path() profileId:string - ){ - const profile: any = await this.profileRepository.findOne({ - where: { - id: profileId , - // current_holders: { - // orgRevision: { - // orgRevisionIsCurrent: true, - // orgRevisionIsDraft: false, - // }, - // } - }, - relations: ["current_holders","roleKeycloaks"], - }); - const orgRevision = await this.orgRevisionRepo.findOne({ - where: { - orgRevisionIsCurrent: true, - orgRevisionIsDraft: false, - }, - }); - - const orgRevisionRef = - profile?.current_holders?.find((x:any) => x.orgRevisionId == orgRevision?.id) ?? null; - console.log("profile.current_holders.id>>>",orgRevisionRef.id); - await CreatePosMasterHistoryOfficer(orgRevisionRef.id, req, "DELETE"); - console.log("profile.id>>>",profile.id); - await removeProfileInOrganize(profile.id, "OFFICER"); - return new HttpSuccess(profile) - } @Post("excexute/salary") public async newSalaryAndUpdate( @Request() req: RequestWithUser, @@ -4298,21 +4266,24 @@ export class CommandController extends Controller { body.data.map(async (item) => { const profile: any = await this.profileRepository.findOne({ where: { id: item.profileId }, - relations: ["current_holders","roleKeycloaks"], + relations: ["roleKeycloaks"], }); if (!profile) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้"); } - - const orgRevision = await this.orgRevisionRepo.findOne({ - where: { - orgRevisionIsCurrent: true, - orgRevisionIsDraft: false, + const posMaster: any = await this.posMasterRepository.findOne({ + where: { + current_holderId: item.profileId, + orgRevision:{ + orgRevisionIsCurrent: true, + orgRevisionIsDraft: false, + } }, + relations:['orgRevision'] }); - const orgRevisionRef = - profile?.current_holders?.find((x:any) => x.orgRevisionId == orgRevision?.id) ?? null; + + const orgRevisionRef = posMaster?posMaster.id: null; //ลบตำแหน่งที่รักษาการแทน const code = _command?.commandType?.code; @@ -4341,12 +4312,8 @@ export class CommandController extends Controller { createdAt: new Date(), lastUpdatedAt: new Date(), }; - if (orgRevisionRef && item.isLeave == true){ - console.log("profile.current_holders.id>>>",orgRevisionRef.id); - await CreatePosMasterHistoryOfficer(orgRevisionRef.id, req, "DELETE"); - } if (item.isLeave != undefined && item.isLeave == true) { - console.log("profile.id>>>",profile.id); + await CreatePosMasterHistoryOfficer(orgRevisionRef, req, "DELETE"); await removeProfileInOrganize(profile.id, "OFFICER"); } const clearProfile = await checkCommandType(String(item.commandId));