SCSAI PLM系统集成技术文档

SCSAI PLM系统集成技术文档

本文由 BossAgents 文档数字员工自动转化 · 来源:技术文档 · 内容未经修改

SCSAI PLM系统集成技术文档

概述

本文档总结了SCSAI agent PLM系统的集成方案,包括数据库连接、身份认证、AML操作以及标准化对象管理接口设计。目标是构建一个通用的、可被大模型调用的标准接口层,实现语音驱动的PLM操作。

一、系统架构

`` ┌─────────────────────────────────────────────────────────────────┐ │ 用户交互层 │ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │ │ 语音输入 │ │ 图形界面 │ │ 命令行 │ │ │ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │ │ │ │ │ │ │ └────────────────┼────────────────┘ │ │ ▼ │ │ ┌───────────────────────────────────────────────────────────┐ │ │ │ 大模型理解层 │ │ │ │ • 语音转文本 (ASR) │ │ │ │ • 意图识别 (NLU) │ │ │ │ • 内容生成 (NLG) │ │ │ │ • 接口调用决策 │ │ │ └───────────────────────────────────────────────────────────┘ │ │ │ │ │ ▼ │ │ ┌───────────────────────────────────────────────────────────┐ │ │ │ 标准对象操作接口层 │ │ │ │ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ │ │ │ │ │ 识别 │ │ 创建 │ │ 修复 │ │ 优化 │ │ 比对 │ │ │ │ │ │Identify│ │ Create │ │ Repair │ │Optimize│ │ Compare│ │ │ │ │ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘ │ │ │ └───────────────────────────────────────────────────────────┘ │ │ │ │ │ ▼ │ │ ┌───────────────────────────────────────────────────────────┐ │ │ │ SCSAI集成层 │ │ │ │ • AML请求构建 │ │ │ │ • SOAP通信 │ │ │ │ • 认证管理 │ │ │ │ • 响应解析 │ │ │ └───────────────────────────────────────────────────────────┘ │ │ │ │ │ ▼ │ │ ┌───────────────────────────────────────────────────────────┐ │ │ │ SCSAI agent服务器 │ │ │ │ https://ylxt.chat/scplm/server/agentServer.aspx │ │ │ └───────────────────────────────────────────────────────────┘ │ └─────────────────────────────────────────────────────────────────┘ `

二、核心组件

2.1 SCSAI JavaScript SDK集成

SCSAI提供了原生JavaScript SDK,包含以下核心文件: | 文件 | 功能 | 加载顺序 | |------|------|----------| |
xmlHttpRequest.js | HTTP请求封装 | 1 | | xmlDocument.js | XML文档处理 | 2 | | static_variables_storage.js | 静态变量存储 | 3 | | soap_object.js | SOAP通信对象 | 4 | | sciot_object.js | 核心sciot对象 | 5 | | sciot_user.js | 用户认证和登录 | 6 | | sciot_modules.js | 功能模块 | 7 | | sciot_export.js | 导出功能 | 8 |

2.2 全局对象初始化

`javascript // 必须在加载SCSAI JS文件前设置 window.__staticVariablesStorage = true; // 核心全局对象 window.Sciot // Sciot类构造函数 window.sciot // Sciot实例(登录后创建) window.Enums // 枚举定义 window.SciotModules // 功能模块集合 `

2.3 登录流程

`javascript // 1. 创建sciot实例 const sciot = new Sciot(); // 2. 设置服务器配置 sciot.setServerUrl('https://ylxt.chat/scplm/server'); sciot.setDatabase('SCPLM'); // 3. 执行登录 await sciot.login({ loginName: 'root', password: 'password', database: 'SCPLM' }); // 4. 登录成功后可执行AML操作 `

2.4 AML操作

AML (SCSAI Markup Language) 是SCSAI的数据操作语言:
`xml 零件* 新零件 PART-001 零件描述 更新后的描述 `

三、标准对象操作接口设计

3.1 接口概述

基于PLM业务场景,抽象出五个核心操作: | 操作 | 英文 | 描述 | 典型场景 | |------|------|------|----------| | 识别 | Identify | 识别对象类型、属性、关系 | "这是什么零件?"、"查找供应商" | | 创建 | Create | 创建新对象或关系 | "新建一个物料"、"添加供应商" | | 修复 | Repair | 修复数据错误或不完整 | "补全零件信息"、"修正错误数据" | | 优化 | Optimize | 优化对象属性或结构 | "优化BOM结构"、"降低成本" | | 比对 | Compare | 比较对象差异 | "对比两个BOM"、"版本差异分析" |

3.2 统一接口定义

