Commit 72fe2ccd by dong

fix20230413

parent dcaace2d
...@@ -5,86 +5,103 @@ from apps.utils.response_code import RET ...@@ -5,86 +5,103 @@ from apps.utils.response_code import RET
from apps.big_data import api_bigdata from apps.big_data import api_bigdata
# 项目管理---项目列表 # 获取项目列表
"""项目总览""" @api_bigdata.route("/GetProject", methods=["POST"])
def get_project():
req_dic = request.get_json()
# # token = request.headers['token']
#
# project_stalker = req_dic['project_stalker']
#
# project_name = req_dic['project_name']
# district = req_dic['district']
# development_area = req_dic['development_area']
# investor_name = req_dic['investor_name']
# investor_district = req_dic['investor_district']
# industry = req_dic['industry']
# industry2 = ''
# if '/' in industry:
# industry1 = industry.split('/')[0]
# industry2 = industry.split('/')[1]
# else:
# industry1 = industry
# investment_volume = req_dic['investment_volume']
# project_progress = req_dic['project_progress']
# project_year = req_dic['project_year']
page = req_dic['page']
per_page = req_dic['per_page']
# flag = req_dic['flag']
@api_bigdata.route("/GetJjzb", methods=["GET"]) # 项目跟踪 # try:
def get_jjzb(): # user_obj = verify_token(token)
try: # user_district = get_district_name(token)
obj_li = City.query.all() # except Exception as e:
data = [{ # current_app.logger.error(e)
"id": obj.id, # return jsonify(code=RET.SESSIONERR, msg="进行操作时用户信息校验失败,请重新登陆后尝试!")
"area": obj.area,
"size": obj.size,
"year": obj.year,
"people": obj.people,
"GDP": obj.GDP,
"addscale": obj.addscale,
"investment": obj.investment,
"retail": obj.retail,
"in_out": obj.in_out,
"public": obj.public,
"people_out": obj.people_out,
"people_per": obj.people_per,
"public_in": obj.public_in,
"info": obj.info,
"question": obj.question,
"flag": obj.flag
} for obj in obj_li]
return jsonify(code=RET.OK, data=data, msg="查询成功!")
except Exception as e:
current_app.logger.error(e)
return jsonify(code=RET.DBERR, msg="查询出错!")
@api_bigdata.route("/GetCyfb", methods=["POST"]) # 项目跟踪
def get_cyfb():
req_dict = request.get_json()
district = req_dict.get("district") # 区县或者开发区名称
try: try:
# 3. 产业结构分布饼状图数据统计 # project_obj = ProjectManagement.query.filter(
company = Company.query.filter(Company.district == district if district else text('')) # ProjectManagement.project_name.like('%{}%'.format(project_name)) if project_name else text(''),
count_all = company.count() # ProjectManagement.project_stalker == project_stalker if project_stalker else text(''),
if count_all == 0: # ProjectManagement.district == district if district else text(''),
count_all = 1 # ProjectManagement.development_area == development_area if development_area else text(''),
count_gt = company.filter_by(f_type=1).count() # 钢铁 # ProjectManagement.investment_volume > investment_volume[0] if investment_volume else text(''),
count_gjd = company.filter_by(f_type=2).count() # 光机电 # ProjectManagement.investment_volume <= investment_volume[1] if investment_volume else text(''),
count_mcq = company.filter_by(f_type=7).count() # 煤层气 # ProjectManagement.investor_district.like('%{}%'.format(investor_district)) if investor_district else text(
count_zbzz = company.filter_by(f_type=8).count() # 装备制造 # ''),
count_zz = company.filter_by(f_type=9).count() # 铸造 # ProjectManagement.industry.like('%{}%'.format(industry1)) if industry1 else text(''),
count_mhg = company.filter_by(f_type=10).count() # 煤化工 # ProjectManagement.industry2.like('%{}%'.format(industry2)) if industry2 else text(''),
count_xcl = company.filter_by(f_type=11).count() # 新材料 # ProjectManagement.investor_name.like('%{}%'.format(investor_name)) if investor_name else text(''),
count_lsjc = company.filter_by(f_type=12).count() # 绿色建材 # ProjectManagement.project_progress == project_progress if project_progress else text(''),
count_yy = company.filter_by(f_type=13).count() # 医药 # ProjectManagement.project_year == project_year if project_year else text(''),
count_smfz = company.filter_by(f_type=14).count() # 丝麻纺织服装 # ProjectManagement.is_delete == 0
count_xdfwy = company.filter_by(f_type=15).count() # 现代服务业 # )
count_szjj = company.filter_by(f_type=16).count() # 数字经济
count_whly = company.filter_by(f_type=17).count() # 文化旅游
count_qt = count_all - count_gt - count_gjd - count_mcq - count_zbzz - \ project_obj = ProjectManagement.query.filter(
count_zz - count_mhg - count_xcl - count_lsjc - count_yy - \ # ProjectManagement.district == user_district if user_district != '晋城市' else text(''),
count_smfz - count_xdfwy - count_szjj - count_whly # ProjectManagement.sign_time.notin_(['Null', '']) if flag == 2 else text(''),
# ProjectManagement.project_name.like('%{}%'.format(project_name)) if project_name else text(''),
# ProjectManagement.project_stalker == project_stalker if project_stalker else text(''),
# ProjectManagement.project_stalker != '' if flag == 2 else text(''),
# ProjectManagement.district == district if district else text(''),
# ProjectManagement.development_area == development_area if development_area else text(''),
# ProjectManagement.investment_volume > investment_volume[0] if investment_volume else text(''),
# ProjectManagement.investment_volume <= investment_volume[1] if investment_volume else text(''),
# ProjectManagement.investor_district.like('%{}%'.format(investor_district)) if investor_district else text(''),
# ProjectManagement.industry.like('%{}%'.format(industry1)) if industry1 else text(''),
# ProjectManagement.industry2.like('%{}%'.format(industry2)) if industry2 else text(''),
# ProjectManagement.investor_name.like('%{}%'.format(investor_name)) if investor_name else text(''),
# ProjectManagement.project_progress == project_progress if project_progress else text(''),
# ProjectManagement.project_year == project_year if project_year else text(''),
ProjectManagement.is_delete == 0
)
# 产业结构分布 if not project_obj.all():
data = [ return jsonify(code=RET.NODATA, msg='没有符合条件的数据!')
{"name": "钢铁", "value": count_gt}, # {百分比,value} project_size = project_obj.count()
{"name": "光机电", "value": count_gjd},
{"name": "煤层气", "value": count_mcq}, project_obj_list = project_obj.order_by(ProjectManagement.upload_time.desc()).paginate(page, per_page).items
{"name": "装备制造", "value": count_zbzz}, if project_obj_list:
{"name": "铸造", "value": count_zz}, data = [{
{"name": "煤化工", "value": count_mhg}, "id": project_obj.id,
{"name": "新材料", "value": count_xcl}, "project_stalker": project_obj.project_stalker,
{"name": "绿色建材", "value": count_lsjc}, "project_name": project_obj.project_name,
{"name": "医药", "value": count_yy}, "district": project_obj.district,
{"name": "丝麻纺织服装", "value": count_smfz}, "development_area": project_obj.development_area,
{"name": "现代服务业", "value": count_xdfwy}, "attract_name": project_obj.attract_name,
{"name": "数字经济", "value": count_szjj}, "investor_name": project_obj.investor_name,
{"name": "文化旅游", "value": count_whly} "investor_district": project_obj.investor_district,
] "industry": project_obj.industry,
"investment_volume": project_obj.investment_volume,
"construction_content": project_obj.construction_content,
"project_address": project_obj.project_address,
"project_progress": project_obj.project_progress,
"project_problem": project_obj.project_problem,
"project_year": project_obj.project_year
} for project_obj in project_obj_list]
return jsonify(code=RET.OK, data={"data": data, "size": project_size, "msg": "数据获取成功!"})
return jsonify(code=RET.OK, data=data, msg="查询成功!")
except Exception as e: except Exception as e:
current_app.logger.error(e) current_app.logger.error(e)
return jsonify(code=RET.DBERR, msg="查询出错!") return jsonify(code=RET.DBERR, msg="查询数据库错误!")
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment