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
|
@@ -1,358 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""
|
|
3
|
-
合同风险审查报告渲染器(今承达)
|
|
4
|
-
|
|
5
|
-
把风险审查结果渲染成小e卡片(xiaoeCustomPage),并产出可直接使用的 browsertool payload。
|
|
6
|
-
|
|
7
|
-
用法(Windows PowerShell):
|
|
8
|
-
|
|
9
|
-
# 1) 从 CLI 落盘的大结果直接渲染(推荐)
|
|
10
|
-
python render_risk_report.py --ref "<refs目录下的 xxx.json>" --out "报告.html"
|
|
11
|
-
python render_risk_report.py --ref "<refs目录下的 xxx.json>" --out "报告.html" --payload "payload.json"
|
|
12
|
-
|
|
13
|
-
# 2) 从已归一化的数据渲染
|
|
14
|
-
python render_risk_report.py --data "<report_data.json>" --out "报告.html"
|
|
15
|
-
|
|
16
|
-
# 3) 只抽取数据、不渲染
|
|
17
|
-
python render_risk_report.py --ref "<json>" --dump-data "report_data.json"
|
|
18
|
-
|
|
19
|
-
约定:
|
|
20
|
-
- 输出 HTML 内**不得出现双引号**(放进 customParams.html 会被截断),脚本自动处理
|
|
21
|
-
- 统计只保留三项:审查规则总数 / 判定无风险 / 判定有风险
|
|
22
|
-
- 「查看审查详情」按钮通过 rightPanel.open 打开 AIContractV2 审查组件
|
|
23
|
-
"""
|
|
24
|
-
|
|
25
|
-
import argparse
|
|
26
|
-
import html
|
|
27
|
-
import io
|
|
28
|
-
import json
|
|
29
|
-
import os
|
|
30
|
-
import sys
|
|
31
|
-
|
|
32
|
-
TEMPLATE_NAME = 'contract-risk-report-template.html'
|
|
33
|
-
DEFAULT_AIID = '1326842382967570463' # 当前生效审查助手(自用AI)
|
|
34
|
-
DEFAULT_SRC_PATH = '/sp/contract/business/ai-contract'
|
|
35
|
-
DEFAULT_BASE = 'https://www.e-cology.com.cn'
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
# ---------------------------------------------------------------- 工具
|
|
39
|
-
|
|
40
|
-
def _read_json(path):
|
|
41
|
-
with io.open(path, 'r', encoding='utf-8-sig') as f:
|
|
42
|
-
return json.load(f)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def _esc(text):
|
|
46
|
-
"""HTML 转义,并消除双引号(模板内必须是单引号体系)"""
|
|
47
|
-
s = html.escape(str(text or ''), quote=True)
|
|
48
|
-
return s.replace('"', ''')
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
def _rule_name(title):
|
|
52
|
-
"""从规则 title 中取【规则名称】那一行"""
|
|
53
|
-
for line in (title or '').split('\n'):
|
|
54
|
-
if '规则名称' in line:
|
|
55
|
-
return line.replace('【规则名称】', '').strip()
|
|
56
|
-
return (title or '').split('\n')[0][:60]
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
# ---------------------------------------------------------------- 数据抽取
|
|
60
|
-
|
|
61
|
-
def extract_from_ref(path):
|
|
62
|
-
"""从 CLI 落盘结果(含 envelope 包裹)抽取报告数据"""
|
|
63
|
-
top = _read_json(path)
|
|
64
|
-
env = top.get('envelope', top)
|
|
65
|
-
data = env.get('data', {})
|
|
66
|
-
records = data.get('records', [])
|
|
67
|
-
if not records:
|
|
68
|
-
raise SystemExit('该结果没有审查记录,无法生成报告(status 可能为 EMPTY)')
|
|
69
|
-
|
|
70
|
-
scnr = records[0].get('scnr', '')
|
|
71
|
-
obj = json.loads(scnr) if isinstance(scnr, str) else scnr
|
|
72
|
-
|
|
73
|
-
role_key = obj.get('entryRole') or 'partyB'
|
|
74
|
-
by_role = obj.get('resultsByRole') or {}
|
|
75
|
-
items = by_role.get(role_key) or []
|
|
76
|
-
if not items:
|
|
77
|
-
# 立场键兜底
|
|
78
|
-
for k, v in by_role.items():
|
|
79
|
-
if v:
|
|
80
|
-
role_key, items = k, v
|
|
81
|
-
break
|
|
82
|
-
|
|
83
|
-
selected = (obj.get('rules') or {}).get('selected') or []
|
|
84
|
-
|
|
85
|
-
risks, passed = [], []
|
|
86
|
-
for it in items:
|
|
87
|
-
name = _rule_name(it.get('title'))
|
|
88
|
-
if it.get('customRuleNoRisk') is True:
|
|
89
|
-
passed.append({'name': name})
|
|
90
|
-
else:
|
|
91
|
-
risks.append({
|
|
92
|
-
'name': name,
|
|
93
|
-
'original': (it.get('originalContent') or '').strip(),
|
|
94
|
-
'suggestion': (it.get('suggestion') or '').strip(),
|
|
95
|
-
'explanation': (it.get('explanation') or '').strip(),
|
|
96
|
-
'status': it.get('ruleStatus') or '',
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
return {
|
|
100
|
-
'role': role_key,
|
|
101
|
-
'ruleTotal': len(selected) if selected else len(items),
|
|
102
|
-
'judged': len(items),
|
|
103
|
-
'noRisk': len(passed),
|
|
104
|
-
'risk': len(risks),
|
|
105
|
-
'risks': risks,
|
|
106
|
-
'passed': passed,
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
def _safe_name(text, fallback='合同风险审查报告'):
|
|
111
|
-
"""转成可安全用于下载文件名的字符串(去掉路径非法字符与单引号)"""
|
|
112
|
-
s = str(text or '').strip() or fallback
|
|
113
|
-
for ch in ['\\', '/', ':', '*', '?', '"', '<', '>', '|', "'", '\r', '\n']:
|
|
114
|
-
s = s.replace(ch, '_')
|
|
115
|
-
return s[:80]
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
def merge_meta(data, args):
|
|
119
|
-
"""补入报告抬头信息(可从命令行覆盖)"""
|
|
120
|
-
data.setdefault('contract', args.contract or '合同风险审查报告')
|
|
121
|
-
data.setdefault('partyA', args.party_a or '')
|
|
122
|
-
data.setdefault('partyB', args.party_b or '')
|
|
123
|
-
data.setdefault('reviewDate', args.review_date or '')
|
|
124
|
-
data['fileId'] = args.file_id or data.get('fileId', '')
|
|
125
|
-
data['fileName'] = args.file_name or data.get('fileName', '')
|
|
126
|
-
data['aiid'] = args.aiid or DEFAULT_AIID
|
|
127
|
-
data['base'] = args.base_url or DEFAULT_BASE
|
|
128
|
-
data['cardId'] = args.card_id or data.get('cardId') or 'cr-report-%s' % (data.get('stamp') or '000')
|
|
129
|
-
# 下载文件名:风险评估报告_合同名_日期
|
|
130
|
-
date_part = (data.get('reviewDate') or '').replace('-', '') or 'report'
|
|
131
|
-
data['fileBase'] = _safe_name('风险审查报告_%s_%s' % (data.get('contract') or '', date_part))
|
|
132
|
-
return data
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
# ---------------------------------------------------------------- 渲染
|
|
136
|
-
|
|
137
|
-
def _info_rows(d):
|
|
138
|
-
rows = [
|
|
139
|
-
('合同名称', d.get('contract', '')),
|
|
140
|
-
('甲方(用户)', d.get('partyA', '')),
|
|
141
|
-
('乙方(供方)', d.get('partyB', '')),
|
|
142
|
-
('审查立场', '乙方(partyB)' if d.get('role') == 'partyB' else d.get('role', '')),
|
|
143
|
-
('审查类型', '风险审查(合同预审)'),
|
|
144
|
-
('审查日期', d.get('reviewDate', '')),
|
|
145
|
-
]
|
|
146
|
-
out = []
|
|
147
|
-
for k, v in rows:
|
|
148
|
-
if not v:
|
|
149
|
-
continue
|
|
150
|
-
out.append(
|
|
151
|
-
"<tr><td style='padding:7px 10px;background:#f7f9fc;width:110px;color:#7a8497;border-radius:6px'>"
|
|
152
|
-
+ _esc(k) + "</td><td style='padding:7px 10px'>" + _esc(v) + "</td></tr>"
|
|
153
|
-
)
|
|
154
|
-
return ''.join(out)
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
def _risk_items(d):
|
|
158
|
-
out = []
|
|
159
|
-
for i, r in enumerate(d.get('risks', []), 1):
|
|
160
|
-
out.append(
|
|
161
|
-
"<div style='background:#fff;border:1px solid #e8ebf2;border-left:3px solid #c0392b;"
|
|
162
|
-
"border-radius:10px;padding:14px 16px;margin-bottom:12px'>"
|
|
163
|
-
"<div style='display:flex;align-items:center;gap:8px;margin-bottom:10px'>"
|
|
164
|
-
"<span style='background:#fdecea;color:#c0392b;border-radius:10px;padding:2px 8px;font-size:11px'>待整改</span>"
|
|
165
|
-
"<span style='font-size:14px;font-weight:700;color:#1f2430'>" + str(i) + '. ' + _esc(r.get('name')) + "</span></div>"
|
|
166
|
-
"<div style='font-size:12px;color:#7a8497;margin-bottom:4px'>合同原文</div>"
|
|
167
|
-
"<div style='background:#f7f9fc;border-radius:6px;padding:10px;font-size:13px;color:#3c4453;"
|
|
168
|
-
"line-height:1.7;margin-bottom:10px'>" + _esc(r.get('original')) + "</div>"
|
|
169
|
-
"<div style='font-size:12px;color:#7a8497;margin-bottom:4px'>问题说明</div>"
|
|
170
|
-
"<div style='font-size:13px;color:#b45309;line-height:1.7;margin-bottom:10px'>" + _esc(r.get('explanation')) + "</div>"
|
|
171
|
-
"<div style='font-size:12px;color:#7a8497;margin-bottom:4px'>建议修改为</div>"
|
|
172
|
-
"<div style='background:#f0f9f4;border:1px solid #cfeadd;border-radius:6px;padding:10px;font-size:13px;"
|
|
173
|
-
"color:#1a6b45;line-height:1.7'>" + _esc(r.get('suggestion')) + "</div>"
|
|
174
|
-
"</div>"
|
|
175
|
-
)
|
|
176
|
-
return ''.join(out)
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
def _pass_tags(d):
|
|
180
|
-
out = []
|
|
181
|
-
for i, p in enumerate(d.get('passed', []), 1):
|
|
182
|
-
out.append(
|
|
183
|
-
"<span style='display:inline-block;background:#f0f9f4;border:1px solid #cfeadd;color:#1a6b45;"
|
|
184
|
-
"border-radius:8px;padding:5px 10px;font-size:12px;margin:0 8px 8px 0'>"
|
|
185
|
-
+ str(i) + '. ' + _esc(p.get('name')) + "</span>"
|
|
186
|
-
)
|
|
187
|
-
return ''.join(out)
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
def _detail_cfg(d):
|
|
191
|
-
"""rightPanel.open 的 e10Sdk 配置,单引号序列化(ES5 安全)"""
|
|
192
|
-
cfg = {
|
|
193
|
-
'type': 'e10Sdk',
|
|
194
|
-
'width': 1200,
|
|
195
|
-
'contentProps': {
|
|
196
|
-
'src': d['base'] + DEFAULT_SRC_PATH,
|
|
197
|
-
'sdkOptions': {
|
|
198
|
-
'compName': 'ui.CorsComponent',
|
|
199
|
-
'routerType': 'MemoryRouter',
|
|
200
|
-
'routerProps': {'initialEntries': [DEFAULT_SRC_PATH]},
|
|
201
|
-
'params': {
|
|
202
|
-
'app': '@weapp/contract',
|
|
203
|
-
'compName': 'AIContractV2',
|
|
204
|
-
'aiProps': {
|
|
205
|
-
'aiid': d['aiid'],
|
|
206
|
-
'fileId': d['fileId'],
|
|
207
|
-
'fileName': d['fileName'],
|
|
208
|
-
},
|
|
209
|
-
},
|
|
210
|
-
},
|
|
211
|
-
},
|
|
212
|
-
}
|
|
213
|
-
return json.dumps(cfg, ensure_ascii=False, separators=(',', ':')).replace('"', "'")
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
def render(d, template_path):
|
|
217
|
-
with io.open(template_path, 'r', encoding='utf-8') as f:
|
|
218
|
-
tpl = f.read()
|
|
219
|
-
|
|
220
|
-
card_id = d.get('cardId') or 'cr-report-%s' % (d.get('stamp') or '000')
|
|
221
|
-
|
|
222
|
-
out = tpl
|
|
223
|
-
out = out.replace('{{CARD_ID}}', card_id)
|
|
224
|
-
out = out.replace('{{FILE_BASE}}', _safe_name(d.get('fileBase') or '合同风险审查报告'))
|
|
225
|
-
out = out.replace('{{CONTRACT_NAME}}', _esc(d.get('contract')))
|
|
226
|
-
out = out.replace('{{TINFO}}', _info_rows(d))
|
|
227
|
-
out = out.replace('{{STAT_TOTAL}}', str(d.get('ruleTotal', 0)))
|
|
228
|
-
out = out.replace('{{STAT_NO_RISK}}', str(d.get('noRisk', 0)))
|
|
229
|
-
out = out.replace('{{STAT_RISK}}', str(d.get('risk', 0)))
|
|
230
|
-
out = out.replace('{{RISK_COUNT}}', str(d.get('risk', 0)))
|
|
231
|
-
out = out.replace('{{RISK_ITEMS}}', _risk_items(d))
|
|
232
|
-
out = out.replace('{{PASS_COUNT}}', str(d.get('noRisk', 0)))
|
|
233
|
-
out = out.replace('{{PASS_TAGS}}', _pass_tags(d))
|
|
234
|
-
out = out.replace('{{DETAIL_CFG}}', _detail_cfg(d))
|
|
235
|
-
return out
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
def build_payload(html_str, d, call_id):
|
|
239
|
-
return {
|
|
240
|
-
'version': 1,
|
|
241
|
-
'callId': call_id,
|
|
242
|
-
'toolId': 'fill_form',
|
|
243
|
-
'arguments': {
|
|
244
|
-
'type': 'e10',
|
|
245
|
-
'title': d.get('title') or '合同风险审查报告',
|
|
246
|
-
'src': d['base'] + '/sp/contract/xiaoe-custom-page',
|
|
247
|
-
'width': 1200,
|
|
248
|
-
'sdkRenderType': 'inline',
|
|
249
|
-
'sdkOptions': {
|
|
250
|
-
'compName': 'ui.CorsComponent',
|
|
251
|
-
'routerType': 'MemoryRouter',
|
|
252
|
-
'routerProps_pc': {'initialEntries': ['/sp/contract/xiaoe-custom-page']},
|
|
253
|
-
'params_pc': {
|
|
254
|
-
'app': '@weapp/contract',
|
|
255
|
-
'compName': 'xiaoeCustomPage',
|
|
256
|
-
'customParams': {'html': html_str},
|
|
257
|
-
},
|
|
258
|
-
},
|
|
259
|
-
},
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
def lint(html_str, js_path):
|
|
264
|
-
"""交付前自检:双引号数量、ES5 语法禁用项"""
|
|
265
|
-
problems = []
|
|
266
|
-
dq = html_str.count('"')
|
|
267
|
-
if dq:
|
|
268
|
-
problems.append('html 内含 %d 个双引号(必须为 0)' % dq)
|
|
269
|
-
for bad in ['=>', 'const ', 'let ', '??', '?.', '`']:
|
|
270
|
-
if bad in html_str:
|
|
271
|
-
problems.append('html 内出现 ES5 禁用语法: %s' % bad)
|
|
272
|
-
if js_path:
|
|
273
|
-
with io.open(js_path, 'w', encoding='utf-8') as f:
|
|
274
|
-
i = html_str.find('<script>')
|
|
275
|
-
j = html_str.rfind('</script>')
|
|
276
|
-
f.write(html_str[i + 8:j] if i >= 0 and j > i else '')
|
|
277
|
-
return problems
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
# ---------------------------------------------------------------- 入口
|
|
281
|
-
|
|
282
|
-
def main():
|
|
283
|
-
ap = argparse.ArgumentParser(description='渲染合同风险审查报告卡片')
|
|
284
|
-
ap.add_argument('--ref', help='CLI 落盘的审查结果 json(含 envelope)')
|
|
285
|
-
ap.add_argument('--data', help='已归一化的 report_data.json')
|
|
286
|
-
ap.add_argument('--out', help='输出的 HTML 文件路径')
|
|
287
|
-
ap.add_argument('--payload', help='输出的 browsertool payload json 路径')
|
|
288
|
-
ap.add_argument('--dump-data', help='只抽取数据并保存到此路径')
|
|
289
|
-
ap.add_argument('--template', help='自定义模板路径')
|
|
290
|
-
ap.add_argument('--contract', help='合同名称')
|
|
291
|
-
ap.add_argument('--party-a', dest='party_a', help='甲方')
|
|
292
|
-
ap.add_argument('--party-b', dest='party_b', help='乙方')
|
|
293
|
-
ap.add_argument('--review-date', dest='review_date', help='审查日期')
|
|
294
|
-
ap.add_argument('--file-id', dest='file_id', help='审查 fileId(打开详情用)')
|
|
295
|
-
ap.add_argument('--file-name', dest='file_name', help='审查文件名')
|
|
296
|
-
ap.add_argument('--aiid', help='审查助手 id,默认 %s' % DEFAULT_AIID)
|
|
297
|
-
ap.add_argument('--base-url', dest='base_url', help='E10 地址,默认 %s' % DEFAULT_BASE)
|
|
298
|
-
ap.add_argument('--card-id', dest='card_id', help='卡片唯一 id')
|
|
299
|
-
ap.add_argument('--call-id', dest='call_id', help='payload callId')
|
|
300
|
-
args = ap.parse_args()
|
|
301
|
-
|
|
302
|
-
if args.ref:
|
|
303
|
-
data = extract_from_ref(args.ref)
|
|
304
|
-
elif args.data:
|
|
305
|
-
data = _read_json(args.data)
|
|
306
|
-
else:
|
|
307
|
-
ap.error('必须提供 --ref 或 --data')
|
|
308
|
-
|
|
309
|
-
data = merge_meta(data, args)
|
|
310
|
-
|
|
311
|
-
if args.dump_data:
|
|
312
|
-
with io.open(args.dump_data, 'w', encoding='utf-8') as f:
|
|
313
|
-
json.dump(data, f, ensure_ascii=False, indent=2)
|
|
314
|
-
print('DATA_SAVED=' + args.dump_data)
|
|
315
|
-
if not args.out:
|
|
316
|
-
return
|
|
317
|
-
|
|
318
|
-
here = os.path.dirname(os.path.abspath(__file__))
|
|
319
|
-
tpl = args.template or os.path.join(here, '..', 'references', TEMPLATE_NAME)
|
|
320
|
-
tpl = os.path.abspath(tpl)
|
|
321
|
-
|
|
322
|
-
html_str = render(data, tpl)
|
|
323
|
-
|
|
324
|
-
if args.card_id:
|
|
325
|
-
pass
|
|
326
|
-
else:
|
|
327
|
-
html_str = html_str # cardId 已在 render 内处理
|
|
328
|
-
|
|
329
|
-
problems = lint(html_str, None)
|
|
330
|
-
print('RULE_TOTAL=%d NO_RISK=%d RISK=%d' % (data['ruleTotal'], data['noRisk'], data['risk']))
|
|
331
|
-
if problems:
|
|
332
|
-
for p in problems:
|
|
333
|
-
print('[LINT_FAIL] ' + p)
|
|
334
|
-
else:
|
|
335
|
-
print('[LINT_OK] 双引号 0 个,无 ES5 禁用语法')
|
|
336
|
-
|
|
337
|
-
print('HTML_LEN=%d' % len(html_str))
|
|
338
|
-
|
|
339
|
-
# 2026-11-09 用户指定:报告只作为卡片输出,默认不落盘。
|
|
340
|
-
# 仅当显式传 --out 时才写文件;不再回退到 cwd 自动生成
|
|
341
|
-
# risk_report_xxx.html(那会造成同一份报告出现卡片 + 文件两遍)。
|
|
342
|
-
if args.out:
|
|
343
|
-
with io.open(args.out, 'w', encoding='utf-8') as f:
|
|
344
|
-
f.write(html_str)
|
|
345
|
-
print('HTML_SAVED=' + os.path.abspath(args.out))
|
|
346
|
-
else:
|
|
347
|
-
print('HTML_SKIPPED=未传 --out,按约定不落盘(报告仅作为卡片交付)')
|
|
348
|
-
|
|
349
|
-
if args.payload:
|
|
350
|
-
call_id = args.call_id or 'contract-risk-report-%s' % (data.get('stamp') or '000')
|
|
351
|
-
payload = build_payload(html_str, data, call_id)
|
|
352
|
-
with io.open(args.payload, 'w', encoding='utf-8') as f:
|
|
353
|
-
json.dump(payload, f, ensure_ascii=False, indent=2)
|
|
354
|
-
print('PAYLOAD_SAVED=' + os.path.abspath(args.payload))
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
if __name__ == '__main__':
|
|
358
|
-
main()
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
# 查验预览(仅限已在票夹中的发票)
|
|
2
|
-
|
|
3
|
-
## 什么时候读取
|
|
4
|
-
|
|
5
|
-
用户要查验**已在票夹中的发票**(已有 `fid`),但没有明确要求把查验结果回写票夹时读取本文件。
|
|
6
|
-
|
|
7
|
-
## ⚠️ 路由判断
|
|
8
|
-
|
|
9
|
-
- 如果用户提供的是**文件路径或 URL**(还没上传到票夹),**不要**使用本命令 → 应改用 `invoice.upload-and-validate`(一站式上传+OCR+查验)
|
|
10
|
-
- 本命令**仅适用于票夹中已存在的发票**,必须已有 `fid`
|
|
11
|
-
|
|
12
|
-
## Operation
|
|
13
|
-
|
|
14
|
-
| Operation | 固定规则 |
|
|
15
|
-
| --- | --- |
|
|
16
|
-
| `invoice.validate.preview` | 先取详情,固定 `flag=100`、`is_save=1`、`needLog=true`,不回写查验结果 |
|
|
17
|
-
|
|
18
|
-
## 输入
|
|
19
|
-
|
|
20
|
-
必须提供 `fid` 和 `scope`。`scope` 只能是 `personal` 或 `enterprise`。
|
|
21
|
-
|
|
22
|
-
## 示例
|
|
23
|
-
|
|
24
|
-
Windows PowerShell:
|
|
25
|
-
|
|
26
|
-
```powershell
|
|
27
|
-
weaver-work-cli --json invoice run invoice.validate.preview --input-json '{"fid":"12345","scope":"personal"}'
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
macOS/Linux(bash/zsh):
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
weaver-work-cli --json invoice run invoice.validate.preview --input-json '{"fid":"12345","scope":"personal"}'
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## 注意
|
|
37
|
-
|
|
38
|
-
`invoice.validate.preview` 只做预览。`saved=false` 表示没有回写票夹;不要把预览结果描述为已更新发票。
|
|
39
|
-
|
|
40
|
-
同一张发票每天最多查验 5 次,超过后返回 `api/business_error`、`error.code="6022"`、「单张发票每天最多查验5次」,不要重试。话费 / 油费补贴报销中,这种发票视为查验通过,继续报销,见 [reim-phone-subsidy-rules.md](reim-phone-subsidy-rules.md)「查验次数用完」。
|