weaver-work-cli 0.1.50 → 0.1.53
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-EJYIOJPH.js → attachment-content-W3TSJC3Y.js} +3 -3
- package/dist/chunks/{chunk-BFKLQLBK.js → chunk-2J3XY4ED.js} +7 -7
- package/dist/chunks/{chunk-K67FODVC.js → chunk-6GCXWKG6.js} +1 -1
- package/dist/chunks/{chunk-WNJUGI2F.js → chunk-76PRVYH4.js} +1 -1
- package/dist/chunks/{chunk-RYFRGTUV.js → chunk-DEHJ7PMA.js} +4 -4
- package/dist/chunks/{chunk-3NCFFHB2.js → chunk-IF33CG4V.js} +1 -1
- package/dist/chunks/{chunk-YB3AJYPY.js → chunk-PE334WL3.js} +4 -4
- package/dist/chunks/{chunk-MCZG6HPM.js → chunk-QQXMHM3J.js} +2 -2
- package/dist/chunks/{chunk-7ECB22G3.js → chunk-U7ROML5E.js} +23 -23
- package/dist/chunks/{chunk-7AYQJSFY.js → chunk-WTLQGS6D.js} +2 -2
- package/dist/chunks/{chunk-6T53BSWZ.js → chunk-XPQN4E5O.js} +50 -19
- package/dist/chunks/{chunk-HARQF5IP.js → chunk-Z4G7LLDD.js} +25 -25
- package/dist/chunks/{conflict-C4UDHCWV.js → conflict-57WDJWL7.js} +2 -2
- package/dist/chunks/{contract-VUC6JOPG.js → contract-LJRAXVZU.js} +8587 -1421
- package/dist/chunks/{create-flow-6OG2LYBD.js → create-flow-3FMMZBCA.js} +6 -6
- package/dist/chunks/{data-QO7QWOIV.js → data-WK5CQXNF.js} +17 -32
- package/dist/chunks/{env-WP57TF2S.js → env-JYZE3BZB.js} +2 -2
- package/dist/chunks/{factory-VUXI7N5C.js → factory-66SCIKW3.js} +1 -1
- package/dist/chunks/{group-chat-UQRGXILK.js → group-chat-MNRYMLNG.js} +3 -3
- package/dist/chunks/{invoice-E7GOITEU.js → invoice-V7ZTITUO.js} +725 -205
- package/dist/chunks/{meeting-4BBLVAWM.js → meeting-IIY4UAJL.js} +10 -10
- package/dist/chunks/{recruit-stage-FKWS5UQF.js → recruit-stage-XCMVEQA2.js} +718 -131
- package/dist/chunks/{registry-V4CHRQDI.js → registry-CJOVECZD.js} +1 -1
- package/dist/chunks/{registry-5CRCN2TV.js → registry-METZ2LWE.js} +10 -10
- package/dist/chunks/{room-recommend-AYR3UG7R.js → room-recommend-YFY7HTOF.js} +4 -4
- package/dist/chunks/{schedule-JZEFIXUS.js → schedule-6I63TERA.js} +4 -4
- package/dist/chunks/smart-extract-FOUYNIG3.js +2882 -0
- package/dist/chunks/{workflow-3ZAF2J5E.js → workflow-YHXFIU63.js} +1 -1
- package/dist/index.js +11 -6
- package/dist/shortcuts/contract/manifest.js +251 -0
- package/dist/shortcuts/contract/ooxml/docx-table.js +233 -0
- package/dist/shortcuts/contract/operations/card-action.js +1165 -0
- package/dist/shortcuts/contract/operations/card-ebdf-list.js +571 -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/card.js +6 -5
- package/dist/shortcuts/contract/operations/docx-fillfromquote.js +532 -0
- package/dist/shortcuts/contract/operations/docx-verify.js +258 -0
- package/dist/shortcuts/contract/operations/elements-build.js +761 -0
- package/dist/shortcuts/contract/operations/elements-spec.js +216 -0
- package/dist/shortcuts/contract/operations/first-screen.js +588 -0
- package/dist/shortcuts/contract/operations/flow.js +81 -25
- package/dist/shortcuts/contract/operations/ledger.js +438 -0
- 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 +104 -3
- package/dist/shortcuts/contract/operations/quote.js +131 -25
- package/dist/shortcuts/contract/operations/quotescreen.js +529 -0
- package/dist/shortcuts/contract/operations/registry.js +30 -0
- package/dist/shortcuts/contract/operations/review.js +73 -58
- package/dist/shortcuts/contract/operations/summary-validate.js +293 -0
- package/dist/shortcuts/contract/operations/summary.js +4 -2
- package/dist/shortcuts/contract/operations/triage.js +1100 -0
- 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/index.js +5 -0
- package/dist/shortcuts/invoice/index.js +0 -12
- package/dist/shortcuts/invoice/manifest.js +200 -49
- 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/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 +492 -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 +454 -0
- package/dist/shortcuts/workflow/operations/form.js +68 -33
- package/dist/shortcuts/workflow/operations/read.js +19 -1
- package/docs/SKILL.md +1 -1
- package/docs/_catalog.md +3 -0
- package/docs/agent-invoice.md +5 -7
- package/docs/data.md +5 -1
- package/docs/fna.md +14 -1
- package/docs/invoice.md +7 -5
- package/docs/smart-extract.md +156 -0
- package/package.json +1 -1
- package/skill-template/business-info.json +16 -1
- package/skill-template/domains/qiyecheng.md +2 -0
- 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 +223 -35
- package/skills/weaver-e10-jinchengda/references/contract-action-card.md +47 -481
- package/skills/weaver-e10-jinchengda/references/contract-action-engine.md +11 -11
- package/skills/weaver-e10-jinchengda/references/contract-agent-entry.md +3 -3
- package/skills/weaver-e10-jinchengda/references/contract-ai-assistant.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +32 -16
- package/skills/weaver-e10-jinchengda/references/contract-card-render-internals.md +478 -0
- package/skills/weaver-e10-jinchengda/references/contract-command-index.md +4 -4
- package/skills/weaver-e10-jinchengda/references/contract-disabled-capabilities.md +2 -2
- package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +39 -61
- package/skills/weaver-e10-jinchengda/references/contract-element-save-record.md +18 -13
- package/skills/weaver-e10-jinchengda/references/contract-execution-rules.md +2 -2
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +21 -6
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +6 -4
- package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +3 -3
- package/skills/weaver-e10-jinchengda/references/contract-ledger-catalog.md +263 -0
- package/skills/weaver-e10-jinchengda/references/contract-ledger-query-playbook.md +525 -0
- package/skills/weaver-e10-jinchengda/references/contract-ledger-rules.md +36 -0
- package/skills/weaver-e10-jinchengda/references/contract-modeltext-library.md +128 -0
- package/skills/weaver-e10-jinchengda/references/contract-multi-file.md +87 -0
- package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +80 -54
- package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +110 -14
- package/skills/weaver-e10-jinchengda/references/contract-template-selector.md +19 -21
- package/skills/weaver-e10-jinchengda/references/orchestration.md +12 -12
- package/skills/weaver-e10-jinchengda/references/source-manifest.json +1 -6
- package/skills/weaver-e10-jinchengda/scripts/fill_plan.py +2 -1
- package/skills/weaver-e10-qiyecheng/SKILL.md +37 -0
- package/skills/weaver-e10-qiyecheng/references/ai-check-audit.md +14 -0
- package/skills/weaver-e10-qiyecheng/references/budget.md +14 -0
- package/skills/weaver-e10-qiyecheng/references/catalog.md +25 -0
- 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 +34 -27
- 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 -42
- 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 +180 -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 +106 -0
- package/skills/weaver-e10-workflow/references/workflow-create.md +6 -5
- package/skills/weaver-e10-workflow/references/workflow-edit.md +1 -1
- 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-yepiaotong/SKILL.md +46 -33
- 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-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 +12 -8
- package/skills/weaver-e10-yepiaotong/references/invoice-upload-and-validate.md +97 -39
- package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +91 -2
- package/skills/weaver-e10-yepiaotong/references/reim-examples.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +12 -12
- package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +8 -4
- package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +136 -91
- package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +109 -23
- package/skills/weaver-e10-yepiaotong/references/source-manifest.json +110 -43
- 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_ebdf_list_card.py +0 -265
- package/skills/weaver-e10-jinchengda/scripts/render_risk_report.py +0 -358
- package/skills/weaver-e10-jinchengda/scripts/validate_action_card.py +0 -588
- package/skills/weaver-e10-jinchengda/scripts/verify_docx_placeholders.py +0 -118
- package/skills/weaver-e10-yepiaotong/references/invoice-validation-preview.md +0 -40
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
"""render_ebdf_list_card.py — 业绩核算六菜单 ebdf 列表组件卡生成器(2026-11-10)
|
|
4
|
-
|
|
5
|
-
为什么要有这个脚本:
|
|
6
|
-
业绩核算六个菜单以前用 `open_web` 在外部浏览器视图打开,用户拿不到 E10 列表组件。
|
|
7
|
-
现在统一改为 ebdf 列表页组件卡(fill_form + e10 + sdkOptions),字段名与 pageId 容易抄错,
|
|
8
|
-
因此全部固化在脚本里,模型不再手写卡片。
|
|
9
|
-
|
|
10
|
-
用法:
|
|
11
|
-
python scripts/render_ebdf_list_card.py --menu 直销合同 --origin https://xxx.cn \
|
|
12
|
-
--title "我的合同" --com-param field_846297265322574070=叶通 --out card.json
|
|
13
|
-
|
|
14
|
-
--menu / --page-id 二选一:菜单名(含别名)或直接给 pageId
|
|
15
|
-
--origin 必填,scheme+host,不带路径/query,不含 {baseUrl}
|
|
16
|
-
--title 卡片标题,默认取菜单名
|
|
17
|
-
--call-id 默认 ebdf-list-<菜单>-<YYYYMMDDHHmm>-01
|
|
18
|
-
--com-param 可重复,形如 field_<字段id>=<值>
|
|
19
|
-
--com-params-json 直接给 comParams 对象(与 --com-param 互斥)
|
|
20
|
-
--out 输出文件;省略则打印到 stdout
|
|
21
|
-
--print 写出后同时打印
|
|
22
|
-
|
|
23
|
-
退出码:0 自检全过;1 参数或自检失败。
|
|
24
|
-
"""
|
|
25
|
-
|
|
26
|
-
import argparse
|
|
27
|
-
import datetime
|
|
28
|
-
import io
|
|
29
|
-
import json
|
|
30
|
-
import re
|
|
31
|
-
import sys
|
|
32
|
-
|
|
33
|
-
# 菜单 -> pageId(2026-11-10 用户确认,勿改)
|
|
34
|
-
MENU_PAGES = {
|
|
35
|
-
"直销合同": "881124906081886244",
|
|
36
|
-
"直销业绩": "846297265322576586",
|
|
37
|
-
"合同收款": "846297265322576589",
|
|
38
|
-
"项目验收": "846297265322576590",
|
|
39
|
-
"渠道订单": "881210951456350225",
|
|
40
|
-
"渠道订单-商务": "881211329321197671",
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
ALIASES = {
|
|
44
|
-
"e-cology合同": "直销合同",
|
|
45
|
-
"e-cology 合同": "直销合同",
|
|
46
|
-
"合同数据": "直销合同",
|
|
47
|
-
"直销合同数据": "直销合同",
|
|
48
|
-
"业绩": "直销业绩",
|
|
49
|
-
"个人业绩": "直销业绩",
|
|
50
|
-
"机构业绩": "直销业绩",
|
|
51
|
-
"大区业绩": "直销业绩",
|
|
52
|
-
"团队业绩": "直销业绩",
|
|
53
|
-
"合同收款信息": "合同收款",
|
|
54
|
-
"收款": "合同收款",
|
|
55
|
-
"验收": "项目验收",
|
|
56
|
-
"项目验收数据": "项目验收",
|
|
57
|
-
"渠道订单数据": "渠道订单",
|
|
58
|
-
"e-office合同": "渠道订单",
|
|
59
|
-
"e-teams合同": "渠道订单",
|
|
60
|
-
"渠道协议": "渠道订单-商务",
|
|
61
|
-
"e-office协议订单": "渠道订单-商务",
|
|
62
|
-
"商务渠道订单": "渠道订单-商务",
|
|
63
|
-
"渠道订单商务": "渠道订单-商务",
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
FIELD_KEY = re.compile(r"^field_\d+$")
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
def die(msg):
|
|
70
|
-
sys.stderr.write("[FAIL] %s\n" % msg)
|
|
71
|
-
return 1
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
def resolve_menu(raw):
|
|
75
|
-
name = (raw or "").strip()
|
|
76
|
-
if name in MENU_PAGES:
|
|
77
|
-
return name, MENU_PAGES[name], ""
|
|
78
|
-
if name in ALIASES:
|
|
79
|
-
real = ALIASES[name]
|
|
80
|
-
return real, MENU_PAGES[real], ""
|
|
81
|
-
hits = [k for k in MENU_PAGES if name and (name in k or k in name)]
|
|
82
|
-
if len(hits) == 1:
|
|
83
|
-
return hits[0], MENU_PAGES[hits[0]], ""
|
|
84
|
-
return None, None, "未知菜单 %r,可选:%s" % (raw, "、".join(MENU_PAGES))
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
def clean_origin(raw):
|
|
88
|
-
origin = (raw or "").strip().rstrip("/")
|
|
89
|
-
if not origin:
|
|
90
|
-
raise ValueError("缺少 origin")
|
|
91
|
-
if "{baseUrl}" in origin:
|
|
92
|
-
raise ValueError("origin 仍是占位符 {baseUrl}")
|
|
93
|
-
if not re.match(r"^https?://[^/]+$", origin):
|
|
94
|
-
raise ValueError("origin 只能是 scheme+host,不能带路径、query 或用户信息")
|
|
95
|
-
return origin
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
def parse_com_params(pairs, raw_json):
|
|
99
|
-
if pairs and raw_json:
|
|
100
|
-
raise ValueError("--com-param 与 --com-params-json 只能二选一")
|
|
101
|
-
params = {}
|
|
102
|
-
if raw_json:
|
|
103
|
-
try:
|
|
104
|
-
params = json.loads(raw_json)
|
|
105
|
-
except Exception as exc:
|
|
106
|
-
raise ValueError("--com-params-json 不是合法 JSON:%s" % exc)
|
|
107
|
-
if not isinstance(params, dict):
|
|
108
|
-
raise ValueError("--com-params-json 必须是对象")
|
|
109
|
-
for item in pairs or []:
|
|
110
|
-
if "=" not in item:
|
|
111
|
-
raise ValueError("--com-param 需要 key=value,收到 %r" % item)
|
|
112
|
-
k, v = item.split("=", 1)
|
|
113
|
-
params[k.strip()] = v
|
|
114
|
-
out = {}
|
|
115
|
-
for k, v in params.items():
|
|
116
|
-
if not FIELD_KEY.match(str(k)):
|
|
117
|
-
raise ValueError("条件键必须是 field_<字段id>,收到 %r" % k)
|
|
118
|
-
out[str(k)] = v if isinstance(v, str) else str(v)
|
|
119
|
-
return out
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
def build(menu, page_id, origin, title, call_id, com_params):
|
|
123
|
-
path = "/list/%s" % page_id
|
|
124
|
-
return {
|
|
125
|
-
"version": 1,
|
|
126
|
-
"callId": call_id,
|
|
127
|
-
"toolId": "fill_form",
|
|
128
|
-
"arguments": {
|
|
129
|
-
"type": "e10",
|
|
130
|
-
"title": title,
|
|
131
|
-
"src": "%s/sp/ebdfpage/list/%s" % (origin, page_id),
|
|
132
|
-
"sdkRenderType": "inline",
|
|
133
|
-
"sdkOptions": {
|
|
134
|
-
"compName": "ui.CorsComponent",
|
|
135
|
-
"routerType": "MemoryRouter",
|
|
136
|
-
"routerProps_pc": {"initialEntries": [path]},
|
|
137
|
-
"routerProps_mobile": {"initialEntries": [path]},
|
|
138
|
-
"params_pc": {
|
|
139
|
-
"app": "@weapp/ebdfpage",
|
|
140
|
-
"compName": "TableViewList",
|
|
141
|
-
"noMDialog": True,
|
|
142
|
-
},
|
|
143
|
-
"params_mobile": {
|
|
144
|
-
"app": "@weapp/ebdfpage",
|
|
145
|
-
"compName": "MTableViewList",
|
|
146
|
-
"noMDialog": True,
|
|
147
|
-
},
|
|
148
|
-
"params": {
|
|
149
|
-
"pageId": page_id,
|
|
150
|
-
"comParams": com_params,
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
def self_check(card, page_id):
|
|
158
|
-
"""按 validate_action_card.py 的 ebdf 分支逐项核对,返回问题列表。"""
|
|
159
|
-
bad = []
|
|
160
|
-
a = card.get("arguments") or {}
|
|
161
|
-
so = a.get("sdkOptions") or {}
|
|
162
|
-
pp = so.get("params_pc") or {}
|
|
163
|
-
pm = so.get("params_mobile") or {}
|
|
164
|
-
par = so.get("params") or {}
|
|
165
|
-
rpc = so.get("routerProps_pc") or {}
|
|
166
|
-
rmb = so.get("routerProps_mobile") or {}
|
|
167
|
-
|
|
168
|
-
if card.get("version") != 1:
|
|
169
|
-
bad.append("version != 1")
|
|
170
|
-
if card.get("toolId") != "fill_form":
|
|
171
|
-
bad.append("toolId != fill_form")
|
|
172
|
-
if not card.get("callId"):
|
|
173
|
-
bad.append("callId 为空")
|
|
174
|
-
if a.get("type") != "e10":
|
|
175
|
-
bad.append("arguments.type != e10")
|
|
176
|
-
if a.get("sdkRenderType") != "inline":
|
|
177
|
-
bad.append("sdkRenderType != inline")
|
|
178
|
-
if "width" in a:
|
|
179
|
-
bad.append("ebdf 列表卡不应带 arguments.width")
|
|
180
|
-
if not (a.get("src") or "").endswith("/sp/ebdfpage/list/%s" % page_id):
|
|
181
|
-
bad.append("src 与 pageId 不一致")
|
|
182
|
-
if so.get("compName") != "ui.CorsComponent":
|
|
183
|
-
bad.append("sdkOptions.compName != ui.CorsComponent")
|
|
184
|
-
if so.get("routerType") != "MemoryRouter":
|
|
185
|
-
bad.append("routerType != MemoryRouter")
|
|
186
|
-
if pp.get("app") != "@weapp/ebdfpage" or pp.get("compName") != "TableViewList":
|
|
187
|
-
bad.append("params_pc 组件不对")
|
|
188
|
-
if pm.get("app") != "@weapp/ebdfpage" or pm.get("compName") != "MTableViewList":
|
|
189
|
-
bad.append("params_mobile 组件不对")
|
|
190
|
-
if pp.get("noMDialog") is not True or pm.get("noMDialog") is not True:
|
|
191
|
-
bad.append("noMDialog 未同时为 true")
|
|
192
|
-
if par.get("pageId") != page_id:
|
|
193
|
-
bad.append("params.pageId 与 pageId 不一致")
|
|
194
|
-
want = ["/list/%s" % page_id]
|
|
195
|
-
if rpc.get("initialEntries") != want or rmb.get("initialEntries") != want:
|
|
196
|
-
bad.append("initialEntries 与 pageId 不一致")
|
|
197
|
-
cp = par.get("comParams")
|
|
198
|
-
if not isinstance(cp, dict):
|
|
199
|
-
bad.append("comParams 不是对象")
|
|
200
|
-
else:
|
|
201
|
-
for k, v in cp.items():
|
|
202
|
-
if not FIELD_KEY.match(k):
|
|
203
|
-
bad.append("comParams 键格式错误:%r" % k)
|
|
204
|
-
if not isinstance(v, str):
|
|
205
|
-
bad.append("comParams 值不是字符串:%r" % k)
|
|
206
|
-
return bad
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
def main():
|
|
210
|
-
ap = argparse.ArgumentParser(description="生成业绩核算 ebdf 列表组件卡")
|
|
211
|
-
ap.add_argument("--menu")
|
|
212
|
-
ap.add_argument("--page-id", dest="page_id")
|
|
213
|
-
ap.add_argument("--origin", required=True)
|
|
214
|
-
ap.add_argument("--title")
|
|
215
|
-
ap.add_argument("--call-id", dest="call_id")
|
|
216
|
-
ap.add_argument("--com-param", dest="com_params", action="append", default=[])
|
|
217
|
-
ap.add_argument("--com-params-json", dest="com_params_json")
|
|
218
|
-
ap.add_argument("--out")
|
|
219
|
-
ap.add_argument("--print", dest="do_print", action="store_true")
|
|
220
|
-
args = ap.parse_args()
|
|
221
|
-
|
|
222
|
-
if args.page_id:
|
|
223
|
-
page_id = args.page_id.strip()
|
|
224
|
-
if not re.match(r"^\d{6,}$", page_id):
|
|
225
|
-
return die("pageId 必须是数字串,收到 %r" % page_id)
|
|
226
|
-
menu = args.menu or page_id
|
|
227
|
-
else:
|
|
228
|
-
menu, page_id, err = resolve_menu(args.menu)
|
|
229
|
-
if err:
|
|
230
|
-
return die(err)
|
|
231
|
-
|
|
232
|
-
try:
|
|
233
|
-
origin = clean_origin(args.origin)
|
|
234
|
-
com_params = parse_com_params(args.com_params, args.com_params_json)
|
|
235
|
-
except ValueError as exc:
|
|
236
|
-
return die(str(exc))
|
|
237
|
-
|
|
238
|
-
title = (args.title or menu).strip()
|
|
239
|
-
if not title:
|
|
240
|
-
return die("title 不能为空")
|
|
241
|
-
stamp = datetime.datetime.now().strftime("%Y%m%d%H%M")
|
|
242
|
-
call_id = args.call_id or "ebdf-list-%s-%s-01" % (menu, stamp)
|
|
243
|
-
|
|
244
|
-
card = build(menu, page_id, origin, title, call_id, com_params)
|
|
245
|
-
bad = self_check(card, page_id)
|
|
246
|
-
if bad:
|
|
247
|
-
for b in bad:
|
|
248
|
-
sys.stderr.write("[FAIL] %s\n" % b)
|
|
249
|
-
return 1
|
|
250
|
-
|
|
251
|
-
text = json.dumps(card, ensure_ascii=False, indent=2)
|
|
252
|
-
if args.out:
|
|
253
|
-
with io.open(args.out, "w", encoding="utf-8", newline="\n") as f:
|
|
254
|
-
f.write(text + "\n")
|
|
255
|
-
if args.do_print or not args.out:
|
|
256
|
-
print(text)
|
|
257
|
-
sys.stderr.write(
|
|
258
|
-
"[PASS] %s / pageId=%s / comParams=%d / callId=%s\n"
|
|
259
|
-
% (menu, page_id, len(com_params), call_id)
|
|
260
|
-
)
|
|
261
|
-
return 0
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
if __name__ == "__main__":
|
|
265
|
-
sys.exit(main())
|
|
@@ -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()
|