fix(inbound): 拿走即提交空秤等 3 秒,补货抬货不再误提交

补货时把原货抬起来调整位置会被当成取走、按短重量入账。
空秤窗口 0.3s→3s、残重 3s→10s;期间货放回秤上即取消,
状态卡提示行显示到期时间。分拣仍必须人工确认。
This commit is contained in:
雨天
2026-11-23 18:41:53 +08:00
parent 7b9acb23b2
commit e313739453
4 changed files with 75 additions and 13 deletions
+27 -5
View File
@@ -3513,6 +3513,8 @@ class FlowEngine:
settled * 0.6)
if st['weight'] >= floor:
# 读数还在正常区间:可能被增减,跟住它,稳了就换新读数
if getattr(self, '_confirm_gone_at', 0.0):
self.emit('hint', '') # 货回来了,撤掉取货提示
self._confirm_gone_at = 0.0
self._track_confirm_weight(now, st)
return
@@ -3521,6 +3523,13 @@ class FlowEngine:
# 才按取走处理,用的始终是掉下去之前的稳定值。
if not getattr(self, '_confirm_gone_at', 0.0):
self._confirm_gone_at = now
# 现场:补货时常把原货抬起来调整位置,以前 3 秒就误提交。
# 把窗口放长,并在提示行里说明怎么取消(把货放回秤上)。
self.emit('hint', '读数掉了:持续 %g 秒不回升才自动提交;'
'补货时把货放回秤上就取消'
% self._confirm_linger_s())
self.emit('log', '读数下降(可能取货/补货调整):%g 秒内'
'放回秤上就不提交' % self._confirm_linger_s())
elif now - self._confirm_gone_at >= self._confirm_linger_s():
name = (self._frozen_row or {}).get('item_name') or ''
self.emit('log', '货已取走(%.3f → %.3f kg),自动提交「%s」'
@@ -3537,8 +3546,12 @@ class FlowEngine:
return
if not getattr(self, '_confirm_gone_at', 0.0):
self._confirm_gone_at = now
self.emit('hint', '秤上已没货:%g 秒后自动提交;还在补货请把货放回秤上'
% (self._confirm_zero_ms() / 1000.0))
self.emit('log', '秤已归零:%g 秒内把货放回秤上就不提交'
% (self._confirm_zero_ms() / 1000.0))
if now - self._confirm_gone_at < self._confirm_zero_ms() / 1000.0:
return # 归零要稳一小会儿,防读数毛刺
return # 空秤要稳一小会儿,防读数毛刺/抬货调整
name = (self._frozen_row or {}).get('item_name') or ''
self.emit('log', '货已取走(%.3f → %.3f kg,秤已归零),自动提交「%s」'
% (float(getattr(self, '_confirm_settled_kg', 0.0)
@@ -3552,12 +3565,21 @@ class FlowEngine:
self.emit('log', '自动提交失败:%s' % msg)
def _confirm_linger_s(self):
"""读数掉到 6 成以下、既不归零也不回升时,等多久算「取走」"""
return float(self.cfg['flow'].get('confirm_linger_s', 3.0) or 3.0)
"""读数掉到 6 成以下、既不归零也不回升时,等多久算「取走」
v1.0.69:3 秒 → 10 秒。现场补货时会把原货抬起来调整位置,
旧窗口太短会被当成取走,按补货前的短重量提交。
这段时间里把货放回秤上就自动取消。
"""
return float(self.cfg['flow'].get('confirm_linger_s', 10.0) or 10.0)
def _confirm_zero_ms(self):
"""秤归零后要稳定多久才提交(防瞬时毛刺/轻货抖动)"""
return float(self.cfg['flow'].get('confirm_zero_ms', 300) or 300)
"""秤归零后要稳定多久才提交(防瞬时毛刺/抬货调整)
v1.0.69:300ms → 3000ms。抬货调整/补货常超过 0.3 秒,
旧值会把「抬起来挪一下」当成取走直接提交。
"""
return float(self.cfg['flow'].get('confirm_zero_ms', 3000) or 3000)
def _track_confirm_weight(self, now, st):
"""v1.0.62:确认期间跟住秤读数,稳出一个新值就按它记账
+24 -8
View File
@@ -114,8 +114,8 @@ check('默认开(不写配置也是拿走即提交)', e.submit_on_remove() i
e = Fake(flow_cfg={'submit_on_remove': False})
check('显式关掉生效', e.submit_on_remove() is False)
print('二、_confirm_tick:拿走即提交(v1.0.62 口径:秤归零才提交,'
'提交值=取货前最后一次稳定读数)')
print('二、_confirm_tick:拿走即提交(v1.0.69 口径:空秤稳 3 秒才提交,'
'抬货调整/补货放回秤上即取消)')
e = Fake()
e.state = 'CONFIRM'
e._focus = {'mode': 'weigh', 'row_id': 'r1'}
@@ -126,14 +126,30 @@ t0 = time.monotonic()
e._confirm_tick(t0, {'present': True, 'weight': 9.0})
check('货在秤上:不提交,记见过货', e.confirms == []
and e._confirm_seen_present is True)
e._confirm_tick(t0 + 0.1, {'present': False, 'weight': 8.8})
check('读数掉一点还没归零:不提交', e.confirms == [])
e._confirm_tick(t0 + 0.2, {'present': False, 'weight': 0.0})
check('归零瞬间(未稳 0.3 秒):先不提交', e.confirms == [])
e._confirm_tick(t0 + 0.6, {'present': False, 'weight': 0.0})
check('归零稳住 → confirm_focus(auto_remove=True)',
e._confirm_tick(t0 + 0.1, {'present': True, 'weight': 8.8})
check('读数掉一点但还在秤上:不提交', e.confirms == [])
e._confirm_tick(t0 + 0.5, {'present': False, 'weight': 0.0})
check('归零瞬间:先不提交', e.confirms == [])
e._confirm_tick(t0 + 3.4, {'present': False, 'weight': 0.0})
check('空秤未满 3 秒:不提交', e.confirms == [])
e._confirm_tick(t0 + 3.6, {'present': False, 'weight': 0.0})
check('空秤满 3 秒 → confirm_focus(auto_remove=True)',
e.confirms == [True])
# 现场:补货时把原货抬起来调整位置,再放回去 —— 不能算取走
e = Fake()
e.state = 'CONFIRM'
e._focus = {'mode': 'weigh', 'row_id': 'r1'}
e._frozen_kg = 9.0
e._frozen_row = mrow()
t0 = time.monotonic()
e._confirm_tick(t0, {'present': True, 'weight': 9.0})
e._confirm_tick(t0 + 0.5, {'present': False, 'weight': 0.0})
e._confirm_tick(t0 + 2.0, {'present': True, 'weight': 9.4})
check('抬起 1.5 秒又放回:不提交', e.confirms == [])
check('放回后取货计时清零', not e._confirm_gone_at,
e._confirm_gone_at)
e = Fake()
e.state = 'CONFIRM'
e._focus = {'mode': 'weigh'}
+16
View File
@@ -3997,6 +3997,22 @@ class App:
def _on_log(self, s):
self.log(s)
def _on_hint(self, text):
"""引擎发来的临时提示(如「3 秒后自动提交」):写在状态卡提示行
空字符串 = 撤掉临时提示,恢复待确认件的正常提示。
"""
try:
if text:
self.lbl_hint.configure(text=str(text), fg=C.amber)
else:
line, warn = self._pending_hint(getattr(self, '_focus_p', None)
or {})
self.lbl_hint.configure(text=warn or line,
fg=C.amber if warn else C.ink2)
except Exception:
pass
def _show_recent_records(self, n_last=20):
"""最近提交台账(records.csv 倒序 N 条):点一行看抓拍照片。
+8
View File
@@ -54,6 +54,14 @@
· 设置页预览改用像素字号:Windows 显示缩放 125%/150% 时,预览文字
不再被放大成“压住二维码”的样子(实际打印本来就没问题)。
◆ 入库「拿走即提交」不再被补货误触发
· 以前秤一空 0.3 秒就自动提交:补货时把原货抬起来调整位置,会被
当成取走,按补货前的短重量入账。
· 现在空秤要连续 3 秒才自动提交(残重不归零等 10 秒);这期间把货
放回秤上立即取消,状态卡提示行会显示「N 秒后自动提交」。
· 要调宽松可在 config 的 flow 段设置:confirm_zero_ms(默认 3000)、
confirm_linger_s(默认 10)。分拣工位不受影响,仍必须人工确认。
◆ 点待办卡不再抖、也不会两张同时亮
· 所有卡片外框固定 4px,选中(琥珀)/ 确认(绿)只换颜色、不改粗细。
以前确认行比别的卡粗 2px,一点卡整排卡片就被撑大、界面跟着跳。