Commit f6c7ca8d by dong

fix20221210

parent 10073925
from sqlalchemy import func, desc, or_, text from sqlalchemy import func, desc, or_, text, and_
from flask import current_app, request, jsonify from flask import current_app, request, jsonify
from apps.models import Induzone, Industry, CompanyIndustryPoint, User from apps.models import Induzone, Industry, CompanyIndustryPoint, User
from apps.utils.response_code import RET from apps.utils.response_code import RET
...@@ -60,6 +60,7 @@ def default_address(): ...@@ -60,6 +60,7 @@ def default_address():
@api_address.route("/ChooseAddress", methods=["POST"]) @api_address.route("/ChooseAddress", methods=["POST"])
def advice(): def advice():
req_dict = request.get_json() req_dict = request.get_json()
key_words = req_dict.get("key_words") # 关键字
industry_id = req_dict.get("industry_id") # 所属行业选择 nid(必填) industry_id = req_dict.get("industry_id") # 所属行业选择 nid(必填)
product = req_dict.get("product") # 主营产品 "药" (必填) product = req_dict.get("product") # 主营产品 "药" (必填)
budget = req_dict.get('budget') # 落地投资预算 "22" # 大于 (必填) budget = req_dict.get('budget') # 落地投资预算 "22" # 大于 (必填)
...@@ -70,26 +71,34 @@ def advice(): ...@@ -70,26 +71,34 @@ def advice():
page = req_dict.get("page") page = req_dict.get("page")
perpage = req_dict.get("perpage") perpage = req_dict.get("perpage")
# print(address) if not any([product, budget, preference, revenue, tax, address]):
if not any([industry_id, product, budget, preference, revenue, tax, address]):
return jsonify(code=RET.DATAERR, msg="数据不全") return jsonify(code=RET.DATAERR, msg="数据不全")
try: try:
# indu = Industry.query.filter_by(nid=industry_id).first()
# if not indu:
# return jsonify(code=RET.DATAERR, msg="参数错误")
# # 获取产业名称
# industry_name = indu.oname
# 根据产业名称查询园区
# zone = Induzone.query.filter(or_(Induzone.navigat.like("%{}%".format(industry_name)),
# Induzone.navigator.like("%{}%".format(industry_name))))
zone = Induzone.query.filter( zone = Induzone.query.filter(
and_(
Induzone.district == address if address and address != '晋城市' else text(''), Induzone.district == address if address and address != '晋城市' else text(''),
Induzone.navigat.like('%{}%'.format(product)) if product else text(''), Induzone.navigat.like('%{}%'.format(product)) if product else text(''),
Induzone.invest_power < float(budget) if budget else text(''), Induzone.invest_power < float(budget) if budget else text(''),
Induzone.cate == "产业园区", Induzone.cate == "产业园区",
Induzone.tax < tax if tax else text('') Induzone.tax < tax if tax else text('')
) )).filter(
print(zone.all()) or_(
Induzone.name.like("%" + key_words + "%") if key_words else text(''),
Induzone.level.like("%" + key_words + "%") if key_words else text(''),
Induzone.industry_type.like("%" + key_words + "%") if key_words else text(''),
Induzone.charge.like("%" + key_words + "%") if key_words else text(''),
Induzone.address.like("%" + key_words + "%") if key_words else text('')
))
if industry_id:
indu = Industry.query.filter_by(nid=industry_id).first()
if not indu:
return jsonify(code=RET.DATAERR, msg="参数错误")
# 获取产业名称
industry_name = indu.oname
# 根据产业名称查询园区
zone = Induzone.query.filter(or_(Induzone.navigat.like("%{}%".format(industry_name)),
Induzone.navigator.like("%{}%".format(industry_name))))
if preference[0] == "true": # 如果有政府扶持力度 --- 政策数的打分 if preference[0] == "true": # 如果有政府扶持力度 --- 政策数的打分
zone = zone.order_by(Induzone.policy_point.desc()) zone = zone.order_by(Induzone.policy_point.desc())
if preference[1] == "true": # 产业聚集度 --- 产业的打分 if preference[1] == "true": # 产业聚集度 --- 产业的打分
......
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