parent
129ea8c102
commit
4c87fdca34
1 changed files with 19 additions and 3 deletions
|
|
@ -4266,12 +4266,22 @@ export class CommandController extends Controller {
|
||||||
body.data.map(async (item) => {
|
body.data.map(async (item) => {
|
||||||
const profile: any = await this.profileRepository.findOne({
|
const profile: any = await this.profileRepository.findOne({
|
||||||
where: { id: item.profileId },
|
where: { id: item.profileId },
|
||||||
relations: ["roleKeycloaks"],
|
relations: ["roleKeycloaks","current_holders"],
|
||||||
});
|
});
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const orgRevision = await this.orgRevisionRepo.findOne({
|
||||||
|
where: {
|
||||||
|
orgRevisionIsCurrent: true,
|
||||||
|
orgRevisionIsDraft: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const orgRevisionRef =
|
||||||
|
profile?.current_holders?.find((x:any) => x.orgRevisionId == orgRevision?.id) ?? null;
|
||||||
|
|
||||||
//ลบตำแหน่งที่รักษาการแทน
|
//ลบตำแหน่งที่รักษาการแทน
|
||||||
const code = _command?.commandType?.code;
|
const code = _command?.commandType?.code;
|
||||||
if (code && ["C-PM-13"].includes(code)) {
|
if (code && ["C-PM-13"].includes(code)) {
|
||||||
|
|
@ -4300,6 +4310,9 @@ export class CommandController extends Controller {
|
||||||
lastUpdatedAt: new Date(),
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
if (item.isLeave != undefined && item.isLeave == true) {
|
if (item.isLeave != undefined && item.isLeave == true) {
|
||||||
|
if(orgRevisionRef){
|
||||||
|
await CreatePosMasterHistoryOfficer(orgRevisionRef.id, req, "DELETE");
|
||||||
|
}
|
||||||
await removeProfileInOrganize(profile.id, "OFFICER");
|
await removeProfileInOrganize(profile.id, "OFFICER");
|
||||||
}
|
}
|
||||||
const clearProfile = await checkCommandType(String(item.commandId));
|
const clearProfile = await checkCommandType(String(item.commandId));
|
||||||
|
|
@ -4628,8 +4641,8 @@ export class CommandController extends Controller {
|
||||||
orgRevisionIsDraft: false,
|
orgRevisionIsDraft: false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
// const orgRevisionRef =
|
const orgRevisionRef =
|
||||||
// profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null;
|
profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null;
|
||||||
// const orgRootRef = orgRevisionRef?.orgRoot ?? null;
|
// const orgRootRef = orgRevisionRef?.orgRoot ?? null;
|
||||||
// const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null;
|
// const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null;
|
||||||
// const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null;
|
// const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null;
|
||||||
|
|
@ -4770,6 +4783,9 @@ export class CommandController extends Controller {
|
||||||
_profile.leaveDate = item.commandDateAffect ?? _null;
|
_profile.leaveDate = item.commandDateAffect ?? _null;
|
||||||
_profile.leaveType = exceptClear.LeaveType ?? _null;
|
_profile.leaveType = exceptClear.LeaveType ?? _null;
|
||||||
} else {
|
} else {
|
||||||
|
if(orgRevisionRef){
|
||||||
|
await CreatePosMasterHistoryOfficer(orgRevisionRef.id, req, "DELETE");
|
||||||
|
}
|
||||||
await removeProfileInOrganize(_profile.id, "OFFICER");
|
await removeProfileInOrganize(_profile.id, "OFFICER");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue