Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
financial-system
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xianyang
financial-system
Commits
64966efe
Commit
64966efe
authored
Apr 26, 2023
by
xianyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化tcp清算
parent
1eb193e6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
1 deletion
+39
-1
env.py
core/config/env.py
+4
-0
functions.py
libs/functions.py
+35
-1
No files found.
core/config/env.py
View file @
64966efe
...
...
@@ -64,6 +64,8 @@ class TestingEnv(Env):
PASSWORD
:
str
=
"fj123456"
oss_url
=
'http://oss.3yakj.com/application_static_data'
CLEARING_CENTER_URL
:
str
=
'http://106.55.103.148:6464/'
CLEARING_CENTER_HOST
:
str
=
'106.55.103.148'
CLEARING_CENTER_PORT
:
int
=
6464
class
ProdEnv
(
Env
):
...
...
@@ -84,6 +86,8 @@ class ProdEnv(Env):
ALGORITHM
:
str
=
"HS256"
PASSWORD
:
str
=
"fj123456"
CLEARING_CENTER_URL
:
str
=
'http://47.103.144.36:5454/'
CLEARING_CENTER_HOST
:
str
=
'106.55.103.148'
CLEARING_CENTER_PORT
:
int
=
6464
# env = TestingEnv() # 开发环境
...
...
libs/functions.py
View file @
64966efe
...
...
@@ -98,7 +98,7 @@ def wrapper_out():
def
search
(
params
,
method
):
"""
调用清算接口
调用清算接口
http
:param params: 传入参数
:param method: 传入方法
"""
...
...
@@ -116,6 +116,39 @@ def search(params, method):
return
text
def
send_json_rpc_request
(
params
,
method
):
"""
调用清算接口tcp
:param params: 传入参数
:param method: 传入方法
"""
with
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
as
s
:
s
.
connect
((
env
.
CLEARING_CENTER_HOST
,
env
.
CLEARING_CENTER_PORT
))
request
=
{
"jsonrpc"
:
"2.0"
,
"method"
:
method
,
"params"
:
params
,
"id"
:
'125'
}
# 将请求对象编码为 JSON 字符串
request_str
=
json
.
dumps
(
request
)
+
"
\n
"
# test协议一定要加\n
# 发送 JSON-RPC 请求
s
.
sendall
(
request_str
.
encode
())
# 接收服务器响应
response_str
=
s
.
recv
(
1024
)
.
decode
()
# 将响应字符串解码为 JSON 对象
response
=
json
.
loads
(
response_str
)
if
"error"
in
response
:
return
{}
return
response
[
"result"
]
def
get_ip
():
res
=
socket
.
gethostbyname
(
socket
.
gethostname
())
return
res
...
...
@@ -133,6 +166,7 @@ def get_month_last_month(month_type,start_time,end_time):
print
(
last_month
,
now_month
)
return
last_month
,
now_month
def
time_format
(
utc_timestamp
:
int
):
days
=
(
utc_timestamp
+
3600
*
8
)
%
86400
hours
=
int
(
days
/
3600
)
...
...
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