-- 数字员工菜单场景名称修复为行业说明（UTF-8）
-- workflow_llm    对应 提示回复场景
-- summary_generation 对应 摘要生成场景

UPDATE admin_ai_scene SET scene_name = '提示回复场景', update_time = NOW()
WHERE scene_code = 'workflow_llm';

UPDATE admin_ai_scene SET scene_name = '摘要生成场景', update_time = NOW()
WHERE scene_code = 'summary_generation';

INSERT INTO admin_ai_scene (scene_code, scene_name, scene_type, pipeline_type, quality_threshold, status, create_by, update_by)
SELECT 'workflow_llm', '提示回复场景', 'single', NULL, NULL, 1, 'system', 'system'
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM admin_ai_scene WHERE scene_code = 'workflow_llm');

INSERT INTO admin_ai_scene (scene_code, scene_name, scene_type, pipeline_type, quality_threshold, status, create_by, update_by)
SELECT 'summary_generation', '摘要生成场景', 'single', NULL, NULL, 1, 'system', 'system'
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM admin_ai_scene WHERE scene_code = 'summary_generation');

-- 缺省场景更改为工作流模板
INSERT INTO admin_ai_scene_model (scene_code, model_id, pipeline_order, role, sort_weight)
SELECT s.scene_code, m.id, 0, 'generator', 0
FROM admin_ai_scene s
CROSS JOIN (SELECT id FROM admin_ai_model WHERE status = 1 ORDER BY sort_order LIMIT 1) m
WHERE s.scene_code IN ('workflow_llm', 'summary_generation')
AND NOT EXISTS (SELECT 1 FROM admin_ai_scene_model sm WHERE sm.scene_code = s.scene_code);
