Skip to content

Core Traceability (TXNG & Multi-Industry F41) ​

Phân hệ Core Traceability (TXNG) chiếm hơn 45 modules trong apps/backend/src/modules/, bao phủ toàn bộ hoạt động sản xuất, chế biến, đóng gói, kho vận, thương mại B2B/B2C và recall sản phẩm của doanh nghiệp.


1. End-to-End TXNG Business Flow ​

Rendering diagram...

2. Chi tiết Các Nhóm Module Nghiệp vụ ​

2.1. Multi-Industry Taxonomy & Input Sources (TXNG-F41) ​

Module (apps/backend/src/modules/*)Endpoint chính (/api/v1/*)Chức năng & Business Rules
industries, general-industry, segment, family, classes, brick/industries, /segments, /families, /classes, /bricksQuản lý cây phân loại ngành kinh tế Việt Nam VSIC 2025 và cây phân loại sản phẩm GS1 GPC 4 cấp.
attribute-templates/attribute-templatesQuản lý Dynamic Attribute Templates (AttributeTemplate & AttributeDefinition) gắn theo từng ngành nghề (default_template_id).
input-sources & input-source-suppliers/input-sources, /input-source-suppliersQuản lý 5 nhóm nguồn đầu vào: Giống (GENETIC), Nguyên liệu thô (RAW_MATERIAL), Linh kiện/Bán thành phẩm (COMPONENT), Vật tư tiêu hao (CONSUMABLE), và Khác (OTHER). Tự động validate export_price >= import_price, chuẩn hóa chứng từ nhập khẩu (international_shipping_docs, customs_declaration_docs) khi origin_country !== 'VN', phát hành Digital Product Passport (DigitalProductPassport), và enqueue event input_source.created vào integration_outbox.
materials/materialsQuản lý vật tư nông nghiệp/công nghiệp (phân bón, thuốc BVTV, thức ăn chăn nuôi, phụ gia...), workflow phê duyệt (approve-material) và cảnh báo vật tư cấm/hạn chế.
raw-material-zones & facilities/raw-material-zones, /facilitiesQuản lý vùng trồng/vùng nuôi (polygon coordinates, diện tích, thổ nhưỡng, nguồn nước) và cơ sở sản xuất/nhà máy kèm chứng nhận VietGAP/GlobalGAP/HACCP/ISO (company_certifications).

2.2. Products (GTIN), Production Plans & Batches (Batch) ​

Module (apps/backend/src/modules/*)Endpoint chính (/api/v1/*)Chức năng & Business Rules
gtin & gtin-reviews/gtin, /public/gtin/:gtin14/reviewsQuản lý sản phẩm thương phẩm, tự động sinh/đồng bộ mã nda_gtin_code (GTIN-14), quy trình sản xuất chuẩn (production-processes), và consumer reviews (gtin-reviews).
production-plans & plan-input-links/production-plans, /plan-input-linksLập kế hoạch sản xuất (DRAFT → PENDING → APPROVED → IN_PROGRESS → COMPLETED). Module plan-input-links liên kết các lô nguyên liệu đầu vào hoặc input sources vào kế hoạch/lô sản xuất, sử dụng Row-Level Lock FOR UPDATE OF wi để trừ tồn kho chính xác.
stamps, blank-stamps, stamp-print-plans, qr-codes/stamps, /blank-stamps, /stamp-print-plans, /qr-codesQuản lý quota tem của doanh nghiệp, phôi tem trắng (blank-stamps), kế hoạch in tem (stamp-print-plans sinh hàng loạt mã Sgtin ở trạng thái REGISTERED), và kích hoạt/vô hiệu hóa hiển thị QR công khai (public_activated_at).
batchs/batchesCore module của phân hệ sản xuất (TXNG-F09). Khi tạo batch (BatchService.create):
1. Tự động sinh mã lô {SHORT}-LOT-{CROP|LIVE|AQUA|PROC}-{YYYYMMDD}-{SEQ}.
2. Nếu chưa chọn kế hoạch in tem, tự động tạo StampPrintPlan và gán quantity mã Sgtin vào batch.
3. Nếu có PlanInputLink, tự động enqueue sự kiện CTE-MATERIAL-IN vào vc_outbox để ký W3C VC.
4. Tự động khởi tạo danh sách ProductionLog từ quy trình mẫu và chuyển trạng thái ProductionPlan từ APPROVED sang IN_PROGRESS.
production-logs/production-logsGhi nhận nhật ký canh tác/chế biến theo từng công đoạn (cultivation_event_type), đính kèm hình ảnh thực địa và kích hoạt ký VC CTE-PRODUCTION.

2.3. Packaging, Combo Assembly, Warehouse & Cross-Enterprise Distribution ​

Module (apps/backend/src/modules/*)Endpoint chính (/api/v1/*)Chức năng & Business Rules
packaging-plans/packaging-plansMulti-level Packaging (SGTIN đơn lẻ → Box → Carton → Pallet / SSCC), confirm đóng gói (confirm) và xuất thẳng sang kho thành phẩm (export).
combo-assemblies/combo-assembliesLắp ráp sản phẩm Combo (TXNG-F32) từ nhiều SGTIN thành phần thuộc các batches khác nhau, hỗ trợ tháo rã (disassemble) và Cascading Recall tự động.
warehouses, stock-transfers, stock-deduction-requests/warehouses, /stock-transfers, /stock-deduction-requestsQuản lý tồn kho theo 3 chiều (theo SGTIN, theo PackagingUnit, theo Batch/Product), kiểm kê kho (stock-take), và internal stock transfer giữa các kho của cùng doanh nghiệp.
company-link, purchase-orders, shipment-orders/company-links, /purchase-orders, /shipment-ordersThiết lập quan hệ đối tác cung ứng (CompanyLink), tạo đơn đặt hàng B2B (PurchaseOrder với mã PO-{YYYYMMDD}-{SEQ} dùng pg_advisory_xact_lock), và điều phối Cross-Enterprise Shipment (ShipmentOrder + CrossEnterpriseShipmentsService) tích hợp trực tiếp với Driver trên Zalo MiniApp.
sale-points, pos-sales, buyer-confirmations/sale-points, /pos-transactions, /pos-simulation, /buyer-confirmationsQuản lý điểm bán lẻ, giao dịch bán hàng tại quầy POS (chuyển trạng thái SGTIN sang SOLD và ký VC CTE-SOLD), POS Simulator (PosSimulatorService) phục vụ load testing, và buyer confirmation từ phía người mua.
traceback, trace, public-trace/traceback, /trace, /public/traceBackward Traceability (từ SGTIN/Batch thành phẩm ngược về vùng nguyên liệu và input sources) và Forward Traceability (xác định toàn bộ các đơn vị nhận hàng bị ảnh hưởng khi cần thực hiện recall).

Technical Documentation & Security Audit Report — kl-audit v3.0