Cloud apps

WBS Cloud guide

WBS Cloud is a serverless port of the WBS platform's ingest pipeline: uploads flow through staged runs, every artifact records its provenance, and periodic jobs run from the worker/API.

Uploading a source

  1. Open WBS Cloud — no account needed for the console itself.
  2. Upload a file: a data table (CSV, TSV, JSON, TXT, Markdown) or a construction document (PDF, DOCX, DOC, XLS, XLSX, DWG), up to 100 MB — or a ZIP, 7Z or RAR archive of them.
  3. One pipeline record starts automatically for the upload; open it to watch progress. Each file inside (and the QTO take-off of a drawing set) is a child pipeline listed inside that record.

Documents are read on the server before the pipeline sees them:

Format How it is read What the pipeline gets
PDF unpdf; a scanned PDF goes through the PaddleOCR service prose → numbered-heading tree, chunks keep the page number
DOCX the built-in ZIP reader + the Word XML prose → numbered-heading tree
XLSX / XLS the built-in ZIP reader + the sheet XML tab-separated rows → a BOQ table (code, name, qty, unit, đơn giá, thành tiền)
DWG LibreDWG (WebAssembly) in a child process the drawing's facts: model-space texts with their position, line / multiline lengths per layer — what quantity take-off reads (a drawing it cannot read falls back to the string scan)
DOC best-effort string scan (latin1 + utf16le) whatever text the file carries

Files larger than 4 MB go browser → Vercel Blob → the server; the original is kept in Blob and the extracted text is what the pipeline parses.

Files & drawings

Tệp & bản vẽ lists every uploaded file (one row per file, not per pipeline). Xem opens a preview:

  • PDF — inline in the browser.
  • DWG — an interactive 3D viewer (below), with a static SVG / label-map fallback when the original bytes are not in Blob.
  • Text / data — the extracted content, read back from the database or Blob.

Tải always returns the original bytes (/api/wbs/uploads/:id/file?download=1).

The DWG / PEB 3D viewer

Opening a .dwg shows a three.js viewer with two modes and three displays. The geometry is computed once by the LibreDWG worker and cached in wbs_dwg_geometry; the renderer only draws what the database already worked out (the same "compute once, store, render" rule as a spatial database).

  • Bản vẽ DWG — the uploaded drawing:
    • Nét — every line / polyline / tessellated circle & arc as coloured LineSegments, grouped per layer; INSERT blocks are expanded with their scale / rotation. Drag to orbit, scroll to zoom, presets for iso / top / front / side.
    • Khối — closed outlines are ear-clipped and extruded into watertight prisms, stacked per layer; the Tách lớp slider pulls the layers apart (exploded view). Open lines stay lines.
    • SVG — the static LibreDWG render, or the facts label map when the original is not stored. This is also the automatic fallback if the 3D geometry cannot be read.
  • Mô hình PEB 3D — a parametric pre-engineered steel frame (portal frames, purlins, girts, endwall columns, X-bracing) generated from span / eave / bay-count / pitch, with a checkbox per member group.

Layer / group checkboxes toggle visibility; each name keeps a stable colour. Endpoints: GET /api/wbs/uploads/:id/geometry (cached, ?refresh=1 to recompute) and POST /api/wbs/staad/generate.

The four stages

Stage What it does
extract Detect format, count rows/lines, capture headers
chunk Split text into ~800-char chunks on heading/page boundaries
structure Build the WBS tree: header mapping, category roots, codes, quantities, units
lineage Write the provenance graph: upload → stages → artifacts

Header mapping understands English and Vietnamese aliases — mã / mã vật tư / STT (code), tên công tác / mô tả (name), khối lượng / KL (qty), đơn vị / ĐVT (unit), nhóm / bộ phận (category). Quantities parse 12.5, 1.234,56, 1,234.56, and (50) (accounting negative); units normalize (m2 → m², tấn → ton, bộ stays bộ).

Reading a run

  • Stages show status, timing, and detail (row counts, headers, errors).
  • Items is the built WBS table, one row per work item with five columns: 序号 STT · 项目名称 Nội dung công việc · 计量单位 Đơn vị · 工程量 Khối lượng · 备注 Ghi chú. A row with a name but no STT, unit or quantity is a section heading; "合计 / Tổng cộng" rows are skipped.
  • Lineage graphs how every artifact was produced — the answer to "where did this number come from?".
  • Re-run reprocesses the same upload (stages are idempotent) — useful after a mapping fix upstream.

WBS templates: tài liệu and xây lắp điện

Some packages have no quantity table to read: the project's document set and the electrical installation. Their WBS comes from a template instead — a ready-made tree kept under version control in src/lib/wbs/templates.ts.

Template Id What it covers
Tài liệu tai-lieu pháp lý & chuẩn bị đầu tư → khảo sát/thiết kế → đấu thầu → thi công → nghiệm thu, hoàn công, quyết toán (5 sections, 25 documents)
Xây lắp điện xay-lap-dien EL-01…EL-12: nguồn & tủ điện, dây dẫn, ống/máng, phụ kiện, chiếu sáng, ổ cắm/công tắc, thiết bị đóng ngắt, máy điện & điều hoà, báo cháy, mạng, điện ngoài trời, chống sét & tiếp địa

Open WBS mẫu, name a project (optional), and Tạo WBS mẫu (POST /api/wbs/templates {template, project?}). The run is created already finished and has no input file: quantities stay empty for the project to fill, and every electrical row carries the representative BA.* codes of TT 38/2026/TT-BXD Phụ lục III in its note. Re-run rebuilds the same tree from the code, so a template fix reaches an old run when it is re-run.

The electrical template is a work breakdown for projects that do not yet have CAD plans; when electrical DWG plans are uploaded, the QTO engine below also takes off electrical items directly into EL-01…EL-12.

Quantity take-off (QTO / tiên lượng) from drawings

Upload a building's drawing set as one archive (.zip / .7z / .rar of the DWG files): besides one run per file, a QTO run is created over all the drawings of the archive. Drawings uploaded one by one are gathered with Bóc từ bản vẽ của dự án on the WBS page (POST /api/wbs/qto {project}).

The take-off reads both structural and electrical drawings and says where every number came from:

Source What is read
S3 bảng thống kê pile schedule (types, diameter, capacity, counts, test piles, head / toe levels), footing / pile-cap / beam schedules (mark · size · level · piles per cap), door schedule
S4 hình học footing, stub-column, base-plate and column marks counted on the plans; tie beams measured as MLINE length; wall beams as line length on their layer; electrical device blocks (OC, CT, DEN, TU, MCB, QUAT, AC, …) and cable/conduit layer lengths on electrical plans
S5 suy diễn backfill, rebar by kg/m³, stub / wall-beam / slab volume from a stated section; electrical assembly expansion (tail wire, final conduit, junction boxes) and derived conduit lengths with +8% waste on length-measured materials (0% on counted devices) — the assumption is always in the note

Each row has nguồn, tin cậy (CAO / TRUNG BÌNH / THẤP), bản vẽ and a note; rows the drawings do not give stay empty (yellow) and become tasks. The run page also shows the footing table (n · l · b · h), the design parameters read off the drawings and the cross-checks (e.g. piles from the pile schedule vs piles from the pile-cap schedule). Tải tiên lượng (Excel) (GET /api/wbs/runs/:id/qto) downloads TienLuong · ChiTietKL · ThamSo · KiemChung · BanVe.

Rules that keep counts honest: a bilingual label (KHE CO / 收缩缝) counts once; AutoCAD _recover copies are skipped; a mark written less than 5 % as often as the most common mark on the same plan is listed as "không tính" rather than counted.

From QTO to BOQ: 清单 and quotes

