Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
H
hh_ccs
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
贺阳
hh_ccs
Commits
06b9d598
提交
06b9d598
authored
9月 25, 2024
作者:
贺阳
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
检查 如果类型是create 根据提单号和大包数量查询到了数据 就不做处理
上级
ffa12d84
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
64 行增加
和
53 行删除
+64
-53
tt_controllers.py
ccs_connect_tiktok/controllers/tt_controllers.py
+64
-53
没有找到文件。
ccs_connect_tiktok/controllers/tt_controllers.py
浏览文件 @
06b9d598
...
...
@@ -286,6 +286,14 @@ class TTApi(http.Controller):
declare_type
=
kws
.
get
(
'declare_type'
)
if
declare_type
:
declare_type
=
declare_type
.
lower
()
exit_bl_obj
=
[]
if
declare_type
==
'create'
:
# 检查 如果类型是create 根据提单号和大包数量查询到了数据 就不做处理
select_bl_sql
=
"""select id from cc_bl where bl_no='{0}' and big_package_qty={1};"""
.
format
(
kws
.
get
(
'master_waybill_no'
),
kws
.
get
(
'big_bag_quantity'
))
request
.
_cr
.
execute
(
select_bl_sql
)
exit_bl_obj
=
request
.
_cr
.
fetchall
()
logging
.
info
(
'select_bl_sql:
%
s,exit_bl_obj:
%
s'
%
(
select_bl_sql
,
exit_bl_obj
))
if
not
bl
:
if
declare_type
==
'create'
:
bl
=
request
.
env
[
'cc.bl'
]
.
sudo
()
.
create
(
bl_vals
)
...
...
@@ -297,59 +305,62 @@ class TTApi(http.Controller):
else
:
if
declare_type
==
'update'
and
bl
.
state
==
'draft'
:
bl
.
write
(
bl_vals
)
# 生成cc.big.package
big_bag_list
=
kws
.
get
(
'big_bag_list'
)
if
big_bag_list
and
len
(
big_bag_list
)
>
0
:
# 删除大包数据 改为sql
big_package_ids
=
bl
.
big_package_ids
where_sql
=
""
if
len
(
big_package_ids
)
<=
0
else
(
"where id=
%
s"
%
big_package_ids
[
0
]
.
id
if
len
(
big_package_ids
)
==
1
else
"where id in {0}"
.
format
(
tuple
(
big_package_ids
.
ids
)))
if
where_sql
and
len
(
big_package_ids
)
>
0
:
del_sql
=
"delete from cc_big_package {0}"
.
format
(
where_sql
)
request
.
_cr
.
execute
(
del_sql
)
request
.
_cr
.
commit
()
# for package in bl.big_package_ids:
# package.bl_id = False
# package.unlink()
# 本身提单的小包解除关联
for
ship
in
bl
.
ship_package_ids
:
ship
.
bl_id
=
False
ship
.
big_package_id
=
False
for
big_bag
in
big_bag_list
:
big_bag_no
=
big_bag
.
get
(
'big_bag_no'
)
# 检查big_bag_no是否已经存在
big_package_vals
=
dict
(
bl_id
=
bl
.
id
,
big_package_no
=
big_bag
.
get
(
'big_bag_no'
),
next_provider_name
=
big_bag
.
get
(
'next_provider_name'
))
big_package
=
request
.
env
[
'cc.big.package'
]
.
sudo
()
.
search
(
[(
'big_package_no'
,
'='
,
big_bag_no
)],
limit
=
1
)
if
not
big_package
:
big_package
=
request
.
env
[
'cc.big.package'
]
.
sudo
()
.
create
(
big_package_vals
)
else
:
big_package
.
write
(
big_package_vals
)
# 生成cc.ship.package
package_list
=
big_bag
.
get
(
'package_list'
)
# 大包下的小包
if
package_list
and
len
(
package_list
)
>
0
:
package_ids
=
[
package
.
get
(
'provider_order_id'
)
for
package
in
package_list
]
ship_packages
=
request
.
env
[
'cc.ship.package'
]
.
sudo
()
.
search
(
[(
'logistic_order_no'
,
'in'
,
package_ids
)])
if
ship_packages
and
len
(
ship_packages
)
>
0
:
ship_packages
.
write
(
{
'is_cancel'
:
False
,
'cancel_reason'
:
False
,
'big_package_id'
:
big_package
.
id
,
'bl_id'
:
big_package
.
bl_id
.
id
})
if
len
(
package_ids
)
!=
len
(
ship_packages
):
# 找出ship_packages没有找到的package
package_ids
=
set
(
package_ids
)
ship_package_ids
=
set
(
[
ship_package
.
logistic_order_no
for
ship_package
in
ship_packages
])
diff_ids
=
package_ids
-
ship_package_ids
_logger
.
info
(
'diff_ids:
%
s'
%
diff_ids
)
else
:
res
[
'msg'
]
=
'Big bag [
%
s] not include any package. '
%
big_bag
.
get
(
'big_bag_no'
)
else
:
res
[
'msg'
]
=
'Big bag list is empty.'
if
bl
and
((
declare_type
==
'create'
and
len
(
exit_bl_obj
)
<=
0
)
or
(
declare_type
==
'update'
and
bl
.
state
==
'draft'
)):
logging
.
info
(
'-----update big'
)
# 生成cc.big.package
big_bag_list
=
kws
.
get
(
'big_bag_list'
)
if
big_bag_list
and
len
(
big_bag_list
)
>
0
:
# 删除大包数据 改为sql
big_package_ids
=
bl
.
big_package_ids
where_sql
=
""
if
len
(
big_package_ids
)
<=
0
else
(
"where id=
%
s"
%
big_package_ids
[
0
]
.
id
if
len
(
big_package_ids
)
==
1
else
"where id in {0}"
.
format
(
tuple
(
big_package_ids
.
ids
)))
if
where_sql
and
len
(
big_package_ids
)
>
0
:
del_sql
=
"delete from cc_big_package {0}"
.
format
(
where_sql
)
request
.
_cr
.
execute
(
del_sql
)
request
.
_cr
.
commit
()
# for package in bl.big_package_ids:
# package.bl_id = False
# package.unlink()
# 本身提单的小包解除关联
for
ship
in
bl
.
ship_package_ids
:
ship
.
bl_id
=
False
ship
.
big_package_id
=
False
for
big_bag
in
big_bag_list
:
big_bag_no
=
big_bag
.
get
(
'big_bag_no'
)
# 检查big_bag_no是否已经存在
big_package_vals
=
dict
(
bl_id
=
bl
.
id
,
big_package_no
=
big_bag
.
get
(
'big_bag_no'
),
next_provider_name
=
big_bag
.
get
(
'next_provider_name'
))
big_package
=
request
.
env
[
'cc.big.package'
]
.
sudo
()
.
search
(
[(
'big_package_no'
,
'='
,
big_bag_no
)],
limit
=
1
)
if
not
big_package
:
big_package
=
request
.
env
[
'cc.big.package'
]
.
sudo
()
.
create
(
big_package_vals
)
else
:
big_package
.
write
(
big_package_vals
)
# 生成cc.ship.package
package_list
=
big_bag
.
get
(
'package_list'
)
# 大包下的小包
if
package_list
and
len
(
package_list
)
>
0
:
package_ids
=
[
package
.
get
(
'provider_order_id'
)
for
package
in
package_list
]
ship_packages
=
request
.
env
[
'cc.ship.package'
]
.
sudo
()
.
search
(
[(
'logistic_order_no'
,
'in'
,
package_ids
)])
if
ship_packages
and
len
(
ship_packages
)
>
0
:
ship_packages
.
write
(
{
'is_cancel'
:
False
,
'cancel_reason'
:
False
,
'big_package_id'
:
big_package
.
id
,
'bl_id'
:
big_package
.
bl_id
.
id
})
if
len
(
package_ids
)
!=
len
(
ship_packages
):
# 找出ship_packages没有找到的package
package_ids
=
set
(
package_ids
)
ship_package_ids
=
set
(
[
ship_package
.
logistic_order_no
for
ship_package
in
ship_packages
])
diff_ids
=
package_ids
-
ship_package_ids
_logger
.
info
(
'diff_ids:
%
s'
%
diff_ids
)
else
:
res
[
'msg'
]
=
'Big bag [
%
s] not include any package. '
%
big_bag
.
get
(
'big_bag_no'
)
else
:
res
[
'msg'
]
=
'Big bag list is empty.'
except
Exception
as
e
:
res
[
'code'
]
=
5000
res
[
'msg'
]
=
'system error:
%
s'
%
str
(
e
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论