This commit is contained in:
parent
ef279df452
commit
557741e29d
1 changed files with 35 additions and 0 deletions
|
|
@ -3352,6 +3352,41 @@ export class PositionController extends Controller {
|
||||||
posMaster.lastUpdatedAt = new Date();
|
posMaster.lastUpdatedAt = new Date();
|
||||||
await this.posMasterRepository.save(posMaster, { data: request });
|
await this.posMasterRepository.save(posMaster, { data: request });
|
||||||
setLogDataDiff(request, { before, after: posMaster });
|
setLogDataDiff(request, { before, after: posMaster });
|
||||||
|
|
||||||
|
// อัพเดท org และ posMasterNo ใน profile ตลอดไม่ต้องดัก isSit
|
||||||
|
if (posMaster.current_holderId) {
|
||||||
|
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||||
|
where: { id: posMaster.orgRevisionId },
|
||||||
|
});
|
||||||
|
if (orgRevision?.orgRevisionIsCurrent) {
|
||||||
|
const pmWithOrg = await this.posMasterRepository.findOne({
|
||||||
|
where: { id: posMaster.id },
|
||||||
|
relations: ["orgRoot", "orgChild1", "orgChild2", "orgChild3", "orgChild4", "positions", "positions.posExecutive"],
|
||||||
|
});
|
||||||
|
const _profile = await this.profileRepository.findOne({
|
||||||
|
where: { id: posMaster.current_holderId },
|
||||||
|
});
|
||||||
|
if (_profile && pmWithOrg) {
|
||||||
|
const _null: any = null;
|
||||||
|
_profile.posMasterNo = getPosMasterNo(pmWithOrg) ?? _null;
|
||||||
|
_profile.org = getOrgFullName(pmWithOrg) ?? _null;
|
||||||
|
// ถ้าไม่ใช่ตำแหน่งนั่งทับ (isSit = false) ถึงจะอัพเดทตำแหน่งในทะเบียนประวัติ
|
||||||
|
if (!pmWithOrg.isSit) {
|
||||||
|
const selectedPos = (pmWithOrg as any).positions?.find((p: any) => p.positionIsSelected === true);
|
||||||
|
if (selectedPos) {
|
||||||
|
_profile.position = selectedPos.positionName ?? _null;
|
||||||
|
_profile.posTypeId = selectedPos.posTypeId ?? _null;
|
||||||
|
_profile.posLevelId = selectedPos.posLevelId ?? _null;
|
||||||
|
_profile.positionField = selectedPos.positionField ?? _null;
|
||||||
|
_profile.posExecutive = (selectedPos as any).posExecutive?.posExecutiveName ?? _null;
|
||||||
|
_profile.positionArea = selectedPos.positionArea ?? _null;
|
||||||
|
_profile.positionExecutiveField = selectedPos.positionExecutiveField ?? _null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await this.profileRepository.save(_profile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue