Commit 1bf61383 by 赵宇

fix

parent 4248840e
......@@ -19,7 +19,7 @@ redis_store = None # 创建变量避免导入错误,在函数中进行初始
# 配置日志信息
# 创建日志记录器,指明日志保存的路径、每个日志文件的最大大小、保存的日志文件个数上限
file_log_handler = RotatingFileHandler("logs/log", maxBytes=1024 * 1024 * 100, backupCount=10)
file_log_handler = RotatingFileHandler("logs/logs", maxBytes=1024 * 1024 * 100, backupCount=10)
stream_log_handler = logging.StreamHandler()
# 创建日志记录的格式 日志等级 输入日志信息的文件名 行数 日志信息
formatter = logging.Formatter('%(levelname)s %(filename)s:%(lineno)d %(message)s')
......@@ -48,7 +48,6 @@ def after_request(resp):
# 'Content-Type,Authorization,X-Requested-With,token,application/octet-stream'
# x-requested-with,content-type
# "Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With"
def creat_app(config_name):
'''
:param config_name: str 配置模式的名称('develop', 'product')
......
......@@ -226,7 +226,8 @@ class Video(db.Model):
id = db.Column(db.Integer, primary_key=True, autoincrement=True, doc='视频主键id', comment='视频主键id')
district = db.Column(db.String(32), nullable=False, doc='区县名称', comment='区县名称')
video_id = db.Column(db.String(35), doc='视频', comment='视频')
# video_id = db.Column(db.String(255), doc='视频url', comment='视频url')
video_id1 = db.Column(db.String(255), doc='视频链接', comment='视频链接')
# 招商驾驶舱-项目数量/金额产业分布图
......
......@@ -14,26 +14,24 @@ from apps import db, constants, redis_store
# 获取左上角经济指标数据
def get_jjzb(district):
'''经济指标数据'''
years = [2021] # 指定数据的年份,与数据库中数据对齐
# years = [2021] # 指定数据的年份,与数据库中数据对齐
try:
if not district or district == '晋城市':
datas = City.query.filter_by(area='晋城市').filter(City.year.in_(years)).all()
datas = City.query.filter_by(area='晋城市').first()
else:
datas = City.query.filter_by(area=district).filter(City.year.in_(years)).all()
df = [{"list": [{"nums": '%.2f亿元' % (data.GDP / 10000) if data.GDP else "-亿元", "name": "地区生产总值"},
{"nums": '%.2f' % data.addscale + "%" if data.addscale else "-%", "name": "规上工业增加值增速"},
{"nums": '%.2f亿元' % (data.investment / 10000) if data.investment else "-亿元",
"name": "固定资产投资"},
{"nums": '%.2f亿元' % (data.retail / 10000) if data.retail else "-亿元", "name": "社会消费品零售额"},
{"nums": '%.2f亿元' % (data.in_out / 10000) if data.in_out else "-亿元", "name": "进出口总额"},
{"nums": '%.2f亿元' % (data.public / 10000) if data.public else "-亿元", "name": "一般公共预算支出"},
{"nums": '%.2f元' % data.people_out if data.people_out else "-元", "name": "居民人均可支配收入"},
{"nums": '%.2f' % data.people_per if data.people_per else "-", "name": "居民消费价格指数"}],
"desc": data.question if data.question else ""} for data in datas]
datas = City.query.filter_by(area=district).first()
df_dic = {"GDP": '%.2f亿元' % (datas.GDP / 10000) if datas.GDP else "-亿元", # 地区生产总值
"addscale": '%.2f' % datas.addscale + "%" if datas.addscale else "-%", # 规上工业增加值增速
"investment": '%.2f亿元' % (datas.investment / 10000) if datas.investment else "-亿元", # 固定资产投资
"retail": '%.2f亿元' % (datas.retail / 10000) if datas.retail else "-亿元", # 社会消费品零售额
"in_out": '%.2f亿元' % (datas.in_out / 10000) if datas.in_out else "-亿元", # 进出口总额
"public": '%.2f亿元' % (datas.public / 10000) if datas.public else "-亿元", # 一般公共预算支出
"people_out": '%.2f元' % datas.people_out if datas.people_out else "-元", # 居民人均可支配收入
"people_per": '%.2f' % datas.people_per if datas.people_per else "-"} # 居民消费价格指数
# print(df_dic)
# return jsonify(code=RET.OK, msg="查找成功", data=df)
return df
return df_dic
# return df
except Exception as e:
current_app.logger.error(e)
return jsonify(code=RET.DBERR, msg="数据库错误")
......@@ -42,7 +40,7 @@ def get_jjzb(district):
@api_attract.route("/index", methods=["GET"])
def index():
return 'hahah'
return '德旭,你好!'
# 左上角企业数量各资质统计、左上角获取经济指标数据、产业机构分布饼状图数据统计
......@@ -92,20 +90,17 @@ def menu():
dengl = company.filter_by(dengl="1").count() # 瞪羚
dujs = company.filter_by(unicorn="1").count() # 独角兽
table_data = [
{"name": "500强企业", "nums": t_c5},
{"name": "上市企业", "nums": ssqy},
{"name": "规模以上企业", "nums": gmys},
{"name": "专精特新企业", "nums": zjtx},
{"name": "高新技术企业", "nums": gxjs},
{"name": "科技型中小企业", "nums": kjzx},
{"name": "瞪羚企业", "nums": dengl},
{"name": "独角兽企业", "nums": dujs},
]
table_dic = {"t_c5": t_c5, # 500强企业
"ssqy": ssqy, # 上市企业
"gmys": gmys, # 规模以上企业
"zjtx": zjtx, # 专精特新企业
"gxjs": gxjs, # 高新技术企业
"kjzx": kjzx, # 科技型中小企业
"dengl": dengl, # 瞪羚企业
"dujs": dujs} # 独角兽企业
# 2. 左上角获取经济指标数据
jjzb_data = get_jjzb(district)
# 3. 产业机构分布饼状图数据统计
count_all = company.count()
if count_all == 0:
......@@ -118,7 +113,6 @@ def menu():
# count_xdfu = company.filter_by(f_type=6).count() # 现代服务业
# count_qt = count_all - count_mcq - count_gjd - count_mtmhg - count_gtzz - count_qyly - count_xdfu
count_qt = count_all - count_mcq - count_gjd - count_mtmhg - count_gtzz - count_qyly
mcq = int(count_mcq / count_all * 100)
gjd = int(count_gjd / count_all * 100)
mtmhg = int(count_mtmhg / count_all * 100)
......@@ -134,14 +128,15 @@ def menu():
{"per": gjd, "name": "光机电", "count": count_gjd},
{"per": gtzz, "name": "钢铁铸造", "count": count_gtzz},
{"per": qyly, "name": "全域旅游和康养", "count": count_qyly},
# {"per": qt + xdfu, "name": "其他", "count": count_qt + count_xdfu},
{"per": qt, "name": "其他", "count": count_qt},
]
# TODO 4.五大千亿级产业集群
data = {
"jjzb_data":jjzb_data, # 左上角经济指标数据
"table_data": table_data, # 左上角企业数据统计
"industry": industry # 产业结构分布饼状图数据
"jjzb_dic": jjzb_data, # 左上角经济指标数据
"table_dic": table_dic, # 左上角企业数据统计
"industry_dic": industry # 产业结构分布饼状图数据
}
return jsonify(code=RET.OK, msg="查找成功", data=data)
......@@ -159,7 +154,7 @@ def project():
project_map = []
industry_money = []
industry_nums = []
list1 = ["沁水县", "高平市", "陵川县", "阳城县", "泽州县", "城区"]
list1 = ["晋城市", "沁水县", "高平市", "陵川县", "阳城县", "泽州县", "城区"]
# 晋城市,点击区县之前默认数据
if not district or district == '晋城市':
......@@ -175,14 +170,28 @@ def project():
"add3": ss.invest_grade
})
# 产业数量/金额分布图数据
project_list = NewProject.query.filter_by(district=i).all()
# types_list = []
# industry_dic = {}
project_list = NewProject.query.filter_by(district="晋城市").all()
i = 0
for project in project_list:
i += 1
if i > 6:
pass
else:
industry_money.append({"name": project.type,
# "number": i.number,
"money": project.money})
"value": project.money})
industry_nums.append({"name": project.type,
# "money": i.money,
"number": project.number})
"value": project.number})
# money_list = []
#
# types = project.type
# money = project.money
# if types in types_list:
# industry_dic[types].append(money)
# money_list.append(money)
# industry_dic.update({types:money_list})
# types_list.append(types)
# 点击区县后的联动数据
else:
......@@ -197,14 +206,17 @@ def project():
"add3": ss.invest_grade
})
# 产业数量/金额分布图数据
i = 0
project_list = NewProject.query.filter_by(district=district).all()
for project in project_list:
i += 1
if i > 6:
pass
else:
industry_money.append({"name": project.type,
# "number": i.number,
"money": project.money})
"value": project.money})
industry_nums.append({"name": project.type,
# "money": i.money,
"number": project.number})
"value": project.number})
except Exception as e:
current_app.logger.error(e)
return jsonify(code=RET.DBERR, msg="数据库错误")
......@@ -246,8 +258,8 @@ def propol():
data_policy = [{"name": i.name, "id": i.id, "distict": district} for i in policy.all()]
data_project = [{"name": i.name, "id": i.id} for i in project.all()]
data = {
"project": data_project,
"policy": data_policy,
"project": data_project, # 重点项目
"policy": data_policy, # 政策
}
......@@ -269,7 +281,10 @@ def get_info():
try:
city = City.query.filter_by(area=district).first()
info = city.info
return jsonify(code=RET.OK, msg="查询成功", data=info)
detail_dic = {
"detail_data": info
}
return jsonify(code=RET.OK, msg="查询成功", data=detail_dic)
except Exception as e:
current_app.logger.error(e)
return jsonify(code=RET.DBERR, msg="数据库错误")
......@@ -297,7 +312,7 @@ def attract_video():
except Exception as e:
current_app.logger.error(e)
if video:
url = video.video_id
url = video.video_id1
if url:
return jsonify(code=RET.OK, msg="查询成功", data={"url": url})
else:
......@@ -317,16 +332,16 @@ def keyproject():
try:
project = Project.query.get(id)
data = {
"name": project.name,
"district": project.district,
"type": project.type,
"money": project.money,
"background": project.background,
"content": project.content,
"way": project.way,
"company": project.company,
"contact": project.contact,
"email": project.email
"name": project.name, # 工程名
"district": project.district, # 区县名称
"type": project.type, # 工程类型
"money": project.money, # 项目投资金额
"background": project.background, # 项目背景
"content": project.content, # 项目的具体内容
"way": project.way, # 拟引资方式及内容
"company": project.company, # 招商单位
"contact": project.contact, # 联系方式
"email": project.email # 电子邮箱
}
return jsonify(code=RET.OK, msg="查找成功", data=data)
except Exception as e:
......@@ -342,16 +357,24 @@ def policy_details():
if not _id:
return jsonify(code=RET.PARAMERR, msg="参数不全")
try:
_id1 = int(_id) + 1
_id2 = int(_id) - 1
if _id2 < 1:
_id2 = ''
policy = InduPolicy.query.get(_id)
data = {"name": policy.name,
"file": policy.file if policy.file else "-",
"category": policy.category if policy.category else "-",
"org": policy.org if policy.org else "-",
"industry": policy.industry if policy.industry else "-",
"district": policy.district if policy.district else "-",
"pubdate": str(policy.pubdate)[0:10] if policy.pubdate else "-",
"url": policy.url if policy.pubdate else "-",
"post_num": policy.post_num if policy.post_num else ""}
policy1 = InduPolicy.query.get(str(_id1))
policy2 = InduPolicy.query.get(str(_id2))
data = {"name": policy.name, # 政策名
"file": policy.file if policy.file else "-", # 本地文件位置
"category": policy.category if policy.category else "-", # 政策类型
"org": policy.org if policy.org else "-", # 政策发布机构
"industry": policy.industry if policy.industry else "-", # 行业名称
"district": policy.district if policy.district else "-", # 政策发布地区
"pubdate": str(policy.pubdate)[0:10] if policy.pubdate else "-", # 发布时间
"url": policy.url if policy.pubdate else "-", # 外链接
"post_num": policy.post_num if policy.post_num else "", # 发文字号
"last": [policy2.name, _id1] if policy2 else "",
"next": [policy1.name, _id2] if policy1 else ""}
return jsonify(code=RET.OK, msg="查找成功", data=data)
except Exception as e:
current_app.logger.error(e)
......@@ -361,44 +384,23 @@ def policy_details():
# 列表展示左上角企业
@api_attract.route("/showListb", methods=["POST"])
def showListb():
district_dict = {'晋城市': '晋城市',
'沁水县': '沁水县',
'高平市': '高平市',
'陵川县': '陵川县',
'阳城县': '阳城县',
'泽州县': '泽州县',
'城区': '城区'
}
req_dic = request.get_json()
type = req_dic.get("type") # 1234567 (优质企业-500强-上市-规模-专精特新-高新-科技中小)
classify = req_dic.get("classify") # 1234 企业-学校-科研机构-传新平台
type = req_dic.get("type") # 12345678 (500强-上市-规模-专精特新-高新-科技中小-瞪羚-独角兽)
district = req_dic.get("district")
page = req_dic.get("page")
perpage = req_dic.get("perpage")
if not all([type, classify, district]):
if not all([type, district]):
return jsonify(code=RET.PARAMERR, msg="参数错误")
if not page:
page = 1
if not perpage:
perpage = 20
try:
# 企业
if classify == 1:
if district == "太原市":
company = Company.query.filter_by(city="太原市")
if district == "晋城市":
company = Company.query.filter_by(city="晋城市")
else:
# company = Company.query.filter(or_(Company.district == district_dict[district],
# Company.induzone == district_dict[district]))
company = Company.query.filter_by(city="太原市").filter(Company.induzone == district_dict[district])
company = Company.query.filter_by(city="晋城市", district=district)
size = company.count()
# if type == 1:
# company = company.order_by(Company.isfive.desc()).order_by(Company.tbe.desc()).order_by(
# Company.high_new.desc()).order_by(
# Company.quoted_company.desc()).order_by(Company.scale.desc())
if type == 1:
company = company.filter_by(isfive=1)
size = company.count()
......@@ -406,11 +408,10 @@ def showListb():
company = company.filter_by(quoted_company=1)
size = company.count()
if type == 3:
# company = company.filter_by(scale=1)
if district == "晋城市":
company = Company.query.filter_by(scale="1")
else:
company = Company.query.filter(Company.induzone == district_dict[district]).filter_by(scale="1")
company = Company.query.filter_by(district=district, scale="1")
size = company.count()
if type == 4:
company = company.filter_by(zjtg=1)
......@@ -427,16 +428,15 @@ def showListb():
if type == 8:
company = company.filter_by(unicorn=1)
size = company.count()
company = company.paginate(page, perpage).items
company = company.paginate(page, per_page=4).items
data = [{
"id": i.id,
"name": i.company_name,
"industry": i.company_industry if i.company_industry else "-",
"product": i.product if i.product else "-",
"build_date": i.build_date.strftime("%Y-%m-%d") if i.build_date else "-",
# "capital": i.capital if i.capital else "-",
"build_date": "-",
"capital": i.capital if i.capital else "-",
"isfive": "500强企业" if i.isfive == "1" else "",
# "quoted_company": "上市企业" if i.quoted_company == "1" else "",
"quoted_company": i.public_sector if i.public_sector != "空" else "",
"scale": "规模以上企业" if i.scale == "1" else "",
"zjtg": "专精特新企业" if i.zjtg == "1" else "",
......@@ -446,63 +446,6 @@ def showListb():
"unicorn": "独角兽企业" if i.unicorn == "1" else "",
} for i in company]
data = {"data_list": data, "size": size}
# 学校
# elif classify == 2:
# if district == "太原市":
# college = College.query.filter()
# else:
# college = College.query.filter(or_(College.admin == district_dict[district],
# College.developarea == district_dict[district]))
# if type == 1:
# college = college.filter(or_(College.cateid == 1, College.cateid == 2))
# if type == 2:
# college = college.filter(College.cateid == 3)
# size = college.count()
# college = college.paginate(page, perpage).items
# data = [{
# "id": i.id,
# "name": i.name,
# "cateone": 1,
# "category": i.category if i.category else "-",
# "nature": i.nature if i.nature else "-",
# "buildate": i.buildate if i.buildate else "-",
# } for i in college]
# data = {"data_list": data, "size": size}
# # 科研机构:
# elif classify == 3:
# if district == "太原市":
# scientific = Scientific.query.filter_by()
# else:
# scientific = Scientific.query.filter(or_(Scientific.admin == district_dict[district],
# Scientific.developarea == district_dict[district]))
# size = scientific.count()
# scientific = scientific.paginate(page, perpage).items
# data = [{
# "id": i.id,
# "name": i.name,
# "cateone": 2,
# "type": "科研机构",
# "telephone": i.telephone if i.telephone else "-",
# } for i in scientific]
# data = {"data_list": data, "size": size}
# # 创新平台:
# elif classify == 4:
# if district == "太原市":
# lab = Lab.query.filter_by()
# else:
# lab = Lab.query.filter(or_(Lab.admin == district_dict[district],
# Lab.developarea == district_dict[district]))
# size = lab.count()
# lab = lab.paginate(page, perpage).items
# data = [{
# "id": i.id,
# "name": i.name,
# "type": i.cate,
# "cateone": 3
# } for i in lab]
# data = {"data_list": data, "size": size}
else:
data = {}
return jsonify(code=RET.OK, msg="查找成功", data=data)
except Exception as e:
current_app.logger.error(e)
......@@ -528,27 +471,30 @@ def enterprise_detail():
company = Company.query.get(_id)
if company:
data = {"id": company.id,
"company_name": company.company_name,
"telephone": company.telephone if company.telephone else "-",
"web_site": company.web_site if company.web_site else "-",
"email": company.email if company.email else "-",
"address": company.address if company.address else "-",
"jwd": {"lng": company.lng if company.lng else "-",
"lat": company.lat if company.lat else "-"},
"company_info": company.company_info if company.company_info else "-",
"high_new": "高新技术企业" if company.high_new else "-",
"legal": company.legal if company.legal else "-",
"status": company.status if company.status else "-",
"build_date": str(company.build_date)[:10] if company.build_date else "-",
"capital": company.capital if company.capital else "-",
"social_code": company.social_code if company.social_code else "-",
"taking": company.takingn if company.takingn else "-",
"bao": company.bao_num if company.bao_num else "-",
"entype": company.entype if company.entype else "-",
"industry": company.company_industry if company.company_industry else "-",
"scope": company.business_scope if company.business_scope else "-",
"collect": "1",
"choice": "3"
"company_name": company.company_name, # 企业名
"telephone": company.telephone if company.telephone else "-", # 电话
"web_site": company.web_site if company.web_site else "-", # 网址
"email": company.email if company.email else "-", # 邮箱
"address": company.address if company.address else "-", # 地址
"jwd": {"lng": company.lng if company.lng else "-", # 经度
"lat": company.lat if company.lat else "-"}, # 维度
"company_info": company.company_info if company.company_info else "-", # 企业信息
"business_scope": company.business_scope if company.business_scope else "-", # 经营范围
"high_new": "高新技术企业" if company.high_new else "-", # 高新技术企业
"legal": company.legal if company.legal else "-", # 法定代表人
"status": company.status if company.status else "-", # 状态
"build_date": str(company.build_date)[:10] if company.build_date else "-", # 创建时间
"capital": company.capital if company.capital else "-", # 注册资本
"social_code": company.social_code if company.social_code else "-", # 统一社会信用代码
# "taking": company.takingn if company.takingn else "-", # 营收 (万元)
"bao": company.bao_num if company.bao_num else "-", #参保人数
"entype": company.entype if company.entype else "-", # 企业类型
"industry": company.company_industry if company.company_industry else "-", # 所属行业
"scope": company.business_scope if company.business_scope else "-", # 企业经营范围
# "collect": "1",
# "choice": "3"
"tax_code": company.tax_code if company.tax_code else "-",
"register_code": company.register_code if company.register_code else "-",
}
else:
return jsonify(code=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