`typescript interface ObjectOperationRequest { operation: 'identify' | 'create' | 'repair' | 'optimize' | 'compare'; objectType: string; // 对象类型:Part, Vendor, ECR, ECO等 context: { objectId?: string; // 目标对象ID objectIds?: string[]; // 多个对象ID(比对用) attributes?: Record; // 属性数据 constraints?: Record; // 约束条件 }; naturalLanguage?: string; // 自然语言描述 } interface ObjectOperationResponse { success: boolean; operation: string; objectType: string; result: { identified?: any; // 识别结果 created?: any; // 创建结果 repaired?: any; // 修复结果 optimized?: any; // 优化结果 compared?: any; // 比对结果 }; message: string; suggestions?: string[]; // 后续建议 } `

3.3 各操作详细设计

#### 3.3.1 识别 (Identify) 用途: 识别对象类型、属性、关系、状态 API:
POST /api/objects/identify 请求示例: `json { "operation": "identify", "objectType": "Part", "context": { "objectId": "PART-001", "attributes": { "name": "发动机" } }, "naturalLanguage": "查找名称包含发动机的所有零件" } ` 响应示例: `json { "success": true, "operation": "identify", "objectType": "Part", "result": { "identified": [ { "id": "PART-001", "name": "发动机总成", "item_number": "ENG-001", "description": "V6 3.0L发动机", "state": "Released", "relationships": ["BOM", "Document", "Vendor"] } ] }, "message": "识别到1个匹配对象", "suggestions": ["查看BOM结构", "查看关联文档"] } ` #### 3.3.2 创建 (Create) 用途: 创建新对象、建立关系 API: POST /api/objects/create 请求示例: `json { "operation": "create", "objectType": "Part", "context": { "attributes": { "name": "新零件", "item_number": "PART-NEW-001", "description": "通过语音创建的新零件", "classification": "Mechanical" } }, "naturalLanguage": "创建一个新零件,名称是新零件,编号是PART-NEW-001" } ` 响应示例: `json { "success": true, "operation": "create", "objectType": "Part", "result": { "created": { "id": "NEW-ID-12345", "name": "新零件", "item_number": "PART-NEW-001", "state": "Preliminary" } }, "message": "成功创建零件:新零件", "suggestions": ["添加BOM组件", "关联文档", "提交审批"] } ` #### 3.3.3 修复 (Repair) 用途: 修复数据错误、补全缺失信息 API: POST /api/objects/repair 请求示例: `json { "operation": "repair", "objectType": "Part", "context": { "objectId": "PART-001", "attributes": { "description": "补充完整描述", "cost": 1000 } }, "naturalLanguage": "补全PART-001的描述和成本信息" } ` 响应示例: `json { "success": true, "operation": "repair", "objectType": "Part", "result": { "repaired": { "id": "PART-001", "fixedFields": ["description", "cost"], "beforeState": { "description": null, "cost": null }, "afterState": { "description": "补充完整描述", "cost": 1000 } } }, "message": "成功修复2个字段", "suggestions": ["检查其他缺失字段", "提交审批"] } ` #### 3.3.4 优化 (Optimize) 用途: 优化属性值、结构、成本等 API: POST /api/objects/optimize 请求示例: `json { "operation": "optimize", "objectType": "BOM", "context": { "objectId": "BOM-001", "constraints": { "targetCost": 5000, "maintainQuality": true } }, "naturalLanguage": "优化BOM-001的成本,目标成本5000元,保持质量" } ` 响应示例: `json { "success": true, "operation": "optimize", "objectType": "BOM", "result": { "optimized": { "id": "BOM-001", "beforeCost": 6500, "afterCost": 4800, "savings": 1700, "changes": [ { "component": "PART-A", "action": "替代", "saving": 800 }, { "component": "PART-B", "action": "减少数量", "saving": 900 } ] } }, "message": "优化完成,节省成本1700元", "suggestions": ["查看详细变更", "提交审批"] } ` #### 3.3.5 比对 (Compare) 用途: 比较对象差异、版本对比 API: POST /api/objects/compare 请求示例: `json { "operation": "compare", "objectType": "Part", "context": { "objectIds": ["PART-V1", "PART-V2"] }, "naturalLanguage": "对比PART-V1和PART-V2的差异" } ` 响应示例: `json { "success": true, "operation": "compare", "objectType": "Part", "result": { "compared": { "object1": { "id": "PART-V1", "version": "A" }, "object2": { "id": "PART-V2", "version": "B" }, "differences": [ { "field": "cost", "value1": 100, "value2": 120, "change": "+20%" }, { "field": "weight", "value1": 50, "value2": 45, "change": "-10%" }, { "field": "bomComponents", "value1": 10, "value2": 12, "change": "+2" } ] } }, "message": "发现3处差异", "suggestions": ["查看详细BOM差异", "生成变更报告"] } `

