weaver-work-cli 0.1.63 → 0.1.65
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-BLDYBZDX.js → archive-WUZKAEZ6.js} +2 -2
- package/dist/chunks/{archive-oa-3GJ3TWXR.js → archive-oa-PN46RTI2.js} +2 -2
- package/dist/chunks/{asset-AFXJN4CK.js → asset-ZPC5VWZM.js} +2 -2
- package/dist/chunks/{asset-idle-VUJXWGWJ.js → asset-idle-DHGP3NYY.js} +2 -2
- package/dist/chunks/{attachment-content-VMJA7NSQ.js → attachment-content-QUM27QNB.js} +3 -3
- package/dist/chunks/{blog-EREB35VU.js → blog-JC47AIXK.js} +2 -2
- package/dist/chunks/{caizhilian-ATM2JO5S.js → caizhilian-IKIHM77A.js} +4 -4
- package/dist/chunks/{calendar-E26ZIH7S.js → calendar-GZTSJ57Y.js} +2 -2
- package/dist/chunks/{chunk-OMAGCLUE.js → chunk-26FCCU5O.js} +2 -2
- package/dist/chunks/{chunk-EOZHSNND.js → chunk-3W5NMGDS.js} +2 -2
- package/dist/chunks/{chunk-SHBDXEUE.js → chunk-6AW5LW4T.js} +4 -4
- package/dist/chunks/{chunk-C5PIGPGX.js → chunk-6T5X6YWX.js} +2 -2
- package/dist/chunks/{chunk-WPBZQVLS.js → chunk-AFZTMYGC.js} +1 -1
- package/dist/chunks/{chunk-LOVAIGM2.js → chunk-CUY64WP4.js} +50 -50
- package/dist/chunks/{chunk-IGICM3WJ.js → chunk-D6SWOUUP.js} +2 -2
- package/dist/chunks/{chunk-BY3WDJO5.js → chunk-E3OQSNF5.js} +1 -1
- package/dist/chunks/{chunk-G3ZM57PD.js → chunk-F4ME3CGS.js} +2 -2
- package/dist/chunks/{chunk-6VCQLZXE.js → chunk-FDBAFANU.js} +1 -0
- package/dist/chunks/{chunk-RV2JAA5I.js → chunk-FJUOUSV3.js} +1 -1
- package/dist/chunks/{chunk-6G2JARDK.js → chunk-HLT6B26P.js} +1 -1
- package/dist/chunks/{chunk-THMBDCRA.js → chunk-HWA2A25Y.js} +2 -2
- package/dist/chunks/{chunk-HEJPVXD3.js → chunk-IJDZ7VDC.js} +4 -4
- package/dist/chunks/{chunk-GOBNIGWS.js → chunk-IT3SB7RV.js} +89 -16
- package/dist/chunks/{chunk-TNFIUZ4H.js → chunk-JDZOYHAL.js} +1 -1
- package/dist/chunks/{chunk-QZYKZ7MQ.js → chunk-K7QKQRSL.js} +155 -57
- package/dist/chunks/{chunk-QAMIIFP6.js → chunk-LRK7YND4.js} +11 -11
- package/dist/chunks/{chunk-4OB22YKE.js → chunk-NZLFKBEM.js} +6 -6
- package/dist/chunks/{chunk-RR45ELVE.js → chunk-Q6D6PSMH.js} +2 -2
- package/dist/chunks/{chunk-5CY37VLS.js → chunk-QT7GGCSY.js} +45 -43
- package/dist/chunks/{chunk-GQK6WLOS.js → chunk-VLY5RTVO.js} +2 -2
- package/dist/chunks/{chunk-SDPC7BG2.js → chunk-WSHIOSGM.js} +2 -2
- package/dist/chunks/{chunk-I4C2KR2G.js → chunk-ZV3TYANI.js} +1 -1
- package/dist/chunks/{conflict-AMNTM3FV.js → conflict-76ZUL3E7.js} +2 -2
- package/dist/chunks/{contract-PLO2V2NO.js → contract-INMS7SYQ.js} +846 -199
- package/dist/chunks/{cowork-FZAXE6FO.js → cowork-34CBYVQP.js} +2 -2
- package/dist/chunks/{create-flow-2DAUN7HU.js → create-flow-7WGKLRHH.js} +8 -6
- package/dist/chunks/{data-7NXMWET4.js → data-QKWI5325.js} +13 -2
- package/dist/chunks/{ebuilder-form-DEYHX6M7.js → ebuilder-form-ZONRROK4.js} +3 -3
- package/dist/chunks/{ehr-QQH2DYYA.js → ehr-2CONM7R6.js} +2 -2
- package/dist/chunks/{entry-mode-2JTVEKMP.js → entry-mode-3UMMMK6Z.js} +3 -3
- package/dist/chunks/{env-2JZMXC6I.js → env-7EGXNZR2.js} +2 -2
- package/dist/chunks/{esb-I5ZFHJUK.js → esb-FQASCY2H.js} +4 -4
- package/dist/chunks/{factory-XIATYHU6.js → factory-BDERKTYX.js} +1 -1
- package/dist/chunks/{fna-3V2TL6B2.js → fna-FCLVIWAS.js} +2 -2
- package/dist/chunks/{group-chat-CVYUZCOQ.js → group-chat-4E7EZMTJ.js} +3 -3
- package/dist/chunks/{host-CBONEAZS.js → host-2ED2KC4X.js} +3 -3
- package/dist/chunks/{host-4DP7C7YQ.js → host-2UYZEY2V.js} +3 -3
- package/dist/chunks/{host-4KQCAEWA.js → host-46NYKDQP.js} +3 -3
- package/dist/chunks/{host-BD7NAM33.js → host-7IPZKIM4.js} +3 -3
- package/dist/chunks/{host-L37QVNIV.js → host-P7G22WNM.js} +3 -3
- package/dist/chunks/{host-4X2F3JPQ.js → host-XLCBLNJD.js} +3 -3
- package/dist/chunks/{hrm-OL3IKN7C.js → hrm-XKL27NX2.js} +3 -3
- package/dist/chunks/{im-YXQWUF3R.js → im-NDYIMASG.js} +3 -3
- package/dist/chunks/{invoice-4WY32PR2.js → invoice-MOGNB6HN.js} +3 -3
- package/dist/chunks/{jiuchuanhui-L6SHLONH.js → jiuchuanhui-3T5X7SB7.js} +2 -2
- package/dist/chunks/{lazy-dispatch-OYE6QV24.js → lazy-dispatch-4WOIL3ZQ.js} +4 -4
- package/dist/chunks/{mail-PZV2KNRU.js → mail-P7VMUKQW.js} +2 -2
- package/dist/chunks/{meeting-6SOBCC6N.js → meeting-2FMYZXG5.js} +13 -13
- package/dist/chunks/{minute-doc-KSJSJNOH.js → minute-doc-3DHMYMBE.js} +4 -4
- package/dist/chunks/{okr-B76FW5M2.js → okr-VZXRQGS4.js} +2 -2
- package/dist/chunks/{operations-YOMEGFLV.js → operations-MI2BSKZX.js} +4 -4
- package/dist/chunks/{performance-4VBKUPFO.js → performance-OPEQNW7Y.js} +870 -15
- package/dist/chunks/{plan-HBNZRQTI.js → plan-TJAS4N5X.js} +2 -2
- package/dist/chunks/{project-IV6FWK74.js → project-CYBGU6K6.js} +2 -2
- package/dist/chunks/{reception-BR5YURT6.js → reception-3FT2F66K.js} +2 -2
- package/dist/chunks/{recruit-stage-4HQ6OGXT.js → recruit-stage-WPGB5BDJ.js} +2 -2
- package/dist/chunks/{registry-JFQEFC7E.js → registry-6UGQO35C.js} +2 -2
- package/dist/chunks/{registry-MZJQX65Q.js → registry-QRMXRSCT.js} +4 -4
- package/dist/chunks/{registry-7LICMV5J.js → registry-XXFMYPBM.js} +12 -12
- package/dist/chunks/{room-recommend-43GLLE7Y.js → room-recommend-7LD2OHL5.js} +4 -4
- package/dist/chunks/{schedule-ZQ42BEW6.js → schedule-ZAYMZKTQ.js} +4 -4
- package/dist/chunks/{smart-extract-QKAEAZGM.js → smart-extract-FOBSVNYW.js} +2 -2
- package/dist/chunks/{workflow-6HV7H5PC.js → workflow-NYJJIT3D.js} +4 -4
- package/dist/index.js +33 -33
- package/dist/internal/e10/auth/commands.js +182 -43
- package/dist/shortcuts/contract/error-actions.js +112 -0
- package/dist/shortcuts/contract/errors.js +9 -1
- package/dist/shortcuts/contract/manifest.js +18 -7
- package/dist/shortcuts/contract/operations/docx-slots.js +112 -5
- package/dist/shortcuts/contract/operations/docx-verify.js +2 -70
- package/dist/shortcuts/contract/operations/elements-build.js +82 -56
- package/dist/shortcuts/contract/operations/elements-spec.js +140 -3
- package/dist/shortcuts/contract/operations/ledger-card.js +25 -2
- package/dist/shortcuts/contract/operations/ledger.js +33 -5
- package/dist/shortcuts/contract/operations/money.js +90 -0
- package/dist/shortcuts/contract/operations/placeholder-scan.js +104 -0
- package/dist/shortcuts/contract/operations/quote-recognize.js +54 -17
- package/dist/shortcuts/contract/operations/quote-ref.js +179 -0
- package/dist/shortcuts/contract/operations/quote-submit.js +20 -3
- package/dist/shortcuts/contract/operations/quote.js +66 -12
- package/dist/shortcuts/contract/operations/solutions-spec.js +79 -0
- package/dist/shortcuts/contract/operations/triage.js +55 -9
- package/dist/shortcuts/data/operations/shared.js +14 -1
- package/dist/shortcuts/meeting/operations/eb/create-flow.js +25 -11
- package/dist/shortcuts/performance/flow-utils.js +363 -0
- package/dist/shortcuts/performance/manifest.js +2 -2
- package/dist/shortcuts/performance/operations/flow-detail.js +85 -0
- package/dist/shortcuts/performance/operations/flow-list.js +213 -0
- package/dist/shortcuts/performance/operations/flow-score.js +241 -0
- package/dist/shortcuts/performance/operations/registry.js +6 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.categoryCounts.js +64 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +15 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +4 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +4 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.prepareQuery.js +4 -0
- package/docs/e10-auth.md +27 -2
- package/package.json +1 -1
- package/skills/weaver-e10-jinchengda/SKILL.md +87 -39
- package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +29 -29
- package/skills/weaver-e10-jinchengda/references/contract-clause-insert.md +2 -2
- package/skills/weaver-e10-jinchengda/references/contract-clause-library-crud.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-command-index.md +29 -7
- package/skills/weaver-e10-jinchengda/references/contract-compare-report.md +3 -3
- package/skills/weaver-e10-jinchengda/references/contract-credit-page.md +5 -5
- package/skills/weaver-e10-jinchengda/references/contract-disabled-capabilities.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-doc-compare.md +22 -25
- package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +53 -314
- package/skills/weaver-e10-jinchengda/references/contract-element-extract.md +6 -5
- package/skills/weaver-e10-jinchengda/references/contract-element-save-record.md +19 -11
- package/skills/weaver-e10-jinchengda/references/contract-execution-rules.md +3 -3
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +43 -25
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +103 -212
- package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +7 -7
- package/skills/weaver-e10-jinchengda/references/contract-ledger-catalog.md +7 -6
- package/skills/weaver-e10-jinchengda/references/contract-ledger-query-playbook.md +34 -21
- package/skills/weaver-e10-jinchengda/references/contract-ledger-rules.md +6 -6
- package/skills/weaver-e10-jinchengda/references/contract-modeltext-library.md +3 -3
- package/skills/weaver-e10-jinchengda/references/contract-multi-file.md +6 -6
- package/skills/weaver-e10-jinchengda/references/contract-object-detect.md +22 -22
- package/skills/weaver-e10-jinchengda/references/contract-open-web-pages.md +21 -19
- package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +6 -5
- package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +132 -95
- package/skills/weaver-e10-jinchengda/references/contract-request-status.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-request-write.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-template-recommend.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-type-fingerprints.md +12 -12
- package/skills/weaver-e10-jinchengda/references/contract-workflow-discovery.md +1 -1
- package/skills/weaver-e10-jinchengda/references/orchestration.md +5 -5
- package/skills/weaver-e10-meeting/SKILL.md +8 -7
- package/skills/weaver-e10-meeting/references/create-commands.md +2 -2
- package/skills/weaver-e10-meeting/references/create-flow.md +6 -6
- package/skills/weaver-e10-meeting/references/create-guardrails.md +10 -10
- package/skills/weaver-e10-meeting/references/invitation.md +1 -1
- package/skills/weaver-e10-meeting/references/meeting-eb.md +26 -26
- package/skills/weaver-e10-meeting/references/meeting-invitation.md +2 -2
- package/skills/weaver-e10-meeting/references/meeting-minute-file.md +2 -2
- package/skills/weaver-e10-meeting/references/meeting-verification.md +1 -1
- package/skills/weaver-e10-performance/SKILL.md +45 -5
- package/skills/weaver-e10-performance/agents/openai.yaml +26 -2
- package/skills/weaver-e10-performance/references/flow-api.md +128 -0
- package/skills/weaver-e10-performance/references/flow-assess.md +149 -0
- package/skills/weaver-e10-workflow/SKILL.md +40 -16
- package/skills/weaver-e10-workflow/aigroup/default.json +1 -1
- package/skills/weaver-e10-workflow/references/todo-dialogue.md +30 -27
- package/skills/weaver-e10-workflow/references/todo-smart-convert.md +90 -22
- package/skills/weaver-e10-workflow/references/workflow-view.md +18 -2
- package/skills/weaver-e10-workflow/tools/todo-summary.cjs +240 -43
- package/skills/weaver-e10-yimiaoban/SKILL.md +8 -5
- package/skills/weaver-e10-yimiaoban/references/source-manifest.json +3 -3
|
@@ -3,6 +3,9 @@ import { dirname, resolve } from 'node:path';
|
|
|
3
3
|
import { contractValidationError } from '../errors.js';
|
|
4
4
|
import { readZip, rewriteZip } from '../ooxml/zip.js';
|
|
5
5
|
import { allTableGrids, collectRanges, deleteTableRows, insertTableRows, parseTables, paragraphText, setCellText, setParagraphText, } from '../ooxml/docx-table.js';
|
|
6
|
+
import { findMoneyPlaceholder, hasCurrencySymbol } from './money.js';
|
|
7
|
+
import { RESIDUE_PATTERNS, residueTextOfDocx, scanResidue } from './placeholder-scan.js';
|
|
8
|
+
import { assertQuoteRefsResolved, resolveQuoteRefs } from './quote-ref.js';
|
|
6
9
|
/**
|
|
7
10
|
* 模板位点扫描 + 按填充方案回填(2026-11-16 新增,模板驱动)。
|
|
8
11
|
*
|
|
@@ -475,9 +478,69 @@ function pickColumnValue(item, columnName) {
|
|
|
475
478
|
}
|
|
476
479
|
return null;
|
|
477
480
|
}
|
|
481
|
+
function describeIssues(issues) {
|
|
482
|
+
const head = issues
|
|
483
|
+
.slice(0, 5)
|
|
484
|
+
.map((issue) => `${issue.label}${issue.slotId ? `(${issue.slotId})` : ''}=${issue.value}`)
|
|
485
|
+
.join('、');
|
|
486
|
+
return issues.length > 5 ? `${head} 等 ${issues.length} 处` : head;
|
|
487
|
+
}
|
|
488
|
+
function auditPlanValues(plan, scannedSlots) {
|
|
489
|
+
const slotById = new Map(scannedSlots.map((slot) => [slot.slotId, slot]));
|
|
490
|
+
const placeholder = [];
|
|
491
|
+
const displayMoney = [];
|
|
492
|
+
const inspect = (slotId, label, value, isMoney) => {
|
|
493
|
+
if (value === null || value === undefined || value === '')
|
|
494
|
+
return;
|
|
495
|
+
const text = String(value);
|
|
496
|
+
// 占位符不论落在哪个位点都是事故:它只是模型侧的展示形态
|
|
497
|
+
const token = findMoneyPlaceholder(text);
|
|
498
|
+
if (token) {
|
|
499
|
+
placeholder.push({ slotId, label, value: text, placeholder: token });
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
502
|
+
// 形状保持的展示文本(¥144,000.00)无法与真实金额区分,只能在金额位点上拒收。
|
|
503
|
+
// 只拦货币符号:`144000元` 之类数字完整的写法含义唯一,拒收属误伤。
|
|
504
|
+
if (isMoney && hasCurrencySymbol(text)) {
|
|
505
|
+
displayMoney.push({ slotId, label, value: text, placeholder: null });
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
for (const slot of Array.isArray(plan.slots) ? plan.slots : []) {
|
|
509
|
+
const slotId = typeof slot?.slotId === 'string' ? slot.slotId : '';
|
|
510
|
+
if (!slotId)
|
|
511
|
+
continue;
|
|
512
|
+
const scanned = slotById.get(slotId);
|
|
513
|
+
inspect(slotId, scanned?.label ?? '未知位点', slot?.value, scanned?.constraint === 'money');
|
|
514
|
+
}
|
|
515
|
+
for (const detail of Array.isArray(plan.details) ? plan.details : []) {
|
|
516
|
+
const slotId = typeof detail?.slotId === 'string' ? detail.slotId : '';
|
|
517
|
+
const scanned = slotId ? slotById.get(slotId) : undefined;
|
|
518
|
+
const columns = scanned && scanned.type === 'detail-area' ? scanned.columns.map((column) => column.name) : [];
|
|
519
|
+
const label = scanned?.label ?? '明细区';
|
|
520
|
+
inspect(slotId, `${label}·小计`, detail?.subtotal ?? detail?.total, true);
|
|
521
|
+
for (const item of Array.isArray(detail?.items) ? detail.items : []) {
|
|
522
|
+
if (typeof item !== 'object' || item === null)
|
|
523
|
+
continue;
|
|
524
|
+
for (const [key, value] of Object.entries(item)) {
|
|
525
|
+
// 有模板列名时以列名语义为准;没有时退回按键名判语义(判不出按文本列,不误报)
|
|
526
|
+
const isMoney = columns.length > 0
|
|
527
|
+
? columns.some((name) => normalizeKey(name) === normalizeKey(key) && inferConstraint(name) === 'money')
|
|
528
|
+
: inferConstraint(key) === 'money';
|
|
529
|
+
inspect(slotId, `${label}·${key}`, value, isMoney);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
if (plan.totals && typeof plan.totals === 'object') {
|
|
534
|
+
inspect('totals.grandTotal', '合同总额', plan.totals.grandTotal, true);
|
|
535
|
+
const installments = Array.isArray(plan.totals.installments) ? plan.totals.installments : [];
|
|
536
|
+
installments.forEach((value, index) => {
|
|
537
|
+
inspect(`totals.installments[${index}]`, `第 ${index + 1} 期金额`, value, true);
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
return { placeholder, displayMoney };
|
|
541
|
+
}
|
|
478
542
|
/**
|
|
479
543
|
* 轻量 XML 良构校验(标签配对 + 残余栈),不依赖第三方解析库。
|
|
480
|
-
*
|
|
481
544
|
* 2026-11-16 实测教训:引擎曾对**标签已破碎、Word 打不开**的产物返回 `ok=true`——
|
|
482
545
|
* 因为回读只用正则抽 `<w:t>` 文本,不做结构校验,错误被完全掩盖。
|
|
483
546
|
* 因此把「产物必须是良构 XML」提升为独立交付判据,任何 FAIL 一律不得交付。
|
|
@@ -582,14 +645,23 @@ export const contractDocxSlotsOperations = [
|
|
|
582
645
|
if (!outInput)
|
|
583
646
|
throw contractValidationError('out_required', 'out(输出 docx 绝对路径)为必填');
|
|
584
647
|
const planInput = input.plan;
|
|
585
|
-
const
|
|
648
|
+
const planRaw = typeof planInput === 'string'
|
|
586
649
|
? (existsSync(resolve(planInput))
|
|
587
650
|
? JSON.parse(readFileSync(resolve(planInput), 'utf8').replace(/^\uFEFF/u, ''))
|
|
588
651
|
: (() => { throw contractValidationError('plan_not_found', `填充方案文件不存在:${planInput}`); })())
|
|
589
652
|
: planInput;
|
|
590
|
-
if (typeof
|
|
653
|
+
if (typeof planRaw !== 'object' || planRaw === null || Array.isArray(planRaw)) {
|
|
591
654
|
throw contractValidationError('plan_required', 'plan 必须是填充方案对象或其 JSON 文件路径');
|
|
592
655
|
}
|
|
656
|
+
// ── 值引用解析(2026-11-20 P1):plan 里任何位置都可以写
|
|
657
|
+
// {"$quote":"<报价书解析结果.json 绝对路径>#<字段路径>"},由本进程读真值填进来。
|
|
658
|
+
// 模型只需要说「取哪个字段」(结构不被脱敏),金额从头到尾不经过模型上下文。
|
|
659
|
+
// 必须在写前守卫之前完成,守卫才能对**解析后的真值**再做一次体检。
|
|
660
|
+
const refOutcome = resolveQuoteRefs(planRaw);
|
|
661
|
+
assertQuoteRefsResolved(refOutcome, (errors) => `填充方案有 ${errors.length} 处 $quote 引用取不到值:`
|
|
662
|
+
+ errors.slice(0, 5).map((item) => `${item.at}(${item.ref}:${item.reason})`).join(';')
|
|
663
|
+
+ '。请核对引用的文件路径与字段路径;报价书解析结果需先用 contract.quote.parse / contract.quote.normalize 的 out 参数落盘。');
|
|
664
|
+
const plan = refOutcome.value;
|
|
593
665
|
const strict = input.strict !== false;
|
|
594
666
|
const allowRowInsert = input.allowRowInsert !== false;
|
|
595
667
|
const slotWrites = Array.isArray(plan.slots) ? plan.slots : [];
|
|
@@ -597,6 +669,9 @@ export const contractDocxSlotsOperations = [
|
|
|
597
669
|
const unsupported = Array.isArray(plan.unsupported) ? plan.unsupported : [];
|
|
598
670
|
const totals = typeof plan.totals === 'object' && plan.totals !== null ? plan.totals : null;
|
|
599
671
|
let xml = readDocumentXml(templatePath);
|
|
672
|
+
const templateXml = xml;
|
|
673
|
+
// 位点清单只扫一次:写前用于守卫(哪些位点是金额约束),写后用于核对必填覆盖
|
|
674
|
+
const templateSlots = scanSlots(templateXml).slots;
|
|
600
675
|
const gridsBefore = allTableGrids(xml);
|
|
601
676
|
const tablesBefore = parseTables(xml).length;
|
|
602
677
|
const warnings = [];
|
|
@@ -606,6 +681,21 @@ export const contractDocxSlotsOperations = [
|
|
|
606
681
|
// 2026-11-16 实测:删 6 行后 3r17c1 / 3r18c1 / 3r21c1 全部写空,
|
|
607
682
|
// 回读报「位点不存在」,而 applied 仍把它们计入成功数,属双重静默失败。
|
|
608
683
|
const rowShifts = [];
|
|
684
|
+
// ── 阶段 0:写前守卫。必须在做任何写入之前判定,确保残次品根本不会落盘。
|
|
685
|
+
// 2026-11-20 事故:占位符被当成值写入,写后五项校验全过,残次品直接交付。
|
|
686
|
+
const audit = auditPlanValues(plan, templateSlots);
|
|
687
|
+
if (audit.placeholder.length > 0) {
|
|
688
|
+
throw contractValidationError('plan_value_placeholder', `填充方案有 ${audit.placeholder.length} 处脱敏占位符:${describeIssues(audit.placeholder)}。`
|
|
689
|
+
+ '占位符只是模型上下文里的展示形态,本地进程收到的是字面量、没有任何还原环节,'
|
|
690
|
+
+ '写进 docx 就会得到金额错误的合同,因此拒绝写入。'
|
|
691
|
+
+ '正确动作:改用报价单解析结果里的纯数值(如 809166.76 或 "809166.76")重写这些位点后重跑,'
|
|
692
|
+
+ '不要传 [[MONEY_*]];这不是「金额拿不到」,不要向用户索要金额。', { placeholder: audit.placeholder });
|
|
693
|
+
}
|
|
694
|
+
if (audit.displayMoney.length > 0) {
|
|
695
|
+
throw contractValidationError('plan_value_display_text', `填充方案有 ${audit.displayMoney.length} 处金额位点传的是带货币符号的展示文本:`
|
|
696
|
+
+ `${describeIssues(audit.displayMoney)}。展示文本与脱敏值无法区分、也不会被还原,`
|
|
697
|
+
+ '请改传纯数值(如 144000 或 "144000.00"),数值以报价单解析结果的 totals / sections 为准。', { displayMoney: audit.displayMoney });
|
|
698
|
+
}
|
|
609
699
|
// ── 阶段 1:明细区行数调整(插行 / 删行),必须在写单元格之前完成,否则行号会漂移
|
|
610
700
|
for (const detail of detailPlans) {
|
|
611
701
|
const parsed = typeof detail?.slotId === 'string' ? parseSlotId(detail.slotId) : null;
|
|
@@ -836,7 +926,7 @@ export const contractDocxSlotsOperations = [
|
|
|
836
926
|
const checks = [];
|
|
837
927
|
const fails = [];
|
|
838
928
|
// 5.1 必填位点必须已覆盖
|
|
839
|
-
const scanned =
|
|
929
|
+
const scanned = templateSlots;
|
|
840
930
|
const requiredSlots = scanned.filter((slot) => slot.required);
|
|
841
931
|
const covered = new Set([...applied]);
|
|
842
932
|
const uncovered = requiredSlots
|
|
@@ -972,6 +1062,22 @@ export const contractDocxSlotsOperations = [
|
|
|
972
1062
|
else {
|
|
973
1063
|
checks.push({ level: 'PASS', item: 'XML 良构', detail: '标签全部配对' });
|
|
974
1064
|
}
|
|
1065
|
+
// 5.8 占位符残留:交付硬判据(2026-11-20 新增)
|
|
1066
|
+
//
|
|
1067
|
+
// 前七项的语义都是「写进去了没有」——必填有值、回读一致、金额勾稽、结构未变、XML 良构。
|
|
1068
|
+
// 它们**都无法发现「写进去的值本身是占位符」**:占位符满足必填、写的等于读的、
|
|
1069
|
+
// 非数字直接跳过金额勾稽、结构也没变。2026-11-20 实测事故(付款表 4 行写成占位符文本)
|
|
1070
|
+
// 正是五项校验全过、残次品照常交付。因此交付前必须回读全文扫残留,命中即不得交付。
|
|
1071
|
+
const residue = scanResidue(residueTextOfDocx(readZip(readFileSync(outPath))));
|
|
1072
|
+
const residueKeys = Object.keys(residue);
|
|
1073
|
+
if (residueKeys.length > 0) {
|
|
1074
|
+
const summary = residueKeys.map((key) => `${key}×${residue[key]}`).join('、');
|
|
1075
|
+
fails.push(`占位符残留:${summary}`);
|
|
1076
|
+
checks.push({ level: 'FAIL', item: '占位符残留', detail: summary });
|
|
1077
|
+
}
|
|
1078
|
+
else {
|
|
1079
|
+
checks.push({ level: 'PASS', item: '占位符残留', detail: `0 处(清单 ${RESIDUE_PATTERNS.length} 项)` });
|
|
1080
|
+
}
|
|
975
1081
|
const validateOk = fails.length === 0;
|
|
976
1082
|
return {
|
|
977
1083
|
status: 'COMPLETE',
|
|
@@ -987,11 +1093,12 @@ export const contractDocxSlotsOperations = [
|
|
|
987
1093
|
detailAdjust,
|
|
988
1094
|
rowShifts,
|
|
989
1095
|
details: detailResults,
|
|
1096
|
+
resolvedQuoteRefs: refOutcome.resolved,
|
|
990
1097
|
validate: { ok: validateOk, checks, fails },
|
|
991
1098
|
selfCheckPassed: validateOk,
|
|
992
1099
|
selfCheck: fails,
|
|
993
1100
|
note: validateOk
|
|
994
|
-
? `通过:${applied.length}
|
|
1101
|
+
? `通过:${applied.length} 个位点写入,必填覆盖、回读一致、金额勾稽、表结构、XML 良构与占位符残留校验均通过`
|
|
995
1102
|
: '不通过:见 validate.fails;未通过校验的产物不得交付',
|
|
996
1103
|
},
|
|
997
1104
|
};
|
|
@@ -2,62 +2,7 @@ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
import { contractValidationError } from '../errors.js';
|
|
4
4
|
import { readZip } from '../ooxml/zip.js';
|
|
5
|
-
|
|
6
|
-
* docx 占位符与结构校验(2026-11-13 第八批下沉)。
|
|
7
|
-
*
|
|
8
|
-
* 合并自两处**重复实现**:
|
|
9
|
-
* - `scripts/verify_docx_placeholders.py`(独立校验入口)
|
|
10
|
-
* - `scripts/fill_contract_from_quote.py` 的 `validate()`
|
|
11
|
-
*
|
|
12
|
-
* 两者做的是同一件事:读 word/*.xml 全量文本 + 可见文本交叉比对,
|
|
13
|
-
* 检查占位符残留、标题出现次数、标题是否重复、表格结构是否损坏。
|
|
14
|
-
* 合并后只保留一份口径,避免「两套校验给出不同结论」。
|
|
15
|
-
*
|
|
16
|
-
* 原实现依赖 python-docx 取「可见文本」与「表格结构」;
|
|
17
|
-
* 这里改为直接解析 document.xml:可见文本取 `<w:t>` 文本节点(python-docx 的
|
|
18
|
-
* paragraph.text 也只看 w:t,不含 instrText),表格结构按 `<w:tbl>` 深度扫描,
|
|
19
|
-
* 合并单元格与嵌套表格都不会让计数漂移。
|
|
20
|
-
*/
|
|
21
|
-
const DEFAULT_PATTERNS = [
|
|
22
|
-
'xxx公司',
|
|
23
|
-
'XXX公司',
|
|
24
|
-
'***有限公司',
|
|
25
|
-
'***',
|
|
26
|
-
'年 月 日',
|
|
27
|
-
'年 月 日',
|
|
28
|
-
'【】',
|
|
29
|
-
'____',
|
|
30
|
-
'{{',
|
|
31
|
-
'}}',
|
|
32
|
-
];
|
|
33
|
-
const XML_ENTITIES = [
|
|
34
|
-
[/</gu, '<'],
|
|
35
|
-
[/>/gu, '>'],
|
|
36
|
-
[/"/gu, '"'],
|
|
37
|
-
[/'/gu, "'"],
|
|
38
|
-
[/&/gu, '&'],
|
|
39
|
-
];
|
|
40
|
-
function decodeEntities(text) {
|
|
41
|
-
let out = text;
|
|
42
|
-
for (const [pattern, value] of XML_ENTITIES)
|
|
43
|
-
out = out.replace(pattern, value);
|
|
44
|
-
return out;
|
|
45
|
-
}
|
|
46
|
-
function stripTags(xml) {
|
|
47
|
-
return decodeEntities(xml.replace(/<[^>]+>/gu, ''));
|
|
48
|
-
}
|
|
49
|
-
/** 统计子串出现次数(按字面量,不用正则,避免占位符里的特殊字符)。 */
|
|
50
|
-
function countOccurrences(haystack, needle) {
|
|
51
|
-
if (!needle)
|
|
52
|
-
return 0;
|
|
53
|
-
let count = 0;
|
|
54
|
-
let index = haystack.indexOf(needle);
|
|
55
|
-
while (index !== -1) {
|
|
56
|
-
count += 1;
|
|
57
|
-
index = haystack.indexOf(needle, index + needle.length);
|
|
58
|
-
}
|
|
59
|
-
return count;
|
|
60
|
-
}
|
|
5
|
+
import { RESIDUE_PATTERNS, countOccurrences, stripTags, visibleText } from './placeholder-scan.js';
|
|
61
6
|
/** 按 `<w:tbl>` 深度扫描取顶层表格的行列数与 0 格行。 */
|
|
62
7
|
function extractTables(documentXml) {
|
|
63
8
|
const tables = [];
|
|
@@ -127,19 +72,6 @@ function extractTables(documentXml) {
|
|
|
127
72
|
}
|
|
128
73
|
return tables;
|
|
129
74
|
}
|
|
130
|
-
/** 可见文本:逐段落取 `<w:t>` 文本(等价 python-docx 的 paragraph.text / cell.text)。 */
|
|
131
|
-
function visibleText(documentXml) {
|
|
132
|
-
const lines = [];
|
|
133
|
-
for (const chunk of documentXml.split(/<\/w:p>/u)) {
|
|
134
|
-
const parts = [];
|
|
135
|
-
for (const match of chunk.matchAll(/<w:t(?:\s[^>]*)?>([\s\S]*?)<\/w:t>/gu)) {
|
|
136
|
-
parts.push(decodeEntities(match[1] ?? ''));
|
|
137
|
-
}
|
|
138
|
-
if (parts.length > 0)
|
|
139
|
-
lines.push(parts.join(''));
|
|
140
|
-
}
|
|
141
|
-
return lines.join('\n');
|
|
142
|
-
}
|
|
143
75
|
export const contractDocxVerifyOperations = [
|
|
144
76
|
{
|
|
145
77
|
name: 'contract.docx.verify',
|
|
@@ -158,7 +90,7 @@ export const contractDocxVerifyOperations = [
|
|
|
158
90
|
}
|
|
159
91
|
return item;
|
|
160
92
|
})
|
|
161
|
-
:
|
|
93
|
+
: RESIDUE_PATTERNS;
|
|
162
94
|
const title = typeof input.title === 'string' ? input.title.trim() : '';
|
|
163
95
|
const titleCountRaw = input.titleCount;
|
|
164
96
|
const titleCount = typeof titleCountRaw === 'number' && Number.isFinite(titleCountRaw) && titleCountRaw >= 0
|
|
@@ -2,6 +2,7 @@ import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'no
|
|
|
2
2
|
import { basename, dirname, extname, join, resolve } from 'node:path';
|
|
3
3
|
import { contractValidationError } from '../errors.js';
|
|
4
4
|
import { BUILTIN, CHECKBOX_HINTS_RESALE, CHECKBOX_HINTS_UPSALE, COMPANY_OPTIONS, NEW_CUSTOMER, } from './elements-spec.js';
|
|
5
|
+
import { SOLUTION_NAMES } from './solutions-spec.js';
|
|
5
6
|
/**
|
|
6
7
|
* 按流程内置字段表,把 triage.json 的要素自动组装成 recognizeResult。
|
|
7
8
|
*
|
|
@@ -146,9 +147,15 @@ function rowSnippet(lines, index) {
|
|
|
146
147
|
cells.shift();
|
|
147
148
|
return stripNumber(cells.join(''));
|
|
148
149
|
}
|
|
149
|
-
/**
|
|
150
|
+
/**
|
|
151
|
+
* 把 needle 拆成可用于兜底匹配的长片段(仍要求逐字命中原文行)。
|
|
152
|
+
*
|
|
153
|
+
* 2026-11-20:分隔符补上连字符 `- - — –`。专项名形如「聚才林-人事管理」,
|
|
154
|
+
* 合同里写的是「人事管理(组织架构…)」——不拆开就永远匹配不到,专项 origin 全为 null。
|
|
155
|
+
* 拆开后 `-` 两侧的词(人事管理 / 即时通讯 / 资产管理 …)都是合同里真实存在的字。
|
|
156
|
+
*/
|
|
150
157
|
function fragments(needle, minLength = 4) {
|
|
151
|
-
const parts = truthyText(needle).split(/[
|
|
158
|
+
const parts = truthyText(needle).split(/[\s,。;、,;::;||//()()#【】[\]\--—–]+/u);
|
|
152
159
|
return parts.filter((part) => part.length >= minLength);
|
|
153
160
|
}
|
|
154
161
|
/** 为数字串补充「千分位 / 去千分位」两种字形,供正文逐字匹配。 */
|
|
@@ -287,18 +294,35 @@ export function mapCompany(value) {
|
|
|
287
294
|
}
|
|
288
295
|
return '';
|
|
289
296
|
}
|
|
290
|
-
/**
|
|
297
|
+
/**
|
|
298
|
+
* 按归一化写法匹配选项,返回**选项 ID**(`options` 的表值)。
|
|
299
|
+
*
|
|
300
|
+
* 2026-11-20 回退:**选项值一律传选项 ID,不传显示名**(此前一度改成传显示名,已撤销)。
|
|
301
|
+
* 别名归一化(去空格、全半角、括号补充说明)保留:表键是「合同/口述里的写法」,表值是选项 ID。
|
|
302
|
+
*
|
|
303
|
+
* 匹配规则(保留 2026-11-20 的两处加固,它们修的是**匹配歧义**、与值形态无关):
|
|
304
|
+
* ① **精确命中优先**——否则「触发」会被「不触发」的子串匹配拉成歧义;
|
|
305
|
+
* ② 模糊命中要求**结论唯一**——同一字段下不同选项的别名可能互相包含
|
|
306
|
+
* (如签约形式的裸别名「双方电子签署」是两个选项的公共前缀),
|
|
307
|
+
* 命中多个不同选项时返回 null(宁可不填,也不写错选项)。
|
|
308
|
+
*/
|
|
291
309
|
export function pickOption(table, value) {
|
|
292
310
|
if (!pyTruthy(value))
|
|
293
311
|
return null;
|
|
294
312
|
const normalized = norm(value);
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
if (normalized ===
|
|
313
|
+
// ① 精确命中优先
|
|
314
|
+
for (const [alias, optionId] of Object.entries(table)) {
|
|
315
|
+
if (normalized === norm(alias))
|
|
298
316
|
return optionId;
|
|
299
|
-
}
|
|
300
317
|
}
|
|
301
|
-
|
|
318
|
+
// ② 模糊命中,但要求结论唯一
|
|
319
|
+
const ids = new Set();
|
|
320
|
+
for (const [alias, optionId] of Object.entries(table)) {
|
|
321
|
+
const candidate = norm(alias);
|
|
322
|
+
if (candidate.includes(normalized) || normalized.includes(candidate))
|
|
323
|
+
ids.add(optionId);
|
|
324
|
+
}
|
|
325
|
+
return ids.size === 1 ? [...ids][0] : null;
|
|
302
326
|
}
|
|
303
327
|
/**
|
|
304
328
|
* 流程标题兜底:取合同文件名称并去掉扩展名(2026-11-12 用户指定)。
|
|
@@ -352,34 +376,8 @@ function makePayload(spec, flow, fileId, results, subtables = []) {
|
|
|
352
376
|
},
|
|
353
377
|
};
|
|
354
378
|
}
|
|
355
|
-
/**
|
|
356
|
-
|
|
357
|
-
* 专项方案法定名称(references/contract-field-extract-new-customer.md §5.2 的 15 项)。
|
|
358
|
-
*
|
|
359
|
-
* 为什么固化到 CLI:专项名称只允许这 15 项,原名不得改写、缩写或自创。
|
|
360
|
-
* 过去完全依赖模型先读完 24 KB 文档再逐项对照——漏读或记错时会**静默写入错误名称**,
|
|
361
|
-
* 表单照样保存、页面不报错,事后极难发现;而且「读不全 → 再读一次」本身要白跑工具往返。
|
|
362
|
-
* 固化后非法值当场报错并回传 allowed 全量清单,模型无需预读文档即可自纠。
|
|
363
|
-
*
|
|
364
|
-
* 维护红线:与 §5.2 表格严格一一对应;新增/改名必须先改 reference 再改这里。
|
|
365
|
-
*/
|
|
366
|
-
export const SOLUTION_NAMES = [
|
|
367
|
-
'文书定-档案管理',
|
|
368
|
-
'聚才林-人事管理',
|
|
369
|
-
'采知连-文档管理',
|
|
370
|
-
'今承达-合同管理',
|
|
371
|
-
'齐业成-费控管理',
|
|
372
|
-
'千里聆-业务流程自动化',
|
|
373
|
-
'京桥通-采购管理',
|
|
374
|
-
'九氚汇-营销管理',
|
|
375
|
-
'事井然-项目管理',
|
|
376
|
-
'易秒办-即时通讯',
|
|
377
|
-
'令信通-统一身份',
|
|
378
|
-
'资管家-资产管理',
|
|
379
|
-
'业票通-数电票管理',
|
|
380
|
-
'数智大脑-小e',
|
|
381
|
-
'青蓝阁-学习考试',
|
|
382
|
-
];
|
|
379
|
+
/** 专项名称与命中依据清单见 `solutions-spec.ts`;此处再导出,保持既有引用可用。 */
|
|
380
|
+
export { SOLUTION_NAMES };
|
|
383
381
|
/**
|
|
384
382
|
* 校验专项方案名称是否都在白名单内。
|
|
385
383
|
*
|
|
@@ -399,6 +397,7 @@ export function assertSolutionNames(solutions) {
|
|
|
399
397
|
return;
|
|
400
398
|
throw contractValidationError('invalid_solution', `专项方案名称不在法定清单内:${received.join(' / ')}。合法值仅 ${SOLUTION_NAMES.length} 项(见 allowed);未命中的专项整行不要输出,禁止自创或改写名称`, { allowed: SOLUTION_NAMES, received });
|
|
401
399
|
}
|
|
400
|
+
/** 新客户流程:完整 23 项语义映射。 */
|
|
402
401
|
export function buildNewCustomer({ triage, fileId, flow, lines, sourceMap, fileIds }) {
|
|
403
402
|
const spec = NEW_CUSTOMER;
|
|
404
403
|
const fields = spec.fields;
|
|
@@ -419,11 +418,13 @@ export function buildNewCustomer({ triage, fileId, flow, lines, sourceMap, fileI
|
|
|
419
418
|
|| (pyTruthy(elements.finalUser)
|
|
420
419
|
&& pyTruthy(elements.partyA)
|
|
421
420
|
&& norm(elements.finalUser) !== norm(elements.partyA));
|
|
421
|
+
// 选项类字段一律写**选项 ID**(2026-11-20 回退:此前一度改成写显示名,已撤销)。
|
|
422
|
+
// 表键是合同/口述里的写法,表值是选项 ID;`pickOption` 做归一化匹配。
|
|
422
423
|
if (isPartnerSign) {
|
|
423
|
-
add('buyMode', spec.options?.buyMode['通过伙伴签署'], '签约相对方与最终用户不是同一主体,属通过伙伴签署', buildNeedles(partnerName));
|
|
424
|
+
add('buyMode', pickOption(spec.options?.buyMode ?? {}, '通过伙伴签署') ?? spec.options?.buyMode['通过伙伴签署'], '签约相对方与最终用户不是同一主体,属通过伙伴签署', buildNeedles(partnerName));
|
|
424
425
|
}
|
|
425
426
|
else {
|
|
426
|
-
add('buyMode', spec.options?.buyMode['直签'], '泛微与实际使用方直接签署', buildNeedles(elements.partyA));
|
|
427
|
+
add('buyMode', pickOption(spec.options?.buyMode ?? {}, '直签') ?? spec.options?.buyMode['直签'], '泛微与实际使用方直接签署', buildNeedles(elements.partyA));
|
|
427
428
|
}
|
|
428
429
|
// 流程标题:优先取合同标题;抽不到时直接取合同文件名(去后缀)
|
|
429
430
|
if (pyTruthy(elements.title)) {
|
|
@@ -446,24 +447,39 @@ export function buildNewCustomer({ triage, fileId, flow, lines, sourceMap, fileI
|
|
|
446
447
|
add('ourCompany', optionId, '乙方签约主体映射', `乙方:${truthyText(elements.partyB)}`);
|
|
447
448
|
}
|
|
448
449
|
add('address', elements.address, '取合同约定联系/送达地址', orElse(elements.address, '地址'));
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
//
|
|
450
|
+
// 收件人 / 电话:骨架键是 receiver / mobile,历史代码读的是 contact / phone。
|
|
451
|
+
// 2026-11-20 修复:两个键名都认(骨架键优先)——此前只读旧键,
|
|
452
|
+
// 模型按骨架填的值没人读,「合同收件人」「收件人移动电话」永远空着且不报错。
|
|
453
|
+
const receiverText = orElse(elements.receiver, elements.contact);
|
|
454
|
+
const mobileText = orElse(elements.mobile, elements.phone);
|
|
455
|
+
add('receiver', receiverText, '取合同联系人', orElse(receiverText, '联系人'));
|
|
456
|
+
add('mobile', mobileText, '取合同联系电话', orElse(mobileText, '电话'));
|
|
457
|
+
// 签署信息:抽到就用,抽不到用默认(值都是**选项 ID**)
|
|
452
458
|
let signForm = spec.defaults?.signForm ?? '2';
|
|
453
459
|
const rawSign = norm(orElse(elements.rawSign, ''));
|
|
454
460
|
if (rawSign.includes('电子签') && rawSign.includes('契约锁'))
|
|
455
461
|
signForm = '4';
|
|
456
462
|
add('signForm', signForm, '合同未特别约定,按纸质签署(默认值)', buildNeedles('盖章') ?? buildNeedles('电子签'));
|
|
457
463
|
if (pyTruthy(elements.signDate)) {
|
|
458
|
-
add('signDate', spec.options?.signDate['指定签署日期'], '合同载明签订日期,按指定签署日期', buildNeedles(elements.signDate));
|
|
464
|
+
add('signDate', spec.options?.signDate?.['指定签署日期'] ?? '3', '合同载明签订日期,按指定签署日期', buildNeedles(elements.signDate));
|
|
459
465
|
add('designatedDate', elements.signDate, '合同签订时间', buildNeedles(elements.signDate));
|
|
460
466
|
}
|
|
461
467
|
else {
|
|
462
468
|
add('signDate', spec.defaults?.signDate ?? '2', '合同未载明签署日期,按默认合同办理当天', null);
|
|
463
469
|
}
|
|
464
470
|
add('signWay', spec.defaults?.signWay ?? '0', '未特别约定签署顺序,按我方先盖章', null);
|
|
471
|
+
// 是否触发开票立项确认:业务属性、不从合同文本推断。
|
|
472
|
+
// 2026-11-20 用户定稿:新客户流程**默认「触发」**(选项 ID:触发=0 / 不触发=1);
|
|
473
|
+
// 合同明确写了不触发时才改。值同样是**选项 ID**。
|
|
474
|
+
add('invoiceConfirm', pickOption(spec.options?.invoiceConfirm ?? {}, elements.invoiceConfirm) ?? spec.defaults?.invoiceConfirm ?? '0', '业务属性不从合同文本推断,按流程默认「触发」', null);
|
|
465
475
|
// 专项购买信息(明细表):只输出合同原文命中的专项,未命中整行不输出;
|
|
466
476
|
// 无专属计价时金额固定填 0,禁止用「有无金额」反推专项是否存在(references §5.1/§5.3)。
|
|
477
|
+
//
|
|
478
|
+
// origin 口径(2026-11-20 修复):**不能用法定专项名去正文里找原文**。
|
|
479
|
+
// 「聚才林-人事管理」这类标准产品名按定义不会逐字出现在合同里(合同写的是
|
|
480
|
+
// 「人事管理(组织架构、岗位体系、…)」),此前 `ro(buildNeedles(name))` 必然取不到 → origin 全 null。
|
|
481
|
+
// 现在按优先级取:模型给的原文片段 `evidence` → 法定名(靠 fragments 拆出「人事管理」「即时通讯」
|
|
482
|
+
// 这类合同里真实存在的词)。参考 reference §4 的示例,origin 应为 `fileId#人事管理模块` 这种**合同原文**。
|
|
467
483
|
const subtables = [];
|
|
468
484
|
const solutions = Array.isArray(elements.solutions) ? elements.solutions : [];
|
|
469
485
|
if (solutions.length && spec.subFormId) {
|
|
@@ -474,13 +490,16 @@ export function buildNewCustomer({ triage, fileId, flow, lines, sourceMap, fileI
|
|
|
474
490
|
if (!name)
|
|
475
491
|
return;
|
|
476
492
|
const amount = amountOf(item?.amount) || '0';
|
|
477
|
-
const
|
|
493
|
+
const evidence = truthyText(item?.evidence);
|
|
494
|
+
const planOrigin = ro(buildNeedles(evidence)) ?? ro(buildNeedles(name));
|
|
495
|
+
// 金额列:填 0 表示「无专属计价」,正文里没有这个 0 —— 硬套专项方案那行的出处等于编造来源,故置 null。
|
|
496
|
+
const amountOrigin = amount === '0' ? null : ro(buildNeedles(amount));
|
|
478
497
|
rows.push({
|
|
479
498
|
subDataId: rows.length + 1,
|
|
480
499
|
mainDataId: 1,
|
|
481
500
|
reasons: ['合同标的列明该专项', '按折扣后实际金额计,无专属计价填 0'],
|
|
482
501
|
values: [name, amount],
|
|
483
|
-
origins: [
|
|
502
|
+
origins: [planOrigin ?? null, amountOrigin ?? null],
|
|
484
503
|
});
|
|
485
504
|
});
|
|
486
505
|
if (rows.length) {
|
|
@@ -530,18 +549,25 @@ export function buildGeneric({ triage, fileId, flow, lines, sourceMap, fileIds }
|
|
|
530
549
|
add('totalAmount', amount, '取合同总额并归一为数字', buildNeedles(amount) ?? buildNeedles(elements.totalAmount));
|
|
531
550
|
// ④ 联系 / 送达类文本
|
|
532
551
|
add('address', elements.address, '取合同约定联系/送达地址', buildNeedles(elements.address));
|
|
533
|
-
|
|
534
|
-
|
|
552
|
+
const receiverText = orElse(elements.receiver, elements.contact);
|
|
553
|
+
const mobileText = orElse(elements.mobile, elements.phone);
|
|
554
|
+
add('receiver', receiverText, '取合同联系人', buildNeedles(receiverText));
|
|
555
|
+
add('mobile', mobileText, '取合同联系电话', buildNeedles(mobileText));
|
|
535
556
|
// ⑤ 背景说明 / 对方签署人(有则填)
|
|
536
557
|
add('background', elements.background, '取合同背景说明', buildNeedles(elements.background));
|
|
537
558
|
add('partySigner', elements.partySigner, '取对方签署人', buildNeedles(elements.partySigner));
|
|
538
559
|
add('partyContact', elements.partyContact, '取对方签署人联系方式', buildNeedles(elements.partyContact));
|
|
539
|
-
// ⑥
|
|
560
|
+
// ⑥ 选项类字段:**一律传选项 ID**(2026-11-20 用户定稿)。
|
|
561
|
+
// 本流程登记了 options 表的字段 → 归一化匹配后取选项 ID;未登记的字段原样透传(该流程未收 ID 表)。
|
|
562
|
+
const optionId = (key, value) => {
|
|
563
|
+
const table = spec.options?.[key];
|
|
564
|
+
return table ? pickOption(table, value) ?? '' : value;
|
|
565
|
+
};
|
|
540
566
|
// 购买方式:有丙方/伙伴 → 通过伙伴签署,否则直签
|
|
541
|
-
addSelect('buyMode', orElse(elements.buyMode, pyTruthy(elements.partyC) ? '通过伙伴签署' : '直签'), '按合同签约结构判定购买方式', buildNeedles(elements.partyC));
|
|
567
|
+
addSelect('buyMode', optionId('buyMode', orElse(elements.buyMode, pyTruthy(elements.partyC) ? '通过伙伴签署' : '直签')), '按合同签约结构判定购买方式', buildNeedles(elements.partyC));
|
|
542
568
|
// 我方签约公司:必须映射成下拉框可用选项值,禁止直接填乙方全称
|
|
543
569
|
const company = mapCompany(orElse(elements.ourCompany, elements.partyB));
|
|
544
|
-
addSelect('ourCompany', company, `乙方签约主体映射为下拉选项:${company || '未匹配'}`, buildNeedles(elements.partyB));
|
|
570
|
+
addSelect('ourCompany', optionId('ourCompany', company), `乙方签约主体映射为下拉选项:${company || '未匹配'}`, buildNeedles(elements.partyB));
|
|
545
571
|
// 客户名称 / 最终用户:浏览型字段同样直接填中文全称
|
|
546
572
|
addSelect('finalUser', orElse(elements.finalUser, elements.partyA), '取合同甲方(最终用户)企业全称', buildNeedles(elements.partyA));
|
|
547
573
|
// 合同相关伙伴:有丙方/伙伴时填中文全称(写文本备份字段,浏览字段只读)
|
|
@@ -557,17 +583,17 @@ export function buildGeneric({ triage, fileId, flow, lines, sourceMap, fileIds }
|
|
|
557
583
|
else
|
|
558
584
|
signForm = '纸质签署';
|
|
559
585
|
}
|
|
560
|
-
addSelect('signForm', signForm, '按合同签署章节判定签约形式', ['本合同经甲乙双方盖章后生效', '盖章']);
|
|
586
|
+
addSelect('signForm', optionId('signForm', signForm), '按合同签署章节判定签约形式', ['本合同经甲乙双方盖章后生效', '盖章']);
|
|
561
587
|
// 合同签署日期:载明签订日期则指定,否则默认合同办理当天
|
|
562
588
|
const signDateNeedles = [...(buildNeedles(elements.signDate) ?? []), '签订时间'];
|
|
563
|
-
addSelect('signDateType', orElse(elements.signDateType, pyTruthy(elements.signDate) ? '指定签署日期' : '默认合同办理当天'), '合同载明签订日期则指定,否则默认合同办理当天', signDateNeedles);
|
|
589
|
+
addSelect('signDateType', optionId('signDateType', orElse(elements.signDateType, pyTruthy(elements.signDate) ? '指定签署日期' : '默认合同办理当天')), '合同载明签订日期则指定,否则默认合同办理当天', signDateNeedles);
|
|
564
590
|
// 合同签订方式:合同未约定签署顺序,属全文推导,无原文出处
|
|
565
|
-
addSelect('signWay', orElse(elements.signWay, '我方先盖章'), '合同未特别约定签署顺序,按我方先盖章', null);
|
|
591
|
+
addSelect('signWay', optionId('signWay', orElse(elements.signWay, '我方先盖章')), '合同未特别约定签署顺序,按我方先盖章', null);
|
|
566
592
|
// 其余选项字段只在合同有明确依据时填,无依据留空(不猜)
|
|
567
|
-
addSelect('contractType', elements.contractType, '按合同标的产品线判定合同类型', buildNeedles(elements.contractType));
|
|
568
|
-
addSelect('implParty', elements.implParty, '按合同实施主体判定实施方', buildNeedles(elements.implParty));
|
|
569
|
-
addSelect('relatedProduct', elements.relatedProduct, '按合同标的判定相关产品', buildNeedles(elements.relatedProduct));
|
|
570
|
-
addSelect('isXinChuang', elements.isXinChuang, '合同未涉及信创内容则不填', buildNeedles(elements.isXinChuang));
|
|
593
|
+
addSelect('contractType', optionId('contractType', elements.contractType), '按合同标的产品线判定合同类型', buildNeedles(elements.contractType));
|
|
594
|
+
addSelect('implParty', optionId('implParty', elements.implParty), '按合同实施主体判定实施方', buildNeedles(elements.implParty));
|
|
595
|
+
addSelect('relatedProduct', optionId('relatedProduct', elements.relatedProduct), '按合同标的判定相关产品', buildNeedles(elements.relatedProduct));
|
|
596
|
+
addSelect('isXinChuang', optionId('isXinChuang', elements.isXinChuang), '合同未涉及信创内容则不填', buildNeedles(elements.isXinChuang));
|
|
571
597
|
// ⑦ 合同购买内容(复选框):按正文语义命中勾选,命中不到整条不填
|
|
572
598
|
const checkbox = spec.checkbox;
|
|
573
599
|
if (checkbox) {
|