This commit is contained in:
Adisak 2025-11-12 18:20:02 +07:00
parent 62750576d3
commit 92f4ccb30a

View file

@ -4266,21 +4266,21 @@ 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","current_holders"], relations: ["roleKeycloaks"],
}); });
if (!profile) { if (!profile) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
} }
const orgRevision = await this.orgRevisionRepo.findOne({ // const orgRevision = await this.orgRevisionRepo.findOne({
where: { // where: {
orgRevisionIsCurrent: true, // orgRevisionIsCurrent: true,
orgRevisionIsDraft: false, // orgRevisionIsDraft: false,
}, // },
}); // });
const orgRevisionRef = // const orgRevisionRef =
profile?.current_holders?.find((x:any) => x.orgRevisionId == orgRevision?.id) ?? null; // profile?.current_holders?.find((x:any) => x.orgRevisionId == orgRevision?.id) ?? null;
//ลบตำแหน่งที่รักษาการแทน //ลบตำแหน่งที่รักษาการแทน
const code = _command?.commandType?.code; const code = _command?.commandType?.code;
@ -4310,9 +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){ // if(orgRevisionRef){
await CreatePosMasterHistoryOfficer(orgRevisionRef.id, req, "DELETE"); // 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));