158 lines
13 KiB
MySQL
158 lines
13 KiB
MySQL
|
|
-- 库存管理模块表结构、字典和菜单
|
||
|
|
|
||
|
|
drop table if exists warehouse_area;
|
||
|
|
create table warehouse_area (
|
||
|
|
id bigint(20) not null auto_increment comment '主键',
|
||
|
|
area_code varchar(64) default null comment '库区编码',
|
||
|
|
area_name varchar(100) not null comment '库区名称',
|
||
|
|
remark varchar(500) default null comment '备注',
|
||
|
|
create_time datetime default null comment '创建时间',
|
||
|
|
update_time datetime default null comment '更新时间',
|
||
|
|
primary key (id),
|
||
|
|
unique key uk_warehouse_area_code (area_code)
|
||
|
|
) engine=innodb auto_increment=1 comment='库区定义表';
|
||
|
|
|
||
|
|
drop table if exists product_info;
|
||
|
|
create table product_info (
|
||
|
|
id bigint(20) not null auto_increment comment '主键',
|
||
|
|
product_code varchar(64) default null comment '产品编码',
|
||
|
|
product_name varchar(100) not null comment '产品名称',
|
||
|
|
brand varchar(100) default null comment '品牌',
|
||
|
|
category varchar(100) default null comment '类别',
|
||
|
|
spec varchar(100) default null comment '规格型号',
|
||
|
|
unit varchar(32) default null comment '单位',
|
||
|
|
remark varchar(500) default null comment '备注',
|
||
|
|
create_time datetime default null comment '创建时间',
|
||
|
|
update_time datetime default null comment '更新时间',
|
||
|
|
primary key (id),
|
||
|
|
unique key uk_product_info_code (product_code)
|
||
|
|
) engine=innodb auto_increment=1 comment='产品信息表';
|
||
|
|
|
||
|
|
drop table if exists in_record;
|
||
|
|
create table in_record (
|
||
|
|
id bigint(20) not null auto_increment comment '主键',
|
||
|
|
in_no varchar(64) not null comment '入库单号',
|
||
|
|
area_id bigint(20) not null comment '库区id',
|
||
|
|
product_id bigint(20) not null comment '产品id',
|
||
|
|
in_type tinyint(1) not null comment '入库类型',
|
||
|
|
in_num decimal(16,3) not null comment '入库数量',
|
||
|
|
in_status tinyint(1) not null default 0 comment '入库状态',
|
||
|
|
operator varchar(64) default null comment '系统操作人',
|
||
|
|
in_operator varchar(64) default null comment '入库人',
|
||
|
|
confirm_time datetime default null comment '确认入库时间',
|
||
|
|
remark varchar(500) default null comment '备注',
|
||
|
|
create_time datetime default null comment '创建时间',
|
||
|
|
update_time datetime default null comment '更新时间',
|
||
|
|
primary key (id),
|
||
|
|
unique key uk_in_record_no (in_no),
|
||
|
|
key idx_in_record_area_product (area_id, product_id)
|
||
|
|
) engine=innodb auto_increment=1 comment='入库记录表';
|
||
|
|
|
||
|
|
drop table if exists stock_info;
|
||
|
|
create table stock_info (
|
||
|
|
id bigint(20) not null auto_increment comment '主键',
|
||
|
|
area_id bigint(20) not null comment '库区id',
|
||
|
|
product_id bigint(20) not null comment '产品id',
|
||
|
|
stock_num decimal(16,3) not null default 0.000 comment '当前库存数量',
|
||
|
|
last_check_time datetime default null comment '最近盘库时间',
|
||
|
|
create_time datetime default null comment '创建时间',
|
||
|
|
update_time datetime default null comment '更新时间',
|
||
|
|
primary key (id),
|
||
|
|
unique key uk_stock_area_product (area_id, product_id)
|
||
|
|
) engine=innodb auto_increment=1 comment='库存信息表';
|
||
|
|
|
||
|
|
drop table if exists out_record;
|
||
|
|
create table out_record (
|
||
|
|
id bigint(20) not null auto_increment comment '主键',
|
||
|
|
out_no varchar(64) not null comment '出库单号',
|
||
|
|
area_id bigint(20) not null comment '库区id',
|
||
|
|
product_id bigint(20) not null comment '产品id',
|
||
|
|
out_type tinyint(1) not null comment '出库类型',
|
||
|
|
out_num decimal(16,3) not null comment '出库数量',
|
||
|
|
source_no varchar(64) default null comment '关联单据号',
|
||
|
|
operator varchar(64) default null comment '系统操作人',
|
||
|
|
out_operator varchar(64) default null comment '出库人',
|
||
|
|
out_time datetime default null comment '出库时间',
|
||
|
|
remark varchar(500) default null comment '备注',
|
||
|
|
create_time datetime default null comment '创建时间',
|
||
|
|
update_time datetime default null comment '更新时间',
|
||
|
|
primary key (id),
|
||
|
|
unique key uk_out_record_no (out_no),
|
||
|
|
key idx_out_record_area_product (area_id, product_id)
|
||
|
|
) engine=innodb auto_increment=1 comment='出库记录表';
|
||
|
|
|
||
|
|
drop table if exists stock_check_record;
|
||
|
|
create table stock_check_record (
|
||
|
|
id bigint(20) not null auto_increment comment '主键',
|
||
|
|
check_no varchar(64) not null comment '盘点单号',
|
||
|
|
area_id bigint(20) not null comment '库区id',
|
||
|
|
product_id bigint(20) not null comment '产品id',
|
||
|
|
book_num decimal(16,3) not null comment '账面库存',
|
||
|
|
real_num decimal(16,3) not null comment '实际盘点数量',
|
||
|
|
diff_num decimal(16,3) not null comment '差异数量',
|
||
|
|
check_status tinyint(1) not null default 0 comment '盘点状态',
|
||
|
|
check_user varchar(64) default null comment '盘点人',
|
||
|
|
confirm_user varchar(64) default null comment '审核人',
|
||
|
|
confirm_time datetime default null comment '审核生效时间',
|
||
|
|
reason varchar(500) default null comment '差异原因',
|
||
|
|
create_time datetime default null comment '创建时间',
|
||
|
|
update_time datetime default null comment '更新时间',
|
||
|
|
primary key (id),
|
||
|
|
unique key uk_stock_check_no (check_no),
|
||
|
|
key idx_stock_check_area_product (area_id, product_id)
|
||
|
|
) engine=innodb auto_increment=1 comment='盘库记录表';
|
||
|
|
|
||
|
|
insert into sys_dict_type values(100, '入库类型', 'wms_in_type', '0', 'admin', sysdate(), '', null, '库存模块入库类型');
|
||
|
|
insert into sys_dict_type values(101, '入库状态', 'wms_in_status', '0', 'admin', sysdate(), '', null, '库存模块入库状态');
|
||
|
|
insert into sys_dict_type values(102, '出库类型', 'wms_out_type', '0', 'admin', sysdate(), '', null, '库存模块出库类型');
|
||
|
|
insert into sys_dict_type values(103, '盘点状态', 'wms_check_status', '0', 'admin', sysdate(), '', null, '库存模块盘点状态');
|
||
|
|
|
||
|
|
insert into sys_dict_data values(100, 1, '生产入库', '1', 'wms_in_type', '', 'primary', 'Y', '0', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_dict_data values(101, 2, '采购入库', '2', 'wms_in_type', '', 'success', 'N', '0', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_dict_data values(102, 3, '归还入库', '3', 'wms_in_type', '', 'info', 'N', '0', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_dict_data values(103, 4, '退货入库', '4', 'wms_in_type', '', 'warning', 'N', '0', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_dict_data values(104, 1, '待入库', '0', 'wms_in_status', '', 'warning', 'Y', '0', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_dict_data values(105, 2, '已入库', '1', 'wms_in_status', '', 'success', 'N', '0', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_dict_data values(106, 1, '生产出库', '1', 'wms_out_type', '', 'primary', 'Y', '0', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_dict_data values(107, 2, '退货出库', '2', 'wms_out_type', '', 'warning', 'N', '0', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_dict_data values(108, 3, '销售出库', '3', 'wms_out_type', '', 'success', 'N', '0', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_dict_data values(109, 1, '待确认', '0', 'wms_check_status', '', 'warning', 'Y', '0', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_dict_data values(110, 2, '盘点生效', '1', 'wms_check_status', '', 'success', 'N', '0', 'admin', sysdate(), '', null, '');
|
||
|
|
|
||
|
|
insert into sys_menu values('2000', '库存管理', '0', '5', 'warehouse', null, '', '', 1, 0, 'M', '0', '0', '', 'dict', 'admin', sysdate(), '', null, '库存管理目录');
|
||
|
|
insert into sys_menu values('2001', '库区定义', '2000', '1', 'area', 'warehouse/area/index', '', '', 1, 0, 'C', '0', '0', 'warehouse:area:list', 'tree', 'admin', sysdate(), '', null, '库区定义菜单');
|
||
|
|
insert into sys_menu values('2002', '产品信息', '2000', '2', 'product', 'warehouse/product/index', '', '', 1, 0, 'C', '0', '0', 'warehouse:product:list', 'dict', 'admin', sysdate(), '', null, '产品信息菜单');
|
||
|
|
insert into sys_menu values('2003', '入库记录', '2000', '3', 'inRecord', 'warehouse/inRecord/index', '', '', 1, 0, 'C', '0', '0', 'warehouse:in:list', 'form', 'admin', sysdate(), '', null, '入库记录菜单');
|
||
|
|
insert into sys_menu values('2004', '库存信息', '2000', '4', 'stock', 'warehouse/stock/index', '', '', 1, 0, 'C', '0', '0', 'warehouse:stock:list', 'monitor', 'admin', sysdate(), '', null, '库存信息菜单');
|
||
|
|
insert into sys_menu values('2005', '出库记录', '2000', '5', 'outRecord', 'warehouse/outRecord/index', '', '', 1, 0, 'C', '0', '0', 'warehouse:out:list', 'log', 'admin', sysdate(), '', null, '出库记录菜单');
|
||
|
|
insert into sys_menu values('2006', '盘库记录', '2000', '6', 'stockCheck', 'warehouse/stockCheck/index', '', '', 1, 0, 'C', '0', '0', 'warehouse:check:list', 'job', 'admin', sysdate(), '', null, '盘库记录菜单');
|
||
|
|
|
||
|
|
insert into sys_menu values('2007', '库区查询', '2001', '1', '#', '', '', '', 1, 0, 'F', '0', '0', 'warehouse:area:query', '#', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_menu values('2008', '库区新增', '2001', '2', '#', '', '', '', 1, 0, 'F', '0', '0', 'warehouse:area:add', '#', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_menu values('2009', '库区修改', '2001', '3', '#', '', '', '', 1, 0, 'F', '0', '0', 'warehouse:area:edit', '#', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_menu values('2010', '库区删除', '2001', '4', '#', '', '', '', 1, 0, 'F', '0', '0', 'warehouse:area:remove', '#', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_menu values('2011', '库区导出', '2001', '5', '#', '', '', '', 1, 0, 'F', '0', '0', 'warehouse:area:export', '#', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_menu values('2012', '产品查询', '2002', '1', '#', '', '', '', 1, 0, 'F', '0', '0', 'warehouse:product:query', '#', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_menu values('2013', '产品新增', '2002', '2', '#', '', '', '', 1, 0, 'F', '0', '0', 'warehouse:product:add', '#', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_menu values('2014', '产品修改', '2002', '3', '#', '', '', '', 1, 0, 'F', '0', '0', 'warehouse:product:edit', '#', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_menu values('2015', '产品删除', '2002', '4', '#', '', '', '', 1, 0, 'F', '0', '0', 'warehouse:product:remove', '#', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_menu values('2016', '产品导出', '2002', '5', '#', '', '', '', 1, 0, 'F', '0', '0', 'warehouse:product:export', '#', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_menu values('2017', '入库查询', '2003', '1', '#', '', '', '', 1, 0, 'F', '0', '0', 'warehouse:in:query', '#', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_menu values('2018', '入库新增', '2003', '2', '#', '', '', '', 1, 0, 'F', '0', '0', 'warehouse:in:add', '#', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_menu values('2019', '入库修改', '2003', '3', '#', '', '', '', 1, 0, 'F', '0', '0', 'warehouse:in:edit', '#', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_menu values('2020', '入库删除', '2003', '4', '#', '', '', '', 1, 0, 'F', '0', '0', 'warehouse:in:remove', '#', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_menu values('2021', '确认入库', '2003', '5', '#', '', '', '', 1, 0, 'F', '0', '0', 'warehouse:in:confirm', '#', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_menu values('2022', '入库导出', '2003', '6', '#', '', '', '', 1, 0, 'F', '0', '0', 'warehouse:in:export', '#', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_menu values('2023', '库存查询', '2004', '1', '#', '', '', '', 1, 0, 'F', '0', '0', 'warehouse:stock:query', '#', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_menu values('2024', '库存出库', '2004', '2', '#', '', '', '', 1, 0, 'F', '0', '0', 'warehouse:stock:out', '#', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_menu values('2025', '库存导出', '2004', '3', '#', '', '', '', 1, 0, 'F', '0', '0', 'warehouse:stock:export', '#', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_menu values('2026', '出库查询', '2005', '1', '#', '', '', '', 1, 0, 'F', '0', '0', 'warehouse:out:query', '#', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_menu values('2027', '出库新增', '2005', '2', '#', '', '', '', 1, 0, 'F', '0', '0', 'warehouse:out:add', '#', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_menu values('2028', '出库导出', '2005', '3', '#', '', '', '', 1, 0, 'F', '0', '0', 'warehouse:out:export', '#', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_menu values('2029', '盘库查询', '2006', '1', '#', '', '', '', 1, 0, 'F', '0', '0', 'warehouse:check:query', '#', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_menu values('2030', '盘库新增', '2006', '2', '#', '', '', '', 1, 0, 'F', '0', '0', 'warehouse:check:add', '#', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_menu values('2031', '盘库修改', '2006', '3', '#', '', '', '', 1, 0, 'F', '0', '0', 'warehouse:check:edit', '#', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_menu values('2032', '盘库删除', '2006', '4', '#', '', '', '', 1, 0, 'F', '0', '0', 'warehouse:check:remove', '#', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_menu values('2033', '盘库确认', '2006', '5', '#', '', '', '', 1, 0, 'F', '0', '0', 'warehouse:check:confirm', '#', 'admin', sysdate(), '', null, '');
|
||
|
|
insert into sys_menu values('2034', '盘库导出', '2006', '6', '#', '', '', '', 1, 0, 'F', '0', '0', 'warehouse:check:export', '#', 'admin', sysdate(), '', null, '');
|