human and vehicle bug fix

This commit is contained in:
2025-08-22 13:51:35 +05:30
parent c24b0fd414
commit 970e3a837b
10 changed files with 135 additions and 130 deletions

View File

@@ -73,6 +73,7 @@ type ProductsStore = {
getPointUuidByActionUuid: (productUuid: string, actionUuid: string) => (string) | undefined;
getTriggerByUuid: (productUuid: string, triggerUuid: string) => TriggerSchema | undefined;
getTriggersByTriggeredPointUuid: (productUuid: string, triggeredPointUuid: string) => TriggerSchema[];
getTriggeringModels: (productUuid: string, actionUUid: string) => EventsSchema[];
getIsEventInProduct: (productUuid: string, modelUuid: string) => boolean;
};
@@ -898,6 +899,58 @@ export const createProductStore = () => {
return undefined;
},
getTriggeringModels: (productUuid: string, actionUuid: string) => {
const product = get().products.find(p => p.productUuid === productUuid);
if (!product) return [];
const triggeringModels: EventsSchema[] = [];
const targetModelUuid = get().getModelUuidByActionUuid(productUuid, actionUuid);
if (!targetModelUuid) return [];
for (const event of product.eventDatas) {
if ('points' in event) {
for (const point of (event as ConveyorEventSchema).points) {
if (point.action?.triggers) {
for (const trigger of point.action.triggers) {
if (trigger.triggeredAsset?.triggeredModel?.modelUuid === targetModelUuid &&
trigger.triggeredAsset?.triggeredAction?.actionUuid === actionUuid) {
triggeringModels.push(event);
break;
}
}
}
}
} else if ('point' in event) {
const point = (event as any).point;
if ('action' in point && point.action?.triggers) {
for (const trigger of point.action.triggers) {
if (trigger.triggeredAsset?.triggeredModel?.modelUuid === targetModelUuid &&
trigger.triggeredAsset?.triggeredAction?.actionUuid === actionUuid) {
triggeringModels.push(event);
break;
}
}
} else if ('actions' in point) {
for (const action of point.actions) {
if (action.triggers) {
for (const trigger of action.triggers) {
if (trigger.triggeredAsset?.triggeredModel?.modelUuid === targetModelUuid &&
trigger.triggeredAsset?.triggeredAction?.actionUuid === actionUuid) {
triggeringModels.push(event);
break;
}
}
}
}
}
}
}
return triggeringModels;
},
getTriggersByTriggeredPointUuid: (productUuid, triggeredPointUuid) => {
const product = get().products.find(p => p.productUuid === productUuid);
if (!product) return [];