Commit aad27809 by dong

fix20221209

parent f2220281
...@@ -1659,4 +1659,12 @@ class OperationLog(db.Model): ...@@ -1659,4 +1659,12 @@ class OperationLog(db.Model):
time = db.Column(db.DateTime, default='', comment='转为已读状态的时间(用于消息提醒)') time = db.Column(db.DateTime, default='', comment='转为已读状态的时间(用于消息提醒)')
# 新版产业链数据
class IndustryChain(db.Model):
__tablename_ = "industry_chain"
__table_args__ = ({'comment': '新版产业链数据数据表'}) # 添加表注释
id = db.Column(db.Integer, primary_key=True, autoincrement=True, comment='主键id')
industry_name = db.Column(db.String(20), comment='行业名称')
industry_type = db.Column(db.Integer, comment='行业类型(0是产业集群,1是上游行业,2是中游行业,3是下游行业)')
relate_id = db.Column(db.Integer, comment='关系id(关联与哪个产业环节')
...@@ -95,6 +95,103 @@ def get_cluster(): ...@@ -95,6 +95,103 @@ def get_cluster():
current_app.logger.error(e) current_app.logger.error(e)
# 获取新表的产业集群名称
@api_atlas.route('/IndustryCluster', methods=['POST'])
def industry_cluster():
req_dic = request.get_json()
industry_name = req_dic['industry_name']
industry_obj = IndustryChain.query.filter_by(industry_name=industry_name).first()
industry_id = industry_obj.id
result = {
"industryChain": industry_name,
"nodeList": [find_up_thr1(1, industry_id),
find_up_thr1(2, industry_id),
find_up_thr1(3, industry_id)]
}
print(result)
return result
def get_count(chain_name):
company_count = Company.query.filter(
Company.product_all.like('%{}%'.format(chain_name))).count()
print(chain_name + '===' + str(company_count))
return company_count
def find_up_thr1(industry_type, industry_id):
# relation 1为上游,2为中游,3为下游
relation = ''
if industry_type == 1:
relation = '上游'
if industry_type == 2:
relation = '中游'
if industry_type == 3:
relation = '下游'
# 零级,上中下三游
data = {
"node": "{}".format(relation),
"level": 1,
"subNodeList": [],
}
# 获取一级节点
chain_one_obj_list = IndustryChain.query.filter_by(industry_type=industry_type,
relate_id=industry_id).all()
res_one = [{"chain_name": chain_one_obj.industry_name,
"chain_name_id": chain_one_obj.id
} for chain_one_obj in chain_one_obj_list]
for it in res_one: # 一级节点
pname_one = it
chain_name = pname_one["chain_name"]
company_count = get_count(chain_name)
# 一级
node_one = {
"node": "{}({})".format(chain_name, company_count),
"level": 2,
"subNodeList": []
}
# 获取二级节点
chain_two_obj_list = IndustryChain.query.filter_by(relate_id=pname_one["chain_name_id"]).all()
res_two = [{"chain_name": chain_two_obj.industry_name,
"chain_name_id": chain_two_obj.id
} for chain_two_obj in chain_two_obj_list]
for item in res_two:
pname_two = item
chain_name = pname_two["chain_name"]
company_count = get_count(chain_name)
# 二级
node_two = {
"node": "{}({})".format(chain_name, company_count),
"level": 3,
"subNodeList": []
}
# 获取第三级节点
chain_three_obj_list = IndustryChain.query.filter_by(relate_id=pname_two["chain_name_id"]).all()
res_three = [{"chain_name": chain_three_obj.industry_name,
"chain_name_id": chain_three_obj.id
} for chain_three_obj in chain_three_obj_list]
for itm in res_three:
pname_thr = itm
chain_name = pname_thr["chain_name"]
company_count = get_count(chain_name)
# 三级
node_thr = {
"node": "{}({})".format(chain_name, company_count),
"level": 4,
"subNodeList": []
}
node_two["subNodeList"].append(node_thr)
node_one["subNodeList"].append(node_two)
data["subNodeList"].append(node_one)
return data
# 返回上中下游产业链数据接口 # 返回上中下游产业链数据接口
@api_atlas.route('/industry/chain', methods=['POST']) @api_atlas.route('/industry/chain', methods=['POST'])
# @login_required # @login_required
......
...@@ -15,6 +15,9 @@ from apps import db, constants, redis_store ...@@ -15,6 +15,9 @@ from apps import db, constants, redis_store
# 获取左上角经济指标数据 # 获取左上角经济指标数据
from util import verify_token
def get_jjzb(district, year): def get_jjzb(district, year):
'''经济指标数据''' '''经济指标数据'''
year1 = datetime.now().year - 1 year1 = datetime.now().year - 1
...@@ -521,6 +524,18 @@ def company_detail(): ...@@ -521,6 +524,18 @@ def company_detail():
req_dict = request.get_json() req_dict = request.get_json()
id = req_dict.get("id") # 企业id id = req_dict.get("id") # 企业id
token = request.headers['token']
try:
user_obj = verify_token(token)
user_id = user_obj.id
collect_obj_list = UserCompany.query.filter_by(user_id=user_id).all()
company_id_list = [collect_obj.id for collect_obj in collect_obj_list]
collect_obj_list1 = UserEnterprise.query.filter_by(user_id=user_id).all()
enterprise_id_list = [collect_obj.id for collect_obj in collect_obj_list1]
except:
return jsonify(code=RET.SESSIONERR, msg="请重新登录!")
# 校验参数完整性 # 校验参数完整性
if not all([id]): if not all([id]):
...@@ -528,6 +543,11 @@ def company_detail(): ...@@ -528,6 +543,11 @@ def company_detail():
try: try:
company = Company.query.get(id) company = Company.query.get(id)
user = User.query.get(user_id) # 获取关注列表
if user:
company_ids = [coms.id for coms in user.company]
else:
company_ids = []
# 工商状况-查询行政许可数据 # 工商状况-查询行政许可数据
data_info1 = CompanyAdminPermission.query.filter_by(company_id=id).all() data_info1 = CompanyAdminPermission.query.filter_by(company_id=id).all()
# 工商状况-查询税务信用数据 # 工商状况-查询税务信用数据
...@@ -561,6 +581,8 @@ def company_detail(): ...@@ -561,6 +581,8 @@ def company_detail():
"web_site": company.web_site if company.web_site else "", # 网址 "web_site": company.web_site if company.web_site else "", # 网址
"email": company.email if company.email else "", # 邮箱 "email": company.email if company.email else "", # 邮箱
"address": company.address if company.address else "", # 地址 "address": company.address if company.address else "", # 地址
"collect": "1" if company.id in company_ids else "2", # 关注状态码1关注,2未关注
"choice": "1", # 1太原企业,2全国企业
"location": province + city + district, "location": province + city + district,
"jwd": {"lng": company.lng if company.lng else "", # 经度 "jwd": {"lng": company.lng if company.lng else "", # 经度
......
...@@ -882,14 +882,34 @@ def get_collect(): ...@@ -882,14 +882,34 @@ def get_collect():
"id": i.id, "id": i.id,
"company_name": i.company_name, "company_name": i.company_name,
"create_time": create_time.create_time.strftime('%Y-%m-%d %H:%M:%S'), "create_time": create_time.create_time.strftime('%Y-%m-%d %H:%M:%S'),
"build_date": i.build_date.strftime("%Y-%m-%d") if i.build_date else "-" "build_date": i.build_date.strftime("%Y-%m-%d") if i.build_date else "-",
"high_new": '高新技术企业' if i.high_new == '1' else '',
"tbe": '科技型中小企业' if i.tbe == '1' else '',
"quoted_company": '上市企业' if i.quoted_company == '1' else '',
"sxmon": '山西民营100强' if i.sxmon == '1' else '',
"zjtg": '山西专精特新企业' if i.zjtg == '1' else '',
"unicorn": '独角兽企业' if i.unicorn == '1' else '',
"dengl": '瞪羚' if i.dengl == '1' else '',
"isfive": '中国500强' if i.isfive == '1' else '',
"scale": '规模以上企业' if i.scale == '1' else '',
"serve": '限额以上服务业' if i.serve == '1' else ''
}) })
else: else:
company.append({ company.append({
"id": i.id, "id": i.id,
"company_name": i.company_name, "company_name": i.company_name,
"create_time": create_time.create_time.strftime('%Y-%m-%d %H:%M:%S'), "create_time": create_time.create_time.strftime('%Y-%m-%d %H:%M:%S'),
"build_date": i.build_date.strftime("%Y-%m-%d") if i.build_date else "-" "build_date": i.build_date.strftime("%Y-%m-%d") if i.build_date else "-",
"high_new": '高新技术企业' if i.high_new == '1' else '',
"tbe": '科技型中小企业' if i.tbe == '1' else '',
"quoted_company": '上市企业' if i.quoted_company == '1' else '',
"sxmon": '山西民营100强' if i.sxmon == '1' else '',
"zjtg": '山西专精特新企业' if i.zjtg == '1' else '',
"unicorn": '独角兽企业' if i.unicorn == '1' else '',
"dengl": '瞪羚' if i.dengl == '1' else '',
"isfive": '中国500强' if i.isfive == '1' else '',
"scale": '规模以上企业' if i.scale == '1' else '',
"serve": '限额以上服务业' if i.serve == '1' else ''
}) })
except Exception as e: except Exception as e:
current_app.logger.error(e) current_app.logger.error(e)
......
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