Files
WareShipManifest/reports/sign_receipt/query.sql
Misaka_Company df8f25f6da Add sign-off receipt report and refine packing list: single-line info bar, real-glyph row height, auto-paginated detail table
- Packing list: info bar changed to a single-line three-column layout (schedule no. | order no. | box no.); packing date moved to bottom-right on the same row as the total; date separator changed to slash
- Packing list: range column widened 20->30mm; quantity/position-no./remark start shifted right 10mm; remark column narrowed to compensate; total width unchanged
- Packing list: detail cells now use line_spacing=1.0 + valign=top; separators changed to thin solid lines at row bottom (+1mm line spacing); placeholder empty rows no longer step y
- Packing list: row height estimation now uses fpdf2's same simhei glyph measured width (replacing rough character-count estimate); _clean adds control-character cleanup
- New sign-off receipt report reports/sign_receipt: master+detail linked query, ReportBro auto-paginated table, PyMuPDF stamped footer (document no. / page no. / sign-off column)
- run.py: required params now read from each report's config.yaml; default output path auto-generated; added transform.stamp_footer post-processing hook
- .gitignore: ignore .workbuddy/
2026-08-04 08:55:09 +08:00

73 lines
3.2 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- 签收单:按序列号 receipt_no 取主表头 + 聚合多排产号多箱的明细。
-- 参数receipt_no (str, 11 位序列号)
-- 注load_sql 会剥离整行 -- 注释,故注释里可自由书写中文。
--
-- 数据来源:
-- warehouseOutbound.delivery_receipt 签收单主表(收发方/客户总排行号/运输/日期)
-- warehouseOutbound.delivery_receipt_item 签收单明细(仅 receipt_no + paichan_no + box_no
-- CargoTrace.finished_goods_box 箱头(按 paichan_no + box_no 定位)
-- CargoTrace.finished_goods_box_item 箱内明细(总排号 + 数量)
-- productionContractData.26年压力表/温度计合同数据 产品信息
--
-- 设计要点:
-- * 主表 LEFT JOIN 进明细链路,使每一行都冗余主表头字段;
-- transform 取首行作为单头,其余行作为明细预展开。
-- * 明细粒度:一个 (箱号, 产品) 一行;同一箱同一产品数量 SUM 聚合。
-- * 排产号/订单号:由「箱内排产号 paichan_no + 合同表[订单号]」组合而成,
-- 对应示例"排产号/订单号"列(不再单独取合同号)。
-- * 客户总排行号 customer_total_no 已在主表,直接带出,与内部 paichan_no 无关。
SELECT
h.receipt_no,
h.receipt_date,
h.seq,
h.shipper_name,
h.shipper_address,
h.shipper_phone,
h.receiver_name,
h.receiver_address,
h.receiver_phone,
h.customer_order_no,
h.customer_total_no,
h.transport_mode,
h.ship_date,
h.sign_date,
h.signed_by,
h.maker,
h.remark AS receipt_remark,
b.box_no,
di.paichan_no AS paichan_no,
COALESCE(p.[], t.[]) AS product_name,
COALESCE(p.[], t.[]) AS model,
COALESCE(p.[], t.[]) AS range_,
COALESCE(p.[], t.[]) AS weihao,
SUM(bi.quantity) AS qty,
COALESCE(p.[], t.[]) AS order_no
FROM warehouseOutbound.delivery_receipt h
JOIN warehouseOutbound.delivery_receipt_item di
ON di.receipt_no = h.receipt_no
JOIN CargoTrace.finished_goods_box b
ON b.paichan_no = di.paichan_no AND b.box_no = di.box_no
JOIN CargoTrace.finished_goods_box_item bi
ON bi.box_id = b.id
LEFT JOIN [productionContractData].[26] p
ON p.[] = bi.zongpai_no
LEFT JOIN [productionContractData].[26] t
ON t.[] = bi.zongpai_no
WHERE h.receipt_no = :receipt_no
GROUP BY
h.receipt_no, h.receipt_date, h.seq,
h.shipper_name, h.shipper_address, h.shipper_phone,
h.receiver_name, h.receiver_address, h.receiver_phone,
h.customer_order_no, h.customer_total_no,
h.transport_mode, h.ship_date, h.sign_date, h.signed_by,
h.maker, h.remark,
b.box_no,
di.paichan_no,
COALESCE(p.[], t.[]),
COALESCE(p.[], t.[]),
COALESCE(p.[], t.[]),
COALESCE(p.[], t.[]),
COALESCE(p.[], t.[])
ORDER BY b.box_no;