接入灰度订单关联物流节点并区分预计与实际轨迹

This commit is contained in:
2026-10-30 10:13:11 +08:00
parent ce445d0fb8
commit 6a428bd468
10 changed files with 464 additions and 47 deletions
+4 -2
View File
@@ -7,7 +7,7 @@ import sqlite3
import sys
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from logistics_chat.order_data import import_records
from logistics_chat.order_data import import_records, import_tracking_records
def main():
@@ -15,6 +15,7 @@ def main():
parser.add_argument('--snapshot', type=Path, required=True)
parser.add_argument('--db', type=Path, required=True)
parser.add_argument('--replace', action='store_true', help='Replace existing rows, including manual edits')
parser.add_argument('--tracking-only', action='store_true', help='Update only tracking for matching local orders')
args = parser.parse_args()
if not args.snapshot.is_file() or args.snapshot.stat().st_size > 10*1024*1024:
parser.error('Snapshot must be an existing JSON file smaller than 10 MB')
@@ -24,7 +25,8 @@ def main():
parser.error('Snapshot must contain a list of at most 3000 orders')
if not args.db.parent.is_dir(): parser.error('Database parent directory must exist')
with sqlite3.connect(args.db) as connection:
result = import_records(connection, records, replace=args.replace)
importer = import_tracking_records if args.tracking_only else import_records
result = importer(connection, records, replace=args.replace)
print(json.dumps(result))