AutoRpa/rpa_rebate/run_import.py

32 lines
1.2 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 页面细单新增入口(按货品ID搜,不做 Excel)。不连 Oracle、不送审、不写 actionCode=2。验收只看 ACCEPT.txt。
from __future__ import annotations
import os
from pathlib import Path
from apa_browser_adapter import ApaBrowserAdapter
from rpa_oracle import load_job_env
from rebate_finder import context_from_env
from rebate_flow_steps import import_draft_for_contract, run_import_flow
# 只跑细单新增。按货品 ID 搜,不做 Excel。货品表有成功行且没有失败行才算通过。不写表。
def main() -> int:
load_job_env(Path(__file__).resolve().parent)
contract_no = (os.getenv("REBATE_ACCEPT_CONTRACT_NO") or "").strip()
if not contract_no:
print("缺少 REBATE_ACCEPT_CONTRACT_NO,细单新增需要已搜到的合同号", flush=True)
return 1
ctx = context_from_env()
draft = import_draft_for_contract(contract_no)
browser = ApaBrowserAdapter(url=ctx.rebate_url, flow="REBATE_IMPORT")
result = run_import_flow(browser, ctx, contract_no, draft)
if result.parsed and result.fail_count == 0 and result.success_count > 0:
return 0
return 1
if __name__ == "__main__":
raise SystemExit(main())