weaver-work-cli 0.1.49 → 0.1.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/chunks/{attachment-content-MU2LPI5P.js → attachment-content-MBYYSQIX.js} +3 -3
- package/dist/chunks/{chunk-ZKEUGS2U.js → chunk-7UOXOGFL.js} +4 -4
- package/dist/chunks/{chunk-72MI3MBX.js → chunk-ATEXBEPD.js} +55 -15
- package/dist/chunks/{chunk-3NV2ETZR.js → chunk-D3TDNRFE.js} +8 -8
- package/dist/chunks/{chunk-6GWU63YF.js → chunk-DZOC77ZD.js} +1 -1
- package/dist/chunks/{chunk-K3BT54CU.js → chunk-IRMA3GVP.js} +1 -1
- package/dist/chunks/{chunk-3X7VOSBA.js → chunk-KLZ3ULQQ.js} +1 -1
- package/dist/chunks/{chunk-YLCYX7LE.js → chunk-KMRT7NAT.js} +18 -5
- package/dist/chunks/{chunk-NBEWUR7L.js → chunk-LALWNK6M.js} +167 -44
- package/dist/chunks/{chunk-BRRW7CWA.js → chunk-LM2H7SZI.js} +26 -26
- package/dist/chunks/{chunk-KV5SOWMS.js → chunk-LTRLF6MM.js} +4 -4
- package/dist/chunks/{chunk-D2QRZUW4.js → chunk-RPRFIG6I.js} +35 -28
- package/dist/chunks/{chunk-GEOMANP7.js → chunk-RWFRZSIP.js} +2 -2
- package/dist/chunks/{chunk-EJVA5ZVB.js → chunk-ZRHKGQRQ.js} +2 -2
- package/dist/chunks/{conflict-6347A7YK.js → conflict-D2HYKBMH.js} +2 -2
- package/dist/chunks/{contract-N6P2HIIE.js → contract-MFOFMM2J.js} +4284 -254
- package/dist/chunks/{create-flow-7WG7LVX5.js → create-flow-7ZATJVTM.js} +6 -6
- package/dist/chunks/{data-QO7QWOIV.js → data-WK5CQXNF.js} +17 -32
- package/dist/chunks/{env-LHRKSLG6.js → env-5DO4YENS.js} +2 -2
- package/dist/chunks/{factory-2H7Z4RWJ.js → factory-3M7D7WJC.js} +1 -1
- package/dist/chunks/{fna-ZVB2IILI.js → fna-ECOYBQYL.js} +328 -5
- package/dist/chunks/{group-chat-EW6PNDDT.js → group-chat-B2HT5NEO.js} +3 -3
- package/dist/chunks/{im-3RCNL5GT.js → im-TN2JYVGJ.js} +2 -2
- package/dist/chunks/{invoice-FXWH5GPO.js → invoice-V7ZTITUO.js} +726 -206
- package/dist/chunks/{meeting-N2FQBHXI.js → meeting-HZOX3CBB.js} +10 -10
- package/dist/chunks/{msg-parse-4GSQ2WTO.js → msg-parse-FPFVPMYI.js} +5 -1
- package/dist/chunks/{reception-MYOKJULO.js → reception-QGPNTGHG.js} +98 -82
- package/dist/chunks/{recruit-stage-FKWS5UQF.js → recruit-stage-XCMVEQA2.js} +718 -131
- package/dist/chunks/{registry-BUTEDK3C.js → registry-E5RQJVWN.js} +2 -2
- package/dist/chunks/{registry-7VZ6YJUF.js → registry-KYPFFQIH.js} +1 -1
- package/dist/chunks/{registry-CKUVBS53.js → registry-SJHSBO5G.js} +10 -10
- package/dist/chunks/{room-recommend-MBCYENQ2.js → room-recommend-5AHR4YQV.js} +4 -4
- package/dist/chunks/{schedule-5IFMCXME.js → schedule-KZPJUPC2.js} +4 -4
- package/dist/chunks/smart-extract-IXHCZE4R.js +2846 -0
- package/dist/chunks/{workflow-2TRU2ZSP.js → workflow-UHKCZJMY.js} +1 -1
- package/dist/index.js +14 -9
- package/dist/shortcuts/contract/host.js +11 -0
- package/dist/shortcuts/contract/index.js +13 -0
- package/dist/shortcuts/contract/manifest.js +204 -0
- package/dist/shortcuts/contract/operations/card-action.js +585 -0
- package/dist/shortcuts/contract/operations/card-ebdf-list.js +315 -0
- package/dist/shortcuts/contract/operations/card-plan.js +327 -0
- package/dist/shortcuts/contract/operations/card-risk-report.js +565 -0
- package/dist/shortcuts/contract/operations/elements-build.js +714 -0
- package/dist/shortcuts/contract/operations/elements-spec.js +216 -0
- package/dist/shortcuts/contract/operations/first-screen.js +563 -0
- package/dist/shortcuts/contract/operations/flow.js +81 -25
- package/dist/shortcuts/contract/operations/modeltext.js +132 -0
- package/dist/shortcuts/contract/operations/op-resolver.js +22 -0
- package/dist/shortcuts/contract/operations/performance.js +58 -7
- package/dist/shortcuts/contract/operations/quote.js +410 -22
- package/dist/shortcuts/contract/operations/registry.js +22 -0
- package/dist/shortcuts/contract/operations/review.js +73 -58
- package/dist/shortcuts/contract/operations/save-recognize.js +151 -0
- package/dist/shortcuts/contract/operations/summary-validate.js +293 -0
- package/dist/shortcuts/contract/operations/summary.js +4 -2
- package/dist/shortcuts/contract/operations/upload.js +48 -7
- package/dist/shortcuts/contract/prewarm-cache.js +90 -0
- package/dist/shortcuts/contract/prewarm.js +88 -0
- package/dist/shortcuts/contract/upload-cache.js +49 -4
- package/dist/shortcuts/data/index.js +1 -6
- package/dist/shortcuts/data/manifest.js +2 -2
- package/dist/shortcuts/data/operations/index.js +1 -1
- package/dist/shortcuts/data/operations/query.js +23 -46
- package/dist/shortcuts/fna/host.js +4 -2
- package/dist/shortcuts/fna/manifest.js +14 -5
- package/dist/shortcuts/fna/operations/audit.js +334 -0
- package/dist/shortcuts/fna/operations/registry.js +2 -0
- package/dist/shortcuts/im/operations/at-mention.js +6 -3
- package/dist/shortcuts/im/operations/msg-parse.js +35 -5
- package/dist/shortcuts/im/operations/msg-sync.js +3 -1
- package/dist/shortcuts/im/operations/msg-write.js +57 -9
- package/dist/shortcuts/index.js +5 -0
- package/dist/shortcuts/invoice/index.js +0 -12
- package/dist/shortcuts/invoice/manifest.js +201 -50
- package/dist/shortcuts/invoice/operations/registry.js +4 -2
- package/dist/shortcuts/invoice/operations/reim-relation.js +438 -0
- package/dist/shortcuts/invoice/operations/shared.js +3 -19
- package/dist/shortcuts/invoice/operations/upload-and-validate.js +109 -73
- package/dist/shortcuts/meeting/operations/from-group-chat.js +16 -2
- package/dist/shortcuts/reception/constants.js +3 -7
- package/dist/shortcuts/reception/operations/leads.js +30 -6
- package/dist/shortcuts/reception/operations/panels.js +3 -2
- package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +4 -2
- package/dist/shortcuts/recruit-stage/operations/jd-create.js +6 -2
- package/dist/shortcuts/recruit-stage/operations/list.js +217 -1
- package/dist/shortcuts/recruit-stage/operations/resume-import.js +144 -158
- package/dist/shortcuts/recruit-stage/operations/search.js +348 -0
- package/dist/shortcuts/recruit-stage/shared.js +5 -0
- package/dist/shortcuts/recruit-stage/tag-lookup.js +136 -0
- package/dist/shortcuts/smart-extract/constants.js +79 -0
- package/dist/shortcuts/smart-extract/continuation.js +71 -0
- package/dist/shortcuts/smart-extract/errors.js +68 -0
- package/dist/shortcuts/smart-extract/host.js +191 -0
- package/dist/shortcuts/smart-extract/index.js +105 -0
- package/dist/shortcuts/smart-extract/ledger.js +70 -0
- package/dist/shortcuts/smart-extract/manifest.js +35 -0
- package/dist/shortcuts/smart-extract/operations/attachment.js +212 -0
- package/dist/shortcuts/smart-extract/operations/batch.js +67 -0
- package/dist/shortcuts/smart-extract/operations/config.js +118 -0
- package/dist/shortcuts/smart-extract/operations/fill.js +489 -0
- package/dist/shortcuts/smart-extract/operations/preview.js +174 -0
- package/dist/shortcuts/smart-extract/operations/registry.js +34 -0
- package/dist/shortcuts/smart-extract/operations/save.js +355 -0
- package/dist/shortcuts/smart-extract/operations/shared.js +191 -0
- package/dist/shortcuts/smart-extract/operations/structure.js +401 -0
- package/dist/shortcuts/smart-extract/operations/target.js +167 -0
- package/dist/shortcuts/smart-extract/operations/types.js +22 -0
- package/dist/shortcuts/smart-extract/operations/validate.js +408 -0
- package/dist/shortcuts/workflow/operations/read.js +77 -15
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +140 -24
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +42 -14
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +4 -6
- package/docs/SKILL.md +1 -1
- package/docs/_catalog.md +4 -1
- package/docs/agent-invoice.md +5 -7
- package/docs/data.md +5 -1
- package/docs/fna.md +24 -4
- package/docs/invoice.md +7 -5
- package/docs/smart-extract.md +156 -0
- package/package.json +1 -1
- package/skill-template/business-info.json +21 -1
- package/skill-template/domains/qiyecheng.md +6 -2
- package/skill-template/domains/smart-extract.md +16 -0
- package/skill-template/domains/yepiaotong.md +2 -2
- package/skills/weaver-e10-data/references/scene-and-misc.md +4 -3
- package/skills/weaver-e10-jinchengda/SKILL.md +159 -11
- package/skills/weaver-e10-jinchengda/references/contract-action-card.md +13 -8
- package/skills/weaver-e10-jinchengda/references/contract-action-engine.md +5 -4
- package/skills/weaver-e10-jinchengda/references/contract-clause-library-crud.md +44 -2
- package/skills/weaver-e10-jinchengda/references/contract-command-index.md +2 -2
- package/skills/weaver-e10-jinchengda/references/contract-element-save-record.md +220 -0
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +68 -33
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +26 -15
- package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-modeltext-library.md +128 -0
- package/skills/weaver-e10-jinchengda/references/contract-multi-file.md +90 -0
- package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +96 -2
- package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +167 -5
- package/skills/weaver-e10-jinchengda/scripts/contract_first_screen.py +200 -0
- package/skills/weaver-e10-jinchengda/scripts/fill_contract_from_quote.py +572 -0
- package/skills/weaver-e10-jinchengda/scripts/fill_plan.py +997 -0
- package/skills/weaver-e10-jinchengda/scripts/quote_screen.py +560 -0
- package/skills/weaver-e10-jinchengda/scripts/triage_contract.py +894 -0
- package/skills/weaver-e10-jinchengda/scripts/validate_action_card.py +93 -0
- package/skills/weaver-e10-jinchengda/scripts/verify_docx_placeholders.py +118 -0
- package/skills/weaver-e10-qiyecheng/SKILL.md +58 -7
- package/skills/weaver-e10-qiyecheng/references/ai-check-audit.md +118 -0
- package/skills/weaver-e10-qiyecheng/references/budget.md +14 -0
- package/skills/weaver-e10-qiyecheng/references/catalog.md +42 -3
- package/skills/weaver-e10-qiyecheng/references/expense-center.md +8 -0
- package/skills/weaver-e10-qiyecheng/references/expense-chart.md +9 -0
- package/skills/weaver-e10-qiyecheng/references/invoice-writeoff.md +13 -0
- package/skills/weaver-e10-qiyecheng/references/loan-management.md +14 -0
- package/skills/weaver-e10-qiyecheng/references/self-hosted-mode.md +239 -0
- package/skills/weaver-e10-qiyecheng/references/source-manifest.json +153 -40
- package/skills/weaver-e10-reception-flow/SKILL.md +43 -6
- package/skills/weaver-e10-reception-flow/references/guide.md +1 -1
- package/skills/weaver-e10-recruit-stage/SKILL.md +62 -4
- package/skills/weaver-e10-recruit-stage/agents/openai.yaml +42 -8
- package/skills/weaver-e10-recruit-stage/references/env-ziyong.md +79 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +11 -3
- package/skills/weaver-e10-recruit-stage/references/recruit-edit-interview-feedback.md +3 -2
- package/skills/weaver-e10-recruit-stage/references/recruit-interview-not-attended.md +153 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +7 -4
- package/skills/weaver-e10-recruit-stage/references/recruit-match-candidates.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-my-positions.md +66 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +156 -40
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import-batch.md +122 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +36 -8
- package/skills/weaver-e10-recruit-stage/references/recruit-search-by-tag.md +157 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-utterance-glossary.md +35 -0
- package/skills/weaver-e10-smart-extract/SKILL.md +169 -0
- package/skills/weaver-e10-smart-extract/references/api-contract.md +71 -0
- package/skills/weaver-e10-smart-extract/references/result-format.md +102 -0
- package/skills/weaver-e10-smart-extract/references/troubleshooting.md +105 -0
- package/skills/weaver-e10-workflow/SKILL.md +2 -1
- package/skills/weaver-e10-workflow/references/todo-smart-convert.md +29 -6
- package/skills/weaver-e10-workflow/references/workflow-query.md +1 -1
- package/skills/weaver-e10-workflow/references/workflow-view.md +1 -1
- package/skills/weaver-e10-workflow/tools/todo-summary.cjs +162 -10
- package/skills/weaver-e10-yepiaotong/SKILL.md +53 -35
- package/skills/weaver-e10-yepiaotong/references/invoice-add.md +2 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-file-upload.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-import.md +19 -2
- package/skills/weaver-e10-yepiaotong/references/invoice-issuing-workflow.md +19 -32
- package/skills/weaver-e10-yepiaotong/references/invoice-ocr-preview.md +8 -2
- package/skills/weaver-e10-yepiaotong/references/invoice-reim-relation.md +407 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +18 -53
- package/skills/weaver-e10-yepiaotong/references/invoice-upload-and-validate.md +97 -39
- package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +96 -7
- package/skills/weaver-e10-yepiaotong/references/reim-examples.md +5 -38
- package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +14 -14
- package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +8 -4
- package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +139 -94
- package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +131 -58
- package/skills/weaver-e10-yepiaotong/references/source-manifest.json +110 -43
- package/skills/weaver-e10-yimiaoban/SKILL.md +8 -6
- package/skills/weaver-e10-yimiaoban/references/msg-read.md +20 -0
- package/skills/weaver-e10-yimiaoban/references/msg-write.md +7 -0
- package/skills/weaver-e10-yimiaoban/references/source-manifest.json +18 -15
- package/dist/shortcuts/invoice/operations/validate-preview.js +0 -40
- package/skills/weaver-e10-jinchengda/scripts/plan_actions.py +0 -279
- package/skills/weaver-e10-jinchengda/scripts/render_action_card.py +0 -450
- package/skills/weaver-e10-jinchengda/scripts/render_risk_report.py +0 -358
- package/skills/weaver-e10-yepiaotong/references/invoice-validation-preview.md +0 -40
|
@@ -0,0 +1,560 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""
|
|
4
|
+
quote_screen.py — 报价单首屏(2026-11-11 新增,与 first_screen.py 对称)
|
|
5
|
+
|
|
6
|
+
背景:合同有 contract_first_screen.cmd 快路径,报价单没有,只能由模型手工串联
|
|
7
|
+
quote.sheets → quote.parse → render_action_card → validate,
|
|
8
|
+
天然摊成 4~5 轮。本脚本把这条链固化为两阶段,目标是报价单首屏 ≤3 轮。
|
|
9
|
+
|
|
10
|
+
设计要点:
|
|
11
|
+
1) 语义由模型判定:脚本只把 xlsx 还原成原始网格(extract)与金额结构(parse),
|
|
12
|
+
客户名称/税率/汇总表标记一律由模型读 rows 后产出,不在这里猜。
|
|
13
|
+
2) 两阶段:阶段1 出 sheets + raw_grid + parsed + 要素骨架;
|
|
14
|
+
阶段2 收模型 summary_data.json,产出「文字摘要」与动作卡片。
|
|
15
|
+
3) 报价单**不出摘要卡片、不生成摘要 HTML**(2026-11-11 用户指定):
|
|
16
|
+
报价单只是报价口径,摘要价值低,用对话正文几行文字说清即可;
|
|
17
|
+
省掉 summary render 与卡片内嵌 HTML,可再少 1~2 轮往返。
|
|
18
|
+
|
|
19
|
+
用法(Windows PowerShell / cmd):
|
|
20
|
+
阶段1:
|
|
21
|
+
contract_quote_screen.cmd --file "D:/q/报价.xlsx" --out-dir "D:/tmp/out"
|
|
22
|
+
阶段2:
|
|
23
|
+
contract_quote_screen.cmd --file "D:/q/报价.xlsx" --out-dir "D:/tmp/out" `
|
|
24
|
+
--summary-data "D:/tmp/out/summary_data.json" --company-name "某公司全称"
|
|
25
|
+
|
|
26
|
+
退出码:0 成功;1 CLI 调用失败;2 参数错误;3 卡片未产出
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
import argparse
|
|
30
|
+
import io
|
|
31
|
+
import json
|
|
32
|
+
import os
|
|
33
|
+
import shutil
|
|
34
|
+
import subprocess
|
|
35
|
+
import sys
|
|
36
|
+
import time
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _find_cli():
|
|
40
|
+
"""直接使用 PATH 中的 weaver-work-cli(requires.bins 已声明该依赖)。
|
|
41
|
+
|
|
42
|
+
历史版本把 C:\\Users\\Administrator\\... 写死在模块级常量里,换机即失效且
|
|
43
|
+
没有任何回退;自行探测客户端安装目录同样属于规范禁止的 bootstrap 脚本。
|
|
44
|
+
仅保留环境变量与 PATH 两种显式来源。
|
|
45
|
+
|
|
46
|
+
2026-11-12 修正:Windows 下 subprocess 走 CreateProcessW,不解析 PATHEXT,
|
|
47
|
+
裸名 "weaver-work-cli" 不会被补全成 .cmd,进程启动阶段即抛 [WinError 2],
|
|
48
|
+
报价单首屏 --auto 必然失败且无覆盖入口。改用 shutil.which 解析完整路径,
|
|
49
|
+
解析不到时才回退裸名。
|
|
50
|
+
"""
|
|
51
|
+
explicit = os.environ.get("WEAVER_WORK_CLI")
|
|
52
|
+
if explicit:
|
|
53
|
+
return explicit
|
|
54
|
+
return shutil.which("weaver-work-cli") or "weaver-work-cli"
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
CLI = _find_cli()
|
|
58
|
+
PY = sys.executable
|
|
59
|
+
SKILL_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
60
|
+
SCRIPTS = os.path.join(SKILL_DIR, "scripts")
|
|
61
|
+
BASE = "https://www.e-cology.com.cn"
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _run(args, timeout=180):
|
|
65
|
+
"""执行命令并返回 (ok, stdout, stderr)。stderr 只作诊断,成败看 JSON ok。"""
|
|
66
|
+
try:
|
|
67
|
+
p = subprocess.run(args, capture_output=True, timeout=timeout)
|
|
68
|
+
out = p.stdout.decode("utf-8", "replace")
|
|
69
|
+
err = p.stderr.decode("utf-8", "replace")
|
|
70
|
+
return p.returncode == 0, out, err
|
|
71
|
+
except Exception as e: # noqa: BLE001
|
|
72
|
+
return False, "", str(e)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def cli_json(operation, payload, tmp_dir, tag):
|
|
76
|
+
"""调 CLI 并解析 JSON envelope;成败只看 ok 字段,不看退出码(stderr 提示会污染退出码)。"""
|
|
77
|
+
argf = os.path.join(tmp_dir, "args_%s.json" % tag)
|
|
78
|
+
with io.open(argf, "w", encoding="utf-8") as f:
|
|
79
|
+
json.dump(payload, f, ensure_ascii=False)
|
|
80
|
+
ok, out, err = _run([CLI, "--runtime-agent", "xiaoe", "--json",
|
|
81
|
+
"contract", "run", operation, "--input", argf])
|
|
82
|
+
try:
|
|
83
|
+
start = out.index("{")
|
|
84
|
+
data = json.loads(out[start:])
|
|
85
|
+
except Exception:
|
|
86
|
+
return None, (out or err or "无输出")
|
|
87
|
+
return data, ""
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def write_json(path, obj):
|
|
91
|
+
with io.open(path, "w", encoding="utf-8") as f:
|
|
92
|
+
json.dump(obj, f, ensure_ascii=False, indent=2)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
# 预览关键词。模型判定客户名/税率/汇总表只需这些行,
|
|
96
|
+
# 直接在本轮打印可省掉「再读一次 raw_grid.json」的一轮往返。
|
|
97
|
+
PREVIEW_KEYS = ["客户", "用户名称", "甲方", "报价日期", "有效", "税率", "合计",
|
|
98
|
+
"标准价", "最终优惠", "总价", "汇总", "总计"]
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def preview(rows, head=12):
|
|
102
|
+
"""打印前 head 行 + 关键词命中行,供模型直接判语义。"""
|
|
103
|
+
total = len(rows)
|
|
104
|
+
|
|
105
|
+
def fmt(i, r):
|
|
106
|
+
cells = [c for c in r if str(c).strip()]
|
|
107
|
+
return "r%-3d %s" % (i + 1, " | ".join(str(c).strip()[:40] for c in cells))
|
|
108
|
+
|
|
109
|
+
print("---- GRID HEAD ----")
|
|
110
|
+
for i in range(min(head, total)):
|
|
111
|
+
line = fmt(i, rows[i])
|
|
112
|
+
if line.strip():
|
|
113
|
+
print(line)
|
|
114
|
+
|
|
115
|
+
print("---- GRID KEY HITS ----")
|
|
116
|
+
shown = set()
|
|
117
|
+
for i, r in enumerate(rows):
|
|
118
|
+
joined = "".join(str(c) for c in r)
|
|
119
|
+
if any(k in joined for k in PREVIEW_KEYS):
|
|
120
|
+
if i in shown:
|
|
121
|
+
continue
|
|
122
|
+
shown.add(i)
|
|
123
|
+
print(fmt(i, r))
|
|
124
|
+
|
|
125
|
+
if total > head:
|
|
126
|
+
print("NOTE 完整网格共 %d 行,见 raw_grid.json;上面只给头部与关键词行" % total)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def _money(v):
|
|
130
|
+
"""金额格式化:整数加千分位,非数字原样返回。"""
|
|
131
|
+
try:
|
|
132
|
+
n = float(v)
|
|
133
|
+
except (TypeError, ValueError):
|
|
134
|
+
return str(v) if v not in (None, "") else ""
|
|
135
|
+
if abs(n - int(n)) < 1e-9:
|
|
136
|
+
return "{:,}".format(int(n))
|
|
137
|
+
return "{:,.2f}".format(n)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def build_text_summary(sd):
|
|
141
|
+
"""把 summary_data.json 压成对话可直接使用的纯文字摘要(不出 HTML、不出卡片)。
|
|
142
|
+
|
|
143
|
+
结构兼容两种写法:
|
|
144
|
+
- sections[].type='table' 且带 rows/total → 取第一条作为「费用构成」
|
|
145
|
+
- sections[].type='list' / 'reasons' → 取 items 作为「要点」
|
|
146
|
+
模型只需给 meta / totals / sections,无需为文字摘要额外改造格式。
|
|
147
|
+
"""
|
|
148
|
+
if not isinstance(sd, dict):
|
|
149
|
+
sd = {}
|
|
150
|
+
lines = []
|
|
151
|
+
title = sd.get("title") or "报价单"
|
|
152
|
+
meta = sd.get("meta")
|
|
153
|
+
if not isinstance(meta, dict):
|
|
154
|
+
meta = {}
|
|
155
|
+
totals = sd.get("totals")
|
|
156
|
+
if not isinstance(totals, dict):
|
|
157
|
+
totals = {}
|
|
158
|
+
|
|
159
|
+
head = "报价单:%s" % title
|
|
160
|
+
lines.append(head)
|
|
161
|
+
|
|
162
|
+
who = []
|
|
163
|
+
if meta.get("customer"):
|
|
164
|
+
who.append("客户:%s" % meta["customer"])
|
|
165
|
+
if meta.get("quote_date"):
|
|
166
|
+
who.append("报价日期:%s" % meta["quote_date"])
|
|
167
|
+
if meta.get("sales"):
|
|
168
|
+
who.append("客户经理:%s" % meta["sales"])
|
|
169
|
+
if who:
|
|
170
|
+
lines.append(" | ".join(who))
|
|
171
|
+
|
|
172
|
+
std = totals.get("standard_total")
|
|
173
|
+
fin = totals.get("final_total")
|
|
174
|
+
if std not in (None, "") or fin not in (None, ""):
|
|
175
|
+
seg = []
|
|
176
|
+
if std not in (None, ""):
|
|
177
|
+
seg.append("标准价合计 %s 元" % _money(std))
|
|
178
|
+
if fin not in (None, ""):
|
|
179
|
+
seg.append("最终优惠报价 %s 元" % _money(fin))
|
|
180
|
+
same = False
|
|
181
|
+
try:
|
|
182
|
+
same = float(str(fin).replace(",", "")) == float(str(std).replace(",", ""))
|
|
183
|
+
except (TypeError, ValueError):
|
|
184
|
+
same = False
|
|
185
|
+
if same:
|
|
186
|
+
seg.append("未让价")
|
|
187
|
+
lines.append("金额:" + ",".join(seg))
|
|
188
|
+
|
|
189
|
+
# 费用构成:优先取 table 型 section(含 total)
|
|
190
|
+
comp = ""
|
|
191
|
+
for sec in sd.get("sections") or []:
|
|
192
|
+
if not isinstance(sec, dict):
|
|
193
|
+
continue
|
|
194
|
+
rows = sec.get("rows") or []
|
|
195
|
+
# 只认 >=3 列的明细表;2 列键值表(项目|内容)不是费用构成,跳过
|
|
196
|
+
if sec.get("type") == "table" and rows and len(rows[0]) >= 3:
|
|
197
|
+
parts = []
|
|
198
|
+
for r in rows:
|
|
199
|
+
if not isinstance(r, (list, tuple)) or len(r) < 2:
|
|
200
|
+
continue
|
|
201
|
+
name = str(r[1]).strip() if len(r) > 1 else ""
|
|
202
|
+
amt = str(r[-1]).strip()
|
|
203
|
+
if name:
|
|
204
|
+
parts.append("%s %s 元" % (name, amt))
|
|
205
|
+
if parts:
|
|
206
|
+
comp = ";".join(parts)
|
|
207
|
+
lines.append("构成:" + comp)
|
|
208
|
+
break
|
|
209
|
+
|
|
210
|
+
# 要点:list / reasons 型 section 的 items(最多 5 条,避免正文过长)
|
|
211
|
+
points = []
|
|
212
|
+
for sec in sd.get("sections") or []:
|
|
213
|
+
if not isinstance(sec, dict):
|
|
214
|
+
continue
|
|
215
|
+
if sec.get("type") in ("list", "reasons"):
|
|
216
|
+
for it in (sec.get("items") or [])[:5]:
|
|
217
|
+
s = str(it).strip()
|
|
218
|
+
if s and s not in points:
|
|
219
|
+
points.append(s)
|
|
220
|
+
if points:
|
|
221
|
+
lines.append("要点:" + ";".join(points[:5]))
|
|
222
|
+
|
|
223
|
+
warns = [str(w).strip() for w in (sd.get("warnings") or []) if str(w).strip()]
|
|
224
|
+
if warns:
|
|
225
|
+
lines.append("待核对:" + ";".join(warns[:3]))
|
|
226
|
+
|
|
227
|
+
return "\n".join(lines)
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def stage1(path, out_dir):
|
|
231
|
+
os.makedirs(out_dir, exist_ok=True)
|
|
232
|
+
fwd = path.replace("\\", "/")
|
|
233
|
+
|
|
234
|
+
sheets_res, msg = cli_json("contract.quote.sheets", {"path": fwd}, out_dir, "sheets")
|
|
235
|
+
if not sheets_res or not sheets_res.get("ok"):
|
|
236
|
+
print("FAIL sheets: %s" % (msg or sheets_res))
|
|
237
|
+
return 1
|
|
238
|
+
sheets = sheets_res["data"]["sheets"]
|
|
239
|
+
sheet = sheets[0]
|
|
240
|
+
print("SHEETS=%s" % json.dumps(sheets, ensure_ascii=False))
|
|
241
|
+
print("DEFAULT_SHEET=%s (多 sheet 时先让用户选,不要静默取第一个)" % sheet)
|
|
242
|
+
|
|
243
|
+
ext, msg = cli_json("contract.quote.extract", {"path": fwd, "sheet": sheet}, out_dir, "extract")
|
|
244
|
+
if not ext or not ext.get("ok"):
|
|
245
|
+
print("FAIL extract: %s" % (msg or ext))
|
|
246
|
+
return 1
|
|
247
|
+
raw = ext["data"]
|
|
248
|
+
write_json(os.path.join(out_dir, "raw_grid.json"), raw)
|
|
249
|
+
print("RAW_GRID rows=%s cols=%s -> %s"
|
|
250
|
+
% (raw.get("counts", {}).get("rows"), raw.get("counts", {}).get("cols"),
|
|
251
|
+
os.path.join(out_dir, "raw_grid.json")))
|
|
252
|
+
preview(raw.get("rows") or [])
|
|
253
|
+
|
|
254
|
+
parsed, msg = cli_json("contract.quote.parse", {"path": fwd, "sheet": sheet}, out_dir, "parse")
|
|
255
|
+
if parsed and parsed.get("ok"):
|
|
256
|
+
write_json(os.path.join(out_dir, "parsed.json"), parsed["data"])
|
|
257
|
+
meta = parsed["data"].get("meta", {})
|
|
258
|
+
totals = parsed["data"].get("totals", {})
|
|
259
|
+
print("PARSED standard=%s final=%s customer_hit=%r"
|
|
260
|
+
% (totals.get("standard_total"), totals.get("final_total"), meta.get("customer")))
|
|
261
|
+
for w in parsed["data"].get("warnings", []):
|
|
262
|
+
print("WARN %s" % w)
|
|
263
|
+
print("NOTE 上述 customer_hit 为空不代表文件没写客户名;请读 raw_grid.json 由模型判定。")
|
|
264
|
+
else:
|
|
265
|
+
print("WARN parse 未成功(可只用 raw_grid 由模型判定): %s" % (msg or parsed))
|
|
266
|
+
|
|
267
|
+
skeleton = {
|
|
268
|
+
"kind": "quote",
|
|
269
|
+
"file": fwd,
|
|
270
|
+
"sheet": sheet,
|
|
271
|
+
"sheets": sheets,
|
|
272
|
+
"meta": {"customer": "", "quote_date": "", "sales": "", "phone": "",
|
|
273
|
+
"_note": "读 raw_grid.json 后由模型填写;取不到写空串,不要编造"},
|
|
274
|
+
"totals": {"standard_total": None, "final_total": None},
|
|
275
|
+
"sections": [],
|
|
276
|
+
"_next": "模型填好本骨架后产出 summary_data.json,再以 --summary-data 进入阶段2",
|
|
277
|
+
}
|
|
278
|
+
sk_path = os.path.join(out_dir, "elements_skeleton.json")
|
|
279
|
+
write_json(sk_path, skeleton)
|
|
280
|
+
print("SKELETON=%s" % sk_path)
|
|
281
|
+
print("STAGE1_DONE")
|
|
282
|
+
return 0
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
# ---------------------------------------------------------------- auto 模式
|
|
286
|
+
# 2026-11-11 用户反馈:报价单首屏被拆成「阶段1 → 模型填 JSON → 阶段2」两轮,
|
|
287
|
+
# 叠加读 reference、dup 探查,实测 105s。核心诉求是:判类型 → 认客户 →
|
|
288
|
+
# 查金额矛盾 → 出卡片,一条命令做完。--auto 就是这条命令。
|
|
289
|
+
|
|
290
|
+
_LABELS = [
|
|
291
|
+
("customer", r"客户(?:名称|全称)?\s*[::]\s*([^\s::||]+)"),
|
|
292
|
+
("quote_date", r"报价日期\s*[::]\s*([0-9]{4}\s*[-/年]\s*[0-9]{1,2}\s*[-/月]\s*[0-9]{1,2})"),
|
|
293
|
+
("sales", r"客户经理\s*[::]\s*([^\s::||]+)"),
|
|
294
|
+
("phone", r"联系电话\s*[::]\s*([0-9\-]{6,})"),
|
|
295
|
+
]
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
def _money0(n):
|
|
299
|
+
"""金额整数不带 .00,缺值给破折号。"""
|
|
300
|
+
if n in (None, ""):
|
|
301
|
+
return "—"
|
|
302
|
+
try:
|
|
303
|
+
v = float(str(n).replace(",", ""))
|
|
304
|
+
except (TypeError, ValueError):
|
|
305
|
+
return str(n)
|
|
306
|
+
if abs(v - round(v)) < 0.005:
|
|
307
|
+
return "{:,.0f}".format(v)
|
|
308
|
+
return "{:,.2f}".format(v)
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
def auto_meta(rows):
|
|
312
|
+
"""从原始网格的『标签:值』单元格取客户/日期/经理/电话。取不到留空,不编造。"""
|
|
313
|
+
import re
|
|
314
|
+
meta = {"customer": "", "quote_date": "", "sales": "", "phone": ""}
|
|
315
|
+
for row in rows or []:
|
|
316
|
+
if not isinstance(row, (list, tuple)):
|
|
317
|
+
continue
|
|
318
|
+
for cell in row:
|
|
319
|
+
if cell is None:
|
|
320
|
+
continue
|
|
321
|
+
s = str(cell).strip()
|
|
322
|
+
if not s:
|
|
323
|
+
continue
|
|
324
|
+
for key, pat in _LABELS:
|
|
325
|
+
if meta[key]:
|
|
326
|
+
continue
|
|
327
|
+
m = re.search(pat, s)
|
|
328
|
+
if m:
|
|
329
|
+
meta[key] = m.group(1).strip()
|
|
330
|
+
return meta
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
def clean_title(file_path):
|
|
334
|
+
"""文件名 -> 可读标题:去【】前缀、去 _日期_后缀与尾部编号。"""
|
|
335
|
+
import re
|
|
336
|
+
base = os.path.splitext(os.path.basename(file_path))[0]
|
|
337
|
+
base = re.sub(r"^【[^】]*】", "", base)
|
|
338
|
+
base = re.sub(r"_[0-9]{6,}.*$", "", base)
|
|
339
|
+
base = re.sub(r"\s*\(\d+\)\s*$", "", base)
|
|
340
|
+
base = re.sub(r"_\d+$", "", base)
|
|
341
|
+
return base.strip() or "报价单"
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
def auto_summary(file_path, raw, parsed):
|
|
345
|
+
"""脚本能确定的部分全部自动填好;模型只需在需要时覆盖。"""
|
|
346
|
+
data = parsed or {}
|
|
347
|
+
meta = auto_meta(raw.get("rows") or [])
|
|
348
|
+
pm = data.get("meta") or {}
|
|
349
|
+
for k in ("customer", "quote_date", "sales", "phone"):
|
|
350
|
+
if not meta.get(k) and pm.get(k):
|
|
351
|
+
meta[k] = pm.get(k)
|
|
352
|
+
|
|
353
|
+
totals = data.get("totals") or {}
|
|
354
|
+
rows = []
|
|
355
|
+
points = []
|
|
356
|
+
for sec in data.get("sections") or []:
|
|
357
|
+
code = sec.get("code") or ""
|
|
358
|
+
name = sec.get("title") or ""
|
|
359
|
+
total = sec.get("total")
|
|
360
|
+
rows.append(["%s%s" % (code, name), _money0(total)])
|
|
361
|
+
items = sec.get("items") or []
|
|
362
|
+
if name:
|
|
363
|
+
points.append("%s%s:%d 项,%s 元" % (code, name, len(items), _money0(total)))
|
|
364
|
+
|
|
365
|
+
warns = [str(w) for w in (data.get("warnings") or []) if str(w).strip()]
|
|
366
|
+
# 客户名已自动取到时,parse 的「未识别到客户名称」告警已失效,不能带给用户
|
|
367
|
+
if meta.get("customer"):
|
|
368
|
+
# 2026-11-12:客户名已取到时,任何「未能定位 / 未识别到客户名称」的告警都已失效。
|
|
369
|
+
# 旧实现只过滤一种固定文案,措辞一改就会把假告警带给用户。
|
|
370
|
+
warns = [w for w in warns
|
|
371
|
+
if not ("客户名称" in w and ("未能" in w or "未从" in w or "未识别" in w))]
|
|
372
|
+
for c in data.get("checks") or []:
|
|
373
|
+
if not isinstance(c, dict):
|
|
374
|
+
continue
|
|
375
|
+
diff = c.get("diff")
|
|
376
|
+
if diff:
|
|
377
|
+
sec_key = (c.get("section") or "").replace("、", "")
|
|
378
|
+
if sec_key:
|
|
379
|
+
warns = [w for w in warns
|
|
380
|
+
if not ("表内" in w and sec_key in w.replace("、", ""))]
|
|
381
|
+
msg = "%s 明细求和 %s 元与表内合计 %s 元相差 %s 元" % (
|
|
382
|
+
c.get("section") or "某分项", _money0(c.get("sum_items")),
|
|
383
|
+
_money0(c.get("sheet_total")), _money0(abs(diff)))
|
|
384
|
+
if msg not in warns:
|
|
385
|
+
warns.append(msg)
|
|
386
|
+
|
|
387
|
+
totals_out = {
|
|
388
|
+
"standard_total": totals.get("standard_total"),
|
|
389
|
+
"final_total": totals.get("final_total"),
|
|
390
|
+
}
|
|
391
|
+
if totals.get("sum_items_grand") not in (None, ""):
|
|
392
|
+
std = totals.get("standard_total")
|
|
393
|
+
grand = totals.get("sum_items_grand")
|
|
394
|
+
try:
|
|
395
|
+
if std not in (None, "") and float(grand) != float(std):
|
|
396
|
+
warns.append("全部明细求和 %s 元与标准价合计 %s 元不一致,差额 %s 元"
|
|
397
|
+
% (_money0(grand), _money0(std), _money0(float(grand) - float(std))))
|
|
398
|
+
except (TypeError, ValueError):
|
|
399
|
+
pass
|
|
400
|
+
|
|
401
|
+
sd = {
|
|
402
|
+
"title": clean_title(file_path),
|
|
403
|
+
"doc_type": "quote",
|
|
404
|
+
"meta": meta,
|
|
405
|
+
"totals": totals_out,
|
|
406
|
+
"sections": [
|
|
407
|
+
{"type": "table", "title": "费用构成", "rows": rows,
|
|
408
|
+
"total": _money0(totals.get("final_total"))},
|
|
409
|
+
{"type": "list", "title": "要点", "items": points},
|
|
410
|
+
],
|
|
411
|
+
"warnings": warns,
|
|
412
|
+
}
|
|
413
|
+
return sd
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
def stage_auto(path, out_dir, doc_type="quote", title="", company_name=""):
|
|
417
|
+
"""一条命令:sheets → extract → parse → 自动识客户 → 矛盾校验 → 卡片。"""
|
|
418
|
+
t0 = time.time()
|
|
419
|
+
os.makedirs(out_dir, exist_ok=True)
|
|
420
|
+
fwd = path.replace("\\", "/")
|
|
421
|
+
|
|
422
|
+
sheets_res, msg = cli_json("contract.quote.sheets", {"path": fwd}, out_dir, "sheets")
|
|
423
|
+
if not sheets_res or not sheets_res.get("ok"):
|
|
424
|
+
print("FAIL sheets: %s" % (msg or sheets_res))
|
|
425
|
+
return 1
|
|
426
|
+
sheets = sheets_res["data"]["sheets"]
|
|
427
|
+
sheet = sheets[0]
|
|
428
|
+
print("SHEETS=%s" % json.dumps(sheets, ensure_ascii=False))
|
|
429
|
+
if len(sheets) > 1:
|
|
430
|
+
print("NOTE 多 sheet,已取第一个『%s』;需要换表请指定 --sheet" % sheet)
|
|
431
|
+
|
|
432
|
+
ext, msg = cli_json("contract.quote.extract", {"path": fwd, "sheet": sheet}, out_dir, "extract")
|
|
433
|
+
if not ext or not ext.get("ok"):
|
|
434
|
+
print("FAIL extract: %s" % (msg or ext))
|
|
435
|
+
return 1
|
|
436
|
+
raw = ext["data"]
|
|
437
|
+
write_json(os.path.join(out_dir, "raw_grid.json"), raw)
|
|
438
|
+
|
|
439
|
+
parsed, msg = cli_json("contract.quote.parse", {"path": fwd, "sheet": sheet}, out_dir, "parse")
|
|
440
|
+
if not parsed or not parsed.get("ok"):
|
|
441
|
+
print("FAIL parse: %s" % (msg or parsed))
|
|
442
|
+
return 1
|
|
443
|
+
pdata = parsed["data"]
|
|
444
|
+
write_json(os.path.join(out_dir, "parsed.json"), pdata)
|
|
445
|
+
|
|
446
|
+
sd = auto_summary(path, raw, pdata)
|
|
447
|
+
if company_name:
|
|
448
|
+
sd["meta"]["customer"] = company_name
|
|
449
|
+
sd_path = os.path.join(out_dir, "summary_data.json")
|
|
450
|
+
write_json(sd_path, sd)
|
|
451
|
+
|
|
452
|
+
cust = sd["meta"].get("customer") or ""
|
|
453
|
+
print("AUTO customer=%r date=%r sales=%r" % (cust, sd["meta"].get("quote_date"), sd["meta"].get("sales")))
|
|
454
|
+
print("AUTO totals standard=%s final=%s" % (sd["totals"].get("standard_total"), sd["totals"].get("final_total")))
|
|
455
|
+
for w in sd.get("warnings") or []:
|
|
456
|
+
print("CHECK %s" % w)
|
|
457
|
+
|
|
458
|
+
rc = stage2(path, out_dir, sd_path, doc_type, title, cust)
|
|
459
|
+
print("AUTO_ELAPSED=%.1fs" % (time.time() - t0))
|
|
460
|
+
return rc
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
def stage2(path, out_dir, summary_data="", doc_type="quote", title="", company_name=""):
|
|
464
|
+
# 报价单不出摘要 HTML、不出摘要卡(2026-11-11 用户指定):只产出文字摘要。
|
|
465
|
+
text_summary = ""
|
|
466
|
+
if summary_data:
|
|
467
|
+
if not os.path.isfile(summary_data):
|
|
468
|
+
print("FAIL summary-data 不存在: %s" % summary_data)
|
|
469
|
+
return 2
|
|
470
|
+
try:
|
|
471
|
+
with io.open(summary_data, encoding="utf-8-sig") as f:
|
|
472
|
+
sd = json.load(f)
|
|
473
|
+
except Exception as e: # noqa: BLE001
|
|
474
|
+
print("FAIL 摘要 JSON 读取失败: %s" % e)
|
|
475
|
+
return 2
|
|
476
|
+
text_summary = build_text_summary(sd)
|
|
477
|
+
txt_path = os.path.join(out_dir, "text_summary.txt")
|
|
478
|
+
with io.open(txt_path, "w", encoding="utf-8") as f:
|
|
479
|
+
f.write(text_summary)
|
|
480
|
+
print("TEXT_SUMMARY=%s" % txt_path)
|
|
481
|
+
else:
|
|
482
|
+
print("SKIP text summary:未提供 --summary-data,本轮只出动作卡片")
|
|
483
|
+
|
|
484
|
+
ctx = {
|
|
485
|
+
"scene": "doc",
|
|
486
|
+
"docType": doc_type,
|
|
487
|
+
"stage": "quote",
|
|
488
|
+
"hasFileId": False,
|
|
489
|
+
# 报价单写明对方企业全称时,按规则可追加「查对方资信」
|
|
490
|
+
"hasCounterparty": bool(company_name),
|
|
491
|
+
# 报价单不出摘要卡:固定 False,动作引擎据此不生成「查看合同摘要」
|
|
492
|
+
"summaryReady": False,
|
|
493
|
+
"flowKey": None,
|
|
494
|
+
}
|
|
495
|
+
ctx_path = os.path.join(out_dir, "card_ctx.json")
|
|
496
|
+
write_json(ctx_path, ctx)
|
|
497
|
+
|
|
498
|
+
card = os.path.join(out_dir, "card.html")
|
|
499
|
+
# 2026-11-12:卡片渲染下沉到 CLI operation(进程内,无子进程),
|
|
500
|
+
# render_action_card.py 已下线,不要再恢复对它的调用。
|
|
501
|
+
cli = shutil.which("weaver-work-cli") or "weaver-work-cli"
|
|
502
|
+
card_args = {"context": ctx, "out": card, "baseUrl": BASE}
|
|
503
|
+
if title:
|
|
504
|
+
card_args["title"] = title
|
|
505
|
+
if company_name:
|
|
506
|
+
card_args["companyName"] = company_name
|
|
507
|
+
args_path = os.path.join(out_dir, "card_args.json")
|
|
508
|
+
write_json(args_path, card_args)
|
|
509
|
+
ok, out, err = _run([cli, "--json", "contract", "run",
|
|
510
|
+
"contract.card.action", "--input", args_path])
|
|
511
|
+
if not os.path.isfile(card):
|
|
512
|
+
print("FAIL render_action_card: %s" % (err or out)[:600])
|
|
513
|
+
return 3
|
|
514
|
+
print("CARD=%s" % card)
|
|
515
|
+
|
|
516
|
+
ok, out, err = _run([PY, os.path.join(SCRIPTS, "validate_action_card.py"), card])
|
|
517
|
+
tail = [ln for ln in (out or "").splitlines() if ln.strip().startswith("summary:")]
|
|
518
|
+
print("VALIDATE %s" % (tail[0] if tail else "未取得校验结论"))
|
|
519
|
+
if not ok:
|
|
520
|
+
print("WARN 卡片校验未通过,详见上方输出")
|
|
521
|
+
|
|
522
|
+
if text_summary:
|
|
523
|
+
print("==== TEXT_SUMMARY_BEGIN ====")
|
|
524
|
+
print(text_summary)
|
|
525
|
+
print("==== TEXT_SUMMARY_END ====")
|
|
526
|
+
|
|
527
|
+
print("==== CARD_HTML_BEGIN ====")
|
|
528
|
+
with io.open(card, encoding="utf-8") as f:
|
|
529
|
+
print(f.read())
|
|
530
|
+
print("==== CARD_HTML_END ====")
|
|
531
|
+
print("STAGE2_DONE")
|
|
532
|
+
return 0
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
def main():
|
|
536
|
+
ap = argparse.ArgumentParser(description="报价单首屏:阶段1 取网格与骨架;阶段2 出文字摘要与动作卡")
|
|
537
|
+
ap.add_argument("--file", required=True, help="报价单 .xlsx 绝对路径")
|
|
538
|
+
ap.add_argument("--out-dir", required=True, help="中间产物与卡片输出目录")
|
|
539
|
+
ap.add_argument("--auto", action="store_true",
|
|
540
|
+
help="一条命令:提取→解析→自动识客户→金额校验→出卡片(首屏推荐)")
|
|
541
|
+
ap.add_argument("--summary-data", default="", help="阶段2:模型产出的摘要 JSON")
|
|
542
|
+
ap.add_argument("--doc-type", default="quote", help="quote | tender,默认 quote")
|
|
543
|
+
ap.add_argument("--title", default="", help="卡片标题,默认由动作引擎算")
|
|
544
|
+
ap.add_argument("--company-name", default="",
|
|
545
|
+
help="阶段2:对方企业全称(模型从 raw grid 判定后传入),用于出「查对方资信」卡")
|
|
546
|
+
a = ap.parse_args()
|
|
547
|
+
|
|
548
|
+
if not os.path.isfile(a.file):
|
|
549
|
+
print("FAIL 文件不存在: %s" % a.file)
|
|
550
|
+
return 2
|
|
551
|
+
|
|
552
|
+
if a.auto:
|
|
553
|
+
return stage_auto(a.file, a.out_dir, a.doc_type, a.title, a.company_name)
|
|
554
|
+
if a.summary_data or a.title:
|
|
555
|
+
return stage2(a.file, a.out_dir, a.summary_data, a.doc_type, a.title, a.company_name)
|
|
556
|
+
return stage1(a.file, a.out_dir)
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
if __name__ == "__main__":
|
|
560
|
+
sys.exit(main())
|