update
Some checks failed
release / release (push) Failing after 8s

This commit is contained in:
Adisak 2025-11-12 18:02:28 +07:00
parent 3d689ff19c
commit 62750576d3
2 changed files with 7 additions and 17 deletions

View file

@ -4313,9 +4313,7 @@ export class CommandController extends Controller {
if(orgRevisionRef){
await CreatePosMasterHistoryOfficer(orgRevisionRef.id, req, "DELETE");
}
console.log("A");
await removeProfileInOrganize(profile.id, "OFFICER");
console.log("Z");
}
const clearProfile = await checkCommandType(String(item.commandId));
const _null: any = null;

View file

@ -253,73 +253,65 @@ export function calculateRetireYear(birthDate: Date) {
return yy + 61;
}
export async function removeProfileInOrganize(profileId: string, type: string) {
console.log(1);
const currentRevision = await AppDataSource.getRepository(OrgRevision)
.createQueryBuilder("orgRevision")
.where("orgRevision.orgRevisionIsDraft = false")
.andWhere("orgRevision.orgRevisionIsCurrent = true")
.getOne();
console.log(2);
const draftRevision = await AppDataSource.getRepository(OrgRevision)
.createQueryBuilder("orgRevision")
.where("orgRevision.orgRevisionIsDraft = true")
.andWhere("orgRevision.orgRevisionIsCurrent = false")
.getOne();
console.log(3);
if (!currentRevision && !draftRevision) {
console.log(4);
return;
}
if (type === "OFFICER") {
console.log(5);
const findProfileInposMaster = await AppDataSource.getRepository(PosMaster)
.createQueryBuilder("posMaster")
.where("posMaster.orgRevisionId = :orgRevisionId", { orgRevisionId: currentRevision?.id })
.andWhere("posMaster.current_holderId = :profileId", { profileId })
.getOne();
console.log(6);
await AppDataSource.getRepository(PosMaster)
.createQueryBuilder()
.update(PosMaster)
.set({ current_holderId: null })
.where("id = :id", { id: findProfileInposMaster?.id })
.execute();
console.log(7);
const findProfileInposMasterDraft = await AppDataSource.getRepository(PosMaster)
.createQueryBuilder("posMaster")
.where("posMaster.orgRevisionId = :orgRevisionId", { orgRevisionId: draftRevision?.id })
.andWhere("posMaster.next_holderId = :profileId", { profileId })
.getOne();
console.log(8);
await AppDataSource.getRepository(PosMaster)
.createQueryBuilder()
.update(PosMaster)
.set({ next_holderId: null })
.where("id = :id", { id: findProfileInposMasterDraft?.id })
.execute();
console.log(9);
if (!findProfileInposMaster && !findProfileInposMasterDraft) {
console.log(10);
return;
}
console.log(11);
const findPosition = await AppDataSource.getRepository(Position)
.createQueryBuilder("position")
.where("position.posMasterId = :posMasterId", { posMasterId: findProfileInposMaster?.id })
.getMany();
console.log(12);
if (!findPosition) {
console.log(13);
return;
}
console.log(13);
await AppDataSource.getRepository(Position)
.createQueryBuilder()
.update(Position)
.set({ positionIsSelected: false })
.where("id IN (:...ids)", { ids: findPosition.map((item) => item.id) })
.execute();
console.log(14);
}
if (type === "EMPLOYEE") {
const findProfileInEmpPosMaster = await AppDataSource.getRepository(EmployeePosMaster)