-- ----------------------------
|
-- 门急诊随访模块 + 手术随访模块 开关(sys_config 参数配置表)
|
-- ----------------------------
|
-- 本脚本一次建两个键,都可重复执行(幂等):
|
--
|
-- 键名:outpatientvisit.enabled 门急诊随访总开关
|
-- 键名:othervisit.enabled 手术随访总开关
|
-- 键值:true = 启用(默认,等价于不配置这一行)
|
-- false = 关闭
|
--
|
-- 读取方式:OuthospVisitSwitch#isEnabled() / OtherVisitSwitch#isEnabled()
|
-- sys_config 热读 + 10 秒进程内缓存,fail-open(读不到 / 读库异常都按 true 处理)。
|
--
|
-- ⚠️ 这两个模块与出入院/宣教**有一个关键结构差异**:
|
-- 它们的控制器里**全是记录 CRUD**(list / export / getInfo / add / edit / remove),
|
-- **没有任何"生成随访"的 HTTP 触发端点** —— 触发器全在定时任务与 service 调用里。
|
-- 所以它们**没有** XxxAvailabilityInterceptor / XxxWebConfig,
|
-- 开关的作用点在**门面的编排方法**上,不在 HTTP 层。
|
-- 这是刻意的:与出入院模块"判断标准是这个端点会不会生成随访,而不是它在不在本模块里"
|
-- 完全一致 —— 既然一个会生成随访的 HTTP 端点都没有,就不该为了让形状整齐而硬造拦截器。
|
--
|
-- 关闭 outpatientvisit 后的行为:
|
-- 1) OuthospVisitFacade#dealOutpatientInfo()(门诊随访主扫描:扫未处理门诊记录 →
|
-- 匹配长期任务 → 写子任务)返回 0 并打 WARN,**不再生成新的门诊随访**;
|
-- 2) ⚠️ 定时任务入口**改走该门面**才会受管 —— 2025 修复前,RyTask#dealOutHospInfo
|
-- 调的是 IPatMedOuthospService(经 OuthospDataFacade,无守卫),
|
-- 开关是**失效**的。修复后与手术随访 RyTask#dealOperationInfo 走 otherVisitFacade 同形。
|
-- 3) 门诊记录查询/CRUD(/smartor/patouthosp/**、/smartor/provisional/**)**不受影响**;
|
-- 4) 门诊分表维护与存储过程重建(OuthospVisitFacade#createOuthospQuarterTable)
|
-- **不受本开关约束** —— 它建的是物理分表,属数据基础设施;
|
-- 它自己的开关是 sys_config: outhosp.split.mode(没配就整块不执行)。
|
-- 若把它也套上随访开关,关闭随访会让新周期分表不建 → 门诊记录写不进表。
|
-- 5) 改完立即生效,最多 10 秒,不需要重启。
|
--
|
-- 关闭 othervisit 后的行为:
|
-- 1) OtherVisitFacade#dealOperationInfo()(手术随访主扫描)返回 0 并打 WARN;
|
-- 2) 手术记录 / 手术明细 / 手术基础字典的查询与 CRUD
|
-- (/smartor/operation/**、/smartor/item/**、/smartor/baseopera/**)**不受影响**;
|
-- 3) 改完立即生效,最多 10 秒,不需要重启。
|
--
|
-- ⚠️ 两者都**不作用于**已生成的子任务:关闭开关是"当天不再生成新的随访",
|
-- 已存在的子任务的到期/回收由 ruoyi-inhospvisit 的定时任务处理。
|
--
|
-- 注意:本项目用的 MySQL 版本可能不支持 ADD COLUMN IF NOT EXISTS,
|
-- 因此这里用 information_schema 判断后再动态执行。
|
-- ----------------------------
|
|
SET @sys_config_exists = (
|
SELECT COUNT(1) FROM information_schema.COLUMNS
|
WHERE TABLE_SCHEMA = DATABASE()
|
AND TABLE_NAME = 'sys_config'
|
AND COLUMN_NAME = 'config_key'
|
);
|
|
-- ---------------------------------------------------------------
|
-- 1) outpatientvisit.enabled
|
-- ---------------------------------------------------------------
|
SET @ddl = IF(@sys_config_exists = 0,
|
'SELECT ''sys_config 表不存在,请先执行建表脚本'' AS warning',
|
'INSERT INTO sys_config (config_name, config_key, config_value, config_type, create_by, create_time, remark)
|
SELECT ''门急诊随访模块开关'', ''outpatientvisit.enabled'', ''true'', ''Y'', ''admin'', SYSDATE(),
|
''门急诊随访总开关(运行时读取,改完最多10秒生效):true启用,false关闭;默认true。只作用于门诊随访编排,门诊记录CRUD与分表维护不受影响''
|
FROM DUAL
|
WHERE NOT EXISTS (SELECT 1 FROM sys_config WHERE config_key = ''outpatientvisit.enabled'')');
|
|
PREPARE outpatientvisit_stmt FROM @ddl;
|
EXECUTE outpatientvisit_stmt;
|
DEALLOCATE PREPARE outpatientvisit_stmt;
|
|
-- ---------------------------------------------------------------
|
-- 2) othervisit.enabled
|
-- ---------------------------------------------------------------
|
SET @ddl = IF(@sys_config_exists = 0,
|
'SELECT ''sys_config 表不存在,请先执行建表脚本'' AS warning',
|
'INSERT INTO sys_config (config_name, config_key, config_value, config_type, create_by, create_time, remark)
|
SELECT ''手术随访模块开关'', ''othervisit.enabled'', ''true'', ''Y'', ''admin'', SYSDATE(),
|
''手术随访总开关(运行时读取,改完最多10秒生效):true启用,false关闭;默认true。只作用于手术随访编排,手术记录/明细/基础字典CRUD不受影响''
|
FROM DUAL
|
WHERE NOT EXISTS (SELECT 1 FROM sys_config WHERE config_key = ''othervisit.enabled'')');
|
|
PREPARE othervisit_stmt FROM @ddl;
|
EXECUTE othervisit_stmt;
|
DEALLOCATE PREPARE othervisit_stmt;
|
|
-- 日常开关操作(二选一,改完最多 10 秒生效):
|
-- 关闭门诊随访:UPDATE sys_config SET config_value = 'false', update_time = SYSDATE() WHERE config_key = 'outpatientvisit.enabled';
|
-- 关闭手术随访:UPDATE sys_config SET config_value = 'false', update_time = SYSDATE() WHERE config_key = 'othervisit.enabled';
|
|
-- 查询当前值
|
-- SELECT config_id, config_name, config_key, config_value, remark FROM sys_config
|
-- WHERE config_key IN ('outpatientvisit.enabled', 'othervisit.enabled');
|