This commit is contained in:
ywb
2026-06-16 14:55:38 +08:00
parent fede57e69a
commit 3d0bcc8f6f
2 changed files with 22 additions and 4 deletions
+8 -3
View File
@@ -2037,13 +2037,18 @@ def api_customs_printer():
else: else:
logger.warning(f"[printer] ⚠️ printer 和 orderItem 均为空,回退 modelName=机器1") logger.warning(f"[printer] ⚠️ printer 和 orderItem 均为空,回退 modelName=机器1")
# 更新查验计数 # 更新查验计数(先检查是否超量,超量时不增加计数)
if gs.inspection and result["inventoryCode"]: if gs.inspection and result["inventoryCode"]:
for item in gs.inspection["items"]: for item in gs.inspection["items"]:
if item["inventoryCode"] == result["inventoryCode"]: if item["inventoryCode"] == result["inventoryCode"]:
item["inspected"] += 1 # 先返回当前值(未+1),让调用方判断是否超量
result["matchedItem"] = item result["matchedItem"] = item
logger.info(f"[printer] ✅ 查验计数更新: {item['inventoryName']}{item['inspected']}/{item['quantify']}") # 只有未超量时才真正+1
if item["inspected"] < item["quantify"]:
item["inspected"] += 1
logger.info(f"[printer] ✅ 查验计数更新: {item['inventoryName']}{item['inspected']}/{item['quantify']}")
else:
logger.warning(f"[printer] ⚠️ 超量不计数: {item['inventoryName']} 已达 {item['inspected']}/{item['quantify']}")
break break
else: else:
logger.warning(f"[printer] ⚠️ inventoryCode={result['inventoryCode']} 不在查验清单中") logger.warning(f"[printer] ⚠️ inventoryCode={result['inventoryCode']} 不在查验清单中")
+14 -1
View File
@@ -800,7 +800,20 @@ class MissionExecutorV3:
has_inspection = data.get("hasInspection", False) has_inspection = data.get("hasInspection", False)
self._log(f" 📊 解析结果: modelName={model}, inventoryCode={inv_code}, hasInspection={has_inspection}, matched={'yes' if matched else 'no'}") self._log(f" 📊 解析结果: modelName={model}, inventoryCode={inv_code}, hasInspection={has_inspection}, matched={'yes' if matched else 'no'}")
if matched: if matched:
self._log(f" 🏷️ 机型: {model} (物料:{inv_code}) — 查验 {matched['inspected']}/{matched['quantify']}") inspected = matched.get('inspected', 0)
quantify = matched.get('quantify', 0)
# 超量检查:已查验数量超过报关单数量
if inspected > quantify:
self._log(f" ⚠️ 机型「{model}」已查验 {inspected} 台,超过报关单数量 {quantify}")
new_qr = self._request_manual_qr(
f"机型「{model}」在报关单中只需查验 {quantify} 台,\n当前已扫到第 {inspected} 台,请重新扫描或手动输入正确的二维码:"
)
# 超量时不能跳过,必须重新输入
if self._stop.is_set():
return model
qr_value = new_qr
continue # 用新二维码重试
self._log(f" 🏷️ 机型: {model} (物料:{inv_code}) — 查验 {inspected}/{quantify}")
return model return model
elif has_inspection and not matched: elif has_inspection and not matched:
# 有查验但机型不在报关单中 → 弹窗 # 有查验但机型不在报关单中 → 弹窗