SCSAI 四层架构设计文档

SCSAI 四层架构设计文档

版本: 1.0

日期: 2026-05-09

作者: SCSAI 数字员工平台


一、架构总览

SCSAI 采用四层递进架构,实现从"人工操作"到"完全自主"的演进路径:

┌──────────────────────────────────────────────────────────┐
│ 第4层:数字员工自主完成(零交互)                            │
│    用户什么都不用做,数字员工自动完成业务                      │
│    例:小智-ECR审核员每15分钟自动扫描并审批ECR               │
├──────────────────────────────────────────────────────────┤
│ 第3层:自然语言 / 简单点击(低交互)                         │
│    用户用自然语言描述需求,AI自动理解并执行                    │
│    例:"创建一个供应商华为" → 自动识别、填充、创建            │
├──────────────────────────────────────────────────────────┤
│ 第2层:业务CRUD + LLM模板生成                               │
│    传统表单操作 + AI辅助填充,用户确认后提交                   │
│    例:填写供应商表单,LLM根据描述自动生成字段值               │
├──────────────────────────────────────────────────────────┤
│ 第1层:对象类管理(元数据层)                                │
│    管理系统的"模具"——对象类(ItemType)的定义                  │
│    例:创建/修复/优化/比对对象类                             │
└──────────────────────────────────────────────────────────┘

核心设计思想

对象类是模具,业务对象是注塑件

  • 对象类(ItemType)定义了数据的结构、属性、关系、生命周期
  • 业务对象(Vendor、ECR、BOM等)是对象类的实例
  • 对象类走通了,业务就是套模板——一个通用引擎覆盖所有业务CRUD

二、各层详细设计

第1层:对象类管理(元数据层)

#### 2.1.1 核心工具(SCSAI-tools.js)

| 工具函数 | 功能 | 调用方式 |

|---------|------|---------|

| smartCreateItemType | 智能创建对象类 | SCSAI-tools.js |

| smartRepairItemType | 智能修复对象类问题 | SCSAI-tools.js |

| smartCompareItemTypes | 智能比对两个对象类差异 | SCSAI-tools.js |

| importItemTypes | 批量导入对象类 | SCSAI-tools.js |

| optimizeItemTypes | 批量优化对象类属性 | SCSAI-tools.js |

| identifyItemType | 根据描述识别匹配的对象类 | SCSAI-tools.js |

#### 2.1.2 AI-Agent 工具注册(ai-agent.js)

// 对象类管理工具(6个)
- identify_item_type      // 识别对象类
- smart_create_item_type  // 智能创建
- smart_repair_item_type  // 智能修复
- smart_compare_item_types // 智能比对
- import_item_types       // 批量导入
- optimize_item_types     // 批量优化

#### 2.1.3 数据双写策略

所有对象类操作遵循 SCSAI为主,SQLite为缓存

  1. 先写入 SCSAI 系统(主数据源)
  2. 成功后异步更新本地 SQLite 缓存
  3. SCSAI 不可用时降级为本地模式

第2层:业务CRUD + LLM模板生成

#### 2.2.1 通用业务引擎(核心创新)

设计目标:一个工具覆盖所有业务对象的 CRUD

// 通用业务操作引擎
smartBusinessOperation({
    operation: 'create' | 'read' | 'update' | 'delete' | 'list' | 'generate',
    item_type: 'Vendor' | 'Customer' | 'ECR' | 'Project' | 'BOM' | ...,
    properties: { /* 属性键值对 */ },
    id: 'item_id',           // read/update/delete 时使用
    max_records: 50,         // list 时使用
    where: '<name>华为</name>' // list 时的AML条件
})

#### 2.2.2 业务模板系统

预定义模板(8种)

| 模板名称 | 中文名 | 字段数 | 核心字段 |

|---------|-------|-------|---------|

| Vendor | 供应商 | 7 | name, code, contact_person, phone, email, address, category |

| Customer | 客户 | 7 | name, code, contact_person, phone, email, address, level |

| ECR | 变更请求 | 6 | name, title, description, reason, priority, affected_parts |

| Project | 项目 | 7 | name, description, manager, start_date, end_date, priority, status |

| Quality Inspection | 质量检验 | 8 | title, inspection_type, part_number, part_name, inspector, total_inspected, defect_count, result |

| NCR | 不合格品报告 | 7 | title, severity, part_number, part_name, description, quantity, responsible |

| BOM | 物料清单 | 6 | name, part_number, description, version, quantity, unit |

