提交 a14cd1d3 authored 作者: 贺阳's avatar 贺阳

尾程匹配节点时间和前序节点推送的优化

上级 9441f0b7
......@@ -5,15 +5,15 @@ import base64
import json
import logging
import re
import tempfile
from datetime import datetime, timedelta
from io import BytesIO
import pdfplumber
import xlrd
from aip.ocr import AipOcr
from odoo import models
from odoo.exceptions import ValidationError
import tempfile
from aip.ocr import AipOcr
from pdf2image import convert_from_path
_logger = logging.getLogger(__name__)
......@@ -265,8 +265,9 @@ class OrderStateChangeRule(models.Model):
ids = [i[0] for i in result]
bl_objs = self.env['cc.bl'].sudo().search([('id', 'in', ids)]) if result else False
if bl_objs and attachment_tuple_arr:
file_objs = self.env['cc.clearance.file'].sudo().search([('file_name', '=', '尾程交接POD(待大包数量和箱号)'),
('bl_id', 'in', bl_objs.ids)])
file_objs = self.env['cc.clearance.file'].sudo().search(
[('file_name', '=', '尾程交接POD(待大包数量和箱号)'),
('bl_id', 'in', bl_objs.ids)])
file_objs.unlink()
for attachment_tuple in attachment_tuple_arr:
attachment_name, attachment_data = attachment_tuple
......@@ -362,7 +363,7 @@ class OrderStateChangeRule(models.Model):
# poppler_path = r"E:\poppler-23.08.0\Library\bin"
# images = convert_from_path(pdf_path, poppler_path=poppler_path)
# 非本地代码
images = convert_from_path(pdf_path)#如果文件损坏的会报错,需要处理
images = convert_from_path(pdf_path) # 如果文件损坏的会报错,需要处理
# 保存每一页为图片文件
for i, image in enumerate(images):
if i == 0:
......
......@@ -883,6 +883,7 @@ class BatchGetPodInfoWizard(models.TransientModel):
if redis_conn and redis_conn != 'no' and pod_node_id:
redis_conn.lpush('mail_push_package_list', json.dumps(
{'ids': bl_objs.ids, 'ship_packages': str(ship_packages), 'action_type': 'push_match_node',
'user_login': self.env.user.login,
'pod_node_id': pod_node_id}))
def _extract_time_from_pdf(self, file_data, bl_no, ocr_texts=None):
......
......@@ -8,12 +8,12 @@ import redis
import config
# 默认字符gbk
# logging.basicConfig(filename='./push_data_logger.log', level=logging.INFO)
logging.basicConfig(filename='./push_data_logger.log', level=logging.INFO)
# 设置文件字符为utf-8
logging.basicConfig(handlers=[logging.FileHandler('logs/mail_push.log', 'a', 'utf-8')],
format='%(asctime)s %(levelname)s %(message)s', level=logging.INFO)
# logging.basicConfig(handlers=[logging.FileHandler('logs/mail_push.log', 'a', 'utf-8')],
# format='%(asctime)s %(levelname)s %(message)s', level=logging.INFO)
class Order_dispose(object):
......@@ -45,7 +45,7 @@ class Order_dispose(object):
utc_time = data.get('utc_time')
user_login = data.get('user_login')
pod_node_id = data.get('pod_node_id')
bl_record.mail_auto_push(utc_time, ship_packages, action_type, user_login, config.pda_db_user,
bl_record.mail_auto_push(utc_time, ship_packages, action_type, user_login, user_login or config.pda_db_user,
pod_node_id=pod_node_id)
except Exception as ex:
logging.error('mail_auto_push error:%s' % str(ex))
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论