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):
...
@@ -286,6 +286,14 @@ class TTApi(http.Controller):
declare_type
=
kws
.
get
(
'declare_type'
)
declare_type
=
kws
.
get
(
'declare_type'
)
if
declare_type
:
if
declare_type
:
declare_type
=
declare_type
.
lower
()
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
not
bl
:
if
declare_type
==
'create'
:
if
declare_type
==
'create'
:
bl
=
request
.
env
[
'cc.bl'
]
.
sudo
()
.
create
(
bl_vals
)
bl
=
request
.
env
[
'cc.bl'
]
.
sudo
()
.
create
(
bl_vals
)
...
@@ -297,59 +305,62 @@ class TTApi(http.Controller):
...
@@ -297,59 +305,62 @@ class TTApi(http.Controller):
else
:
else
:
if
declare_type
==
'update'
and
bl
.
state
==
'draft'
:
if
declare_type
==
'update'
and
bl
.
state
==
'draft'
:
bl
.
write
(
bl_vals
)
bl
.
write
(
bl_vals
)
# 生成cc.big.package
if
bl
and
((
declare_type
==
'create'
and
len
(
exit_bl_obj
)
<=
0
)
or
(
big_bag_list
=
kws
.
get
(
'big_bag_list'
)
declare_type
==
'update'
and
bl
.
state
==
'draft'
)):
if
big_bag_list
and
len
(
big_bag_list
)
>
0
:
logging
.
info
(
'-----update big'
)
# 删除大包数据 改为sql
# 生成cc.big.package
big_package_ids
=
bl
.
big_package_ids
big_bag_list
=
kws
.
get
(
'big_bag_list'
)
where_sql
=
""
if
len
(
big_package_ids
)
<=
0
else
(
if
big_bag_list
and
len
(
big_bag_list
)
>
0
:
"where id=
%
s"
%
big_package_ids
[
0
]
.
id
if
len
(
# 删除大包数据 改为sql
big_package_ids
)
==
1
else
"where id in {0}"
.
format
(
tuple
(
big_package_ids
=
bl
.
big_package_ids
big_package_ids
.
ids
)))
where_sql
=
""
if
len
(
big_package_ids
)
<=
0
else
(
if
where_sql
and
len
(
big_package_ids
)
>
0
:
"where id=
%
s"
%
big_package_ids
[
0
]
.
id
if
len
(
del_sql
=
"delete from cc_big_package {0}"
.
format
(
where_sql
)
big_package_ids
)
==
1
else
"where id in {0}"
.
format
(
tuple
(
request
.
_cr
.
execute
(
del_sql
)
big_package_ids
.
ids
)))
request
.
_cr
.
commit
()
if
where_sql
and
len
(
big_package_ids
)
>
0
:
# for package in bl.big_package_ids:
del_sql
=
"delete from cc_big_package {0}"
.
format
(
where_sql
)
# package.bl_id = False
request
.
_cr
.
execute
(
del_sql
)
# package.unlink()
request
.
_cr
.
commit
()
# 本身提单的小包解除关联
# for package in bl.big_package_ids:
for
ship
in
bl
.
ship_package_ids
:
# package.bl_id = False
ship
.
bl_id
=
False
# package.unlink()
ship
.
big_package_id
=
False
# 本身提单的小包解除关联
for
big_bag
in
big_bag_list
:
for
ship
in
bl
.
ship_package_ids
:
big_bag_no
=
big_bag
.
get
(
'big_bag_no'
)
ship
.
bl_id
=
False
# 检查big_bag_no是否已经存在
ship
.
big_package_id
=
False
big_package_vals
=
dict
(
bl_id
=
bl
.
id
,
for
big_bag
in
big_bag_list
:
big_package_no
=
big_bag
.
get
(
'big_bag_no'
),
big_bag_no
=
big_bag
.
get
(
'big_bag_no'
)
next_provider_name
=
big_bag
.
get
(
'next_provider_name'
))
# 检查big_bag_no是否已经存在
big_package
=
request
.
env
[
'cc.big.package'
]
.
sudo
()
.
search
(
big_package_vals
=
dict
(
bl_id
=
bl
.
id
,
[(
'big_package_no'
,
'='
,
big_bag_no
)],
limit
=
1
)
big_package_no
=
big_bag
.
get
(
'big_bag_no'
),
if
not
big_package
:
next_provider_name
=
big_bag
.
get
(
'next_provider_name'
))
big_package
=
request
.
env
[
'cc.big.package'
]
.
sudo
()
.
create
(
big_package_vals
)
big_package
=
request
.
env
[
'cc.big.package'
]
.
sudo
()
.
search
(
else
:
[(
'big_package_no'
,
'='
,
big_bag_no
)],
limit
=
1
)
big_package
.
write
(
big_package_vals
)
if
not
big_package
:
# 生成cc.ship.package
big_package
=
request
.
env
[
'cc.big.package'
]
.
sudo
()
.
create
(
big_package_vals
)
package_list
=
big_bag
.
get
(
'package_list'
)
# 大包下的小包
else
:
if
package_list
and
len
(
package_list
)
>
0
:
big_package
.
write
(
big_package_vals
)
package_ids
=
[
package
.
get
(
'provider_order_id'
)
for
package
in
package_list
]
# 生成cc.ship.package
ship_packages
=
request
.
env
[
'cc.ship.package'
]
.
sudo
()
.
search
(
package_list
=
big_bag
.
get
(
'package_list'
)
# 大包下的小包
[(
'logistic_order_no'
,
'in'
,
package_ids
)])
if
package_list
and
len
(
package_list
)
>
0
:
if
ship_packages
and
len
(
ship_packages
)
>
0
:
package_ids
=
[
package
.
get
(
'provider_order_id'
)
for
package
in
package_list
]
ship_packages
.
write
(
ship_packages
=
request
.
env
[
'cc.ship.package'
]
.
sudo
()
.
search
(
{
'is_cancel'
:
False
,
'cancel_reason'
:
False
,
'big_package_id'
:
big_package
.
id
,
[(
'logistic_order_no'
,
'in'
,
package_ids
)])
'bl_id'
:
big_package
.
bl_id
.
id
})
if
ship_packages
and
len
(
ship_packages
)
>
0
:
if
len
(
package_ids
)
!=
len
(
ship_packages
):
ship_packages
.
write
(
# 找出ship_packages没有找到的package
{
'is_cancel'
:
False
,
'cancel_reason'
:
False
,
'big_package_id'
:
big_package
.
id
,
package_ids
=
set
(
package_ids
)
'bl_id'
:
big_package
.
bl_id
.
id
})
ship_package_ids
=
set
(
if
len
(
package_ids
)
!=
len
(
ship_packages
):
[
ship_package
.
logistic_order_no
for
ship_package
in
ship_packages
])
# 找出ship_packages没有找到的package
diff_ids
=
package_ids
-
ship_package_ids
package_ids
=
set
(
package_ids
)
_logger
.
info
(
'diff_ids:
%
s'
%
diff_ids
)
ship_package_ids
=
set
(
else
:
[
ship_package
.
logistic_order_no
for
ship_package
in
ship_packages
])
res
[
'msg'
]
=
'Big bag [
%
s] not include any package. '
%
big_bag
.
get
(
'big_bag_no'
)
diff_ids
=
package_ids
-
ship_package_ids
else
:
_logger
.
info
(
'diff_ids:
%
s'
%
diff_ids
)
res
[
'msg'
]
=
'Big bag list is empty.'
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
:
except
Exception
as
e
:
res
[
'code'
]
=
5000
res
[
'code'
]
=
5000
res
[
'msg'
]
=
'system error:
%
s'
%
str
(
e
)
res
[
'msg'
]
=
'system error:
%
s'
%
str
(
e
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论