SCSAI PLM System Integration Technical Documentation
Overview
This document summarizes the integration solution for the SCSAI Agent PLM system, covering database connections, identity authentication, AML operations, and standardized object management interface design. The goal is to build a universal, standard interface layer callable by large language models, enabling voice-driven PLM operations.
1. System Architecture
┌─────────────────────────────────────────────────────────────────┐
│ 用户交互层 │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ 语音输入 │ │ 图形界面 │ │ 命令行 │ │
│ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │
│ │ │ │ │
│ └────────────────┼────────────────┘ │
│ ▼ │
│ ┌───────────────────────────────────────────────────────────┐ │
│ │ 大模型理解层 │ │
│ │ • 语音转文本 (ASR) │ │
│ │ • 意图识别 (NLU) │ │
│ │ • 内容生成 (NLG) │ │
│ │ • 接口调用决策 │ │
│ └───────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌───────────────────────────────────────────────────────────┐ │
│ │ 标准对象操作接口层 │ │
│ │ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ │ │
│ │ │ Identify │ │ Create │ │ Repair │ │ Optimize │ │ Compare │ │ │
│ │ │Identify│ │ Create │ │ Repair │ │Optimize│ │ Compare│ │ │
│ │ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘ │ │
│ └───────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌───────────────────────────────────────────────────────────┐ │
│ │ SCSAI集成层 │ │
│ │ • AML请求构建 │ │
│ │ • SOAP通信 │ │
│ │ • 认证管理 │ │
│ │ • 响应解析 │ │
│ └───────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌───────────────────────────────────────────────────────────┐ │
│ │ SCSAI Agent服务器 │ │
│ │ https://ylxt.chat/scplm/server/InnovatorServer.aspx │ │
│ └───────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
二、核心组件
2.1 SCSAI JavaScript SDK集成
SCSAI提供了原生JavaScript SDK,包含以下核心文件:
| File | Function | Loading Order |
|------|------|----------|
| xmlHttpRequest.js | HTTP Request Wrapper | 1 |
| xmlDocument.js | XML Document Processing | 2 |
| static_variables_storage.js | Static Variable Storage | 3 |
| soap_object.js | SOAP Communication Object | 4 |
| sciot_object.js | Core sciot Object | 5 |
| sciot_user.js | User Authentication and Login | 6 |
| sciot_modules.js | Functional Modules | 7 |
| sciot_export.js | Export Functionality | 8 |
2.2 Global Object Initialization
// 必须在加载SCSAI JS文件前设置
window.__staticVariablesStorage = true;
// 核心全局对象
window.Sciot // Sciot类构造函数
window.sciot // Sciot实例(登录后创建)
window.Enums // 枚举定义
window.SciotModules // 功能模块集合
2.3 登录流程
// 1. Createsciot实例
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的数据操作语言:
<!-- 查询对象 -->
<AML>
<Item type="Part" action="get" select="id,name,item_number,description">
<name>零件*</name>
</Item>
</AML>
<!-- 创建对象 -->
<AML>
<Item type="Part" action="add">
<name>新零件</name>
<item_number>PART-001</item_number>
<description>零件描述</description>
</Item>
</AML>
<!-- 更新对象 -->
<AML>
<Item type="Part" action="edit" id="零件ID">
<description>更新后的描述</description>
</Item>
</AML>
<!-- 删除对象 -->
<AML>
<Item type="Part" action="delete" id="零件ID" />
</AML>
三、标准对象操作接口设计
3.1 接口概述
基于PLM业务场景,抽象出五个核心操作:
| Operation | English | Description | Typical Scenario |
|------|------|------|----------|
| Identify | Identify | Identify object type, attributes, relationships | "What is this part?", "Find the supplier" |
| Create | Create | Create new objects or relationships | "Create a new material", "Add a supplier" |
| Repair | Repair | Fix data errors or incompleteness | "Complete part information", "Correct erroneous data" |
| Optimize | Optimize | Optimize object properties or structure | "Optimize BOM structure", "Reduce costs" |
| Compare | Compare | Compare object differences | "Compare two BOMs", "Version difference analysis" |
3.2 Unified Interface Definition
interface ObjectOperationRequest {
operation: 'identify' | 'create' | 'repair' | 'optimize' | 'compare';
objectType: string; // 对象类型:Part, Vendor, ECR, ECO等
context: {
objectId?: string; // 目标对象ID
objectIds?: string[]; // 多个对象ID(比对用)
attributes?: Record<string, any>; // 属性数据
constraints?: Record<string, any>; // 约束条件
};
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 (Identify)
Purpose: Identify object type, attributes, relationships, status
API: POST /api/objects/identify
Request Example:
{
"operation": "identify",
"objectType": "Part",
"context": {
"objectId": "PART-001",
"attributes": {
"name": "发动机"
}
},
"naturalLanguage": "查找名称包含发动机的所有零件"
}
响应示例:
{
"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 (Create)
Purpose: Create new objects, establish relationships
API: POST /api/objects/create
Request Example:
{
"operation": "create",
"objectType": "Part",
"context": {
"attributes": {
"name": "新零件",
"item_number": "PART-NEW-001",
"description": "通过语音创建的新零件",
"classification": "Mechanical"
}
},
"naturalLanguage": "创建一个新零件,名称是新零件,编号是PART-NEW-001"
}
响应示例:
{
"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 (Repair)
Purpose: Fix data errors, complete missing information
API: POST /api/objects/repair
Request Example:
{
"operation": "repair",
"objectType": "Part",
"context": {
"objectId": "PART-001",
"attributes": {
"description": "补充完整描述",
"cost": 1000
}
},
"naturalLanguage": "补全PART-001的描述和成本信息"
}
响应示例:
{
"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 (Optimize)
Purpose: Optimize attribute values, structure, cost, etc.
API: POST /api/objects/optimize
Request Example:
{
"operation": "optimize",
"objectType": "BOM",
"context": {
"objectId": "BOM-001",
"constraints": {
"targetCost": 5000,
"maintainQuality": true
}
},
"naturalLanguage": "OptimizeBOM-001的成本,目标成本5000元,保持质量"
}
响应示例:
{
"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 (Compare)
Purpose: Compare object differences, version comparison
API: POST /api/objects/compare
Request Example:
{
"operation": "compare",
"objectType": "Part",
"context": {
"objectIds": ["PART-V1", "PART-V2"]
},
"naturalLanguage": "对比PART-V1和PART-V2的差异"
}
响应示例:
{
"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模板设计
SYSTEM_PROMPT = """
你是一个PLM系统的智能助手。用户会通过自然语言描述他们的需求,
你需要:
1. 理解用户意图
2. 识别操作类型(Identify/Create/Repair/Optimize/Compare)
3. 提取对象类型和相关参数
4. 返回结构化的接口调用请求
可操作的对象类型:
- Part: 物料/零件
- Product: 产品
- Vendor: 供应商
- ECR: 变更请求
- ECO: 变更指令
- Document: 文档
- BOM: 物料清单
操作类型:
- identify: 查询、Search、Identify
- create: Create、新建、添加
- repair: Repair、补全、修正
- optimize: Optimize、改进、调整
- compare: 对比、比较、差异分析
"""
USER_PROMPT_TEMPLATE = """
用户输入:{user_input}
请分析用户意图并返回JSON格式的接口调用请求:
{{
"operation": "操作类型",
"objectType": "对象类型",
"context": {{
"objectId": "对象ID(如果有)",
"attributes": {{}},
"constraints": {{}}
}},
"confidence": 0.95
}}
"""
4.3 完整调用流程
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 接口层实现
// lib/plm/object-operations.ts
export class ObjectOperations {
async identify(request: ObjectOperationRequest): Promise<ObjectOperationResponse> {
const aml = this.buildIdentifyAML(request);
const result = await this.SCSAI.applyAML(aml);
return this.parseIdentifyResult(result, request);
}
async create(request: ObjectOperationRequest): Promise<ObjectOperationResponse> {
const aml = this.buildCreateAML(request);
const result = await this.SCSAI.applyAML(aml);
return this.parseCreateResult(result, request);
}
async repair(request: ObjectOperationRequest): Promise<ObjectOperationResponse> {
const aml = this.buildRepairAML(request);
const result = await this.SCSAI.applyAML(aml);
return this.parseRepairResult(result, request);
}
async optimize(request: ObjectOperationRequest): Promise<ObjectOperationResponse> {
// 优化可能需要复杂的业务逻辑
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<ObjectOperationResponse> {
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路由实现
// 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 });
}
}
六、总结
本方案通过抽象出五个核心操作(Identify、Create、Repair、Optimize、Compare),建立了一套标准化的对象操作接口。这套接口:
- Generality: Applicable to all PLM object types
- Extensibility: Easy to add new operation types
- AI-Friendly: Structured input/output, easy for large model invocation
- Business Focus: Covers core PLM business scenarios
Next Steps:
- Refine the AML construction logic for each operation
- Implement the large model intent recognition service
- Develop a voice interaction interface
- Establish operation audit logs
BossAgents