Add the owner's 清单 (quantities, no prices yet) or a supplier's báo giá to a QTO run. The take-off and the 清单 rarely use the same names ("Đào móng, đài cọc / 挖基坑" vs "挖一般土方 / Đào đất thường"), so a QTO run is matched by similarity of the Chinese characters and the Vietnamese words — weighted by rarity, the unit must agree, the closer quantity breaks a tie, one quote row per take-off row. The matched quote row's quantity becomes KL theo 清单 (with the difference in %) and its prices price the row; the take-off quantity is never replaced. Unmatched rows are matched by hand on the quote's page, then Áp vào lượt re-applies the quote. The BOQ download is then take-off quantity × quoted price, bilingual names in one cell.

Nhà cung cấp, báo giá, công việc

  • Nhà cung cấp — legal name, trade categories, contact, rating; each quote is linked to its supplier. Nạp từ WBS imports the shared WBS directory: the VICEM / Hòa Phát supplier trees (with parent and member rows), the major-supplier list and the sample equipment quotes. The import is idempotent, and unverified legal structures are flagged.
  • Báo giá — every quote received, its lines and the take-off row each line priced; status (đã xin giá / đã nhận / chọn / loại), validity.
  • Công việc — the QTO run opens one for every row without a quantity or resting on an assumption, and for every failed cross-check; add your own (xin báo giá, hỏi chủ đầu tư), assign, set a due date, close.

Writes to these follow the admin gate: open unless WBS_ADMIN_SECRET is set.

From WBS to BOQ: adding a quote

The WBS table holds quantities only. Adding a quote (báo giá) completes the BOQ with two price groups between Khối lượng and Ghi chú:

Group Columns
金额(VNĐ)Thành tiền 主材单价(含损耗)Đơn giá vật liệu chính · 施工单价 Đơn giá xây dựng · 全费用综合单价 Đơn giá tổng · 合价 Thành tiền
金额(元)Thành tiền the same four, in 元

On the run page:

  1. Tải mẫu xin báo giá (Excel) downloads the quantity sheet in the BOQ layout with empty price cells: 13 columns A–M, a three-row merged header, SUBTOTAL per section, =ROUND(D*G,0) per row and the 元 group as VNĐ / $L$4, where L4 holds the rate ("1元 = 3650").
  2. Upload the filled-in sheet (.xlsx, .csv, .tsv) under Báo giá → BOQ and enter the rate. Rows are matched by name (either language of a bilingual name, in sheet order for repeated names); the quantities of the run are never overwritten. Unmatched quote rows are listed.
  3. The table switches to the full BOQ and the download becomes Tải BOQ (Excel).

Derived cells: đơn giá tổng = vật liệu chính + xây dựng when the quote gives no total unit price; thành tiền = khối lượng × đơn giá tổng; 元 = VNĐ ÷ rate unless the quote states 元 itself. A two-row header (a currency group over its sub-columns) is read as one header, and a price column marked 元 / CNY / RMB goes to the 元 group.

API: POST /api/wbs/runs/:id/quote (multipart file and/or cny_rate), GET /api/wbs/runs/:id/boq (the workbook). Code: src/lib/wbs/boq.ts, boq-xlsx.ts, quote.ts.

Tính toán điện chuẩn TCVN 7447-5-52 & Sinh quy cách BOQ (/wbs/electrical)

Một dòng BOQ điện theo TT 38/2026 Phụ lục III (ví dụ BA.16300 Lắp đặt dây dẫn 3 ruột hay BA.18200 Lắp đặt aptomat 1 pha) không thể định giá chính xác nếu thiếu quy cách vật tư (tiết diện cáp CXV 3x6, trị định mức & dòng cắt MCB C32A/6kA) và nhóm nhân công (Nhóm 3 vs Nhóm 4).

