feat(shipping-notice): 新增订单行与字段冲突管理功能,支持字段冲突查询与解决
This commit is contained in:
1 parent
4fbaed2b4c
commit
9da0481fc3
74 files changed
+4861
-375
No files matched your search
@@ -2,8 +2,8 @@
|
||||
services/shipping_notice/export.py
|
||||
|
||||
用途:生成发货通知对应的货代出货 Excel,并管理模板与导出文件存储路径。
|
||||
依赖:openpyxl、app.models.ShippingTask、path_utils、Flask current_app 配置。
|
||||
逻辑:由 fulfillment_workflow.generate_excel 调用本文件,根据任务数据填充模板后返回导出文件路径。
|
||||
依赖:openpyxl、app.models.ShippingTask、path_utils、task_line_store、Flask current_app 配置。
|
||||
逻辑:由 fulfillment_workflow.generate_excel 调用本文件;订单行经 read_task_order_lines 读取。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -18,6 +18,7 @@ from openpyxl import Workbook, load_workbook
|
||||
|
||||
from app.models import ShippingTask
|
||||
from app.path_utils import backend_dir, resolve_backend_relative_path
|
||||
from app.services.shipping_notice.task_line_store import read_task_order_lines
|
||||
|
||||
DEFAULT_HEADERS = [
|
||||
"客户名称",
|
||||
@@ -81,9 +82,7 @@ def _delivery_date_for_task(task: ShippingTask) -> str:
|
||||
formatted = _format_delivery_date(task.required_date)
|
||||
if formatted:
|
||||
return formatted
|
||||
for line in task.lines_json or []:
|
||||
if not isinstance(line, dict):
|
||||
continue
|
||||
for line in read_task_order_lines(task):
|
||||
formatted = _format_delivery_date(line.get("required_date"))
|
||||
if formatted:
|
||||
return formatted
|
||||
@@ -91,7 +90,7 @@ def _delivery_date_for_task(task: ShippingTask) -> str:
|
||||
|
||||
|
||||
def _resolve_odm_id(task: ShippingTask) -> str:
|
||||
notice_lines = [line for line in (task.lines_json or []) if isinstance(line, dict)]
|
||||
notice_lines = read_task_order_lines(task)
|
||||
inventory_lines = [row for row in (task.inventory_lines_json or []) if isinstance(row, dict)]
|
||||
if not inventory_lines:
|
||||
return ""
|
||||
@@ -190,7 +189,7 @@ def _fill_pvmi_template(task: ShippingTask, path: Path) -> None:
|
||||
business_ref = task.shipping_case.business_no if task.shipping_case and task.shipping_case.business_no else task.task_no
|
||||
header_ws.cell(DATA_START_ROW, 7).value = business_ref
|
||||
|
||||
notice_lines = [line for line in (task.lines_json or []) if isinstance(line, dict)]
|
||||
notice_lines = read_task_order_lines(task)
|
||||
if not notice_lines:
|
||||
notice_lines = [{}]
|
||||
|
||||
@@ -229,7 +228,7 @@ def _fill_legacy_template(task: ShippingTask, path: Path) -> None:
|
||||
"""填充 legacy 模板;技术任务号继续保留在导出文件名与系统记录中。"""
|
||||
wb = load_workbook(filename=str(path))
|
||||
ws = wb.active
|
||||
lines = task.lines_json or [None]
|
||||
lines = read_task_order_lines(task) or [None]
|
||||
if ws.max_row == 1 and not any(ws.cell(1, c).value for c in range(1, 9)):
|
||||
ws.append(DEFAULT_HEADERS)
|
||||
for line in lines:
|
||||
@@ -243,7 +242,7 @@ def _fill_blank_workbook(task: ShippingTask, path: Path) -> None:
|
||||
ws = wb.active
|
||||
ws.title = "Shipment"
|
||||
ws.append(DEFAULT_HEADERS)
|
||||
lines = task.lines_json or [None]
|
||||
lines = read_task_order_lines(task) or [None]
|
||||
for line in lines:
|
||||
ws.append(_row_values(task, line))
|
||||
wb.save(path)
|
||||
|
||||
Reference in new issue
Block a user