-- 区县经济指标数据表
CREATE TABLE IF NOT EXISTS regional_economic_data (
    id SERIAL PRIMARY KEY,
    district_name VARCHAR(50) NOT NULL,
    district_code VARCHAR(20) NOT NULL,
    year INT NOT NULL,
    -- 核心经济指标
    gdp DECIMAL(14,2),                -- GDP总量（亿元）
    gdp_growth DECIMAL(5,2),          -- GDP同比增速（%）
    gdp_per_capita DECIMAL(12,2),     -- 人均GDP（元）
    fiscal_revenue DECIMAL(12,2),     -- 一般公共预算收入（亿元）
    fiscal_revenue_growth DECIMAL(5,2),
    fixed_investment DECIMAL(12,2),   -- 固定资产投资（亿元）
    fixed_investment_growth DECIMAL(5,2),
    retail_sales DECIMAL(12,2),       -- 社消零售总额（亿元）
    retail_sales_growth DECIMAL(5,2),
    industrial_output DECIMAL(12,2),  -- 规上工业增加值（亿元）
    industrial_output_growth DECIMAL(5,2),
    tertiary_ratio DECIMAL(5,2),      -- 第三产业占比（%）
    import_export DECIMAL(12,2),      -- 进出口总额（亿元）
    import_export_growth DECIMAL(5,2),
    actual_fdi DECIMAL(10,2),         -- 实际利用外资（亿美元）
    tech_expenditure DECIMAL(10,2),   -- R&D经费投入（亿元）
    tech_expenditure_ratio DECIMAL(5,2), -- R&D/GDP（%）
    -- 补充指标
    population DECIMAL(8,2),          -- 常住人口（万人）
    urban_income DECIMAL(10,2),       -- 城镇居民人均可支配收入（元）
    rural_income DECIMAL(10,2),       -- 农村居民人均可支配收入（元）
    created_at TIMESTAMPTZ DEFAULT now(),
    UNIQUE(district_code, year)
);

-- 清理旧数据
DELETE FROM regional_economic_data;

-- ====================================================================
-- 2024年数据
-- ====================================================================
INSERT INTO regional_economic_data (district_name, district_code, year,
    gdp, gdp_growth, gdp_per_capita, fiscal_revenue, fiscal_revenue_growth,
    fixed_investment, fixed_investment_growth, retail_sales, retail_sales_growth,
    industrial_output, industrial_output_growth, tertiary_ratio,
    import_export, import_export_growth, actual_fdi, tech_expenditure, tech_expenditure_ratio,
    population, urban_income, rural_income) VALUES
('东城区', 'dongcheng', 2024, 2856.30, 5.8, 182540, 312.50, 6.2, 1285.40, 4.8, 1356.20, 5.5, 485.60, 6.1, 68.5, 856.30, 7.2, 12.80, 98.50, 3.45, 156.50, 82560, 48320),
('西城区', 'xicheng', 2024, 2145.80, 6.1, 168920, 245.80, 5.8, 985.60, 5.2, 1125.40, 6.8, 356.20, 5.5, 72.3, 625.40, 6.5, 8.50, 72.30, 3.37, 127.00, 78450, 45680),
('南城区', 'nancheng', 2024, 1856.50, 5.5, 152360, 198.60, 4.8, 856.30, 3.5, 985.60, 5.2, 312.50, 4.8, 65.8, 425.60, 5.8, 6.20, 52.80, 2.84, 121.90, 75680, 42560),
('北城区', 'beicheng', 2024, 1625.40, 5.2, 145680, 178.50, 4.5, 756.80, 3.2, 856.30, 4.8, 285.60, 4.2, 63.5, 356.80, 4.5, 4.80, 42.50, 2.61, 111.60, 72340, 40250),
('高新区', 'gaoxin', 2024, 3256.80, 8.5, 245680, 425.60, 9.2, 1856.30, 12.5, 985.60, 7.5, 856.30, 10.2, 58.2, 1856.30, 12.8, 28.50, 168.50, 5.17, 132.60, 95680, 52340),
('经开区', 'jingkai', 2024, 2456.50, 7.8, 198560, 325.80, 8.5, 1556.80, 11.2, 856.30, 6.5, 685.60, 9.8, 52.5, 1256.80, 10.5, 18.60, 125.60, 5.11, 123.70, 88560, 48560),
('青山县', 'qingshan', 2024, 685.60, 4.2, 82560, 62.50, 3.5, 325.60, 2.8, 356.80, 3.5, 185.60, 3.8, 45.2, 125.60, 3.2, 1.80, 12.50, 1.82, 83.00, 56780, 32560),
('和平县', 'heping', 2024, 525.80, 3.8, 68540, 48.60, 3.2, 256.80, 2.5, 285.60, 3.2, 142.50, 3.2, 42.8, 85.60, 2.8, 1.20, 8.60, 1.64, 76.70, 52340, 30250),
('龙湖县', 'longhu', 2024, 456.30, 3.5, 62540, 38.50, 2.8, 198.60, 2.2, 225.60, 2.8, 125.60, 2.8, 40.5, 65.80, 2.5, 0.85, 6.50, 1.42, 72.90, 48560, 28560),
('明德县', 'mingde', 2024, 385.60, 3.2, 55680, 32.50, 2.5, 168.50, 1.8, 198.60, 2.5, 98.50, 2.5, 38.6, 45.60, 2.2, 0.65, 4.80, 1.24, 69.30, 45680, 26840),
('新华区', 'xinhua', 2024, 1356.80, 6.5, 156780, 165.80, 6.8, 685.60, 6.5, 756.80, 6.2, 245.60, 5.8, 62.5, 385.60, 6.8, 5.60, 45.60, 3.36, 86.50, 72560, 42680);

