Phase 5: Supervisor and Stall screens, weld map, heat table, clock and CO verification
The shop at parity with the old build. Supervisor screen (department chips, CO headline, numbers, Change orders
on hold, station grid with clocks and CO tags, boards) and Stall screen (station picker, hero, My packets,
Submitted). Shop steps on the packet page: assign with station, welder picker and stamp; pull back; Start, Pause,
Resume; Submit with a PIN signature and the missing steps as links; review with Send to Q.C., Return to station
and Skip Q.C. route; a lead's read-only review. Weld map (pdf.js viewer with pan, pinch, zoom, full screen; marks
with leader lines; weld sheet; weld record with field CAS; carried marks). Heat map (heat table placed, dragged,
sized, removed; legacy amber tags; borrowed heat map read-only). Checklist tab with templates from settings.
VOID stamps on voided pages. Change orders: CO-n labels, supervisor verify with signature, approval copies the
heat table to the new sheet and the BOM merge keeps the shop's values. Server clock of record with VISUAL ticket
hours beside it. Presence per packet over SSE. Migration 0006 (bfx, bfy, carried_from, checklist_templates).
New endpoints /api/shop/board, /api/shop/stations, /api/shop/stall, /api/departments/{code}/people.
Tests: policy oracle for every shop action, role and status; clock arithmetic; concurrent inserts; CO apply;
frontend geometry, heat table, clock, checklist, weld sheet, screens; seven Playwright scenarios. Docs updated.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
@@ -5,8 +5,11 @@ import type {
|
||||
AttachPagesBody,
|
||||
BomLine,
|
||||
BomPatch,
|
||||
DeptPerson,
|
||||
FieldCas,
|
||||
Guarded,
|
||||
HeatTableBody,
|
||||
HeatTagBody,
|
||||
LogRow,
|
||||
PacketCard,
|
||||
PacketCreate,
|
||||
@@ -15,7 +18,9 @@ import type {
|
||||
PacketRead,
|
||||
ReceiptBody,
|
||||
ShortBody,
|
||||
StageFields,
|
||||
TransitionBody,
|
||||
WeldBody,
|
||||
WhStageBody,
|
||||
WorkOrder,
|
||||
} from "./types";
|
||||
@@ -86,4 +91,33 @@ export const packetsApi = {
|
||||
receiveShort: (id: number, item: number, body: ReceiptBody, g: Guarded = {}) =>
|
||||
api.post<PacketRead>(`${base(id)}/bom/${item}/short/receipts`, { ...body, ...g }),
|
||||
setWhStage: (id: number, body: WhStageBody, g: Guarded = {}) => api.post<PacketRead>(`${base(id)}/wh`, { ...body, ...g }),
|
||||
|
||||
/* Phase 5: the shop. Every answer is the packet. */
|
||||
addWeld: (id: number, body: WeldBody, g: Guarded = {}) => api.post<PacketRead>(`${base(id)}/welds`, { ...body, ...g }),
|
||||
/** If-Match is the weld's row_version. */
|
||||
patchWeld: (id: number, no: number, rowVersion: number, body: WeldBody, g: Guarded = {}) =>
|
||||
request<PacketRead>(`${base(id)}/welds/${no}`, { method: "PATCH", body: { ...body, ...g }, headers: ifMatch(rowVersion) }),
|
||||
removeWeld: (id: number, no: number, rowVersion: number, body: { reason?: string } & Guarded = {}) =>
|
||||
request<PacketRead>(`${base(id)}/welds/${no}`, { method: "DELETE", body, headers: ifMatch(rowVersion) }),
|
||||
addHeatTag: (id: number, body: HeatTagBody, g: Guarded = {}) => api.post<PacketRead>(`${base(id)}/heat-tags`, { ...body, ...g }),
|
||||
patchHeatTag: (id: number, no: number, rowVersion: number, body: HeatTagBody, g: Guarded = {}) =>
|
||||
request<PacketRead>(`${base(id)}/heat-tags/${no}`, { method: "PATCH", body: { ...body, ...g }, headers: ifMatch(rowVersion) }),
|
||||
removeHeatTag: (id: number, no: number, rowVersion: number, body: { reason?: string } & Guarded = {}) =>
|
||||
request<PacketRead>(`${base(id)}/heat-tags/${no}`, { method: "DELETE", body, headers: ifMatch(rowVersion) }),
|
||||
putHeatTable: (id: number, page: number, body: HeatTableBody, g: Guarded = {}) =>
|
||||
api.put<PacketRead>(`${base(id)}/heat-table/${page}`, { ...body, ...g }),
|
||||
removeHeatTable: (id: number, page: number, g: Guarded = {}) => api.delWithBody<PacketRead>(`${base(id)}/heat-table/${page}`, g),
|
||||
/** The weld record fields with a field-level base: 409 field_conflict when someone changed one first. */
|
||||
patchStage: (id: number, body: FieldCas<StageFields>) => api.patch<PacketRead>(`${base(id)}/stage`, body),
|
||||
setChecklist: (id: number, key: string, done: boolean, g: Guarded = {}) =>
|
||||
api.put<PacketRead>(`${base(id)}/stage/checklist/${encodeURIComponent(key)}`, { done, ...g }),
|
||||
clock: (id: number, op: "start" | "pause" | "resume", g: Guarded = {}) => api.post<PacketRead>(`${base(id)}/stage/clock`, { op, ...g }),
|
||||
coVerify: (id: number, no: number, body: { dept: string; note?: string } & Guarded) =>
|
||||
api.post<PacketRead>(`${base(id)}/change-orders/${no}/verify`, body),
|
||||
};
|
||||
|
||||
/** GET /api/departments/{code}/people: the welder picker and the weld sheet's stamp. */
|
||||
export const peopleApi = {
|
||||
list: async (dept: string, signal?: AbortSignal): Promise<DeptPerson[]> =>
|
||||
asList<DeptPerson>(await api.get<unknown>(`/api/departments/${encodeURIComponent(dept)}/people`, signal), "people"),
|
||||
};
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
// The shop board, the stall and the department people (phase 5 contract, api/shop.py and api/departments.py).
|
||||
// These types belong to the Supervisor and Stall screens. The packet page types stay in types.ts.
|
||||
import { api } from "./client";
|
||||
import { asList, qs } from "./query";
|
||||
import type { PacketCard } from "./types";
|
||||
|
||||
export interface ShopClock {
|
||||
/** Live on the server at the time of the answer: stored plus the running time. */
|
||||
elapsed_ms: number;
|
||||
running: boolean;
|
||||
}
|
||||
|
||||
export interface ShopCo {
|
||||
label: string;
|
||||
/** "pending" while Clerical reviews a change from VISUAL, "approved" once it applies. */
|
||||
review: string;
|
||||
}
|
||||
|
||||
/** A card on the shop board: the phase 4 card plus the station, welder, clock and open change orders. */
|
||||
export interface ShopCard extends Omit<PacketCard, "open_cos"> {
|
||||
welder_stamp?: string | null;
|
||||
clock?: ShopClock | null;
|
||||
target_hrs?: number | null;
|
||||
open_cos: ShopCo[];
|
||||
return_note?: string | null;
|
||||
}
|
||||
|
||||
export interface ShopStation {
|
||||
id: number;
|
||||
name: string;
|
||||
packets: ShopCard[];
|
||||
}
|
||||
|
||||
export type BoardLevel = "lead" | "supervisor" | "admin";
|
||||
|
||||
export interface ShopDept {
|
||||
code: string;
|
||||
name: string;
|
||||
weld: boolean;
|
||||
level: BoardLevel;
|
||||
stations: ShopStation[];
|
||||
}
|
||||
|
||||
export interface ShopKpis {
|
||||
ready: number;
|
||||
at_stations: number;
|
||||
review: number;
|
||||
elapsed_ms: number;
|
||||
target_hrs: number;
|
||||
}
|
||||
|
||||
/** One open change order on a packet in scope, or one waiting on a department of mine. */
|
||||
export interface ShopCoRow {
|
||||
packet_id: number;
|
||||
unit_number: string;
|
||||
op: string | null;
|
||||
title: string | null;
|
||||
dept_code: string;
|
||||
co_no: number;
|
||||
label: string;
|
||||
review: string;
|
||||
hold: boolean;
|
||||
pending_depts: string[];
|
||||
/** I can verify one of the pending departments. */
|
||||
mine: boolean;
|
||||
reason: string | null;
|
||||
ecn: string | null;
|
||||
issued_at: string | null;
|
||||
}
|
||||
|
||||
export const SHOP_COLUMNS = ["ready", "review", "qc", "warehouse", "complete"] as const;
|
||||
export type ShopColumn = (typeof SHOP_COLUMNS)[number];
|
||||
|
||||
export interface ShopBoard {
|
||||
depts: ShopDept[];
|
||||
kpis: ShopKpis;
|
||||
cos: ShopCoRow[];
|
||||
columns: Record<ShopColumn, ShopCard[]>;
|
||||
}
|
||||
|
||||
export interface ShopBoardQuery {
|
||||
/** A department code, or "all". */
|
||||
dept?: string;
|
||||
project_id?: number;
|
||||
unit_id?: number;
|
||||
}
|
||||
|
||||
export interface StationOption {
|
||||
dept_code: string;
|
||||
dept_name: string;
|
||||
id: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface StallAnswer {
|
||||
station: { id: number; name: string; dept_code: string; dept_name: string };
|
||||
mine: ShopCard[];
|
||||
submitted: ShopCard[];
|
||||
}
|
||||
|
||||
export interface DeptPerson {
|
||||
id: string;
|
||||
display_name: string;
|
||||
stamp: string | null;
|
||||
level: "worker" | "lead" | "supervisor";
|
||||
station_limits: number[];
|
||||
}
|
||||
|
||||
/** A card with every list present, so the screens never trip on a missing field. */
|
||||
export function normaliseCard(raw: ShopCard): ShopCard {
|
||||
return { ...raw, open_cos: Array.isArray(raw.open_cos) ? raw.open_cos : [] };
|
||||
}
|
||||
|
||||
function cards(raw: unknown): ShopCard[] {
|
||||
return Array.isArray(raw) ? (raw as ShopCard[]).map(normaliseCard) : [];
|
||||
}
|
||||
|
||||
/** Every department, column and number present, even when the server leaves one out. */
|
||||
export function normaliseBoard(raw: Partial<ShopBoard> | null): ShopBoard {
|
||||
const cols = (raw?.columns ?? {}) as Partial<Record<ShopColumn, unknown>>;
|
||||
const columns = Object.fromEntries(SHOP_COLUMNS.map((c) => [c, cards(cols[c])])) as ShopBoard["columns"];
|
||||
const depts = (Array.isArray(raw?.depts) ? raw.depts : []).map((d) => ({
|
||||
...d,
|
||||
stations: (Array.isArray(d.stations) ? d.stations : []).map((s) => ({ ...s, packets: cards(s.packets) })),
|
||||
}));
|
||||
return {
|
||||
depts,
|
||||
kpis: { ready: 0, at_stations: 0, review: 0, elapsed_ms: 0, target_hrs: 0, ...(raw?.kpis ?? {}) },
|
||||
cos: Array.isArray(raw?.cos) ? raw.cos.map((c) => ({ ...c, pending_depts: Array.isArray(c.pending_depts) ? c.pending_depts : [] })) : [],
|
||||
columns,
|
||||
};
|
||||
}
|
||||
|
||||
export async function getBoard(q: ShopBoardQuery = {}, signal?: AbortSignal): Promise<ShopBoard> {
|
||||
return normaliseBoard(await api.get<Partial<ShopBoard> | null>(`/api/shop/board${qs({ ...q })}`, signal));
|
||||
}
|
||||
|
||||
export async function getStations(signal?: AbortSignal): Promise<StationOption[]> {
|
||||
return asList<StationOption>(await api.get<unknown>("/api/shop/stations", signal), "stations");
|
||||
}
|
||||
|
||||
export async function getStall(stationId: number, signal?: AbortSignal): Promise<StallAnswer> {
|
||||
const raw = await api.get<Partial<StallAnswer> | null>(`/api/shop/stall${qs({ station_id: stationId })}`, signal);
|
||||
return {
|
||||
station: raw?.station ?? { id: stationId, name: "", dept_code: "", dept_name: "" },
|
||||
mine: cards(raw?.mine),
|
||||
submitted: cards(raw?.submitted),
|
||||
};
|
||||
}
|
||||
|
||||
export async function getPeople(dept: string, signal?: AbortSignal): Promise<DeptPerson[]> {
|
||||
return asList<DeptPerson>(await api.get<unknown>(`/api/departments/${encodeURIComponent(dept)}/people`, signal), "people");
|
||||
}
|
||||
|
||||
export const shopApi = { getBoard, getStations, getStall, getPeople };
|
||||
+195
-7
@@ -227,10 +227,20 @@ export interface PacketPage {
|
||||
pn: number;
|
||||
dwg: string | null;
|
||||
rev: string | null;
|
||||
void: { co_id: number; at: string; new_n: number | null } | null;
|
||||
void: PageVoid | null;
|
||||
url: string;
|
||||
}
|
||||
|
||||
/** A voided drawing page. Phase 5 adds the CO number, who voided it and the page that replaced it. */
|
||||
export interface PageVoid {
|
||||
co_id: number;
|
||||
at: string;
|
||||
new_n: number | null;
|
||||
co_no?: number | null;
|
||||
by?: WhoRef | null;
|
||||
new?: { n: number; dwg: string | null; rev: string | null } | null;
|
||||
}
|
||||
|
||||
export interface BomShort {
|
||||
id: number;
|
||||
qty: number | string;
|
||||
@@ -327,11 +337,11 @@ export interface PacketRead {
|
||||
work_orders: WorkOrder[];
|
||||
pages: PacketPage[];
|
||||
bom: BomLine[];
|
||||
welds: unknown[];
|
||||
heat_tags: unknown[];
|
||||
heat_table: unknown[];
|
||||
stage: Record<string, unknown> | null;
|
||||
stages: unknown[];
|
||||
welds: Weld[];
|
||||
heat_tags: HeatTag[];
|
||||
heat_table: HeatTablePlacement[];
|
||||
stage: Stage | null;
|
||||
stages: Stage[];
|
||||
wh: WhInfo | null;
|
||||
qc: Record<string, unknown> | null;
|
||||
qc_history: unknown[];
|
||||
@@ -346,6 +356,178 @@ export interface PacketRead {
|
||||
checklist_items: Array<{ group: string; key: string; text: string }>;
|
||||
qc_items: unknown[];
|
||||
flag: string | null;
|
||||
/** Phase 5: the database now(), to tick the clock from. */
|
||||
server_now?: string | null;
|
||||
/** Phase 5: the sum of the work orders' target hours. */
|
||||
target_hrs?: number | null;
|
||||
/** Phase 5: VISUAL labor tickets on the packet's work orders. Null for a hand packet or no match. */
|
||||
labor?: Labor | null;
|
||||
/** Phase 5: the borrowed heat map of a sibling packet, read-only. */
|
||||
heat_src?: HeatSrc | null;
|
||||
}
|
||||
|
||||
/* ---------- Phase 5: the shop on the packet ---------- */
|
||||
|
||||
export interface Weld {
|
||||
weld_no: number;
|
||||
page: number | null;
|
||||
/** Where the arrow points, as a fraction of the page. */
|
||||
fx: number | null;
|
||||
fy: number | null;
|
||||
/** The bubble. Null means the default position (geometry.bpos). */
|
||||
bfx?: number | null;
|
||||
bfy?: number | null;
|
||||
wo_base: string | null;
|
||||
piece: number | null;
|
||||
items: number[];
|
||||
type: string | null;
|
||||
size: string | null;
|
||||
process: string | null;
|
||||
stamp: string | null;
|
||||
at: string | null;
|
||||
row_version: number;
|
||||
welder: WhoRef | null;
|
||||
by?: WhoRef | null;
|
||||
dept_code?: string | null;
|
||||
stage_id?: number | null;
|
||||
/** Logged in an earlier department's stage. */
|
||||
carried?: boolean;
|
||||
}
|
||||
|
||||
export interface HeatTag {
|
||||
tag_no: number;
|
||||
page: number | null;
|
||||
item: number;
|
||||
fx: number | null;
|
||||
fy: number | null;
|
||||
bfx?: number | null;
|
||||
bfy?: number | null;
|
||||
row_version: number;
|
||||
carried?: boolean;
|
||||
carried_from?: number | null;
|
||||
}
|
||||
|
||||
/** One heat table on a drawing page. x, y is the top-left corner as a fraction; s the size factor. */
|
||||
export interface HeatTablePlacement {
|
||||
page: number;
|
||||
x: number;
|
||||
y: number;
|
||||
s: number;
|
||||
carried_from?: number | null;
|
||||
by?: WhoRef | null;
|
||||
at?: string | null;
|
||||
}
|
||||
|
||||
export interface StageClock {
|
||||
/** Live on the server at read time: stored plus the running time. */
|
||||
elapsed_ms: number;
|
||||
stored_ms?: number;
|
||||
running?: boolean;
|
||||
running_since: string | null;
|
||||
started_at: string | null;
|
||||
}
|
||||
|
||||
export interface ChecklistEntry {
|
||||
done: boolean;
|
||||
at?: string | null;
|
||||
by?: string | null;
|
||||
by_name?: string | null;
|
||||
stamp?: string | null;
|
||||
}
|
||||
|
||||
export interface Stage {
|
||||
id: number;
|
||||
dept_code: string;
|
||||
station: StationRef | null;
|
||||
welder: WelderRef | null;
|
||||
checklist: Record<string, ChecklistEntry>;
|
||||
filler: string | null;
|
||||
filler_lot: string | null;
|
||||
preheat: string | null;
|
||||
notes: string | null;
|
||||
clock: StageClock;
|
||||
opened_at: string | null;
|
||||
closed_at?: string | null;
|
||||
row_version: number;
|
||||
}
|
||||
|
||||
/** The weld record fields on the open stage. */
|
||||
export interface StageFields {
|
||||
filler: string | null;
|
||||
filler_lot: string | null;
|
||||
preheat: string | null;
|
||||
notes: string | null;
|
||||
}
|
||||
|
||||
export interface LaborWo {
|
||||
wo_base: string;
|
||||
lot: string;
|
||||
split: string;
|
||||
sub: string;
|
||||
seq: number | null;
|
||||
hours: number;
|
||||
tickets: number;
|
||||
last_ticket: string | null;
|
||||
}
|
||||
|
||||
export interface Labor {
|
||||
hours: number;
|
||||
tickets: number;
|
||||
per_wo: LaborWo[];
|
||||
observed_at: string | null;
|
||||
}
|
||||
|
||||
export interface HeatSrc {
|
||||
packet_id: number;
|
||||
op: string | null;
|
||||
status: PacketStatus;
|
||||
drawing: string | null;
|
||||
rev: string | null;
|
||||
pages: PacketPage[];
|
||||
heat_table: HeatTablePlacement[];
|
||||
heat_tags: HeatTag[];
|
||||
bom: Array<{ item: number; heat: string | null; na: boolean }>;
|
||||
}
|
||||
|
||||
/** A weld write. Positions are fractions of the page. */
|
||||
export interface WeldBody {
|
||||
page?: number | null;
|
||||
fx?: number | null;
|
||||
fy?: number | null;
|
||||
bfx?: number | null;
|
||||
bfy?: number | null;
|
||||
wo_base?: string | null;
|
||||
piece?: number | null;
|
||||
items?: number[];
|
||||
type?: string | null;
|
||||
size?: string | null;
|
||||
process?: string | null;
|
||||
stamp?: string | null;
|
||||
}
|
||||
|
||||
export interface HeatTagBody {
|
||||
page?: number | null;
|
||||
item?: number;
|
||||
fx?: number | null;
|
||||
fy?: number | null;
|
||||
bfx?: number | null;
|
||||
bfy?: number | null;
|
||||
}
|
||||
|
||||
export interface HeatTableBody {
|
||||
x: number;
|
||||
y: number;
|
||||
s: number;
|
||||
carried_from?: number | null;
|
||||
}
|
||||
|
||||
/** One person on GET /api/departments/{code}/people. */
|
||||
export interface DeptPerson {
|
||||
id: string;
|
||||
display_name: string;
|
||||
stamp: string | null;
|
||||
level: "worker" | "lead" | "supervisor";
|
||||
station_limits: number[];
|
||||
}
|
||||
|
||||
/** One row of GET /api/packets/{id}/log, newest first. */
|
||||
@@ -541,7 +723,13 @@ export interface ChangeOrder {
|
||||
rejected_reason?: string | null;
|
||||
items: ChangeOrderItem[];
|
||||
required: string[];
|
||||
verified: Record<string, { by: WhoRef | null; at: string; note: string | null }>;
|
||||
verified: Record<string, { by: WhoRef | null; at: string; note: string | null; signed?: boolean }>;
|
||||
/** Phase 5: "CO-<co_no>". */
|
||||
label?: string;
|
||||
/** Phase 5: required minus verified. */
|
||||
pending_depts?: string[];
|
||||
/** Phase 5: approved with pending departments, or pending with hold. */
|
||||
open?: boolean;
|
||||
vis?: CoVis | null;
|
||||
waiting?: { dwg: string; rev: string; since?: string | null; err?: string | null } | null;
|
||||
staged?: { asset_id: string; name: string | null; rev: string; dwg: string; sha256?: string; pages?: number | null } | null;
|
||||
|
||||
Reference in New Issue
Block a user