Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
H
hh_ccs
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
贺阳
hh_ccs
Commits
ac040816
提交
ac040816
authored
6月 11, 2025
作者:
贺阳
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加修改尾程快递的大包理货信息的接口
上级
2ffcf83d
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
164 行增加
和
12 行删除
+164
-12
order_controller.py
ccs_connect_tiktok/controllers/order_controller.py
+146
-2
cc_bill_loading.py
ccs_connect_tiktok/models/cc_bill_loading.py
+13
-9
mail_push.py
consumers/mail_push.py
+5
-1
没有找到文件。
ccs_connect_tiktok/controllers/order_controller.py
浏览文件 @
ac040816
...
@@ -90,7 +90,6 @@ class OrderController(http.Controller):
...
@@ -90,7 +90,6 @@ class OrderController(http.Controller):
def
bl_info
(
self
):
def
bl_info
(
self
):
"""
"""
查看提单以及大包,小包和托盘信息
查看提单以及大包,小包和托盘信息
:param kwargs:
:return:
:return:
"""
"""
kwargs
=
json
.
loads
(
request
.
httprequest
.
data
)
kwargs
=
json
.
loads
(
request
.
httprequest
.
data
)
...
@@ -299,6 +298,152 @@ class OrderController(http.Controller):
...
@@ -299,6 +298,152 @@ class OrderController(http.Controller):
logging
.
info
(
'res:
%
s'
%
res
)
logging
.
info
(
'res:
%
s'
%
res
)
return
res
return
res
@http.route
(
'/api/update/pro/big/package/tally/detail'
,
type
=
'json'
,
auth
=
'public'
,
methods
=
[
'GET'
,
'POST'
],
csrf
=
False
)
def
update_pro_big_package_tally_detail
(
self
):
"""
修改尾程快递的理货信息
:return:
"""
kwargs
=
json
.
loads
(
request
.
httprequest
.
data
)
pda_lang
=
kwargs
.
get
(
'pda_lang'
)
or
'zh'
res
=
{
'state'
:
201
,
'message'
:
''
}
action_type
=
kwargs
.
get
(
'action_type'
)
or
'tally'
# tally / handover
try
:
logging
.
info
(
'update_pro_big_package_tally_detail kw:
%
s'
%
kwargs
)
if
action_type
and
(
kwargs
.
get
(
'big_package_arr'
)
or
kwargs
.
get
(
'ship_package_arr'
)):
ship_packages
=
[]
big_package_exception_arr
=
{}
ship_package_exception_arr
=
{}
# 处理包裹信息
def
process_packages
(
package_arr
,
package_type
,
ship_packages
):
error_no_set
=
set
()
# 使用集合来存储错误信息
for
package_item
in
package_arr
:
file_str
=
'big_package_no'
if
package_type
==
'big'
else
(
'logistic_order_no'
if
package_type
==
'ship'
else
'pallet_number'
)
# 大包号/物流订单号
package_no
=
package_item
.
get
(
file_str
)
# 包裹号
exception_cause_ids
=
package_item
.
get
(
'exception_cause_ids'
)
# 异常原因id数组
package_obj
=
request
.
env
[
f
'cc.{package_type}.package'
]
.
sudo
()
.
search
(
[(
file_str
,
'='
,
package_no
)])
# 小包/大包 1个
if
package_obj
:
if
exception_cause_ids
:
for
excep_item
in
exception_cause_ids
:
if
package_type
==
'ship'
:
if
excep_item
not
in
ship_package_exception_arr
:
ship_package_exception_arr
[
excep_item
]
=
[
]
ship_package_exception_arr
[
excep_item
]
+=
package_obj
.
ids
else
:
if
excep_item
not
in
big_package_exception_arr
:
big_package_exception_arr
[
excep_item
]
=
[
]
big_package_exception_arr
[
excep_item
]
+=
package_obj
.
ids
package_obj
.
update_exception_info
(
exception_cause_ids
)
# 修改异常信息
tally_time
=
package_item
.
get
(
'tally_time'
)
if
(
action_type
==
'tally'
and
package_item
.
get
(
'tally_state'
)
==
'checked_goods'
)
or
(
action_type
==
'handover'
and
package_item
.
get
(
'tally_state'
)
==
'handover_completed'
):
if
package_type
==
'ship'
:
ship_packages
.
append
({
'id'
:
[
package_obj
.
id
],
'bl_id'
:
package_obj
.
bl_id
.
id
,
'tally_time'
:
tally_time
})
else
:
for
package
in
package_obj
:
if
(
action_type
==
'tally'
and
package
.
tally_state
==
'unprocessed_goods'
)
or
(
action_type
==
'handover'
and
package
.
tally_state
in
(
'unprocessed_goods'
,
'checked_goods'
)):
ship_packages
.
append
({
'id'
:
package
.
ship_package_ids
.
ids
,
'bl_id'
:
package
.
bl_id
.
id
,
'tally_time'
:
tally_time
})
# 小包
package_obj
.
update_big_package_info
(
action_type
=
action_type
,
tally_state
=
package_item
.
get
(
'tally_state'
),
tally_user_id
=
package_item
.
get
(
'tally_user_id'
),
tally_time
=
tally_time
)
# 修改理货信息
else
:
error_no_set
.
add
(
package_no
)
return
error_no_set
# 处理小包、大包
if
kwargs
.
get
(
'ship_package_arr'
):
error_no_arr
=
process_packages
(
kwargs
[
'ship_package_arr'
],
'ship'
,
ship_packages
)
if
error_no_arr
:
res
[
'message'
]
=
{
'en'
:
'Ship package number [
%
s] does not exist'
%
','
.
join
(
error_no_arr
),
'zh'
:
'小包物流订单号[
%
s]不存在'
%
','
.
join
(
error_no_arr
)
}[
pda_lang
]
return
res
if
kwargs
.
get
(
'big_package_arr'
):
error_no_arr
=
process_packages
(
kwargs
[
'big_package_arr'
],
'big'
,
ship_packages
)
if
error_no_arr
:
res
[
'message'
]
=
{
'en'
:
'Big package number [
%
s] does not exist'
%
','
.
join
(
error_no_arr
),
'zh'
:
'大包号[
%
s]不存在'
%
','
.
join
(
error_no_arr
)
}[
pda_lang
]
return
res
# 修改异常原因,发送异常邮件
lang
=
'zh_CN'
if
pda_lang
==
'zh'
else
'en_US'
# 语言
for
exception_id
,
big_package
in
big_package_exception_arr
.
items
():
if
big_package
:
big_wizard_obj
=
request
.
env
[
'add.exception.info.wizard'
]
.
sudo
()
.
with_context
({
'active_id'
:
big_package
,
'active_name'
:
'cc.big.package'
,
'not_update_ex'
:
True
})
.
create_add_exception_wizard
(
'big package'
,
[
exception_id
],
big_package_ids
=
big_package
,
send_email
=
True
,
email_language
=
lang
)
big_wizard_obj
.
confirm
()
# 发送邮件
for
exception_id
,
ship_package
in
ship_package_exception_arr
.
items
():
if
ship_package
:
ship_wizard_obj
=
request
.
env
[
'add.exception.info.wizard'
]
.
sudo
()
.
with_context
({
'active_id'
:
ship_package
,
'active_name'
:
'cc.ship.package'
,
'not_update_ex'
:
True
})
.
create_add_exception_wizard
(
'ship package'
,
[
exception_id
],
ship_package_ids
=
ship_package
,
send_email
=
True
,
email_language
=
lang
)
ship_wizard_obj
.
confirm
()
# 发送邮件
res
[
'state'
]
=
200
logging
.
info
(
'update_big_package_tally_detail ship_packages:
%
s'
%
len
(
ship_packages
))
# 有小包 就更新小包状态和同步
if
ship_packages
:
redis_conn
=
request
.
env
[
'common.common'
]
.
sudo
()
.
get_redis
()
if
redis_conn
and
redis_conn
!=
'no'
:
# redis_conn.lpush('push_ship_package_state', json.dumps(
# {'bl_id': bl_obj.id, 'ship_package_ids': ship_package_ids}))
bl_ids
=
[
ship_package
.
get
(
'bl_id'
)
for
ship_package
in
ship_packages
]
logging
.
info
(
'bl_ids:
%
s'
%
bl_ids
)
redis_conn
.
lpush
(
'mail_push_package_list'
,
json
.
dumps
(
{
'ids'
:
list
(
set
(
bl_ids
)),
'ship_packages'
:
str
(
ship_packages
),
'action_type'
:
action_type
}))
else
:
null_msg_dic
=
{
'en'
:
'The bill of lading number and action type must be provided; at least one of the following is required: big package data or ship package data.'
,
'zh'
:
'类型必须提供;大包数据或小包数据至少需要提供一个。'
}
res
[
'message'
]
=
null_msg_dic
[
pda_lang
]
except
Exception
as
e
:
logging
.
info
(
'update_pro_big_package_tally_detail error:
%
s'
%
e
)
exceptions_msg_dic
=
{
'en'
:
'System parsing error, the reason for the error is
%
s'
%
e
,
'zh'
:
'系统解析错误,错误原因是
%
s'
%
e
}
res
[
'message'
]
=
exceptions_msg_dic
[
pda_lang
]
logging
.
info
(
'res:
%
s'
%
res
)
return
res
@http.route
(
'/api/exceptions/info'
,
type
=
'json'
,
auth
=
'public'
,
methods
=
[
'GET'
,
'POST'
],
csrf
=
False
)
@http.route
(
'/api/exceptions/info'
,
type
=
'json'
,
auth
=
'public'
,
methods
=
[
'GET'
,
'POST'
],
csrf
=
False
)
def
exceptions_info
(
self
):
def
exceptions_info
(
self
):
"""
"""
...
@@ -396,7 +541,6 @@ class OrderController(http.Controller):
...
@@ -396,7 +541,6 @@ class OrderController(http.Controller):
group_dict
[
key
][
'ship_package_arr'
]
=
[]
group_dict
[
key
][
'ship_package_arr'
]
=
[]
group_dict
[
key
][
'count'
]
+=
1
group_dict
[
key
][
'count'
]
+=
1
group_dict
[
key
][
'big_package_arr'
]
.
append
(
pkg
.
search_big_package_info
(
pda_lang
=
pda_lang
,
type
=
tally_state
))
group_dict
[
key
][
'big_package_arr'
]
.
append
(
pkg
.
search_big_package_info
(
pda_lang
=
pda_lang
,
type
=
tally_state
))
print
(
'pkg.ship_package_ids:
%
s'
%
pkg
.
ship_package_ids
)
group_dict
[
key
][
'ship_package_arr'
]
.
extend
(
group_dict
[
key
][
'ship_package_arr'
]
.
extend
(
[
ship_package_item
.
search_ship_package_info
(
pda_lang
=
pda_lang
)
for
ship_package_item
in
[
ship_package_item
.
search_ship_package_info
(
pda_lang
=
pda_lang
)
for
ship_package_item
in
pkg
.
ship_package_ids
])
pkg
.
ship_package_ids
])
...
...
ccs_connect_tiktok/models/cc_bill_loading.py
浏览文件 @
ac040816
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
import
asyncio
import
asyncio
import
json
import
logging
import
logging
import
ssl
import
ssl
from
datetime
import
timedelta
,
datetime
from
datetime
import
timedelta
,
datetime
import
json
import
aiohttp
import
aiohttp
import
certifi
import
certifi
import
pytz
import
pytz
...
@@ -606,19 +607,22 @@ class CcBl(models.Model):
...
@@ -606,19 +607,22 @@ class CcBl(models.Model):
# package_order = self.env['cc.ship.package'].sudo().browse(package_id)
# package_order = self.env['cc.ship.package'].sudo().browse(package_id)
if
response_data
[
'code'
]
!=
0
:
if
response_data
[
'code'
]
!=
0
:
# package_order.is_sync = False
# package_order.is_sync = False
update_false_arr
.
append
(
package_id
)
# 更新 is_sync为 False
update_false_arr
.
append
(
package_id
)
# 更新 is_sync为 False
error_msg
=
response_data
[
'msg'
]
error_msg
=
response_data
[
'msg'
]
request_id
=
response_data
[
'requestID'
]
request_id
=
response_data
[
'requestID'
]
create_api_log_value_arr
.
append
((
tracking_no
,
utc_time
,
'小包状态轨迹回传:'
+
error_msg
,
False
,
data_text
,
request_id
,
'推出'
,
utc_time
))
create_api_log_value_arr
.
append
((
tracking_no
,
utc_time
,
'小包状态轨迹回传:'
+
error_msg
,
False
,
data_text
,
request_id
,
'推出'
,
utc_time
))
is_ok
=
False
is_ok
=
False
else
:
else
:
# 回传成功
# 回传成功
update_true_arr
.
append
(
package_id
)
# 更新 is_sync为 True
update_true_arr
.
append
(
package_id
)
# 更新 is_sync为 True
state_arr
=
package_node_result_dict
.
get
(
state
,
[])
state_arr
=
package_node_result_dict
.
get
(
state
,
[])
tk_code
=
state_arr
[
1
]
if
state_arr
else
''
tk_code
=
state_arr
[
1
]
if
state_arr
else
''
create_sync_log_value_arr
.
append
((
package_id
,
utc_time
,
'Tiktok'
,
tk_code
,
process_time
,
state_explain
,
user_id
))
create_sync_log_value_arr
.
append
(
(
package_id
,
utc_time
,
'Tiktok'
,
tk_code
,
process_time
,
state_explain
,
user_id
))
request_id
=
response_data
[
'requestID'
]
request_id
=
response_data
[
'requestID'
]
create_api_log_value_arr
.
append
((
tracking_no
,
utc_time
,
''
,
True
,
data_text
,
request_id
,
'推出'
,
utc_time
))
create_api_log_value_arr
.
append
(
(
tracking_no
,
utc_time
,
''
,
True
,
data_text
,
request_id
,
'推出'
,
utc_time
))
if
update_false_arr
:
if
update_false_arr
:
update_false_ids
=
'(
%
s)'
%
str
(
update_false_arr
)[
1
:
-
1
]
update_false_ids
=
'(
%
s)'
%
str
(
update_false_arr
)[
1
:
-
1
]
sql
=
"update cc_ship_package set is_sync=False where id in
%
s"
%
update_false_ids
sql
=
"update cc_ship_package set is_sync=False where id in
%
s"
%
update_false_ids
...
@@ -831,10 +835,10 @@ class CcBl(models.Model):
...
@@ -831,10 +835,10 @@ class CcBl(models.Model):
item
.
push_clear_customs_start
(
before_utc_time
)
item
.
push_clear_customs_start
(
before_utc_time
)
user_obj
=
self
.
env
[
'res.users'
]
.
search
([(
'login'
,
'='
,
mail_db_user
)],
limit
=
1
)
user_obj
=
self
.
env
[
'res.users'
]
.
search
([(
'login'
,
'='
,
mail_db_user
)],
limit
=
1
)
# 尝试调用 callback_track
# 尝试调用 callback_track
if
self
.
try_callback_track
(
user_obj
=
user_obj
):
if
item
.
try_callback_track
(
user_obj
=
user_obj
):
item
.
push_clear_customs_end
(
utc_time
)
item
.
push_clear_customs_end
(
utc_time
)
# 再次尝试调用 callback_track
# 再次尝试调用 callback_track
if
not
self
.
try_callback_track
(
user_obj
=
user_obj
):
if
not
item
.
try_callback_track
(
user_obj
=
user_obj
):
logging
.
error
(
f
"Failed to push item after {3} attempts."
)
logging
.
error
(
f
"Failed to push item after {3} attempts."
)
else
:
else
:
logging
.
error
(
f
"Failed to start process for item after {3} attempts."
)
logging
.
error
(
f
"Failed to start process for item after {3} attempts."
)
...
@@ -914,7 +918,7 @@ class CcBl(models.Model):
...
@@ -914,7 +918,7 @@ class CcBl(models.Model):
self
.
env
.
cr
.
execute
(
sql
)
self
.
env
.
cr
.
execute
(
sql
)
self
.
_cr
.
commit
()
# 提交事务
self
.
_cr
.
commit
()
# 提交事务
self
.
try_callback_track
(
max_retries
=
2
,
ship_package_ids
=
ship_package_ids
,
item
.
try_callback_track
(
max_retries
=
2
,
ship_package_ids
=
ship_package_ids
,
user_obj
=
user_obj
)
user_obj
=
user_obj
)
# 理货或尾程交接的节点
# 理货或尾程交接的节点
# 预先获取所有状态节点
# 预先获取所有状态节点
...
@@ -960,7 +964,7 @@ class CcBl(models.Model):
...
@@ -960,7 +964,7 @@ class CcBl(models.Model):
self
.
env
.
cr
.
execute
(
sql
)
self
.
env
.
cr
.
execute
(
sql
)
self
.
_cr
.
commit
()
# 提交事务
self
.
_cr
.
commit
()
# 提交事务
self
.
try_callback_track
(
max_retries
=
2
,
ship_package_ids
=
ship_package_ids
,
item
.
try_callback_track
(
max_retries
=
2
,
ship_package_ids
=
ship_package_ids
,
user_obj
=
user_obj
)
user_obj
=
user_obj
)
return
True
return
True
...
...
consumers/mail_push.py
浏览文件 @
ac040816
...
@@ -37,7 +37,11 @@ class Order_dispose(object):
...
@@ -37,7 +37,11 @@ class Order_dispose(object):
bl_obj
=
self
.
odoo_db
.
env
[
'cc.bl'
]
bl_obj
=
self
.
odoo_db
.
env
[
'cc.bl'
]
if
action_type
and
not
utc_time
:
if
action_type
and
not
utc_time
:
bl_obj
=
self
.
pda_odoo_db
.
env
[
'cc.bl'
]
bl_obj
=
self
.
pda_odoo_db
.
env
[
'cc.bl'
]
bl_record
=
bl_obj
.
browse
(
data
[
'id'
])
bl_ids
=
data
.
get
(
'ids'
)
if
bl_ids
:
bl_record
=
bl_obj
.
browse
(
bl_ids
)
else
:
bl_record
=
bl_obj
.
browse
(
data
[
'id'
])
# utc_time = datetime.strptime(data['utc_time'], "%Y-%m-%d %H:%M:%S")
# utc_time = datetime.strptime(data['utc_time'], "%Y-%m-%d %H:%M:%S")
utc_time
=
data
.
get
(
'utc_time'
)
utc_time
=
data
.
get
(
'utc_time'
)
user_login
=
data
.
get
(
'user_login'
)
user_login
=
data
.
get
(
'user_login'
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论