-- ============================================
-- A股智投分析平台 - 种子数据
-- 包含基础版块、股票、市场指数数据
-- ============================================

USE aguzhitou;

-- ============================================
-- 1. 初始化版块数据
-- ============================================
INSERT INTO `sectors` (`name`, `code`) VALUES
('半导体', '880491'),
('新能源', '880952'),
('医药生物', '880122'),
('白酒', '880381'),
('银行', '880471'),
('证券', '880472'),
('保险', '880473'),
('房地产', '880482'),
('汽车', '880391'),
('电子', '880494'),
('计算机', '880498'),
('通信', '880495'),
('传媒', '880499'),
('军工', '880954'),
('有色金属', '880324'),
('钢铁', '880318'),
('煤炭', '880952'),
('化工', '880336'),
('建筑材料', '880344'),
('机械设备', '880440')
ON DUPLICATE KEY UPDATE `name` = VALUES(`name`);

-- ============================================
-- 2. 初始化股票数据
-- ============================================
INSERT INTO `stocks` (`code`, `name`, `sector_code`, `market_cap`, `pe`, `pb`) VALUES
-- 银行板块
('600000', '浦发银行', '880471', 350000000000, 4.5, 0.45),
('600016', '民生银行', '880471', 280000000000, 4.2, 0.42),
('600036', '招商银行', '880471', 850000000000, 6.8, 1.05),
('601166', '兴业银行', '880471', 420000000000, 4.8, 0.58),
('601288', '农业银行', '880471', 1200000000000, 4.5, 0.55),
('601398', '工商银行', '880471', 1800000000000, 4.8, 0.58),
('601988', '中国银行', '880471', 950000000000, 4.6, 0.52),

-- 白酒板块
('000568', '泸州老窖', '880381', 320000000000, 25.5, 6.8),
('000858', '五粮液', '880381', 650000000000, 22.3, 5.8),
('600519', '贵州茅台', '880381', 2100000000000, 32.5, 9.8),
('600809', '山西汾酒', '880381', 280000000000, 28.5, 8.5),

-- 半导体板块
('688008', '澜起科技', '880491', 85000000000, 65.2, 8.5),
('688012', '中微公司', '880491', 120000000000, 78.5, 9.2),
('688036', '传音控股', '880491', 95000000000, 22.5, 6.8),
('688981', '中芯国际', '880491', 420000000000, 85.5, 3.8),

-- 新能源板块
('601012', '隆基绿能', '880952', 180000000000, 15.5, 2.8),
('002594', '比亚迪', '880952', 650000000000, 32.5, 5.8),
('300274', '阳光电源', '880952', 120000000000, 28.5, 8.5),
('603659', '璞泰来', '880952', 45000000000, 25.5, 4.2),

-- 医药生物板块
('600196', '复星医药', '880122', 68000000000, 22.5, 2.1),
('600276', '恒瑞医药', '880122', 380000000000, 65.8, 8.5),
('603259', '药明康德', '880122', 280000000000, 35.5, 5.8),

-- 证券板块
('600030', '中信证券', '880472', 320000000000, 18.5, 1.35),
('600837', '海通证券', '880472', 120000000000, 22.5, 0.95),
('601688', '华泰证券', '880472', 85000000000, 15.8, 0.88),

-- 汽车板块
('600104', '上汽集团', '880391', 180000000000, 12.5, 0.85),
('601633', '长城汽车', '880391', 220000000000, 18.5, 2.8),
('601238', '广汽集团', '880391', 95000000000, 12.8, 0.95),

-- 电子板块
('000725', '京东方A', '880494', 165000000000, 45.5, 1.35),
('002415', '海康威视', '880494', 320000000000, 22.5, 4.8),
('601138', '工业富联', '880494', 280000000000, 15.5, 2.1),

-- 有色金属板块
('601899', '紫金矿业', '880324', 320000000000, 15.8, 3.2),
('603993', '洛阳钼业', '880324', 120000000000, 18.5, 2.5),

