73 lines
4.5 KiB
SQL
73 lines
4.5 KiB
SQL
|
||
DROP TABLE IF EXISTS `wms_stock`;
|
||
|
||
create table wms_stock
|
||
(
|
||
stock_id bigint auto_increment comment '主键ID'
|
||
primary key,
|
||
warehouse_id bigint not null comment '仓库/库区/库位ID',
|
||
item_id bigint not null comment '物品ID(指向原材料或产品主键)',
|
||
item_type varchar(20) not null comment '物品类型(raw_material/product)',
|
||
batch_no varchar(50) null comment '批次号(可选)',
|
||
remark varchar(255) null comment '备注',
|
||
del_flag tinyint(1) default 0 not null comment '删除标志(0=正常,1=已删除)',
|
||
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
|
||
create_by varchar(50) null comment '创建人',
|
||
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
|
||
update_by varchar(50) null comment '更新人',
|
||
constraint fk_stock_warehouse
|
||
foreign key (warehouse_id) references wms_warehouse (warehouse_id)
|
||
)
|
||
comment '库存表:原材料-钢卷-库区的存放关系' charset = utf8mb4;
|
||
|
||
|
||
create index idx_stock_warehouse
|
||
on wms_stock (warehouse_id);
|
||
|
||
|
||
create table wms_material_coil
|
||
(
|
||
coil_id bigint auto_increment comment '主键ID'
|
||
primary key,
|
||
enter_coil_no varchar(50) not null comment '入场钢卷号(年份后两位+月份+当月第几个,如25100001、25102422)',
|
||
current_coil_no varchar(50) not null comment '当前钢卷号(入场钢卷号和当前钢卷号可能不同)',
|
||
supplier_coil_no varchar(50) null comment '厂家原料卷号',
|
||
data_type tinyint(1) default 1 not null comment '数据类型(0=历史,1=现存)',
|
||
warehouse_id bigint null comment '所在库区ID',
|
||
next_warehouse_id bigint null comment '下一库区ID',
|
||
qrcode_record_id bigint null comment '关联二维码ID(wms_generate_record.record_id)',
|
||
team varchar(50) null comment '班组',
|
||
has_merge_split tinyint(1) default 0 not null comment '是否合卷/分卷(0=否,1=分卷,2=合卷)',
|
||
parent_coil_nos varchar(500) null comment '父卷号(合卷或分卷时用,逗号分隔)',
|
||
item_id bigint not null comment '物品ID(指向原材料或产品主键)',
|
||
item_type varchar(20) not null comment '物品类型(raw_material/product)',
|
||
gross_weight decimal(10,2) null comment '毛重(kg)',
|
||
net_weight decimal(10,2) null comment '净重(kg)',
|
||
status tinyint(1) default 0 null comment '状态(0=在库,1=在途,2=已出库)',
|
||
remark varchar(255) null comment '备注',
|
||
del_flag tinyint(1) default 0 not null comment '删除标志(0=正常,1=已删除)',
|
||
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
|
||
create_by varchar(50) null comment '创建人',
|
||
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
|
||
update_by varchar(50) null comment '更新人',
|
||
constraint uk_enter_coil_no
|
||
unique (enter_coil_no) comment '入场钢卷号唯一约束',
|
||
constraint fk_coil_warehouse
|
||
foreign key (warehouse_id) references wms_warehouse (warehouse_id),
|
||
constraint fk_coil_next_warehouse
|
||
foreign key (next_warehouse_id) references wms_warehouse (warehouse_id),
|
||
constraint fk_coil_qrcode
|
||
foreign key (qrcode_record_id) references wms_generate_record (record_id)
|
||
)
|
||
comment '钢卷物料表' charset = utf8mb4;
|
||
|
||
create index idx_coil_current_no
|
||
on wms_material_coil (current_coil_no);
|
||
|
||
create index idx_coil_type
|
||
on wms_material_coil (data_type);
|
||
|
||
create index idx_coil_warehouse
|
||
on wms_material_coil (warehouse_id);
|
||
|