包含 RuoYi-Vue 后端(ruoyi-iot 门禁模块)、RuoYi-Vue2 前端、设计文档与升级脚本。 忽略构建产物(target/node_modules/dist)、IDE 配置、运行日志与数据库转储。
62 lines
3.2 KiB
SQL
62 lines
3.2 KiB
SQL
-- =========================================================================
|
|
-- 热修复:区分「人脸下发失败」与「人脸清除失败」
|
|
--
|
|
-- 背景:
|
|
-- lock_auth.sync_status 原先把两种失败都写成 3(下发失败):
|
|
-- - 人脸 add 失败 → 补偿按「待下发」重发 add,正确;
|
|
-- - 人脸 delete 失败(退房/换房/整锁清空)→ 补偿同样按「待下发」重发 add,
|
|
-- 把刚删掉的人脸又加回设备,导致"旧房授权删除失败、越删越有"。
|
|
--
|
|
-- 处理:
|
|
-- 1) 新增字典值 6 = 待清除(清除指令失败,等待补偿重发 delete);
|
|
-- 2) 把历史数据中「最新一条授权类命令是 0012 清除、且当前为 3」的授权改为 6,
|
|
-- 让补偿改走 delete 通道;其余 3 保持「下发失败」,仍按 add 补偿。
|
|
--
|
|
-- 执行前置:备份 lock_auth / sys_dict_data;可重复执行。
|
|
-- 说明:脚本只交付,由 DBA 在窗口期执行;应用需同步升级到包含本修复的版本。
|
|
-- =========================================================================
|
|
|
|
set names utf8mb4;
|
|
|
|
|
|
-- =========================================================================
|
|
-- 1、字典:lock_sync_status 增加 6 = 待清除(5 在 v2 基线中规划为「已过期」,故取 6)
|
|
-- =========================================================================
|
|
delete from sys_dict_data where dict_type = 'lock_sync_status' and dict_value = '6';
|
|
|
|
insert into sys_dict_data (dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark) values
|
|
(6, '待清除', '6', 'lock_sync_status', '', 'warning', 'N', '0', 'admin', now(), '清除指令失败,等待补偿重发删除');
|
|
|
|
|
|
-- =========================================================================
|
|
-- 2、历史数据:清除失败(3)改为待清除(6)
|
|
-- 判定依据:该授权最近一条授权类命令(0011 下发 / 0012 清除)是 0012
|
|
-- =========================================================================
|
|
update lock_auth a
|
|
set a.sync_status = '6',
|
|
a.sync_msg = '清除失败,等待重发删除指令',
|
|
a.update_time = CURRENT_TIMESTAMP
|
|
where a.sync_status = '3'
|
|
and coalesce((
|
|
select c.command_type
|
|
from lock_command c
|
|
where c.biz_id = a.auth_id
|
|
and c.command_type in ('0011', '0012')
|
|
order by c.command_id desc
|
|
limit 1
|
|
), '') = '0012';
|
|
|
|
|
|
-- =========================================================================
|
|
-- 3、执行后核对(只读)
|
|
-- =========================================================================
|
|
-- 3.1 各同步状态数量
|
|
-- select sync_status, count(1) as total from lock_auth where del_flag = '0' group by sync_status;
|
|
--
|
|
-- 3.2 仍为「下发失败」且最近命令是清除的授权(应为空,否则可手工置 5)
|
|
-- select a.auth_id, a.person_no, a.device_sn, a.sync_status, a.sync_msg
|
|
-- from lock_auth a
|
|
-- where a.sync_status = '3'
|
|
-- and (select c.command_type from lock_command c
|
|
-- where c.biz_id = a.auth_id and c.command_type in ('0011','0012')
|
|
-- order by c.command_id desc limit 1) = '0012'; |