Knowledge

VGM Declaration 生成工具

_raw/openclaw/p5678-sessions-skills-docs-logs-2026-05-25/skills/vgm-declaration/SKILL.md


name: vgm-declaration description: 船政出口业务工具:将销售订单发货表.xlsx 导入 SQLite,并自动生成 Container VGM Declaration 申报文件。当用户需要处理销售订单发货表、生成 VGM 申报单、填写集装箱重量申报、处理船名航次/SO号/柜号数据时触发此 skill。


VGM Declaration 生成工具

目录结构

vgm-declaration/
├── SKILL.md
├── scripts/
│   ├── import_sales_data.py   # 导入 xlsx → SQLite
│   └── generate_vgm.py        # 从 SQLite 生成 VGM Declaration
├── assets/
│   └── template/
│       └── Container VGM Declaration.xlsx   # VGM 申报模板
└── output/                    # 生成结果(sales.db 和 VGM xlsx 均存放于此)

所有路径均为相对路径,脚本从 scripts/ 目录运行时自动定位。

工作流程

第一步:导入销售订单发货表

bash
python3 scripts/import_sales_data.py <xlsx_path> [db_path]
  • xlsx_path:销售订单发货表.xlsx 路径
  • db_path(可选):SQLite 输出路径,默认:`output/sales.db`
  • 重复导入会清空并重建表

第二步:生成 VGM Declaration

bash
python3 scripts/generate_vgm.py [db_path] [output_dir] [--template <path>]
  • db_path(可选):默认 output/sales.db
  • output_dir(可选):默认 output/,生成结果存放于此
  • 按「船名航次 + SO号」分组,每组生成一个 xlsx 文件
  • 输出文件名:Container VGM Declaration_<vessel>_<so>.xlsx
  • --template(可选):自定义模板路径,默认使用 assets/template/ 中的内置模板

关键规则

VGM 计算公式

VGM = 柜重 + Σ(单箱毛重KG × 箱数)   按柜号分组求和

模板填写位置

位置内容
D6船名航次(Vessel Voyage)
D7SO号(Liner Booking #)
B13起Item No.(序号,从1开始)
C13起Container Number(柜号)
E13起Container Type(柜型)
F13起Verified Gross Mass in kg(VGM)

多柜处理

同一船名航次 + SO号下存在多个柜号时,从第13行起每柜占一行,序号递增。

数据库表结构

表名:销售订单发货表

字段名列名类型
订单号order_noTEXT
客户customerTEXT
船名航次vessel_voyageTEXT
提单号bill_of_ladingTEXT
SO号so_noTEXT
柜号container_noTEXT
封签seal_noTEXT
柜重container_weightREAL
客户订单编号customer_order_noTEXT
柜型container_typeTEXT
目的港destination_portTEXT
货号item_noTEXT
客户货号customer_item_noTEXT
商品英文名product_name_enTEXT
销售数量sales_qtyREAL
箱数carton_qtyREAL
单箱数量qty_per_cartonREAL
箱子长cmcarton_lengthREAL
箱子宽cmcarton_widthREAL
箱子高cmcarton_heightREAL
体积m³volume_cbmREAL
单箱净重KGnet_weight_per_cartonREAL
单箱毛重KGgross_weight_per_cartonREAL
净重total_net_weightREAL
毛重total_gross_weightREAL
销售单价unit_priceREAL
实际销售金额actual_amountREAL
注意:销售订单发货表第1行为辅助行,第2行为表头,数据从第3行开始。毛重字段在 Excel 中为公式,脚本自动按 单箱毛重KG × 箱数 计算。