feat: 详细日志(分页/映射/批次进度)+ Artifacts 摘要(sync-summary/verify-report)
This commit is contained in:
@@ -111,6 +111,7 @@ class SyncDB:
|
||||
"goodsUpdated": 0, "goodsRemoved": 0, "ordersDeleted": 0,
|
||||
}
|
||||
if not orders and not goods and not delete_order_nos:
|
||||
print("[DB sync] 无数据可写入,跳过")
|
||||
return result
|
||||
|
||||
conn = self._conn()
|
||||
@@ -163,12 +164,18 @@ class SyncDB:
|
||||
for g in goods_dedup:
|
||||
goods_by_order.setdefault(g.orderNo, []).append(g)
|
||||
|
||||
print(f"[DB sync] 准备写入: {len(orders_dedup)} 订单 / {len(goods_dedup)} 商品"
|
||||
+ (f" (系统={system_name})" if system_name else ""))
|
||||
|
||||
# 3. 分批 upsert orders + 关联 goods
|
||||
total_order_batches = -(-len(orders_dedup) // ORDER_CHUNK)
|
||||
for i in range(0, len(orders_dedup), ORDER_CHUNK):
|
||||
chunk = orders_dedup[i : i + ORDER_CHUNK]
|
||||
related: list[GoodsUpsertInput] = []
|
||||
for o in chunk:
|
||||
related.extend(goods_by_order.get(o.orderNo, []))
|
||||
batch_no = i // ORDER_CHUNK + 1
|
||||
print(f"[DB sync] 订单批次 {batch_no}/{total_order_batches}: {len(chunk)} 订单 / {len(related)} 商品")
|
||||
stats = self._upsert_order_batch(conn, chunk, related, system_name)
|
||||
for k, v in stats.items():
|
||||
result[k] += v
|
||||
@@ -199,6 +206,7 @@ class SyncDB:
|
||||
raise
|
||||
finally:
|
||||
conn.close()
|
||||
print(f"[DB sync] 写入完成: {result}")
|
||||
return result
|
||||
|
||||
def _upsert_order_batch(
|
||||
|
||||
Reference in New Issue
Block a user