Commit 2eb94017 by dong

fix20230112

parent f898d867
...@@ -439,7 +439,10 @@ def write_dynamic(user_name, project_id, item, time): ...@@ -439,7 +439,10 @@ def write_dynamic(user_name, project_id, item, time):
@api_manage.route("/SearchProject", methods=["POST"]) @api_manage.route("/SearchProject", methods=["POST"])
def search_project(): def search_project():
req_dic = request.get_json() req_dic = request.get_json()
# token = request.headers['token'] token = request.headers['token']
flag = req_dic['flag'] # 1为线索库,2为对接库,3为签约库,4为开工库 flag = req_dic['flag'] # 1为线索库,2为对接库,3为签约库,4为开工库
# 线索库 # 线索库
distribute_condition = req_dic['distribute_condition'] # 分发情况 distribute_condition = req_dic['distribute_condition'] # 分发情况
......
...@@ -113,6 +113,11 @@ class Enterprise(db.Model): ...@@ -113,6 +113,11 @@ class Enterprise(db.Model):
c_type = db.Column(db.Integer, index=True, doc='行业类id', comment='行业类id') # 行业类id c_type = db.Column(db.Integer, index=True, doc='行业类id', comment='行业类id') # 行业类id
f_name = db.Column(db.String(255), doc='父行业类名', comment='父行业类名') # 父行业类名 f_name = db.Column(db.String(255), doc='父行业类名', comment='父行业类名') # 父行业类名
f_type = db.Column(db.Integer, index=True, doc='父行业类id', comment='父行业类id') # 父行业类id f_type = db.Column(db.Integer, index=True, doc='父行业类id', comment='父行业类id') # 父行业类id
sxonhun = db.Column(db.String(32)) # 是否山西100强
scale = db.Column(db.String(32)) # 规模以上企业
serve = db.Column(db.String(32)) # 限额以上服务业
__table_args__ = ({'comment': '全国企业表'}) # 添加表注释 __table_args__ = ({'comment': '全国企业表'}) # 添加表注释
......
...@@ -6,4 +6,5 @@ api_address = Blueprint("api_address", __name__) ...@@ -6,4 +6,5 @@ api_address = Blueprint("api_address", __name__)
from . import view from . import view
from . import map_view from . import map_view
from . import fill_data from . import fill_data
from . import choose_view
from flask import g, current_app, request, jsonify, session from flask import g, current_app, request, jsonify, session
from sqlalchemy import or_ from sqlalchemy import or_, and_
from apps.view_map import api_map from apps.view_map import api_map
from apps.util import login_required, verify_token from apps.util import login_required, verify_token
...@@ -159,64 +159,65 @@ def attract_cnums(): ...@@ -159,64 +159,65 @@ def attract_cnums():
# 全国企业列表 # 全国企业列表
@api_map.route('/AttractEnterprise', methods=['POST']) # @api_map.route('/AttractEnterprise', methods=['POST'])
# @login_required # # @login_required
def enterprise(): # def enterprise():
''' # '''
太原市企业列表 # 太原市企业列表
:return: # :return:
''' # '''
req_dict = request.get_json() # req_dict = request.get_json()
inid = req_dict.get("inid") # 行业id # inid = req_dict.get("inid") # 行业id
page = req_dict.get("page") # 分页页码 # page = req_dict.get("page") # 分页页码
perpage = req_dict.get("perpage") # 分页大小 # perpage = req_dict.get("perpage") # 分页大小
province = req_dict.get("province") # province = req_dict.get("province")
city = req_dict.get("city") # city = req_dict.get("city")
district = req_dict.get("district") # district = req_dict.get("district")
product = req_dict.get("product") # 产业产品选择 # product = req_dict.get("product") # 产业产品选择
#
if not all([page, perpage]): #
return jsonify(code=RET.PARAMERR, msg="参数不完整") # if not all([page, perpage]):
# return jsonify(code=RET.PARAMERR, msg="参数不完整")
try: #
if inid: # 子行业分类 # try:
enterprise = Enterprise.query.filter_by(c_type=inid) # if inid: # 子行业分类
else: # enterprise = Enterprise.query.filter_by(c_type=inid)
enterprise = Enterprise.query.filter_by() # else:
# 区域选择 # enterprise = Enterprise.query.filter_by()
if province: # # 区域选择
enterprise = enterprise.filter_by(province=province) # if province:
if city: # enterprise = enterprise.filter_by(province=province)
enterprise = enterprise.filter_by(city=city) # if city:
if district: # enterprise = enterprise.filter_by(city=city)
enterprise = enterprise.filter_by(district=district) # if district:
if product: # enterprise = enterprise.filter_by(district=district)
enterprise = enterprise.filter(Enterprise.product_all.like("%{}%".format(product))) # if product:
size = enterprise.count() # enterprise = enterprise.filter(Enterprise.product_all.like("%{}%".format(product)))
enterprise = enterprise.order_by(Enterprise.hots.desc()).paginate(page, perpage).items # 企业热度倒序 # size = enterprise.count()
# enterprise = enterprise.order_by(Enterprise.hots.desc()).paginate(page, perpage).items # 企业热度倒序
df = [{"id": i.id, #
"company_name": i.company_name, # df = [{"id": i.id,
"hots": i.hots, # "company_name": i.company_name,
"aptitude": ['高新技术企业' if i.high_new == '1' else # "hots": i.hots,
'科技型中小企业' if i.tbe == '1' else # "aptitude": ['高新技术企业' if i.high_new == '1' else
'上市企业' if i.quoted_company == '1' else # '科技型中小企业' if i.tbe == '1' else
'山西民营100强' if i.sxmon == '1' else # '上市企业' if i.quoted_company == '1' else
'山西专精特新企业' if i.zjtg == '1' else # '山西民营100强' if i.sxmon == '1' else
'独角兽企业' if i.unicorn == '1' else # '山西专精特新企业' if i.zjtg == '1' else
'瞪羚' if i.dengl == '1' else # '独角兽企业' if i.unicorn == '1' else
'中国500强' if i.isfive == '1' else # '瞪羚' if i.dengl == '1' else
'规模以上企业' if i.scale == '1' else # '中国500强' if i.isfive == '1' else
'限额以上服务业' if i.serve == '1' else ''] # '规模以上企业' if i.scale == '1' else
} for i in enterprise] # '限额以上服务业' if i.serve == '1' else '']
data = {"size": size, "df": df} # } for i in enterprise]
except Exception as e: # data = {"size": size, "df": df}
current_app.logger.error(e) # except Exception as e:
return jsonify(code=RET.DBERR, msg="数据库查询错误") # current_app.logger.error(e)
# return jsonify(code=RET.DBERR, msg="数据库查询错误")
return jsonify(code=RET.OK, msg="获取成功", data=data) #
# return jsonify(code=RET.OK, msg="获取成功", data=data)
""""""
# 招商地图下的散点图(至区后) # 招商地图下的散点图(至区后)
@api_map.route('/AttractSdmap', methods=['POST']) @api_map.route('/AttractSdmap', methods=['POST'])
# @login_required # @login_required
...@@ -316,3 +317,70 @@ def search_enterprise(): ...@@ -316,3 +317,70 @@ def search_enterprise():
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='查询出错!')
# 全国企业列表
@api_map.route('/AttractEnterprise', methods=['POST'])
def attract_enterprise():
'''
太原市企业列表
:return:
'''
req_dict = request.get_json()
inid = req_dict.get("inid") # 行业id
company_name = req_dict.get("company_name") # 产业产品名称筛选
entype = req_dict.get("entype") # 企业类型id
qualificat = req_dict.get("qualificat") # 企业资质id
quoted = req_dict.get("quoted") # 上市板块(A股,1)(创业股,2)(港股,3)(新三股,4)(新四股,5)(中小板,6)
area = req_dict.get("area") # ["省","市","区"]
province = area[0]
city = area[1]
district = area[2]
page = req_dict.get("page") # 分页页码
perpage = req_dict.get("perpage") # 分页大小
if not all([page, perpage]):
return jsonify(code=RET.PARAMERR, msg="参数不完整")
try:
enterprise_obj = Enterprise.query.filter(and_(
Enterprise.entype.like('%{}%'.format(entype)) if entype else text(''),
Enterprise.company_name.like('%{}%'.format(company_name)) if company_name else text(''),
Enterprise.c_type == inid if inid else text(''),
Enterprise.public_id == quoted if quoted else text(''),
Enterprise.province == province if province else text(''),
Enterprise.city == city if city else text(''),
Enterprise.district == district if district else text(''),
Enterprise.high_new == '1' if qualificat == '高新技术企业' else text(''),
Enterprise.tbe == '1' if qualificat == '科技型中小企业' else text(''),
Enterprise.quoted_company == '1' if qualificat == '上市企业' else text(''),
Enterprise.sxonhun == '1' if qualificat == '山西100强企业' else text(''),
Enterprise.zjtg == '1' if qualificat == '山西专精特新企业' else text(''),
Enterprise.unicorn == '1' if qualificat == '独角兽企业' else text(''),
Enterprise.dengl == '1' if qualificat == '瞪羚企业' else text(''),
Enterprise.isfive == '1' if qualificat == '中国500强企业' else text(''),
Enterprise.scale == '1' if qualificat == '规模以上企业' else text(''),
Enterprise.serve == '1' if qualificat == '限额以上服务业企业' else text(''),
))
size = enterprise_obj.count()
enterprise_obj_list = enterprise_obj.paginate(page, perpage).items
df = [{"id": i.id,
"company_name": i.company_name,
"aptitude": list(filter(None, ["高新技术企业" if i.high_new == '1' else '',
"科技型中小企业" if i.tbe == '1' else '',
"上市企业" if i.quoted_company == '1' else '',
"山西民营100强" if i.sxonhun == '1' else '',
"山西专精特新企业" if i.zjtg == '1' else '',
"独角兽企业" if i.unicorn == '1' else '',
"瞪羚" if i.dengl == '1' else '',
"中国500强" if i.isfive == '1' else '',
"规模以上企业" if i.scale == '1' else '',
"限额以上服务业" if i.serve == '1' else '']))
} for i in enterprise_obj_list]
data = {"size": size, "df": df}
except Exception as e:
current_app.logger.error(e)
return jsonify(code=RET.DBERR, msg="数据库查询错误")
return jsonify(code=RET.OK, msg="获取成功", data=data)
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