Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
H
hh_ccs
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
贺阳
hh_ccs
Commits
df7602c3
提交
df7602c3
authored
10月 17, 2025
作者:
贺阳
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
每次获取尾程pod都新生成一条附件信息,不进行覆盖
上级
1cdc26ee
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
7 行增加
和
85 行删除
+7
-85
batch_get_pod_info_wizard.py
ccs_base/wizard/batch_get_pod_info_wizard.py
+7
-85
没有找到文件。
ccs_base/wizard/batch_get_pod_info_wizard.py
浏览文件 @
df7602c3
...
...
@@ -44,7 +44,6 @@ class BatchGetPodInfoWizard(models.TransientModel):
bl_objs
=
self
.
get_order
()
# 调用接口获取提单pdf文件
pdf_file_arr
=
self
.
_get_pdf_file_arr
()
# pdf_file_arr = self._get_pdf_file_arr_test()
if
not
pdf_file_arr
:
raise
ValidationError
(
_
(
'No PDF files found'
))
#提示:没有获取到PDF文件
# 处理PDF文件,匹配提单对象
...
...
@@ -70,72 +69,6 @@ class BatchGetPodInfoWizard(models.TransientModel):
if
self
.
sync_last_mile_pod
:
self
.
_sync_last_mile_pod
(
processed_files
)
def
_get_pdf_file_arr_test
(
self
):
"""
Get PDF file from test data # 从测试数据获取PDF文件
"""
pdf_file_arr
=
[]
bl_objs
=
self
.
get_order
()
for
bl
in
bl_objs
:
clearance_file
=
self
.
env
[
'cc.clearance.file'
]
.
sudo
()
.
search_clearance_file
(
bl
.
id
,
'尾程交接POD(待大包数量和箱号)'
)
#查找清关文件
if
clearance_file
and
clearance_file
.
file
:
try
:
# 验证原始文件数据
file_data
=
clearance_file
.
file
if
isinstance
(
file_data
,
bytes
):
# 验证PDF文件头
if
not
file_data
.
startswith
(
b
'
%
PDF-'
):
# 检查是否是base64编码的字符串
try
:
decoded_data
=
base64
.
b64decode
(
file_data
)
if
decoded_data
.
startswith
(
b
'
%
PDF-'
):
file_data
=
decoded_data
else
:
continue
except
Exception
as
e
:
continue
elif
isinstance
(
file_data
,
str
):
# 尝试base64解码
try
:
decoded_data
=
base64
.
b64decode
(
file_data
)
if
decoded_data
.
startswith
(
b
'
%
PDF-'
):
file_data
=
decoded_data
else
:
continue
except
Exception
as
e
:
continue
else
:
continue
# # 验证PDF可以打开
# try:
# import fitz
# test_doc = fitz.open(stream=file_data, filetype="pdf")
# page_count = len(test_doc)
# test_doc.close()
# _logger.info(f"清关文件PDF验证成功,页数: {page_count},提单号: {bl.bl_no}")
# except Exception as e:
# _logger.warning(f"清关文件PDF无法打开,提单号: {bl.bl_no}, 错误: {str(e)}")
# continue
# 转换为base64
file_data_base64
=
base64
.
b64encode
(
file_data
)
.
decode
(
'utf-8'
)
pdf_file_arr
.
append
({
'bl_no'
:
self
.
env
[
'common.common'
]
.
sudo
()
.
process_match_str
(
bl
.
bl_no
),
'file_name'
:
clearance_file
.
attachment_name
or
clearance_file
.
file_name
,
'file_data'
:
file_data_base64
})
except
Exception
as
e
:
_logger
.
error
(
f
"处理清关文件失败,提单号: {bl.bl_no}, 错误: {str(e)}"
)
continue
else
:
_logger
.
warning
(
f
"未找到清关文件,提单号: {bl.bl_no}"
)
return
pdf_file_arr
# 写一个方法掉接口获取提单pdf文件
def
_get_pdf_file_arr
(
self
):
"""
...
...
@@ -227,24 +160,13 @@ class BatchGetPodInfoWizard(models.TransientModel):
bl
=
file_info
[
'bl'
]
file_name
=
file_info
[
'file_name'
]
file_data
=
file_info
[
'file_data'
]
# 查找或创建清关文件记录
clearance_file
=
self
.
env
[
'cc.clearance.file'
]
.
sudo
()
.
search_clearance_file
(
bl
.
id
,
'尾程交接POD(待大包数量和箱号)'
)
if
not
clearance_file
:
# 创建新的清关文件记录
clearance_file
=
self
.
env
[
'cc.clearance.file'
]
.
create
({
'bl_id'
:
bl
.
id
,
'file_name'
:
'尾程交接POD(待大包数量和箱号)'
,
'attachment_name'
:
file_name
,
'file'
:
file_data
})
else
:
# 更新现有记录
clearance_file
.
write
({
'attachment_name'
:
file_name
,
'file'
:
file_data
})
# 创建新的清关文件记录
clearance_file
=
self
.
env
[
'cc.clearance.file'
]
.
create
({
'bl_id'
:
bl
.
id
,
'file_name'
:
'尾程交接POD(待大包数量和箱号)'
,
'attachment_name'
:
file_name
,
'file'
:
file_data
})
file_info
[
'clearance_file'
]
=
clearance_file
def
_match_bl_by_file_name
(
self
,
pdf_file_arr
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论