两件事,都是「图上画着、实际走不到」这一类。 ## ① 审批点后面没有网关(用户提出) A5 只有一条出边 A5→A6,驳回走向藏在 `reject` 声明里,图上只是一枚牌子。 BPMN 的常规是审批的两个去向都由网关决定 —— 补 G3「审批结果」, `verdict = "pass"` → A6,`verdict = "reject"` → A4(回边)。 补的时候撞上真问题:`onApprovalVerdict` 只在 pass 时走 `advanceFrom`, 而且 payload 里**不含 verdict** —— 于是 G3 没有判据可读。异或分叉的每条出边都得带条件、 没有无条件兜底边,判据一缺就全不成立,流会无声停在 G3。 能让闸过的最省事办法是在 `e-a5-g3` 上喂一枚常量 `verdict: "pass"`。**没那么做** —— 那样 G3 的条件恒真、驳回边永不可达,网关就是个摆设,又是一处「画着两个去向、 其中一个结构上走不到」的谎。 改的是引擎:裁决进载荷,通过与驳回**都先看图**,只有没画驳回边的包才退回 `reject` 声明 (它 schema 必填,且是通用机制)。`advanceFrom` 因此回报「有没有真的推出去」, 并加 `quiet` 参数 —— 「先试边、不成再退回声明」这一步试空是正常分支,不是死路, 不该报 route-dead-end 假警。 `reject` 保留:schema 必填、CONTRACT.md 的不变量、且审批人界面拿它渲染人读文案。 它与 `e-g3-a4` 必须字字对齐,加了测试守。 ## ② 几何重排:两带换行,不回形 原坐标逐点抄自 MVP 的 SVG,是回形走线(row 0 左→右、row 1 右→左、row 2 折回最左)—— 这正是上一轮流程链读成 A1→A7→A2 的根源。重排为两带: 受理·选型·寻源(y 60..100)→ 换行车道 y=190 → 定价·审批·议价·成交(y 310..350)→ 未成交闭环(y 410..450)。每带内 x 随推进次序单调递增。 实测渲染(画布 639×325):带 0 的 A1 57→G1 159→A2 223→G2 325→A3 389→G2J 491, 带 1 的 A4 38→A5 153→G3 242→A6 293→G4 395,**零框重叠**。 两枚回 A4 的卡点同一条车道、同朝向(向上=回退)。 ## ③ 顺带:两枚去向旗终于有地方落 上一轮我在债务簿写「A1 过不了 G1 是诚实状态、不是缺陷」——**判断错了**。 出口的标量字段只从落地事实取,而 `needAlternative` / `needSourcing` 在任何台账对象上都没有列,活动实现了也一样取不到。 新增 `project.intake_verdict`「受理结论」**一单一行**(主键只有询价单号)。 为什么不挂在按料号分行的「统一受理记录」上:`flat` 是把这一单所有落地行 reduce 展开, 六个料号就有六行同名列、最后合并的那行赢 —— 而归并规则是「任一条命中 C 即需选型」, last-write-wins 会静默给出错的去向。测试正反两面都守:结论表主键只能是 rfq_ref, 且**其它对象上不许出现去向旗**。 A2 也要回写这一行,所以 `rfqRef` 进了 G1→A2 的边映射,并**正式声明进 A2 的入参**—— 不声明也能偷渡(闭合校验遇到未声明的目标直接跳过),但那是默许不是正当。 A2 的 contract.version 因此升 0.2.0,包版升 0.5.0。 顺手删了一个陈旧草稿 v2:它是我早前测编辑器留下的旧图(14 节点、无 G3), 而种子刚把 v1 用新图重发布 —— 草稿内容比已发布版更旧,谁发布它 G3 就没了。 删前确认零工作流引用。系统没有「丢弃草稿」的入口,这条记进债务簿。 typecheck ✓ lint ✓ depcruise 374 模块 ✓ api:check ✓ 495 测试 ✓ 发布闸实测:15 节点 / 18 边,边映射闭合校验通过。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KeDBx2PHLavbURXB8LJJ7m
200 lines
8.3 KiB
TypeScript
200 lines
8.3 KiB
TypeScript
/**
|
|
* 四域十九对象(docs/MVP示例工作流.html · 动态数据 + 静态底座;定价审批表落审批机制,不入台账)。
|
|
*
|
|
* 划分原则(产品决策,2026-07-27):**流转单据(过程)归 project;沉淀资产按内容归
|
|
* customer / intel / supplier**。声明只写活动**要用**的字段;物化走安装通道的声明合并
|
|
* (最大化合并、只增不破坏),这里不建表 —— 建表是 ledger 的事。
|
|
*/
|
|
import { objectDeclarationSchema } from '@contracts';
|
|
import type { LedgerFieldType, ObjectDeclaration } from '@contracts';
|
|
|
|
const f = (name: string, type: LedgerFieldType, label: string, primaryKey = false) => ({
|
|
name,
|
|
type,
|
|
label,
|
|
primaryKey,
|
|
masked: false,
|
|
});
|
|
|
|
const obj = (domain: string, object: string, label: string, fields: ReturnType<typeof f>[]) =>
|
|
objectDeclarationSchema.parse({ domain, object, label, fields });
|
|
|
|
export const MVP_OBJECTS: readonly ObjectDeclaration[] = [
|
|
/* ── project:每一单的流转单据(位置签 输入/过程/输出) ─────────────── */
|
|
obj('project', 'rfq_file', 'RFQ/BOM文件', [
|
|
f('rfq_ref', 'text', '询价单号', true),
|
|
f('pn', 'text', 'PN', true),
|
|
f('qty_eau', 'text', '数量/EAU'),
|
|
f('brand', 'text', '厂牌'),
|
|
f('analog_flag', 'boolean', 'Analog'),
|
|
f('aec_cert', 'text', 'AEC认证'),
|
|
f('target_price', 'number', '目标价'),
|
|
f('lead_time', 'text', '交期'),
|
|
]),
|
|
obj('project', 'intake_record', '统一受理记录', [
|
|
f('customer_code', 'text', '客户码', true),
|
|
f('pn', 'text', 'PN', true),
|
|
f('brand', 'text', '厂牌'),
|
|
f('eau', 'text', 'EAU'),
|
|
f('type_tag', 'text', 'Type标'),
|
|
f('target_price', 'number', '目标价'),
|
|
f('status', 'text', '状态'),
|
|
]),
|
|
obj('project', 'pn_class', '料号分类表', [
|
|
f('pn', 'text', 'PN', true),
|
|
f('type_tag', 'text', 'Type标'),
|
|
f('basis', 'text', '分级依据'),
|
|
f('history_hit', 'boolean', '历史价命中'),
|
|
f('review_note', 'text', '复核结论'),
|
|
]),
|
|
/*
|
|
* 受理结论 —— **一单一行**(主键只有询价单号),不是一料一行。
|
|
*
|
|
* 它承载 A1 出口的两枚去向旗。为什么必须单独一个对象、不能挂在按料号分行的
|
|
* 「统一受理记录」上:出口载荷的标量字段取自 `landed.flat`,而 `flat` 是把这一单
|
|
* **所有**落地行 reduce 展开成一个平对象(`wiring/engines.ts`)。旗挂在按料号分的行上,
|
|
* 六个料号就有六行同名列,**最后合并的那行赢** —— 而归并规则是「任一条命中 C 即需选型」,
|
|
* last-write-wins 会静默给出错的去向,网关照着错值分叉,没人看得出来。
|
|
*
|
|
* 一单一行就没有这个歧义:G1 / G2 读的是同一行的同一个值。
|
|
* 逐料号的判定仍写「料号分类表」,这里只放归并后的结论。
|
|
*/
|
|
obj('project', 'intake_verdict', '受理结论', [
|
|
f('rfq_ref', 'text', '询价单号', true),
|
|
f('need_alternative', 'boolean', '需选型'),
|
|
f('need_sourcing', 'boolean', '需寻源'),
|
|
f('c_count', 'number', 'C类条数'),
|
|
f('status', 'text', '状态'),
|
|
]),
|
|
obj('project', 'alt_request', '替代评估请求', [
|
|
f('material', 'text', '初选物料', true),
|
|
f('chip_type', 'text', '芯片类型'),
|
|
f('spec_params', 'text', '参数规格'),
|
|
f('scenario', 'text', '应用场景'),
|
|
f('requester', 'text', '需求人'),
|
|
]),
|
|
obj('project', 'inquiry_request', '询价请求', [
|
|
f('pn', 'text', 'PN', true),
|
|
f('brand', 'text', 'Brand'),
|
|
f('era', 'text', 'ERA'),
|
|
f('project_stage', 'text', '项目阶段'),
|
|
f('accept_alt', 'boolean', '接受替代'),
|
|
f('unit_usage', 'text', '单机用量'),
|
|
f('tp', 'number', 'TP'),
|
|
f('scenario', 'text', '场景'),
|
|
]),
|
|
obj('project', 'supplier_floor', '供应商底价表', [
|
|
f('pn', 'text', 'PN', true),
|
|
f('supplier', 'text', '供应商', true),
|
|
f('floor_price', 'number', '底价'),
|
|
f('moq', 'text', 'MOQ'),
|
|
f('lead_time', 'text', '交期'),
|
|
]),
|
|
obj('project', 'alt_benchmark', '替代对标表', [
|
|
f('original_pn', 'text', '原型号', true),
|
|
f('candidate_pn', 'text', '候选型号', true),
|
|
f('alt_grade', 'text', '替代等级'),
|
|
f('param_diff', 'text', '参数差异项'),
|
|
f('diff_risk', 'text', '差异风险'),
|
|
f('mod_eval', 'text', '改动评估'),
|
|
f('verify_advice', 'text', '验证建议'),
|
|
]),
|
|
obj('project', 'sourcing_compare', '寻源比价表', [
|
|
f('pn', 'text', 'PN', true),
|
|
f('supplier', 'text', '供应商', true),
|
|
f('quote_price', 'number', '报价'),
|
|
f('moq', 'text', 'MOQ'),
|
|
f('lead_time', 'text', '交期'),
|
|
f('channel_grade', 'text', '渠道等级'),
|
|
f('condition', 'text', '成色'),
|
|
f('verdict', 'text', '结论'),
|
|
]),
|
|
obj('project', 'quote_draft', '报价草案', [
|
|
f('pn', 'text', 'PN', true),
|
|
f('proposed_price', 'number', '拟报单价'),
|
|
f('margin', 'number', '毛利率'),
|
|
f('deviation', 'number', '偏离度'),
|
|
]),
|
|
obj('project', 'formal_quote', '正式报价单', [
|
|
f('pn', 'text', 'PN', true),
|
|
f('unit_price_cny', 'number', '单价CNY'),
|
|
f('lead_time', 'text', '交期'),
|
|
f('spq', 'text', 'SPQ'),
|
|
f('moq', 'text', 'MOQ'),
|
|
f('trade_terms', 'text', '贸易条款'),
|
|
f('valid_until', 'date', '有效期'),
|
|
]),
|
|
obj('project', 'followup', '跟进提醒', [
|
|
f('quote_no', 'text', '报价单号', true),
|
|
f('customer_code', 'text', '客户'),
|
|
f('d3', 'date', 'D+3'),
|
|
f('d7', 'date', 'D+7'),
|
|
f('reply_status', 'text', '回复状态'),
|
|
]),
|
|
obj('project', 'landing_stats', '报价落地率统计', [
|
|
f('period', 'text', '期', true),
|
|
f('landing_rate', 'number', '落地率'),
|
|
f('type_a_hit', 'number', 'TypeA命中'),
|
|
f('d3_reply_rate', 'number', 'D+3回复率'),
|
|
f('return_rate', 'number', '退回率'),
|
|
]),
|
|
|
|
/* ── customer:客户信息 ────────────────────────────────────────────── */
|
|
obj('customer', 'profile', '客户资料库', [
|
|
f('customer_code', 'text', '客户码', true),
|
|
f('grade', 'text', '客户等级'),
|
|
f('tags', 'text', '画像标签'),
|
|
f('payment_terms', 'text', '付款条款'),
|
|
f('industry', 'text', '行业属性'),
|
|
f('risk_level', 'text', '风险等级'),
|
|
f('annual_purchase', 'number', '年采购额'),
|
|
]),
|
|
|
|
/* ── intel:市场与销售情报 ─────────────────────────────────────────── */
|
|
obj('intel', 'history_price', '历史价格情报', [
|
|
f('pn', 'text', 'PN', true),
|
|
f('quoted_at', 'timestamp', '报价日期', true),
|
|
f('brand', 'text', '厂牌'),
|
|
f('unit_price_cny', 'number', '单价CNY'),
|
|
f('lead_time', 'text', '交期'),
|
|
f('moq', 'text', 'MOQ'),
|
|
f('valid_until', 'date', '有效期'),
|
|
]),
|
|
obj('intel', 'chip_spec', '芯片规格书', [
|
|
f('pn', 'text', 'PN', true),
|
|
f('key_params', 'text', '关键参数'),
|
|
f('package', 'text', '封装'),
|
|
f('version_date', 'date', '版本日期'),
|
|
]),
|
|
obj('intel', 'public_select', '公网选型库', [
|
|
f('alt_relation', 'text', '替代关系', true),
|
|
f('param_compare', 'text', '参数对比'),
|
|
f('spec_ref', 'text', '规格书'),
|
|
f('lifecycle', 'text', '生命周期'),
|
|
f('price_ref', 'text', '价格参考'),
|
|
]),
|
|
|
|
/* ── supplier:供应商信息 ─────────────────────────────────────────── */
|
|
obj('supplier', 'channel_dir', '供应商渠道目录', [
|
|
f('supplier', 'text', '供应商', true),
|
|
f('channel_type', 'text', '渠道类型'),
|
|
f('brand_lines', 'text', '品牌线'),
|
|
f('contact', 'text', '联系人'),
|
|
]),
|
|
obj('supplier', 'dead_stock', '呆滞库存表', [
|
|
f('pn', 'text', 'PN', true),
|
|
f('stock_qty', 'number', '库存量'),
|
|
f('stock_age', 'text', '库龄'),
|
|
f('cost_price', 'number', '成本价'),
|
|
]),
|
|
];
|
|
|
|
export function declarationsFor(objects: readonly `${string}.${string}`[]): ObjectDeclaration[] {
|
|
return objects.map((key) => {
|
|
const [domain, object] = key.split('.');
|
|
const hit = MVP_OBJECTS.find((o) => o.domain === domain && o.object === object);
|
|
if (hit === undefined) throw new Error(`未知对象:${key} —— 先在 MVP_OBJECTS 登记`);
|
|
return hit;
|
|
});
|
|
}
|