feat: init ai-platform - 源码 + 配置

This commit is contained in:
2026-08-25 16:27:43 +08:00
commit 83210a606a
122 changed files with 27401 additions and 0 deletions
@@ -0,0 +1,530 @@
// 雷勃动力传动(漳州)有限公司 — 轴承订单盈利能力分析数据模型
export type OrderStatus = 'open' | 'closed' | 'production' | 'shipped';
export type Channel = '外销-B2B' | '外销-B2C' | '内销-直销' | '内销-代理' | '电商平台';
export type RiskLevel = 'normal' | 'warning' | 'danger';
export type DeliveryPriority = 'urgent' | 'high' | 'normal' | 'low';
/** 客户名称脱敏:前两个字符替换为 **,保留剩余字符 */
export function maskCustomerName(name: string): string {
if (!name || name.length <= 2) return '**';
return '**' + name.slice(2);
}
export interface CostDetail {
// 直接材料
fabric: number; // 钢材
accessories: number; // 配件(保持架/密封件)
// 直接人工
labor: number;
// 其他费用(制造费用)
overhead: number;
}
export interface CostRow {
type: '原材料成本' | '直接人工成本' | '管理成本';
qty: number;
unitPrice: number;
revenue: number; // 销售收入(含税)
directMaterial: number; // 直接材料
directLabor: number; // 直接人工
manufacturingCost: number; // 制造费用
totalCost: number; // 制造成本合计
grossProfit: number; // 毛利
grossMargin: number; // 毛利率 (小数)
mgmtExpense: number; // 管理销研费用
netProfit: number; // 净利润
netMargin: number; // 净利率 (小数)
detail: CostDetail;
}
export interface QuoteCostItem {
name: string;
quotedPrice: number; // 报价成本单价
quantity: number;
totalCost: number;
percentage: number; // 占报价比例
}
export interface CostSubItem {
label: string;
stdCost: number;
stdPct: number;
purchaseCost: number;
purchasePct: number;
usageCost: number;
usagePct: number;
purchaseVsStdAmt: number;
purchaseVsStdPct: number;
usageVsStdAmt: number;
usageVsStdPct: number;
}
export interface CostBreakdown {
category: string;
items: CostSubItem[];
}
export interface ProductionStep {
name: string;
cost: number; // 工序成本(元)
duration: number; // 耗时(小时)
defectRate: number; // 不良率(小数)
hasIssue: boolean; // 是否存在工艺问题
issueDesc?: string; // 问题描述
}
export interface ProductionLine {
id: string;
name: string;
equipment: string; // 自动线/半自动线/混合设备
totalCost: number;
totalHours: number;
yieldRate: number; // 综合良率(小数)
steps: ProductionStep[];
}
export interface Order {
id: string;
orderNo: string; // 制造令号
customer: string; // 客户
salesperson: string; // 业务员
channel: Channel;
closedDate: string; // 结单日期
productCategory: string; // 品类
status: OrderStatus;
riskLevel: RiskLevel;
deliveryPriority: DeliveryPriority;
region: string;
rows: CostRow[]; // 原材料成本/直接人工成本/管理成本三行
costBreakdown: CostBreakdown[]; // 成本明细附表
quoteCostItems?: QuoteCostItem[]; // 与客户报价成本细项对比
productionLines?: ProductionLine[]; // 生产线成本对比
tags: string[];
submittedAt: string;
note?: string;
}
// ── 默认生产线数据 ────────────────────────────────────────────────────────────
const DEFAULT_PRODUCTION_LINES: ProductionLine[] = [
{ id: 'A', name: 'A线', equipment: '自动线', totalCost: 108500, totalHours: 52.5, yieldRate: 0.970,
steps: [
{ name: '下料', cost: 35000, duration: 8, defectRate: 0.003, hasIssue: false },
{ name: '车加工', cost: 22000, duration: 10, defectRate: 0.005, hasIssue: false },
{ name: '热处理', cost: 15000, duration: 6, defectRate: 0.012, hasIssue: true, issueDesc: '温控偶有偏差±2℃' },
{ name: '磨加工', cost: 18000, duration: 12, defectRate: 0.006, hasIssue: false },
{ name: '装配', cost: 12000, duration: 10, defectRate: 0.004, hasIssue: false },
{ name: '检验', cost: 6500, duration: 6.5, defectRate: 0, hasIssue: false },
]},
{ id: 'B', name: 'B线', equipment: '半自动线', totalCost: 136000, totalHours: 72, yieldRate: 0.872,
steps: [
{ name: '下料', cost: 38000, duration: 12, defectRate: 0.008, hasIssue: false },
{ name: '车加工', cost: 28000, duration: 14, defectRate: 0.015, hasIssue: true, issueDesc: '主轴跳动超标,刀具磨损快' },
{ name: '热处理', cost: 22000, duration: 8, defectRate: 0.042, hasIssue: true, issueDesc: '温控老化,硬度不均匀' },
{ name: '磨加工', cost: 24000, duration: 16, defectRate: 0.038, hasIssue: true, issueDesc: '砂轮磨损快,精度不稳定' },
{ name: '装配', cost: 15000, duration: 14, defectRate: 0.032, hasIssue: true, issueDesc: '工装松动,配合间隙偏大' },
{ name: '检验', cost: 9000, duration: 8, defectRate: 0, hasIssue: false },
]},
{ id: 'C', name: 'C线', equipment: '混合设备', totalCost: 118200, totalHours: 62, yieldRate: 0.934,
steps: [
{ name: '下料', cost: 36000, duration: 10, defectRate: 0.005, hasIssue: false },
{ name: '车加工', cost: 24000, duration: 12, defectRate: 0.008, hasIssue: false },
{ name: '热处理', cost: 18000, duration: 7, defectRate: 0.018, hasIssue: false },
{ name: '磨加工', cost: 20000, duration: 14, defectRate: 0.025, hasIssue: true, issueDesc: '老磨床精度偏低' },
{ name: '装配', cost: 13000, duration: 12, defectRate: 0.012, hasIssue: false },
{ name: '检验', cost: 7200, duration: 7, defectRate: 0, hasIssue: false },
]},
];
// ── 订单生成器(轴承产品) ──────────────────────────────────────────────────────
function genOrder(p: {
id: string; orderNo: string; customer: string; salesperson: string;
channel: Channel; closedDate: string; productCategory: string;
status: OrderStatus; riskLevel: RiskLevel; deliveryPriority?: DeliveryPriority; region: string;
tags: string[]; submittedAt: string; note?: string;
qty: number; unitPrice: number;
stdMat: number; stdLabor: number; stdOH: number;
purMatAdj: number; useMatAdj: number; useLaborAdj: number;
mgmt: number; matSplit?: [number, number];
}): Order {
const revenue = Math.round(p.qty * p.unitPrice);
const sp = p.matSplit || [0.7, 0.3];
const mkRow = (type: '原材料成本'|'直接人工成本'|'管理成本', matA: number, labA: number): CostRow => {
const dm = Math.round(p.stdMat * (1 + matA));
const dl = Math.round(p.stdLabor * (1 + labA));
const mc = p.stdOH; const tc = dm + dl + mc;
const gp = revenue - tc; const gm = revenue > 0 ? gp / revenue : 0;
const np = gp - p.mgmt; const nm = revenue > 0 ? np / revenue : 0;
return { type, qty: p.qty, unitPrice: p.unitPrice, revenue, directMaterial: dm, directLabor: dl,
manufacturingCost: mc, totalCost: tc, grossProfit: gp, grossMargin: +gm.toFixed(4),
mgmtExpense: p.mgmt, netProfit: np, netMargin: +nm.toFixed(4),
detail: { fabric: Math.round(dm * sp[0]), accessories: Math.round(dm * sp[1]), labor: dl, overhead: mc } };
};
const std = mkRow('原材料成本', 0, 0);
const pur = mkRow('直接人工成本', p.purMatAdj, 0);
const use = mkRow('管理成本', p.useMatAdj, p.useLaborAdj);
const bd = (_r: CostRow): CostBreakdown[] => makeBearingBreakdown(std, pur, use, revenue, p.stdOH);
return { ...p, deliveryPriority: p.deliveryPriority || 'normal', rows: [std, pur, use], costBreakdown: bd(std), productionLines: DEFAULT_PRODUCTION_LINES };
}
// ── 轴承组件成本明细生成器 ──────────────────────────────────────────────────
const BEARING_COMP = [
{ label: '外圈', pct: 0.2076 }, { label: '内圈', pct: 0.1648 },
{ label: '滚针', pct: 0.4712 }, { label: '保持器', pct: 0.0617 },
{ label: '挡圈', pct: 0.0461 }, { label: '密封', pct: 0.0383 },
{ label: '油塞', pct: 0.0103 },
];
function makeBearingBreakdown(std: CostRow, pur: CostRow, use: CostRow, revenue: number, stdOH: number): CostBreakdown[] {
const mkItem = (label: string, pct: number) => {
const s = Math.round(std.directMaterial * pct);
const p = Math.round(pur.directMaterial * pct);
const u = Math.round(use.directMaterial * pct);
return { label, stdCost: s, stdPct: s / revenue, purchaseCost: p, purchasePct: p / revenue,
usageCost: u, usagePct: u / revenue,
purchaseVsStdAmt: p - s, purchaseVsStdPct: s ? (p - s) / s : 0,
usageVsStdAmt: u - s, usageVsStdPct: s ? (u - s) / s : 0 };
};
return [
{ category: '原材料', items: BEARING_COMP.map(c => mkItem(c.label, c.pct)) },
{ category: '直接人工', items: [
{ label: '人工', stdCost: std.directLabor, stdPct: std.directLabor / revenue,
purchaseCost: pur.directLabor, purchasePct: pur.directLabor / revenue,
usageCost: use.directLabor, usagePct: use.directLabor / revenue,
purchaseVsStdAmt: 0, purchaseVsStdPct: 0,
usageVsStdAmt: use.directLabor - std.directLabor, usageVsStdPct: std.directLabor ? (use.directLabor - std.directLabor) / std.directLabor : 0 },
]},
{ category: '其他费用', items: [
{ label: '费用', stdCost: stdOH, stdPct: 0, purchaseCost: stdOH, purchasePct: 0,
usageCost: stdOH, usagePct: 0, purchaseVsStdAmt: 0, purchaseVsStdPct: 0, usageVsStdAmt: 0, usageVsStdPct: 0 },
]},
];
}
// ── 订单数据 ──────────────────────────────────────────────────────────────────
export const ORDERS: Order[] = [
// ── ORD001: 三一重工 — 深沟球轴承 6205-2RS ──────────────────────────────
{
id: 'ORD001', orderNo: 'RB-ZZ-260315001', customer: '三一重工', salesperson: '林志强',
channel: '内销-直销', closedDate: '2026-04-20', productCategory: '深沟球轴承',
status: 'closed', riskLevel: 'normal', deliveryPriority: 'normal', region: '华东区',
tags: ['标准品', '战略客户', '成本稳定'], submittedAt: '2026-06-10',
rows: [
{ type: '原材料成本', qty: 5000, unitPrice: 85.67, revenue: 428350,
directMaterial: 243000, directLabor: 72000, manufacturingCost: 54000, totalCost: 369000,
grossProfit: 59350, grossMargin: 0.1386,
mgmtExpense: 42835, netProfit: 16515, netMargin: 0.0386,
detail: { fabric: 170100, accessories: 72900, labor: 72000, overhead: 54000 } },
{ type: '直接人工成本', qty: 5000, unitPrice: 85.67, revenue: 428350,
directMaterial: 252720, directLabor: 72000, manufacturingCost: 54000, totalCost: 378720,
grossProfit: 49630, grossMargin: 0.1159,
mgmtExpense: 42835, netProfit: 6795, netMargin: 0.0159,
detail: { fabric: 176904, accessories: 75816, labor: 72000, overhead: 54000 } },
{ type: '管理成本', qty: 5000, unitPrice: 85.67, revenue: 428350,
directMaterial: 236880, directLabor: 61200, manufacturingCost: 54000, totalCost: 352080,
grossProfit: 76270, grossMargin: 0.1781,
mgmtExpense: 42835, netProfit: 33435, netMargin: 0.0781,
detail: { fabric: 165816, accessories: 71064, labor: 61200, overhead: 54000 } },
],
costBreakdown: [
{ category: '原材料', items: [
{ label: '外圈', stdCost: 50450, stdPct: 0.1178, purchaseCost: 52465, purchasePct: 0.1225,
usageCost: 49190, usagePct: 0.1148, purchaseVsStdAmt: 2015, purchaseVsStdPct: 0.0400,
usageVsStdAmt: -1260, usageVsStdPct: -0.0250 },
{ label: '内圈', stdCost: 40050, stdPct: 0.0935, purchaseCost: 41648, purchasePct: 0.0972,
usageCost: 39058, usagePct: 0.0912, purchaseVsStdAmt: 1598, purchaseVsStdPct: 0.0399,
usageVsStdAmt: -992, usageVsStdPct: -0.0248 },
{ label: '滚针', stdCost: 114500, stdPct: 0.2673, purchaseCost: 119085, purchasePct: 0.2780,
usageCost: 111584, usagePct: 0.2604, purchaseVsStdAmt: 4585, purchaseVsStdPct: 0.0401,
usageVsStdAmt: -2916, usageVsStdPct: -0.0255 },
{ label: '保持器', stdCost: 15000, stdPct: 0.0350, purchaseCost: 15593, purchasePct: 0.0364,
usageCost: 14616, usagePct: 0.0341, purchaseVsStdAmt: 593, purchaseVsStdPct: 0.0395,
usageVsStdAmt: -384, usageVsStdPct: -0.0256 },
{ label: '挡圈', stdCost: 11200, stdPct: 0.0261, purchaseCost: 11650, purchasePct: 0.0272,
usageCost: 10920, usagePct: 0.0255, purchaseVsStdAmt: 450, purchaseVsStdPct: 0.0402,
usageVsStdAmt: -280, usageVsStdPct: -0.0250 },
{ label: '密封', stdCost: 9300, stdPct: 0.0217, purchaseCost: 9679, purchasePct: 0.0226,
usageCost: 9072, usagePct: 0.0212, purchaseVsStdAmt: 379, purchaseVsStdPct: 0.0408,
usageVsStdAmt: -228, usageVsStdPct: -0.0245 },
{ label: '油塞', stdCost: 2500, stdPct: 0.0058, purchaseCost: 2600, purchasePct: 0.0061,
usageCost: 2440, usagePct: 0.0057, purchaseVsStdAmt: 100, purchaseVsStdPct: 0.0400,
usageVsStdAmt: -60, usageVsStdPct: -0.0240 },
]},
{ category: '直接人工', items: [
{ label: '人工', stdCost: 72000, stdPct: 0.1681, purchaseCost: 72000, purchasePct: 0.1681,
usageCost: 61200, usagePct: 0.1429, purchaseVsStdAmt: 0, purchaseVsStdPct: 0,
usageVsStdAmt: -10800, usageVsStdPct: -0.1500 },
]},
{ category: '其他费用', items: [
{ label: '费用', stdCost: 54000, stdPct: 0.1261, purchaseCost: 54000, purchasePct: 0.1261,
usageCost: 54000, usagePct: 0.1261, purchaseVsStdAmt: 0, purchaseVsStdPct: 0, usageVsStdAmt: 0, usageVsStdPct: 0 },
]},
],
quoteCostItems: [
{ name: '外圈', quotedPrice: 10.09, quantity: 5000, totalCost: 50450, percentage: 0.2076 },
{ name: '内圈', quotedPrice: 8.01, quantity: 5000, totalCost: 40050, percentage: 0.1648 },
{ name: '滚针', quotedPrice: 1.43125, quantity: 80000, totalCost: 114500, percentage: 0.4712 },
{ name: '保持器', quotedPrice: 3.00, quantity: 5000, totalCost: 15000, percentage: 0.0617 },
{ name: '挡圈', quotedPrice: 1.12, quantity: 10000, totalCost: 11200, percentage: 0.0461 },
{ name: '密封', quotedPrice: 0.93, quantity: 10000, totalCost: 9300, percentage: 0.0383 },
{ name: '油塞', quotedPrice: 0.25, quantity: 10000, totalCost: 2500, percentage: 0.0103 },
{ name: '人工', quotedPrice: 14.4, quantity: 5000, totalCost: 72000, percentage: 0.1681 },
{ name: '制造费用', quotedPrice: 10.8, quantity: 5000, totalCost: 54000, percentage: 0.1261 },
],
note: '钢材直接人工成本高于标准4%,但领用环节人工节省10800元(15%),整体管理成本最优。建议优化采购渠道降低钢材溢价。',
productionLines: DEFAULT_PRODUCTION_LINES,
},
// ── ORD002: 徐工集团 — 圆锥滚子轴承 32210 ──────────────────────────────
{
id: 'ORD002', orderNo: 'RB-ZZ-260402002', customer: '徐工集团', salesperson: '林志强',
channel: '内销-直销', closedDate: '2026-05-10', productCategory: '圆锥滚子轴承',
status: 'closed', riskLevel: 'warning', deliveryPriority: 'high', region: '华东区',
tags: ['工程机械', '领用超标', '成本偏差'], submittedAt: '2026-06-09',
rows: [
{ type: '原材料成本', qty: 3500, unitPrice: 385.0, revenue: 1347500,
directMaterial: 756000, directLabor: 231000, manufacturingCost: 168000, totalCost: 1155000,
grossProfit: 192500, grossMargin: 0.1429,
mgmtExpense: 134750, netProfit: 57750, netMargin: 0.0429,
detail: { fabric: 529200, accessories: 226800, labor: 231000, overhead: 168000 } },
{ type: '直接人工成本', qty: 3500, unitPrice: 385.0, revenue: 1347500,
directMaterial: 793800, directLabor: 231000, manufacturingCost: 168000, totalCost: 1192800,
grossProfit: 154700, grossMargin: 0.1148,
mgmtExpense: 134750, netProfit: 19950, netMargin: 0.0148,
detail: { fabric: 555660, accessories: 238140, labor: 231000, overhead: 168000 } },
{ type: '管理成本', qty: 3500, unitPrice: 385.0, revenue: 1347500,
directMaterial: 816480, directLabor: 266400, manufacturingCost: 168000, totalCost: 1250880,
grossProfit: 96620, grossMargin: 0.0717,
mgmtExpense: 134750, netProfit: -38130, netMargin: -0.0283,
detail: { fabric: 571536, accessories: 244944, labor: 266400, overhead: 168000 } },
],
costBreakdown: makeBearingBreakdown(
{ directMaterial: 756000, directLabor: 231000 } as CostRow,
{ directMaterial: 793800, directLabor: 231000 } as CostRow,
{ directMaterial: 816480, directLabor: 266400 } as CostRow,
1347500, 168000),
note: '管理成本严重超标:材料超8%、人工超15%,导致领用口径净亏损38130元。需重点核查生产损耗率与工时记录。',
productionLines: DEFAULT_PRODUCTION_LINES,
},
// ── ORD003: Siemens AG — 角接触球轴承 7208B ────────────────────────────
{
id: 'ORD003', orderNo: 'RB-ZZ-260228003', customer: 'Siemens AG', salesperson: '黄海燕',
channel: '外销-B2B', closedDate: '2026-04-05', productCategory: '角接触球轴承',
status: 'shipped', riskLevel: 'normal', deliveryPriority: 'normal', region: '欧洲区',
tags: ['精密轴承', '外销欧洲', '毛利偏薄'], submittedAt: '2026-06-08',
rows: [
{ type: '原材料成本', qty: 8000, unitPrice: 255.54, revenue: 2044320,
directMaterial: 1134000, directLabor: 367200, manufacturingCost: 275400, totalCost: 1776600,
grossProfit: 267720, grossMargin: 0.1310,
mgmtExpense: 204432, netProfit: 63288, netMargin: 0.0310,
detail: { fabric: 793800, accessories: 340200, labor: 367200, overhead: 275400 } },
{ type: '直接人工成本', qty: 8000, unitPrice: 255.54, revenue: 2044320,
directMaterial: 1095480, directLabor: 367200, manufacturingCost: 275400, totalCost: 1738080,
grossProfit: 306240, grossMargin: 0.1498,
mgmtExpense: 204432, netProfit: 101808, netMargin: 0.0498,
detail: { fabric: 766836, accessories: 328644, labor: 367200, overhead: 275400 } },
{ type: '管理成本', qty: 8000, unitPrice: 255.54, revenue: 2044320,
directMaterial: 1145340, directLabor: 356040, manufacturingCost: 275400, totalCost: 1776780,
grossProfit: 267540, grossMargin: 0.1309,
mgmtExpense: 204432, netProfit: 63108, netMargin: 0.0309,
detail: { fabric: 801738, accessories: 343602, labor: 356040, overhead: 275400 } },
],
costBreakdown: makeBearingBreakdown(
{ directMaterial: 1134000, directLabor: 367200 } as CostRow,
{ directMaterial: 1095480, directLabor: 367200 } as CostRow,
{ directMaterial: 1145340, directLabor: 356040 } as CostRow,
2044320, 275400),
productionLines: DEFAULT_PRODUCTION_LINES,
},
// ── ORD004: ABB Robotics — 精密轴承套装 ────────────────────────────────
{
id: 'ORD004', orderNo: 'RB-ZZ-260310004', customer: 'ABB Robotics', salesperson: '黄海燕',
channel: '外销-B2B', closedDate: '2026-04-18', productCategory: '精密轴承套装',
status: 'closed', riskLevel: 'normal', deliveryPriority: 'low', region: '欧洲区',
tags: ['精密套装', '高毛利', '成本稳定'], submittedAt: '2026-06-07',
rows: [
{ type: '原材料成本', qty: 3200, unitPrice: 680.0, revenue: 2176000,
directMaterial: 1088000, directLabor: 326400, manufacturingCost: 272000, totalCost: 1686400,
grossProfit: 489600, grossMargin: 0.2250,
mgmtExpense: 217600, netProfit: 272000, netMargin: 0.1250,
detail: { fabric: 761600, accessories: 326400, labor: 326400, overhead: 272000 } },
{ type: '直接人工成本', qty: 3200, unitPrice: 680.0, revenue: 2176000,
directMaterial: 1040160, directLabor: 326400, manufacturingCost: 272000, totalCost: 1638560,
grossProfit: 537440, grossMargin: 0.2470,
mgmtExpense: 217600, netProfit: 319840, netMargin: 0.1470,
detail: { fabric: 728112, accessories: 312048, labor: 326400, overhead: 272000 } },
{ type: '管理成本', qty: 3200, unitPrice: 680.0, revenue: 2176000,
directMaterial: 1121680, directLabor: 316560, manufacturingCost: 272000, totalCost: 1710240,
grossProfit: 465760, grossMargin: 0.2140,
mgmtExpense: 217600, netProfit: 248160, netMargin: 0.1140,
detail: { fabric: 785176, accessories: 336504, labor: 316560, overhead: 272000 } },
],
costBreakdown: makeBearingBreakdown(
{ directMaterial: 1088000, directLabor: 326400 } as CostRow,
{ directMaterial: 1040160, directLabor: 326400 } as CostRow,
{ directMaterial: 1121680, directLabor: 316560 } as CostRow,
2176000, 272000),
productionLines: DEFAULT_PRODUCTION_LINES,
},
// ── ORD005: 海螺水泥 — 调心滚子轴承 22316 ──────────────────────────────
{
id: 'ORD005', orderNo: 'RB-ZZ-260120005', customer: '海螺水泥', salesperson: '林志强',
channel: '内销-代理', closedDate: '2026-03-28', productCategory: '调心滚子轴承',
status: 'closed', riskLevel: 'normal', deliveryPriority: 'low', region: '华南区',
tags: ['重工配套', '高毛利', '代理渠道'], submittedAt: '2026-06-06',
rows: [
{ type: '原材料成本', qty: 2000, unitPrice: 645.0, revenue: 1290000,
directMaterial: 504000, directLabor: 168000, manufacturingCost: 126000, totalCost: 798000,
grossProfit: 492000, grossMargin: 0.3814,
mgmtExpense: 193500, netProfit: 298500, netMargin: 0.2314,
detail: { fabric: 352800, accessories: 151200, labor: 168000, overhead: 126000 } },
{ type: '直接人工成本', qty: 2000, unitPrice: 645.0, revenue: 1290000,
directMaterial: 496440, directLabor: 168000, manufacturingCost: 126000, totalCost: 790440,
grossProfit: 499560, grossMargin: 0.3873,
mgmtExpense: 193500, netProfit: 306060, netMargin: 0.2373,
detail: { fabric: 347508, accessories: 148932, labor: 168000, overhead: 126000 } },
{ type: '管理成本', qty: 2000, unitPrice: 645.0, revenue: 1290000,
directMaterial: 501480, directLabor: 164640, manufacturingCost: 126000, totalCost: 792120,
grossProfit: 497880, grossMargin: 0.3860,
mgmtExpense: 193500, netProfit: 304380, netMargin: 0.2360,
detail: { fabric: 351036, accessories: 150444, labor: 164640, overhead: 126000 } },
],
costBreakdown: makeBearingBreakdown(
{ directMaterial: 504000, directLabor: 168000 } as CostRow,
{ directMaterial: 496440, directLabor: 168000 } as CostRow,
{ directMaterial: 501480, directLabor: 164640 } as CostRow,
1290000, 126000),
productionLines: DEFAULT_PRODUCTION_LINES,
},
// ── ORD006: Thyssenkrupp — 推力滚子轴承 ───────────────────────────────
{
id: 'ORD006', orderNo: 'RB-ZZ-260205006', customer: 'Thyssenkrupp', salesperson: '黄海燕',
channel: '外销-B2B', closedDate: '2026-03-22', productCategory: '推力滚子轴承',
status: 'shipped', riskLevel: 'normal', deliveryPriority: 'normal', region: '欧洲区',
tags: ['重工配套', '外销欧洲', '高毛利'], submittedAt: '2026-06-05',
rows: [
{ type: '原材料成本', qty: 2400, unitPrice: 560.0, revenue: 1344000,
directMaterial: 604800, directLabor: 201600, manufacturingCost: 161280, totalCost: 967680,
grossProfit: 376320, grossMargin: 0.2800,
mgmtExpense: 134400, netProfit: 241920, netMargin: 0.1800,
detail: { fabric: 423360, accessories: 181440, labor: 201600, overhead: 161280 } },
{ type: '直接人工成本', qty: 2400, unitPrice: 560.0, revenue: 1344000,
directMaterial: 583680, directLabor: 201600, manufacturingCost: 161280, totalCost: 946560,
grossProfit: 397440, grossMargin: 0.2957,
mgmtExpense: 134400, netProfit: 263040, netMargin: 0.1957,
detail: { fabric: 408576, accessories: 175104, labor: 201600, overhead: 161280 } },
{ type: '管理成本', qty: 2400, unitPrice: 560.0, revenue: 1344000,
directMaterial: 592800, directLabor: 197568, manufacturingCost: 161280, totalCost: 951648,
grossProfit: 392352, grossMargin: 0.2919,
mgmtExpense: 134400, netProfit: 257952, netMargin: 0.1919,
detail: { fabric: 414960, accessories: 177840, labor: 197568, overhead: 161280 } },
],
costBreakdown: makeBearingBreakdown(
{ directMaterial: 604800, directLabor: 201600 } as CostRow,
{ directMaterial: 583680, directLabor: 201600 } as CostRow,
{ directMaterial: 592800, directLabor: 197568 } as CostRow,
1344000, 161280),
productionLines: DEFAULT_PRODUCTION_LINES,
},
// ── ORD007: Vestas — 风电主轴轴承 ──────────────────────────────────────
{
id: 'ORD007', orderNo: 'RB-ZZ-260115007', customer: 'Vestas', salesperson: '黄海燕',
channel: '外销-B2B', closedDate: '2026-03-10', productCategory: '风电主轴轴承',
status: 'closed', riskLevel: 'warning', deliveryPriority: 'high', region: '欧洲区',
tags: ['风电核心件', '高单价', '毛利监控'], submittedAt: '2026-06-04',
rows: [
{ type: '原材料成本', qty: 600, unitPrice: 3600.0, revenue: 2160000,
directMaterial: 1080000, directLabor: 324000, manufacturingCost: 216000, totalCost: 1620000,
grossProfit: 540000, grossMargin: 0.2500,
mgmtExpense: 324000, netProfit: 216000, netMargin: 0.1000,
detail: { fabric: 756000, accessories: 324000, labor: 324000, overhead: 216000 } },
{ type: '直接人工成本', qty: 600, unitPrice: 3600.0, revenue: 2160000,
directMaterial: 1036800, directLabor: 324000, manufacturingCost: 216000, totalCost: 1576800,
grossProfit: 583200, grossMargin: 0.2700,
mgmtExpense: 324000, netProfit: 259200, netMargin: 0.1200,
detail: { fabric: 725760, accessories: 311040, labor: 324000, overhead: 216000 } },
{ type: '管理成本', qty: 600, unitPrice: 3600.0, revenue: 2160000,
directMaterial: 1112400, directLabor: 333720, manufacturingCost: 216000, totalCost: 1662120,
grossProfit: 497880, grossMargin: 0.2305,
mgmtExpense: 324000, netProfit: 173880, netMargin: 0.0805,
detail: { fabric: 778680, accessories: 333720, labor: 333720, overhead: 216000 } },
],
costBreakdown: makeBearingBreakdown(
{ directMaterial: 1080000, directLabor: 324000 } as CostRow,
{ directMaterial: 1036800, directLabor: 324000 } as CostRow,
{ directMaterial: 1112400, directLabor: 333720 } as CostRow,
2160000, 216000),
note: '风电主轴轴承单价高但材料占比大。采购节省4%但领用超标3%,人工领用也偏高,需关注特种钢材加工损耗。',
productionLines: DEFAULT_PRODUCTION_LINES,
},
// ── ORD008: 中车株洲电机 — 绝缘轴承 ──────────────────────────────────
{
id: 'ORD008', orderNo: 'RB-ZZ-260301008', customer: '中车株洲电机', salesperson: '林志强',
channel: '内销-直销', closedDate: '', productCategory: '绝缘轴承',
status: 'production', riskLevel: 'normal', deliveryPriority: 'urgent', region: '华中区',
tags: ['轨道交通', '在产', '高毛利'], submittedAt: '2026-06-03',
rows: [
{ type: '原材料成本', qty: 1800, unitPrice: 420.0, revenue: 756000,
directMaterial: 302400, directLabor: 113400, manufacturingCost: 75600, totalCost: 491400,
grossProfit: 264600, grossMargin: 0.3500,
mgmtExpense: 75600, netProfit: 189000, netMargin: 0.2500,
detail: { fabric: 211680, accessories: 90720, labor: 113400, overhead: 75600 } },
{ type: '直接人工成本', qty: 1800, unitPrice: 420.0, revenue: 756000,
directMaterial: 289440, directLabor: 113400, manufacturingCost: 75600, totalCost: 478440,
grossProfit: 277560, grossMargin: 0.3671,
mgmtExpense: 75600, netProfit: 201960, netMargin: 0.2671,
detail: { fabric: 202608, accessories: 86832, labor: 113400, overhead: 75600 } },
{ type: '管理成本', qty: 1800, unitPrice: 420.0, revenue: 756000,
directMaterial: 308520, directLabor: 116820, manufacturingCost: 75600, totalCost: 500940,
grossProfit: 255060, grossMargin: 0.3374,
mgmtExpense: 75600, netProfit: 179460, netMargin: 0.2374,
detail: { fabric: 215964, accessories: 92556, labor: 116820, overhead: 75600 } },
],
costBreakdown: makeBearingBreakdown(
{ directMaterial: 302400, directLabor: 113400 } as CostRow,
{ directMaterial: 289440, directLabor: 113400 } as CostRow,
{ directMaterial: 308520, directLabor: 116820 } as CostRow,
756000, 75600),
productionLines: DEFAULT_PRODUCTION_LINES,
},
// ── 批量生成的订单 (ORD009–ORD020) ───────────────────────────────────
genOrder({ id:'ORD009', orderNo:'RB-ZZ-260220009', customer:'SEW-Eurodrive', salesperson:'黄海燕', channel:'外销-B2B', closedDate:'2026-04-15', productCategory:'深沟球轴承', status:'closed', riskLevel:'normal', region:'欧洲区', tags:['电机配套','外销稳定'], submittedAt:'2026-06-02', qty:15000, unitPrice:42.5, stdMat:320000, stdLabor:96000, stdOH:72000, purMatAdj:-0.03, useMatAdj:-0.01, useLaborAdj:-0.02, mgmt:64000 }),
genOrder({ id:'ORD010', orderNo:'RB-ZZ-260105010', customer:'美的集团', salesperson:'林志强', channel:'内销-直销', closedDate:'2026-03-15', productCategory:'深沟球轴承', status:'closed', riskLevel:'warning', region:'华南区', tags:['家电配套','毛利偏低'], submittedAt:'2026-06-01', qty:50000, unitPrice:12.8, stdMat:320000, stdLabor:96000, stdOH:72000, purMatAdj:-0.02, useMatAdj:0.05, useLaborAdj:0.03, mgmt:48000, note:'大批量低单价,领用材料损耗率偏高。' }),
genOrder({ id:'ORD011', orderNo:'RB-ZZ-260210011', customer:'Bosch Rexroth', salesperson:'黄海燕', channel:'外销-B2B', closedDate:'2026-04-28', productCategory:'圆锥滚子轴承', status:'closed', riskLevel:'normal', region:'欧洲区', tags:['液压配套','高毛利'], submittedAt:'2026-05-30', qty:6000, unitPrice:185.0, stdMat:580000, stdLabor:168000, stdOH:126000, purMatAdj:-0.04, useMatAdj:-0.02, useLaborAdj:-0.03, mgmt:110000 }),
genOrder({ id:'ORD012', orderNo:'RB-ZZ-260318012', customer:'中联重科', salesperson:'陈伟明', channel:'内销-直销', closedDate:'2026-05-20', productCategory:'调心滚子轴承', status:'shipped', riskLevel:'normal', region:'华中区', tags:['工程机械','内销主力'], submittedAt:'2026-05-28', qty:4000, unitPrice:520.0, stdMat:1080000, stdLabor:312000, stdOH:234000, purMatAdj:-0.02, useMatAdj:0.01, useLaborAdj:-0.02, mgmt:208000 }),
genOrder({ id:'ORD013', orderNo:'RB-ZZ-260201013', customer:'Nidec Japan', salesperson:'黄海燕', channel:'外销-B2B', closedDate:'2026-04-08', productCategory:'精密轴承套装', status:'closed', riskLevel:'normal', region:'日本区', tags:['电机配套','外销日本'], submittedAt:'2026-05-26', qty:8000, unitPrice:265.0, stdMat:1120000, stdLabor:320000, stdOH:240000, purMatAdj:-0.03, useMatAdj:-0.01, useLaborAdj:-0.02, mgmt:168000 }),
genOrder({ id:'ORD014', orderNo:'RB-ZZ-260322014', customer:'金风科技', salesperson:'陈伟明', channel:'内销-直销', closedDate:'2026-05-28', productCategory:'风电偏航轴承', status:'closed', riskLevel:'danger', region:'西北区', tags:['风电核心件','高风险','领用超标'], submittedAt:'2026-05-24', qty:400, unitPrice:8500.0, stdMat:1760000, stdLabor:480000, stdOH:360000, purMatAdj:-0.02, useMatAdj:0.08, useLaborAdj:0.05, mgmt:280000, note:'风电大件加工损耗严重,领用超标8%,需改善工艺管控。' }),
genOrder({ id:'ORD015', orderNo:'RB-ZZ-260128015', customer:'柳工机械', salesperson:'林志强', channel:'内销-直销', closedDate:'2026-04-02', productCategory:'圆锥滚子轴承', status:'closed', riskLevel:'warning', region:'华南区', tags:['工程机械','价格压力'], submittedAt:'2026-05-22', qty:10000, unitPrice:280.0, stdMat:1560000, stdLabor:420000, stdOH:336000, purMatAdj:-0.01, useMatAdj:0.04, useLaborAdj:0.02, mgmt:224000, note:'客户压价严重,领用偏差导致毛利空间被压缩。' }),
genOrder({ id:'ORD016', orderNo:'RB-ZZ-260410016', customer:'SKF Brasil', salesperson:'黄海燕', channel:'外销-B2B', closedDate:'', productCategory:'深沟球轴承', status:'production', riskLevel:'normal', region:'南美区', tags:['OEM配套','在产'], submittedAt:'2026-05-20', qty:20000, unitPrice:38.5, stdMat:420000, stdLabor:126000, stdOH:94500, purMatAdj:-0.02, useMatAdj:0.01, useLaborAdj:0.0, mgmt:64000 }),
genOrder({ id:'ORD017', orderNo:'RB-ZZ-260215017', customer:'现代重工', salesperson:'黄海燕', channel:'外销-B2B', closedDate:'2026-03-25', productCategory:'船用轴承', status:'closed', riskLevel:'danger', region:'韩国区', tags:['船舶配套','亏损风险'], submittedAt:'2026-05-18', qty:3000, unitPrice:420.0, stdMat:680000, stdLabor:189000, stdOH:151200, purMatAdj:0.03, useMatAdj:0.10, useLaborAdj:0.06, mgmt:126000, note:'船级社认证材料溢价3%,领用超标10%,亏损风险大。' }),
genOrder({ id:'ORD018', orderNo:'RB-ZZ-260305018', customer:'卧龙电驱', salesperson:'陈伟明', channel:'内销-代理', closedDate:'2026-04-22', productCategory:'深沟球轴承', status:'closed', riskLevel:'normal', region:'华东区', tags:['电机配套','成本稳定'], submittedAt:'2026-05-16', qty:30000, unitPrice:22.5, stdMat:360000, stdLabor:108000, stdOH:81000, purMatAdj:-0.03, useMatAdj:-0.01, useLaborAdj:-0.02, mgmt:54000 }),
genOrder({ id:'ORD019', orderNo:'RB-ZZ-260405019', customer:'格力电器', salesperson:'林志强', channel:'内销-直销', closedDate:'', productCategory:'深沟球轴承', status:'open', riskLevel:'normal', region:'华南区', tags:['家电配套','在制'], submittedAt:'2026-05-14', qty:80000, unitPrice:8.5, stdMat:360000, stdLabor:108000, stdOH:81000, purMatAdj:-0.02, useMatAdj:0.01, useLaborAdj:0.0, mgmt:48000 }),
genOrder({ id:'ORD020', orderNo:'RB-ZZ-260328020', customer:'WEG Brazil', salesperson:'黄海燕', channel:'外销-B2B', closedDate:'2026-05-15', productCategory:'OEM轴承', status:'closed', riskLevel:'warning', region:'南美区', tags:['OEM配套','偏差监控'], submittedAt:'2026-05-12', qty:25000, unitPrice:28.0, stdMat:380000, stdLabor:112000, stdOH:84000, purMatAdj:0.01, useMatAdj:0.06, useLaborAdj:0.03, mgmt:56000, note:'巴西批量大但单价偏低,领用材料偏差6%需持续监控。' }),
];
export const statusConfig: Record<OrderStatus, { label: string; color: string }> = {
open: { label: '在制中', color: '#00d4ff' },
closed: { label: '已结单', color: '#00e599' },
production: { label: '生产中', color: '#ffb340' },
shipped: { label: '已出货', color: '#7b61ff' },
};
export const riskConfig: Record<RiskLevel, { label: string; color: string; bg: string }> = {
normal: { label: '正常', color: '#00e599', bg: 'rgba(0,229,153,0.12)' },
warning: { label: '预警', color: '#ffb340', bg: 'rgba(255,179,64,0.12)' },
danger: { label: '危险', color: '#ff6b6b', bg: 'rgba(255,107,107,0.12)' },
};
export const channelConfig: Record<Channel, { color: string }> = {
'外销-B2B': { color: '#00d4ff' },
'外销-B2C': { color: '#4fc3f7' },
'内销-直销': { color: '#7b61ff' },
'内销-代理': { color: '#ff6b9d' },
'电商平台': { color: '#ffb340' },
};
export const deliveryPriorityConfig: Record<DeliveryPriority, { label: string; color: string; bg: string }> = {
urgent: { label: '紧急', color: '#ff6b6b', bg: 'rgba(255,107,107,0.15)' },
high: { label: '高', color: '#ffb340', bg: 'rgba(255,179,64,0.15)' },
normal: { label: '中', color: '#00d4ff', bg: 'rgba(0,212,255,0.12)' },
low: { label: '低', color: '#00e599', bg: 'rgba(0,229,153,0.12)' },
};