weaver-work-cli 0.1.46 → 0.1.48
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/dist/chunks/{archive-oa-BBDP7AKJ.js → archive-oa-EDJDU3V4.js} +454 -5
- package/dist/chunks/{attachment-content-MCXQBD6N.js → attachment-content-4KSNBPRO.js} +3 -3
- package/dist/chunks/{chunk-UFIFZ4YC.js → chunk-2BQESR2U.js} +1 -1
- package/dist/chunks/{chunk-727FH2NI.js → chunk-2IGZUMNG.js} +15 -2
- package/dist/chunks/{chunk-76H3IKH6.js → chunk-5B5JXTY2.js} +35 -35
- package/dist/chunks/{chunk-Q4OYAQYH.js → chunk-72MI3MBX.js} +4 -0
- package/dist/chunks/{chunk-4RWS2YYL.js → chunk-BCACE6VV.js} +2 -2
- package/dist/chunks/{chunk-AD46OMQK.js → chunk-EFOUMXIX.js} +119 -44
- package/dist/chunks/{chunk-IRMIEDXN.js → chunk-FEP6ELMR.js} +1 -1
- package/dist/chunks/{chunk-JB34OE7R.js → chunk-NBEWUR7L.js} +1 -1
- package/dist/chunks/{chunk-6V5ZPKHV.js → chunk-NK74RE5F.js} +2 -2
- package/dist/chunks/{chunk-GSZTA43P.js → chunk-OCYRVZGN.js} +2 -2
- package/dist/chunks/{chunk-OXHHJWNC.js → chunk-PSPOFLSU.js} +1 -1
- package/dist/chunks/{chunk-6AXKWFKG.js → chunk-R2HHLJNN.js} +4 -4
- package/dist/chunks/{chunk-PSOMGA3U.js → chunk-SVFG6EMV.js} +35 -6
- package/dist/chunks/{chunk-IP4CWQCF.js → chunk-WMSAWAWZ.js} +8 -8
- package/dist/chunks/{conflict-H7EHQXYY.js → conflict-APGSD5E7.js} +2 -2
- package/dist/chunks/{contract-3QLAGYQL.js → contract-N6P2HIIE.js} +425 -187
- package/dist/chunks/{create-flow-VRVJEOBX.js → create-flow-5TXFOC7X.js} +6 -6
- package/dist/chunks/{ehr-SH2LM3NK.js → ehr-XI4BIVR2.js} +16 -5
- package/dist/chunks/{env-66FPSJDV.js → env-B6GKA2J3.js} +2 -2
- package/dist/chunks/{factory-UH2TZBVA.js → factory-MFCKLUT6.js} +1 -1
- package/dist/chunks/{group-chat-CAKMMV7K.js → group-chat-YE7WIBFO.js} +3 -3
- package/dist/chunks/{im-NJB7ZYMH.js → im-3RCNL5GT.js} +107 -1
- package/dist/chunks/{invoice-OQP3TMKQ.js → invoice-FXWH5GPO.js} +209 -0
- package/dist/chunks/{lazy-dispatch-DD6ULZ3I.js → lazy-dispatch-XSAHDK6Z.js} +2 -2
- package/dist/chunks/{meeting-VTBFW4HI.js → meeting-RYZV2JTQ.js} +10 -10
- package/dist/chunks/{reception-5WITA44R.js → reception-VL6TKVAW.js} +480 -26
- package/dist/chunks/{recruit-stage-CAKZTUA7.js → recruit-stage-ERZD3ZNB.js} +52 -16
- package/dist/chunks/{registry-JVQBLFQ5.js → registry-22O6UG4I.js} +10 -10
- package/dist/chunks/{registry-AQVGHUM6.js → registry-7VZ6YJUF.js} +2 -2
- package/dist/chunks/{registry-PVUZQDDQ.js → registry-BUTEDK3C.js} +1 -1
- package/dist/chunks/{room-recommend-5U55FMXZ.js → room-recommend-IMZPJMYB.js} +4 -4
- package/dist/chunks/{schedule-IDETODCA.js → schedule-SPPAHER2.js} +4 -4
- package/dist/chunks/{workflow-BSYT5TGL.js → workflow-WVEFJ6KC.js} +2 -2
- package/dist/core/refs.js +19 -2
- package/dist/index.js +13 -13
- package/dist/shortcuts/archive-oa/constants.js +42 -0
- package/dist/shortcuts/archive-oa/host.js +2 -2
- package/dist/shortcuts/archive-oa/index.js +38 -0
- package/dist/shortcuts/archive-oa/operations/borrow-car.js +117 -3
- package/dist/shortcuts/archive-oa/operations/my-borrow-contract.js +271 -0
- package/dist/shortcuts/archive-oa/operations/registry.js +5 -3
- package/dist/shortcuts/contract/index.js +9 -1
- package/dist/shortcuts/contract/manifest.js +14 -2
- package/dist/shortcuts/contract/operations/card.js +231 -0
- package/dist/shortcuts/contract/operations/registry.js +2 -0
- package/dist/shortcuts/contract/operations/review.js +16 -5
- package/dist/shortcuts/contract/operations/summary.js +25 -17
- package/dist/shortcuts/ehr/operations/recruit-write.js +22 -5
- package/dist/shortcuts/ehr/recruit-stage/operations/interview-arrange.js +17 -8
- package/dist/shortcuts/ehr/recruit-stage/shared.js +33 -8
- package/dist/shortcuts/im/index.js +128 -0
- package/dist/shortcuts/im/operations/session.js +6 -0
- package/dist/shortcuts/invoice/manifest.js +60 -0
- package/dist/shortcuts/invoice/operations/registry.js +2 -0
- package/dist/shortcuts/invoice/operations/reim-subsidy.js +163 -0
- package/dist/shortcuts/meeting/operations/eb/conflict.js +26 -3
- package/dist/shortcuts/meeting/operations/eb/continuation-alias.js +63 -0
- package/dist/shortcuts/meeting/operations/eb/create-flow.js +71 -12
- package/dist/shortcuts/meeting/operations/eb/factory.js +5 -3
- package/dist/shortcuts/reception/host.js +33 -1
- package/dist/shortcuts/reception/index.js +19 -0
- package/dist/shortcuts/reception/manifest.js +53 -1
- package/dist/shortcuts/reception/operations/ask.js +18 -0
- package/dist/shortcuts/reception/operations/compose.js +113 -3
- package/dist/shortcuts/reception/operations/leads.js +245 -0
- package/dist/shortcuts/reception/operations/markdown.js +22 -0
- package/dist/shortcuts/reception/operations/registry.js +2 -0
- package/dist/shortcuts/reception/operations/render.js +36 -3
- package/dist/shortcuts/reception/operations/restaurant-rooms.js +118 -0
- package/dist/shortcuts/reception/operations/restaurant.js +251 -0
- package/dist/shortcuts/reception/operations/restaurantrooms.js +42 -0
- package/dist/shortcuts/reception/operations/schedule.js +7 -1
- package/dist/shortcuts/reception/upload.js +22 -6
- package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +17 -8
- package/dist/shortcuts/recruit-stage/shared.js +42 -14
- package/docs/archive-oa.md +4 -2
- package/docs/invoice.md +1 -0
- package/package.json +1 -1
- package/skill-template/domains/archive-oa.md +2 -1
- package/skill-template/master-skill-template.md +1 -0
- package/skill-template/skill-template.md +1 -0
- package/skills/weaver-e10-archive-oa/SKILL.md +33 -6
- package/skills/weaver-e10-archive-oa/references/borrow-car.md +32 -7
- package/skills/weaver-e10-archive-oa/references/contract-search.md +32 -0
- package/skills/weaver-e10-archive-oa/references/disabled-capabilities.md +1 -1
- package/skills/weaver-e10-archive-oa/references/my-borrow-contract.md +97 -0
- package/skills/weaver-e10-archive-oa/references/my-borrow.md +6 -1
- package/skills/weaver-e10-archive-oa/references/qys-contract-search.md +22 -0
- package/skills/weaver-e10-calendar/SKILL.md +1 -1
- package/skills/weaver-e10-calendar/references/calendar-query.md +1 -1
- package/skills/weaver-e10-calendar/references/calendar-write.md +9 -9
- package/skills/weaver-e10-cowork/SKILL.md +9 -6
- package/skills/weaver-e10-jinchengda/SKILL.md +10 -7
- package/skills/weaver-e10-jinchengda/references/contract-action-card-template.html +17 -0
- package/skills/weaver-e10-jinchengda/references/contract-action-card.md +263 -35
- package/skills/weaver-e10-jinchengda/references/contract-action-engine.md +8 -5
- package/skills/weaver-e10-jinchengda/references/contract-ai-assistant.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +175 -22
- package/skills/weaver-e10-jinchengda/references/contract-command-index.md +2 -2
- package/skills/weaver-e10-jinchengda/references/contract-credit-page.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-doc-compare.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +124 -19
- package/skills/weaver-e10-jinchengda/references/contract-element-extract.md +2 -2
- package/skills/weaver-e10-jinchengda/references/contract-execution-rules.md +4 -4
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +6 -0
- package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-risk-report-template.html +178 -0
- package/skills/weaver-e10-jinchengda/references/contract-template-recommend.md +1 -1
- package/skills/weaver-e10-jinchengda/references/orchestration.md +7 -7
- package/skills/weaver-e10-jinchengda/scripts/plan_actions.py +279 -0
- package/skills/weaver-e10-jinchengda/scripts/render_action_card.py +450 -0
- package/skills/weaver-e10-jinchengda/scripts/render_risk_report.py +358 -0
- package/skills/weaver-e10-jinchengda/scripts/validate_action_card.py +505 -0
- package/skills/weaver-e10-jucailin/SKILL.md +7 -4
- package/skills/weaver-e10-jucailin/references/recruit-create.md +3 -2
- package/skills/weaver-e10-jucailin/references/recruit-read.md +2 -1
- package/skills/weaver-e10-jucailin/references/recruit-stage-ops.md +3 -3
- package/skills/weaver-e10-jucailin/references/safety-boundaries.md +30 -2
- package/skills/weaver-e10-mail/SKILL.md +17 -4
- package/skills/weaver-e10-meeting/SKILL.md +94 -409
- package/skills/weaver-e10-meeting/references/create-flow.md +188 -0
- package/skills/weaver-e10-meeting/references/create-guardrails.md +234 -0
- package/skills/weaver-e10-meeting/references/pitfalls.md +40 -0
- package/skills/weaver-e10-reception-flow/SKILL.md +62 -18
- package/skills/weaver-e10-reception-flow/data/fields-snapshot.json +628 -26
- package/skills/weaver-e10-reception-flow/references/fields-snapshot.md +96 -26
- package/skills/weaver-e10-reception-flow/scripts/render.py +81 -2
- package/skills/weaver-e10-recruit-stage/SKILL.md +45 -12
- package/skills/weaver-e10-recruit-stage/agents/openai.yaml +58 -8
- package/skills/weaver-e10-recruit-stage/references/position-templates.md +5 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-edit-interview-feedback.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +40 -11
- package/skills/weaver-e10-recruit-stage/references/recruit-list-candidate.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-list-interview.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-match-candidates.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +16 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-parse.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-search-candidate.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-urge-feedback.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-utterance-glossary.md +127 -0
- package/skills/weaver-e10-shijingran/SKILL.md +6 -2
- package/skills/weaver-e10-shijingran/references/source-manifest.json +5 -4
- package/skills/weaver-e10-workflow/SKILL.md +1 -1
- package/skills/weaver-e10-yepiaotong/SKILL.md +14 -8
- package/skills/weaver-e10-yepiaotong/references/invoice-import.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-issuing-workflow.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +10 -3
- package/skills/weaver-e10-yepiaotong/references/invoice-upload-and-validate.md +2 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-validation-preview.md +2 -0
- package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +69 -7
- package/skills/weaver-e10-yepiaotong/references/reim-examples.md +3 -3
- package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +9 -16
- package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +6 -5
- package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +206 -92
- package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +27 -21
- package/skills/weaver-e10-yepiaotong/references/source-manifest.json +35 -0
- package/skills/weaver-e10-yimiaoban/SKILL.md +2 -1
- package/skills/weaver-e10-yimiaoban/references/msg-write.md +32 -0
- package/skills/weaver-e10-yimiaoban/references/session-sysmsg.md +3 -0
- package/skills/weaver-e10-yimiaoban/references/source-manifest.json +11 -11
- package/dist/chunks/{ebuilder-form-GWDTKEI2.js → ebuilder-form-I5ZIX4WO.js} +3 -3
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-README.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-SKILL.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-openai.yaml +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-position-templates.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-arrange-interview.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-capability-check.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-check-install.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-detail-process.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-edit-interview-feedback.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-jd-create.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-jd-template.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-list-candidate.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-list-interview.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-match-candidates.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-output-links.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-resolve-creator.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-resolve-metadata.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-resume-import.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-resume-parse.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-search-candidate.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-urge-feedback.md +0 -0
|
@@ -0,0 +1,358 @@
|
|
|
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()
|