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
d329e750
Commit
d329e750
authored
Jan 09, 2020
by
huangjing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hj
parent
2a980a75
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
15 deletions
+44
-15
calc_result/IndexGet.py
+11
-2
calc_result/RiskComputer.py
+15
-6
calc_result/Update.py
+8
-2
calc_result/main.py
+10
-5
No files found.
calc_result/IndexGet.py
View file @
d329e750
...
...
@@ -4,10 +4,19 @@
# @Author : hj
# @File : IndexGet.py
# @Software: PyCharm
import
pymysql
import
pymysql
,
os
from
IndexItem
import
IndexItem
env_dist
=
os
.
environ
#获取环境变量
FK_DB_HOST
=
env_dist
.
get
(
'FK_DB_HOST'
)
#获取mysql地址
FK_DB_PORT
=
env_dist
.
get
(
'FK_DB_PORT'
)
#获取mysql端口号
FK_DB_USER
=
env_dist
.
get
(
'FK_DB_USER'
)
#获取mysql用户名
FK_DB_PWD
=
env_dist
.
get
(
'FK_DB_PWD'
)
#获取mysql密码
FK_DB_NAME
=
env_dist
.
get
(
'FK_DB_NAME'
)
#获取mysql库
class
IndexGet
:
conn
=
pymysql
.
connect
(
host
=
'43.247.184.35'
,
port
=
8899
,
user
=
'write'
,
password
=
'write'
,
db
=
'fktaxctl'
,
charset
=
"utf8mb4"
)
conn
=
pymysql
.
connect
(
host
=
FK_DB_HOST
,
port
=
FK_DB_PORT
,
user
=
FK_DB_USER
,
password
=
FK_DB_PWD
,
db
=
FK_DB_NAME
,
charset
=
"utf8mb4"
)
def
Subscribe
(
self
,
span
,
type
):
print
(
"查询条件"
,
span
,
type
)
cursor
=
self
.
conn
.
cursor
()
...
...
calc_result/RiskComputer.py
View file @
d329e750
# coding:utf-8
from
IndexItem
import
IndexItem
from
IndexComputerFile
import
IndexComputer
import
json
,
redis
,
datetime
,
pymysql
import
json
,
redis
,
datetime
,
pymysql
,
os
env_dist
=
os
.
environ
#获取环境变量
FK_DB_HOST
=
env_dist
.
get
(
'FK_DB_HOST'
)
#获取mysql地址
FK_DB_PORT
=
env_dist
.
get
(
'FK_DB_PORT'
)
#获取mysql端口号
FK_DB_USER
=
env_dist
.
get
(
'FK_DB_USER'
)
#获取mysql用户名
FK_DB_PWD
=
env_dist
.
get
(
'FK_DB_PWD'
)
#获取mysql密码
FK_DB_NAME
=
env_dist
.
get
(
'FK_DB_NAME'
)
#获取mysql库
class
RiskComputer
:
IndexRes
=
{}
indexs
=
[]
...
...
@@ -30,7 +38,7 @@ class RiskComputer:
self
.
IndexRes
[
indexItem
.
Name
]
=
"0"
def
Ret2Json
(
self
):
#把指标结果转化为樊辉需要的Json
#json写入数据库
db
=
pymysql
.
connect
(
host
=
'43.247.184.35'
,
port
=
8899
,
user
=
'write'
,
password
=
'write'
,
db
=
'fktaxctl'
,
charset
=
"utf8mb4"
)
db
=
pymysql
.
connect
(
host
=
FK_DB_HOST
,
port
=
FK_DB_PORT
,
user
=
FK_DB_USER
,
password
=
FK_DB_PWD
,
db
=
FK_DB_NAME
,
charset
=
"utf8mb4"
)
cursor
=
db
.
cursor
()
for
key
in
self
.
IndexRes
:
sql
=
"""INSERT INTO result_set(batchno,indexName,status) VALUES ('"""
+
str
(
self
.
batch_No
)
+
"""', '"""
+
str
(
key
)
+
"""','"""
+
str
(
self
.
IndexRes
[
key
])
+
"""')"""
...
...
@@ -44,8 +52,8 @@ class RiskComputer:
# 关闭数据库连接
db
.
close
()
jsonStr
=
json
.
dumps
(
self
.
IndexRes
,
ensure_ascii
=
False
,
indent
=
4
,
separators
=
(
','
,
':'
))
#写入信息到Redis的队列中
redisPool
=
redis
.
ConnectionPool
(
host
=
'43.247.184.32'
,
port
=
8967
,
password
=
'Gongsibao2018'
,
db
=
2
)
client
=
redis
.
Redis
(
connection_pool
=
redisPool
)
client
.
lpush
(
'funcmq'
,
'{"key":'
+
str
(
datetime
.
datetime
.
now
())
+
',"content":'
+
str
(
self
.
batch_No
)
+
'}'
)
#
#
写入信息到Redis的队列中
# redisPool = redis.ConnectionPool(host=FK_REDIS_HOST
, port=8967, password='Gongsibao2018',db=2)
#
client = redis.Redis(connection_pool=redisPool)
#
client.lpush('funcmq','{"key":'+str(datetime.datetime.now())+',"content":'+str(self.batch_No)+'}')
return
jsonStr
\ No newline at end of file
calc_result/Update.py
View file @
d329e750
...
...
@@ -4,9 +4,15 @@
# @Author : hj
# @File : Update.py
# @Software: PyCharm
import
pymysql
import
pymysql
,
os
env_dist
=
os
.
environ
#获取环境变量
FK_DB_HOST
=
env_dist
.
get
(
'FK_DB_HOST'
)
#获取mysql地址
FK_DB_PORT
=
env_dist
.
get
(
'FK_DB_PORT'
)
#获取mysql端口号
FK_DB_USER
=
env_dist
.
get
(
'FK_DB_USER'
)
#获取mysql用户名
FK_DB_PWD
=
env_dist
.
get
(
'FK_DB_PWD'
)
#获取mysql密码
FK_DB_NAME
=
env_dist
.
get
(
'FK_DB_NAME'
)
#获取mysql库
class
UpdateId
:
conn
=
pymysql
.
connect
(
host
=
'43.247.184.35'
,
port
=
8899
,
user
=
'write'
,
password
=
'write'
,
db
=
'fktaxctl'
,
charset
=
"utf8mb4"
)
conn
=
pymysql
.
connect
(
host
=
FK_DB_HOST
,
port
=
FK_DB_PORT
,
user
=
FK_DB_USER
,
password
=
FK_DB_PWD
,
db
=
FK_DB_NAME
,
charset
=
"utf8mb4"
)
def
Update
(
self
,
BatchNo
):
cursor
=
self
.
conn
.
cursor
()
sql
=
"UPDATE upload_batch SET batchstatuscode = 'rptover' WHERE id =
%
s;"
...
...
calc_result/main.py
View file @
d329e750
...
...
@@ -4,11 +4,19 @@
# @Author : hj
# @File : getInfoByBatchNo.py
# @Software: PyCharm
import
requests
,
json
,
redis
,
re
import
requests
,
json
,
redis
,
re
,
os
from
RiskComputer
import
RiskComputer
from
IndexGet
import
IndexGet
from
Update
import
UpdateId
env_dist
=
os
.
environ
#获取环境变量
FK_REDIS_HOST
=
env_dist
.
get
(
'FK_REDIS_HOST'
)
#获取redis地址
FK_REDIS_PORT
=
env_dist
.
get
(
'FK_REDIS_PORT'
)
#获取redis端口号
FK_REDIS_PWD
=
env_dist
.
get
(
'FK_REDIS_PWD'
)
#获取redis密码
FK_REDIS_DB
=
env_dist
.
get
(
'FK_REDIS_DB'
)
#获取redis库
#使用任务号获取任务信息
def
getInfo_ByBatchNo
(
BatchNo
):
Info_task
=
[]
...
...
@@ -109,10 +117,7 @@ def fun(str):
fun_list
.
append
(
indexdict
)
return
fun_list
redisPool
=
redis
.
ConnectionPool
(
host
=
'43.247.184.32'
,
port
=
8967
,
password
=
'Gongsibao2018'
,
db
=
2
)
redisPool
=
redis
.
ConnectionPool
(
host
=
FK_REDIS_HOST
,
port
=
FK_REDIS_PORT
,
password
=
FK_REDIS_PWD
,
db
=
FK_REDIS_DB
)
client
=
redis
.
Redis
(
connection_pool
=
redisPool
)
a
=
client
.
lrange
(
'notifyRule'
,
-
1
,
-
1
)
print
(
a
,
"aaa"
)
...
...
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