| Document | 文档 | 5 | name, description, category, author, version |

动态模板

  • 如果没有预定义模板,自动从 SCSAI 获取对象类属性定义
  • 支持任意自定义对象类型

#### 2.2.3 AI-Agent 工具注册

// 通用业务引擎工具(4个)
- smart_business_operation    // 通用CRUD引擎
- get_business_template       // 获取业务模板
- list_business_templates     // 列出所有模板
- get_item_type_properties    // 获取对象类属性定义

#### 2.2.4 典型使用流程

场景:用户说"创建一个供应商华为"

用户输入: "创建一个供应商华为,联系人是张三,电话18601921816"
    ↓
LLM理解意图 → 识别 item_type = "Vendor"
    ↓
调用 get_business_template("Vendor")
    ↓
返回模板: { label: "供应商", fields: [...7个字段...] }
    ↓
LLM按模板提取信息:
    - name: "华为"
    - contact_person: "张三"
    - phone: "18601921816"
    - 其他字段: 留空或默认值
    ↓
调用 smart_business_operation({
    operation: "create",
    item_type: "Vendor",
    properties: { name: "华为", contact_person: "张三", phone: "18601921816" }
})
    ↓
SCSAI创建成功 → 返回结果给用户

第3层:自然语言 / 简单点击

#### 2.3.1 入口位置

| 入口 | 位置 | 功能 |

|-----|------|------|

| AI助手 | 左侧导航栏 → 💬 AI助手 | 自然语言对话,调用任意工具 |

| 悬浮按钮 | 右下角悬浮球 | 全局快捷唤起 |

| 业务页面 | 各业务模块内嵌AI助手 | 上下文感知的智能辅助 |

#### 2.3.2 交互模式

模式1:直接执行(查询类)

用户: "查看所有供应商"
AI: 直接调用 list_business_templates → 返回结果

模式2:确认后执行(修改类)

用户: "删除供应商华为"
AI: "确认删除供应商'华为'吗?回复'确认'执行,回复'取消'放弃"
用户: "确认"
AI: 执行删除 → 返回结果

模式3:多轮对话(复杂任务)

用户: "创建一个ECR"
AI: "请描述变更内容:变更标题是什么?"
用户: "产品外壳材料变更"
AI: "变更原因是什么?"
用户: "客户要求提升耐热性"
AI: "好的,我将为您创建ECR-2026-001..."

第4层:数字员工自主完成

#### 2.4.1 数字员工花名册

| 工号 | 名称 | 职责 | 调度周期 | 等级 | 部门 |

|-----|------|------|---------|------|------|

| DS-ECR-001 | 小智-ECR审核员 | ECR变更请求初审 | 每15分钟 | 初级 | 质量部 |

| DS-VEN-001 | 小智-供应商管家 | 供应商质量监控 | 每30分钟 | 中级 | 采购部 |

| DS-COST-001 | 小智-成本优化师 | BOM成本分析优化 | 每天凌晨2点 | 高级 | 财务部 |

| DS-DATA-001 | 小智-数据书记员 | SCSAI数据同步 | 每小时 | 初级 | IT部 |

#### 2.4.2 自主工作示例

小智-ECR审核员的工作流程

每15分钟执行:
1. 查询状态为"待审核"的ECR
2. 对每个ECR进行LLM智能分析:
   - 检查必填字段完整性
   - 评估变更风险等级
   - 计算置信度分数
3. 决策:
   - 置信度>0.8且低风险 → 自动审批
   - 置信度>0.9且高风险 → 自动驳回
   - 其他 → 升级人工处理
4. 记录操作日志

三、技术实现

3.1 核心文件结构

server/
├── utils/
│   ├── SCSAI-client.js       # SCSAI SOAP API 客户端
│   └── SCSAI-tools.js        # 对象类管理工具 + 通用业务引擎
├── ai-agent.js              # AI代理核心,40+工具注册
├── digital-staff/
│   └── index.js             # 数字员工调度器
└── routes/
    └── aml.js               # AML路由,对象类管理API

frontend/
└── app.js                   # 前端Vue应用,AI助手UI

3.2 关键API端点

| 端点 | 方法 | 功能 |

|-----|------|------|

| /api/ai-agent/chat | POST | AI助手对话入口 |

| /api/ai-agent/execute | POST | 工具执行入口 |

| /api/ai-agent/tools | GET | 获取工具列表 |

| /api/digital-staff/status | GET | 数字员工状态 |