Mở Tính toán điện (TCVN) trên thanh điều hướng WBS Cloud để chạy toàn bộ chuỗi tính kỹ thuật gắn trực tiếp với BOQ:

  1. Chọn tiết diện cáp theo TCVN 7447-5-52:2010 (≡ IEC 60364-5-52:2009):
    • Bảng dòng chịu tải Iz gốc B.52.2–B.52.5 cho đồng/nhôm, PVC 70 °C & XLPE 90 °C, 2 & 3 ruột mang tải, phương pháp lắp đặt A1 / A2 / B1 / B2 / C.
    • Hiệu chỉnh nhiệt độ môi trường Bảng B.52.14 — mặc định 40 °C theo khí hậu Việt Nam (TCVN 9207:2012 điều 5.7: PVC 0.87, XLPE 0.91).
    • Hệ số suy giảm nhóm mạch Bảng B.52.17 (5 kiểu bố trí: bó lại, 1 lớp trên tường, máng đục lỗ, thang cáp...).
    • Kiểm tra tổn thế ΔU% tách riêng giới hạn TCVN 9207:2012: ≤ 3% cho mạch chiếu sáng, ≤ 5% cho mạch động lực/ổ cắm.
  2. Kiểm tra ngắn mạch (IEC 60949) & chọn thiết bị bảo vệ (TCVN 7447-4-43:2010):
    • Quy chiếu trở kháng lưới và MBA về phía thứ cấp 400 V / 230 V, tính Icc max / Icc min, tự chọn MCB/MCCB và kiểm tra khả năng cắt Icu (kA).
  3. Nhóm nhân công TT 37/2026 & Chi phí chung TT 36/2026:
    • Tự quyết định Nhóm 3 (điện dân dụng trong nhà) hay Nhóm 4 (hạ tầng kỹ thuật, đường dây ngoài trời, báo cháy, camera, đo lường) theo mã định mức và loại công trình.
    • Tra đơn giá nhân công mẫu các tỉnh (TP.HCM/BR-VT, Hà Nội, Quảng Ninh, Thanh Hóa, Gia Lai) và tỷ lệ CP chung theo quy mô gói thầu (≤15 tỷ: 65%, ≤50 tỷ: 62%, ≤100 tỷ: 59%, >100 tỷ: 55%).
    • Kèm danh sách các hạng mục ngoài Phụ lục III (vỏ tủ điện, trạm biến áp, báo cháy, chống sét, đào rãnh AD.*) cần tách báo giá.

Kịch bản kiểm thử thực tế (/wbs/electrical)

  • Case 1 (Mạch nhánh xưởng 3 pha 32A, 45m, XLPE, phương pháp C, 40°C, 3 mạch đi chung): bấm nút mẫu đầu tiên trên /wbs/electrical → kỳ vọng ra CXV 3x6 (Iz bảng 52 A × 0.91 × 0.70 = 33.12 A, ΔU = 1.968%), Icc max = 1764.3 A, MCB 3P C32A/6kA, và 2 dòng BOQ (BA.16300 + BA.18300).
  • Case 2 (Chiếu sáng văn phòng 1 pha 10A, 35m, PVC, B1, bật Mạch chiếu sáng ΔU ≤ 3%): kiểm tra tiết diện tự tăng lên để đảm bảo ΔU% ≤ 3%.
  • Case 3 (Đổi loại công trình Dân dụng → Hạ tầng kỹ thuật tại Quảng Ninh Vùng I): kiểm tra BA.16300 tự đổi từ Nhóm 3 (312.000đ) sang Nhóm 4 (338.000đ).

Job schedules

Periodic jobs are still stored and run by the worker (/api/wbs/worker):

  • pipeline-tick — advances queued runs every 5 minutes.
  • cleanup-nightly — prunes old uploads and runs (7-day floor).

The Scheduler tab was removed from the console; schedules are managed through /api/wbs/schedules. On deployments with WBS_ADMIN_SECRET set, mutations need the admin secret.

Graph projection (operators)

When a Neo4j AuraDB instance is configured (NEO4J_URI), every run's lineage is mirrored into the graph and queryable with Cypher. Mirroring is fail-soft: Postgres remains the source of truth.