From 3d1179adc7e0e3a9ab52c32ab4dd2677d316d458 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 7 May 2025 17:41:49 +0700 Subject: [PATCH] fix command21 --- src/controllers/CommandController.ts | 30 ++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 6ea3bf75..f806b20b 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -5804,7 +5804,7 @@ export class CommandController extends Controller { body.refIds.map(async (item) => { const profile = await this.profileEmployeeRepository.findOne({ where: { id: item.refId }, - relations: ["roleKeycloaks"], + relations: ["roleKeycloaks",], }); if (!profile) { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); @@ -5815,6 +5815,8 @@ export class CommandController extends Controller { orgRevisionIsDraft: false, }, }); + const orgRevisionRef = + profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null; const _posMaster = await this.employeePosMasterRepository.findOne({ where: { orgRevisionId: orgRevision?.id, @@ -5829,6 +5831,11 @@ export class CommandController extends Controller { orgChild4: true, }, }); + const orgRootRef = _posMaster?.orgRoot ?? null; + const orgChild1Ref = _posMaster?.orgChild1 ?? null; + const orgChild2Ref = _posMaster?.orgChild2 ?? null; + const orgChild3Ref = _posMaster?.orgChild3 ?? null; + const orgChild4Ref = _posMaster?.orgChild4 ?? null; let orgShortName = ""; if (_posMaster != null) { if (_posMaster.orgChild1Id === null) { @@ -5859,14 +5866,15 @@ export class CommandController extends Controller { positionSalaryAmount: item.positionSalaryAmount, mouthSalaryAmount: item.mouthSalaryAmount, position: profile.positionTemp, + positionName: profile.positionTemp, positionType: profile.posTypeNameTemp, positionLevel: profile.posLevelNameTemp, order: dest_item == null ? 1 : dest_item.order + 1, - // orgRoot: orgRootRef?.orgRootName??null, - // orgChild1: orgChild1Ref?.orgChild1Name??null, - // orgChild2: orgChild2Ref?.orgChild2Name??null, - // orgChild3: orgChild3Ref?.orgChild3Name??null, - // orgChild4: orgChild4Ref?.orgChild4Name??null, + orgRoot: orgRootRef?.orgRootName??null, + orgChild1: orgChild1Ref?.orgChild1Name??null, + orgChild2: orgChild2Ref?.orgChild2Name??null, + orgChild3: orgChild3Ref?.orgChild3Name??null, + orgChild4: orgChild4Ref?.orgChild4Name??null, createdUserId: req.user.sub, createdFullName: req.user.name, lastUpdateUserId: req.user.sub, @@ -6057,6 +6065,16 @@ export class CommandController extends Controller { }); await this.profileEmployeeRepository.save(profile); await this.employeePositionRepository.save(positionNew); + //ลบออกคนออกจากโครงสร้างลูกจ้างชั่วคราว + const posMasterTemp = await this.employeeTempPosMasterRepository.findOne({ + where: { + orgRevisionId: orgRevision?.id, + current_holderId: profile.id, + }, + }); + if(posMasterTemp){ + await this.employeeTempPosMasterRepository.update(posMasterTemp.id,{current_holderId: _null}); + } } }), );