Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
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
蒋勇
zhichan
Commits
0c8fd3cc
Commit
0c8fd3cc
authored
Jul 15, 2020
by
张云飞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zyf
parent
82114c60
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
76 deletions
+20
-76
ic-name/hanshujisuan.py
+20
-76
No files found.
ic-name/hanshujisuan.py
View file @
0c8fd3cc
...
@@ -19,22 +19,7 @@ ES_HOST = ""
...
@@ -19,22 +19,7 @@ ES_HOST = ""
ES_USER
=
""
ES_USER
=
""
ES_PWD
=
""
ES_PWD
=
""
ES_PORT
=
""
ES_PORT
=
""
# dbdict = os.environ
environDict
=
os
.
environ
environDict
=
os
.
environ
# environDict = json.loads(dbdict.get('ZYF'))
# print('获取环境变量',environDict)
# if environDict:
# print(environDict, "---------------------------")
# DB_HOST = environDict.get('DB_HOST')
# DB_PORT = environDict.get('DB_PORT')
# DB_USER = environDict.get('DB_USER')
# DB_PWD = environDict.get('DB_PWD')
# QCC_APPKEY = environDict.get('QCC_APPKEY')
# QCC_SECRETKEY = environDict.get('QCC_SECRETKEY')
# ES_HOST = environDict.get('ES_HOST')
# ES_USER = environDict.get('ES_USER')
# ES_PWD = environDict.get('ES_PWD')
# ES_PORT = environDict.get('ES_PORT')
DB_HOST
=
environDict
.
get
(
'DB_HOST'
)
DB_HOST
=
environDict
.
get
(
'DB_HOST'
)
DB_PORT
=
int
(
environDict
.
get
(
'DB_PORT'
))
DB_PORT
=
int
(
environDict
.
get
(
'DB_PORT'
))
DB_USER
=
environDict
.
get
(
'DB_USER'
)
DB_USER
=
environDict
.
get
(
'DB_USER'
)
...
@@ -45,11 +30,11 @@ ES_HOST = environDict.get('ES_HOST')
...
@@ -45,11 +30,11 @@ ES_HOST = environDict.get('ES_HOST')
ES_USER
=
environDict
.
get
(
'ES_USER'
)
ES_USER
=
environDict
.
get
(
'ES_USER'
)
ES_PWD
=
environDict
.
get
(
'ES_PWD'
)
ES_PWD
=
environDict
.
get
(
'ES_PWD'
)
ES_PORT
=
int
(
environDict
.
get
(
'ES_PORT'
))
ES_PORT
=
int
(
environDict
.
get
(
'ES_PORT'
))
print
(
'------------------------------------'
)
print
(
DB_HOST
,
DB_PORT
,
ES_HOST
,
ES_PORT
)
print
(
'------------------------------------'
)
print
(
DB_HOST
,
DB_HOST
,
DB_PORT
,
ES_PORT
)
print
(
type
(
DB_PORT
),
type
(
ES_PORT
),
'------------------'
)
def
findByType
():
def
findByType
():
conn
=
pymysql
.
connect
(
host
=
DB_HOST
,
port
=
DB_PORT
,
user
=
DB_USER
,
password
=
DB_PWD
,
db
=
"brg-ic-name"
)
conn
=
pymysql
.
connect
(
host
=
DB_HOST
,
port
=
DB_PORT
,
user
=
DB_USER
,
password
=
DB_PWD
,
db
=
"brg-ic-name"
)
sql
=
'SELECT * FROM gsb_newcity'
sql
=
'SELECT * FROM gsb_newcity'
...
@@ -371,36 +356,6 @@ def similarityJudg(str1, str2):
...
@@ -371,36 +356,6 @@ def similarityJudg(str1, str2):
return
int
(
b
)
return
int
(
b
)
# def foursimilarityJudg(cityname,keyword,btname,name):
# cchars = list(cityname)
# kchars = list(keyword)
# bchars = list(btname)
# nchars = list(name)
# len2 = len(nchars)
# count = 0
# for i in range(len(cchars)):
# for j in range(len(nchars)):
# if cchars[i] == nchars[j]:
# count += 1
# continue
# b1 = round(count / len2, 4)
# count = 0
# for i in range(len(kchars)):
# for j in range(len(nchars)):
# if kchars[i] == nchars[j]:
# count += 1
# continue
# b2 = round(count / len2, 4)
# count = 0
# for i in range(len(bchars)):
# for j in range(len(nchars)):
# if bchars[i] == nchars[j]:
# count += 1
# continue
# b3 = round(count / len2, 4)
# b = round((b1+b2+b3)*100,0)
# return int(b)
def
foursimilarityJudg
(
keywords
,
name
):
def
foursimilarityJudg
(
keywords
,
name
):
s1
=
keywords
s1
=
keywords
s2
=
name
s2
=
name
...
@@ -592,7 +547,7 @@ def getgsbJSON(cityname, keyword, btname, orgname, setcity, keywords, cityList,
...
@@ -592,7 +547,7 @@ def getgsbJSON(cityname, keyword, btname, orgname, setcity, keywords, cityList,
}
}
point
=
0
point
=
0
count
=
-
1
count
=
-
1
es
=
Elastic
(
ES_HOST
,
ES_USER
,
ES_PWD
,
ES_PORT
)
es
=
Elastic
(
ES_HOST
,
ES_USER
,
ES_PWD
,
ES_PORT
)
jes
=
es
.
es_search
(
params
)
jes
=
es
.
es_search
(
params
)
status
=
jes
[
"Status"
]
status
=
jes
[
"Status"
]
if
status
==
400
:
if
status
==
400
:
...
@@ -721,7 +676,7 @@ def getgsbqccJSON(cityname, keyword, btname, url, orgname, setcity, keywords, Ap
...
@@ -721,7 +676,7 @@ def getgsbqccJSON(cityname, keyword, btname, url, orgname, setcity, keywords, Ap
"orgname"
:
orgname
,
"orgname"
:
orgname
,
"setcity"
:
setcity
"setcity"
:
setcity
}
}
es
=
Elastic
(
ES_HOST
,
ES_USER
,
ES_PWD
,
ES_PORT
)
es
=
Elastic
(
ES_HOST
,
ES_USER
,
ES_PWD
,
ES_PORT
)
jes
=
es
.
es_search
(
params
)
jes
=
es
.
es_search
(
params
)
status
=
jes
[
"Status"
]
status
=
jes
[
"Status"
]
if
status
==
200
:
if
status
==
200
:
...
@@ -1049,29 +1004,19 @@ def inputinfo(cityname, keyword, btname, url, orgname, setcity, appkey, AppKey,
...
@@ -1049,29 +1004,19 @@ def inputinfo(cityname, keyword, btname, url, orgname, setcity, appkey, AppKey,
def
heming
(
eventdict
):
def
heming
(
eventdict
):
print
(
eventdict
)
print
(
eventdict
)
# 查询数据方式,1:公司宝,2:企查查,3:混合模式
# 查询数据方式,1:公司宝,2:企查查,3:混合模式
search_type
=
eventdict
[
'search_type'
]
searchtype
=
int
(
eventdict
[
'searchtype'
])
if
eventdict
[
'searchtype'
]
else
1
# search_type = 1
cityname
=
eventdict
[
"cityname"
]
# 北京,地区
cityname
=
eventdict
[
"cityname"
]
# 北京,地区
keyword
=
eventdict
[
"keyword"
]
# 汉唐,字号
keyword
=
eventdict
[
"keyword"
]
# 汉唐,字号
btname
=
eventdict
[
"btname"
]
# 科技,行业类型
btname
=
eventdict
[
"btname"
]
# 科技,行业类型
orgname
=
eventdict
[
"orgname"
]
# 有限公司,公司类型,默认:有限公司,可能有股份有限公司,集团公司等等,需要王驰给与建议
orgname
=
eventdict
[
"orgname"
]
# 有限公司,公司类型,默认:有限公司,可能有股份有限公司,集团公司等等,需要王驰给与建议
sitcity
=
eventdict
[
"sitcity"
]
sitcity
=
int
(
eventdict
[
"sitcity"
])
if
eventdict
[
"sitcity"
]
else
1
print
(
type
(
sitcity
),
sitcity
,
'------------------------------'
)
# 有限公司,公司类型,默认:有限公司,可能有股份有限公司,集团公司等等,需要王驰给与建议
# 有限公司,公司类型,默认:有限公司,可能有股份有限公司,集团公司等等,需要王驰给与建议
try
:
if
sitcity
==
2
:
if
sitcity
==
2
:
keywords
=
keyword
+
"("
+
cityname
+
")"
+
btname
+
orgname
print
(
'222222222222222222222222'
)
elif
sitcity
==
3
:
keywords
=
keyword
+
btname
+
"("
+
cityname
+
")"
+
orgname
keywords
=
keyword
+
"("
+
cityname
+
")"
+
btname
+
orgname
else
:
elif
sitcity
==
3
:
keywords
=
cityname
+
keyword
+
btname
+
orgname
keywords
=
keyword
+
btname
+
"("
+
cityname
+
")"
+
orgname
else
:
print
(
'11111111111111111111111'
)
keywords
=
cityname
+
keyword
+
btname
+
orgname
except
Exception
as
e
:
print
(
'qqqqqqqqqqqqqqqqqqqqqqqqqq'
)
# 地区在字号中的位置
# 地区在字号中的位置
senlist
=
getSensitiveByLike
(
keyword
)
senlist
=
getSensitiveByLike
(
keyword
)
Brandlist
=
getBrandByLike
(
keyword
)
Brandlist
=
getBrandByLike
(
keyword
)
...
@@ -1085,24 +1030,23 @@ def heming(eventdict):
...
@@ -1085,24 +1030,23 @@ def heming(eventdict):
AppKey
=
QCC_APPKEY
AppKey
=
QCC_APPKEY
SecretKey
=
QCC_SECRETKEY
SecretKey
=
QCC_SECRETKEY
if
len
(
senlist
)
+
len
(
Brandlist
)
+
len
(
citylist
)
+
len
(
cList
)
==
0
:
if
len
(
senlist
)
+
len
(
Brandlist
)
+
len
(
citylist
)
+
len
(
cList
)
==
0
:
if
search_type
==
1
:
# 按照检索方式去查询es
if
searchtype
==
2
:
# 请求qcc数据接口
res
=
getgsbJSON
(
cityname
,
keyword
,
btname
,
orgname
,
sitcity
,
keywords
,
cityList
,
brandList
,
sensitiveList
,
similarCityList
,
identicalCityList
)
elif
search_type
==
2
:
# 请求qcc数据接口
# 企查查数据接口Appkey,查询数据库
# 企查查数据接口Appkey,查询数据库
url
=
"http://api.qichacha.com/ECIV4/Search?key="
+
AppKey
+
"&pageSize=20"
url
=
"http://api.qichacha.com/ECIV4/Search?key="
+
AppKey
+
"&pageSize=20"
res
=
getqccJSON
(
cityname
,
keyword
,
btname
,
url
,
orgname
,
keywords
,
AppKey
,
SecretKey
,
cityList
,
brandList
,
res
=
getqccJSON
(
cityname
,
keyword
,
btname
,
url
,
orgname
,
keywords
,
AppKey
,
SecretKey
,
cityList
,
brandList
,
sensitiveList
,
similarCityList
,
identicalCityList
)
sensitiveList
,
similarCityList
,
identicalCityList
)
elif
search
_
type
==
3
:
# 混合请求数据
elif
searchtype
==
3
:
# 混合请求数据
# 企查查数据接口Appkey,查询数据库
# 企查查数据接口Appkey,查询数据库
url
=
"http://api.qichacha.com/ECIV4/Search?key="
+
AppKey
+
"&pageSize=20"
url
=
"http://api.qichacha.com/ECIV4/Search?key="
+
AppKey
+
"&pageSize=20"
res
=
getgsbqccJSON
(
cityname
,
keyword
,
btname
,
url
,
orgname
,
sitcity
,
keywords
,
AppKey
,
SecretKey
,
cityList
,
res
=
getgsbqccJSON
(
cityname
,
keyword
,
btname
,
url
,
orgname
,
sitcity
,
keywords
,
AppKey
,
SecretKey
,
cityList
,
brandList
,
sensitiveList
,
similarCityList
,
identicalCityList
)
brandList
,
sensitiveList
,
similarCityList
,
identicalCityList
)
else
:
# 按照检索方式去查询es
res
=
getgsbJSON
(
cityname
,
keyword
,
btname
,
orgname
,
sitcity
,
keywords
,
cityList
,
brandList
,
sensitiveList
,
similarCityList
,
identicalCityList
)
else
:
else
:
point
=
0
point
=
0
similarCityList
=
[]
similarCityList
=
[]
identicalCityList
=
[]
identicalCityList
=
[]
res
=
getJSON
(
keyword
,
point
,
cityList
,
brandList
,
sensitiveList
,
similarCityList
,
identicalCityList
)
res
=
getJSON
(
keyword
,
point
,
cityList
,
brandList
,
sensitiveList
,
similarCityList
,
identicalCityList
)
print
(
"---------------------------"
,
res
)
print
(
"---------------------------"
,
res
)
return
res
return
res
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