CREATE TABLE `lms_package_point`
(
    `point_id`        bigint                                          NOT NULL COMMENT '库存记录标识',
    `point_code`      varchar(20) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '点位编码',
    `point_name`      varchar(20) CHARACTER SET utf8 COLLATE utf8_bin              DEFAULT NULL COMMENT '点位名称',
    `point_type`      varchar(20) CHARACTER SET utf8 COLLATE utf8_bin              DEFAULT NULL COMMENT '点位类型',
    `container_name`  varchar(32) CHARACTER SET utf8 COLLATE utf8_bin              DEFAULT NULL COMMENT '子卷号',
    `point_status`    varchar(20) CHARACTER SET utf8 COLLATE utf8_bin              DEFAULT NULL COMMENT '库存状态',
    `vehicle_code`    varchar(20) CHARACTER SET utf8 COLLATE utf8_bin              DEFAULT NULL COMMENT '载具号',
    `block`           varchar(20) CHARACTER SET utf8 COLLATE utf8_bin              DEFAULT NULL COMMENT '区块',
    `point_location`  varchar(20) CHARACTER SET utf8 COLLATE utf8_bin              DEFAULT NULL COMMENT '位置',
    `sort_seq`        decimal(5, 0)                                   NOT NULL     DEFAULT '1' COMMENT '顺序号',
    `is_used`         bit(1)                                          NOT NULL     DEFAULT b'0' COMMENT '是否启用',
    `remark`          varchar(1000) CHARACTER SET utf8 COLLATE utf8_bin            DEFAULT NULL COMMENT '备注',
    `plan`            varchar(20) CHARACTER SET utf8 COLLATE utf8_bin              DEFAULT NULL COMMENT '规划',
    `row_num`         char(6) CHARACTER SET utf8 COLLATE utf8_bin                  DEFAULT '0' COMMENT '排',
    `col_num`         char(6) CHARACTER SET utf8 COLLATE utf8_bin                  DEFAULT '0' COMMENT '列',
    `depth`           char(1) CHARACTER SET utf8 COLLATE utf8_bin                  DEFAULT '0' COMMENT '深浅位0浅位1深位',
    `wait_point_type` varchar(20) CHARACTER SET utf8 COLLATE utf8_bin              DEFAULT '0' COMMENT '所属等待点类型',
    `lock_status`     varchar(20) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL     DEFAULT '0' COMMENT '锁状态',
    `creator`         varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者',
    `create_time`     datetime                                        NOT NULL     DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater`         varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '更新者',
    `update_time`     datetime                                        NOT NULL     DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted`         bit(1)                                          NOT NULL     DEFAULT b'0' COMMENT '是否删除',
    PRIMARY KEY (`point_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC COMMENT='装箱区点位库存表';

-- 子卷下线点初始化数据
INSERT INTO lms_package_point (point_id, point_code, point_name, point_type, point_status)
SELECT UUID_SHORT(), seed.point_code, seed.point_name, '1', '1'
FROM (
         SELECT 'ZJXX_01' AS point_code, '子卷下线点01' AS point_name
         UNION ALL
         SELECT 'ZJXX_02', '子卷下线点02'
         UNION ALL
         SELECT 'ZJXX_03', '子卷下线点03'
         UNION ALL
         SELECT 'ZJXX_04', '子卷下线点04'
         UNION ALL
         SELECT 'ZJXX_05', '子卷下线点05'
         UNION ALL
         SELECT 'ZJXX_06', '子卷下线点06'
     ) seed
WHERE NOT EXISTS (
    SELECT 1
    FROM lms_package_point existing
    WHERE existing.point_code = seed.point_code
      AND existing.deleted = b'0'
);

-- 菜单 SQL
INSERT INTO system_menu(name, permission, type, sort, parent_id,
                        path, icon, component, status, component_name)
VALUES ('装箱区管理', '', 2, 0, 6741,
        'package-point', '', 'lms/packagepoint/index', 0, 'PackagePoint');

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

-- 按钮 SQL
INSERT INTO system_menu(name, permission, type, sort, parent_id,
                        path, icon, component, status)
VALUES ('装箱区点位库存查询', 'lms:package-point:query', 3, 1, @parentId,
        '', '', '', 0);
INSERT INTO system_menu(name, permission, type, sort, parent_id,
                        path, icon, component, status)
VALUES ('装箱区点位库存创建', 'lms:package-point:create', 3, 2, @parentId,
        '', '', '', 0);
INSERT INTO system_menu(name, permission, type, sort, parent_id,
                        path, icon, component, status)
VALUES ('装箱区点位库存更新', 'lms:package-point:update', 3, 3, @parentId,
        '', '', '', 0);
INSERT INTO system_menu(name, permission, type, sort, parent_id,
                        path, icon, component, status)
VALUES ('装箱区点位库存删除', 'lms:package-point:delete', 3, 4, @parentId,
        '', '', '', 0);
INSERT INTO system_menu(name, permission, type, sort, parent_id,
                        path, icon, component, status)
VALUES ('装箱区点位库存导出', 'lms:package-point:export', 3, 5, @parentId,
        '', '', '', 0);
