Commit ada4307b by dong

fix202302014

parent cc7c428d
...@@ -122,12 +122,21 @@ class Enterprise(db.Model): ...@@ -122,12 +122,21 @@ class Enterprise(db.Model):
unicorn = db.Column(db.String(32), doc='独角兽企业', comment='独角兽企业') # 独角兽企业 unicorn = db.Column(db.String(32), doc='独角兽企业', comment='独角兽企业') # 独角兽企业
isfive = db.Column(db.String(32), doc='是否中国500强', comment='是否中国500强') # 是否中国500强 isfive = db.Column(db.String(32), doc='是否中国500强', comment='是否中国500强') # 是否中国500强
product_all = db.Column(db.String(255), doc='公司拥有产品', comment='公司拥有产品') # 公司拥有产品
takingn = db.Column(db.Float, doc='营收', comment='营收') # 营收 takingn = db.Column(db.Float, doc='营收', comment='营收') # 营收
hots = db.Column(db.Integer, doc='企业热度(权重值)', comment='企业热度(权重值)') # 企业热度(权重值) hots = db.Column(db.Integer, doc='企业热度(权重值)', comment='企业热度(权重值)') # 企业热度(权重值)
c_name = db.Column(db.String(255), doc='行业类名', comment='行业类名') # 行业类名 c_name = db.Column(db.String(255), doc='行业类名', comment='行业类名') # 行业类名
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
product_all = db.Column(db.String(255), doc='公司拥有产品', comment='公司拥有产品') # 公司拥有产品
c_name1 = db.Column(db.String(255), doc='行业类名', comment='行业类名') # 行业类名
c_type1 = db.Column(db.Integer, index=True, doc='行业类id', comment='行业类id') # 行业类id
product_all1 = db.Column(db.String(255), doc='公司拥有产品', comment='公司拥有产品') # 公司拥有产品
c_name2 = db.Column(db.String(255), doc='行业类名', comment='行业类名') # 行业类名
c_type2 = db.Column(db.Integer, index=True, doc='行业类id', comment='行业类id') # 行业类id
product_all2 = db.Column(db.String(255), doc='公司拥有产品', comment='公司拥有产品') # 公司拥有产品
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
......
...@@ -94,13 +94,14 @@ def industry_cluster(): ...@@ -94,13 +94,14 @@ def industry_cluster():
try: try:
industry_obj = IndustryChain.query.filter_by(industry_name=industry_name).first() industry_obj = IndustryChain.query.filter_by(industry_name=industry_name).first()
industry_id = industry_obj.id industry_id = industry_obj.id
chain_id = industry_obj.chain_id
# 查询redis # 查询redis
result = { result = {
"industryChain": industry_name, "industryChain": industry_name,
"nodeList": [find_up_thr1(1, industry_id, flag), "nodeList": [find_up_thr1(chain_id, 1, industry_id, flag),
find_up_thr1(2, industry_id, flag), find_up_thr1(chain_id, 2, industry_id, flag),
find_up_thr1(3, industry_id, flag)] find_up_thr1(chain_id, 3, industry_id, flag)]
} }
except Exception as e: except Exception as e:
current_app.logger.error(e) current_app.logger.error(e)
...@@ -137,7 +138,7 @@ def industry_cluster(): ...@@ -137,7 +138,7 @@ def industry_cluster():
# Enterprise.c_type == industry_id, # Enterprise.c_type == industry_id,
# ).count() # ).count()
# return company_count # return company_count
def get_count(industry_id, chain_name, flag): def get_count(chain_id, industry_id, chain_name, flag):
company_count = '' company_count = ''
if flag == 1: # 晋城 if flag == 1: # 晋城
# if industry_id in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]: # if industry_id in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]:
...@@ -156,7 +157,7 @@ def get_count(industry_id, chain_name, flag): ...@@ -156,7 +157,7 @@ def get_count(industry_id, chain_name, flag):
# else: # else:
chain_obj = IndustryChain.query.filter( chain_obj = IndustryChain.query.filter(
IndustryChain.industry_name == chain_name, IndustryChain.industry_name == chain_name,
IndustryChain.chain_id == industry_id, IndustryChain.chain_id == chain_id,
).first() ).first()
company_count = chain_obj.enterprise_num company_count = chain_obj.enterprise_num
return company_count return company_count
...@@ -240,7 +241,7 @@ def get_count(industry_id, chain_name, flag): ...@@ -240,7 +241,7 @@ def get_count(industry_id, chain_name, flag):
# node_one["subNodeList"].append(node_two) # node_one["subNodeList"].append(node_two)
# data["subNodeList"].append(node_one) # data["subNodeList"].append(node_one)
# return data # return data
def find_up_thr1(industry_type, industry_id, flag): def find_up_thr1(chain_id, industry_type, industry_id, flag):
# relation 1为上游,2为中游,3为下游 # relation 1为上游,2为中游,3为下游
relation = '' relation = ''
if industry_type == 1: if industry_type == 1:
...@@ -267,7 +268,7 @@ def find_up_thr1(industry_type, industry_id, flag): ...@@ -267,7 +268,7 @@ def find_up_thr1(industry_type, industry_id, flag):
chain_name1 = pname_one["chain_name"] chain_name1 = pname_one["chain_name"]
total_count = 0 total_count = 0
# 一级的企业数量 # 一级的企业数量
company_count = get_count(industry_id, chain_name1, flag) company_count = get_count(chain_id, industry_id, chain_name1, flag)
total_count += company_count total_count += company_count
# 一级 # 一级
node_one = { node_one = {
...@@ -284,7 +285,7 @@ def find_up_thr1(industry_type, industry_id, flag): ...@@ -284,7 +285,7 @@ def find_up_thr1(industry_type, industry_id, flag):
for pname_two in res_two: for pname_two in res_two:
chain_name2 = pname_two["chain_name"] chain_name2 = pname_two["chain_name"]
company_count = get_count(industry_id, chain_name2, flag) company_count = get_count(chain_id, industry_id, chain_name2, flag)
total_count += company_count total_count += company_count
# 二级 # 二级
...@@ -301,7 +302,7 @@ def find_up_thr1(industry_type, industry_id, flag): ...@@ -301,7 +302,7 @@ def find_up_thr1(industry_type, industry_id, flag):
} for chain_three_obj in chain_three_obj_list] } for chain_three_obj in chain_three_obj_list]
for pname_thr in res_three: for pname_thr in res_three:
chain_name3 = pname_thr["chain_name"] chain_name3 = pname_thr["chain_name"]
company_count = get_count(industry_id, chain_name3, flag) company_count = get_count(chain_id, industry_id, chain_name3, flag)
total_count += company_count total_count += company_count
# 三级 # 三级
......
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