-- ====================================================================
-- 2025年数据
-- ====================================================================
INSERT INTO regional_economic_data (district_name, district_code, year,
    gdp, gdp_growth, gdp_per_capita, fiscal_revenue, fiscal_revenue_growth,
    fixed_investment, fixed_investment_growth, retail_sales, retail_sales_growth,
    industrial_output, industrial_output_growth, tertiary_ratio,
    import_export, import_export_growth, actual_fdi, tech_expenditure, tech_expenditure_ratio,
    population, urban_income, rural_income) VALUES
('东城区', 'dongcheng', 2025, 3045.20, 6.6, 193560, 335.80, 7.5, 1356.80, 5.6, 1445.80, 6.6, 518.60, 6.8, 69.2, 928.50, 8.4, 14.20, 112.50, 3.69, 157.40, 87250, 51480),
('西城区', 'xicheng', 2025, 2298.50, 7.1, 179850, 265.80, 8.1, 1065.80, 8.1, 1205.60, 7.1, 385.60, 8.3, 73.5, 685.60, 9.6, 9.80, 82.50, 3.59, 127.80, 82850, 48560),
('南城区', 'nancheng', 2025, 1965.80, 5.9, 160580, 212.50, 7.0, 912.50, 6.6, 1052.80, 6.8, 338.50, 8.3, 66.5, 465.80, 9.4, 7.20, 60.50, 3.08, 122.40, 79850, 45280),
('北城区', 'beicheng', 2025, 1712.50, 5.4, 152680, 189.60, 6.2, 798.50, 5.5, 905.60, 5.8, 302.50, 5.9, 64.2, 382.50, 7.2, 5.50, 48.60, 2.84, 112.20, 76450, 42850),
('高新区', 'gaoxin', 2025, 3586.50, 10.1, 268560, 475.80, 11.8, 2125.60, 14.5, 1085.60, 10.1, 965.80, 12.8, 59.5, 2156.80, 16.2, 35.60, 198.50, 5.54, 133.50, 102560, 56280),
('经开区', 'jingkai', 2025, 2685.80, 9.3, 215680, 362.50, 11.3, 1785.60, 14.7, 925.60, 8.1, 768.50, 12.1, 53.8, 1425.80, 13.4, 22.50, 148.50, 5.53, 124.50, 94560, 52180),
('青山县', 'qingshan', 2025, 718.50, 4.8, 86250, 66.80, 6.9, 348.60, 7.1, 378.50, 6.1, 198.50, 7.0, 46.5, 138.50, 10.3, 2.15, 14.80, 2.06, 83.30, 59850, 34560),
('和平县', 'heping', 2025, 548.60, 4.3, 71250, 51.80, 6.6, 272.50, 6.1, 302.50, 5.9, 152.80, 7.2, 43.5, 92.50, 8.1, 1.45, 10.20, 1.86, 77.00, 55280, 32150),
('龙湖县', 'longhu', 2025, 476.80, 4.5, 65280, 41.20, 7.0, 215.60, 8.6, 240.80, 6.7, 135.60, 8.0, 41.8, 72.80, 10.6, 1.05, 7.80, 1.64, 73.10, 51280, 30250),
('明德县', 'mingde', 2025, 402.80, 4.5, 58120, 34.80, 7.1, 182.50, 8.3, 212.50, 7.0, 106.50, 8.1, 39.8, 50.80, 11.4, 0.82, 5.80, 1.44, 69.30, 48250, 28560),
('新华区', 'xinhua', 2025, 1452.50, 7.0, 166250, 179.80, 8.4, 745.80, 8.8, 812.50, 7.4, 268.50, 9.3, 63.8, 425.60, 10.4, 6.80, 52.80, 3.64, 87.40, 76850, 45280);
