百世「应到/实到」抓取并写入汇总报表
- site_baishi.baishi_download_undelivered_data_impl:进「扫描综合查询→实时扫描率」 后、下钻未扫前,顺手抓「到/接件扫描→当日」的 应扫(td.nth(10))/已扫(td.nth(11)), 落库 site_settings(scan_expected_pieces / scan_arrived_pieces);try/except 包裹, 不影响下载主流程。 - expected_undelivered.process_baishi:应到件/已到件改由 state_store.get_setting 读回 (空串→None),不再写死 None。 - expected_undelivered.build_summary:百世行有基数时填真实 应到件/已到件/未到率(带热力色), 无基数仍显示「—」;口径说明文案同步更新。默认不计入合计行/KPI/柱状图(保持 4 站口径)。
This commit is contained in:
@@ -174,6 +174,31 @@ def baishi_download_undelivered_data_impl(page):
|
||||
page.get_by_role("tab", name="实时扫描率").wait_for(state="visible")
|
||||
print("✅ 扫描综合查询界面已加载")
|
||||
|
||||
# 1.5 顺手抓取「到/接件扫描 → 当日」的 应扫/已扫(=应到/实到基数),
|
||||
# 供汇总报表填写百世行的应到件/实到件。
|
||||
# 实时扫描率表头为 14 列 leaf:发/交件[昨日×3, 当日×4] +
|
||||
# 到/接件[昨日×3, 当日×4],到/接件当日四列索引为
|
||||
# 10(应扫) 11(已扫) 12(未扫) 13(率)。(与下方 nth(12) 未扫同源)
|
||||
try:
|
||||
_first_row = page.locator(".ant-table-tbody > tr").first
|
||||
_exp_txt = _first_row.locator("td").nth(10).inner_text().strip().replace(",", "")
|
||||
_arr_txt = _first_row.locator("td").nth(11).inner_text().strip().replace(",", "")
|
||||
|
||||
def _to_int(v):
|
||||
try:
|
||||
return int(float(v)) if v not in ("", "-") else 0
|
||||
except (TypeError, ValueError):
|
||||
return 0
|
||||
|
||||
_exp_n, _arr_n = _to_int(_exp_txt), _to_int(_arr_txt)
|
||||
if _exp_n > 0:
|
||||
state_store.set_setting("百世", "scan_expected_pieces", str(_exp_n))
|
||||
state_store.set_setting("百世", "scan_arrived_pieces", str(_arr_n))
|
||||
print(f" ℹ️ 已记录百世应到/实到基数:应扫 {_exp_n} / 已扫 {_arr_n}")
|
||||
except Exception as _e:
|
||||
# 抓取失败绝不影响未到明细下载主流程
|
||||
print(f" ⚠️ 抓取百世应到/实到基数失败(不影响未到明细下载):{_e}")
|
||||
|
||||
# 2. 精准定位并点击【到/接件扫描 -> 当日 -> 未扫】的数字控件
|
||||
print(">> 正在解析表格,提取当日到件未扫明细...")
|
||||
# 定位第一行数据的第 13 列(索引 12)
|
||||
|
||||
Reference in New Issue
Block a user