feat(shipping-notice): 库存缺口料号兜底自动放行并新增料号可用量列
- 匹配器按料号二次汇总 part_available_qty 随行级匹配事实持久化(新列,迁移 0a575f3a) - 缺口行料号总库存满足需求时系统自动放行,复用人工放行同一落库/审计/门禁链路,证据按预约优先→料号兜底自动带出 - 前端库存匹配表原「可用数量」列改为「预约数量」,其后新增「可用数量」(料号总库存)列 - DSV 连接器防误点「忘记密码」链接并参数化料号报表取数,库存 worker 按料号查询配套 - 收料就绪与来源状态联动调整;casdoor 未识别认证错误日志保留原始异常堆栈 - 同步门禁/投影/持久化测试、调拨卡片文案四语言与文档
This commit is contained in:
1 parent
4e97553f42
commit
386f93108c
62 files changed
+4000
-219
No files matched your search
@@ -209,6 +209,9 @@ def _click_dsv_password_method(page: Any) -> bool:
|
||||
核心逻辑:先用 DOM 脚本按方法行点击(兼容 mfaForm / device-list / 泛化 listitem);
|
||||
失败再按 Playwright 行选择器与精确文案 `Password`/`密码` 点击;任一路经须
|
||||
`transition_confirmed`(密码框出现或离开方法页)才算成功。
|
||||
防误点约束:“忘记密码”链接锚点文本恰好是“密码”(“忘记”在 #forgotLinks 父级文本
|
||||
节点里),方法页判定、DOM 脚本与文案兜底三层都必须按容器/跳转目标将其排除,
|
||||
否则会跳到 password.dbschenker.com 找回密码页导致登录中断。
|
||||
|
||||
Args:
|
||||
page: Playwright Page(可含 iframe)。
|
||||
@@ -255,7 +258,45 @@ def _click_dsv_password_method(page: Any) -> bool:
|
||||
time.sleep(0.3)
|
||||
return False
|
||||
|
||||
def text_candidate_clickable(locator: Any) -> bool:
|
||||
"""
|
||||
文案兜底命中候选时,只放行真正的控件(button/a/li/input/role=button)。
|
||||
|
||||
[BUGFIX] text=密码 这类子串选择器会命中 body/表单包裹层,force 点击其几何中心,
|
||||
中心压在“忘记密码”链接上就会跳到 password.dbschenker.com;容器命中一律跳过。
|
||||
"""
|
||||
try:
|
||||
info = locator.evaluate(
|
||||
"(node) => ({"
|
||||
" tag: node.tagName,"
|
||||
" forgot: !!(node.closest && node.closest('#forgotLinks')),"
|
||||
" href: (node.getAttribute ? (node.getAttribute('href') || '') : ''),"
|
||||
" role: (node.getAttribute && node.getAttribute('role')) || ''"
|
||||
"})"
|
||||
)
|
||||
except Exception:
|
||||
return False
|
||||
if not isinstance(info, dict):
|
||||
return False
|
||||
if info.get('forgot'):
|
||||
return False
|
||||
if 'password.dbschenker.com' in str(info.get('href') or '').lower():
|
||||
return False
|
||||
tag = str(info.get('tag') or '').upper()
|
||||
return tag in {'BUTTON', 'A', 'LI', 'INPUT'} or str(info.get('role') or '') == 'button'
|
||||
|
||||
def try_click_locator(locator: Any) -> bool:
|
||||
# [BUGFIX] “忘记密码”链接锚点文本就是“密码”,text="密码"/a:has-text("密码") 都会命中;
|
||||
# 点击前按所在容器与跳转目标统一拦截,防止误跳 password.dbschenker.com 找回密码页。
|
||||
try:
|
||||
if locator.evaluate(
|
||||
"(node) => (node.closest && !!node.closest('#forgotLinks'))"
|
||||
" || ((node.getAttribute ? (node.getAttribute('href') || '') : '')"
|
||||
".toLowerCase().includes('password.dbschenker.com'))"
|
||||
):
|
||||
return False
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
locator.scroll_into_view_if_needed(timeout=3_000)
|
||||
except Exception:
|
||||
@@ -288,7 +329,12 @@ def _click_dsv_password_method(page: Any) -> bool:
|
||||
const style = window.getComputedStyle(node);
|
||||
return !(style.display === 'none' || style.visibility === 'hidden' || rect.width <= 0 || rect.height <= 0);
|
||||
};
|
||||
const isPasswordMethod = (text) => {
|
||||
const isPasswordMethod = (node, text) => {
|
||||
// [BUGFIX] “忘记密码”链接的锚点文本恰好是“密码”(“忘记”二字在父级 #forgotLinks 的
|
||||
// 文本节点里),仅按元素自身文案排除会漏掉它;必须按所在容器与跳转目标排除。
|
||||
if (node.closest && node.closest('#forgotLinks')) return false;
|
||||
const href = (node.getAttribute && node.getAttribute('href')) || '';
|
||||
if (node.tagName === 'A' && /password\\.dbschenker\\.com/i.test(href)) return false;
|
||||
const lowered = (text || '').toLowerCase();
|
||||
const excluded = (
|
||||
text.includes('忘记密码') || lowered.includes('forgot password')
|
||||
@@ -309,7 +355,7 @@ def _click_dsv_password_method(page: Any) -> bool:
|
||||
const rows = Array.from(document.querySelectorAll(
|
||||
"form[name='mfaForm'] li.mb-2, form[name='mfaForm'] .mb-2, .device-list li.mb-2, .device-list .mb-2, li.mb-2, [role='listitem'], .device-type, button, a, [role='button']"
|
||||
)).filter((node) => isVisible(node));
|
||||
const row = rows.find((node) => isPasswordMethod(textOf(node)));
|
||||
const row = rows.find((node) => isPasswordMethod(node, textOf(node)));
|
||||
if (!row) return false;
|
||||
const target = row.querySelector('.device-continue, button, a, [role="button"], input[type="submit"]') || row;
|
||||
target.scrollIntoView({ block: 'center', inline: 'center' });
|
||||
@@ -378,6 +424,8 @@ def _click_dsv_password_method(page: Any) -> bool:
|
||||
locator.wait_for(state="visible", timeout=500)
|
||||
except Exception:
|
||||
continue
|
||||
if not text_candidate_clickable(locator):
|
||||
continue
|
||||
if try_click_locator(locator):
|
||||
return True
|
||||
time.sleep(0.5)
|
||||
@@ -802,6 +850,11 @@ def _looks_like_dsv_login_method_page(page: Any) -> bool:
|
||||
# 宽泛 needle 造成误判(反复尝试点击“密码方式”而非关闭弹窗);命中升级提示时直接判非方法页。
|
||||
if _has_dsv_password_upgrade_prompt(page):
|
||||
return False
|
||||
# [BUGFIX] 密码输入页正文同样含“密码/Password”(label、placeholder、忘记密码链接),
|
||||
# 会被下方宽泛 needle 误判成方法页,导致 _click_dsv_password_method 在密码页上运行、
|
||||
# 其文案兜底点中“忘记密码”链接跳到 password.dbschenker.com。密码框可见即必非方法页。
|
||||
if _find_dsv_password_locator(page, timeout_ms=120) is not None:
|
||||
return False
|
||||
# 含英文新版 “Choose a sign in method”(无连字符);旧版为 sign-on。
|
||||
needles = (
|
||||
"选择登录方法",
|
||||
|
||||
@@ -1175,13 +1175,16 @@ def _fill_dsv_filter_if_needed(
|
||||
value: 参数值。
|
||||
report_name: 报表名;透传给 dsv_report_parameters 按报表模板解析控件。
|
||||
program_label: 业务标签(如 AWSRTM);同名报表的站点控件覆盖。
|
||||
|
||||
Raises:
|
||||
RuntimeError: 配置了值但全部填充路径失败(FILL-FAIL-FAST,中止本源触发批内重试)。
|
||||
"""
|
||||
module_path = Path(__file__).resolve().parent / "dsv_report_parameters.py"
|
||||
spec = importlib.util.spec_from_file_location("dsv_report_parameters_runtime", module_path)
|
||||
assert spec and spec.loader
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
module.fill_dsv_filter_if_needed(
|
||||
filled = module.fill_dsv_filter_if_needed(
|
||||
page,
|
||||
selector_env,
|
||||
label,
|
||||
@@ -1192,6 +1195,11 @@ def _fill_dsv_filter_if_needed(
|
||||
report_name=report_name,
|
||||
program_label=program_label,
|
||||
)
|
||||
if not filled:
|
||||
# [FILL-FAIL-FAST] 配置了值但全部填充路径失败时必须中止本源,禁止静默吞掉后在
|
||||
# 错误上下文继续执行(2026-10-09 AWSRTM 串报曾因此连环误报;2026-08-26 AWSRTM
|
||||
# 填参失败曾把空参数报表误报为 skipped)。抛错后由批内重试在干净上下文重来。
|
||||
raise RuntimeError(f"DSV report filter fill failed: {label}={str(value or '').strip()!r}")
|
||||
|
||||
|
||||
def _fill_dsv_multi_select(
|
||||
@@ -1553,8 +1561,58 @@ def _return_to_dsv_report_parameters(page: Any, report_name: str) -> None:
|
||||
_wait_for_dsv_report_form_ready(page, report_name)
|
||||
|
||||
|
||||
def _assert_dsv_report_viewer_identity(page: Any, source: dict[str, Any], *, timeout_ms: int = 10_000) -> None:
|
||||
"""
|
||||
校验报表查看器载入的确实是目标报表,防止"菜单点对、报表开错"。
|
||||
|
||||
核心逻辑:2026-10-09 AWSRTM 生产事故——批内重试导航时菜单 fast-path 全部命中,
|
||||
但 viewer(myIframe) 实际载入了 Bison 的同名 3lv 报表;现有 report_title 子串检查
|
||||
("On Hand Inventory By Location 3lv" 包含 "on hand inventory by location")无法识破。
|
||||
program_label(如 AWSRTM)才是站点唯一标识:只扫描 URL 含 /s360reports/ssrs/ 的
|
||||
viewer frame 正文(portal 顶层 Recent Reports 文本同样含 program_label,禁止全 frame 扫描),
|
||||
超时未命中即抛错,由 _navigate_dsv_to_report_form 整页 reset 后重导一次。
|
||||
|
||||
Args:
|
||||
page: Playwright Page 对象。
|
||||
source: 库存源配置(取 query/navigation.program_label 作身份标识)。
|
||||
timeout_ms: 等待 viewer 标题刷新的上限;超时视为载入了错误报表。
|
||||
|
||||
Raises:
|
||||
RuntimeError: 超时仍未见 program_label(含观测到的 viewer 正文片段,便于定位串报来源)。
|
||||
"""
|
||||
program_label = _dsv_navigation_signature(source)[1]
|
||||
if not program_label:
|
||||
return
|
||||
expected = program_label.strip().lower()
|
||||
deadline = time.monotonic() + max(timeout_ms / 1000, 1)
|
||||
last_viewer_body = ""
|
||||
while True:
|
||||
for frame in page.frames:
|
||||
try:
|
||||
frame_url = str(frame.url or "").lower()
|
||||
except Exception:
|
||||
frame_url = ""
|
||||
if "/s360reports/ssrs/" not in frame_url:
|
||||
continue
|
||||
try:
|
||||
body = frame.locator("body").inner_text(timeout=500).lower()
|
||||
except Exception:
|
||||
body = ""
|
||||
last_viewer_body = body[:300]
|
||||
if expected in body:
|
||||
return
|
||||
if time.monotonic() >= deadline:
|
||||
break
|
||||
time.sleep(0.5)
|
||||
raise RuntimeError(
|
||||
"DSV report viewer identity mismatch: "
|
||||
f"expected program_label={program_label!r} in SSRS viewer title; "
|
||||
f"last_viewer_body={last_viewer_body!r}"
|
||||
)
|
||||
|
||||
|
||||
def _navigate_dsv_to_report_form_once(page: Any, source: dict[str, Any], report_name: str) -> None:
|
||||
"""单次报表导航:开 Reports 菜单 → program_group → program_label → 分组 → 报表 → 等表单就绪。"""
|
||||
"""单次报表导航:开 Reports 菜单 → program_group → program_label → 分组 → 报表 → 等表单就绪 → 校验 viewer 身份。"""
|
||||
query = source.get("query") if isinstance(source.get("query"), dict) else {}
|
||||
navigation = source.get("navigation") if isinstance(source.get("navigation"), dict) else {}
|
||||
reports_selector = _env("FREIGHT_RPA_WORKER_DSV_REPORTS_SELECTOR")
|
||||
@@ -1589,6 +1647,9 @@ def _navigate_dsv_to_report_form_once(page: Any, source: dict[str, Any], report_
|
||||
_click_dsv_menu_item(page, report_name)
|
||||
|
||||
_wait_for_dsv_report_form_ready(page, report_name)
|
||||
# [IDENTITY-GATE] 菜单点击成功≠目标报表已打开:viewer 载错报表时在此快速失败,
|
||||
# 由外层 _navigate_dsv_to_report_form 整页 reset 后重导一次(2026-10-09 AWSRTM 串报)。
|
||||
_assert_dsv_report_viewer_identity(page, source)
|
||||
|
||||
|
||||
def _navigate_dsv_to_report_form(page: Any, source: dict[str, Any]) -> str:
|
||||
|
||||
@@ -45,13 +45,10 @@ def _normalize_report_name(report_name: str) -> str:
|
||||
# 报表名 → 参数控件模板。同名的 SSRS 参数在不同报表里的控件长相不同:
|
||||
# - 3lv 版(On Hand Inventory By Location 3lv,Bison/AWSBI):Warehouse 是原生 select(ddValue);
|
||||
# - JDA 版(On Hand Inventory by Location,Moerdijk 等):Warehouse 是 txtValue + toggle + divDropDown
|
||||
# 组成的多选框下拉(multi_value),历史 YAML 为该源配置的 selectors 即源于此。
|
||||
# - Receipt Detail(Bison/AWSBI 收料):Warehouse 亦为原生 select,但控件位是 ctl27(非库存 ctl17);
|
||||
# 父容器 data-parametername=p_dns_cd_wh(2026-09-28 实机 DOM 核对)。
|
||||
# - Receipt Detail@AWSRTM(Moerdijk 收料):Warehouse 与库存 JDA 同构为 multi_value,控件位 ctl29
|
||||
# (2026-09-28 实机:txtValue + glyphui-downarrow + divDropDown)。
|
||||
# 模板按"归一化报表名"精确匹配;可用 `报表名@program_label` 覆盖站点差异;
|
||||
# 未命中时回退 _DSV_REPORT_PARAM_DEFAULTS(保持旧行为)。
|
||||
# 组成的多选框下拉(multi_value)。
|
||||
# [2026-10-08] SSRS 参数控件 ctl 编号每次渲染都会漂移(实测:昨夜登记的 ctl29=Warehouse,
|
||||
# 今日同页 ctl29=Project ID),ctl 注册条目仅作结构性解析失败时的最后回退;
|
||||
# multi_select 一律优先 resolve_parameter_controls_structural(按 ParamLabelCell 标签现场派生)。
|
||||
_DSV_REPORT_PARAM_TEMPLATES: dict[str, dict[str, dict[str, str]]] = {
|
||||
"on hand inventory by location 3lv": {
|
||||
"Warehouse": {
|
||||
@@ -117,6 +114,61 @@ def resolve_parameter_controls(
|
||||
return dict(template.get(label_key) or {})
|
||||
|
||||
|
||||
# 结构性解析脚本:在 SSRS 参数网格(ParametersGrid)中按 ParamLabelCell 标签定位参数行,
|
||||
# 从行内 _txtValue 的 id 基座派生 multi_value 三件套(_txtValue/_ctl01/_divDropDown)。
|
||||
# 控件位(ctlNN)是随报表实例变化的实现细节,禁止在代码/配置中写死——一律由此派生。
|
||||
_STRUCTURAL_CONTROLS_JS = """(label) => {
|
||||
const wanted = String(label || "").trim().toLowerCase();
|
||||
const rows = Array.from(document.querySelectorAll(
|
||||
"table[id*='ParametersGrid'] tr.isparameterrow, table[id*='ParametersGrid'] tr"));
|
||||
for (const row of rows) {
|
||||
const cell = row.querySelector(".ParamLabelCell");
|
||||
if (!cell) continue;
|
||||
const text = (cell.innerText || cell.textContent || "").trim().toLowerCase();
|
||||
if (text !== wanted) continue;
|
||||
const txt = row.querySelector("[id$='_txtValue']");
|
||||
if (!txt || !txt.id) continue;
|
||||
const base = txt.id.replace(/_txtValue$/, "");
|
||||
const toggle = document.getElementById(base + "_ctl01");
|
||||
const dropdown = document.getElementById(base + "_divDropDown");
|
||||
if (!toggle || !dropdown) return null;
|
||||
return { text: "#" + base + "_txtValue", toggle: "#" + base + "_ctl01", dropdown: "#" + base + "_divDropDown" };
|
||||
}
|
||||
return null;
|
||||
}"""
|
||||
|
||||
|
||||
def resolve_parameter_controls_structural(page: Any, label: str) -> dict[str, str] | None:
|
||||
"""按参数标签在 SSRS 参数网格中结构性解析 multi_value 控件三件套(免硬编码/免发版)。
|
||||
|
||||
【AI 触发时机】:报表/站点的控件位未登记注册表模板时调用(如 Owner@Receipt
|
||||
Detail@AWSRTM);SSRS 参数行自带 ParamLabelCell 标签与 _txtValue/_ctl01/_divDropDown
|
||||
控件族,按标签定位行即可派生控件位,适配任意站点/报表,无需为每个站点改代码。
|
||||
|
||||
核心逻辑:逐 frame 在 ParametersGrid 中找标签匹配的参数行 → 行内 _txtValue 的 id
|
||||
基座 → 校验 _ctl01/_divDropDown 存在 → 返回三件套;任一 frame 命中即返回,
|
||||
全部未命中(或命中但非 multi_value 形态)返回 None,由调用方回退默认/通用路径。
|
||||
|
||||
Args:
|
||||
page: Playwright Page(跨主文档与全部 frame 探测)。
|
||||
label: 参数名(与页面 ParamLabelCell 展示文本一致,如 Owner)。
|
||||
|
||||
Returns:
|
||||
dict[str, str]: {text, toggle, dropdown} 三件套选择器;未命中为 None。
|
||||
"""
|
||||
wanted = str(label or "").strip()
|
||||
if not wanted or page is None:
|
||||
return None
|
||||
for frame in getattr(page, "frames", None) or []:
|
||||
try:
|
||||
found = frame.evaluate(_STRUCTURAL_CONTROLS_JS, wanted)
|
||||
except Exception:
|
||||
continue # 跨域/已销毁帧等探测失败:换下一 frame
|
||||
if isinstance(found, dict) and found.get("text"):
|
||||
return {key: str(found[key]) for key in ("text", "toggle", "dropdown")}
|
||||
return None
|
||||
|
||||
|
||||
def _iter_dsv_report_roots(page: Any) -> list[Any]:
|
||||
"""返回包含 ReportViewerMain 的 frame;找不到时回退到全部 roots。"""
|
||||
matched: list[Any] = []
|
||||
@@ -278,6 +330,21 @@ def _fill_input_via_script(root: Any, selector: str, value: str) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def _multi_value_already_set(current: str, wanted_values: list[str]) -> bool:
|
||||
"""判断 SSRS 多选框 txtValue 是否已"精确等于"目标集合(相等才允许跳过勾选)。
|
||||
|
||||
[2026-10-08 Owner@AWSRTM 事故根因] 旧实现用子串包含判断:多选框默认"全选",
|
||||
txtValue 恒为全量 CSV,任何 CRTM 目标值都是它的子串 → 恒误判"已设置"并跳过
|
||||
下拉勾选,Owner 恒为全部、报表恒为巨量。必须用集合相等判定。
|
||||
"""
|
||||
current = str(current or "").strip()
|
||||
wanted_items = {str(item).strip().casefold() for item in (wanted_values or []) if str(item).strip()}
|
||||
if not current or not wanted_items:
|
||||
return False
|
||||
current_items = {item.strip().casefold() for item in current.split(",") if item.strip()}
|
||||
return current_items == wanted_items
|
||||
|
||||
|
||||
def _fill_multi_value_parameter(
|
||||
page: Any,
|
||||
label: str,
|
||||
@@ -309,7 +376,7 @@ def _fill_multi_value_parameter(
|
||||
if text_locator is not None and not select_all:
|
||||
try:
|
||||
current = str(text_locator.input_value(timeout=2_000) or "").strip()
|
||||
if current and all(item.casefold() in current.casefold() for item in cleaned):
|
||||
if _multi_value_already_set(current, cleaned):
|
||||
print(f"[dsv-filter] {label} already set text={current!r}")
|
||||
return True
|
||||
except Exception:
|
||||
@@ -559,17 +626,23 @@ def fill_dsv_filter_if_needed(
|
||||
debug_stage: Callable[..., None] | None = None,
|
||||
report_name: str | None = None,
|
||||
program_label: str | None = None,
|
||||
) -> None:
|
||||
) -> bool:
|
||||
"""
|
||||
按 ReportViewer 控件类型填充 DSV 报表参数。
|
||||
|
||||
核心逻辑:报表模板(report_name + program_label)命中时整表替换默认控件;
|
||||
multi_value(如 Receipt Detail@AWSRTM Warehouse=ctl29)优先勾选 checkbox,
|
||||
失败时只回退同模板 txtValue,禁止残留默认 ctl17_ddValue 误走库存 select。
|
||||
|
||||
Returns:
|
||||
bool: True 表示已填充或合法跳过(值为空/未配置控件);False 表示配置了值
|
||||
但全部填充路径失败——调用方(导出包装层)必须据此中止本源,禁止静默吞掉
|
||||
后在错误上下文继续执行(2026-10-09 AWSRTM 串报事故链之一,2026-08-26
|
||||
AWSRTM 填参失败曾误报 skipped)。
|
||||
"""
|
||||
text = str(value or "").strip()
|
||||
if not text:
|
||||
return
|
||||
return True
|
||||
|
||||
def _debug(stage: str, target: str) -> None:
|
||||
if debug_stage is not None:
|
||||
@@ -582,7 +655,7 @@ def fill_dsv_filter_if_needed(
|
||||
if label not in {"Warehouse", "Owner", "PutawayZone"}:
|
||||
print(f"[dsv-filter] {label} already visible text={text!r}")
|
||||
_debug(f"filter-skip-{label.lower()}", text)
|
||||
return
|
||||
return True
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -607,7 +680,7 @@ def fill_dsv_filter_if_needed(
|
||||
if not selector and not defaults:
|
||||
print(f"[dsv] skip {label} filter; no selector configured")
|
||||
_debug(f"filter-no-selector-{label.lower()}", text)
|
||||
return
|
||||
return True
|
||||
|
||||
values = [part.strip() for part in text.split(",") if part.strip()] if label == "PutawayZone" else [text]
|
||||
|
||||
@@ -617,7 +690,7 @@ def fill_dsv_filter_if_needed(
|
||||
page, label, values, timeout_ms=timeout_ms, config_override=defaults,
|
||||
):
|
||||
_debug(f"filter-filled-{label.lower()}", text)
|
||||
return
|
||||
return True
|
||||
|
||||
# [STEP 2] 仅当控件类型确认为 select 时走 ddValue;禁止用 endswith(ddValue) 盖过 multi_value。
|
||||
if defaults.get("control") == "select":
|
||||
@@ -626,7 +699,7 @@ def fill_dsv_filter_if_needed(
|
||||
page, label, text, select_selector, timeout_ms=timeout_ms,
|
||||
):
|
||||
_debug(f"filter-filled-{label.lower()}", text)
|
||||
return
|
||||
return True
|
||||
|
||||
# [STEP 3] 文本输入/脚本兜底:适用于普通文本参数与多选控件的输入框。
|
||||
if not selector:
|
||||
@@ -637,12 +710,12 @@ def fill_dsv_filter_if_needed(
|
||||
)
|
||||
print(f"[dsv] failed to fill {label} filter text={text!r}", file=sys.stderr)
|
||||
_debug(f"filter-failed-{label.lower()}", text)
|
||||
return
|
||||
return False
|
||||
print(f"[dsv-filter] filling {label} text={text!r} selector={selector!r}")
|
||||
for root in _iter_dsv_report_roots(page):
|
||||
if _fill_input_via_script(root, selector, text):
|
||||
_debug(f"filter-filled-{label.lower()}", text)
|
||||
return
|
||||
return True
|
||||
|
||||
# 最后回退:Playwright fill(适用于普通文本参数)
|
||||
_, locator = _find_locator(page, selector)
|
||||
@@ -651,7 +724,7 @@ def fill_dsv_filter_if_needed(
|
||||
try:
|
||||
locator.fill(text, timeout=timeout_ms)
|
||||
_debug(f"filter-filled-{label.lower()}", text)
|
||||
return
|
||||
return True
|
||||
except Exception as exc:
|
||||
print(f"[dsv-filter] {label} fill fallback failed: {exc}", file=sys.stderr)
|
||||
|
||||
@@ -663,6 +736,7 @@ def fill_dsv_filter_if_needed(
|
||||
)
|
||||
print(f"[dsv] failed to fill {label} filter text={text!r}", file=sys.stderr)
|
||||
_debug(f"filter-failed-{label.lower()}", text)
|
||||
return False
|
||||
|
||||
|
||||
def fill_dsv_multi_select_parameter(
|
||||
@@ -680,11 +754,16 @@ def fill_dsv_multi_select_parameter(
|
||||
填充由 YAML `mode: multi_select` 显式声明的 SSRS checkbox 下拉参数。
|
||||
【AI 触发时机】:当 DSV 报表参数不是原生 select,而是 `txtValue + divDropDown + checkbox`
|
||||
组合控件时调用;例如 AWSAMS / AWSRTM 的 Warehouse 下拉需要多选或全选。
|
||||
核心逻辑:selectors 缺省时按报表模板(report_name + program_label)解析控件;两者都没有则返回 False。
|
||||
核心逻辑:selectors 缺省时**优先按参数标签结构性解析控件位**——SSRS 参数控件的
|
||||
ctl 编号每次渲染都会漂移(2026-10-08 实测:昨夜登记的 ctl29 今日漂移为 Project ID,
|
||||
RTM 被写进错误栏位),任何 ctl 编号注册条目都不可靠;结构性解析失败才回退
|
||||
报表模板/默认表。两者都没有则返回 False。
|
||||
"""
|
||||
config_override = {"control": "multi_value"}
|
||||
effective_selectors = selectors or (
|
||||
resolve_parameter_controls(report_name, label, program_label=program_label) or None
|
||||
resolve_parameter_controls_structural(page, label)
|
||||
or resolve_parameter_controls(report_name, label, program_label=program_label)
|
||||
or None
|
||||
)
|
||||
if effective_selectors:
|
||||
for key in ("text", "toggle", "dropdown"):
|
||||
|
||||
@@ -1308,10 +1308,32 @@ def _emit_batch_progress(body: dict[str, Any], run_no: str, results: list[dict[s
|
||||
|
||||
|
||||
# 批内单源导出的暂态失败重试参数:DSV s360 服务端报表错误(rsProcessingAborted 等)
|
||||
# 属暂态故障(AWSRTM 2026-09-20 生产实测),失败源重新导航后重试一次,间隔 30s 覆盖
|
||||
# SSRS 端恢复窗口;不设 env 开关,保持行为确定。
|
||||
# 属暂态故障(AWSRTM 2026-09-20 生产实测),失败源重新导航后重试;不设 env 开关,保持行为确定。
|
||||
# 2026-10-09 补充:rsPutawayZone 每日首跑失败(09-29~10-09 共 6 个早晨)为数据集执行
|
||||
# 超时/后端早批窗口类暂态,恢复窗口是分钟级——此类错误定向放宽到 3 次尝试、每次间隔
|
||||
# 120s,最大化当日导出成功率;其余错误维持 2 次/30s,避免非暂态失败拖长批次。
|
||||
_EXPORT_SOURCE_MAX_ATTEMPTS = 2
|
||||
_EXPORT_SOURCE_RETRY_WAIT_SECONDS = 30
|
||||
_EXPORT_SOURCE_MAX_PROCESSING_ATTEMPTS = 3
|
||||
_EXPORT_SOURCE_RETRY_WAIT_PROCESSING_ERROR_SECONDS = 120
|
||||
|
||||
|
||||
def _export_source_retry_wait_seconds(exc: Exception) -> int:
|
||||
"""按异常类型选择批内重试等待时长:processing error(首跑数据集超时类)用更长窗口。"""
|
||||
return (
|
||||
_EXPORT_SOURCE_RETRY_WAIT_PROCESSING_ERROR_SECONDS
|
||||
if isinstance(exc, DsvReportProcessingError)
|
||||
else _EXPORT_SOURCE_RETRY_WAIT_SECONDS
|
||||
)
|
||||
|
||||
|
||||
def _export_source_max_attempts(exc: Exception) -> int:
|
||||
"""按异常类型选择批内重试次数上限:processing error 类 3 次,其余 2 次。"""
|
||||
return (
|
||||
_EXPORT_SOURCE_MAX_PROCESSING_ATTEMPTS
|
||||
if isinstance(exc, DsvReportProcessingError)
|
||||
else _EXPORT_SOURCE_MAX_ATTEMPTS
|
||||
)
|
||||
|
||||
|
||||
def _handle_inventory_batch_trigger(trigger_path: Path, drop_dir: Path, processed_dir: Path) -> None:
|
||||
@@ -1509,10 +1531,15 @@ def _handle_inventory_batch_trigger(trigger_path: Path, drop_dir: Path, processe
|
||||
if site == "dsv360":
|
||||
# [STEP 3] 批内同一 Profile 只登录一次:首源完整登录,后续源复用当前 tab
|
||||
# 的登录态——同导航走 _return_to_dsv_report_parameters 复用参数页,
|
||||
# 导航不同走 _reset_dsv_export_entry(goto entry + 会话检测,不重复 OAuth)。
|
||||
# 导航不同直接从当前报表上下文展开菜单导航(不重复 OAuth)。
|
||||
# 曾因"每源新开空白页 + 写死 index=0"导致每源重复走 SSO 重定向链
|
||||
# (每源 2-2.5 分钟,且偶发 OAuth 空白页单源失败),现已移除。
|
||||
# 页面串站状态由整页/帧重载兜底,无需隔离页。
|
||||
# [RETRY-RESET] 2026-10-09 AWSRTM 生产事故:attempt 1 失败后页面残留
|
||||
# SSRS 错误页/旧菜单 DOM,在其上直接重开菜单曾把错误报表(Bison 3lv)
|
||||
# 载入 viewer。重试(attempt>1)先整页回 portal 首页清场再导航。
|
||||
if attempt > 1:
|
||||
dsv_report_export.reset_dsv_export_entry(page, entry_url)
|
||||
previous_source = site_sources[index - 1] if index > 0 else None
|
||||
try:
|
||||
# 返回 True 表示参数页已就绪:后续跳过菜单导航直接填参/导出。
|
||||
@@ -1563,14 +1590,15 @@ def _handle_inventory_batch_trigger(trigger_path: Path, drop_dir: Path, processe
|
||||
if isinstance(exc, DsvReportProcessingError)
|
||||
else "rpa_export_failed"
|
||||
)
|
||||
if attempt < _EXPORT_SOURCE_MAX_ATTEMPTS:
|
||||
if attempt < _export_source_max_attempts(exc):
|
||||
retry_wait_seconds = _export_source_retry_wait_seconds(exc)
|
||||
print(
|
||||
f"[inventory-batch] {site} export failed {code}/{wh} "
|
||||
f"(attempt {attempt}/{_EXPORT_SOURCE_MAX_ATTEMPTS}), "
|
||||
f"retry in {_EXPORT_SOURCE_RETRY_WAIT_SECONDS}s: {exc}",
|
||||
f"(attempt {attempt}/{_export_source_max_attempts(exc)}), "
|
||||
f"retry in {retry_wait_seconds}s: {exc}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
time.sleep(_EXPORT_SOURCE_RETRY_WAIT_SECONDS)
|
||||
time.sleep(retry_wait_seconds)
|
||||
continue
|
||||
record_result({"source_code": code, "warehouse_id": wh, "status": "failed", "success": False, "error_code": error_code, "error_message": str(exc), "worker_attempt": attempt, "validation_run_no": source.get("validation_run_no")})
|
||||
print(f"[inventory-batch] {site} export failed {code}/{wh}: {exc}", file=sys.stderr)
|
||||
|
||||
Reference in new issue
Block a user