-- =============================================
-- Assessment Data Seed Script
-- 学业邑规划 - MiAssessment
-- 
-- 题库初始化脚本：测评类型、报告分类、题目、题目分类映射
--
-- Database: SQL Server 2022
-- Run after: init_business_db.sql
-- =============================================

USE [MiAssessment_Business];
GO

PRINT N'========================================';
PRINT N'开始导入测评数据...';
PRINT N'========================================';

-- =============================================
-- 1. 测评类型 (AssessmentType)
-- =============================================
PRINT N'';
PRINT N'1. 导入测评类型...';

IF NOT EXISTS (SELECT 1 FROM [dbo].[assessment_types] WHERE [Code] = 'MI_ASSESSMENT')
BEGIN
    INSERT INTO [dbo].[assessment_types] 
        ([Name], [Code], [ImageUrl], [IntroContent], [Price], [QuestionCount], [Sort], [Status], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES 
        (N'多元智能测评', 'MI_ASSESSMENT', '', N'基于霍华德·加德纳的多元智能理论，全面评估您的八大智能优势', 99.00, 80, 1, 1, GETDATE(), GETDATE(), 0);
    PRINT N'  - 已创建: 多元智能测评';
END
ELSE
BEGIN
    PRINT N'  - 已存在: 多元智能测评';
END

DECLARE @assessmentTypeId BIGINT;
SELECT @assessmentTypeId = [Id] FROM [dbo].[assessment_types] WHERE [Code] = 'MI_ASSESSMENT';
PRINT N'  - 测评类型ID: ' + CAST(@assessmentTypeId AS NVARCHAR(10));
GO

-- =============================================
-- 2. 报告分类 (ReportCategory)
-- =============================================
PRINT N'';
PRINT N'2. 导入报告分类...';

DECLARE @assessmentTypeId BIGINT;
SELECT @assessmentTypeId = [Id] FROM [dbo].[assessment_types] WHERE [Code] = 'MI_ASSESSMENT';

-- 清理现有分类数据（如果需要重新导入）
-- DELETE FROM [dbo].[question_category_mappings] WHERE [CategoryId] IN (SELECT [Id] FROM [dbo].[report_categories] WHERE [AssessmentTypeId] = @assessmentTypeId);
-- DELETE FROM [dbo].[report_categories] WHERE [AssessmentTypeId] = @assessmentTypeId;

-- =============================================
-- 2.1 八大智能 (CategoryType=1, ScoreRule=1 累加计分)
-- =============================================
PRINT N'  2.1 八大智能...';

-- 语言智能
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'LANG' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'语言智能', 'LANG', 1, 1, 1, GETDATE(), GETDATE(), 0);

-- 逻辑数学智能
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'LOGIC' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'逻辑数学智能', 'LOGIC', 1, 1, 2, GETDATE(), GETDATE(), 0);

-- 音乐智能
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'MUSIC' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'音乐智能', 'MUSIC', 1, 1, 3, GETDATE(), GETDATE(), 0);

-- 自然探索智能
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'NATURE' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'自然探索智能', 'NATURE', 1, 1, 4, GETDATE(), GETDATE(), 0);

-- 人际交往智能
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'INTER' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'人际交往智能', 'INTER', 1, 1, 5, GETDATE(), GETDATE(), 0);

-- 自我察觉智能
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'INTRA' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'自我察觉智能', 'INTRA', 1, 1, 6, GETDATE(), GETDATE(), 0);

-- 视觉空间智能
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'VISUAL' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'视觉空间智能', 'VISUAL', 1, 1, 7, GETDATE(), GETDATE(), 0);

-- 肢体运动智能
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'BODY' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'肢体运动智能', 'BODY', 1, 1, 8, GETDATE(), GETDATE(), 0);

PRINT N'    - 八大智能导入完成';
GO

-- =============================================
-- 2.2 40项细分能力 (CategoryType=3, ScoreRule=1 累加计分)
-- =============================================
PRINT N'  2.2 40项细分能力...';

DECLARE @assessmentTypeId BIGINT;
SELECT @assessmentTypeId = [Id] FROM [dbo].[assessment_types] WHERE [Code] = 'MI_ASSESSMENT';

DECLARE @langId BIGINT, @logicId BIGINT, @musicId BIGINT, @natureId BIGINT;
DECLARE @interId BIGINT, @intraId BIGINT, @visualId BIGINT, @bodyId BIGINT;

SELECT @langId = [Id] FROM [dbo].[report_categories] WHERE [Code] = 'LANG' AND [AssessmentTypeId] = @assessmentTypeId;
SELECT @logicId = [Id] FROM [dbo].[report_categories] WHERE [Code] = 'LOGIC' AND [AssessmentTypeId] = @assessmentTypeId;
SELECT @musicId = [Id] FROM [dbo].[report_categories] WHERE [Code] = 'MUSIC' AND [AssessmentTypeId] = @assessmentTypeId;
SELECT @natureId = [Id] FROM [dbo].[report_categories] WHERE [Code] = 'NATURE' AND [AssessmentTypeId] = @assessmentTypeId;
SELECT @interId = [Id] FROM [dbo].[report_categories] WHERE [Code] = 'INTER' AND [AssessmentTypeId] = @assessmentTypeId;
SELECT @intraId = [Id] FROM [dbo].[report_categories] WHERE [Code] = 'INTRA' AND [AssessmentTypeId] = @assessmentTypeId;
SELECT @visualId = [Id] FROM [dbo].[report_categories] WHERE [Code] = 'VISUAL' AND [AssessmentTypeId] = @assessmentTypeId;
SELECT @bodyId = [Id] FROM [dbo].[report_categories] WHERE [Code] = 'BODY' AND [AssessmentTypeId] = @assessmentTypeId;

-- 语言智能下的5项细分能力
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'LANG_ORAL' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @langId, N'口语表达力', 'LANG_ORAL', 3, 1, 1, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'LANG_READ' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @langId, N'文字理解力', 'LANG_READ', 3, 1, 2, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'LANG_SENSE' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @langId, N'阅读敏感力', 'LANG_SENSE', 3, 1, 3, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'LANG_WRITE' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @langId, N'写作表达力', 'LANG_WRITE', 3, 1, 4, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'LANG_FEEL' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @langId, N'语言感受力', 'LANG_FEEL', 3, 1, 5, GETDATE(), GETDATE(), 0);

-- 逻辑数学智能下的5项细分能力
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'LOGIC_THINK' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @logicId, N'思辨敏感力', 'LOGIC_THINK', 3, 1, 1, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'LOGIC_DEDUCE' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @logicId, N'演绎思考力', 'LOGIC_DEDUCE', 3, 1, 2, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'LOGIC_INDUCE' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @logicId, N'整合归纳力', 'LOGIC_INDUCE', 3, 1, 3, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'LOGIC_NUM' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @logicId, N'数字敏感力', 'LOGIC_NUM', 3, 1, 4, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'LOGIC_EXEC' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @logicId, N'思维执行力', 'LOGIC_EXEC', 3, 1, 5, GETDATE(), GETDATE(), 0);
GO

