-- ---------------------------- -- 1、位置信息表 -- ---------------------------- drop table if exists rfid_location; create table rfid_location ( id bigint(20) not null auto_increment comment '标识', location_code varchar(64) not null comment '位置编号', location_alias varchar(128) default null comment '位置别名', location_type char(1) default null comment '位置类型(1-车间;2-工序;3-工位)', parent_id bigint(20) default null comment '父级编号,对应本表id', ancestors varchar(512) default '0' comment '祖级列表', is_marked char(1) not null default '1' comment '是否标识(1-是;0-否)', remark varchar(255) default null comment '备注', created_by varchar(64) default '' comment '创建人', created_at datetime default null comment '创建时间', updated_by varchar(64) default '' comment '更新人', updated_at datetime default null comment '更新时间', primary key (id) ) engine=innodb comment = '位置信息表'; -- ---------------------------- -- 2、设备信息表 -- ---------------------------- drop table if exists rfid_device; create table rfid_device ( id bigint(20) not null auto_increment comment '标识', device_code varchar(64) not null comment '设备编号', device_name varchar(128) not null comment '设备名称', location_id bigint(20) default null comment '所在位置,对应rfid_location.id', device_address varchar(128) default null comment '设备地址(IP等)', device_port int(11) default null comment '设备端口', read_frequency int(11) default null comment '读取频率(单位:自定义,如次/秒)', online_status char(1) not null default '0' comment '在线状态(0-离线;1-在线)', alarm_status char(1) not null default '0' comment '告警状态(0-正常;1-告警)', is_marked char(1) not null default '1' comment '是否标识(1-是;0-否)', remark varchar(255) default null comment '备注', created_by varchar(64) default '' comment '创建人', created_at datetime default null comment '创建时间', updated_by varchar(64) default '' comment '更新人', updated_at datetime default null comment '更新时间', primary key (id) ) engine=innodb comment = '设备信息表'; -- ---------------------------- -- 3、读取记录表 -- ---------------------------- drop table if exists rfid_read_record; create table rfid_read_record ( id bigint(20) not null auto_increment comment '标识', device_id bigint(20) not null comment '设备id,对应rfid_device.id', read_status char(1) not null comment '读取状态(1-成功;0-失败)', barcode varchar(128) not null comment '条码信息', record_time datetime not null comment '记录时间', alarm_flag char(1) not null default '0' comment '是否告警(0-否;1-是)', alarm_level char(1) default null comment '告警级别(1-一般;2-严重等)', alarm_type varchar(64) default null comment '告警类型', alarm_action varchar(128) default null comment '告警行为', primary key (id) ) engine=innodb comment = '读取记录表'; ALTER TABLE rfid_device ADD COLUMN create_dept BIGINT(20) DEFAULT NULL COMMENT '创建部门', ADD COLUMN create_by BIGINT(20) DEFAULT NULL COMMENT '创建者', ADD COLUMN create_time DATETIME DEFAULT NULL COMMENT '创建时间', ADD COLUMN update_by BIGINT(20) DEFAULT NULL COMMENT '更新者', ADD COLUMN update_time DATETIME DEFAULT NULL COMMENT '更新时间'; ALTER TABLE rfid_location ADD COLUMN create_dept BIGINT(20) DEFAULT NULL COMMENT '创建部门', ADD COLUMN create_by BIGINT(20) DEFAULT NULL COMMENT '创建者', ADD COLUMN create_time DATETIME DEFAULT NULL COMMENT '创建时间', ADD COLUMN update_by BIGINT(20) DEFAULT NULL COMMENT '更新者', ADD COLUMN update_time DATETIME DEFAULT NULL COMMENT '更新时间';