Commit 9ad3ec47 by dong

fix20221209

parent 0ccdc64a
......@@ -528,11 +528,6 @@ def company_detail():
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="请重新登录!")
......@@ -740,13 +735,24 @@ def enterprise_detail():
req_dict = request.get_json()
id = req_dict.get("id") # 企业id
token = request.headers['token']
try:
user_obj = verify_token(token)
user_id = user_obj.id
except:
return jsonify(code=RET.SESSIONERR, msg="请重新登录!")
# 校验参数完整性
if not all([id]):
return jsonify(code=RET.PARAMERR, msg="参数不完整")
try:
enterprise = Enterprise.query.get(id)
company = Company.query.get(id)
user = User.query.get(user_id) # 获取关注列表
if user:
enterprise_ids = [enter.id for enter in user.enterprise]
else:
enterprise_ids = []
# 工商状况-查询行政许可数据
data_info1 = EnterpriseAdminPermission.query.filter_by(company_id=id).all()
# 工商状况-查询税务信用数据
......@@ -780,6 +786,9 @@ def enterprise_detail():
"web_site": enterprise.web_site if enterprise.web_site else "", # 网址
"email": enterprise.email if enterprise.email else "", # 邮箱
"address": enterprise.address if enterprise.address else "", # 地址
"collect": "1" if enterprise.id in enterprise_ids else "2", # 关注状态码1关注,2未关注
"choice": "2", # 1太原企业,2全国企业
"location": province + city + district,
"jwd": {"lng": enterprise.lng if enterprise.lng else "", # 经度
......
......@@ -457,7 +457,7 @@ def recommond():
# 优质企业-各资质企业数量
@api_radar.route('/GoodEnterpriseNum', methods=['POST'])
# @login_required
def radar_enums():
def radar_enums1():
'''雷达监测页企业数量统计'''
req_dict = request.get_json()
inid = req_dict.get("inid") # 行业id
......@@ -1032,3 +1032,75 @@ def search_enterprise():
except Exception as e:
current_app.logger.error(e)
return jsonify(code=RET.DBERR, msg='查询出错!')
# 雷达监测页企业数量统计
@api_radar.route('/radar/enums', methods=['POST'])
# @login_required
def radar_enums():
'''雷达监测页企业数量统计'''
req_dict = request.get_json()
inid = req_dict.get("inid") # 行业id
area = req_dict.get("area") # [省,市,区]
province = area[0]
city = area[1]
district = area[2]
product = req_dict.get("product") # 企业产品
# 校验参数完整性
if not all([inid]):
return jsonify(code=RET.PARAMERR, msg="参数不完整")
try:
name_query = "radar" + str(inid) + str("".join(area)) + str(product)
if redis_store.get(name_query) is not None:
data = json.loads(redis_store.get(name_query))
return jsonify(code=RET.OK, msg="获取成功", data=data)
if inid:
enterprise = Enterprise.query.filter_by(c_type=inid)
else:
enterprise = Enterprise.query.filter_by()
if province:
enterprise = enterprise.filter_by(province=province)
if city:
enterprise = enterprise.filter_by(city=city)
if district:
enterprise = enterprise.filter_by(district=district)
if product:
# 有可能会变成模糊查询
enterprise = enterprise.filter(Enterprise.product_all.like("%{}%".format(product)))
nums_all = enterprise.count() # 企业总数
nums_dengl = enterprise.filter_by(dengl="1").count() # 瞪羚企业
nums_hignew = enterprise.filter_by(high_new="1").count() # 高新技术企业
nums_tbe = enterprise.filter_by(tbe="1").count() # 科技型中小企业
nums_quoted = enterprise.filter_by(quoted_company="1").count() # 上市企业
nums_financ = enterprise.filter_by(fianacing="1").count() # 有融资小企业
nums_unicorn = enterprise.filter_by(unicorn="1").count() # 独角兽企业
nums_capital = round(
float(enterprise.with_entities(func.sum(Enterprise.capital_nums)).scalar() if enterprise.with_entities(
func.sum(Enterprise.capital_nums)).scalar() else 0) / 10000, 2) # 注册资本(亿元)
nums_bao = enterprise.with_entities(func.sum(Enterprise.bao_num)).scalar() if enterprise.with_entities(
func.sum(Enterprise.bao_num)).scalar() else 0 # 就业人数
nums_patent = enterprise.with_entities(func.sum(Enterprise.num_patent)).scalar() if enterprise.with_entities(
func.sum(Enterprise.num_patent)).scalar() else 0 # 授权发明专利
data = {"nums_all": float(nums_all), "nums_capital": float(nums_capital), "nums_bao": float(nums_bao),
"nums_patent": float(nums_patent),
"nums_dengl": float(nums_dengl), "nums_hignew": float(nums_hignew), "nums_tbe": float(nums_tbe),
"nums_quoted": float(nums_quoted),
"nums_financ": float(nums_financ), "nums_unicorn": float(nums_unicorn), # "info": info
}
# redis缓存
redis_store.setex(name_query, 30 * 24 * 3600, json.dumps(data))
# redis_store.set(name_query, json.dumps(data))
# redis_store.expire(name_query, 30 * 24 * 3600)
print("redis")
return jsonify(code=RET.OK, msg="获取成功", data=data)
except Exception as e:
current_app.logger.error(e)
return jsonify(code=RET.DBERR, msg="数据库查询错误")
\ No newline at end of file
......@@ -877,23 +877,26 @@ def get_collect():
company_list = user.enterprise[(page - 1) * per_page:page * per_page]
for i in company_list:
create_time = UserEnterprise.query.filter_by(enterprise_id=i.id, user_id=user_id).first()
if company_name and company_name in i.company_name:
company.append({
"id": i.id,
"company_name": i.company_name,
"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 "-",
"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 ''
})
if company_name:
if company_name in i.company_name:
company.append({
"id": i.id,
"company_name": i.company_name,
"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 "-",
"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:
continue
else:
company.append({
"id": i.id,
......@@ -926,22 +929,44 @@ def get_collect():
try:
for i in company_list:
create_time = UserCompany.query.filter_by(company_id=i.id, user_id=user_id).first()
company.append({
"id": i.id,
"company_name": i.company_name,
"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 "-",
"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 ''
})
if company_name:
if company_name in i.company_name:
company.append({
"id": i.id,
"company_name": i.company_name,
"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 "-",
"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:
continue
else:
company.append({
"id": i.id,
"company_name": i.company_name,
"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 "-",
"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:
current_app.logger.error(e)
return jsonify(code=RET.DBERR, 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