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