-- 继续40项细分能力

DECLARE @assessmentTypeId BIGINT;
SELECT @assessmentTypeId = [Id] FROM [dbo].[assessment_types] WHERE [Code] = 'MI_ASSESSMENT';

DECLARE @musicId BIGINT, @natureId BIGINT, @interId BIGINT, @intraId BIGINT, @visualId BIGINT, @bodyId BIGINT;
SELECT @musicId = [Id] FROM [dbo].[report_categories] WHERE [Code] = 'MUSIC' AND [AssessmentTypeId] = @assessmentTypeId;
SELECT @natureId = [Id] FROM [dbo].[report_categories] WHERE [Code] = 'NATURE' AND [AssessmentTypeId] = @assessmentTypeId;
SELECT @interId = [Id] FROM [dbo].[report_categories] WHERE [Code] = 'INTER' AND [AssessmentTypeId] = @assessmentTypeId;
SELECT @intraId = [Id] FROM [dbo].[report_categories] WHERE [Code] = 'INTRA' AND [AssessmentTypeId] = @assessmentTypeId;
SELECT @visualId = [Id] FROM [dbo].[report_categories] WHERE [Code] = 'VISUAL' AND [AssessmentTypeId] = @assessmentTypeId;
SELECT @bodyId = [Id] FROM [dbo].[report_categories] WHERE [Code] = 'BODY' AND [AssessmentTypeId] = @assessmentTypeId;

-- 音乐智能下的5项细分能力
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'MUSIC_PERFORM' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @musicId, N'音乐表演力', 'MUSIC_PERFORM', 3, 1, 1, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'MUSIC_CREATE' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @musicId, N'创作编曲力', 'MUSIC_CREATE', 3, 1, 2, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'MUSIC_FEEL' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @musicId, N'音乐感受力', 'MUSIC_FEEL', 3, 1, 3, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'MUSIC_SENSE' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @musicId, N'乐感敏锐力', 'MUSIC_SENSE', 3, 1, 4, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'MUSIC_APPR' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @musicId, N'音乐鉴赏力', 'MUSIC_APPR', 3, 1, 5, GETDATE(), GETDATE(), 0);

-- 自然探索智能下的5项细分能力
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'NATURE_CLASS' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @natureId, N'事物分类力', 'NATURE_CLASS', 3, 1, 1, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'NATURE_DETAIL' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @natureId, N'细节识别力', 'NATURE_DETAIL', 3, 1, 2, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'NATURE_EXPLORE' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @natureId, N'自然探索力', 'NATURE_EXPLORE', 3, 1, 3, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'NATURE_CARE' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @natureId, N'生命关怀力', 'NATURE_CARE', 3, 1, 4, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'NATURE_OBS' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @natureId, N'观察敏感力', 'NATURE_OBS', 3, 1, 5, GETDATE(), GETDATE(), 0);

-- 人际交往智能下的5项细分能力
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'INTER_TEAM' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @interId, N'团队合作力', 'INTER_TEAM', 3, 1, 1, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'INTER_LEAD' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @interId, N'人际领袖力', 'INTER_LEAD', 3, 1, 2, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'INTER_COMM' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @interId, N'沟通表达力', 'INTER_COMM', 3, 1, 3, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'INTER_READ' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @interId, N'察言观色力', 'INTER_READ', 3, 1, 4, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'INTER_EMPA' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @interId, N'感同身受力', 'INTER_EMPA', 3, 1, 5, GETDATE(), GETDATE(), 0);
GO

-- 继续40项细分能力 (自我察觉、视觉空间、肢体运动)

DECLARE @assessmentTypeId BIGINT;
SELECT @assessmentTypeId = [Id] FROM [dbo].[assessment_types] WHERE [Code] = 'MI_ASSESSMENT';

DECLARE @intraId BIGINT, @visualId BIGINT, @bodyId BIGINT;
SELECT @intraId = [Id] FROM [dbo].[report_categories] WHERE [Code] = 'INTRA' AND [AssessmentTypeId] = @assessmentTypeId;
SELECT @visualId = [Id] FROM [dbo].[report_categories] WHERE [Code] = 'VISUAL' AND [AssessmentTypeId] = @assessmentTypeId;
SELECT @bodyId = [Id] FROM [dbo].[report_categories] WHERE [Code] = 'BODY' AND [AssessmentTypeId] = @assessmentTypeId;

-- 自我察觉智能下的5项细分能力
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'INTRA_GOAL' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @intraId, N'个人目标力', 'INTRA_GOAL', 3, 1, 1, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'INTRA_STRESS' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @intraId, N'挫折抗压力', 'INTRA_STRESS', 3, 1, 2, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'INTRA_REFLECT' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @intraId, N'自我反省力', 'INTRA_REFLECT', 3, 1, 3, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'INTRA_SOCIAL' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @intraId, N'社会关怀力', 'INTRA_SOCIAL', 3, 1, 4, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'INTRA_EMO' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @intraId, N'情绪控制力', 'INTRA_EMO', 3, 1, 5, GETDATE(), GETDATE(), 0);

-- 视觉空间智能下的5项细分能力
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'VISUAL_IMAGE' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @visualId, N'图像感知力', 'VISUAL_IMAGE', 3, 1, 1, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'VISUAL_CREATE' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @visualId, N'创造想象力', 'VISUAL_CREATE', 3, 1, 2, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'VISUAL_COLOR' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @visualId, N'色彩敏感力', 'VISUAL_COLOR', 3, 1, 3, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'VISUAL_SPACE' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @visualId, N'空间感知力', 'VISUAL_SPACE', 3, 1, 4, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'VISUAL_DRAW' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @visualId, N'绘图操作力', 'VISUAL_DRAW', 3, 1, 5, GETDATE(), GETDATE(), 0);

-- 肢体运动智能下的5项细分能力
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'BODY_FINE' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @bodyId, N'精细操控力', 'BODY_FINE', 3, 1, 1, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'BODY_FLEX' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @bodyId, N'肢体柔韧力', 'BODY_FLEX', 3, 1, 2, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'BODY_BALANCE' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @bodyId, N'身体平衡力', 'BODY_BALANCE', 3, 1, 3, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'BODY_POWER' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @bodyId, N'身体爆发力', 'BODY_POWER', 3, 1, 4, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'BODY_TOUCH' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, @bodyId, N'触感敏锐力', 'BODY_TOUCH', 3, 1, 5, GETDATE(), GETDATE(), 0);

PRINT N'    - 40项细分能力导入完成';
GO

-- =============================================
-- 2.3 个人特质 (CategoryType=2, ScoreRule=1 累加计分)
-- =============================================
PRINT N'  2.3 个人特质...';

