diff --git a/assets/version_info.txt b/assets/version_info.txt index f4075b6..ca6389c 100644 --- a/assets/version_info.txt +++ b/assets/version_info.txt @@ -1,16 +1,16 @@ VSVersionInfo( - ffi=FixedFileInfo(filevers=(1, 0, 70, 0), prodvers=(1, 0, 70, 0), + ffi=FixedFileInfo(filevers=(1, 0, 71, 0), prodvers=(1, 0, 71, 0), mask=0x3f, flags=0x0, OS=0x40004, fileType=0x1, subtype=0x0, date=(0, 0)), kids=[ StringFileInfo([StringTable('080404B0', [ StringStruct('CompanyName', '配送中心'), StringStruct('FileDescription', '入库分拣工作站'), - StringStruct('FileVersion', '1.0.70.0'), + StringStruct('FileVersion', '1.0.71.0'), StringStruct('InternalName', 'WeighStation'), StringStruct('OriginalFilename', '入库分拣工作站.exe'), StringStruct('ProductName', '入库分拣工作站'), - StringStruct('ProductVersion', '1.0.70.0'), + StringStruct('ProductVersion', '1.0.71.0'), StringStruct('LegalCopyright', '内部使用')])]), VarFileInfo([VarStruct('Translation', [2052, 1200])]) ] diff --git a/build_exe.py b/build_exe.py index 6d8b574..9e668c8 100644 --- a/build_exe.py +++ b/build_exe.py @@ -20,7 +20,7 @@ import sys ROOT = os.path.dirname(os.path.abspath(__file__)) APP_NAME = '入库分拣工作站' -APP_VERSION = '1.0.70' +APP_VERSION = '1.0.71' ASSETS = os.path.join(ROOT, 'assets') DIST = os.path.join(ROOT, 'dist') OUT = os.path.join(DIST, APP_NAME) diff --git a/installer.iss b/installer.iss index cee4153..8219b2c 100644 --- a/installer.iss +++ b/installer.iss @@ -1,12 +1,12 @@ ; ============================================================ ; 入库分拣工作站 · 安装包脚本(Inno Setup 6) -; 编译:iscc installer.iss → dist\入库分拣工作站_安装程序_v1.0.70.exe +; 编译:iscc installer.iss → dist\入库分拣工作站_安装程序_v1.0.71.exe ; 说明:源目录为 build_exe.py 产出的 dist\入库分拣工作站(onedir) ; ============================================================ #define AppName "入库分拣工作站" #ifndef AppVersion - #define AppVersion "1.0.70" + #define AppVersion "1.0.71" #endif #define AppExe "入库分拣工作站.exe" #define SrcDir "dist\入库分拣工作站" @@ -41,7 +41,7 @@ CloseApplications=yes RestartApplications=no AllowNoIcons=yes ShowLanguageDialog=no -VersionInfoVersion=1.0.70.0 +VersionInfoVersion=1.0.71.0 VersionInfoDescription={#AppName} 安装程序 VersionInfoProductName={#AppName} diff --git a/tools/_test_pager.py b/tools/_test_pager.py index 13d00b8..58edab7 100644 --- a/tools/_test_pager.py +++ b/tools/_test_pager.py @@ -142,6 +142,7 @@ print('=== 2. 卡高谎报一半(严重低估):兜底必须生效 ===') for c in app.todo_cards.values(): real = c.winfo_reqheight() c.winfo_reqheight = (lambda r: (lambda: max(11, int(r / 2))))(real) +app._geom_dirty = True # 等同于「卡片刚重建、高度未知」 bad, empty = scan_pages() check('低估卡高后仍不裁(兜底缩了预算)', not bad, '超出 %r' % bad[:4]) check('没有摆出只有页头的空白页', not empty, str(empty)) diff --git a/ui/app.py b/ui/app.py index ef16923..03ffa99 100644 --- a/ui/app.py +++ b/ui/app.py @@ -39,7 +39,7 @@ class _BoolVar: self._sw.set(v) -APP_VERSION = '1.0.70' +APP_VERSION = '1.0.71' # 待办卡外框粗细:所有卡统一这一个值,选中/确认只换颜色。 # Tk 的 highlight 环画在控件外侧,粗细一变控件尺寸就变,grid 会把整屏 @@ -1168,7 +1168,21 @@ class App: if not self._ka_started: self._ka_started = True threading.Thread(target=self._keepalive, daemon=True).start() - self.engine.refresh_pending(initial=True) + # v1.0.72(性能):登录不再在 UI 线程等网络。引擎在后台登录时已经 + # 拉过一次名单(engine.rows),先直接上屏;随后异步刷新一次。 + # 以前这里调同步的 refresh_pending:入库站要发 2 个请求(pending + + # pending-grouped),读超时 10 秒,网络一抖就是几秒白屏(日志里 + # 实测最大 3.1 秒)。业务逻辑一点没改:刷完还是同一套 _on_pending。 + try: + _rows = getattr(self.engine, 'rows', None) or [] + if _rows: + self._on_pending({ + 'rows': _rows, + 'config': getattr(self.engine, 'server_config', {}) or {}, + 'account': getattr(self.engine, 'account_name', '')}) + except Exception: + pass + self.engine.refresh_pending_async() # 开机自动认设备(后台跑,认出什么就用什么;现场换备机/换口都能自愈) # 延迟 1.5 秒:先让秤把第一帧吐出来,秤正常就不会被探测打扰 if bool(self._get('devices.auto_detect', True)): @@ -3292,6 +3306,7 @@ class App: self._focus_rid = None self._pre_rid = None self._layout_key = None # 重建后必须真的重排一次 + self._geom_dirty = True # 新卡高未知,摆完要做一次几何校验 self._page = 0 # 名单内容换了,回第一页(v1.0.58) if getattr(self, '_empty_lbl', None) is not None: try: @@ -3474,15 +3489,22 @@ class App: pairs = ((getattr(c, '_name_lbl', None), r.get('item_name') or '—'), (getattr(c, '_qty_lbl', None), '%g %s' % (q, unit)), (getattr(c, '_meta_lbl', None), meta)) + changed = False for lbl, txt in pairs: if lbl is None: continue try: if lbl.cget('text') != txt: lbl.configure(text=txt) + changed = True except Exception: pass c._meta_who = meta + # 卡上的字/徽标变了 → 卡高可能变,下一次重排要做几何校验 + badge = getattr(c, '_independent_badge', None) + if changed or (badge is not None + and badge.winfo_manager() == 'pack'): + self._geom_dirty = True # 字变了卡就可能变高(客户名/徽标折行)——idle 里复查一次 # 最底一张是否被视口裁到,裁到就重排(宁少放一行)。 self._schedule_reflow() @@ -3812,6 +3834,11 @@ class App: self.todo_grid.columnconfigure(col, weight=0, minsize=0) card_w = (cw - gap * (ncols + 1)) // ncols thumb = int(60 * self.S) if self._thumb_on() else 0 + # v1.0.72(性能):列宽/缩略图变了,换行宽度跟着变 → 卡高会变, + # 这一次必须做几何校验;没变就不用(普通翻页/重排剩 30ms)。 + if (card_w, thumb) != getattr(self, '_mw_prev', None): + self._mw_prev = (card_w, thumb) + self._geom_dirty = True # 所有卡的换行宽度先按列宽设好(不在本页的卡翻过去时直接用) for kind, obj in items: if kind != 'card': @@ -3907,14 +3934,33 @@ class App: # DPI 或字体差异、页头比估的高……)。与其猜是哪个,不如摆完量一次: # 最底一张真的超出视口,就把「每行平均低估的那几像素」加到行高上 # 重排,**宁少放一行,绝不裁半行**。最多试 4 次。 + # + # v1.0.72(性能):校验按「高度版本 + 页码」缓存 —— 卡高变了 + # (重建卡片 / 字改了 / 列宽变了)或这一页还没校验过,才真去 + # update_idletasks;同一页再翻回来就不用。校验一次约 30ms。 + def _paginate(extra=0.0): + return _paginate_by_height( + items, ncols, view_h, + lambda k, o: _item_height(k, o) + extra) + + hs = tuple(sorted({int(_item_height(k, o)) for k, o in items})) + if hs != getattr(self, '_geom_sig', None) \ + or getattr(self, '_geom_dirty', False): + self._geom_sig = hs + self._geom_ok = set() + self._geom_dirty = False + ok_pages = getattr(self, '_geom_ok', set()) + _pages0 = _paginate() + _target = max(0, min(self._page, len(_pages0) - 1)) + check_geom = _target not in ok_pages + extra = 0.0 # 每行平均被低估的高度 page = [] over = 0 - for _try in range(4): - pages = _paginate_by_height( - items, ncols, view_h, - lambda k, o: _item_height(k, o) + extra) - page = _grid_page(pages) + for _try in range(4 if check_geom else 1): + page = _grid_page(_paginate(extra)) + if not check_geom: + break try: self.todo_grid.update_idletasks() slaves = self.todo_grid.grid_slaves() @@ -3926,6 +3972,10 @@ class App: if over <= 0 or rows <= 0 or len(page) <= 1: break extra += float(over) / rows + if check_geom: + # 缩过行(extra>0)说明分页变了,其它页的校验结果作废 + self._geom_ok = {self._page} if extra > 0 else \ + (set(ok_pages) | {self._page}) self._last_over = max(0, over) # 供 idle 复查用,免得反复重排 self.todo_canvas.itemconfig(self._todo_win, width=cw) @@ -4039,11 +4089,13 @@ class App: try: view_h = max(1, self.todo_canvas.winfo_height()) over = max([w.winfo_y() + w.winfo_height() - for w in self.todo_grid.grid_slaves()] or [0]) - view_h + for w in self.todo_grid.grid_slaves()] or [0]) \ + - view_h # 超出量和上次重排时一样多 → 缩预算也救不了(单张卡就比视口高), # 别再反复重排 if over <= max(0, getattr(self, '_last_over', 0)) + 2: return + self._geom_dirty = True # 重排时走一次几何校验(会缩行) self._layout_key = None # 强制真的重排一次 self._layout_cards() except Exception: @@ -4079,6 +4131,7 @@ class App: if est and abs(real - est) <= max(6, int(est * 0.08)): return self._row_h_est = real + self._geom_dirty = True # 卡高变了,重排时做一次几何校验 self._layout_key = None self._layout_cards() except Exception: diff --git a/使用说明.txt b/使用说明.txt index 47e5955..26bcf18 100644 --- a/使用说明.txt +++ b/使用说明.txt @@ -25,7 +25,23 @@ build_assets/ 打包素材(VC++ 运行库 vc_redist.x64.exe) 打包.bat 双击打包 dist/ 产物:dist\入库分拣工作站\(绿色版) - dist\入库分拣工作站_安装程序_v1.0.70.exe(安装包) + dist\入库分拣工作站_安装程序_v1.0.71.exe(安装包) + +【v1.0.71 入库「手动确认」按账号开关(2026-11-29)】 + +◆ 入库不能再「拿走即自动记账」了(账号开关决定) + · 服务端账号字段 profiles.inbound_auto_submit: + - 未开启 / 服务端没这个字段 → 入库必须点「确认记账」 + - 开启 → 与 1.0.70 一样(拿走货、秤连续空 3 秒自动提交) + · 手动确认时:认出来先跳到那一行、弹确认条;把货取走不会自动过账, + 确认条会一直挂着等人点(不点掉它,下一件不会起新流程)。 + · 识别不受影响:斤类还是放上去自动认;袋/包/桶也是自动抓拍识别, + 只是认出来要人点一下确认。 + · 分拣工位完全不受影响(本来就必须点「确认分拣」)。 + +◆ 修:上一件的品名残留 + · 新一轮开始时清空上一轮识别名,避免「这件没认出来,确认页却显示 + 上一件的品名」。 【v1.0.70 待办分页不再裁掉最底行(2026-11-25)】