四、大模型集成方案

4.1 意图识别流程

` 语音输入 → ASR转文本 → 大模型理解 → 意图分类 → 参数提取 → 接口调用 `

4.2 Prompt模板设计

`python SYSTEM_PROMPT = """ 你是一个PLM系统的智能助手。用户会通过自然语言描述他们的需求, 你需要:
  • 理解用户意图
  • 识别操作类型(识别/创建/修复/优化/比对)
  • 提取对象类型和相关参数
  • 返回结构化的接口调用请求
  • 可操作的对象类型:
  • Part: 物料/零件
  • Product: 产品
  • Vendor: 供应商
  • ECR: 变更请求
  • ECO: 变更指令
  • Document: 文档
  • BOM: 物料清单
  • 操作类型:
  • identify: 查询、搜索、识别
  • create: 创建、新建、添加
  • repair: 修复、补全、修正
  • optimize: 优化、改进、调整
  • compare: 对比、比较、差异分析
  • """ USER_PROMPT_TEMPLATE = """ 用户输入:{user_input} 请分析用户意图并返回JSON格式的接口调用请求: {{ "operation": "操作类型", "objectType": "对象类型", "context": {{ "objectId": "对象ID(如果有)", "attributes": {{}}, "constraints": {{}} }}, "confidence": 0.95 }} """
    `

    4.3 完整调用流程

    `python async def process_voice_command(voice_input: str): # 1. 语音转文本 text = await asr_service.transcribe(voice_input) # 2. 大模型理解 intent = await llm_service.analyze_intent(text) # 3. 构建请求 request = ObjectOperationRequest( operation=intent['operation'], objectType=intent['objectType'], context=intent['context'], naturalLanguage=text ) # 4. 调用标准接口 response = await object_api.execute(request) # 5. 生成回复 reply = await llm_service.generate_response(response) # 6. 语音合成输出 audio = await tts_service.synthesize(reply) return audio, response `

    五、实现建议

    5.1 接口层实现

    `typescript // lib/plm/object-operations.ts export class ObjectOperations { async identify(request: ObjectOperationRequest): Promise { const aml = this.buildIdentifyAML(request); const result = await this.SCSAI.applyAML(aml); return this.parseIdentifyResult(result, request); } async create(request: ObjectOperationRequest): Promise { const aml = this.buildCreateAML(request); const result = await this.SCSAI.applyAML(aml); return this.parseCreateResult(result, request); } async repair(request: ObjectOperationRequest): Promise { const aml = this.buildRepairAML(request); const result = await this.SCSAI.applyAML(aml); return this.parseRepairResult(result, request); } async optimize(request: ObjectOperationRequest): Promise { // 优化可能需要复杂的业务逻辑 const current = await this.identify(request); const suggestions = await this.generateOptimizations(current); const aml = this.buildOptimizeAML(request, suggestions); const result = await this.SCSAI.applyAML(aml); return this.parseOptimizeResult(result, request); } async compare(request: ObjectOperationRequest): Promise { const objects = await Promise.all( request.context.objectIds.map(id => this.getById(request.objectType, id)) ); const differences = this.computeDifferences(objects); return this.parseCompareResult(differences, request); } } `

    5.2 API路由实现

    `typescript // app/api/objects/route.ts export async function POST(request: NextRequest) { const body: ObjectOperationRequest = await request.json(); const operations = new ObjectOperations(); switch (body.operation) { case 'identify': return NextResponse.json(await operations.identify(body)); case 'create': return NextResponse.json(await operations.create(body)); case 'repair': return NextResponse.json(await operations.repair(body)); case 'optimize': return NextResponse.json(await operations.optimize(body)); case 'compare': return NextResponse.json(await operations.compare(body)); default: return NextResponse.json({ error: '未知操作' }, { status: 400 }); } } ``

    六、总结

    本方案通过抽象出五个核心操作(识别、创建、修复、优化、比对),建立了一套标准化的对象操作接口。这套接口:
  • 通用性: 适用于所有PLM对象类型
  • 可扩展: 易于添加新的操作类型
  • AI友好: 结构化输入输出,便于大模型调用
  • 业务聚焦: 覆盖PLM核心业务场景
  • 下一步工作:
  • 完善各操作的AML构建逻辑
  • 实现大模型意图识别服务
  • 开发语音交互界面
  • 建立操作审计日志
  • ← 返回案例列表
    分享:
    🤖 Try Now →
    🤖
    🎁