-- 任务引擎参数调优（2026-03-30）
-- 更新 cfg_task_generator_params 全局默认参数

BEGIN;

UPDATE biz.cfg_task_generator_params SET param_value = 7.5
WHERE site_id IS NULL AND param_key = 'high_priority_recall_threshold';

UPDATE biz.cfg_task_generator_params SET param_value = 4.0
WHERE site_id IS NULL AND param_key = 'priority_recall_threshold';

UPDATE biz.cfg_task_generator_params SET param_value = 3.0
WHERE site_id IS NULL AND param_key = 'min_wbi_for_transfer';

UPDATE biz.cfg_task_generator_params SET param_value = 0.0
WHERE site_id IS NULL AND param_key = 'guard_assistant_coverage_ratio';

UPDATE biz.cfg_task_generator_params SET param_value = 4
WHERE site_id IS NULL AND param_key = 'max_transfer_count';

-- 新增/更新升级倍数参数
INSERT INTO biz.cfg_task_generator_params (site_id, param_key, param_value, description)
VALUES
    (NULL, 'escalation_comanage_multiplier', 2.5, '升级到 COMANAGE 的倍数阈值'),
    (NULL, 'escalation_pool_multiplier', 4.0, '转移到 POOL 的倍数阈值'),
    (NULL, 'default_ideal_interval_days', 10.0, '无历史数据时的兜底到店周期')
ON CONFLICT (site_id, param_key) DO UPDATE SET param_value = EXCLUDED.param_value;

COMMIT;

-- ROLLBACK:
-- UPDATE biz.cfg_task_generator_params SET param_value = 7.0 WHERE site_id IS NULL AND param_key = 'high_priority_recall_threshold';
-- UPDATE biz.cfg_task_generator_params SET param_value = 5.0 WHERE site_id IS NULL AND param_key = 'priority_recall_threshold';
-- UPDATE biz.cfg_task_generator_params SET param_value = 5.0 WHERE site_id IS NULL AND param_key = 'min_wbi_for_transfer';
-- UPDATE biz.cfg_task_generator_params SET param_value = 0.5 WHERE site_id IS NULL AND param_key = 'guard_assistant_coverage_ratio';
-- UPDATE biz.cfg_task_generator_params SET param_value = 2 WHERE site_id IS NULL AND param_key = 'max_transfer_count';
-- UPDATE biz.cfg_task_generator_params SET param_value = 3.0 WHERE site_id IS NULL AND param_key = 'escalation_comanage_multiplier';
-- UPDATE biz.cfg_task_generator_params SET param_value = 5.0 WHERE site_id IS NULL AND param_key = 'escalation_pool_multiplier';
