diff --git a/Controller/RuYuanZaiYuanCountController.py b/Controller/RuYuanZaiYuanCountController.py index fe893a4..0db2748 100644 --- a/Controller/RuYuanZaiYuanCountController.py +++ b/Controller/RuYuanZaiYuanCountController.py @@ -18,3 +18,4 @@ async def get_preschool_education_chart_config(): async def get_preschool_in_school_chart_config(): return RuYuanZaiYuanModel.generate_in_school_education_config() + diff --git a/Controller/__pycache__/RuYuanZaiYuanCountController.cpython-310.pyc b/Controller/__pycache__/RuYuanZaiYuanCountController.cpython-310.pyc index c313beb..b673b4e 100644 Binary files a/Controller/__pycache__/RuYuanZaiYuanCountController.cpython-310.pyc and b/Controller/__pycache__/RuYuanZaiYuanCountController.cpython-310.pyc differ diff --git a/Doc/全省(城镇乡3分)自动计算模板0415 copy(1).xlsx b/Doc/全省(城镇乡3分)自动计算模板0415 copy(1).xlsx new file mode 100644 index 0000000..38676d5 Binary files /dev/null and b/Doc/全省(城镇乡3分)自动计算模板0415 copy(1).xlsx differ diff --git a/Model/RuYuanZaiYuanCountModel.py b/Model/RuYuanZaiYuanCountModel.py index ed45136..f697b7f 100644 --- a/Model/RuYuanZaiYuanCountModel.py +++ b/Model/RuYuanZaiYuanCountModel.py @@ -28,145 +28,46 @@ class RuYuanZaiYuanModel: @staticmethod def generate_preschool_education_config(): # 获取学前教育相关数据 - enrollment_data, in_school_data = RuYuanZaiYuanModel.load_student_data() + # enrollment_data, in_school_data = RuYuanZaiYuanModel.load_student_data() + # + # # 提取云南省级数据 + # yunnan_enroll = next((item for item in enrollment_data if item["area_name"] == "云南省"), None) + # + # if not yunnan_enroll: + # return {} + # + # # 提取年份数据(2015-2024) + # years = [str(year) for year in range(2015, 2025)] + # + # # 构建学前教育数据 + # urban_data = [] # 城区数据 + # town_data = [] # 镇区数据 + # rural_data = [] # 乡村数据 + # total_enroll = [] # 总入园数 + # + # for year in years: + # enroll_data = yunnan_enroll["education_data"]["preschool"].get(year, {}) + # urban_data.append(enroll_data.get("urban", 0) / 10000) # 转换为万人 + # town_data.append(enroll_data.get("town", 0) / 10000) # 转换为万人 + # rural_data.append(enroll_data.get("rural", 0) / 10000) # 转换为万人 + # # 计算总和作为总入园数,而非使用文件中的total字段 + # calculated_total = enroll_data.get("urban", 0) + enroll_data.get("town", 0) + enroll_data.get("rural", 0) + # total_enroll.append(calculated_total / 10000) # 转换为万人 - # 提取云南省级数据 - yunnan_enroll = next((item for item in enrollment_data if item["area_name"] == "云南省"), None) - - if not yunnan_enroll: - return {} - - # 提取年份数据(2015-2024) - years = [str(year) for year in range(2015, 2025)] - - # 构建学前教育数据 - urban_data = [] # 城区数据 - town_data = [] # 镇区数据 - rural_data = [] # 乡村数据 - total_enroll = [] # 总入园数 - - for year in years: - enroll_data = yunnan_enroll["education_data"]["preschool"].get(year, {}) - urban_data.append(enroll_data.get("urban", 0) / 10000) # 转换为万人 - town_data.append(enroll_data.get("town", 0) / 10000) # 转换为万人 - rural_data.append(enroll_data.get("rural", 0) / 10000) # 转换为万人 - # 计算总和作为总入园数,而非使用文件中的total字段 - calculated_total = enroll_data.get("urban", 0) + enroll_data.get("town", 0) + enroll_data.get("rural", 0) - total_enroll.append(calculated_total / 10000) # 转换为万人 - - # 添加2022年基数的粉色折线 - base_year = "2022" - # 找到2022年在years中的索引位置 - base_index = years.index(base_year) if base_year in years else 0 - # 获取2022年的总入园数作为基数 - base_value = total_enroll[base_index] if base_index < len(total_enroll) else 0 - # 创建2022年基数折线数据(2022-2024年) - base_2022_line = [] - for i, year in enumerate(years): - # 只在2022年及之后显示基数线 - if i >= base_index: - base_2022_line.append(base_value) - else: - base_2022_line.append(None) # 2022年之前不显示 - - # 构建ECharts配置 - option = { - "grid": { - "left": 0, - "right": 0, - "top": 40, - "bottom": 10, - "containLabel": True, - }, - "textStyle": { - "color": "#fff", - }, - "tooltip": { - "trigger": "axis", - "axisPointer": { - "type": "cross", - "crossStyle": {"color": "#999"} - }, - "textStyle": {"color": "#fff"}, - "backgroundColor": "rgba(96,98,102,0.8)", - "borderColor": "rgba(255,255,255,0.3)", - "borderWidth": 1 - }, - "legend": { - "data": ["城区", "镇区", "乡村", "总入园数", "2022年基数"], - "top": 0, - "textStyle": {"color": "#fff"}, - "icon": "roundRect", - "itemWidth": 12, - "itemHeight": 12 - }, - "xAxis": [ - { - "type": "category", - "data": years, - "axisPointer": {"type": "shadow"}, - "axisLine": {"lineStyle": {"color": "#fff"}}, - "axisLabel": {"color": "#fff"}, - "nameTextStyle": {"color": "#fff"} + xAxis = ["2019", "2020", "2021", "2022", "2023", "2024", "2025", "2026"] + series_data_1 = [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6] + series_data_2 = [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6] + series_data_3 = [2.4, 5.2, 8.0, 25.4, 27.7, 73.7, 155.6] + series_data_4 = [2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3] + line_data = [2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3] + data = {"xAxis": xAxis, + "series_data_1": series_data_1, + "series_data_2": series_data_2, + "series_data_3": series_data_3, + "series_data_4": series_data_4, + "line_data": line_data } - ], - "yAxis": [ - { - "type": "value", - - "axisLabel": { - "formatter": "{value}" - , "color": "#fff" - } - }, - { - "type": "value", - - "axisLabel": {"formatter": "{value}", "color": "#fff"}, - }, - - ], - "series": [ - { - "name": "城区", - "type": "bar", - "data": urban_data, - "itemStyle": { - "borderRadius": [6, 6, 0, 0], - } - }, - { - "name": "镇区", - "type": "bar", - "data": town_data, - "itemStyle": { - "borderRadius": [6, 6, 0, 0], - }, - }, - { - "name": "乡村", - "type": "bar", - "data": rural_data, - "itemStyle": { - "borderRadius": [6, 6, 0, 0] - }, - }, - { - "name": "总入园数", - "type": "line", - "yAxisIndex": 1, - "data": total_enroll - }, - # 添加2022年基数的粉色折线 - { - "name": "2022年基数", - "type": "line", - "yAxisIndex": 1, - "data": base_2022_line - } - ] - } - return option + return data @staticmethod def generate_in_school_education_config(): diff --git a/Model/__pycache__/RuYuanZaiYuanCountModel.cpython-310.pyc b/Model/__pycache__/RuYuanZaiYuanCountModel.cpython-310.pyc index 3b7c95e..0440c50 100644 Binary files a/Model/__pycache__/RuYuanZaiYuanCountModel.cpython-310.pyc and b/Model/__pycache__/RuYuanZaiYuanCountModel.cpython-310.pyc differ diff --git a/Start.py b/Start.py index 2042d05..5929489 100644 --- a/Start.py +++ b/Start.py @@ -16,5 +16,5 @@ app.include_router(ruyuanZaiYuan_router) # 主程序入口 if __name__ == "__main__": - # 启动 FastAPI 应用,监听 8200 端口 + # 启动 FastAPI 应用,监听 8100 端口 uvicorn.run(app, host="0.0.0.0", port=8100) \ No newline at end of file