CREATE TABLE `dhc_order_ledger` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `lhz_no` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '落货纸号',
  `roll_plan_number` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '滚动计划号',
  `product_model` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '生产版本',
  `order_qty` int DEFAULT '0' COMMENT '订单数量',
  `no_product_num` int DEFAULT '0' COMMENT '未做落货纸数量',
  `product_num` int DEFAULT '0' COMMENT '落货纸数量',
  `sales_area_code` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '销售区域编码',
  `sales_area_name` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '销售区域名称',
  `country_code` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '国家编码',
  `country_name` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '国家名称',
  `customer_name` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '客户名称',
  `real_customer` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '真实客户',
  `brand_code` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '品牌编码',
  `brand_name` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '品牌名称',
  `trade_terms` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '贸易条款',
  `fob_unit_price` decimal(16,2) DEFAULT '0.00' COMMENT 'FOB单价',
  `fob_price` decimal(16,2) DEFAULT '0.00' COMMENT 'FOB总金额',
  `cif_unit_price` decimal(16,2) DEFAULT '0.00' COMMENT 'CIF单价',
  `cif_price` decimal(16,2) DEFAULT '0.00' COMMENT 'CIF总金额',
  `move_price` decimal(16,2) DEFAULT '0.00' COMMENT '总运费',
  `premium` decimal(16,2) DEFAULT '0.00' COMMENT '总保费',
  `cg_unit_price` decimal(16,2) DEFAULT '0.00' COMMENT '预估保值单价',
  `cg_price` decimal(16,2) DEFAULT '0.00' COMMENT '预估保值总额',
  `po_price` decimal(16,2) DEFAULT '0.00' COMMENT 'PO总金额',
  `exw_unit_price` decimal(16,2) DEFAULT '0.00' COMMENT 'EXW单价',
  `actual_invoiced_amount` decimal(16,2) DEFAULT '0.00' COMMENT '实际开票金额',
  `hong_kong_invoice_price` decimal(16,2) DEFAULT '0.00' COMMENT '香港发票价格（运保费不单列）',
  `hong_kong_price` decimal(16,2) DEFAULT '0.00' COMMENT '香港发票总金额（运保费不单列）',
  `product_size` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '尺寸',
  `completemach_code` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '整机编码',
  `new_material_code` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '新物料号',
  `contract_no` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '合同号',
  `order_status_name` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '订单状态',
  `order_status_code` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '订单状态编码',
  `customer_model` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '销售型号',
  `screen_code` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '屏型号',
  `production_base_name` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '生产基地',
  `pack_way_name` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '包装方式',
  `order_type` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '订单类别',
  `ship_port_name` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '起运港',
  `destn_port_name` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '目的港',
  `air_line` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '航线',
  `ship_company` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '船公司',
  `so_no` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'SO号',
  `plan_delivery_date` date DEFAULT NULL COMMENT '计划交货期',
  `plan_delivery_weekday` varchar(10) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '计划交货期Weekday',
  `ordplan_date` date DEFAULT NULL COMMENT '排产交货期',
  `formal_plan_delivery_date` date DEFAULT NULL COMMENT '正式版滚动计划交货期',
  `formal_plan_qty` int DEFAULT '0' COMMENT '正式版滚动计划数量',
  `current_inventory` int DEFAULT '0' COMMENT '当前库存数',
  `delivery_date_diff` int DEFAULT '0' COMMENT 'GSS交货期与正式版交货期差异',
  `qty_diff` int DEFAULT '0' COMMENT 'GSS数量与正式版数量差异',
  `plan_etd` date DEFAULT NULL COMMENT 'ETD计划',
  `plan_eta` date DEFAULT NULL COMMENT 'ETA计划',
  `plan_etd_weekday` varchar(10) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'ETD Weekday（计划）',
  `lhz_etd` date DEFAULT NULL COMMENT '落货纸ETD',
  `dc_etd` date DEFAULT NULL COMMENT '订舱ETD',
  `etd_actual_time` datetime DEFAULT NULL COMMENT 'ETD（实时）',
  `eta_actual_time` datetime DEFAULT NULL COMMENT 'ETA（实时）',
  `eta_difference` int DEFAULT '0' COMMENT 'ETA（差异）',
  `special_remark` varchar(500) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '特殊备注',
  `atd` datetime DEFAULT NULL COMMENT 'ATD',
  `ata` datetime DEFAULT NULL COMMENT 'ATA',
  `ztd_date` date DEFAULT NULL COMMENT '提单日期',
  `is_inspection` char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '是否验货（0否 1是）',
  `sales_assistant_name` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '销售协调',
  `logistics_personnel` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '物流人员',
  `lhz_status_name` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '落货纸状态',
  `order_entry_month` varchar(7) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '报关月份',
  `service_type` char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '是否执行零号（0否 1是）',
  `product_line_type` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '产品线',
  `rk_qty` int DEFAULT '0' COMMENT '累计入库数',
  `product_big_category` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '产品大类',
  `zero_roll_plan_number` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '零号滚动计划号',
  `box_type` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '箱型箱量',
  `manu_remark` varchar(500) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '手工备注',
  `overseas_factory` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '海外工厂',
  `in_production` char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '生产中（0否 1是）',
  `in_stock` char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '有库存（0否 1是）',
  `loaded_in_container` char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '已装柜（0否 1是）',
  `has_shipped` char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '已出运（0否 1是）',
  `delivery_status` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '交付状态',
  `customs_declaration_number` int DEFAULT '0' COMMENT '关单数量',
  `customs_declaration_reason` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '关单原因',
  `create_by` varchar(64) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '创建者',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '更新者',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `remark` varchar(500) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '备注',
  `del_flag` char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标志（0代表存在 1代表删除）',
  PRIMARY KEY (`id`),
  KEY `idx_lhz_no` (`lhz_no`),
  KEY `idx_roll_plan_number` (`roll_plan_number`),
  KEY `idx_customer_name` (`customer_name`),
  KEY `idx_brand_code` (`brand_code`),
  KEY `idx_order_status_code` (`order_status_code`),
  KEY `idx_plan_delivery_date` (`plan_delivery_date`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='订单台账表';

---------------------------------------------------------
-- 菜单 SQL
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
VALUES(2000, '订单台账', 0, 1, 'orderLedger', 'gss/orderLedger/index', 1, 0, 'C', '0', '0', 'gss:orderLedger:list', 'list', 'admin', sysdate(), '', null, '订单台账菜单');

-- 按钮父菜单ID
SELECT @parentId := LAST_INSERT_ID();

-- 按钮 SQL
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
VALUES (2001, '订单台账查询', @parentId, 1, '#', '', 1, 0, 'F', '0', '0', 'gss:orderLedger:query', '#', 'admin', sysdate(), '', null, '');

INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
VALUES (2002, '订单台账新增', @parentId, 2, '#', '', 1, 0, 'F', '0', '0', 'gss:orderLedger:add', '#', 'admin', sysdate(), '', null, '');

INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
VALUES (2003, '订单台账修改', @parentId, 3, '#', '', 1, 0, 'F', '0', '0', 'gss:orderLedger:edit', '#', 'admin', sysdate(), '', null, '');

INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
VALUES (2004, '订单台账删除', @parentId, 4, '#', '', 1, 0, 'F', '0', '0', 'gss:orderLedger:remove', '#', 'admin', sysdate(), '', null, '');

INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
VALUES (2005, '订单台账导出', @parentId, 5, '#', '', 1, 0, 'F', '0', '0', 'gss:orderLedger:export', '#', 'admin', sysdate(), '', null, '');