-- 化工板块
('600309', '万华化学', '880336', 280000000000, 18.5, 3.8),
('002001', '新和成', '880336', 65000000000, 22.5, 2.8)
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `sector_code` = VALUES(`sector_code`),
    `market_cap` = VALUES(`market_cap`),
    `pe` = VALUES(`pe`),
    `pb` = VALUES(`pb`);

-- ============================================
-- 3. 初始化市场指数数据
-- ============================================
INSERT INTO `market_indices` (`name`, `code`, `current`, `change`, `changePercent`, `volume`, `turnover`, `sortOrder`) VALUES
('上证指数', '000001', 3050.32, 15.23, 0.50, 450000000, 4200000000, 1),
('深证成指', '399001', 9850.15, -25.60, -0.26, 520000000, 5100000000, 2),
('创业板指', '399006', 1950.45, 8.75, 0.45, 180000000, 2100000000, 3),
('科创50', '000688', 850.32, -5.23, -0.61, 65000000, 950000000, 4)
ON DUPLICATE KEY UPDATE
    `current` = VALUES(`current`),
    `change` = VALUES(`change`),
    `changePercent` = VALUES(`changePercent`),
    `volume` = VALUES(`volume`),
    `turnover` = VALUES(`turnover`);

-- ============================================
-- 4. 初始化版块行情数据（当前）
-- ============================================
INSERT INTO `sector_quotes` (`sector_code`, `current`, `change`, `changePercent`, `volume`, `turnover`, `momentumScore`, `rank`, `previous_rank`, `quote_time`) VALUES
('880491', 2850.50, 45.25, 1.61, 850000000, 12500000000, 85.5, 1, 3, NOW()),
('880952', 3250.80, 38.50, 1.20, 1200000000, 18500000000, 82.3, 2, 1, NOW()),
('880122', 2150.35, 22.15, 1.04, 650000000, 9800000000, 78.5, 3, 2, NOW()),
('880381', 4850.60, 35.80, 0.74, 450000000, 7200000000, 75.2, 4, 4, NOW()),
('880472', 1250.25, 8.50, 0.68, 380000000, 5200000000, 72.8, 5, 6, NOW()),
('880471', 1850.40, 10.20, 0.55, 520000000, 6800000000, 68.5, 6, 5, NOW()),
('880391', 2250.75, 12.35, 0.55, 480000000, 6500000000, 65.3, 7, 8, NOW()),
('880494', 1650.90, 7.80, 0.47, 420000000, 5800000000, 62.5, 8, 7, NOW()),
('880498', 2850.15, 12.50, 0.44, 380000000, 5200000000, 58.2, 9, 10, NOW()),
('880324', 1950.45, 6.25, 0.32, 320000000, 4800000000, 55.8, 10, 9, NOW()),
('880473', 1450.60, 3.80, 0.26, 280000000, 3800000000, 52.5, 11, 11, NOW()),
('880495', 1250.35, 2.15, 0.17, 250000000, 3500000000, 48.2, 12, 13, NOW()),
('880954', 1850.80, 2.80, 0.15, 220000000, 3200000000, 45.8, 13, 12, NOW()),
('880336', 2150.25, 2.50, 0.12, 290000000, 4200000000, 42.5, 14, 15, NOW()),
('880440', 1750.90, 1.85, 0.11, 260000000, 3600000000, 38.2, 15, 14, NOW()),
('880318', 850.45, 0.75, 0.09, 180000000, 2200000000, 35.8, 16, 16, NOW()),
('880344', 950.60, 0.60, 0.06, 150000000, 1800000000, 32.5, 17, 18, NOW()),
('880482', 1250.35, -2.50, -0.20, 200000000, 2800000000, 28.2, 18, 17, NOW()),
('880499', 850.25, -2.15, -0.25, 120000000, 1500000000, 25.8, 19, 19, NOW()),
('880952', 450.80, -3.25, -0.72, 95000000, 1200000000, 18.5, 20, 20, NOW());

-- ============================================
-- 5. 初始化完成
-- ============================================
SELECT 
    (SELECT COUNT(*) FROM sectors) AS sector_count,
    (SELECT COUNT(*) FROM stocks) AS stock_count,
    (SELECT COUNT(*) FROM market_indices) AS index_count,
    'Seed data loaded successfully' AS status;
