# -*- coding: utf-8 -*- """F-01 修正:推送/查重规则 4 份 .bru 的 pushConfig/wizardConfig 入参文档 由「整体 JSON 串」改为实现的嵌套索引属性路径绑定(e2e 已验证的契约)。 铁律:结构听源码(Spring indexed property binding);表述对齐 e2e 实证。 """ import io, sys sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') BASE = r"D:\code\crm-api-docs\A7 后台管理\业务规则\商机规则" def patch(path, reps): t = open(path, encoding='utf-8').read() for old, new in reps: assert old in t, f"ANCHOR MISSING in {path}: {old[:60]!r}" t = t.replace(old, new, 1) open(path, 'w', encoding='utf-8', newline='\n').write(t) print("patched:", path) BIND_NOTE = " pushConfig 采用 Spring 嵌套索引属性路径表单字段提交(不支持整体 JSON 串提交);步骤结构总览见详情接口回显。\n" # ---------- 方案推送规则 · 保存草稿 ---------- patch(BASE + r"\方案推送规则\保存推送规则草稿.bru", [ (''' pushConfig: {"basic":{"pushNodeName":"方案卡确认","schemeTemplateId":"747831302652166144"},"fieldValidations":[],"fieldMappings":[],"projectCreation":{"createMode":"auto","nameRule":"{客户名称}-{方案名称}"}}''', ''' pushConfig.basic.pushNodeName: 方案卡确认 pushConfig.basic.schemeTemplateId: 747831302652166144 pushConfig.projectCreation.createMode: auto pushConfig.projectCreation.nameRule: {客户名称}-{方案名称}'''), (''' | pushConfig | string(json) | 否 | - | 推送配置 4 步骤整体 JSON(结构见详情接口) |''', ''' | pushConfig.basic.pushNodeName | string | 否 | - | 步骤①推送节点名称(发布必配) | | pushConfig.basic.schemeTemplateId | string | 发布时必配 | - | 步骤①方案卡模板版本行 ID(锁定版本;版本行不存在发布被拒 64030) | | pushConfig.fieldValidations[n].* | string | 否 | - | 步骤②字段校验行:fieldName/fieldSource/fieldType/validateRule/failAction(按 [n] 索引) | | pushConfig.fieldMappings[n].* | string | 否 | - | 步骤③字段映射行:fieldName/targetField/pushMode(按 [n] 索引) | | pushConfig.projectCreation.createMode | string | 否 | - | 步骤④创建方式:auto/interactive/existing(值域外 64030) | | pushConfig.projectCreation.dedupRuleId | string | 否 | - | 步骤④项目重复规则版本行 ID(须为发布中版本,草稿不可被正式引用 64030) | | pushConfig.projectCreation.nameRule | string | 否 | - | 步骤④项目名称规则 |'''), (''' ruleName=投标阶段方案推送&applyScope=1&isDefault=0&ruleDesc=全部商机默认推送规则&pushConfig=%7B...%7D''', ''' ruleName=投标阶段方案推送&applyScope=1&isDefault=0&ruleDesc=全部商机默认推送规则&pushConfig.basic.pushNodeName=方案卡确认&pushConfig.basic.schemeTemplateId=747831302652166144&pushConfig.projectCreation.createMode=auto'''), (''' 保存草稿(新建/原位编辑草稿/从发布中停用生成新草稿;推送配置整体保存)。''', ''' 保存草稿(新建/原位编辑草稿/从发布中停用生成新草稿;推送配置整体保存)。 ''' + BIND_NOTE), ]) # ---------- 方案推送规则 · 发布 ---------- patch(BASE + r"\方案推送规则\发布推送规则.bru", [ (''' pushConfig: {"basic":{"pushNodeName":"方案卡确认","schemeTemplateId":"747831302652166144"},"fieldValidations":[],"fieldMappings":[],"projectCreation":{"createMode":"auto","dedupRuleId":"8101","nameRule":"{客户名称}-{方案名称}"}}''', ''' pushConfig.basic.pushNodeName: 方案卡确认 pushConfig.basic.schemeTemplateId: 747831302652166144 pushConfig.projectCreation.createMode: auto pushConfig.projectCreation.nameRule: {客户名称}-{方案名称}'''), (''' | pushConfig | string(json) | 是 | - | 推送配置 4 步骤整体 JSON(发布校验步骤①必配+引用有效) |''', ''' | pushConfig.basic.pushNodeName | string | 是 | - | 步骤①推送节点名称(未配 64030) | | pushConfig.basic.schemeTemplateId | string | 是 | - | 步骤①方案卡模板版本行 ID(锁定版本;不存在 64030) | | pushConfig.fieldValidations[n].* | string | 否 | - | 步骤②字段校验行:fieldName/fieldSource/fieldType/validateRule/failAction(按 [n] 索引) | | pushConfig.fieldMappings[n].* | string | 否 | - | 步骤③字段映射行:fieldName/targetField/pushMode(按 [n] 索引) | | pushConfig.projectCreation.createMode | string | 否 | - | 步骤④创建方式:auto/interactive/existing(值域外 64030) | | pushConfig.projectCreation.dedupRuleId | string | 否 | - | 步骤④项目重复规则版本行 ID(须为发布中版本,草稿不可被正式引用 64030) | | pushConfig.projectCreation.nameRule | string | 否 | - | 步骤④项目名称规则 |'''), (''' id=8001&ruleName=投标阶段方案推送&applyScope=1&isDefault=1&pushConfig=%7B...%7D''', ''' id=8001&ruleName=投标阶段方案推送&applyScope=1&isDefault=1&pushConfig.basic.pushNodeName=方案卡确认&pushConfig.basic.schemeTemplateId=747831302652166144&pushConfig.projectCreation.createMode=auto'''), (''' 保存并发布(推送配置完整+方案卡模板引用有效+同名称发布中唯一;原发布中转停用)。''', ''' 保存并发布(推送配置完整+方案卡模板引用有效+同名称发布中唯一;原发布中转停用)。 ''' + BIND_NOTE), ]) DEDUP_BIND_NOTE = " wizardConfig 采用 Spring 嵌套索引属性路径表单字段提交(不支持整体 JSON 串提交);步骤结构总览见详情接口回显。\n" # ---------- 项目查重规则 · 保存草稿 ---------- patch(BASE + r"\项目查重规则\保存查重规则草稿.bru", [ (''' wizardConfig: {"triggerScenarios":["OPP_TO_PROJECT"],"projectStatuses":["进行中"],"searchConditions":[{"field":"项目名称","source":"商机","matchMode":"SIMILAR","threshold":80}],"analysisRules":[],"strategies":{"intercept":["明确重复"],"confirm":["疑似重复"],"normal":["无明显冲突"]}}''', ''' wizardConfig.triggerScenarios[0]: OPP_TO_PROJECT wizardConfig.searchConditions[0].field: 项目名称 wizardConfig.searchConditions[0].source: 商机 wizardConfig.searchConditions[0].matchMode: SIMILAR wizardConfig.searchConditions[0].threshold: 80 wizardConfig.strategies.intercept[0]: 明确重复'''), (''' | wizardConfig | string(json) | 否 | - | 4 步骤向导配置整体 JSON(结构见详情接口) |''', ''' | wizardConfig.triggerScenarios[n] | string | 否 | - | 步骤①触发场景多选:OPP_TO_PROJECT/DIRECT_CREATE | | wizardConfig.projectStatuses[n] | string | 否 | - | 步骤①参与检测项目状态多选 | | wizardConfig.searchConditions[n].* | string | 否 | - | 步骤②关联项目检索行:field/source/matchMode(EXACT|SIMILAR)/threshold(按 [n] 索引) | | wizardConfig.analysisRules[n].* | string | 否 | - | 步骤③异常关系分析行:seq/expression(嵌套 JSON 串)/conclusion(按 [n] 索引) | | wizardConfig.strategies.{intercept|confirm|normal}[n] | string | 否 | - | 步骤④处理策略适用的研判结论列表 |'''), (''' ruleName=全商机默认查重&applyScopeType=1&isDefault=1&ruleDesc=全部商机默认查重规则&wizardConfig=%7B...%7D''', ''' ruleName=全商机默认查重&applyScopeType=1&isDefault=1&ruleDesc=全部商机默认查重规则&wizardConfig.triggerScenarios[0]=OPP_TO_PROJECT&wizardConfig.searchConditions[0].field=项目名称&wizardConfig.searchConditions[0].matchMode=SIMILAR'''), (''' 保存草稿(新建/原位编辑草稿/从发布中停用生成新草稿;向导配置整体保存)。''', ''' 保存草稿(新建/原位编辑草稿/从发布中停用生成新草稿;向导配置整体保存)。 ''' + DEDUP_BIND_NOTE), ]) # ---------- 项目查重规则 · 发布 ---------- patch(BASE + r"\项目查重规则\发布查重规则.bru", [ (''' wizardConfig: {"triggerScenarios":["OPP_TO_PROJECT","DIRECT_CREATE"],"projectStatuses":["进行中","已中止暂停","已关闭","已结项"],"searchConditions":[{"field":"项目名称","source":"商机","matchMode":"SIMILAR","threshold":80},{"field":"甲方","source":"客户","matchMode":"EXACT","threshold":null}],"analysisRules":[{"seq":1,"expression":"{\\"op\\":\\"AND\\",\\"children\\":[]}","conclusion":"明确重复"}],"strategies":{"intercept":["明确重复"],"confirm":["疑似重复","同商机多客户"],"normal":["一般风险标签提醒","无明显冲突"]}}''', ''' wizardConfig.triggerScenarios[0]: OPP_TO_PROJECT wizardConfig.projectStatuses[0]: 进行中 wizardConfig.searchConditions[0].field: 项目名称 wizardConfig.searchConditions[0].matchMode: SIMILAR wizardConfig.searchConditions[0].threshold: 80 wizardConfig.analysisRules[0].seq: 1 wizardConfig.analysisRules[0].conclusion: 明确重复 wizardConfig.strategies.intercept[0]: 明确重复'''), (''' | wizardConfig | string(json) | 是 | - | 4 步骤向导配置整体 JSON(结构见详情接口) |''', ''' | wizardConfig.triggerScenarios[n] | string | 否 | - | 步骤①触发场景多选:OPP_TO_PROJECT/DIRECT_CREATE | | wizardConfig.projectStatuses[n] | string | 否 | - | 步骤①参与检测项目状态多选 | | wizardConfig.searchConditions[n].* | string | 否 | - | 步骤②关联项目检索行:field/source/matchMode(EXACT|SIMILAR)/threshold(按 [n] 索引) | | wizardConfig.analysisRules[n].* | string | 否 | - | 步骤③异常关系分析行:seq/expression(嵌套 JSON 串)/conclusion(按 [n] 索引) | | wizardConfig.strategies.{intercept|confirm|normal}[n] | string | 否 | - | 步骤④处理策略适用的研判结论列表 |'''), (''' id=8101&ruleName=全商机默认查重&applyScopeType=1&isDefault=1&wizardConfig=%7B...%7D''', ''' id=8101&ruleName=全商机默认查重&applyScopeType=1&isDefault=1&wizardConfig.triggerScenarios[0]=OPP_TO_PROJECT&wizardConfig.searchConditions[0].field=项目名称&wizardConfig.searchConditions[0].matchMode=SIMILAR'''), (''' 保存并发布(原发布中转停用、仅全部商机档默认顶替)。''', ''' 保存并发布(原发布中转停用、仅全部商机档默认顶替)。 ''' + DEDUP_BIND_NOTE), ]) print("ALL 4 FILES PATCHED")