Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mancheng
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mancheng
Commits
ebf4a949
Commit
ebf4a949
authored
Sep 25, 2023
by
dong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix20230721
parent
6d6f4b3b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
137 additions
and
43 deletions
+137
-43
apps/models.py
+1
-0
apps/view_index/view.py
+3
-1
apps/view_radar/view.py
+133
-42
No files found.
apps/models.py
View file @
ebf4a949
...
@@ -585,6 +585,7 @@ class Examine(BaseModel, db.Model):
...
@@ -585,6 +585,7 @@ class Examine(BaseModel, db.Model):
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
,
autoincrement
=
True
,
comment
=
'主键id'
)
# id
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
,
autoincrement
=
True
,
comment
=
'主键id'
)
# id
district
=
db
.
Column
(
db
.
String
(
255
),
comment
=
'县区'
)
# 县区
district
=
db
.
Column
(
db
.
String
(
255
),
comment
=
'县区'
)
# 县区
time
=
db
.
Column
(
db
.
String
(
30
),
comment
=
'标题的时间'
)
year
=
db
.
Column
(
db
.
Integer
,
comment
=
'年'
)
# 年
year
=
db
.
Column
(
db
.
Integer
,
comment
=
'年'
)
# 年
month
=
db
.
Column
(
db
.
Integer
,
comment
=
'月'
)
# 月
month
=
db
.
Column
(
db
.
Integer
,
comment
=
'月'
)
# 月
project_num
=
db
.
Column
(
db
.
Integer
,
comment
=
'项目个数'
)
# 项目个数
project_num
=
db
.
Column
(
db
.
Integer
,
comment
=
'项目个数'
)
# 项目个数
...
...
apps/view_index/view.py
View file @
ebf4a949
...
@@ -237,8 +237,10 @@ def project():
...
@@ -237,8 +237,10 @@ def project():
"nums3"
:
"{}亿元"
.
format
(
ss
.
invest_finish
),
"nums3"
:
"{}亿元"
.
format
(
ss
.
invest_finish
),
"add3"
:
ss
.
invest_grade
,
"add3"
:
ss
.
invest_grade
,
"nums4"
:
"{}个"
.
format
(
ss
.
start_num
),
"nums4"
:
"{}个"
.
format
(
ss
.
start_num
),
"add4"
:
ss
.
start_num_grade
"add4"
:
ss
.
start_num_grade
,
"time"
:
ss
.
time
})
})
# 已开工项目产业分布/已开工项目到位资金产业分布
# 已开工项目产业分布/已开工项目到位资金产业分布
# types_list = []
# types_list = []
# industry_dic = {}
# industry_dic = {}
...
...
apps/view_radar/view.py
View file @
ebf4a949
import
json
import
json
import
requests
import
requests
import
math
import
math
from
elasticsearch
import
Elasticsearch
from
flask
import
current_app
,
request
,
jsonify
from
flask
import
current_app
,
request
,
jsonify
from
apps.view_radar
import
api_radar
from
apps.view_radar
import
api_radar
from
apps.models
import
*
from
apps.models
import
*
...
@@ -422,8 +424,78 @@ def prolink():
...
@@ -422,8 +424,78 @@ def prolink():
# 产业评估-根据具体环节的细分产业获取相关企业
# 产业评估-根据具体环节的细分产业获取相关企业
# @api_radar.route('/GetLinkEnterprise', methods=['POST'])
# @login_required
# def recommond():
# '''
# 产品描述及企业推荐
# :return:
# '''
# req_dict = request.get_json()
# name = req_dict.get("name") # 产品名
# page = req_dict.get("page")
# perpage = req_dict.get("perpage")
#
# name_query = "GetLinkEnterprise" + name + str(page)
# 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)
# try:
# if not name:
# return jsonify(code=RET.OK, msg="查无数据!")
#
# enterprise = Enterprise.query.filter(Enterprise.city !='晋城市').filter(or_(
# Enterprise.product_all.like("%{}%".format(name)),
# Enterprise.product_all1.like("%{}%".format(name)),
# Enterprise.product_all2.like("%{}%".format(name))
# ))
# size = enterprise.count()
# enterprise = enterprise.order_by(
# # Enterprise.c_type,
# Enterprise.hots.desc()).paginate(page, perpage).items # # 企业热度倒序
# ent_data = []
# for com in enterprise:
# if com.city == '晋城市':
# continue
# ent_data.append({"id": com.id,
# "company_name": com.company_name,
# "city": com.city,
# "district": com.district,
# "build_date": str(com.build_date)[:10] if com.build_date else "-", # 时间
# "legal": com.legal,
# "capital_nums": com.capital_nums,
# "entype": com.entype,
#
# "high_new": "高新技术企业" if com.high_new == "1" else "",
# "tbe": "科技型中小企业" if com.tbe == "1" else "",
# "fianacing": "融资企业" if com.fianacing == "1" else "",
# "quoted_company": "上市企业" if com.quoted_company == "1" else "",
# "dengl": "瞪羚企业" if com.dengl == "1" else "",
# "unicorn": "独角兽企业" if com.unicorn == "1" else "",
# "isfive": "500强企业" if com.isfive == "1" else "",
#
# "tbe_sjmy": "省级民营科技企业" if com.tbe_sjmy == "1" else "",
# "zjtg_gjjxjr": "国家级专精特新小巨人企业" if com.zjtg_gjjxjr == "1" else "",
# "zjtg_sjxjr": "省级专精特新小巨人企业" if com.zjtg_sjxjr == "1" else "",
# "zjtg": "专精特新企业" if com.zjtg == "1" else "",
#
# "address": com.address,
# "telephone": com.telephone
# })
# data = {"ent_data": ent_data, "size": size}
#
# # redis缓存
# redis_store.setex(name_query, 30 * 24 * 3600, json.dumps(data))
# # redis_store.hset('GetLinkEnterprise:{}'.format(name_query), 'GetLinkEnterprise', {'data':data})
#
# return jsonify(code=RET.OK, msg="查询成功", data=data)
# except Exception as e:
# current_app.logger.error(e)
# return jsonify(code=RET.DBERR, msg="数据库查询错误")
@api_radar.route
(
'/GetLinkEnterprise'
,
methods
=
[
'POST'
])
@api_radar.route
(
'/GetLinkEnterprise'
,
methods
=
[
'POST'
])
@login_required
#
@login_required
def
recommond
():
def
recommond
():
'''
'''
产品描述及企业推荐
产品描述及企业推荐
...
@@ -434,56 +506,75 @@ def recommond():
...
@@ -434,56 +506,75 @@ def recommond():
page
=
req_dict
.
get
(
"page"
)
page
=
req_dict
.
get
(
"page"
)
perpage
=
req_dict
.
get
(
"perpage"
)
perpage
=
req_dict
.
get
(
"perpage"
)
name_query
=
"GetLinkEnterprise"
+
name
+
str
(
page
)
#
name_query = "GetLinkEnterprise" + name + str(page)
if
redis_store
.
get
(
name_query
)
is
not
None
:
#
if redis_store.get(name_query) is not None:
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
not
name
:
if
not
name
:
return
jsonify
(
code
=
RET
.
OK
,
msg
=
"查无数据!"
)
return
jsonify
(
code
=
RET
.
OK
,
msg
=
"查无数据!"
)
enterprise
=
Enterprise
.
query
.
filter
(
Enterprise
.
city
!=
'晋城市'
)
.
filter
(
or_
(
body
=
{
Enterprise
.
product_all
.
like
(
"
%
{}
%
"
.
format
(
name
)),
"query"
:
{
Enterprise
.
product_all1
.
like
(
"
%
{}
%
"
.
format
(
name
)),
"bool"
:
{
Enterprise
.
product_all2
.
like
(
"
%
{}
%
"
.
format
(
name
))
"must_not"
:
{
"term"
:
{
"city"
:
"晋城市"
}},
))
"must"
:[
size
=
enterprise
.
count
()
{
enterprise
=
enterprise
.
order_by
(
"multi_match"
:{
# Enterprise.c_type,
"query"
:
"{}"
.
format
(
name
),
Enterprise
.
hots
.
desc
())
.
paginate
(
page
,
perpage
)
.
items
# # 企业热度倒序
"fields"
:[
"product_all"
,
"product_all1"
,
"product_all2"
]
}
}
]
}
},
"from"
:
page
,
"size"
:
perpage
,
"sort"
:
[{
"host"
:{
"order"
:
"desc"
}}],
"aggs"
:
{},
"_source"
:
[],
"highlight"
:
{
"fields"
:
{
"product"
:
{
"type"
:
"plain"
},
"company_name"
:
{
"type"
:
"plain"
},
"industry"
:
{
"type"
:
"plain"
}
}
}
}
es
=
Elasticsearch
([{
'host'
:
'39.100.39.50'
,
'port'
:
9200
}])
data
=
es
.
search
(
index
=
"jc_enterperise1"
,
body
=
body
)
size
=
data
[
"hits"
][
'total'
]
ent_data
=
[]
ent_data
=
[]
for
com
in
enterprise
:
for
com
in
data
[
"hits"
][
'hits'
]:
if
com
.
city
==
'晋城市'
:
ent_data
.
append
({
"id"
:
com
[
"_source"
][
"mysql_id"
],
continue
"company_name"
:
com
[
"_source"
][
"company_name"
],
ent_data
.
append
({
"id"
:
com
.
id
,
"city"
:
com
[
"_source"
][
"city"
],
"company_name"
:
com
.
company_name
,
"district"
:
com
[
"_source"
][
"district"
],
"city"
:
com
.
city
,
"build_date"
:
str
(
com
[
"_source"
][
"build_date"
])[:
10
]
if
com
[
"_source"
][
"build_date"
]
else
"-"
,
# 时间
"district"
:
com
.
district
,
"legal"
:
com
[
"_source"
][
"legal"
],
"build_date"
:
str
(
com
.
build_date
)[:
10
]
if
com
.
build_date
else
"-"
,
# 时间
"capital_nums"
:
round
(
float
(
com
[
"_source"
][
"capital"
]
.
split
(
'万元'
)[
0
]),
2
)
if
com
[
"_source"
][
"capital"
]
and
com
[
"_source"
][
"capital"
]
!=
'-'
else
''
,
"legal"
:
com
.
legal
,
"entype"
:
com
[
"_source"
][
"entype"
],
"capital_nums"
:
com
.
capital_nums
,
"entype"
:
com
.
entype
,
"high_new"
:
"高新技术企业"
if
com
[
"_source"
][
"high_new"
]
==
"1"
else
""
,
"tbe"
:
"科技型中小企业"
if
com
[
"_source"
][
"tbe"
]
==
"1"
else
""
,
"high_new"
:
"高新技术企业"
if
com
.
high_new
==
"1"
else
""
,
"fianacing"
:
"融资企业"
if
com
[
"_source"
][
"fianacing"
]
==
"1"
else
""
,
"tbe"
:
"科技型中小企业"
if
com
.
tbe
==
"1"
else
""
,
"quoted_company"
:
"上市企业"
if
com
[
"_source"
][
"quoted_company"
]
==
"1"
else
""
,
"fianacing"
:
"融资企业"
if
com
.
fianacing
==
"1"
else
""
,
"dengl"
:
"瞪羚企业"
if
com
[
"_source"
][
"dengl"
]
==
"1"
else
""
,
"quoted_company"
:
"上市企业"
if
com
.
quoted_company
==
"1"
else
""
,
"unicorn"
:
"独角兽企业"
if
com
[
"_source"
][
"unicorn"
]
==
"1"
else
""
,
"dengl"
:
"瞪羚企业"
if
com
.
dengl
==
"1"
else
""
,
"isfive"
:
"500强企业"
if
com
[
"_source"
][
"isfive"
]
==
"1"
else
""
,
"unicorn"
:
"独角兽企业"
if
com
.
unicorn
==
"1"
else
""
,
"isfive"
:
"500强企业"
if
com
.
isfive
==
"1"
else
""
,
"tbe_sjmy"
:
"省级民营科技企业"
if
com
[
"_source"
][
"tbe_sjmy"
]
==
"1"
else
""
,
"zjtg_gjjxjr"
:
"国家级专精特新小巨人企业"
if
com
[
"_source"
][
"zjtg_gjjxjr"
]
==
"1"
else
""
,
"tbe_sjmy"
:
"省级民营科技企业"
if
com
.
tbe_sjmy
==
"1"
else
""
,
"zjtg_sjxjr"
:
"省级专精特新小巨人企业"
if
com
[
"_source"
][
"zjtg_sjxjr"
]
==
"1"
else
""
,
"zjtg_gjjxjr"
:
"国家级专精特新小巨人企业"
if
com
.
zjtg_gjjxjr
==
"1"
else
""
,
"zjtg"
:
"专精特新企业"
if
com
[
"_source"
][
"zjtg"
]
==
"1"
else
""
,
"zjtg_sjxjr"
:
"省级专精特新小巨人企业"
if
com
.
zjtg_sjxjr
==
"1"
else
""
,
"zjtg"
:
"专精特新企业"
if
com
.
zjtg
==
"1"
else
""
,
"address"
:
com
[
"_source"
][
"address"
],
"telephone"
:
com
[
"_source"
][
"telephone"
]
"address"
:
com
.
address
,
"telephone"
:
com
.
telephone
})
})
data
=
{
"ent_data"
:
ent_data
,
"size"
:
size
}
data
=
{
"ent_data"
:
ent_data
,
"size"
:
size
}
# redis缓存
# redis缓存
redis_store
.
setex
(
name_query
,
30
*
24
*
3600
,
json
.
dumps
(
data
))
#
redis_store.setex(name_query, 30 * 24 * 3600, json.dumps(data))
# redis_store.hset('GetLinkEnterprise:{}'.format(name_query), 'GetLinkEnterprise', {'data':data})
# redis_store.hset('GetLinkEnterprise:{}'.format(name_query), 'GetLinkEnterprise', {'data':data})
return
jsonify
(
code
=
RET
.
OK
,
msg
=
"查询成功"
,
data
=
data
)
return
jsonify
(
code
=
RET
.
OK
,
msg
=
"查询成功"
,
data
=
data
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment