Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
岳巧源
/
europa-erp-python
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
389fb0e9
authored
Jun 23, 2025
by
刘豪
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
update
parent
66f5e99e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
24 deletions
rs_data.py
rs_data.py
View file @
389fb0e9
...
...
@@ -194,25 +194,36 @@ def get_supplier_id(supplier_name: str, conf: dict) -> int:
db
.
close
()
return
supplier_id
def
down_cn
(
ftp_client
,
extract_dir
):
"""download the zip file"""
logger
.
info
(
"下载cn压缩包"
)
ftp_client
.
download
(
remote_file_name_3
,
conf_environment
[
"tmp_file_path"
]
+
local_file_name_3
)
"""unzip the zip file"""
try
:
logger
.
info
(
"解压压缩包"
)
file_handle
.
unzip
(
conf_environment
[
"tmp_file_path"
]
+
local_file_name_3
,
extract_dir
)
"""handle the file and then post to rabbitmq"""
rs_hk_supplier_id
=
get_supplier_id
(
supplier_name
=
'Rs'
,
conf
=
conf_environment
)
rs_cn_supplier_id
=
get_supplier_id
(
supplier_name
=
'RS-CN'
,
conf
=
conf_environment
)
if
rs_cn_supplier_id
==
-
1
or
rs_hk_supplier_id
==
-
1
:
logger
.
info
(
"不支持的supplier_id"
)
sys
.
exit
(
"can't query the correct supplier id."
)
handle_cn_csv
(
extract_dir
+
handle_file_name_3
,
conf_environment
,
rs_cn_supplier_id
)
except
Exception
as
e
:
logger
.
error
(
"报错:{}"
.
format
(
e
))
def
down_
and_handle
(
ftp_client
):
def
down_
hk
(
ftp_client
,
extract_dir
):
"""download the zip file"""
logger
.
info
(
"下载压缩包"
)
extract_dir
=
conf_environment
[
"tmp_file_path"
]
+
"extract/"
# ftp_client.download(remote_file_name_1, conf_environment["tmp_file_path"] + local_file_name_1)
logger
.
info
(
"下载hk压缩包"
)
ftp_client
.
download
(
remote_file_name_
3
,
conf_environment
[
"tmp_file_path"
]
+
local_file_name_3
)
ftp_client
.
download
(
remote_file_name_
1
,
conf_environment
[
"tmp_file_path"
]
+
local_file_name_1
)
if
not
os
.
path
.
exists
(
extract_dir
):
os
.
makedirs
(
extract_dir
)
"""unzip the zip file"""
try
:
logger
.
info
(
"解压压缩包"
)
# file_handle.unzip(conf_environment["tmp_file_path"] + local_file_name_1, extract_dir)
file_handle
.
unzip
(
conf_environment
[
"tmp_file_path"
]
+
local_file_name_3
,
extract_dir
)
logger
.
info
(
"解压hk压缩包"
)
file_handle
.
unzip
(
conf_environment
[
"tmp_file_path"
]
+
local_file_name_1
,
extract_dir
)
"""handle the file and then post to rabbitmq"""
rs_hk_supplier_id
=
get_supplier_id
(
supplier_name
=
'Rs'
,
conf
=
conf_environment
)
...
...
@@ -220,19 +231,9 @@ def down_and_handle(ftp_client):
if
rs_cn_supplier_id
==
-
1
or
rs_hk_supplier_id
==
-
1
:
logger
.
info
(
"不支持的supplier_id"
)
sys
.
exit
(
"can't query the correct supplier id."
)
# handle_hk_csv(extract_dir + handle_file_name_1, conf_environment, rs_hk_supplier_id)
handle_cn_csv
(
extract_dir
+
handle_file_name_3
,
conf_environment
,
rs_cn_supplier_id
)
handle_hk_csv
(
extract_dir
+
handle_file_name_1
,
conf_environment
,
rs_hk_supplier_id
)
except
Exception
as
e
:
remove_file
(
extract_dir
)
logger
.
error
(
"报错:{}, 重试"
.
format
(
e
))
ftp_client
=
ftp
.
FTPUtil
(
host
=
conf_environment
[
"ftp"
][
"host"
],
port
=
conf_environment
[
"ftp"
][
"port"
],
passive
=
True
,
username
=
conf_environment
[
"ftp"
][
"username"
],
password
=
conf_environment
[
"ftp"
][
"password"
],
logger
=
logger
)
down_and_handle
(
ftp_client
)
return
extract_dir
logger
.
error
(
"报错:{}"
.
format
(
e
))
def
remove_file
(
extract_dir
):
"""remove the temp file, close the connection"""
...
...
@@ -251,7 +252,11 @@ def run():
logger
=
logger
)
if
not
os
.
path
.
exists
(
conf_environment
[
"tmp_file_path"
]):
os
.
makedirs
(
conf_environment
[
"tmp_file_path"
])
extract_dir
=
down_and_handle
(
ftp_client
)
extract_dir
=
conf_environment
[
"tmp_file_path"
]
+
"extract/"
if
not
os
.
path
.
exists
(
extract_dir
):
os
.
makedirs
(
extract_dir
)
down_cn
(
ftp_client
,
extract_dir
)
down_hk
(
ftp_client
,
extract_dir
)
remove_file
(
extract_dir
)
logger
.
info
(
"运行完成"
)
...
...
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