提交 47e4a142 authored 作者: 贺阳's avatar 贺阳

Merge branch 'develop' into feature/需求优化

# Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
......@@ -799,6 +799,27 @@ class CcBL(models.Model):
wizard_obj = wizard_obj.with_context(dict(self._context, active_id=self.id))
wizard_obj.submit()
def check_push_clear_customs_start(self, utc_time):
"""检查清关开始"""
push_node_obj = self.env['cc.node'].sudo().search(
[('node_type', '=', 'package'), ('tk_code', '=', 'cb_imcustoms_start')], limit=1)
node_obj = self.env['cc.node'].sudo().search([('node_type', '=', 'package'), ('seq', '<', push_node_obj.seq)],
order='seq desc',
limit=1)
vals = {
'bl_id': self.id,
'bl_count': 1,
'current_status': node_obj.id,
'update_status': push_node_obj.id,
'process_time': utc_time,
'is_ok': True
}
wizard_obj = self.env['batch.input.ship.package.status.wizard'].sudo().create(vals)
wizard_obj.change_ship_package_ids()
wizard_obj = wizard_obj.with_context(dict(self._context, active_id=self.id))
parcels = wizard_obj.get_process_package()
return parcels
def push_clear_customs_end(self, utc_time):
# 创建向导
push_node_obj = self.env['cc.node'].sudo().search(
......
......@@ -179,6 +179,7 @@ class OrderStateChangeRule(models.Model):
def fetch_mail_dlv_attachment(self, **kwargs):
attachment_arr = kwargs['attachment_arr']
mail_arr = []
for attachment_tuple in attachment_arr:
try:
attachment_name, attachment_data = attachment_tuple
......@@ -205,11 +206,38 @@ class OrderStateChangeRule(models.Model):
if redis_conn == 'no':
raise ValidationError('未连接redis')
else:
redis_conn.lpush('mail_push_package_list', json.dumps(
{'id': bl_obj.id, 'user_login': users_obj.login,
'utc_time': utc_time.strftime("%Y-%m-%d %H:%M:%S")}))
if bl_obj.check_push_clear_customs_start(utc_time.strftime("%Y-%m-%d %H:%M:%S")):
redis_conn.lpush('mail_push_package_list', json.dumps(
{'id': bl_obj.id, 'user_login': users_obj.login,
'utc_time': utc_time.strftime("%Y-%m-%d %H:%M:%S")}))
else:
mail_arr.append(bl_obj)
except Exception as err:
logging.error('fetch_mail_dlv_attachment--error:%s' % str(err))
if mail_arr:
# order_no_arr = [i.bl_no for i in mail_arr]
order_no = ''.join([f"<p>{item.bl_no}</p>" for item in mail_arr])
content = f"""
<p>您好:
以下提单接收到清关邮件,但未触发清关结束或清关开始节点的变动,请查看原因,并手动处理</p>
{order_no}
<p>请立即处理,避免推送超时!</p>"""
# 给客户配置的每个邮箱都发送邮件
patrol_sender_email = self.env["ir.config_parameter"].sudo().get_param('patrol_sender_email') or ''
patrol_receiver_emails = self.env["ir.config_parameter"].sudo().get_param('patrol_receiver_emails') or ''
mail = self.env['mail.mail'].sudo().create({
"email_from": patrol_sender_email,
'subject': '清关节点邮件未触发提醒',
'body_html': content,
'email_to': patrol_receiver_emails
# 'email_to': "1663490807@qq.com,820656583@qq.com"
})
mail.send()
for i in range(2):
if mail.failure_reason:
logging.info('邮件发送失败原因:%s' % mail.failure_reason)
mail.write({'state': 'outgoing'})
mail.send()
def find_final_email_text(self, email_body):
"""匹配尾程pod邮件内容"""
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论