fix command21

This commit is contained in:
AdisakKanthawilang 2025-05-07 17:41:49 +07:00
parent ccf64bfa6d
commit 3d1179adc7

View file

@ -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});
}
}
}),
);