Commit ed6fac8d by dong

fix

parent 5c792b14
from flask import current_app, jsonify
from sqlalchemy import text, or_, and_
from apps.utils.neo4j_conn import conn_neo4j
from apps.models import *
from apps.utils.response_code import RET
from apps.util import verify_token
"""
更新企业是否为链主字段
"""
# # -*- coding:utf-8 -*-
import threading
import pandas as pd
from apps.models import IndustryChain, Enterprise, Company
from manager import app
from apps import db
"""
根据资质计算企业的热度,并提交保存
"""
# 读取链主企业文件
xl_path = "晋城链主企业.xlsx"
data = pd.read_excel(xl_path)
com_li = []
for i in range(len(data)):
com_name = str(data.loc[i, "企业名称"])
com_li.append(com_name)
def handle():
with app.app_context():
company_obj_list = Company.query.all()
# 读取企业数据表的资质
i = 0
for company_obj in company_obj_list:
company_name = company_obj.company_name
if company_name in com_li:
company_obj.chain_master = '1'
db.session.commit()
i += 1
else:
company_obj.chain_master = '0'
db.session.commit()
print('已完成,一共{}个'.format(i))
if __name__ == '__main__':
t = threading.Thread(target=handle)
t.start()
# # -*- coding:utf-8 -*-
import threading
from apps.models import IndustryChain, Enterprise, Company
from manager import app
from apps import db
"""
根据资质计算企业的热度,并提交保存
"""
def handle():
with app.app_context():
company_obj_list = Company.query.all()
# company_obj_list = Enterprise.query.all()
# print(company_obj_list)
# 读取企业数据表的资质
i = 1
for company_obj in company_obj_list:
grade_li = []
if company_obj.isfive and company_obj.isfive == '1': # 五百强
grade_li.append(5)
else:
grade_li.append(0)
if company_obj.quoted_company and company_obj.quoted_company == '1': # 上市
grade_li.append(5)
else:
grade_li.append(0)
if company_obj.chain_master and company_obj.chain_master == '1': # 链主
grade_li.append(5)
else:
grade_li.append(0)
if company_obj.unicorn and company_obj.unicorn == '1': # 独角兽
grade_li.append(4)
else:
grade_li.append(0)
if company_obj.high_new and company_obj.high_new == '1': # 高新技术企业
grade_li.append(3)
else:
grade_li.append(0)
if company_obj.dengl and company_obj.dengl == '1': # 瞪羚
grade_li.append(3)
else:
grade_li.append(0)
if company_obj.scale and company_obj.scale == '1': # 规模以上企业
grade_li.append(3)
else:
grade_li.append(0)
if company_obj.tbe and company_obj.tbe == '1': # 科技型中小企业
grade_li.append(2)
else:
grade_li.append(0)
if company_obj.zjtg and company_obj.zjtg == '1': # 山西专精特新企业
grade_li.append(2)
else:
grade_li.append(0)
if company_obj.fianacing and company_obj.fianacing == '1': # 融资企业
grade_li.append(1)
else:
grade_li.append(0)
if company_obj.patent and company_obj.patent == '1': # 专利企业
grade_li.append(1)
else:
grade_li.append(0)
total_grede = sum(grade_li)
if not total_grede:
total_grede = 0
company_obj.hots = total_grede
db.session.commit()
print(str(i / 975 * 100) + '%')
i += 1
if __name__ == '__main__':
t = threading.Thread(target=handle)
t.start()
...@@ -74,7 +74,7 @@ def find_up_thr(name_query, relation): ...@@ -74,7 +74,7 @@ def find_up_thr(name_query, relation):
# 获取产业集群名称 # 获取产业集群名称
@api_atlas.route('/industry/cluster', methods=['GET']) @api_atlas.route('/industry/cluster', methods=['GET'])
@login_required # @login_required
def get_cluster(): def get_cluster():
try: try:
# cluster_obj = IndustryChain.query.filter_by(industry_type=0, status=1).all() # cluster_obj = IndustryChain.query.filter_by(industry_type=0, status=1).all()
...@@ -82,7 +82,7 @@ def get_cluster(): ...@@ -82,7 +82,7 @@ def get_cluster():
# "icon": i.icon_url, "icon1": i.icon_url1} # "icon": i.icon_url, "icon1": i.icon_url1}
# for i in cluster_obj] # for i in cluster_obj]
cluster_obj = Industry.query.all() cluster_obj = Industry.query.all()
data = [{"id": i.id, 'name': i.oname, 'industry_level': 1, data = [{"id": i.id, 'name': i.oname, 'oname': i.name, 'industry_level': 1,
"icon": '', "icon1": ''} "icon": '', "icon1": ''}
for i in cluster_obj] for i in cluster_obj]
......
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