Files
MIS-Contro-Tower/lib/recap/types.ts
Marcelo 4973c18dc3 recent
2026-04-24 03:17:04 +00:00

118 lines
2.2 KiB
TypeScript

export type RecapSkuRow = {
machineName: string;
sku: string;
good: number;
scrap: number;
target: number | null;
progressPct: number | null;
};
export type RecapMachine = {
machineId: string;
machineName: string;
location: string | null;
production: {
goodParts: number;
scrapParts: number;
totalCycles: number;
bySku: RecapSkuRow[];
};
oee: {
avg: number | null;
availability: number | null;
performance: number | null;
quality: number | null;
};
downtime: {
totalMin: number;
stopsCount: number;
topReasons: Array<{
reasonLabel: string;
minutes: number;
count: number;
}>;
ongoingStopMin: number | null;
};
workOrders: {
completed: Array<{
id: string;
sku: string | null;
goodParts: number;
durationHrs: number;
}>;
active: {
id: string;
sku: string | null;
progressPct: number | null;
startedAt: string | null;
} | null;
moldChangeInProgress: boolean;
moldChangeStartMs: number | null;
};
heartbeat: {
lastSeenAt: string | null;
uptimePct: number | null;
};
};
export type RecapTimelineSegment =
| {
type: "production";
startMs: number;
endMs: number;
workOrderId: string | null;
sku: string | null;
label: string;
}
| {
type: "mold-change";
startMs: number;
endMs: number;
fromMoldId: string | null;
toMoldId: string | null;
durationSec: number;
label: string;
}
| {
type: "macrostop" | "microstop" | "slow-cycle";
startMs: number;
endMs: number;
reason: string | null;
durationSec: number;
label: string;
}
| {
type: "idle";
startMs: number;
endMs: number;
label: string;
};
export type RecapTimelineResponse = {
range: {
start: string;
end: string;
};
segments: RecapTimelineSegment[];
};
export type RecapResponse = {
range: {
start: string;
end: string;
};
availableShifts: Array<{
id: string;
name: string;
}>;
machines: RecapMachine[];
};
export type RecapQuery = {
orgId: string;
machineId?: string;
start?: Date;
end?: Date;
shift?: string;
};