Merge branch 'develop' into adiDev

This commit is contained in:
AdisakKanthawilang 2025-03-21 17:07:13 +07:00
commit 879e75c688

View file

@ -378,6 +378,7 @@ export class WorkflowController extends Controller {
can_delete: false,
can_cancel: false,
can_sign: false,
keycloakId: workflow.createdUserId,
});
}
return new HttpSuccess({
@ -392,6 +393,7 @@ export class WorkflowController extends Controller {
can_delete: operator.canDelete,
can_cancel: operator.canCancel,
can_sign: operator.canSign,
keycloakId: workflow.createdUserId,
});
}
@ -800,15 +802,15 @@ export class WorkflowController extends Controller {
keyword: string;
page: number;
pageSize: number;
profileId?: string | null;
keycloakId?: string | null;
},
) {
let posMasterUser: PosMaster = new PosMaster();
if (body.profileId) {
if (body.keycloakId) {
posMasterUser = (await this.posMasterRepo.findOne({
where: {
orgRevision: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
current_holderId: body.profileId,
current_holder: { keycloak: body.keycloakId },
},
relations: ["current_holder", "current_holder.posType", "current_holder.posLevel"],
})) as PosMaster;
@ -825,38 +827,63 @@ export class WorkflowController extends Controller {
if (!posMasterUser || !posMasterUser.orgRootId)
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบตำแหน่งผู้ใช้งาน");
let condition: any = {
isDirector: true,
orgRootId: posMasterUser.orgRootId,
orgRevisionId: posMasterUser.orgRevisionId,
};
let condition: any = [];
let conditionOfficer: any = {
isDirector: true,
isOfficer: true,
orgRevisionId: posMasterUser.orgRevisionId,
orgChild1Id: IsNull(),
};
if (type.trim().toUpperCase() == "OPERATE") {
condition = {
condition.push({
isDirector: true,
orgRootId: posMasterUser.orgRootId,
orgRevisionId: posMasterUser.orgRevisionId,
// orgChild1Id: IsNull(),
// orgChild2Id: IsNull(),
// orgChild3Id: IsNull(),
// orgChild4Id: IsNull(),
};
if (posMasterUser.orgChild4Id == null) {
condition.orgChild4Id = IsNull();
} else if (posMasterUser.orgChild3Id == null) {
condition.orgChild3Id = IsNull();
} else if (posMasterUser.orgChild2Id == null) {
condition.orgChild2Id = IsNull();
} else if (posMasterUser.orgChild1Id == null) {
condition.orgChild1Id = IsNull();
}
orgChild1Id: IsNull(),
});
condition.push({
isDirector: true,
orgRootId: posMasterUser.orgRootId,
orgRevisionId: posMasterUser.orgRevisionId,
orgChild1Id: posMasterUser.orgChild1Id,
orgChild2Id: IsNull(),
});
condition.push({
isDirector: true,
orgRootId: posMasterUser.orgRootId,
orgRevisionId: posMasterUser.orgRevisionId,
orgChild1Id: posMasterUser.orgChild1Id,
orgChild2Id: posMasterUser.orgChild2Id,
orgChild3Id: IsNull(),
});
condition.push({
isDirector: true,
orgRootId: posMasterUser.orgRootId,
orgRevisionId: posMasterUser.orgRevisionId,
orgChild1Id: posMasterUser.orgChild1Id,
orgChild2Id: posMasterUser.orgChild2Id,
orgChild3Id: posMasterUser.orgChild3Id,
orgChild4Id: IsNull(),
});
condition.push({
isDirector: true,
orgRootId: posMasterUser.orgRootId,
orgRevisionId: posMasterUser.orgRevisionId,
orgChild1Id: posMasterUser.orgChild1Id,
orgChild2Id: posMasterUser.orgChild2Id,
orgChild3Id: posMasterUser.orgChild3Id,
orgChild4Id: posMasterUser.orgChild4Id,
});
} else {
condition = [
{
isDirector: true,
orgRootId: posMasterUser.orgRootId,
orgRevisionId: posMasterUser.orgRevisionId,
},
];
if (
(posMasterUser.current_holder.posType.posTypeName == "ทั่วไป" &&
posMasterUser.current_holder.posLevel.posLevelName == "ชำนาญงาน") ||