Commit fd45fd1b by dong

fix20230317

parent d0593b51
...@@ -155,27 +155,28 @@ def industry_cluster(): ...@@ -155,27 +155,28 @@ def industry_cluster():
# return company_count # return company_count
def get_count(chain_id, industry_id, chain_name, flag): def get_count(chain_id, industry_id, chain_name, flag):
company_count = '' company_count = ''
id_list = []
if flag == 1: # 晋城 if flag == 1: # 晋城
# if industry_id in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]:
# company_count = Company.query.filter( # company_count = Company.query.filter(
# Company.c_type == industry_id # Company.product_all.like('%{}%'.format(chain_name)),
# Company.c_type == chain_id,
# ).count() # ).count()
# else: company_obj_li = Company.query.filter(
company_count = Company.query.filter(
Company.product_all.like('%{}%'.format(chain_name)), Company.product_all.like('%{}%'.format(chain_name)),
Company.c_type == chain_id, Company.c_type == chain_id,
).count() ).all()
# 企业id列表,用于一级产业的企业数量去重
id_list = [company_obj.id for company_obj in company_obj_li]
company_count = len(company_obj_li)
if flag == 2: # 全国 if flag == 2: # 全国
# if industry_id in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]:
# chain_obj = IndustryChain.query.get(industry_id)
# company_count = chain_obj.enterprise_num
# else:
chain_obj = IndustryChain.query.filter( chain_obj = IndustryChain.query.filter(
IndustryChain.industry_name == chain_name, IndustryChain.industry_name == chain_name,
IndustryChain.chain_id == chain_id, IndustryChain.chain_id == chain_id,
).first() ).first()
company_count = chain_obj.enterprise_num company_count = chain_obj.enterprise_num
return company_count return id_list, company_count
# def find_up_thr1(industry_type, industry_id): # def find_up_thr1(industry_type, industry_id):
...@@ -280,16 +281,20 @@ def find_up_thr1(chain_id, industry_type, industry_id, flag): ...@@ -280,16 +281,20 @@ def find_up_thr1(chain_id, industry_type, industry_id, flag):
"chain_name_id": chain_one_obj.id "chain_name_id": chain_one_obj.id
} for chain_one_obj in chain_one_obj_list] } for chain_one_obj in chain_one_obj_list]
for pname_one in res_one: # 一级节点 for pname_one in res_one: # 一级节点
one_id_li = []
chain_name1 = pname_one["chain_name"] chain_name1 = pname_one["chain_name"]
total_count = 0 total_count = 0
# 一级的企业数量 # 一级的企业数量
company_count = get_count(chain_id, industry_id, chain_name1, flag) id_list, company_count = get_count(chain_id, industry_id, chain_name1, flag)
one_id_li.extend(id_list)
total_count += company_count total_count += company_count
# 一级 # 一级
node_one = { node_one = {
"node": "{}".format(chain_name1), "node": "{}".format(chain_name1),
"level": 2, "level": 2,
"company_count": total_count, "company_count": len(set(one_id_li)),
"enterprise_count": total_count,
"subNodeList": [] "subNodeList": []
} }
# 获取二级节点 # 获取二级节点
...@@ -299,9 +304,11 @@ def find_up_thr1(chain_id, industry_type, industry_id, flag): ...@@ -299,9 +304,11 @@ def find_up_thr1(chain_id, industry_type, industry_id, flag):
} for chain_two_obj in chain_two_obj_list] } for chain_two_obj in chain_two_obj_list]
for pname_two in res_two: for pname_two in res_two:
two_id_li = []
chain_name2 = pname_two["chain_name"] chain_name2 = pname_two["chain_name"]
# company_count = get_count(chain_id, industry_id, chain_name2, flag) id_list, company_count = get_count(chain_id, industry_id, chain_name2, flag)
company_count = get_count(chain_id, industry_id, chain_name2, flag) two_id_li.extend(id_list)
one_id_li.extend(two_id_li)
total_count += company_count total_count += company_count
...@@ -309,7 +316,8 @@ def find_up_thr1(chain_id, industry_type, industry_id, flag): ...@@ -309,7 +316,8 @@ def find_up_thr1(chain_id, industry_type, industry_id, flag):
node_two = { node_two = {
"node": "{}".format(chain_name2), "node": "{}".format(chain_name2),
"level": 3, "level": 3,
"company_count": company_count, "company_count": len(set(two_id_li)),
"enterprise_count": company_count,
"subNodeList": [] "subNodeList": []
} }
# 获取第三级节点 # 获取第三级节点
...@@ -318,20 +326,26 @@ def find_up_thr1(chain_id, industry_type, industry_id, flag): ...@@ -318,20 +326,26 @@ def find_up_thr1(chain_id, industry_type, industry_id, flag):
"chain_name_id": chain_three_obj.id "chain_name_id": chain_three_obj.id
} 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:
three_id_li = []
chain_name3 = pname_thr["chain_name"] chain_name3 = pname_thr["chain_name"]
company_count = get_count(chain_id, industry_id, chain_name3, flag) id_list, company_count, = get_count(chain_id, industry_id, chain_name3, flag)
three_id_li.extend(id_list)
two_id_li.extend(three_id_li)
one_id_li.extend(two_id_li)
total_count += company_count total_count += company_count
# 三级 # 三级
node_thr = { node_thr = {
"node": "{}".format(chain_name3), "node": "{}".format(chain_name3),
"level": 4, "level": 4,
"company_count": company_count, "company_count": len(set(three_id_li)),
"enterprise_count": company_count,
"subNodeList": [] "subNodeList": []
} }
node_two["subNodeList"].append(node_thr) node_two["subNodeList"].append(node_thr)
node_one["subNodeList"].append(node_two) node_one["subNodeList"].append(node_two)
node_one.update({"company_count": total_count}) # node_one.update({"company_count": total_count})
node_one.update({"company_count": len(set(one_id_li)), "enterprise_count": total_count})
data["subNodeList"].append(node_one) data["subNodeList"].append(node_one)
return data return data
......
...@@ -851,6 +851,7 @@ def get_enterprise_licence(): ...@@ -851,6 +851,7 @@ def get_enterprise_licence():
req_dict = request.get_json() req_dict = request.get_json()
id = req_dict.get("id") # 企业id id = req_dict.get("id") # 企业id
type = req_dict.get("type")
# 校验参数完整性 # 校验参数完整性
if not all([id]): if not all([id]):
return jsonify(code=RET.PARAMERR, msg="参数不完整") return jsonify(code=RET.PARAMERR, msg="参数不完整")
...@@ -861,7 +862,10 @@ def get_enterprise_licence(): ...@@ -861,7 +862,10 @@ def get_enterprise_licence():
return jsonify(code=RET.OK, msg="获取成功", data=data) return jsonify(code=RET.OK, msg="获取成功", data=data)
try: try:
if type == 'enterprise':
enterprise = Enterprise.query.get(id) enterprise = Enterprise.query.get(id)
else:
enterprise = Company.query.get(id)
company_id = enterprise.company_id company_id = enterprise.company_id
if not company_id: if not company_id:
return jsonify(RET.NODATA, msg='无关联信息') return jsonify(RET.NODATA, msg='无关联信息')
...@@ -896,7 +900,7 @@ def get_enterprise_taxInfo(): ...@@ -896,7 +900,7 @@ def get_enterprise_taxInfo():
''' '''
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'] type = req_dict.get("type")
# 校验参数完整性 # 校验参数完整性
if not all([id]): if not all([id]):
return jsonify(code=RET.PARAMERR, msg="参数不完整") return jsonify(code=RET.PARAMERR, msg="参数不完整")
...@@ -905,7 +909,10 @@ def get_enterprise_taxInfo(): ...@@ -905,7 +909,10 @@ def get_enterprise_taxInfo():
data = json.loads(redis_store.get(name_query)) data = json.loads(redis_store.get(name_query))
return jsonify(code=RET.OK, msg="获取成功", data=data) return jsonify(code=RET.OK, msg="获取成功", data=data)
try: try:
if type == 'enterprise':
enterprise = Enterprise.query.get(id) enterprise = Enterprise.query.get(id)
else:
enterprise = Company.query.get(id)
company_id = enterprise.company_id company_id = enterprise.company_id
if not company_id: if not company_id:
return jsonify(RET.NODATA, msg='无关联信息') return jsonify(RET.NODATA, msg='无关联信息')
...@@ -940,7 +947,7 @@ def get_enterprise_inoutInfo(): ...@@ -940,7 +947,7 @@ def get_enterprise_inoutInfo():
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'] type = req_dict.get("type")
# 校验参数完整性 # 校验参数完整性
if not all([id]): if not all([id]):
return jsonify(code=RET.PARAMERR, msg="参数不完整") return jsonify(code=RET.PARAMERR, msg="参数不完整")
...@@ -949,7 +956,10 @@ def get_enterprise_inoutInfo(): ...@@ -949,7 +956,10 @@ def get_enterprise_inoutInfo():
data = json.loads(redis_store.get(name_query)) data = json.loads(redis_store.get(name_query))
return jsonify(code=RET.OK, msg="获取成功", data=data) return jsonify(code=RET.OK, msg="获取成功", data=data)
try: try:
if type == 'enterprise':
enterprise = Enterprise.query.get(id) enterprise = Enterprise.query.get(id)
else:
enterprise = Company.query.get(id)
company_id = enterprise.company_id company_id = enterprise.company_id
if not company_id: if not company_id:
return jsonify(RET.NODATA, msg='无关联信息') return jsonify(RET.NODATA, msg='无关联信息')
...@@ -981,7 +991,7 @@ def get_enterprise_supplier(): ...@@ -981,7 +991,7 @@ def get_enterprise_supplier():
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'] type = req_dict.get("type")
# 校验参数完整性 # 校验参数完整性
if not all([id]): if not all([id]):
return jsonify(code=RET.PARAMERR, msg="参数不完整") return jsonify(code=RET.PARAMERR, msg="参数不完整")
...@@ -990,7 +1000,10 @@ def get_enterprise_supplier(): ...@@ -990,7 +1000,10 @@ def get_enterprise_supplier():
data = json.loads(redis_store.get(name_query)) data = json.loads(redis_store.get(name_query))
return jsonify(code=RET.OK, msg="获取成功", data=data) return jsonify(code=RET.OK, msg="获取成功", data=data)
try: try:
if type == 'enterprise':
enterprise = Enterprise.query.get(id) enterprise = Enterprise.query.get(id)
else:
enterprise = Company.query.get(id)
company_id = enterprise.company_id company_id = enterprise.company_id
if not company_id: if not company_id:
return jsonify(RET.NODATA, msg='无关联信息') return jsonify(RET.NODATA, msg='无关联信息')
...@@ -1023,7 +1036,7 @@ def get_enterprise_client(): ...@@ -1023,7 +1036,7 @@ def get_enterprise_client():
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'] type = req_dict.get("type")
# 校验参数完整性 # 校验参数完整性
if not all([id]): if not all([id]):
return jsonify(code=RET.PARAMERR, msg="参数不完整") return jsonify(code=RET.PARAMERR, msg="参数不完整")
...@@ -1032,7 +1045,10 @@ def get_enterprise_client(): ...@@ -1032,7 +1045,10 @@ def get_enterprise_client():
data = json.loads(redis_store.get(name_query)) data = json.loads(redis_store.get(name_query))
return jsonify(code=RET.OK, msg="获取成功", data=data) return jsonify(code=RET.OK, msg="获取成功", data=data)
try: try:
if type == 'enterprise':
enterprise = Enterprise.query.get(id) enterprise = Enterprise.query.get(id)
else:
enterprise = Company.query.get(id)
company_id = enterprise.company_id company_id = enterprise.company_id
if not company_id: if not company_id:
return jsonify(RET.NODATA, msg='无关联信息') return jsonify(RET.NODATA, msg='无关联信息')
...@@ -1065,7 +1081,7 @@ def get_enterprise_equity(): ...@@ -1065,7 +1081,7 @@ def get_enterprise_equity():
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'] type = req_dict.get("type")
# 校验参数完整性 # 校验参数完整性
if not all([id]): if not all([id]):
return jsonify(code=RET.PARAMERR, msg="参数不完整") return jsonify(code=RET.PARAMERR, msg="参数不完整")
...@@ -1074,7 +1090,10 @@ def get_enterprise_equity(): ...@@ -1074,7 +1090,10 @@ def get_enterprise_equity():
data = json.loads(redis_store.get(name_query)) data = json.loads(redis_store.get(name_query))
return jsonify(code=RET.OK, msg="获取成功", data=data) return jsonify(code=RET.OK, msg="获取成功", data=data)
try: try:
if type == 'enterprise':
enterprise = Enterprise.query.get(id) enterprise = Enterprise.query.get(id)
else:
enterprise = Company.query.get(id)
company_id = enterprise.company_id company_id = enterprise.company_id
if not company_id: if not company_id:
return jsonify(RET.NODATA, msg='无关联信息') return jsonify(RET.NODATA, msg='无关联信息')
...@@ -1109,7 +1128,7 @@ def get_enterprise_punish(): ...@@ -1109,7 +1128,7 @@ def get_enterprise_punish():
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'] type = req_dict.get("type")
# 校验参数完整性 # 校验参数完整性
if not all([id]): if not all([id]):
return jsonify(code=RET.PARAMERR, msg="参数不完整") return jsonify(code=RET.PARAMERR, msg="参数不完整")
...@@ -1118,7 +1137,10 @@ def get_enterprise_punish(): ...@@ -1118,7 +1137,10 @@ def get_enterprise_punish():
data = json.loads(redis_store.get(name_query)) data = json.loads(redis_store.get(name_query))
return jsonify(code=RET.OK, msg="获取成功", data=data) return jsonify(code=RET.OK, msg="获取成功", data=data)
try: try:
if type == 'enterprise':
enterprise = Enterprise.query.get(id) enterprise = Enterprise.query.get(id)
else:
enterprise = Company.query.get(id)
company_id = enterprise.company_id company_id = enterprise.company_id
if not company_id: if not company_id:
return jsonify(RET.NODATA, msg='无关联信息') return jsonify(RET.NODATA, msg='无关联信息')
...@@ -1152,7 +1174,7 @@ def get_enterprise_certificate(): ...@@ -1152,7 +1174,7 @@ def get_enterprise_certificate():
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'] type = req_dict.get("type")
# 校验参数完整性 # 校验参数完整性
if not all([id]): if not all([id]):
return jsonify(code=RET.PARAMERR, msg="参数不完整") return jsonify(code=RET.PARAMERR, msg="参数不完整")
...@@ -1161,7 +1183,10 @@ def get_enterprise_certificate(): ...@@ -1161,7 +1183,10 @@ def get_enterprise_certificate():
data = json.loads(redis_store.get(name_query)) data = json.loads(redis_store.get(name_query))
return jsonify(code=RET.OK, msg="获取成功", data=data) return jsonify(code=RET.OK, msg="获取成功", data=data)
try: try:
if type == 'enterprise':
enterprise = Enterprise.query.get(id) enterprise = Enterprise.query.get(id)
else:
enterprise = Company.query.get(id)
company_id = enterprise.company_id company_id = enterprise.company_id
if not company_id: if not company_id:
return jsonify(RET.NODATA, msg='无关联信息') return jsonify(RET.NODATA, msg='无关联信息')
...@@ -1193,7 +1218,7 @@ def get_enterprise_patent(): ...@@ -1193,7 +1218,7 @@ def get_enterprise_patent():
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'] type = req_dict.get("type")
# 校验参数完整性 # 校验参数完整性
if not all([id]): if not all([id]):
return jsonify(code=RET.PARAMERR, msg="参数不完整") return jsonify(code=RET.PARAMERR, msg="参数不完整")
...@@ -1202,7 +1227,10 @@ def get_enterprise_patent(): ...@@ -1202,7 +1227,10 @@ def get_enterprise_patent():
data = json.loads(redis_store.get(name_query)) data = json.loads(redis_store.get(name_query))
return jsonify(code=RET.OK, msg="获取成功", data=data) return jsonify(code=RET.OK, msg="获取成功", data=data)
try: try:
if type == 'enterprise':
enterprise = Enterprise.query.get(id) enterprise = Enterprise.query.get(id)
else:
enterprise = Company.query.get(id)
company_id = enterprise.company_id company_id = enterprise.company_id
if not company_id: if not company_id:
return jsonify(RET.NODATA, msg='无关联信息') return jsonify(RET.NODATA, msg='无关联信息')
......
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