DECLARE @assessmentTypeId BIGINT;
SELECT @assessmentTypeId = [Id] FROM [dbo].[assessment_types] WHERE [Code] = 'MI_ASSESSMENT';

IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'TRAIT_VISUAL' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'视觉型特质', 'TRAIT_VISUAL', 2, 1, 1, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'TRAIT_KINETIC' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'手脚并用型特质', 'TRAIT_KINETIC', 2, 1, 2, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'TRAIT_AUDIO' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'听觉型特质', 'TRAIT_AUDIO', 2, 1, 3, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'TRAIT_SELF' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'自我察觉型特质', 'TRAIT_SELF', 2, 1, 4, GETDATE(), GETDATE(), 0);

PRINT N'    - 个人特质导入完成';

-- =============================================
-- 2.4 先天学习类型 (CategoryType=4, ScoreRule=2 二值计分)
-- =============================================
PRINT N'  2.4 先天学习类型...';

IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'LEARN_VISUAL' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'视觉型学习类型', 'LEARN_VISUAL', 4, 2, 1, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'LEARN_THINK' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'思考型学习类型', 'LEARN_THINK', 4, 2, 2, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'LEARN_WHOLE' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'全脑型学习类型', 'LEARN_WHOLE', 4, 2, 3, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'LEARN_BODY' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'体察型学习类型', 'LEARN_BODY', 4, 2, 4, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'LEARN_AUDIO' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'听觉型学习类型', 'LEARN_AUDIO', 4, 2, 5, GETDATE(), GETDATE(), 0);

PRINT N'    - 先天学习类型导入完成';

-- =============================================
-- 2.5 学习的关键能力 (CategoryType=5, ScoreRule=2 二值计分)
-- =============================================
PRINT N'  2.5 学习的关键能力...';

IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'STUDY_FOCUS' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'学习专注力', 'STUDY_FOCUS', 5, 2, 1, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'STUDY_THINK' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'学习思考力', 'STUDY_THINK', 5, 2, 2, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'STUDY_TRANS' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'学习转化力', 'STUDY_TRANS', 5, 2, 3, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'STUDY_MEMORY' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'学习记忆力', 'STUDY_MEMORY', 5, 2, 4, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'STUDY_MOTIVE' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'学习动机力', 'STUDY_MOTIVE', 5, 2, 5, GETDATE(), GETDATE(), 0);

PRINT N'    - 学习的关键能力导入完成';
GO

-- =============================================
-- 2.6 科学大脑类型 (CategoryType=6, ScoreRule=2 二值计分)
-- =============================================
PRINT N'  2.6 科学大脑类型...';

DECLARE @assessmentTypeId BIGINT;
SELECT @assessmentTypeId = [Id] FROM [dbo].[assessment_types] WHERE [Code] = 'MI_ASSESSMENT';

IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'BRAIN_IQ' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'智力脑', 'BRAIN_IQ', 6, 2, 1, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'BRAIN_CREATE' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'创意脑', 'BRAIN_CREATE', 6, 2, 2, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'BRAIN_LANG' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'语言脑', 'BRAIN_LANG', 6, 2, 3, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'BRAIN_MOTOR' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'运动脑', 'BRAIN_MOTOR', 6, 2, 4, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'BRAIN_EMO' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'情绪脑', 'BRAIN_EMO', 6, 2, 5, GETDATE(), GETDATE(), 0);

PRINT N'    - 科学大脑类型导入完成';

-- =============================================
-- 2.7 性格类型 (CategoryType=7, ScoreRule=2 二值计分)
-- =============================================
PRINT N'  2.7 性格类型...';

IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'CHAR_PEACOCK' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'孔雀（表达型）', 'CHAR_PEACOCK', 7, 2, 1, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'CHAR_TIGER' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'老虎（支配型）', 'CHAR_TIGER', 7, 2, 2, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'CHAR_OWL' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'猫头鹰（精准型）', 'CHAR_OWL', 7, 2, 3, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'CHAR_CHAMELEON' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'变色龙（整合型）', 'CHAR_CHAMELEON', 7, 2, 4, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'CHAR_KOALA' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'考拉（耐心型）', 'CHAR_KOALA', 7, 2, 5, GETDATE(), GETDATE(), 0);

PRINT N'    - 性格类型导入完成';

-- =============================================
-- 2.8 未来关键发展能力 (CategoryType=8, ScoreRule=2 二值计分)
-- =============================================
PRINT N'  2.8 未来关键发展能力...';

IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'FUTURE_INFO' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'信息运用力', 'FUTURE_INFO', 8, 2, 1, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'FUTURE_CREATE' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'创新创造力', 'FUTURE_CREATE', 8, 2, 2, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'FUTURE_GOAL' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'目标成就力', 'FUTURE_GOAL', 8, 2, 3, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'FUTURE_ACTION' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'行动执行力', 'FUTURE_ACTION', 8, 2, 4, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'FUTURE_TEAM' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'团队合作力', 'FUTURE_TEAM', 8, 2, 5, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'FUTURE_STRESS' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'抗挫抗压力', 'FUTURE_STRESS', 8, 2, 6, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'FUTURE_LANG' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'多国语言力', 'FUTURE_LANG', 8, 2, 7, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'FUTURE_COMM' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'人际沟通力', 'FUTURE_COMM', 8, 2, 8, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'FUTURE_ADAPT' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'环境适应力', 'FUTURE_ADAPT', 8, 2, 9, GETDATE(), GETDATE(), 0);
IF NOT EXISTS (SELECT 1 FROM [dbo].[report_categories] WHERE [Code] = 'FUTURE_EMO' AND [AssessmentTypeId] = @assessmentTypeId)
    INSERT INTO [dbo].[report_categories] ([AssessmentTypeId], [ParentId], [Name], [Code], [CategoryType], [ScoreRule], [Sort], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES (@assessmentTypeId, 0, N'情绪控制力', 'FUTURE_EMO', 8, 2, 10, GETDATE(), GETDATE(), 0);

PRINT N'    - 未来关键发展能力导入完成';
PRINT N'  报告分类导入完成！';
GO

-- =============================================
-- 3. 题目 (Question) - 80道题
-- =============================================
PRINT N'';
PRINT N'3. 导入题目...';

DECLARE @assessmentTypeId BIGINT;
SELECT @assessmentTypeId = [Id] FROM [dbo].[assessment_types] WHERE [Code] = 'MI_ASSESSMENT';

-- 检查是否已有题目
IF NOT EXISTS (SELECT 1 FROM [dbo].[questions] WHERE [AssessmentTypeId] = @assessmentTypeId)
BEGIN
    INSERT INTO [dbo].[questions] ([AssessmentTypeId], [QuestionNo], [Content], [Sort], [Status], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES 
    (@assessmentTypeId, 1, N'注重细节，主动比较不同环境中动物、植物的适应性特征（干旱、雨季、雷雨等），对比并分析这些不同特征对动植物的影响。', 1, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 2, N'精细操作类游戏或活动表现好（如转笔、游戏操作）或在美术课中能够画出细节丰富的作品或能否熟练使用某种乐器或喜欢组装复杂的手工制作或模型。', 2, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 3, N'在超市买水果时，喜欢主动在心里按颜色、形状或软硬程度给它们分类或整理个人收藏（如树叶标本、玩具）时，习惯按自定的标准（如颜色、材质、使用频次等）进行系统排列。', 3, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 4, N'喜欢自然科学类的课程或喜欢进行自主的自然观察和记录。', 4, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 5, N'能理解并讨论音乐作品的情感和意义或能演奏一种或多种乐器或能识别和分析音乐中的和声和节奏变化或在沟通中，从言语，声调中体会他人的情感。', 5, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 6, N'喜欢口头报告（演讲）等发言行为或在讨论问题时条理足够清晰或喜欢参与辩论赛等类似语言类活动。', 6, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 7, N'在班级（社团）中担任干部或能够协调不同同学的意见或能够公平公正地调解冲突。', 7, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 8, N'与同学、朋友发生冲突时能冷静处理或面对学业压力时，能管理好情绪。', 8, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 9, N'能用语言进行有效的情绪管理和表达或能对复杂话题进行深入探讨交流。', 9, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 10, N'在100米短跑中表现很好或在摸高测试或跳高中表现很好。', 10, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 11, N'学习骑三轮车/自行车很快或学习舞蹈、武术时，身体协调能力强。', 11, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 12, N'在学校的数学考试或竞赛中表现突出或在游戏和活动中，展示深思熟虑的策略和计划。', 12, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 13, N'能通过编程或逻辑游戏展示算法思维或能够在实验/项目中分析数据并总结结论。', 13, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 14, N'在美术作品中能够运用色彩表达情感和主题或对色彩理论（如色环、色调等）表现出兴趣或喜欢探索色彩在不同光线下的变化效果。', 14, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 15, N'主动参加各种音乐创作或演奏比赛，并取得成绩或尝试为学校乐队或小合唱编排和创作新作品。', 15, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 16, N'能阅读并理解较复杂的文本，如小说或报道，并做出批判性分析或对冗长但精彩的故事保持耐心阅读，并有自己的见解。', 16, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 17, N'积极参与需要高度逻辑推理的游戏，如国际象棋、数独等，并表现出策略性或喜欢有效使用计算器、电脑软件等工具来辅助解决问题。', 17, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 18, N'喜欢推理分析，找出联系。', 18, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 19, N'能创作复杂的绘画/雕塑/手工作品或能写短篇小说或能参与学校的戏剧或舞台设计。', 19, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 20, N'喜欢看动画片、图画书。', 20, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 21, N'喜欢记笔记，写写画画。', 21, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 22, N'喜欢和谐团结，讨厌冲突。', 22, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 23, N'喜欢观察周围环境，如昆虫、小猫小狗、花草、天气等自然元素。', 23, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 24, N'喜欢各种音乐活动，喜欢在舞台上唱歌。', 24, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 25, N'在复杂数学题目中的解题思路和计算能力很好或能根据学习计划安排时间并实现制定的目标或能够有效执行家长/老师/同学分配的任务。', 25, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 26, N'能对复杂的自然现象提出独立见解和问题或积极参与学校的科学俱乐部或自然探索小组。', 26, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 27, N'相对跑步、跳跃等大肌肉类运动，更喜欢从事动手掌、手指类的活动，小肌肉发展较好。', 27, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 28, N'在项目/作业中有效分配任务或在班级（朋友）中具有较高的威信或是孩子王。', 28, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 29, N'喜欢参与团体活动。', 29, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 30, N'喜欢参与绘画的活动，并动手画画。', 30, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 31, N'喜欢被抚摸，拥抱等皮肤接触。', 31, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 32, N'喜欢帮助弱势群体，担心受伤的小动物等。', 32, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 33, N'喜欢参加学校或社区的合唱团、乐队或对作曲和编曲表现出兴趣或能分辨并欣赏复杂的音乐作品。', 33, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 34, N'思考较为灵敏，点子多，有发散性思维。', 34, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 35, N'说话或唱歌会主动地改换节奏或音调。', 35, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 36, N'声音十分敏感，很容易记忆以前听过的旋律。', 36, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 37, N'能用力投掷实心球或在力量训练中的表现很好或在击球运动中的表现很好。', 37, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 38, N'喜欢总结规律辅助自己记忆（如历史课）或能在复杂的文章/报告中找出主要观点。', 38, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 39, N'很快能学会滑轮、溜冰、滑雪或在舞蹈/转身、翻转运动中能保持平衡。', 39, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 40, N'擅长比价或计算正确率高。', 40, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 41, N'擅用文字书写方式帮助学习或记忆。', 41, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 42, N'善于理解对方的意思并作出恰当且合适的回应。', 42, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 43, N'善于将物品、玩具分门别类的整理或对天气、植物学、动物学、地质学、地理现象表现出浓厚兴趣。', 43, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 44, N'在公开场合发言时，能控制紧张情绪或遇到失败或挫折时，是否能迅速调整心态。', 44, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 45, N'容易记住生活中的图景、场景、画面。', 45, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 46, N'阅读时能够关注到文章中的细小信息或在科学实验中注意到细节变化或在学习过程中能够识别知识点的细微差异。', 46, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 47, N'容易对所看事情进行联想。', 47, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 48, N'容易对公益性活动产生兴趣并积极投入。', 48, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 49, N'容易从听演讲、看电影或者电视体会意境与作者要表现的情感。', 49, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 50, N'容易被电影的情节或真实事件所感动，看情感电影会哭。', 50, 1, GETDATE(), GETDATE(), 0);
    PRINT N'  - 已导入题目 1-50';
END
GO

-- 继续导入题目 51-80
DECLARE @assessmentTypeId BIGINT;
SELECT @assessmentTypeId = [Id] FROM [dbo].[assessment_types] WHERE [Code] = 'MI_ASSESSMENT';

IF NOT EXISTS (SELECT 1 FROM [dbo].[questions] WHERE [AssessmentTypeId] = @assessmentTypeId AND [QuestionNo] = 51)
BEGIN
    INSERT INTO [dbo].[questions] ([AssessmentTypeId], [QuestionNo], [Content], [Sort], [Status], [CreateTime], [UpdateTime], [IsDeleted])
    VALUES 
    (@assessmentTypeId, 51, N'能通过他人的语言变化，调整自己的语言或肢体动作。', 51, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 52, N'在生活中注意减少浪费，并鼓励家人也这样做或对新闻中有关环境破坏或动物保护的报道表现出兴趣。', 52, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 53, N'能清楚表达自己的看法，并接受他人意见。', 53, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 54, N'能提出并解决实际生活中的数学问题或能够分析实验/经验数据并得出合理结论。', 54, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 55, N'能哼唱出歌曲正确的旋律。', 55, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 56, N'能够自如伸展肢体，身体协调好，喜欢舞蹈、武术、体操等。', 56, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 57, N'能够清楚目标和想法（与对错无关）。', 57, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 58, N'能够觉察他人的情绪感受，并换位思考。', 58, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 59, N'能从一些非语言线索，像是手势、肢体动作等领悟他人的所要表达的意思。', 59, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 60, N'能从故事，小说中体会作者表达的意思。', 60, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 61, N'模仿动作惟妙惟肖或舞蹈肢体动作柔韧。', 61, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 62, N'面对困难时，较能适应，思维积极，不太焦虑。', 62, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 63, N'在进行体育项目（如乒乓球、羽毛球）时动作精准或在编写计算机程序时代码是否整齐规范。', 63, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 64, N'经常会反省、检讨自己的行为。', 64, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 65, N'能够独立完成色彩设计项目，如海报、绘画比赛或在选择服装和装饰品时有独特的色彩品味或对艺术史中色彩运用的研究感兴趣。', 65, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 66, N'会借助绘图或比划的方式表达意思。', 66, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 67, N'敢于面对挑战任务、目标，不怕失败（与是否成功无关）。', 67, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 68, N'对自己想要的目标较为坚持与自我（与对错无关）。', 68, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 69, N'对阅读过或听过的事情能记得较牢，对文字内容、语意敏感度高。', 69, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 70, N'对音乐、曲风有较好的直觉力、判断力。', 70, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 71, N'对文字内容和语意有较好的理解能力。', 71, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 72, N'对所听、所看较为感性。', 72, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 73, N'对数字，运算的敏锐度高，喜欢通过数字表达。', 73, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 74, N'能使用电脑软件进行图形设计或能进行摄影/视频/图像/服装/形象创作或能参与科学博览会设计创新项目。', 74, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 75, N'对动物保护组织的活动表现出关注，并希望参与或在社交网络上分享有关保护自然的文章或视频。', 75, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 76, N'对方向感、立体结构敏锐。', 76, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 77, N'对自己感兴趣的物品或事件，保持长时间观察、想象、分析。', 77, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 78, N'对别人的说话节奏、语气比较在意。', 78, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 79, N'道德意识高，自尊心强，对自己要求高。', 79, 1, GETDATE(), GETDATE(), 0),
    (@assessmentTypeId, 80, N'把握音乐之间的细微区别，感受敏锐。', 80, 1, GETDATE(), GETDATE(), 0);
    PRINT N'  - 已导入题目 51-80';
END

PRINT N'  题目导入完成！共80道题';
GO


-- =============================================
-- 4. 题目-分类映射 (QuestionCategoryMapping)
-- =============================================
PRINT N'';
PRINT N'4. 导入题目-分类映射...';

DECLARE @assessmentTypeId BIGINT;
SELECT @assessmentTypeId = [Id] FROM [dbo].[assessment_types] WHERE [Code] = 'MI_ASSESSMENT';

-- 检查是否已有映射数据
IF NOT EXISTS (SELECT 1 FROM [dbo].[question_category_mappings] qcm 
               INNER JOIN [dbo].[questions] q ON qcm.[QuestionId] = q.[Id] 
               WHERE q.[AssessmentTypeId] = @assessmentTypeId)
BEGIN
    -- =============================================
    -- 4.1 八大智能映射 (CategoryType=1)
    -- =============================================
    PRINT N'  4.1 八大智能映射...';
    
    -- 语言智能 (LANG): 6,9,16,38,41,49,53,60,69,71
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q
    CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId 
      AND c.[Code] = 'LANG' AND c.[AssessmentTypeId] = @assessmentTypeId
      AND q.[QuestionNo] IN (6,9,16,38,41,49,53,60,69,71);

    -- 逻辑数学智能 (LOGIC): 3,12,13,17,18,25,40,43,54,73
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q
    CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId 
      AND c.[Code] = 'LOGIC' AND c.[AssessmentTypeId] = @assessmentTypeId
      AND q.[QuestionNo] IN (3,12,13,17,18,25,40,43,54,73);

    -- 音乐智能 (MUSIC): 5,15,24,33,35,36,50,55,70,80
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q
    CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId 
      AND c.[Code] = 'MUSIC' AND c.[AssessmentTypeId] = @assessmentTypeId
      AND q.[QuestionNo] IN (5,15,24,33,35,36,50,55,70,80);

    -- 自然探索智能 (NATURE): 1,4,23,26,32,45,46,52,62,77
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q
    CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId 
      AND c.[Code] = 'NATURE' AND c.[AssessmentTypeId] = @assessmentTypeId
      AND q.[QuestionNo] IN (1,4,23,26,32,45,46,52,62,77);

    -- 人际交往智能 (INTER): 7,22,28,29,42,48,51,58,59,75
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q
    CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId 
      AND c.[Code] = 'INTER' AND c.[AssessmentTypeId] = @assessmentTypeId
      AND q.[QuestionNo] IN (7,22,28,29,42,48,51,58,59,75);

    -- 自我察觉智能 (INTRA): 8,44,50,53,57,62,64,68,72,79
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q
    CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId 
      AND c.[Code] = 'INTRA' AND c.[AssessmentTypeId] = @assessmentTypeId
      AND q.[QuestionNo] IN (8,44,50,53,57,62,64,68,72,79);

    -- 视觉空间智能 (VISUAL): 14,19,20,21,30,45,47,65,66,76
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q
    CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId 
      AND c.[Code] = 'VISUAL' AND c.[AssessmentTypeId] = @assessmentTypeId
      AND q.[QuestionNo] IN (14,19,20,21,30,45,47,65,66,76);

    -- 肢体运动智能 (BODY): 2,10,11,27,31,37,39,56,61,63
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q
    CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId 
      AND c.[Code] = 'BODY' AND c.[AssessmentTypeId] = @assessmentTypeId
      AND q.[QuestionNo] IN (2,10,11,27,31,37,39,56,61,63);

    PRINT N'    - 八大智能映射完成';
END
GO

-- =============================================
-- 4.2 40项细分能力映射 (CategoryType=3)
-- =============================================
PRINT N'  4.2 40项细分能力映射...';

DECLARE @assessmentTypeId BIGINT;
SELECT @assessmentTypeId = [Id] FROM [dbo].[assessment_types] WHERE [Code] = 'MI_ASSESSMENT';

IF NOT EXISTS (SELECT 1 FROM [dbo].[question_category_mappings] qcm 
               INNER JOIN [dbo].[report_categories] c ON qcm.[CategoryId] = c.[Id]
               WHERE c.[CategoryType] = 3 AND c.[AssessmentTypeId] = @assessmentTypeId)
BEGIN
    -- 语言智能细分
    -- 口语表达力 (LANG_ORAL): 6,9
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'LANG_ORAL' AND q.[QuestionNo] IN (6,9);

    -- 文字理解力 (LANG_READ): 16,71
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'LANG_READ' AND q.[QuestionNo] IN (16,71);

    -- 阅读敏感力 (LANG_SENSE): 38,69
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'LANG_SENSE' AND q.[QuestionNo] IN (38,69);

    -- 写作表达力 (LANG_WRITE): 41,53
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'LANG_WRITE' AND q.[QuestionNo] IN (41,53);

    -- 语言感受力 (LANG_FEEL): 49,60
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'LANG_FEEL' AND q.[QuestionNo] IN (49,60);

    -- 逻辑数学智能细分
    -- 思辨敏感力 (LOGIC_THINK): 12,18
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'LOGIC_THINK' AND q.[QuestionNo] IN (12,18);

    -- 演绎思考力 (LOGIC_DEDUCE): 13,17
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'LOGIC_DEDUCE' AND q.[QuestionNo] IN (13,17);

    -- 整合归纳力 (LOGIC_INDUCE): 3,43
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'LOGIC_INDUCE' AND q.[QuestionNo] IN (3,43);

    -- 数字敏感力 (LOGIC_NUM): 40,73
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'LOGIC_NUM' AND q.[QuestionNo] IN (40,73);

    -- 思维执行力 (LOGIC_EXEC): 25,54
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'LOGIC_EXEC' AND q.[QuestionNo] IN (25,54);

    -- 音乐智能细分
    -- 音乐表演力 (MUSIC_PERFORM): 24,55
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'MUSIC_PERFORM' AND q.[QuestionNo] IN (24,55);

    -- 创作编曲力 (MUSIC_CREATE): 15,35
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'MUSIC_CREATE' AND q.[QuestionNo] IN (15,35);

    -- 音乐感受力 (MUSIC_FEEL): 5,50
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'MUSIC_FEEL' AND q.[QuestionNo] IN (5,50);

    -- 乐感敏锐力 (MUSIC_SENSE): 36,70
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'MUSIC_SENSE' AND q.[QuestionNo] IN (36,70);

    -- 音乐鉴赏力 (MUSIC_APPR): 33,80
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'MUSIC_APPR' AND q.[QuestionNo] IN (33,80);

    -- 自然探索智能细分
    -- 事物分类力 (NATURE_CLASS): 1,46
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'NATURE_CLASS' AND q.[QuestionNo] IN (1,46);

    -- 细节识别力 (NATURE_DETAIL): 62,77
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'NATURE_DETAIL' AND q.[QuestionNo] IN (62,77);

    -- 自然探索力 (NATURE_EXPLORE): 4,23
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'NATURE_EXPLORE' AND q.[QuestionNo] IN (4,23);

    -- 生命关怀力 (NATURE_CARE): 32,52
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'NATURE_CARE' AND q.[QuestionNo] IN (32,52);

    -- 观察敏感力 (NATURE_OBS): 26,45
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'NATURE_OBS' AND q.[QuestionNo] IN (26,45);

    -- 人际交往智能细分
    -- 团队合作力 (INTER_TEAM): 7,29
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'INTER_TEAM' AND q.[QuestionNo] IN (7,29);

    -- 人际领袖力 (INTER_LEAD): 28,42
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'INTER_LEAD' AND q.[QuestionNo] IN (28,42);

    -- 沟通表达力 (INTER_COMM): 58,59
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'INTER_COMM' AND q.[QuestionNo] IN (58,59);

    -- 察言观色力 (INTER_READ): 51,72
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'INTER_READ' AND q.[QuestionNo] IN (51,72);

    -- 感同身受力 (INTER_EMPA): 48,75
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'INTER_EMPA' AND q.[QuestionNo] IN (48,75);

    -- 自我察觉智能细分
    -- 个人目标力 (INTRA_GOAL): 57,68
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'INTRA_GOAL' AND q.[QuestionNo] IN (57,68);

    -- 挫折抗压力 (INTRA_STRESS): 8,44
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'INTRA_STRESS' AND q.[QuestionNo] IN (8,44);

    -- 自我反省力 (INTRA_REFLECT): 64,79
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'INTRA_REFLECT' AND q.[QuestionNo] IN (64,79);

    -- 社会关怀力 (INTRA_SOCIAL): 50,53
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'INTRA_SOCIAL' AND q.[QuestionNo] IN (50,53);

    -- 情绪控制力 (INTRA_EMO): 62,79
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'INTRA_EMO' AND q.[QuestionNo] IN (62,79);

    -- 视觉空间智能细分
    -- 图像感知力 (VISUAL_IMAGE): 20,45
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'VISUAL_IMAGE' AND q.[QuestionNo] IN (20,45);

    -- 创造想象力 (VISUAL_CREATE): 19,47
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'VISUAL_CREATE' AND q.[QuestionNo] IN (19,47);

    -- 色彩敏感力 (VISUAL_COLOR): 14,65
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'VISUAL_COLOR' AND q.[QuestionNo] IN (14,65);

    -- 空间感知力 (VISUAL_SPACE): 21,76
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'VISUAL_SPACE' AND q.[QuestionNo] IN (21,76);

    -- 绘图操作力 (VISUAL_DRAW): 30,66
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'VISUAL_DRAW' AND q.[QuestionNo] IN (30,66);

    -- 肢体运动智能细分
    -- 精细操控力 (BODY_FINE): 2,27
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'BODY_FINE' AND q.[QuestionNo] IN (2,27);

    -- 肢体柔韧力 (BODY_FLEX): 56,61
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'BODY_FLEX' AND q.[QuestionNo] IN (56,61);

    -- 身体平衡力 (BODY_BALANCE): 39,63
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'BODY_BALANCE' AND q.[QuestionNo] IN (39,63);

    -- 身体爆发力 (BODY_POWER): 10,37
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'BODY_POWER' AND q.[QuestionNo] IN (10,37);

    -- 触感敏锐力 (BODY_TOUCH): 31,72
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'BODY_TOUCH' AND q.[QuestionNo] IN (31,72);

    PRINT N'    - 40项细分能力映射完成';
END
GO

-- =============================================
-- 4.3 个人特质映射 (CategoryType=2)
-- =============================================
PRINT N'  4.3 个人特质映射...';

DECLARE @assessmentTypeId BIGINT;
SELECT @assessmentTypeId = [Id] FROM [dbo].[assessment_types] WHERE [Code] = 'MI_ASSESSMENT';

IF NOT EXISTS (SELECT 1 FROM [dbo].[question_category_mappings] qcm 
               INNER JOIN [dbo].[report_categories] c ON qcm.[CategoryId] = c.[Id]
               WHERE c.[CategoryType] = 2 AND c.[AssessmentTypeId] = @assessmentTypeId)
BEGIN
    -- 视觉型特质 (TRAIT_VISUAL): 3,4,14,20,21,23,30,38,43,45,46,47,60,65,66,69,71,74,76,77
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'TRAIT_VISUAL'
      AND q.[QuestionNo] IN (3,4,14,20,21,23,30,38,43,45,46,47,60,65,66,69,71,74,76,77);

    -- 手脚并用型特质 (TRAIT_KINETIC): 2,10,11,12,13,25,27,34,37,39,40,54,56,61,62,63,67,68,73,79
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'TRAIT_KINETIC'
      AND q.[QuestionNo] IN (2,10,11,12,13,25,27,34,37,39,40,54,56,61,62,63,67,68,73,79);

    -- 听觉型特质 (TRAIT_AUDIO): 5,9,15,24,33,35,36,42,49,50,51,55,58,59,69,70,71,72,78,80
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'TRAIT_AUDIO'
      AND q.[QuestionNo] IN (5,9,15,24,33,35,36,42,49,50,51,55,58,59,69,70,71,72,78,80);

    -- 自我察觉型特质 (TRAIT_SELF): 8,9,32,44,48,52,53,57,58,59,62,64,67,68,75,79
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'TRAIT_SELF'
      AND q.[QuestionNo] IN (8,9,32,44,48,52,53,57,58,59,62,64,67,68,75,79);

    PRINT N'    - 个人特质映射完成';
END
GO

-- =============================================
-- 4.4 先天学习类型映射 (CategoryType=4)
-- =============================================
PRINT N'  4.4 先天学习类型映射...';

DECLARE @assessmentTypeId BIGINT;
SELECT @assessmentTypeId = [Id] FROM [dbo].[assessment_types] WHERE [Code] = 'MI_ASSESSMENT';

IF NOT EXISTS (SELECT 1 FROM [dbo].[question_category_mappings] qcm 
               INNER JOIN [dbo].[report_categories] c ON qcm.[CategoryId] = c.[Id]
               WHERE c.[CategoryType] = 4 AND c.[AssessmentTypeId] = @assessmentTypeId)
BEGIN
    -- 视觉型学习类型 (LEARN_VISUAL): 14,20,21,30,45,47,65,66,74,76
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'LEARN_VISUAL'
      AND q.[QuestionNo] IN (14,20,21,30,45,47,65,66,74,76);

    -- 思考型学习类型 (LEARN_THINK): 12,13,18,25,34,38,54,60,71,73
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'LEARN_THINK'
      AND q.[QuestionNo] IN (12,13,18,25,34,38,54,60,71,73);

    -- 全脑型学习类型 (LEARN_WHOLE): 19,26,33,43,53,57,67,68,74,77
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'LEARN_WHOLE'
      AND q.[QuestionNo] IN (19,26,33,43,53,57,67,68,74,77);

    -- 体察型学习类型 (LEARN_BODY): 2,10,11,27,37,39,56,61,63
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'LEARN_BODY'
      AND q.[QuestionNo] IN (2,10,11,27,37,39,56,61,63);

    -- 听觉型学习类型 (LEARN_AUDIO): 5,9,24,35,36,49,55,70,78,80
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'LEARN_AUDIO'
      AND q.[QuestionNo] IN (5,9,24,35,36,49,55,70,78,80);

    PRINT N'    - 先天学习类型映射完成';
END
GO

-- =============================================
-- 4.5 学习的关键能力映射 (CategoryType=5)
-- =============================================
PRINT N'  4.5 学习的关键能力映射...';

DECLARE @assessmentTypeId BIGINT;
SELECT @assessmentTypeId = [Id] FROM [dbo].[assessment_types] WHERE [Code] = 'MI_ASSESSMENT';

IF NOT EXISTS (SELECT 1 FROM [dbo].[question_category_mappings] qcm 
               INNER JOIN [dbo].[report_categories] c ON qcm.[CategoryId] = c.[Id]
               WHERE c.[CategoryType] = 5 AND c.[AssessmentTypeId] = @assessmentTypeId)
BEGIN
    -- 学习专注力 (STUDY_FOCUS): 1,4,23,45,46,47,62,64,68,69,77,79
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'STUDY_FOCUS'
      AND q.[QuestionNo] IN (1,4,23,45,46,47,62,64,68,69,77,79);

    -- 学习思考力 (STUDY_THINK): 12,13,16,18,34,38,54,60,71,73,76,78
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'STUDY_THINK'
      AND q.[QuestionNo] IN (12,13,16,18,34,38,54,60,71,73,76,78);

    -- 学习转化力 (STUDY_TRANS): 2,10,11,25,37,39,54,56,61,63,74,79
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'STUDY_TRANS'
      AND q.[QuestionNo] IN (2,10,11,25,37,39,54,56,61,63,74,79);

    -- 学习记忆力 (STUDY_MEMORY): 36,38,45,55,69,70,71,72,73,76,78,80
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'STUDY_MEMORY'
      AND q.[QuestionNo] IN (36,38,45,55,69,70,71,72,73,76,78,80);

    -- 学习动机力 (STUDY_MOTIVE): 4,23,26,29,48,57,62,67,68,75,77,79
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'STUDY_MOTIVE'
      AND q.[QuestionNo] IN (4,23,26,29,48,57,62,67,68,75,77,79);

    PRINT N'    - 学习的关键能力映射完成';
END
GO

-- =============================================
-- 4.6 科学大脑类型映射 (CategoryType=6)
-- =============================================
PRINT N'  4.6 科学大脑类型映射...';

DECLARE @assessmentTypeId BIGINT;
SELECT @assessmentTypeId = [Id] FROM [dbo].[assessment_types] WHERE [Code] = 'MI_ASSESSMENT';

IF NOT EXISTS (SELECT 1 FROM [dbo].[question_category_mappings] qcm 
               INNER JOIN [dbo].[report_categories] c ON qcm.[CategoryId] = c.[Id]
               WHERE c.[CategoryType] = 6 AND c.[AssessmentTypeId] = @assessmentTypeId)
BEGIN
    -- 智力脑 (BRAIN_IQ): 12,13,18,25,34,38,45,54,60,71,73,76
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'BRAIN_IQ'
      AND q.[QuestionNo] IN (12,13,18,25,34,38,45,54,60,71,73,76);

    -- 创意脑 (BRAIN_CREATE): 14,19,20,30,33,35,47,65,66,74,77,80
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'BRAIN_CREATE'
      AND q.[QuestionNo] IN (14,19,20,30,33,35,47,65,66,74,77,80);

    -- 语言脑 (BRAIN_LANG): 6,9,16,41,49,50,53,60,69,71,72,78
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'BRAIN_LANG'
      AND q.[QuestionNo] IN (6,9,16,41,49,50,53,60,69,71,72,78);

    -- 运动脑 (BRAIN_MOTOR): 2,10,11,27,31,37,39,56,61,62,63,79
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'BRAIN_MOTOR'
      AND q.[QuestionNo] IN (2,10,11,27,31,37,39,56,61,62,63,79);

    -- 情绪脑 (BRAIN_EMO): 8,32,44,48,51,58,59,62,64,67,75,79
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'BRAIN_EMO'
      AND q.[QuestionNo] IN (8,32,44,48,51,58,59,62,64,67,75,79);

    PRINT N'    - 科学大脑类型映射完成';
END
GO

-- =============================================
-- 4.7 性格类型映射 (CategoryType=7)
-- =============================================
PRINT N'  4.7 性格类型映射...';

DECLARE @assessmentTypeId BIGINT;
SELECT @assessmentTypeId = [Id] FROM [dbo].[assessment_types] WHERE [Code] = 'MI_ASSESSMENT';

IF NOT EXISTS (SELECT 1 FROM [dbo].[question_category_mappings] qcm 
               INNER JOIN [dbo].[report_categories] c ON qcm.[CategoryId] = c.[Id]
               WHERE c.[CategoryType] = 7 AND c.[AssessmentTypeId] = @assessmentTypeId)
BEGIN
    -- 孔雀（表达型）(CHAR_PEACOCK): 6,7,9,22,24,29,42,48,53,58
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'CHAR_PEACOCK'
      AND q.[QuestionNo] IN (6,7,9,22,24,29,42,48,53,58);

    -- 老虎（支配型）(CHAR_TIGER): 12,13,25,28,34,54,57,67,68,79
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'CHAR_TIGER'
      AND q.[QuestionNo] IN (12,13,25,28,34,54,57,67,68,79);

    -- 猫头鹰（精准型）(CHAR_OWL): 1,3,38,40,46,63,64,73,76,80
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'CHAR_OWL'
      AND q.[QuestionNo] IN (1,3,38,40,46,63,64,73,76,80);

    -- 变色龙（整合型）(CHAR_CHAMELEON): 4,15,26,33,42,51,59,62,66,77
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'CHAR_CHAMELEON'
      AND q.[QuestionNo] IN (4,15,26,33,42,51,59,62,66,77);

    -- 考拉（耐心型）(CHAR_KOALA): 8,23,32,44,48,52,58,62,75,79
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'CHAR_KOALA'
      AND q.[QuestionNo] IN (8,23,32,44,48,52,58,62,75,79);

    PRINT N'    - 性格类型映射完成';
END
GO

-- =============================================
-- 4.8 未来关键发展能力映射 (CategoryType=8)
-- =============================================
PRINT N'  4.8 未来关键发展能力映射...';

DECLARE @assessmentTypeId BIGINT;
SELECT @assessmentTypeId = [Id] FROM [dbo].[assessment_types] WHERE [Code] = 'MI_ASSESSMENT';

IF NOT EXISTS (SELECT 1 FROM [dbo].[question_category_mappings] qcm 
               INNER JOIN [dbo].[report_categories] c ON qcm.[CategoryId] = c.[Id]
               WHERE c.[CategoryType] = 8 AND c.[AssessmentTypeId] = @assessmentTypeId)
BEGIN
    -- 信息运用力 (FUTURE_INFO): 13,16,38,46,54,60,71,73,77,80
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'FUTURE_INFO'
      AND q.[QuestionNo] IN (13,16,38,46,54,60,71,73,77,80);

    -- 创新创造力 (FUTURE_CREATE): 15,19,33,35,47,65,66,74,77,80
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'FUTURE_CREATE'
      AND q.[QuestionNo] IN (15,19,33,35,47,65,66,74,77,80);

    -- 目标成就力 (FUTURE_GOAL): 25,44,53,57,62,64,67,68,73,79
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'FUTURE_GOAL'
      AND q.[QuestionNo] IN (25,44,53,57,62,64,67,68,73,79);

    -- 行动执行力 (FUTURE_ACTION): 2,10,11,25,37,39,56,61,63,73
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'FUTURE_ACTION'
      AND q.[QuestionNo] IN (2,10,11,25,37,39,56,61,63,73);

    -- 团队合作力 (FUTURE_TEAM): 7,22,29,32,42,48,53,58,59,75
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'FUTURE_TEAM'
      AND q.[QuestionNo] IN (7,22,29,32,42,48,53,58,59,75);

    -- 抗挫抗压力 (FUTURE_STRESS): 8,31,44,50,58,62,64,67,72,79
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'FUTURE_STRESS'
      AND q.[QuestionNo] IN (8,31,44,50,58,62,64,67,72,79);

    -- 多国语言力 (FUTURE_LANG): 6,9,16,41,49,50,53,60,69,71
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'FUTURE_LANG'
      AND q.[QuestionNo] IN (6,9,16,41,49,50,53,60,69,71);

    -- 人际沟通力 (FUTURE_COMM): 7,9,42,48,51,53,58,59,75,78
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'FUTURE_COMM'
      AND q.[QuestionNo] IN (7,9,42,48,51,53,58,59,75,78);

    -- 环境适应力 (FUTURE_ADAPT): 4,11,23,26,31,39,52,56,62,77
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'FUTURE_ADAPT'
      AND q.[QuestionNo] IN (4,11,23,26,31,39,52,56,62,77);

    -- 情绪控制力 (FUTURE_EMO): 8,9,44,50,51,58,62,64,72,79
    INSERT INTO [dbo].[question_category_mappings] ([QuestionId], [CategoryId], [CreateTime])
    SELECT q.[Id], c.[Id], GETDATE()
    FROM [dbo].[questions] q CROSS JOIN [dbo].[report_categories] c
    WHERE q.[AssessmentTypeId] = @assessmentTypeId AND c.[Code] = 'FUTURE_EMO'
      AND q.[QuestionNo] IN (8,9,44,50,51,58,62,64,72,79);

    PRINT N'    - 未来关键发展能力映射完成';
END
GO

-- =============================================
-- 完成
-- =============================================
PRINT N'';
PRINT N'========================================';
PRINT N'测评数据导入完成！';
PRINT N'========================================';
PRINT N'';
PRINT N'导入统计:';
PRINT N'  - 测评类型: 1 个';
PRINT N'  - 报告分类: 82 个';
PRINT N'    - 八大智能: 8 个';
PRINT N'    - 40项细分能力: 40 个';
PRINT N'    - 个人特质: 4 个';
PRINT N'    - 先天学习类型: 5 个';
PRINT N'    - 学习的关键能力: 5 个';
PRINT N'    - 科学大脑类型: 5 个';
PRINT N'    - 性格类型: 5 个';
PRINT N'    - 未来关键发展能力: 10 个';
PRINT N'  - 题目: 80 道';
PRINT N'  - 题目-分类映射: 已建立';
PRINT N'';
GO
