-
This commit is contained in:
@@ -780,7 +780,7 @@ class MissionExecutorV3:
|
|||||||
|
|
||||||
def _lookup_model(self, qr_value: Optional[str]) -> str:
|
def _lookup_model(self, qr_value: Optional[str]) -> str:
|
||||||
"""通过 /api/customs/printer 接口查询机型,同时更新查验计数
|
"""通过 /api/customs/printer 接口查询机型,同时更新查验计数
|
||||||
如果机型不在当前报关单中,弹窗要求重新扫码/输入"""
|
如果机型不在当前报关单中/超量/查询失败,均弹窗要求重新扫码/输入(不可跳过)"""
|
||||||
if not qr_value:
|
if not qr_value:
|
||||||
return "机器1"
|
return "机器1"
|
||||||
while True:
|
while True:
|
||||||
@@ -803,40 +803,39 @@ class MissionExecutorV3:
|
|||||||
inspected = matched.get('inspected', 0)
|
inspected = matched.get('inspected', 0)
|
||||||
quantify = matched.get('quantify', 0)
|
quantify = matched.get('quantify', 0)
|
||||||
# 超量检查:已查验数量超过报关单数量
|
# 超量检查:已查验数量超过报关单数量
|
||||||
if inspected > quantify:
|
if inspected >= quantify:
|
||||||
self._log(f" ⚠️ 机型「{model}」已查验 {inspected} 台,超过报关单数量 {quantify} 台")
|
self._log(f" ⚠️ 机型「{model}」已查验 {inspected} 台,超过报关单数量 {quantify} 台")
|
||||||
new_qr = self._request_manual_qr(
|
new_qr = self._request_manual_qr(
|
||||||
f"机型「{model}」在报关单中只需查验 {quantify} 台,\n当前已扫到第 {inspected} 台,请重新扫描或手动输入正确的二维码:"
|
f"机型「{model}」在报关单中只需查验 {quantify} 台,\n当前已扫到第 {inspected + 1} 台,请重新扫描或手动输入正确的二维码:"
|
||||||
)
|
)
|
||||||
# 超量时不能跳过,必须重新输入
|
|
||||||
if self._stop.is_set():
|
if self._stop.is_set():
|
||||||
return model
|
return model
|
||||||
qr_value = new_qr
|
qr_value = new_qr
|
||||||
continue # 用新二维码重试
|
continue
|
||||||
self._log(f" 🏷️ 机型: {model} (物料:{inv_code}) — 查验 {inspected}/{quantify}")
|
self._log(f" 🏷️ 机型: {model} (物料:{inv_code}) — 查验 {inspected}/{quantify}")
|
||||||
return model
|
return model
|
||||||
elif has_inspection and not matched:
|
elif has_inspection and not matched:
|
||||||
# 有查验但机型不在报关单中 → 弹窗
|
# 有查验但机型不在报关单中 → 弹窗(不可跳过)
|
||||||
self._log(f" ⚠️ 机型「{model}」(物料:{inv_code})不在当前报关单中")
|
self._log(f" ⚠️ 机型「{model}」(物料:{inv_code})不在当前报关单中")
|
||||||
new_qr = self._request_manual_qr(
|
new_qr = self._request_manual_qr(
|
||||||
f"二维码「{qr_value}」对应机型「{model}」不在当前报关单中,\n请重新扫描或手动输入正确的二维码:"
|
f"二维码「{qr_value}」对应机型「{model}」不在当前报关单中,\n请重新扫描或手动输入正确的二维码:"
|
||||||
)
|
)
|
||||||
if new_qr is None or self._stop.is_set():
|
if self._stop.is_set():
|
||||||
return model # 用户跳过/停止,保留原机型
|
return model
|
||||||
qr_value = new_qr
|
qr_value = new_qr
|
||||||
continue # 用新二维码重试
|
continue
|
||||||
else:
|
else:
|
||||||
# 无查验或匹配成功
|
# 无查验或匹配成功
|
||||||
self._log(f" 🏷️ 机型: {model} (物料:{inv_code})")
|
self._log(f" 🏷️ 机型: {model} (物料:{inv_code})")
|
||||||
return model
|
return model
|
||||||
else:
|
else:
|
||||||
self._log(f" ⚠️ printer 返回 ok=false: {data}")
|
self._log(f" ⚠️ printer 返回 ok=false: {data}")
|
||||||
# API 失败也弹窗
|
# API 失败 / ok=false / 无数据 → 弹窗(不可跳过)
|
||||||
self._log(f" ⚠️ 查询机型失败, HTTP {resp.status_code}")
|
self._log(f" ⚠️ 查询机型失败, HTTP {resp.status_code}")
|
||||||
new_qr = self._request_manual_qr(
|
new_qr = self._request_manual_qr(
|
||||||
f"无法查询二维码「{qr_value}」对应的机型,\n请重新扫描或手动输入正确的二维码:"
|
f"无法查询二维码「{qr_value}」对应的机型信息,\n请重新扫描或手动输入正确的二维码:"
|
||||||
)
|
)
|
||||||
if new_qr is None or self._stop.is_set():
|
if self._stop.is_set():
|
||||||
return "机器1"
|
return "机器1"
|
||||||
qr_value = new_qr
|
qr_value = new_qr
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -844,7 +843,7 @@ class MissionExecutorV3:
|
|||||||
new_qr = self._request_manual_qr(
|
new_qr = self._request_manual_qr(
|
||||||
f"查询机型接口异常,请重新扫描或手动输入正确的二维码:"
|
f"查询机型接口异常,请重新扫描或手动输入正确的二维码:"
|
||||||
)
|
)
|
||||||
if new_qr is None or self._stop.is_set():
|
if self._stop.is_set():
|
||||||
return "机器1"
|
return "机器1"
|
||||||
qr_value = new_qr
|
qr_value = new_qr
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user