| /api/digital-staff/dashboard | GET | 工作仪表盘 |

3.3 数据流

用户输入
    ↓
AI-Agent.processMessage()
    ↓
LLM理解意图 → 选择工具
    ↓
executeTool(toolName, params)
    ↓
SCSAI-tools.smartBusinessOperation()
    ↓
SCSAIClient.createItem/updateItem/...  →  SCSAI系统
    ↓
异步更新SQLite缓存
    ↓
返回结果给用户

四、使用示例

4.1 对象类管理

# 识别对象类
curl -X POST https://ylxt.chat/api/ai-agent/execute \
  -H "Content-Type: application/json" \
  -d '{"toolName": "identify_item_type", "params": {"description": "管理供应商信息的类型"}}'

# 创建对象类
curl -X POST https://ylxt.chat/api/ai-agent/execute \
  -H "Content-Type: application/json" \
  -d '{"toolName": "smart_create_item_type", "params": {"name": "CustomPart", "label": "自定义零件", "properties": [...]}}'

# 比对对象类
curl -X POST https://ylxt.chat/api/ai-agent/execute \
  -H "Content-Type: application/json" \
  -d '{"toolName": "smart_compare_item_types", "params": {"source_name": "Part", "target_name": "CustomPart"}}'

4.2 业务操作

# 列出所有业务模板
curl -X POST https://ylxt.chat/api/ai-agent/execute \
  -H "Content-Type: application/json" \
  -d '{"toolName": "list_business_templates", "params": {}}'

# 获取供应商模板
curl -X POST https://ylxt.chat/api/ai-agent/execute \
  -H "Content-Type: application/json" \
  -d '{"toolName": "get_business_template", "params": {"item_type": "Vendor"}}'

# 创建供应商
curl -X POST https://ylxt.chat/api/ai-agent/execute \
  -H "Content-Type: application/json" \
  -d '{
    "toolName": "smart_business_operation",
    "params": {
      "operation": "create",
      "item_type": "Vendor",
      "properties": {"name": "华为技术有限公司", "code": "VENDOR-001"}
    }
  }'

# 查询供应商列表
curl -X POST https://ylxt.chat/api/ai-agent/execute \
  -H "Content-Type: application/json" \
  -d '{
    "toolName": "smart_business_operation",
    "params": {
      "operation": "list",
      "item_type": "Vendor",
      "max_records": 10
    }
  }'

五、待办事项

5.1 近期优化

  • [ ] 对象类管理页面添加快捷入口(识别/创建/修复/优化/比对按钮)
  • [ ] 扩展数字员工覆盖更多业务场景(BOM助手、质量巡检员等)
  • [ ] 前端AI助手接入通用业务引擎

5.2 中期规划

  • [ ] 业务模板可视化编辑器
  • [ ] 数字员工工作流编排
  • [ ] 多模态交互(语音、图片识别)

5.3 长期愿景

  • [ ] 完全自主的数字员工团队
  • [ ] 零代码业务配置
  • [ ] 跨系统智能集成

六、附录

6.1 工具清单(44个)

对象类管理(6个)

identify_item_type, smart_create_item_type, smart_repair_item_type, smart_compare_item_types, import_item_types, optimize_item_types

通用业务引擎(4个)

smart_business_operation, get_business_template, list_business_templates, get_item_type_properties

传统业务工具(10个)

create_vendor, create_project, create_quality_inspection, create_inventory_item, inventory_transaction, create_ncr, create_SCSAI_item, search_item_types, get_item_type_detail, repair_item_type

数据分析(5个)

dashboard_summary, compare_item_types, system_health, analyze_trends, export_data

AI/预测(10个)

run_vision_inspection, batch_visual_inspection, predict_device_health, predict_tool_wear, check_all_devices_health, optimize_process_params, run_mold_flow_analysis, run_scheduling_optimizer, find_alternative_material, smart_sourcing

其他(9个)

assess_supply_chain_risk, get_production_status, calculate_carbon_footprint, trigger_n8n_webhook, generate_quality_report, optimize_energy_consumption, analyze_root_cause, list_data, toggle_core_business

6.2 相关文档

  • 规则引擎-SOUL.md - SOUL架构设计
  • SCSAI系统总结文档.docx - 系统总体介绍
  • SCSAI-INTEGRATION.md - SCSAI集成指南
  • QUICK_REFERENCE.md - 快速参考
← 返回案例列表
分享:
🤖 Try Now →
🤖
🎁