Commit 622d22ee by dong

fix202302013

parent 1abb4a3c
......@@ -1147,7 +1147,7 @@ def edit_project_detail():
project_obj.investment_volume1 = req_dic['investment_volume1']
project_obj.project_info1 = req_dic['project_info1']
project_obj.stop_reason = req_dic['stop_reason']
project_obj.thread_source = req_dic['thread_source']
project_obj. thread_source = req_dic['thread_source']
project_obj.cooperation_way = req_dic['cooperation_way']
project_obj.other_source = req_dic['other_source']
project_obj.remark = req_dic['remark']
......
......@@ -1743,6 +1743,3 @@ class OperationLog(db.Model):
action = db.Column(db.String(20), comment='记录"导入"的动作用于备注(每月十五号前是否进行提报导入)的是和否')
read_type = db.Column(db.Integer, comment='消息类型(用于消息提醒) 0未读,1已读,3已读状态一天后转为历史消息')
time = db.Column(db.DateTime, default='', comment='转为已读状态的时间(用于消息提醒)')
......@@ -115,3 +115,29 @@ def login_required(view_func):
return view_func(*args, **kwargs)
return verify_token
......@@ -26,16 +26,11 @@ def get_all_enterprise():
return jsonify(code=RET.PARAMERR, msg="参数不完整")
try:
# enterprise_all_counts = len(Enterprise.query.all())
enterprise_all_counts = Enterprise.query.count()
# print(enterprise_all_counts)
enterprise_list = Enterprise.query.paginate(page, perpage).items
# counts = len(enterprise_list)
# print(enterprise_list)
if enterprise_list:
data = {"data": [{"id": enterprise.id,
"company": enterprise.company_name, # 企业名
# "area": enterprise.city + enterprise.district,
"area": '',
"createtime": (enterprise.build_date).strftime("%Y-%m-%d") if enterprise.build_date else '',
......
......@@ -108,14 +108,18 @@ def industry_cluster():
return jsonify(code=RET.OK, msg="获取成功", data=result)
def get_count(chain_name, flag):
def get_count(industry_id, chain_name, flag):
company_count = ''
if flag == 1: # 晋城
company_count = Company.query.filter(
Company.product_all.like('%{}%'.format(chain_name))).count()
Company.product_all.like('%{}%'.format(chain_name)),
Company.c_type == industry_id,
).count()
if flag == 2: # 全国
company_count = Enterprise.query.filter(
Enterprise.product_all.like('%{}%'.format(chain_name))).count()
Enterprise.product_all.like('%{}%'.format(chain_name)),
Enterprise.c_type == industry_id,
).count()
# print(chain_name + '===' + str(company_count))
return company_count
......@@ -225,7 +229,7 @@ def find_up_thr1(industry_type, industry_id, flag):
chain_name1 = pname_one["chain_name"]
total_count = 0
# 一级的企业数量
company_count = get_count(chain_name1, flag)
company_count = get_count(industry_id, chain_name1, flag)
total_count += company_count
# 一级
node_one = {
......
......@@ -398,7 +398,6 @@ def get_chain():
industry_name = indu_obj.industry_name
enterprise_list = Enterprise.query.filter(Enterprise.product_all.like("%{}%".format(industry_name))).all()
for enterprise_obj in enterprise_list:
#
indu_obj.enterprise.append(enterprise_obj)
continue
......
import threading
from flask import app
from apps.models import IndustryChain, Enterprise
from manager import app
from apps import db
def handle():
with app.app_context():
industry_obj_list = IndustryChain.query.all()
print(industry_obj_list)
# 读取industry_chain数据表的产业名称
num = 0
for industry_obj in industry_obj_list:
# 清空原有关联企业
industry_obj.enterprise = []
db.session.commit()
industry_name = industry_obj.industry_name
industry_id = industry_obj.id
# 读取全国企业表,模糊匹配product_all字段
if industry_name in ["钢铁", "光机电", "煤层气", "装备制造", "铸造",
"煤化工", "新材料", "绿色建材", "医药", "丝麻纺织服装",
"现代服务业", "数字经济", "文化旅游"]:
print("正在查询【{}】的相关企业......".format(industry_name))
enterprise_list = Enterprise.query.filter(Enterprise.c_type == industry_id).all()
else:
print("正在查询【{}】的相关企业......".format(industry_name))
enterprise_list = Enterprise.query.filter(Enterprise.product_all.like("%{}%".format(industry_name)),
Enterprise.c_type == industry_id).all()
if not enterprise_list:
continue
# enterprise_num = 0
for enterprise_obj in enterprise_list:
industry_obj.enterprise.append(enterprise_obj)
# enterprise_num += 1
# enterprise_rate = str(enterprise_num / len(enterprise_list) * 100) + '%'
# print("需要添加【{}】的企业外键一共{}个,已完成{}".format(industry_name, len(enterprise_list), enterprise_rate))
db.session.commit()
continue
# db.session.commit()
num += 1
# print("产业链【{}】已完成,全部产业链已完成".format(industry_name) + str(num / 775 * 100) + '%')
print("产业链【{}】已完成".format(industry_name))
if __name__ == '__main__':
t = threading.Thread(target=handle)
t.start()
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