2026-11-01 19:44:40 +08:00
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
-- 公寓人脸门禁系统(智能门锁)业务表 —— MySQL 初始化脚本
|
|
|
|
|
|
--
|
|
|
|
|
|
-- 库名:iotlocks(与 application-druid.yml 中 master.url 保持一致)
|
|
|
|
|
|
-- 前置:先执行同目录 ry_20260417.sql(若依基础表)
|
|
|
|
|
|
-- 版本:v1.3(D8:人员主数据 lock_person;D17:lock_device_gateway 一锁多网关;
|
|
|
|
|
|
-- D9:lock_face_feature 按算法版本一人多份特征)
|
|
|
|
|
|
--
|
|
|
|
|
|
-- 规范(与 ry_20260417.sql 完全一致):
|
|
|
|
|
|
-- 1) 主键统一 bigint(20) auto_increment;关联列统一 bigint(20)
|
|
|
|
|
|
-- (不建物理外键,由业务层保证)。
|
|
|
|
|
|
-- 2) 状态/标志位统一 char(1) 或 char(2),与若依 del_flag/status 风格一致;
|
|
|
|
|
|
-- 时间统一 datetime,默认值用 CURRENT_TIMESTAMP。
|
|
|
|
|
|
-- 3) 表与列注释使用 comment;索引统一 idx_ / uk_ 前缀。
|
|
|
|
|
|
-- 4) 脚本可重复执行:建表前 drop table if exists,种子数据先 delete 再 insert。
|
|
|
|
|
|
-- 5) 显式指定主键的种子数据由 auto_increment 自动推进,无需额外复位。
|
|
|
|
|
|
--
|
|
|
|
|
|
-- 表清单:
|
|
|
|
|
|
-- 1. lock_group 公寓分组表
|
|
|
|
|
|
-- 2. lock_gateway 门锁网关表
|
|
|
|
|
|
-- 3. lock_device 智能门锁表
|
|
|
|
|
|
-- 4. lock_device_gateway 门锁-网关归属表(多对多)
|
|
|
|
|
|
-- 5. lock_person 人员主数据表
|
|
|
|
|
|
-- 6. lock_face 人脸特征表(人员维度在 lock_person)
|
|
|
|
|
|
-- 7. lock_face_feature 人脸特征-算法版本表(一人多版本)
|
|
|
|
|
|
-- 8. lock_auth 授权数据表
|
|
|
|
|
|
-- 9. lock_access_log 门禁通行日志表
|
|
|
|
|
|
-- 10. lock_command 下行命令记录表
|
|
|
|
|
|
-- 11. lock_mqtt_log MQTT 报文留痕表
|
|
|
|
|
|
-- 12. lock_service_config 服务参数配置表
|
|
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
|
|
|
|
|
|
set names utf8mb4;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
-- 1、公寓分组表
|
|
|
|
|
|
-- 业务含义:一个公寓对应一个分组;分组是 MQTT 分组级主题
|
|
|
|
|
|
-- (ydlink/{groupCode}/thing/...)的载体,也是批量授权/远程开锁的粒度。
|
|
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
drop table if exists lock_group;
|
|
|
|
|
|
create table lock_group (
|
|
|
|
|
|
group_id bigint(20) not null auto_increment comment '分组ID',
|
|
|
|
|
|
group_code varchar(32) not null comment '分组编号(MQTT主题第2段,全局唯一,一经占用不再复用)',
|
|
|
|
|
|
group_name varchar(64) not null comment '公寓/分组名称',
|
|
|
|
|
|
dept_id bigint(20) default null comment '所属部门ID(用于数据权限)',
|
|
|
|
|
|
manager varchar(64) default null comment '负责人',
|
|
|
|
|
|
phone varchar(20) default null comment '联系电话',
|
|
|
|
|
|
address varchar(255) default null comment '公寓地址',
|
|
|
|
|
|
config_id bigint(20) default null comment '关联MQTT服务器配置ID(lock_service_config.config_id,空表示用全局默认)',
|
|
|
|
|
|
status char(1) default '0' comment '状态(0正常 1停用)',
|
|
|
|
|
|
order_num int(4) default 0 comment '显示顺序',
|
|
|
|
|
|
del_flag char(1) default '0' comment '删除标志(0代表存在 2代表删除)',
|
|
|
|
|
|
create_by varchar(64) default '' comment '创建者',
|
|
|
|
|
|
create_time datetime comment '创建时间',
|
|
|
|
|
|
update_by varchar(64) default '' comment '更新者',
|
|
|
|
|
|
update_time datetime comment '更新时间',
|
|
|
|
|
|
remark varchar(500) default null comment '备注',
|
|
|
|
|
|
primary key (group_id),
|
|
|
|
|
|
unique key uk_lock_group_code (group_code),
|
|
|
|
|
|
key idx_lock_group_dept (dept_id),
|
|
|
|
|
|
key idx_lock_group_status (status)
|
|
|
|
|
|
) engine=innodb comment = '公寓分组表';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
-- 2、门锁网关表
|
|
|
|
|
|
-- 业务含义:门锁网关是 LoRa 汇聚节点,下挂多台门锁;一个网关属于一个分组。
|
|
|
|
|
|
-- 网关是 MQTT 网关级主题(ydlink/{gatewaySn}/thing/...)的载体。
|
|
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
drop table if exists lock_gateway;
|
|
|
|
|
|
create table lock_gateway (
|
|
|
|
|
|
gateway_id bigint(20) not null auto_increment comment '网关ID',
|
|
|
|
|
|
gateway_sn varchar(32) not null comment '网关SN(MQTT主题第2段,全局唯一)',
|
|
|
|
|
|
gateway_name varchar(64) default null comment '网关名称',
|
|
|
|
|
|
group_id bigint(20) default null comment '所属分组ID(lock_group.group_id)',
|
|
|
|
|
|
gateway_ip varchar(64) default null comment '网关IP',
|
|
|
|
|
|
subnet_mask varchar(64) default null comment '子网掩码',
|
|
|
|
|
|
default_gateway varchar(64) default null comment '默认网关',
|
|
|
|
|
|
gateway_password varchar(128) default null comment '网关密码(密文存储,AES加密)',
|
|
|
|
|
|
config_id bigint(20) default null comment '关联MQTT服务器配置ID',
|
|
|
|
|
|
lora_config varchar(1024) default null comment 'LORA参数配置(JSON)',
|
|
|
|
|
|
mqtt_config varchar(1024) default null comment '网关侧MQTT参数(JSON)',
|
|
|
|
|
|
config_version int(11) default 0 comment '配置版本号(每次下发+1,用于比对网关侧是否已同步)',
|
|
|
|
|
|
sync_status char(1) default '0' comment '配置同步状态(0未同步 1已同步 2同步失败)',
|
|
|
|
|
|
online_status char(1) default '1' comment '在线状态(0在线 1离线)',
|
|
|
|
|
|
last_online_time datetime comment '最后在线时间',
|
|
|
|
|
|
last_sync_time datetime comment '最后配置同步时间',
|
|
|
|
|
|
device_count int(11) default 0 comment '下挂门锁数量(冗余统计)',
|
|
|
|
|
|
firmware_ver varchar(32) default null comment '网关固件版本',
|
|
|
|
|
|
status char(1) default '0' comment '状态(0正常 1停用)',
|
|
|
|
|
|
del_flag char(1) default '0' comment '删除标志(0代表存在 2代表删除)',
|
|
|
|
|
|
create_by varchar(64) default '' comment '创建者',
|
|
|
|
|
|
create_time datetime comment '创建时间',
|
|
|
|
|
|
update_by varchar(64) default '' comment '更新者',
|
|
|
|
|
|
update_time datetime comment '更新时间',
|
|
|
|
|
|
remark varchar(500) default null comment '备注',
|
|
|
|
|
|
primary key (gateway_id),
|
|
|
|
|
|
unique key uk_lock_gateway_sn (gateway_sn),
|
|
|
|
|
|
key idx_lock_gateway_group (group_id),
|
|
|
|
|
|
key idx_lock_gateway_online (online_status),
|
|
|
|
|
|
key idx_lock_gateway_sync (sync_status)
|
|
|
|
|
|
) engine=innodb comment = '门锁网关表';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
-- 3、门锁-网关归属表(多对多)
|
|
|
|
|
|
-- 业务含义:一把门锁登记到了哪些网关上,以及每个网关视角下的信号与绑定状态。
|
|
|
|
|
|
--
|
|
|
|
|
|
-- 为什么独立成表:厂家协议里 locklist 是「网关的从设备清单」,绑定动作本身
|
|
|
|
|
|
-- 就是 per-gateway 的——locklist(add) 必须在每个期望为该锁服务的网关上各下发
|
|
|
|
|
|
-- 一次。同一把锁被两个网关覆盖时,两个网关按 LoRa 信号强度自行择优执行;
|
|
|
|
|
|
-- 平台只在跨分组下发时选一个主控网关(选路规则 R1-R4 见 RouteResolver)。
|
|
|
|
|
|
--
|
|
|
|
|
|
-- lock_device.gateway_id / group_id 退化为「当前主控网关」缓存,供列表、筛选、
|
|
|
|
|
|
-- 审计展示;下发前仍按本表实时选路,不能直接读缓存。
|
|
|
|
|
|
--
|
|
|
|
|
|
-- 解除归属用物理删除:本表可由网关 locklist 回执重建,不存在需要保留的业务
|
|
|
|
|
|
-- 历史;走 del_flag 会被 uk_lock_device_gateway 挡住重新绑定。
|
|
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
drop table if exists lock_device_gateway;
|
|
|
|
|
|
create table lock_device_gateway (
|
|
|
|
|
|
rel_id bigint(20) not null auto_increment comment '归属关系ID',
|
|
|
|
|
|
device_id bigint(20) not null comment '门锁ID(lock_device.device_id)',
|
|
|
|
|
|
gateway_id bigint(20) not null comment '网关ID(lock_gateway.gateway_id)',
|
|
|
|
|
|
signal_strength varchar(8) default null comment '该网关视角下的锁信号强度(dBm,如 -42,用于选路比较)',
|
|
|
|
|
|
last_signal_time datetime comment '该网关最后一次上报本锁信号/状态的时间',
|
|
|
|
|
|
online_status char(1) default '2' comment '该网关视角下的锁在线状态(0在线 1离线 2未知,字典 lock_online_status)',
|
|
|
|
|
|
bind_status char(1) default '0' comment 'locklist 下发状态(0待下发 1已下发 2下发失败,字典 lock_bind_status)',
|
|
|
|
|
|
bind_msg varchar(512) default null comment 'locklist 下发结果说明',
|
|
|
|
|
|
bind_time datetime comment '首次登记到该网关的时间',
|
|
|
|
|
|
last_sync_time datetime comment '最后一次 locklist 同步时间',
|
|
|
|
|
|
status char(1) default '0' comment '状态(0正常 1停用)',
|
|
|
|
|
|
del_flag char(1) default '0' comment '删除标志(0代表存在 2代表删除)',
|
|
|
|
|
|
create_by varchar(64) default '' comment '创建者',
|
|
|
|
|
|
create_time datetime comment '创建时间',
|
|
|
|
|
|
update_by varchar(64) default '' comment '更新者',
|
|
|
|
|
|
update_time datetime comment '更新时间',
|
|
|
|
|
|
remark varchar(500) default null comment '备注',
|
|
|
|
|
|
primary key (rel_id),
|
|
|
|
|
|
unique key uk_lock_device_gateway (device_id, gateway_id),
|
|
|
|
|
|
key idx_lock_dg_gateway (gateway_id),
|
|
|
|
|
|
key idx_lock_dg_device (device_id),
|
|
|
|
|
|
key idx_lock_dg_route (gateway_id, online_status, last_signal_time),
|
|
|
|
|
|
key idx_lock_dg_bind (bind_status)
|
|
|
|
|
|
) engine=innodb comment = '门锁-网关归属表';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
-- 4、智能门锁表
|
|
|
|
|
|
-- 业务含义:门锁终端,可通过 LoRa 登记到一个或多个网关(归属事实源为
|
|
|
|
|
|
-- lock_device_gateway)。gateway_id/group_id 只是当前主控网关与其分组的缓存,
|
|
|
|
|
|
-- 为空表示尚未选择主控网关(并非未绑定任何网关)。
|
|
|
|
|
|
-- 协议字段映射:device_sn -> devId,device_password -> devPsw,
|
|
|
|
|
|
-- dev_type -> devType,dev_ver -> devVer。
|
|
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
drop table if exists lock_device;
|
|
|
|
|
|
create table lock_device (
|
|
|
|
|
|
device_id bigint(20) not null auto_increment comment '门锁ID',
|
|
|
|
|
|
device_sn varchar(32) not null comment '门锁SN(对应协议devId,全局唯一)',
|
|
|
|
|
|
device_name varchar(64) default null comment '门锁名称',
|
|
|
|
|
|
gateway_id bigint(20) default null comment '当前主控网关ID(选路结果缓存,事实源为 lock_device_gateway)',
|
|
|
|
|
|
group_id bigint(20) default null comment '主控网关所属分组ID(选路结果缓存,下发以网关分组为准)',
|
|
|
|
|
|
device_password varchar(128) default null comment '门锁密码(密文存储,对应协议devPsw)',
|
|
|
|
|
|
dev_type varchar(8) default null comment '设备类型(对应协议devType)',
|
|
|
|
|
|
dev_ver varchar(16) default null comment '设备固件版本(对应协议devVer)',
|
|
|
|
|
|
face_algo_version varchar(32) default null comment '人脸算法版本(特征提取服务的 algorithm_version 入参,由每把门锁各自维护,如 2.14.5_2.7.1_M3)',
|
|
|
|
|
|
room_no varchar(64) default null comment '分配房间号',
|
|
|
|
|
|
bind_time datetime comment '绑定网关时间',
|
|
|
|
|
|
last_sync_time datetime comment '最后时间同步时间',
|
|
|
|
|
|
signal_strength varchar(8) default null comment '信号强度RSSI(dBm,op=lockrssi 上报,如 -42)',
|
|
|
|
|
|
battery_level int(11) default null comment '剩余电量(百分比,op=lockrssi 上报)',
|
|
|
|
|
|
last_status_time datetime comment '最后状态上报时间(信号/电量上报时间)',
|
|
|
|
|
|
online_status char(1) default '1' comment '在线状态(0在线 1离线 2未知)',
|
|
|
|
|
|
last_online_time datetime comment '最后在线时间',
|
|
|
|
|
|
status char(1) default '0' comment '状态(0正常 1停用)',
|
|
|
|
|
|
del_flag char(1) default '0' comment '删除标志(0代表存在 2代表删除)',
|
|
|
|
|
|
create_by varchar(64) default '' comment '创建者',
|
|
|
|
|
|
create_time datetime comment '创建时间',
|
|
|
|
|
|
update_by varchar(64) default '' comment '更新者',
|
|
|
|
|
|
update_time datetime comment '更新时间',
|
|
|
|
|
|
remark varchar(500) default null comment '备注',
|
|
|
|
|
|
primary key (device_id),
|
|
|
|
|
|
unique key uk_lock_device_sn (device_sn),
|
|
|
|
|
|
key idx_lock_device_gateway (gateway_id),
|
|
|
|
|
|
key idx_lock_device_group (group_id),
|
|
|
|
|
|
key idx_lock_device_room (room_no)
|
|
|
|
|
|
) engine=innodb comment = '智能门锁表';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
-- 5、人员主数据表
|
|
|
|
|
|
-- 业务含义:人员是「是谁」,与凭证(凭什么开门)、授权(能开哪把锁)分离。
|
|
|
|
|
|
-- person_no 是协议中的人员/人脸 ID,2 位字母 + 6 位数字(如 AA000003),
|
|
|
|
|
|
-- 一经下发到设备不可变更;sys_user_id 关联若依账号(员工自助场景,可为空)。
|
|
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
drop table if exists lock_person;
|
|
|
|
|
|
create table lock_person (
|
|
|
|
|
|
person_id bigint(20) not null auto_increment comment '人员ID',
|
|
|
|
|
|
person_no varchar(16) not null comment '人员编号(协议人员/人脸ID,2位字母+6位数字,全局唯一且不可变更)',
|
|
|
|
|
|
person_name varchar(64) default null comment '姓名',
|
|
|
|
|
|
person_type char(1) default '0' comment '人员类型(0住户 1员工 2访客 3其他,字典 lock_person_type)',
|
|
|
|
|
|
dept_id bigint(20) default null comment '所属部门ID(数据权限)',
|
|
|
|
|
|
sys_user_id bigint(20) default null comment '关联若依账号ID(员工自助场景,可为空)',
|
|
|
|
|
|
id_card_no varchar(256) default null comment '证件号(v1 明文存储,见架构设计 D10 决策)',
|
|
|
|
|
|
phone varchar(20) default null comment '联系电话',
|
|
|
|
|
|
valid_from datetime comment '人员有效期起(未填不限)',
|
|
|
|
|
|
valid_to datetime comment '人员有效期止(空表示永久)',
|
|
|
|
|
|
status char(1) default '0' comment '状态(0正常 1停用)',
|
|
|
|
|
|
del_flag char(1) default '0' comment '删除标志(0代表存在 2代表删除)',
|
|
|
|
|
|
create_by varchar(64) default '' comment '创建者',
|
|
|
|
|
|
create_time datetime comment '创建时间',
|
|
|
|
|
|
update_by varchar(64) default '' comment '更新者',
|
|
|
|
|
|
update_time datetime comment '更新时间',
|
|
|
|
|
|
remark varchar(500) default null comment '备注',
|
|
|
|
|
|
primary key (person_id),
|
|
|
|
|
|
unique key uk_lock_person_no (person_no),
|
|
|
|
|
|
key idx_lock_person_name (person_name),
|
|
|
|
|
|
key idx_lock_person_dept (dept_id),
|
|
|
|
|
|
key idx_lock_person_sys_user (sys_user_id)
|
|
|
|
|
|
) engine=innodb comment = '人员主数据表';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
-- 6、人脸特征表
|
|
|
|
|
|
-- 业务含义:人员的人脸生物特征(v1 一人一份;算法多版本见 D9/v2 lock_biometric)。
|
|
|
|
|
|
-- 人员维度(姓名/类型/电话/部门)已拆到 lock_person,本表只保留图片与特征;
|
|
|
|
|
|
-- person_no 保留为协议键——授权帧按人员编号下发,设备侧用它索引特征。
|
|
|
|
|
|
-- 图片与特征分离存储:图片走对象存储/文件服务,特征以 base64 落 text 列。
|
|
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
drop table if exists lock_face;
|
|
|
|
|
|
create table lock_face (
|
|
|
|
|
|
face_id bigint(20) not null auto_increment comment '人脸特征ID',
|
|
|
|
|
|
person_id bigint(20) not null comment '人员ID(lock_person.person_id)',
|
|
|
|
|
|
person_no varchar(32) not null comment '人员编号(冗余协议键,与 lock_person.person_no 一致)',
|
|
|
|
|
|
photo_url varchar(512) default null comment '人脸图片URL',
|
|
|
|
|
|
photo_md5 varchar(32) default null comment '图片指纹(用于变更检测与去重)',
|
|
|
|
|
|
feature_data mediumtext comment '人脸特征值(base64编码)',
|
|
|
|
|
|
feature_md5 varchar(32) default null comment '特征指纹(变更检测与幂等下发用)',
|
|
|
|
|
|
feature_algo_version varchar(32) default null comment '特征算法版本(提取时实际使用的 algorithm_version)',
|
|
|
|
|
|
feature_size int(11) default 0 comment '特征字节数',
|
|
|
|
|
|
extract_status char(1) default '0' comment '特征提取状态(0未提取 1成功 2失败)',
|
|
|
|
|
|
extract_time datetime comment '特征提取时间',
|
|
|
|
|
|
extract_msg varchar(512) default null comment '特征提取失败原因',
|
|
|
|
|
|
status char(1) default '0' comment '状态(0正常 1停用)',
|
|
|
|
|
|
del_flag char(1) default '0' comment '删除标志(0代表存在 2代表删除)',
|
|
|
|
|
|
create_by varchar(64) default '' comment '创建者',
|
|
|
|
|
|
create_time datetime comment '创建时间',
|
|
|
|
|
|
update_by varchar(64) default '' comment '更新者',
|
|
|
|
|
|
update_time datetime comment '更新时间',
|
|
|
|
|
|
remark varchar(500) default null comment '备注',
|
|
|
|
|
|
primary key (face_id),
|
|
|
|
|
|
unique key uk_lock_face_person_id (person_id),
|
|
|
|
|
|
unique key uk_lock_face_person_no (person_no),
|
|
|
|
|
|
key idx_lock_face_extract (extract_status)
|
|
|
|
|
|
) engine=innodb comment = '人脸特征表';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
-- 7、人脸特征-算法版本表
|
|
|
|
|
|
-- 业务含义:同一张人脸照片按不同门锁算法版本分别提取,得到多份特征。
|
|
|
|
|
|
-- 门锁只接受与自身 face_algo_version 一致的特征,换算法不能覆盖旧版本,
|
|
|
|
|
|
-- 否则算法版本不同的老锁会集体失效(D9)。
|
|
|
|
|
|
-- lock_face 继续保存图片与「最近一次成功提取」的镜像,本表是下发选值的
|
|
|
|
|
|
-- 唯一事实源:下发时按 (person_no, algo_version) 取对应版本。
|
|
|
|
|
|
-- 存量数据由 sql/upgrade_d9_face_feature.sql 从 lock_face 回填。
|
|
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
drop table if exists lock_face_feature;
|
|
|
|
|
|
create table lock_face_feature (
|
|
|
|
|
|
feature_id bigint(20) not null auto_increment comment '特征ID',
|
|
|
|
|
|
face_id bigint(20) not null comment '人脸ID(lock_face.face_id)',
|
|
|
|
|
|
person_id bigint(20) not null comment '人员ID(lock_person.person_id)',
|
|
|
|
|
|
person_no varchar(32) not null comment '人员编号(冗余协议键,与 lock_face.person_no 一致)',
|
|
|
|
|
|
algo_version varchar(32) not null comment '算法版本(提取时使用的 algorithm_version,来自 lock_device.face_algo_version)',
|
|
|
|
|
|
feature_data mediumtext comment '人脸特征值(base64编码)',
|
|
|
|
|
|
feature_md5 varchar(32) default null comment '特征指纹(变更检测与幂等下发用)',
|
|
|
|
|
|
feature_size int(11) default 0 comment '特征字节数',
|
|
|
|
|
|
extract_status char(1) default '0' comment '特征提取状态(0未提取 1成功 2失败)',
|
|
|
|
|
|
extract_time datetime comment '特征提取时间',
|
|
|
|
|
|
extract_msg varchar(512) default null comment '特征提取失败原因',
|
|
|
|
|
|
create_by varchar(64) default '' comment '创建者',
|
|
|
|
|
|
create_time datetime comment '创建时间',
|
|
|
|
|
|
update_by varchar(64) default '' comment '更新者',
|
|
|
|
|
|
update_time datetime comment '更新时间',
|
|
|
|
|
|
remark varchar(500) default null comment '备注',
|
|
|
|
|
|
primary key (feature_id),
|
|
|
|
|
|
unique key uk_lock_face_feature_algo (face_id, algo_version),
|
|
|
|
|
|
key idx_lock_face_feature_person (person_no, algo_version),
|
|
|
|
|
|
key idx_lock_face_feature_person_id (person_id)
|
|
|
|
|
|
) engine=innodb comment = '人脸特征-算法版本表';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
-- 8、授权数据表
|
|
|
|
|
|
-- 业务含义:把某个人员(person_no)在某个门锁(device_id)上的某类凭证
|
|
|
|
|
|
-- (人脸/密码/指纹/IC卡)授权关系落库,并跟踪下发到设备的同步状态。
|
|
|
|
|
|
-- 协议对应:ydlink/{groupCode}/thing/data/batch 的 params 数组(add/delete)。
|
|
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
drop table if exists lock_auth;
|
|
|
|
|
|
create table lock_auth (
|
|
|
|
|
|
auth_id bigint(20) not null auto_increment comment '授权ID',
|
|
|
|
|
|
auth_no varchar(64) not null comment '授权编号(业务唯一,建议规则 AUTH+日期+序号)',
|
|
|
|
|
|
person_no varchar(32) not null comment '人员编号(lock_person.person_no)',
|
|
|
|
|
|
person_name varchar(64) default null comment '冗余人员姓名',
|
|
|
|
|
|
device_id bigint(20) not null comment '授权锁ID(lock_device.device_id)',
|
|
|
|
|
|
device_sn varchar(32) default null comment '冗余门锁SN(下发组包直接用)',
|
|
|
|
|
|
gateway_id bigint(20) default null comment '冗余网关ID',
|
|
|
|
|
|
group_id bigint(20) default null comment '冗余分组ID(决定下发主题)',
|
|
|
|
|
|
auth_type char(2) not null comment '授权类型(01人脸 02密码 03指纹 04IC卡)',
|
|
|
|
|
|
auth_value mediumtext comment '授权内容(人脸特征base64/密码密文/指纹特征/IC卡号)',
|
|
|
|
|
|
auth_value_md5 varchar(32) default null comment '授权内容指纹(变更检测与重复下发判断)',
|
|
|
|
|
|
begin_time datetime comment '生效开始时间',
|
|
|
|
|
|
end_time datetime comment '生效结束时间(空表示永久有效)',
|
|
|
|
|
|
auth_time datetime comment '授权操作时间',
|
2026-11-03 18:31:01 +08:00
|
|
|
|
source char(1) default '1' comment '授权来源(1平台 2开放接口)',
|
|
|
|
|
|
source_app_code varchar(32) default null comment '来源应用编码(source=2,lock_open_app.app_code)',
|
|
|
|
|
|
source_biz_no varchar(64) default null comment '来源业务单号(可空;外部入住为 biz_no)',
|
2026-11-01 19:44:40 +08:00
|
|
|
|
sync_status char(1) default '0' comment '下发同步状态(0待下发 1已下发 2下发成功 3下发失败 4已清除 6待清除;5 预留给 v2 的已过期)',
|
|
|
|
|
|
sync_time datetime comment '最后下发/响应时间',
|
|
|
|
|
|
sync_msg varchar(512) default null comment '下发结果说明',
|
|
|
|
|
|
retry_count int(11) default 0 comment '下发重试次数',
|
|
|
|
|
|
status char(1) default '0' comment '状态(0正常 1停用)',
|
|
|
|
|
|
del_flag char(1) default '0' comment '删除标志(0代表存在 2代表删除)',
|
|
|
|
|
|
create_by varchar(64) default '' comment '创建者',
|
|
|
|
|
|
create_time datetime comment '创建时间',
|
|
|
|
|
|
update_by varchar(64) default '' comment '更新者',
|
|
|
|
|
|
update_time datetime comment '更新时间',
|
|
|
|
|
|
remark varchar(500) default null comment '备注',
|
|
|
|
|
|
primary key (auth_id),
|
|
|
|
|
|
unique key uk_lock_auth_no (auth_no),
|
|
|
|
|
|
unique key uk_lock_auth_person_lock (person_no, device_id, auth_type),
|
|
|
|
|
|
key idx_lock_auth_person (person_no),
|
|
|
|
|
|
key idx_lock_auth_device (device_id),
|
|
|
|
|
|
key idx_lock_auth_group (group_id),
|
2026-11-03 18:31:01 +08:00
|
|
|
|
key idx_lock_auth_sync (sync_status),
|
|
|
|
|
|
key idx_lock_auth_source (source, source_app_code)
|
2026-11-01 19:44:40 +08:00
|
|
|
|
) engine=innodb comment = '授权数据表';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
-- 9、门禁通行日志表
|
|
|
|
|
|
-- 业务含义:设备通过 ydlink/{groupCode}/thing/event/trigger(op=lockrecord)
|
|
|
|
|
|
-- 上报的开门记录。本表为高频只追加表,故不设 del_flag / update_*。
|
|
|
|
|
|
--
|
|
|
|
|
|
-- 【性能提示】单公寓千级住户、日均万级记录时,建议按 open_time 做范围分区,
|
|
|
|
|
|
-- 或按 recv_time 定期归档(见 LockAccessLogTask)。
|
|
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
drop table if exists lock_access_log;
|
|
|
|
|
|
create table lock_access_log (
|
|
|
|
|
|
log_id bigint(20) not null auto_increment comment '日志ID',
|
|
|
|
|
|
device_id bigint(20) default null comment '门锁ID(解析device_sn得到,未登记时为空)',
|
|
|
|
|
|
device_sn varchar(32) not null comment '门锁SN',
|
|
|
|
|
|
gateway_id bigint(20) default null comment '上报网关ID',
|
|
|
|
|
|
gateway_sn varchar(32) default null comment '上报网关SN',
|
|
|
|
|
|
group_id bigint(20) default null comment '所属分组ID',
|
|
|
|
|
|
person_no varchar(32) default null comment '人员编号',
|
|
|
|
|
|
person_name varchar(64) default null comment '冗余人员姓名',
|
|
|
|
|
|
card_no varchar(32) default null comment '卡号/凭证号',
|
|
|
|
|
|
open_type varchar(8) default null comment '开门方式(设备码 2密码 3IC卡 4指纹 5二维码 7人脸,平台远程 9;字典 lock_open_type)',
|
|
|
|
|
|
open_result varchar(8) default null comment '开门结果(0失败 1成功)',
|
|
|
|
|
|
open_dir varchar(8) default null comment '开门方向(0进门 1出门 空未知;设备原样上报,长度不固定)',
|
|
|
|
|
|
open_time datetime comment '开门时间(设备上报时间)',
|
|
|
|
|
|
recv_time datetime comment '服务端接收时间',
|
|
|
|
|
|
seq varchar(32) default null comment '报文序号(用于幂等去重)',
|
|
|
|
|
|
raw_params text comment '原始params数组(JSON,便于协议字段二次解析)',
|
|
|
|
|
|
create_time datetime comment '创建时间',
|
|
|
|
|
|
remark varchar(500) default null comment '备注',
|
|
|
|
|
|
primary key (log_id),
|
|
|
|
|
|
key idx_lock_access_log_device (device_sn),
|
|
|
|
|
|
key idx_lock_access_log_person (person_no),
|
|
|
|
|
|
key idx_lock_access_log_time (open_time),
|
|
|
|
|
|
key idx_lock_access_log_seq (device_sn, seq),
|
|
|
|
|
|
key idx_lock_access_log_group (group_id)
|
|
|
|
|
|
) engine=innodb comment = '门禁通行日志表';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
-- 10、下行命令记录表
|
|
|
|
|
|
-- 业务含义:所有平台→设备的指令统一下发留痕,支撑响应匹配、失败重试、
|
|
|
|
|
|
-- 离线补发与操作审计。覆盖:绑定/解绑门锁、同步时间、远程开关锁、重启网关、
|
|
|
|
|
|
-- 修改网络/LORA/MQTT参数、保存配置、授权下发、清除授权、清除门锁。
|
|
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
drop table if exists lock_command;
|
|
|
|
|
|
create table lock_command (
|
|
|
|
|
|
command_id bigint(20) not null auto_increment comment '命令ID',
|
|
|
|
|
|
command_no varchar(64) not null comment '命令编号(对应协议seq,全局唯一)',
|
|
|
|
|
|
command_type char(4) not null comment '命令类型(字典 lock_command_type)',
|
|
|
|
|
|
target_type char(1) not null comment '目标类型(1网关 2门锁 3分组)',
|
|
|
|
|
|
target_id bigint(20) default null comment '目标对象ID',
|
|
|
|
|
|
target_code varchar(32) default null comment '目标编号(网关SN/门锁SN/分组编号,用于主题拼装)',
|
|
|
|
|
|
biz_id bigint(20) default null comment '关联业务ID(如授权下发时指向 lock_auth.auth_id)',
|
|
|
|
|
|
topic varchar(255) default null comment '下发主题',
|
|
|
|
|
|
payload mediumtext comment '下发报文内容',
|
|
|
|
|
|
req_time datetime comment '下发时间',
|
|
|
|
|
|
resp_topic varchar(255) default null comment '响应主题',
|
|
|
|
|
|
resp_payload mediumtext comment '响应报文内容',
|
|
|
|
|
|
resp_time datetime comment '响应时间',
|
|
|
|
|
|
command_status char(1) default '0' comment '命令状态(0待发送 1已发送 2成功 3失败 4超时 5已取消)',
|
|
|
|
|
|
retry_count int(11) default 0 comment '已重试次数',
|
|
|
|
|
|
max_retry int(11) default 3 comment '最大重试次数',
|
|
|
|
|
|
next_retry_time datetime comment '下次重试时间(补偿任务扫描用)',
|
|
|
|
|
|
gateway_ack char(1) default '0' comment '是否已收到网关回执(0否 1是)',
|
|
|
|
|
|
device_ack char(1) default '0' comment '是否已收到门锁回执(0否 1是)',
|
|
|
|
|
|
device_result char(1) default null comment '门锁回执结果(0失败 1成功),双回执齐备才判定命令成功',
|
|
|
|
|
|
error_msg varchar(512) default null comment '失败原因',
|
|
|
|
|
|
create_by varchar(64) default '' comment '创建者',
|
|
|
|
|
|
create_time datetime comment '创建时间',
|
|
|
|
|
|
update_by varchar(64) default '' comment '更新者',
|
|
|
|
|
|
update_time datetime comment '更新时间',
|
|
|
|
|
|
remark varchar(500) default null comment '备注',
|
|
|
|
|
|
primary key (command_id),
|
|
|
|
|
|
unique key uk_lock_command_no (command_no),
|
|
|
|
|
|
key idx_lock_command_status (command_status),
|
|
|
|
|
|
key idx_lock_command_target (target_code),
|
|
|
|
|
|
key idx_lock_command_time (req_time),
|
|
|
|
|
|
key idx_lock_command_retry (command_status, next_retry_time)
|
|
|
|
|
|
) engine=innodb comment = '下行命令记录表';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
-- 11、MQTT 报文留痕表
|
|
|
|
|
|
-- 业务含义:上下行原始报文的落库留痕,用于协议联调、问题回溯与审计。
|
|
|
|
|
|
-- 可通过配置开关(仅记录收发/记录全部)控制写入量。
|
|
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
drop table if exists lock_mqtt_log;
|
|
|
|
|
|
create table lock_mqtt_log (
|
|
|
|
|
|
log_id bigint(20) not null auto_increment comment '日志ID',
|
|
|
|
|
|
direction char(1) not null comment '方向(1上行设备→平台 2下行平台→设备)',
|
|
|
|
|
|
topic varchar(255) not null comment 'MQTT主题',
|
|
|
|
|
|
group_code varchar(32) default null comment '解析出的分组编号',
|
|
|
|
|
|
gateway_sn varchar(32) default null comment '解析出的网关SN',
|
|
|
|
|
|
device_sn varchar(32) default null comment '解析出的设备SN(协议devId)',
|
|
|
|
|
|
op varchar(32) default null comment '操作类型(协议op)',
|
|
|
|
|
|
mode varchar(8) default null comment '方向标识(s2d服务端→设备 d2s设备→服务端)',
|
|
|
|
|
|
ac varchar(8) default null comment '动作类型(协议ac)',
|
|
|
|
|
|
seq varchar(32) default null comment '报文序号(协议seq)',
|
|
|
|
|
|
qos smallint default 1 comment '服务质量',
|
|
|
|
|
|
retained char(1) default '0' comment '是否保留消息(0否 1是)',
|
|
|
|
|
|
payload mediumtext comment '报文原文',
|
|
|
|
|
|
chksum varchar(32) default null comment '报文校验和',
|
|
|
|
|
|
verify_status char(1) default '0' comment '校验结果(0未校验 1通过 2失败)',
|
|
|
|
|
|
handle_status char(1) default '0' comment '处理状态(0待处理 1成功 2失败 3已忽略)',
|
|
|
|
|
|
handle_msg varchar(512) default null comment '处理结果说明',
|
|
|
|
|
|
cost_time int(11) default 0 comment '处理耗时(毫秒)',
|
|
|
|
|
|
recv_time datetime comment '接收/发送时间',
|
|
|
|
|
|
create_time datetime comment '创建时间',
|
|
|
|
|
|
primary key (log_id),
|
|
|
|
|
|
key idx_lock_mqtt_log_topic (topic),
|
|
|
|
|
|
key idx_lock_mqtt_log_device (device_sn),
|
|
|
|
|
|
key idx_lock_mqtt_log_time (recv_time),
|
|
|
|
|
|
key idx_lock_mqtt_log_handle (handle_status),
|
|
|
|
|
|
key idx_lock_mqtt_log_seq (seq),
|
|
|
|
|
|
key idx_lock_mqtt_log_direct (direction)
|
|
|
|
|
|
) engine=innodb comment = 'MQTT报文留痕表';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
-- 12、服务参数配置表
|
|
|
|
|
|
-- 业务含义:承载“系统参数”中的 MQTT 服务器配置、人脸特征提取服务配置
|
|
|
|
|
|
-- 以及其它平台参数。采用 结构化分类字段 + JSON 值 的折中方案:
|
|
|
|
|
|
-- 新增配置项无需改表,前端按 config_type 渲染不同表单。
|
|
|
|
|
|
--
|
|
|
|
|
|
-- config_value JSON 约定:
|
|
|
|
|
|
-- config_type=01(MQTT服务器)
|
|
|
|
|
|
-- {"brokerUrl":"tcp://127.0.0.1:1883","clientId":"","username":"","password":"",
|
|
|
|
|
|
-- "defaultQos":1,"cleanSession":true,"keepAlive":60,"connectionTimeout":30}
|
|
|
|
|
|
-- config_type=02(人脸特征服务)
|
|
|
|
|
|
-- 协议:POST multipart/form-data,表单字段名 file,值为图片文件
|
|
|
|
|
|
-- 返回:{"functionSuccess":true,"resultSuccess":true,"resultData":"特征base64","msg":"处理成功..."}
|
|
|
|
|
|
-- {"endpoint":"http://192.168.1.202:8802/bdws_api/Third/Api/Easen/getFaceFeatureData","timeout":10000}
|
|
|
|
|
|
-- 未配置时使用代码内置默认地址(同上)
|
|
|
|
|
|
-- config_type=03(平台参数)
|
|
|
|
|
|
-- {"accessLogKeepDays":180,"mqttLogLevel":"error","commandTimeout":10,"maxRetry":3}
|
|
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
drop table if exists lock_service_config;
|
|
|
|
|
|
create table lock_service_config (
|
|
|
|
|
|
config_id bigint(20) not null auto_increment comment '配置ID',
|
|
|
|
|
|
config_name varchar(100) not null comment '配置名称',
|
|
|
|
|
|
config_type char(2) not null comment '配置类型(01MQTT服务器 02人脸特征服务 03平台参数,字典 lock_config_type)',
|
|
|
|
|
|
config_value text comment '配置内容(JSON)',
|
|
|
|
|
|
group_id bigint(20) default null comment '归属分组ID(为空表示全局默认)',
|
|
|
|
|
|
is_default char(1) default '1' comment '是否默认(0是 1否)',
|
|
|
|
|
|
enabled char(1) default '0' comment '是否启用(0启用 1停用)',
|
|
|
|
|
|
status char(1) default '0' comment '状态(0正常 1停用)',
|
|
|
|
|
|
del_flag char(1) default '0' comment '删除标志(0代表存在 2代表删除)',
|
|
|
|
|
|
create_by varchar(64) default '' comment '创建者',
|
|
|
|
|
|
create_time datetime comment '创建时间',
|
|
|
|
|
|
update_by varchar(64) default '' comment '更新者',
|
|
|
|
|
|
update_time datetime comment '更新时间',
|
|
|
|
|
|
remark varchar(500) default null comment '备注',
|
|
|
|
|
|
primary key (config_id),
|
|
|
|
|
|
unique key uk_lock_service_config_name (config_name, config_type),
|
|
|
|
|
|
key idx_lock_service_config_type (config_type)
|
|
|
|
|
|
) engine=innodb comment = '服务参数配置表';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
-- 13、字典数据初始化
|
|
|
|
|
|
-- 先按 dict_type 清理,保证脚本可重复执行。
|
|
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
delete from sys_dict_data where dict_type in
|
|
|
|
|
|
('lock_online_status','lock_open_type','lock_open_result','lock_auth_type',
|
|
|
|
|
|
'lock_command_type','lock_command_status','lock_sync_status','lock_handle_status',
|
|
|
|
|
|
'lock_config_type','lock_extract_status','lock_person_type','lock_target_type',
|
|
|
|
|
|
'lock_bind_status');
|
|
|
|
|
|
delete from sys_dict_type where dict_type in
|
|
|
|
|
|
('lock_online_status','lock_open_type','lock_open_result','lock_auth_type',
|
|
|
|
|
|
'lock_command_type','lock_command_status','lock_sync_status','lock_handle_status',
|
|
|
|
|
|
'lock_config_type','lock_extract_status','lock_person_type','lock_target_type',
|
|
|
|
|
|
'lock_bind_status');
|
|
|
|
|
|
|
|
|
|
|
|
insert into sys_dict_type (dict_id, dict_name, dict_type, status, create_by, create_time, remark) values
|
|
|
|
|
|
(100, '门禁设备在线状态', 'lock_online_status', '0', 'admin', CURRENT_TIMESTAMP, '网关/门锁在线状态列表'),
|
|
|
|
|
|
(101, '门禁开门方式', 'lock_open_type', '0', 'admin', CURRENT_TIMESTAMP, '只保留设备码(2密码 3IC卡 4指纹 5二维码 7人脸 9远程开锁)'),
|
|
|
|
|
|
(102, '门禁开门结果', 'lock_open_result', '0', 'admin', CURRENT_TIMESTAMP, '开门结果列表'),
|
|
|
|
|
|
(103, '门禁授权类型', 'lock_auth_type', '0', 'admin', CURRENT_TIMESTAMP, '人脸/密码/指纹/IC卡'),
|
|
|
|
|
|
(104, '门禁命令类型', 'lock_command_type', '0', 'admin', CURRENT_TIMESTAMP, '下行命令类型列表'),
|
|
|
|
|
|
(105, '门禁命令状态', 'lock_command_status','0', 'admin', CURRENT_TIMESTAMP, '命令下发状态列表'),
|
|
|
|
|
|
(106, '门禁授权同步状态', 'lock_sync_status', '0', 'admin', CURRENT_TIMESTAMP, '授权下发同步状态列表'),
|
|
|
|
|
|
(107, '门禁报文处理状态', 'lock_handle_status', '0', 'admin', CURRENT_TIMESTAMP, 'MQTT报文处理状态列表'),
|
|
|
|
|
|
(108, '门禁服务配置类型', 'lock_config_type', '0', 'admin', CURRENT_TIMESTAMP, '服务参数配置类型列表'),
|
|
|
|
|
|
(109, '人脸特征提取状态', 'lock_extract_status','0', 'admin', CURRENT_TIMESTAMP, '人脸特征提取状态列表'),
|
|
|
|
|
|
(110, '门禁人员类型', 'lock_person_type', '0', 'admin', CURRENT_TIMESTAMP, '人员类型列表'),
|
|
|
|
|
|
(111, '门禁命令目标类型', 'lock_target_type', '0', 'admin', CURRENT_TIMESTAMP, '命令下发目标类型列表'),
|
|
|
|
|
|
(112, '门锁绑定状态', 'lock_bind_status', '0', 'admin', CURRENT_TIMESTAMP, 'locklist 下发状态');
|
|
|
|
|
|
|
|
|
|
|
|
insert into sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark) values
|
|
|
|
|
|
-- 在线状态
|
|
|
|
|
|
(100, 1, '在线', '0', 'lock_online_status', '', 'success', 'Y', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(101, 2, '离线', '1', 'lock_online_status', '', 'danger', 'N', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(102, 3, '未知', '2', 'lock_online_status', '', 'info', 'N', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
-- 开门方式(只保留设备码,与 lockrecord params[2] 一致;远程开锁为平台生成)
|
|
|
|
|
|
(110, 1, '密码', '2', 'lock_open_type', '', 'primary', 'N', '0', 'admin', CURRENT_TIMESTAMP, '设备码'),
|
|
|
|
|
|
(111, 2, 'IC卡', '3', 'lock_open_type', '', 'primary', 'N', '0', 'admin', CURRENT_TIMESTAMP, '设备码'),
|
|
|
|
|
|
(112, 3, '指纹', '4', 'lock_open_type', '', 'primary', 'N', '0', 'admin', CURRENT_TIMESTAMP, '设备码'),
|
|
|
|
|
|
(113, 4, '二维码', '5', 'lock_open_type', '', 'primary', 'N', '0', 'admin', CURRENT_TIMESTAMP, '设备码'),
|
|
|
|
|
|
(114, 5, '人脸', '7', 'lock_open_type', '', 'success', 'Y', '0', 'admin', CURRENT_TIMESTAMP, '设备码,实测值'),
|
|
|
|
|
|
(115, 6, '远程开锁', '9', 'lock_open_type', '', 'warning', 'N', '0', 'admin', CURRENT_TIMESTAMP, '平台生成,非设备上报'),
|
|
|
|
|
|
-- 开门结果
|
|
|
|
|
|
(120, 1, '失败', '0', 'lock_open_result', '', 'danger', 'N', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(121, 2, '成功', '1', 'lock_open_result', '', 'success', 'Y', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
-- 授权类型
|
|
|
|
|
|
(130, 1, '人脸', '01', 'lock_auth_type', '', 'primary', 'Y', '0', 'admin', CURRENT_TIMESTAMP, 'op=facefeature'),
|
|
|
|
|
|
(131, 2, '密码', '02', 'lock_auth_type', '', 'primary', 'N', '0', 'admin', CURRENT_TIMESTAMP, 'op=password'),
|
|
|
|
|
|
(132, 3, '指纹', '03', 'lock_auth_type', '', 'primary', 'N', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(133, 4, 'IC卡', '04', 'lock_auth_type', '', 'primary', 'N', '0', 'admin', CURRENT_TIMESTAMP, 'op=iccard'),
|
|
|
|
|
|
-- 命令类型
|
|
|
|
|
|
(140, 1, '绑定门锁', '0001', 'lock_command_type', '', 'primary', 'N', '0', 'admin', CURRENT_TIMESTAMP, 'ydlink/{gwId}/thing/property/set'),
|
|
|
|
|
|
(141, 2, '解绑门锁', '0002', 'lock_command_type', '', 'primary', 'N', '0', 'admin', CURRENT_TIMESTAMP, 'ydlink/{gwId}/thing/property/set'),
|
|
|
|
|
|
(142, 3, '同步门锁时间', '0003', 'lock_command_type', '', 'primary', 'N', '0', 'admin', CURRENT_TIMESTAMP, 'ydlink/{gwId}/thing/property/set'),
|
|
|
|
|
|
(143, 4, '远程开锁', '0004', 'lock_command_type', '', 'warning', 'N', '0', 'admin', CURRENT_TIMESTAMP, 'ydlink/{grpId}/thing/action/execute'),
|
|
|
|
|
|
(144, 5, '远程关锁', '0005', 'lock_command_type', '', 'warning', 'N', '0', 'admin', CURRENT_TIMESTAMP, 'ydlink/{grpId}/thing/action/execute'),
|
|
|
|
|
|
(145, 6, '重启网关', '0006', 'lock_command_type', '', 'danger', 'N', '0', 'admin', CURRENT_TIMESTAMP, 'ydlink/{gwId}/thing/property/set'),
|
|
|
|
|
|
(146, 7, '修改网络参数', '0007', 'lock_command_type', '', 'primary', 'N', '0', 'admin', CURRENT_TIMESTAMP, 'ydlink/{gwId}/thing/property/set'),
|
|
|
|
|
|
(147, 8, '修改LORA参数', '0008', 'lock_command_type', '', 'primary', 'N', '0', 'admin', CURRENT_TIMESTAMP, 'ydlink/{gwId}/thing/property/set'),
|
|
|
|
|
|
(148, 9, '修改MQTT参数', '0009', 'lock_command_type', '', 'primary', 'N', '0', 'admin', CURRENT_TIMESTAMP, 'ydlink/{gwId}/thing/property/set'),
|
|
|
|
|
|
(149, 10, '保存配置', '0010', 'lock_command_type', '', 'primary', 'N', '0', 'admin', CURRENT_TIMESTAMP, 'ydlink/{gwId}/thing/property/set'),
|
|
|
|
|
|
(150, 11, '授权下发', '0011', 'lock_command_type', '', 'primary', 'N', '0', 'admin', CURRENT_TIMESTAMP, 'ydlink/{grpId}/thing/data/batch'),
|
|
|
|
|
|
(151, 12, '清除授权', '0012', 'lock_command_type', '', 'primary', 'N', '0', 'admin', CURRENT_TIMESTAMP, 'ydlink/{grpId}/thing/data/batch'),
|
|
|
|
|
|
(152, 13, '清除门锁', '0013', 'lock_command_type', '', 'danger', 'N', '0', 'admin', CURRENT_TIMESTAMP, 'ydlink/{gwId}/thing/property/set'),
|
|
|
|
|
|
-- 命令状态
|
|
|
|
|
|
(160, 1, '待发送', '0', 'lock_command_status', '', 'info', 'Y', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(161, 2, '已发送', '1', 'lock_command_status', '', 'primary', 'N', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(162, 3, '成功', '2', 'lock_command_status', '', 'success', 'N', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(163, 4, '失败', '3', 'lock_command_status', '', 'danger', 'N', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(164, 5, '超时', '4', 'lock_command_status', '', 'warning', 'N', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(165, 6, '已取消', '5', 'lock_command_status', '', 'info', 'N', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
-- 授权同步状态
|
|
|
|
|
|
(170, 1, '待下发', '0', 'lock_sync_status', '', 'info', 'Y', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(171, 2, '已下发', '1', 'lock_sync_status', '', 'primary', 'N', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(172, 3, '下发成功', '2', 'lock_sync_status', '', 'success', 'N', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(173, 4, '下发失败', '3', 'lock_sync_status', '', 'danger', 'N', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(174, 5, '已清除', '4', 'lock_sync_status', '', 'info', 'N', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(175, 6, '待清除', '6', 'lock_sync_status', '', 'warning', 'N', '0', 'admin', CURRENT_TIMESTAMP, '清除指令失败,等待补偿重发删除'),
|
|
|
|
|
|
-- 报文处理状态
|
|
|
|
|
|
(180, 1, '待处理', '0', 'lock_handle_status', '', 'info', 'Y', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(181, 2, '成功', '1', 'lock_handle_status', '', 'success', 'N', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(182, 3, '失败', '2', 'lock_handle_status', '', 'danger', 'N', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(183, 4, '已忽略', '3', 'lock_handle_status', '', 'info', 'N', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
-- 服务配置类型
|
|
|
|
|
|
(190, 1, 'MQTT服务器', '01', 'lock_config_type', '', 'primary', 'Y', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(191, 2, '人脸特征服务', '02', 'lock_config_type', '', 'primary', 'N', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(192, 3, '平台参数', '03', 'lock_config_type', '', 'primary', 'N', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
-- 特征提取状态
|
|
|
|
|
|
(200, 1, '未提取', '0', 'lock_extract_status', '', 'info', 'Y', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(201, 2, '成功', '1', 'lock_extract_status', '', 'success', 'N', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(202, 3, '失败', '2', 'lock_extract_status', '', 'danger', 'N', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
-- 人员类型
|
|
|
|
|
|
(210, 1, '住户', '0', 'lock_person_type', '', 'primary', 'Y', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(211, 2, '员工', '1', 'lock_person_type', '', 'primary', 'N', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(212, 3, '访客', '2', 'lock_person_type', '', 'warning', 'N', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(213, 4, '其他', '3', 'lock_person_type', '', 'info', 'N', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
-- 门锁绑定状态(locklist 下发状态)
|
|
|
|
|
|
(230, 1, '待下发', '0', 'lock_bind_status', '', 'info', 'Y', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(231, 2, '已下发', '1', 'lock_bind_status', '', 'success', 'N', '0', 'admin', CURRENT_TIMESTAMP, '网关已接收 locklist'),
|
|
|
|
|
|
(232, 3, '下发失败', '2', 'lock_bind_status', '', 'danger', 'N', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
-- 命令目标类型
|
|
|
|
|
|
(220, 1, '网关', '1', 'lock_target_type', '', 'primary', 'Y', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(221, 2, '门锁', '2', 'lock_target_type', '', 'primary', 'N', '0', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(222, 3, '分组', '3', 'lock_target_type', '', 'primary', 'N', '0', 'admin', CURRENT_TIMESTAMP, '');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
-- 14、菜单初始化
|
|
|
|
|
|
-- 使用 2000+ 号段(ry_20260417.sql 的 sys_menu auto_increment 为 2000)。
|
|
|
|
|
|
-- 若依 admin 角色(role_key='admin')默认拥有全部菜单,无需写 sys_role_menu。
|
|
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
delete from sys_menu where perms like 'lock:%';
|
|
|
|
|
|
delete from sys_menu where menu_name = '门禁管理' and parent_id = 0;
|
|
|
|
|
|
|
|
|
|
|
|
-- 一级目录
|
|
|
|
|
|
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, route_name, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark) values
|
|
|
|
|
|
(2000, '门禁管理', 0, 4, 'iot', null, '', '', 1, 0, 'M', '0', '0', '', 'lock', 'admin', CURRENT_TIMESTAMP, '公寓人脸门禁系统目录');
|
|
|
|
|
|
|
|
|
|
|
|
-- 二级菜单:页面
|
|
|
|
|
|
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, route_name, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark) values
|
|
|
|
|
|
(2010, '公寓分组', 2000, 1, 'group', 'iot/group/index', '', '', 1, 0, 'C', '0', '0', 'lock:group:list', 'tree', 'admin', CURRENT_TIMESTAMP, '公寓分组菜单'),
|
|
|
|
|
|
(2020, '门锁网关', 2000, 2, 'gateway', 'iot/gateway/index', '', '', 1, 0, 'C', '0', '0', 'lock:gateway:list', 'server', 'admin', CURRENT_TIMESTAMP, '门锁网关菜单'),
|
|
|
|
|
|
(2030, '智能门锁', 2000, 3, 'device', 'iot/device/index', '', '', 1, 0, 'C', '0', '0', 'lock:device:list', 'lock', 'admin', CURRENT_TIMESTAMP, '智能门锁菜单'),
|
|
|
|
|
|
(2100, '人员管理', 2000, 4, 'person', 'iot/person/index', '', '', 1, 0, 'C', '0', '0', 'lock:person:list', 'peoples', 'admin', CURRENT_TIMESTAMP, '人员主数据菜单'),
|
|
|
|
|
|
(2040, '人脸数据', 2000, 5, 'face', 'iot/face/index', '', '', 1, 0, 'C', '0', '0', 'lock:face:list', 'peoples', 'admin', CURRENT_TIMESTAMP, '人脸特征菜单'),
|
|
|
|
|
|
(2050, '授权管理', 2000, 6, 'auth', 'iot/auth/index', '', '', 1, 0, 'C', '0', '0', 'lock:auth:list', 'lock', 'admin', CURRENT_TIMESTAMP, '授权管理菜单'),
|
|
|
|
|
|
(2060, '通行记录', 2000, 7, 'accesslog', 'iot/accesslog/index','', '', 1, 0, 'C', '0', '0', 'lock:accesslog:list','list', 'admin', CURRENT_TIMESTAMP, '通行记录菜单'),
|
|
|
|
|
|
(2070, '命令记录', 2000, 8, 'command', 'iot/command/index', '', '', 1, 0, 'C', '0', '0', 'lock:command:list', 'job', 'admin', CURRENT_TIMESTAMP, '命令记录菜单'),
|
|
|
|
|
|
(2080, '报文日志', 2000, 9, 'mqttlog', 'iot/mqttlog/index', '', '', 1, 0, 'C', '0', '0', 'lock:mqttlog:list', 'log', 'admin', CURRENT_TIMESTAMP, '报文日志菜单'),
|
|
|
|
|
|
(2090, '系统参数', 2000, 10,'config', 'iot/config/index', '', '', 1, 0, 'C', '0', '0', 'lock:config:list', 'edit', 'admin', CURRENT_TIMESTAMP, '系统参数菜单');
|
|
|
|
|
|
|
|
|
|
|
|
-- 三级菜单:按钮权限
|
|
|
|
|
|
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, route_name, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark) values
|
|
|
|
|
|
-- 公寓分组
|
|
|
|
|
|
(2011, '分组查询', 2010, 1, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:group:query', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2012, '分组新增', 2010, 2, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:group:add', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2013, '分组修改', 2010, 3, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:group:edit', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2014, '分组删除', 2010, 4, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:group:remove', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2015, '分组导出', 2010, 5, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:group:export', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
-- 门锁网关
|
|
|
|
|
|
(2021, '网关查询', 2020, 1, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:gateway:query', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2022, '网关新增', 2020, 2, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:gateway:add', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2023, '网关修改', 2020, 3, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:gateway:edit', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2024, '网关删除', 2020, 4, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:gateway:remove', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2025, '网关导出', 2020, 5, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:gateway:export', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2026, '网关配置下发',2020, 6, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:gateway:config', '#', 'admin', CURRENT_TIMESTAMP, '修改网络/LORA/MQTT参数与保存配置'),
|
|
|
|
|
|
(2027, '网关重启', 2020, 7, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:gateway:reboot', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2028, '网关绑定门锁',2020, 8, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:gateway:bind', '#', 'admin', CURRENT_TIMESTAMP, '绑定/清除门锁'),
|
|
|
|
|
|
-- 智能门锁
|
|
|
|
|
|
(2031, '门锁查询', 2030, 1, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:device:query', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2032, '门锁新增', 2030, 2, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:device:add', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2033, '门锁修改', 2030, 3, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:device:edit', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2034, '门锁删除', 2030, 4, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:device:remove', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2035, '门锁导出', 2030, 5, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:device:export', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2036, '绑定/解绑网关',2030, 6, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:device:bind', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2037, '时间同步', 2030, 7, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:device:sync', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2038, '远程开锁', 2030, 8, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:device:open', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
-- 人员管理
|
|
|
|
|
|
(2101, '人员查询', 2100, 1, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:person:query', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2102, '人员新增', 2100, 2, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:person:add', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2103, '人员修改', 2100, 3, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:person:edit', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2104, '人员删除', 2100, 4, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:person:remove', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2105, '人员导出', 2100, 5, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:person:export', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2106, '人员下拉', 2100, 6, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:person:option', '#', 'admin', CURRENT_TIMESTAMP, '人员选择组件数据源'),
|
|
|
|
|
|
-- 人脸数据
|
|
|
|
|
|
(2041, '人脸查询', 2040, 1, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:face:query', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2042, '人脸新增', 2040, 2, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:face:add', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2043, '人脸修改', 2040, 3, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:face:edit', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2044, '人脸删除', 2040, 4, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:face:remove', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2045, '人脸导出', 2040, 5, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:face:export', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2046, '特征提取', 2040, 6, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:face:extract', '#', 'admin', CURRENT_TIMESTAMP, '调用人脸特征提取服务'),
|
|
|
|
|
|
-- 授权管理
|
|
|
|
|
|
(2051, '授权查询', 2050, 1, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:auth:query', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2052, '授权新增', 2050, 2, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:auth:add', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2053, '授权修改', 2050, 3, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:auth:edit', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2054, '授权删除', 2050, 4, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:auth:remove', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2055, '授权导出', 2050, 5, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:auth:export', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2056, '授权下发', 2050, 6, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:auth:push', '#', 'admin', CURRENT_TIMESTAMP, '向设备下发授权'),
|
|
|
|
|
|
(2057, '清除授权', 2050, 7, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:auth:clear', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
-- 通行记录
|
|
|
|
|
|
(2061, '记录查询', 2060, 1, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:accesslog:query', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2062, '记录导出', 2060, 2, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:accesslog:export', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
-- 命令记录
|
|
|
|
|
|
(2071, '命令查询', 2070, 1, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:command:query', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2072, '命令重发', 2070, 2, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:command:retry', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
-- 报文日志
|
|
|
|
|
|
(2081, '报文查询', 2080, 1, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:mqttlog:query', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
-- 系统参数
|
|
|
|
|
|
(2091, '参数查询', 2090, 1, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:config:query', '#', 'admin', CURRENT_TIMESTAMP, ''),
|
|
|
|
|
|
(2092, '参数修改', 2090, 2, '', null, '', '', 1, 0, 'F', '0', '0', 'lock:config:edit', '#', 'admin', CURRENT_TIMESTAMP, '');
|
|
|
|
|
|
|
|
|
|
|
|
-- =========================================================================
|
|
|
|
|
|
-- 脚本结束
|
|
|
|
|
|
-- =========================================================================
|