diff --git a/Mods/IndepthResearch/Mods/CompanyReport/Router.py b/Mods/IndepthResearch/Mods/CompanyReport/Router.py index a4447f0..7fdb720 100644 --- a/Mods/IndepthResearch/Mods/CompanyReport/Router.py +++ b/Mods/IndepthResearch/Mods/CompanyReport/Router.py @@ -248,22 +248,41 @@ def company_score_add(company_id: int = "企业id", db: Session = Depends(common report_data['市'] = area_index_main_get(db=db, item_id=city_id).name if city_id else None # area_id查询 - # query_id = city_id if city_id else province_id - # data_year = db.query(t_area_report).filter(t_area_report.c['area_id'] == query_id) - # data = [dict(zip(t_area_report.c.keys(), item)) for item in data_year] - # result = { - # "2020": {}, - # "2021": {}, - # "2022": {} - # } - # - # for d in data: - # year = d["年份"] - # if str(year) not in result: - # continue - # result[str(year)]["GDP"] = d["GDP(亿元)"] - # result[str(year)]["GDP增长率"] = d["GDP增速(%)"] - # report_data['近三年经济数据'] = result + query_id = city_id if city_id else province_id + data_year = db.query(t_area_report).filter(t_area_report.c['area_id'] == query_id) + data = [dict(zip(t_area_report.c.keys(), item)) for item in data_year] + result = { + "2020": {}, + "2021": {}, + "2022": {} + } + + for item in data: + year = str(item["年份"]) + result[year]["GDP"] = str(item["GDP(亿元)"]) + "亿元" + result[year]["GDP增长率"] = str(item["GDP增速(%)"]) + "%" + result[year]["人均GDP"] = str(item["人均GDP(元)"]) + "元" + result[year]["常住人口"] = str(item["人口(万人)"]) + "万" + + result[year]["一般公共预算收入"] = str(item["一般公共预算收入(亿元)"]) + "亿元" + result[year]["税收收入"] = str(item["一般公共预算收入:税收收入(亿元)"]) + "亿元" + result[year]["税收占比"] = str(item["一般公共预算收入:税收占比(%)"]) + "%" + result[year]["转移性收入"] = str(item["一般公共预算收入:转移性收入(亿元)"]) + "亿元" + + result[year]["一般公共预算支出"] = str(item["一般公共预算支出(亿元)"]) + "亿元" + result[year]["土地出让收入"] = str(item.get('一般公共预算支出(亿元)')) + result[year]["政府性基金收入"] = str(item["政府性基金收入(亿元)"]) + "亿元" + result[year]["财政自给率"] = str(item["财政自给率(%)"]) + "%" + + result[year]["地方政府债务余额"] = str(item["地方政府债务余额(亿元)"]) + "亿元" + result[year]["地方政府债务限额"] = str(item["地方政府债务限额(亿元)"]) + "亿元" + result[year]["城投有息债务合计"] = str(item["城投平台有息债务(亿元)"]) + "亿元" + result[year]["负债率"] = str(item["负债率(宽口径)(%)"]) + "%" + result[year]["区域宽口径债务率"] = str(item["债务率(宽口径)(%)"]) + "%" + + result[year]["新房销售价格"] = str(item["新房销售价格(元/㎡)"]) + "元/平米" + result[year]["住宅土地楼面价"] = str(item["住宅土地楼面价(元/㎡)"]) + "元/平米" + report_data['近三年经济数据'] = result # 写入模板docx # 生成word研报