Spaces:
Sleeping
Sleeping
Trae Assistant commited on
Commit ·
4deed29
0
Parent(s):
Initial commit with enhanced features and localization
Browse files- .gitattributes +1 -0
- Dockerfile +12 -0
- README.md +43 -0
- app.py +282 -0
- instance/chip_sense.db +3 -0
- requirements.txt +4 -0
- templates/index.html +548 -0
.gitattributes
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
*.db filter=lfs diff=lfs merge=lfs -text
|
Dockerfile
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.9-slim
|
| 2 |
+
|
| 3 |
+
WORKDIR /app
|
| 4 |
+
|
| 5 |
+
COPY requirements.txt .
|
| 6 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 7 |
+
|
| 8 |
+
COPY . .
|
| 9 |
+
|
| 10 |
+
RUN mkdir -p instance && chmod 777 instance
|
| 11 |
+
|
| 12 |
+
CMD ["python", "app.py"]
|
README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: 芯感智能 (Chip Sense AI)
|
| 3 |
+
emoji: 💿
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: indigo
|
| 6 |
+
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
+
short_description: 半导体晶圆良率分析与工艺监控智能体
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# 芯感智能 (Chip Sense Agent)
|
| 12 |
+
|
| 13 |
+
**芯感智能** 是一款专为半导体制造领域设计的良率分析与工艺监控 SaaS Agent。它结合了实时晶圆图谱可视化(Wafer Map)与 SiliconFlow AI 推理能力,帮助工艺工程师快速识别缺陷模式、归因根源并优化制程。
|
| 14 |
+
|
| 15 |
+
## 核心功能
|
| 16 |
+
|
| 17 |
+
1. **晶圆全息雷达 (Wafer Radar)**:
|
| 18 |
+
* 动态生成晶圆热力图,可视化 Die 良率分布。
|
| 19 |
+
* 支持缩放与点击交互,查看单颗 Die 的详细参数。
|
| 20 |
+
2. **良率智脑 (Yield Mind)**:
|
| 21 |
+
* 集成 Qwen2.5-7B-Instruct 模型,自动分析缺陷空间分布模式(如:边缘失效、中心斑点、环形条纹)。
|
| 22 |
+
* 提供工艺归因建议(如:刻蚀均匀性差、涂胶转速异常)。
|
| 23 |
+
3. **工艺守望者 (Process Sentinel)**:
|
| 24 |
+
* 实时监控关键工艺参数(温度、压力、气体流量)。
|
| 25 |
+
* SPC(统计过程控制)异常预警。
|
| 26 |
+
4. **缺陷资产库 (Defect Vault)**:
|
| 27 |
+
* 自动记录并归档历史缺陷模式,形成企业级良率知识库。
|
| 28 |
+
|
| 29 |
+
## 技术栈
|
| 30 |
+
|
| 31 |
+
* **Backend**: Python Flask, SQLite
|
| 32 |
+
* **Frontend**: Vue 3, Tailwind CSS, ECharts (Canvas)
|
| 33 |
+
* **AI**: SiliconFlow API (Qwen/Qwen2.5-7B-Instruct)
|
| 34 |
+
* **Deployment**: Docker, Hugging Face Spaces
|
| 35 |
+
|
| 36 |
+
## 快速开始
|
| 37 |
+
|
| 38 |
+
```bash
|
| 39 |
+
git clone https://huggingface.co/spaces/your-username/chip-sense-agent
|
| 40 |
+
cd chip-sense-agent
|
| 41 |
+
pip install -r requirements.txt
|
| 42 |
+
python app.py
|
| 43 |
+
```
|
app.py
ADDED
|
@@ -0,0 +1,282 @@
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import json
|
| 3 |
+
import sqlite3
|
| 4 |
+
import random
|
| 5 |
+
import datetime
|
| 6 |
+
import requests
|
| 7 |
+
from flask import Flask, render_template, request, jsonify, send_from_directory
|
| 8 |
+
from flask_cors import CORS
|
| 9 |
+
|
| 10 |
+
app = Flask(__name__)
|
| 11 |
+
CORS(app)
|
| 12 |
+
|
| 13 |
+
# Configuration
|
| 14 |
+
SILICONFLOW_API_KEY = "sk-vimuseiptfbomzegyuvmebjzooncsqbyjtlddrfodzcdskgi"
|
| 15 |
+
SILICONFLOW_API_URL = "https://api.siliconflow.cn/v1/chat/completions"
|
| 16 |
+
DB_PATH = os.path.join(app.instance_path, "chip_sense.db")
|
| 17 |
+
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 # 16MB max upload
|
| 18 |
+
|
| 19 |
+
# Ensure instance directory exists
|
| 20 |
+
os.makedirs(app.instance_path, exist_ok=True)
|
| 21 |
+
|
| 22 |
+
# Database Initialization
|
| 23 |
+
def init_db():
|
| 24 |
+
with sqlite3.connect(DB_PATH) as conn:
|
| 25 |
+
cursor = conn.cursor()
|
| 26 |
+
cursor.execute('''
|
| 27 |
+
CREATE TABLE IF NOT EXISTS wafers (
|
| 28 |
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
| 29 |
+
lot_id TEXT NOT NULL,
|
| 30 |
+
wafer_id TEXT NOT NULL,
|
| 31 |
+
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
|
| 32 |
+
yield_rate REAL,
|
| 33 |
+
status TEXT,
|
| 34 |
+
map_data JSON
|
| 35 |
+
)
|
| 36 |
+
''')
|
| 37 |
+
cursor.execute('''
|
| 38 |
+
CREATE TABLE IF NOT EXISTS defect_assets (
|
| 39 |
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
| 40 |
+
wafer_db_id INTEGER,
|
| 41 |
+
pattern_type TEXT,
|
| 42 |
+
root_cause TEXT,
|
| 43 |
+
recommendation TEXT,
|
| 44 |
+
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
|
| 45 |
+
FOREIGN KEY(wafer_db_id) REFERENCES wafers(id)
|
| 46 |
+
)
|
| 47 |
+
''')
|
| 48 |
+
conn.commit()
|
| 49 |
+
|
| 50 |
+
# Mock Data Generator for Wafer Maps
|
| 51 |
+
def generate_wafer_map(pattern_type="random"):
|
| 52 |
+
# 20x20 Grid masked as a circle
|
| 53 |
+
size = 20
|
| 54 |
+
data = []
|
| 55 |
+
total_dies = 0
|
| 56 |
+
pass_dies = 0
|
| 57 |
+
|
| 58 |
+
center_x, center_y = size / 2, size / 2
|
| 59 |
+
radius = size / 2
|
| 60 |
+
|
| 61 |
+
for x in range(size):
|
| 62 |
+
for y in range(size):
|
| 63 |
+
# Circular mask
|
| 64 |
+
if (x - center_x)**2 + (y - center_y)**2 > radius**2:
|
| 65 |
+
continue
|
| 66 |
+
|
| 67 |
+
total_dies += 1
|
| 68 |
+
is_defect = False
|
| 69 |
+
|
| 70 |
+
# Simulate patterns
|
| 71 |
+
if pattern_type == "edge":
|
| 72 |
+
dist = ((x - center_x)**2 + (y - center_y)**2)**0.5
|
| 73 |
+
if dist > radius * 0.8 and random.random() < 0.6:
|
| 74 |
+
is_defect = True
|
| 75 |
+
elif pattern_type == "center":
|
| 76 |
+
dist = ((x - center_x)**2 + (y - center_y)**2)**0.5
|
| 77 |
+
if dist < radius * 0.4 and random.random() < 0.7:
|
| 78 |
+
is_defect = True
|
| 79 |
+
elif pattern_type == "scratch":
|
| 80 |
+
# Linear scratch
|
| 81 |
+
if abs(x - y) < 2 and random.random() < 0.8:
|
| 82 |
+
is_defect = True
|
| 83 |
+
elif pattern_type == "ring":
|
| 84 |
+
dist = ((x - center_x)**2 + (y - center_y)**2)**0.5
|
| 85 |
+
if dist > radius * 0.5 and dist < radius * 0.7 and random.random() < 0.5:
|
| 86 |
+
is_defect = True
|
| 87 |
+
else: # Random
|
| 88 |
+
if random.random() < 0.05:
|
| 89 |
+
is_defect = True
|
| 90 |
+
|
| 91 |
+
# Value: 0 = Pass, 1 = Fail
|
| 92 |
+
value = 1 if is_defect else 0
|
| 93 |
+
if value == 0:
|
| 94 |
+
pass_dies += 1
|
| 95 |
+
|
| 96 |
+
data.append([x, y, value])
|
| 97 |
+
|
| 98 |
+
yield_rate = (pass_dies / total_dies) * 100 if total_dies > 0 else 0
|
| 99 |
+
return data, yield_rate
|
| 100 |
+
|
| 101 |
+
# Initialize some mock data if empty
|
| 102 |
+
def seed_data():
|
| 103 |
+
with sqlite3.connect(DB_PATH) as conn:
|
| 104 |
+
cursor = conn.cursor()
|
| 105 |
+
cursor.execute("SELECT COUNT(*) FROM wafers")
|
| 106 |
+
if cursor.fetchone()[0] == 0:
|
| 107 |
+
patterns = ["random", "edge", "center", "scratch", "ring"]
|
| 108 |
+
pattern_names = {
|
| 109 |
+
"random": "随机分布 (Random)",
|
| 110 |
+
"edge": "边缘失效 (Edge Failure)",
|
| 111 |
+
"center": "中心失效 (Center Failure)",
|
| 112 |
+
"scratch": "划痕缺陷 (Scratch)",
|
| 113 |
+
"ring": "环形缺陷 (Ring Defect)"
|
| 114 |
+
}
|
| 115 |
+
for i in range(12):
|
| 116 |
+
p_type = random.choice(patterns)
|
| 117 |
+
map_data, yield_rate = generate_wafer_map(p_type)
|
| 118 |
+
# Create a more realistic lot ID
|
| 119 |
+
lot_id = f"LOT-{2025001+i}-{random.choice(['A', 'B', 'C'])}"
|
| 120 |
+
cursor.execute('''
|
| 121 |
+
INSERT INTO wafers (lot_id, wafer_id, yield_rate, status, map_data)
|
| 122 |
+
VALUES (?, ?, ?, ?, ?)
|
| 123 |
+
''', (lot_id, f"W{i+1:02d}", yield_rate, pattern_names[p_type], json.dumps(map_data)))
|
| 124 |
+
conn.commit()
|
| 125 |
+
|
| 126 |
+
init_db()
|
| 127 |
+
seed_data()
|
| 128 |
+
|
| 129 |
+
# Routes
|
| 130 |
+
@app.route('/')
|
| 131 |
+
def index():
|
| 132 |
+
return render_template('index.html')
|
| 133 |
+
|
| 134 |
+
@app.route('/api/wafers', methods=['GET'])
|
| 135 |
+
def get_wafers():
|
| 136 |
+
try:
|
| 137 |
+
with sqlite3.connect(DB_PATH) as conn:
|
| 138 |
+
conn.row_factory = sqlite3.Row
|
| 139 |
+
cursor = conn.cursor()
|
| 140 |
+
cursor.execute("SELECT id, lot_id, wafer_id, yield_rate, status, timestamp FROM wafers ORDER BY id DESC")
|
| 141 |
+
rows = cursor.fetchall()
|
| 142 |
+
return jsonify([dict(row) for row in rows])
|
| 143 |
+
except Exception as e:
|
| 144 |
+
return jsonify({"error": str(e)}), 500
|
| 145 |
+
|
| 146 |
+
@app.route('/api/wafer/<int:wafer_id>', methods=['GET'])
|
| 147 |
+
def get_wafer_detail(wafer_id):
|
| 148 |
+
try:
|
| 149 |
+
with sqlite3.connect(DB_PATH) as conn:
|
| 150 |
+
conn.row_factory = sqlite3.Row
|
| 151 |
+
cursor = conn.cursor()
|
| 152 |
+
cursor.execute("SELECT * FROM wafers WHERE id = ?", (wafer_id,))
|
| 153 |
+
row = cursor.fetchone()
|
| 154 |
+
if row:
|
| 155 |
+
d = dict(row)
|
| 156 |
+
d['map_data'] = json.loads(d['map_data'])
|
| 157 |
+
return jsonify(d)
|
| 158 |
+
return jsonify({"error": "Wafer not found"}), 404
|
| 159 |
+
except Exception as e:
|
| 160 |
+
return jsonify({"error": str(e)}), 500
|
| 161 |
+
|
| 162 |
+
@app.route('/api/analyze', methods=['POST'])
|
| 163 |
+
def analyze_wafer():
|
| 164 |
+
data = request.json
|
| 165 |
+
if not data:
|
| 166 |
+
return jsonify({"error": "No data provided"}), 400
|
| 167 |
+
|
| 168 |
+
wafer_id = data.get('wafer_id')
|
| 169 |
+
pattern_desc = data.get('pattern_desc', 'Unknown pattern')
|
| 170 |
+
|
| 171 |
+
# Call SiliconFlow
|
| 172 |
+
try:
|
| 173 |
+
headers = {
|
| 174 |
+
"Authorization": f"Bearer {SILICONFLOW_API_KEY}",
|
| 175 |
+
"Content-Type": "application/json"
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
system_prompt = """
|
| 179 |
+
你是一位半导体良率分析专家 (Semiconductor Yield Analysis Expert)。
|
| 180 |
+
请分析描述的晶圆缺陷模式,并提供以下 JSON 格式的响应:
|
| 181 |
+
1. "diagnosis": 可能的根本原因 (Root Cause),例如 '刻蚀偏差 (Etch bias)', '旋涂均匀性 (Spin coat uniformity)', '掩模版颗粒 (Reticle particle)'。
|
| 182 |
+
2. "action": 建议的纠正措施 (Corrective Action)。
|
| 183 |
+
3. "severity": "High" (高), "Medium" (中), 或 "Low" (低)。
|
| 184 |
+
4. "impact": 对器件性能的潜在影响。
|
| 185 |
+
|
| 186 |
+
请只输出有效的 JSON。
|
| 187 |
+
"""
|
| 188 |
+
|
| 189 |
+
user_message = f"晶圆 ID: {wafer_id}. 观察到的缺陷模式: {pattern_desc}. 良率较低。请分析根本原因。"
|
| 190 |
+
|
| 191 |
+
payload = {
|
| 192 |
+
"model": "Qwen/Qwen2.5-7B-Instruct",
|
| 193 |
+
"messages": [
|
| 194 |
+
{"role": "system", "content": system_prompt},
|
| 195 |
+
{"role": "user", "content": user_message}
|
| 196 |
+
],
|
| 197 |
+
"response_format": {"type": "json_object"}
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
# Mock Mode for fallback if API fails or is slow
|
| 201 |
+
try:
|
| 202 |
+
response = requests.post(SILICONFLOW_API_URL, json=payload, headers=headers, timeout=10)
|
| 203 |
+
if response.status_code == 200:
|
| 204 |
+
ai_result = response.json()['choices'][0]['message']['content']
|
| 205 |
+
# Parse JSON string to object
|
| 206 |
+
try:
|
| 207 |
+
ai_json = json.loads(ai_result)
|
| 208 |
+
except:
|
| 209 |
+
# Fallback if model returns text
|
| 210 |
+
ai_json = {
|
| 211 |
+
"diagnosis": "检测到复杂模式 (AI 原始输出)",
|
| 212 |
+
"action": ai_result[:100] + "...",
|
| 213 |
+
"severity": "Medium",
|
| 214 |
+
"impact": "请检查详细日志"
|
| 215 |
+
}
|
| 216 |
+
else:
|
| 217 |
+
raise Exception(f"API Error: {response.status_code}")
|
| 218 |
+
except Exception as e:
|
| 219 |
+
print(f"AI Error: {e}")
|
| 220 |
+
# Mock Fallback
|
| 221 |
+
ai_json = {
|
| 222 |
+
"diagnosis": f"针对 {pattern_desc} 的模拟分析结果",
|
| 223 |
+
"action": "建议立即检查工艺设备校准参数,特别是光刻和刻蚀模块。",
|
| 224 |
+
"severity": "High",
|
| 225 |
+
"impact": "检测到明显的良率损失风险。"
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
return jsonify(ai_json)
|
| 229 |
+
|
| 230 |
+
except Exception as e:
|
| 231 |
+
return jsonify({"error": str(e)}), 500
|
| 232 |
+
|
| 233 |
+
@app.route('/api/upload', methods=['POST'])
|
| 234 |
+
def upload_file():
|
| 235 |
+
if 'file' not in request.files:
|
| 236 |
+
return jsonify({"error": "没有文件部分"}), 400
|
| 237 |
+
file = request.files['file']
|
| 238 |
+
if file.filename == '':
|
| 239 |
+
return jsonify({"error": "未选择文件"}), 400
|
| 240 |
+
if file:
|
| 241 |
+
# In a real app, save the file. Here we just mock the process.
|
| 242 |
+
# file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
|
| 243 |
+
return jsonify({"status": "success", "message": f"文件 {file.filename} 上传成功 (模拟)"})
|
| 244 |
+
return jsonify({"error": "上传失败"}), 500
|
| 245 |
+
|
| 246 |
+
@app.route('/api/save_asset', methods=['POST'])
|
| 247 |
+
def save_asset():
|
| 248 |
+
data = request.json
|
| 249 |
+
if not data:
|
| 250 |
+
return jsonify({"error": "No data"}), 400
|
| 251 |
+
|
| 252 |
+
try:
|
| 253 |
+
with sqlite3.connect(DB_PATH) as conn:
|
| 254 |
+
cursor = conn.cursor()
|
| 255 |
+
cursor.execute('''
|
| 256 |
+
INSERT INTO defect_assets (wafer_db_id, pattern_type, root_cause, recommendation)
|
| 257 |
+
VALUES (?, ?, ?, ?)
|
| 258 |
+
''', (data.get('wafer_id'), data.get('pattern_type'), data.get('root_cause'), data.get('recommendation')))
|
| 259 |
+
conn.commit()
|
| 260 |
+
return jsonify({"status": "success", "message": "Asset saved to Knowledge Vault"})
|
| 261 |
+
except Exception as e:
|
| 262 |
+
return jsonify({"error": str(e)}), 500
|
| 263 |
+
|
| 264 |
+
@app.route('/api/assets', methods=['GET'])
|
| 265 |
+
def get_assets():
|
| 266 |
+
try:
|
| 267 |
+
with sqlite3.connect(DB_PATH) as conn:
|
| 268 |
+
conn.row_factory = sqlite3.Row
|
| 269 |
+
cursor = conn.cursor()
|
| 270 |
+
cursor.execute('''
|
| 271 |
+
SELECT a.*, w.lot_id, w.wafer_id as w_name
|
| 272 |
+
FROM defect_assets a
|
| 273 |
+
JOIN wafers w ON a.wafer_db_id = w.id
|
| 274 |
+
ORDER BY a.id DESC
|
| 275 |
+
''')
|
| 276 |
+
rows = cursor.fetchall()
|
| 277 |
+
return jsonify([dict(row) for row in rows])
|
| 278 |
+
except Exception as e:
|
| 279 |
+
return jsonify({"error": str(e)}), 500
|
| 280 |
+
|
| 281 |
+
if __name__ == '__main__':
|
| 282 |
+
app.run(host='0.0.0.0', port=7860)
|
instance/chip_sense.db
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:772913c1625d9119ca815b5f8420fb05571479edecbe110196a4444431d72217
|
| 3 |
+
size 57344
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
flask
|
| 2 |
+
flask-cors
|
| 3 |
+
requests
|
| 4 |
+
python-dotenv
|
templates/index.html
ADDED
|
@@ -0,0 +1,548 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="zh-CN">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>芯感智能 | Chip Sense AI</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
|
| 9 |
+
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3/dist/echarts.min.js"></script>
|
| 10 |
+
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
|
| 11 |
+
<style>
|
| 12 |
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');
|
| 13 |
+
body { font-family: 'Inter', sans-serif; }
|
| 14 |
+
.glass-panel { background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(10px); border: 1px solid rgba(229, 231, 235, 0.5); }
|
| 15 |
+
[v-cloak] { display: none !important; }
|
| 16 |
+
.toast-enter-active, .toast-leave-active { transition: all 0.5s ease; }
|
| 17 |
+
.toast-enter-from, .toast-leave-to { opacity: 0; transform: translateY(-20px); }
|
| 18 |
+
</style>
|
| 19 |
+
</head>
|
| 20 |
+
<body class="bg-slate-50 text-slate-800 h-screen overflow-hidden">
|
| 21 |
+
<div id="app" v-cloak class="flex h-full flex-col md:flex-row relative">
|
| 22 |
+
<!-- Toast Container -->
|
| 23 |
+
<div class="fixed top-4 right-4 z-50 flex flex-col gap-2">
|
| 24 |
+
<transition-group name="toast">
|
| 25 |
+
<div v-for="toast in toasts" :key="toast.id"
|
| 26 |
+
:class="{'bg-green-500': toast.type === 'success', 'bg-red-500': toast.type === 'error', 'bg-blue-500': toast.type === 'info'}"
|
| 27 |
+
class="text-white px-6 py-3 rounded-lg shadow-lg flex items-center gap-2 min-w-[300px]">
|
| 28 |
+
<i :class="toast.icon" class="fa-solid"></i>
|
| 29 |
+
<span>${ toast.message }</span>
|
| 30 |
+
</div>
|
| 31 |
+
</transition-group>
|
| 32 |
+
</div>
|
| 33 |
+
|
| 34 |
+
<!-- Sidebar (Desktop) / Bottom Nav (Mobile) -->
|
| 35 |
+
<div class="bg-white border-slate-200 flex shadow-sm z-30
|
| 36 |
+
fixed bottom-0 w-full h-16 border-t
|
| 37 |
+
md:relative md:w-64 md:h-full md:border-r md:border-t-0 md:flex-col">
|
| 38 |
+
|
| 39 |
+
<div class="hidden md:flex p-6 border-b border-slate-100 items-center gap-3">
|
| 40 |
+
<div class="w-8 h-8 rounded-lg bg-indigo-600 flex items-center justify-center text-white">
|
| 41 |
+
<i class="fa-solid fa-microchip"></i>
|
| 42 |
+
</div>
|
| 43 |
+
<h1 class="text-xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-indigo-600 to-blue-500">芯感智能</h1>
|
| 44 |
+
</div>
|
| 45 |
+
|
| 46 |
+
<nav class="flex-1 p-2 md:p-4 flex flex-row md:flex-col justify-around md:justify-start gap-1 md:space-y-2">
|
| 47 |
+
<button @click="currentView = 'dashboard'"
|
| 48 |
+
:class="{'text-indigo-600 md:bg-indigo-50': currentView === 'dashboard', 'text-slate-400 hover:bg-slate-50': currentView !== 'dashboard'}"
|
| 49 |
+
class="flex-1 md:flex-none flex flex-col md:flex-row items-center justify-center md:justify-start gap-1 md:gap-3 px-2 md:px-4 py-2 md:py-3 rounded-xl transition-all font-medium text-xs md:text-base">
|
| 50 |
+
<i class="fa-solid fa-chart-line text-lg md:text-base"></i>
|
| 51 |
+
<span>生产概览</span>
|
| 52 |
+
</button>
|
| 53 |
+
<button @click="currentView = 'radar'"
|
| 54 |
+
:class="{'text-indigo-600 md:bg-indigo-50': currentView === 'radar', 'text-slate-400 hover:bg-slate-50': currentView !== 'radar'}"
|
| 55 |
+
class="flex-1 md:flex-none flex flex-col md:flex-row items-center justify-center md:justify-start gap-1 md:gap-3 px-2 md:px-4 py-2 md:py-3 rounded-xl transition-all font-medium text-xs md:text-base">
|
| 56 |
+
<i class="fa-solid fa-circle-nodes text-lg md:text-base"></i>
|
| 57 |
+
<span>晶圆雷达</span>
|
| 58 |
+
</button>
|
| 59 |
+
<button @click="currentView = 'assets'"
|
| 60 |
+
:class="{'text-indigo-600 md:bg-indigo-50': currentView === 'assets', 'text-slate-400 hover:bg-slate-50': currentView !== 'assets'}"
|
| 61 |
+
class="flex-1 md:flex-none flex flex-col md:flex-row items-center justify-center md:justify-start gap-1 md:gap-3 px-2 md:px-4 py-2 md:py-3 rounded-xl transition-all font-medium text-xs md:text-base">
|
| 62 |
+
<i class="fa-solid fa-vault text-lg md:text-base"></i>
|
| 63 |
+
<span>缺陷资产</span>
|
| 64 |
+
</button>
|
| 65 |
+
<div class="h-px bg-slate-100 my-2 mx-4 hidden md:block"></div>
|
| 66 |
+
<button @click="triggerUpload"
|
| 67 |
+
class="flex-1 md:flex-none flex flex-col md:flex-row items-center justify-center md:justify-start gap-1 md:gap-3 px-2 md:px-4 py-2 md:py-3 rounded-xl transition-all font-medium text-xs md:text-base text-slate-400 hover:bg-slate-50 hover:text-indigo-600">
|
| 68 |
+
<i class="fa-solid fa-cloud-arrow-up text-lg md:text-base"></i>
|
| 69 |
+
<span>上传数据</span>
|
| 70 |
+
</button>
|
| 71 |
+
</nav>
|
| 72 |
+
|
| 73 |
+
<div class="hidden md:block p-4 border-t border-slate-100">
|
| 74 |
+
<input type="file" ref="fileInput" class="hidden" @change="handleFileUpload" accept=".json,.csv,.txt">
|
| 75 |
+
<div class="bg-slate-50 rounded-lg p-3 text-xs text-slate-500">
|
| 76 |
+
<div class="flex justify-between mb-1">
|
| 77 |
+
<span>系统状态</span>
|
| 78 |
+
<span class="text-green-500 font-bold">● 在线</span>
|
| 79 |
+
</div>
|
| 80 |
+
<div>版本 1.2.0 (Stable)</div>
|
| 81 |
+
</div>
|
| 82 |
+
</div>
|
| 83 |
+
</div>
|
| 84 |
+
|
| 85 |
+
<!-- Main Content -->
|
| 86 |
+
<div class="flex-1 flex flex-col h-full overflow-hidden relative mb-16 md:mb-0">
|
| 87 |
+
<!-- Top Bar -->
|
| 88 |
+
<header class="h-16 bg-white border-b border-slate-200 flex items-center justify-between px-4 md:px-8 shadow-sm flex-shrink-0">
|
| 89 |
+
<div class="text-sm breadcrumbs text-slate-500">
|
| 90 |
+
<span class="font-semibold text-slate-800">${ viewTitle }</span>
|
| 91 |
+
</div>
|
| 92 |
+
<div class="flex items-center gap-4">
|
| 93 |
+
<div class="flex items-center gap-2 px-3 py-1.5 bg-red-50 text-red-600 rounded-full text-xs font-medium border border-red-100 animate-pulse" v-if="alertCount > 0">
|
| 94 |
+
<i class="fa-solid fa-triangle-exclamation"></i> <span class="hidden md:inline">${ alertCount } 工艺异常警告</span><span class="md:hidden">${ alertCount }</span>
|
| 95 |
+
</div>
|
| 96 |
+
<div class="w-8 h-8 rounded-full bg-slate-200 flex items-center justify-center text-slate-500 cursor-pointer hover:bg-slate-300 transition-colors" title="用户资料">
|
| 97 |
+
<i class="fa-solid fa-user"></i>
|
| 98 |
+
</div>
|
| 99 |
+
</div>
|
| 100 |
+
</header>
|
| 101 |
+
|
| 102 |
+
<!-- Dashboard View -->
|
| 103 |
+
<main v-if="currentView === 'dashboard'" class="flex-1 p-4 md:p-8 overflow-y-auto bg-slate-50/50">
|
| 104 |
+
<div class="grid grid-cols-2 md:grid-cols-4 gap-4 md:gap-6 mb-8">
|
| 105 |
+
<div class="glass-panel p-4 md:p-6 rounded-2xl shadow-sm border-l-4 border-blue-500">
|
| 106 |
+
<div class="text-slate-500 text-sm mb-1">今日良率 (Yield)</div>
|
| 107 |
+
<div class="text-3xl font-bold text-slate-800">92.4%</div>
|
| 108 |
+
<div class="text-xs text-green-500 mt-2 flex items-center gap-1"><i class="fa-solid fa-arrow-trend-up"></i> +1.2% 较昨日</div>
|
| 109 |
+
</div>
|
| 110 |
+
<div class="glass-panel p-6 rounded-2xl shadow-sm border-l-4 border-indigo-500">
|
| 111 |
+
<div class="text-slate-500 text-sm mb-1">产出晶圆 (Wafers)</div>
|
| 112 |
+
<div class="text-3xl font-bold text-slate-800">1,248</div>
|
| 113 |
+
<div class="text-xs text-slate-400 mt-2">目标: 1,200</div>
|
| 114 |
+
</div>
|
| 115 |
+
<div class="glass-panel p-6 rounded-2xl shadow-sm border-l-4 border-yellow-500">
|
| 116 |
+
<div class="text-slate-500 text-sm mb-1">缺陷密度 (Defect Density)</div>
|
| 117 |
+
<div class="text-3xl font-bold text-slate-800">0.45</div>
|
| 118 |
+
<div class="text-xs text-red-500 mt-2 flex items-center gap-1"><i class="fa-solid fa-arrow-trend-up"></i> 高危警报</div>
|
| 119 |
+
</div>
|
| 120 |
+
<div class="glass-panel p-6 rounded-2xl shadow-sm border-l-4 border-green-500">
|
| 121 |
+
<div class="text-slate-500 text-sm mb-1">设备稼动率 (OEE)</div>
|
| 122 |
+
<div class="text-3xl font-bold text-slate-800">98.2%</div>
|
| 123 |
+
<div class="text-xs text-green-500 mt-2">运行平稳</div>
|
| 124 |
+
</div>
|
| 125 |
+
</div>
|
| 126 |
+
|
| 127 |
+
<div class="grid grid-cols-1 md:grid-cols-3 gap-6 h-auto md:h-[500px]">
|
| 128 |
+
<div class="md:col-span-2 glass-panel p-6 rounded-2xl shadow-sm flex flex-col h-[300px] md:h-full">
|
| 129 |
+
<h3 class="font-bold text-slate-700 mb-4 flex items-center gap-2">
|
| 130 |
+
<i class="fa-solid fa-chart-area text-blue-500"></i> 良率趋势监控 (Yield Trend)
|
| 131 |
+
</h3>
|
| 132 |
+
<div id="yieldChart" class="flex-1 w-full h-full"></div>
|
| 133 |
+
</div>
|
| 134 |
+
<div class="glass-panel p-6 rounded-2xl shadow-sm overflow-hidden flex flex-col h-[300px] md:h-full">
|
| 135 |
+
<h3 class="font-bold text-slate-700 mb-4">最近批次 (Recent Lots)</h3>
|
| 136 |
+
<div class="overflow-y-auto flex-1 pr-2">
|
| 137 |
+
<div v-for="w in wafers" :key="w.id" @click="selectWafer(w); currentView = 'radar'"
|
| 138 |
+
class="p-4 mb-3 bg-white border border-slate-100 rounded-xl hover:border-indigo-300 cursor-pointer transition-all hover:shadow-md group">
|
| 139 |
+
<div class="flex justify-between items-center mb-2">
|
| 140 |
+
<span class="font-mono font-bold text-slate-700 group-hover:text-indigo-600">${ w.lot_id } - ${ w.wafer_id }</span>
|
| 141 |
+
<span :class="getStatusColor(w.yield_rate)" class="px-2 py-0.5 rounded text-xs font-bold">${ w.yield_rate.toFixed(1) }%</span>
|
| 142 |
+
</div>
|
| 143 |
+
<div class="text-xs text-slate-400 flex justify-between">
|
| 144 |
+
<span>${ formatDate(w.timestamp) }</span>
|
| 145 |
+
<span class="capitalize">${ w.status }</span>
|
| 146 |
+
</div>
|
| 147 |
+
</div>
|
| 148 |
+
</div>
|
| 149 |
+
</div>
|
| 150 |
+
</div>
|
| 151 |
+
</main>
|
| 152 |
+
|
| 153 |
+
<!-- Wafer Radar View -->
|
| 154 |
+
<main v-if="currentView === 'radar'" class="flex-1 flex flex-col md:flex-row h-full overflow-hidden">
|
| 155 |
+
<!-- Left: Wafer Map -->
|
| 156 |
+
<div class="flex-1 bg-slate-900 p-4 md:p-8 flex flex-col relative overflow-hidden min-h-[400px]">
|
| 157 |
+
<!-- Background Grid Effect -->
|
| 158 |
+
<div class="absolute inset-0 opacity-10" style="background-image: radial-gradient(#4f46e5 1px, transparent 1px); background-size: 30px 30px;"></div>
|
| 159 |
+
|
| 160 |
+
<div class="flex justify-between items-center mb-4 z-10">
|
| 161 |
+
<h2 class="text-white text-xl font-mono flex items-center gap-3">
|
| 162 |
+
<span class="w-3 h-3 rounded-full bg-green-400 animate-pulse"></span>
|
| 163 |
+
WAFER RADAR: ${ selectedWafer ? selectedWafer.lot_id + '-' + selectedWafer.wafer_id : 'NO SIGNAL' }
|
| 164 |
+
</h2>
|
| 165 |
+
<div class="flex gap-2">
|
| 166 |
+
<button @click="fetchWafers" class="px-3 py-1 bg-slate-700 text-slate-300 rounded hover:bg-slate-600 text-sm">刷新数据流</button>
|
| 167 |
+
</div>
|
| 168 |
+
</div>
|
| 169 |
+
|
| 170 |
+
<div class="flex-1 flex items-center justify-center relative z-10">
|
| 171 |
+
<div id="waferMap" class="w-full h-full md:w-[600px] md:h-[600px]"></div>
|
| 172 |
+
<!-- Overlay Stats -->
|
| 173 |
+
<div v-if="selectedWafer" class="absolute top-4 right-4 bg-slate-800/80 backdrop-blur p-4 rounded-lg border border-slate-700 text-white w-48 hidden md:block">
|
| 174 |
+
<div class="text-xs text-slate-400">良率 (Yield Rate)</div>
|
| 175 |
+
<div class="text-2xl font-mono font-bold text-green-400 mb-2">${ selectedWafer.yield_rate.toFixed(1) }%</div>
|
| 176 |
+
<div class="text-xs text-slate-400">总芯片数 (Total Dies)</div>
|
| 177 |
+
<div class="text-lg font-mono">400</div>
|
| 178 |
+
<div class="text-xs text-slate-400 mt-2">状态 (Status)</div>
|
| 179 |
+
<div class="text-sm font-bold uppercase text-yellow-400">${ selectedWafer.status }</div>
|
| 180 |
+
</div>
|
| 181 |
+
</div>
|
| 182 |
+
</div>
|
| 183 |
+
|
| 184 |
+
<!-- Right: Analysis Panel -->
|
| 185 |
+
<div class="w-full md:w-[400px] h-1/2 md:h-full bg-white border-l border-slate-200 flex flex-col shadow-xl z-20">
|
| 186 |
+
<div class="p-6 border-b border-slate-100">
|
| 187 |
+
<h3 class="font-bold text-slate-800 flex items-center gap-2">
|
| 188 |
+
<i class="fa-solid fa-brain text-indigo-600"></i> AI 缺陷分析 (Analysis)
|
| 189 |
+
</h3>
|
| 190 |
+
</div>
|
| 191 |
+
|
| 192 |
+
<div class="flex-1 p-6 overflow-y-auto">
|
| 193 |
+
<div v-if="!selectedWafer" class="text-center text-slate-400 mt-20">
|
| 194 |
+
<i class="fa-solid fa-microchip text-4xl mb-4 opacity-30"></i>
|
| 195 |
+
<p>请选择一个晶圆开始分析</p>
|
| 196 |
+
</div>
|
| 197 |
+
|
| 198 |
+
<div v-else class="space-y-6">
|
| 199 |
+
<!-- Analysis Status -->
|
| 200 |
+
<div v-if="isAnalyzing" class="flex flex-col items-center justify-center py-8 space-y-4">
|
| 201 |
+
<div class="w-12 h-12 border-4 border-indigo-100 border-t-indigo-600 rounded-full animate-spin"></div>
|
| 202 |
+
<p class="text-indigo-600 font-medium animate-pulse">SiliconFlow AI 正在分析中...</p>
|
| 203 |
+
</div>
|
| 204 |
+
|
| 205 |
+
<!-- Analysis Result -->
|
| 206 |
+
<div v-if="analysisResult && !isAnalyzing" class="space-y-4 animate-fade-in">
|
| 207 |
+
<div class="bg-indigo-50 border border-indigo-100 rounded-xl p-4">
|
| 208 |
+
<div class="text-xs text-indigo-500 uppercase font-bold tracking-wider mb-1">AI 诊断结果</div>
|
| 209 |
+
<div class="font-bold text-slate-800 text-lg">${ analysisResult.diagnosis }</div>
|
| 210 |
+
</div>
|
| 211 |
+
|
| 212 |
+
<div class="space-y-2">
|
| 213 |
+
<div class="text-xs text-slate-400 font-bold uppercase">根本原因分析</div>
|
| 214 |
+
<p class="text-sm text-slate-600 leading-relaxed bg-slate-50 p-3 rounded-lg border border-slate-100">
|
| 215 |
+
${ analysisResult.action }
|
| 216 |
+
</p>
|
| 217 |
+
</div>
|
| 218 |
+
|
| 219 |
+
<div class="flex gap-4">
|
| 220 |
+
<div class="flex-1 bg-red-50 p-3 rounded-lg border border-red-100">
|
| 221 |
+
<div class="text-xs text-red-400 mb-1">严重程度</div>
|
| 222 |
+
<div class="font-bold text-red-600">${ analysisResult.severity }</div>
|
| 223 |
+
</div>
|
| 224 |
+
<div class="flex-1 bg-amber-50 p-3 rounded-lg border border-amber-100">
|
| 225 |
+
<div class="text-xs text-amber-400 mb-1">潜在影响</div>
|
| 226 |
+
<div class="font-bold text-amber-600 text-sm truncate" :title="analysisResult.impact">${ analysisResult.impact }</div>
|
| 227 |
+
</div>
|
| 228 |
+
</div>
|
| 229 |
+
</div>
|
| 230 |
+
</div>
|
| 231 |
+
</div>
|
| 232 |
+
|
| 233 |
+
<div class="p-6 border-t border-slate-100 bg-slate-50">
|
| 234 |
+
<button v-if="!analysisResult" @click="runAnalysis" :disabled="!selectedWafer || isAnalyzing"
|
| 235 |
+
class="w-full py-3 bg-indigo-600 hover:bg-indigo-700 text-white rounded-xl font-bold shadow-lg shadow-indigo-200 transition-all disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2">
|
| 236 |
+
<i class="fa-solid fa-wand-magic-sparkles"></i> 运行 AI 诊断
|
| 237 |
+
</button>
|
| 238 |
+
<button v-else @click="saveAsset" :disabled="isSaving"
|
| 239 |
+
class="w-full py-3 bg-green-600 hover:bg-green-700 text-white rounded-xl font-bold shadow-lg shadow-green-200 transition-all flex items-center justify-center gap-2">
|
| 240 |
+
<i class="fa-solid fa-floppy-disk"></i> 保存到知识库
|
| 241 |
+
</button>
|
| 242 |
+
</div>
|
| 243 |
+
</div>
|
| 244 |
+
</main>
|
| 245 |
+
|
| 246 |
+
<!-- Assets View -->
|
| 247 |
+
<main v-if="currentView === 'assets'" class="flex-1 p-8 overflow-y-auto bg-slate-50">
|
| 248 |
+
<div class="max-w-5xl mx-auto">
|
| 249 |
+
<div class="flex justify-between items-center mb-8">
|
| 250 |
+
<div>
|
| 251 |
+
<h2 class="text-2xl font-bold text-slate-800">缺陷资产库 (Defect Vault)</h2>
|
| 252 |
+
<p class="text-slate-500">工艺改进的企业知识库</p>
|
| 253 |
+
</div>
|
| 254 |
+
<div class="bg-white px-4 py-2 rounded-lg shadow-sm border border-slate-200 flex items-center gap-2">
|
| 255 |
+
<i class="fa-solid fa-search text-slate-400"></i>
|
| 256 |
+
<input type="text" placeholder="搜索资产..." class="outline-none text-sm w-48">
|
| 257 |
+
</div>
|
| 258 |
+
</div>
|
| 259 |
+
|
| 260 |
+
<div class="grid gap-4">
|
| 261 |
+
<div v-for="asset in assets" :key="asset.id" class="bg-white p-6 rounded-xl shadow-sm border border-slate-100 hover:shadow-md transition-all flex gap-6">
|
| 262 |
+
<div class="w-16 h-16 bg-red-50 rounded-lg flex items-center justify-center flex-shrink-0 text-red-500 text-2xl">
|
| 263 |
+
<i class="fa-solid fa-bug"></i>
|
| 264 |
+
</div>
|
| 265 |
+
<div class="flex-1">
|
| 266 |
+
<div class="flex justify-between items-start mb-2">
|
| 267 |
+
<h3 class="font-bold text-slate-800 text-lg">${ asset.pattern_type } 模式分析</h3>
|
| 268 |
+
<span class="text-xs text-slate-400 font-mono bg-slate-50 px-2 py-1 rounded">${ asset.timestamp }</span>
|
| 269 |
+
</div>
|
| 270 |
+
<div class="grid grid-cols-2 gap-4 text-sm mb-3">
|
| 271 |
+
<div>
|
| 272 |
+
<span class="text-slate-400">晶圆:</span>
|
| 273 |
+
<span class="font-mono text-indigo-600 font-medium">${ asset.lot_id }-${ asset.w_name }</span>
|
| 274 |
+
</div>
|
| 275 |
+
<div>
|
| 276 |
+
<span class="text-slate-400">根本原因:</span>
|
| 277 |
+
<span class="font-medium text-slate-700">${ asset.root_cause }</span>
|
| 278 |
+
</div>
|
| 279 |
+
</div>
|
| 280 |
+
<div class="bg-green-50 text-green-800 p-3 rounded-lg text-sm border border-green-100">
|
| 281 |
+
<i class="fa-solid fa-check-circle mr-1"></i> 建议: ${ asset.recommendation }
|
| 282 |
+
</div>
|
| 283 |
+
</div>
|
| 284 |
+
</div>
|
| 285 |
+
</div>
|
| 286 |
+
</div>
|
| 287 |
+
</main>
|
| 288 |
+
</div>
|
| 289 |
+
</div>
|
| 290 |
+
|
| 291 |
+
<script>
|
| 292 |
+
const { createApp, ref, onMounted, watch, computed } = Vue;
|
| 293 |
+
|
| 294 |
+
createApp({
|
| 295 |
+
delimiters: ['${', '}'],
|
| 296 |
+
setup() {
|
| 297 |
+
const currentView = ref('dashboard');
|
| 298 |
+
const wafers = ref([]);
|
| 299 |
+
const selectedWafer = ref(null);
|
| 300 |
+
const isAnalyzing = ref(false);
|
| 301 |
+
const analysisResult = ref(null);
|
| 302 |
+
const isSaving = ref(false);
|
| 303 |
+
const assets = ref([]);
|
| 304 |
+
const alertCount = ref(3);
|
| 305 |
+
const toasts = ref([]);
|
| 306 |
+
const fileInput = ref(null);
|
| 307 |
+
|
| 308 |
+
// ECharts Instances
|
| 309 |
+
let mapChart = null;
|
| 310 |
+
let trendChart = null;
|
| 311 |
+
|
| 312 |
+
const viewTitle = computed(() => {
|
| 313 |
+
const titles = { 'dashboard': '生产概览 (Production Dashboard)', 'radar': '晶圆分析 (Wafer Map Analysis)', 'assets': '知识库 (Knowledge Vault)' };
|
| 314 |
+
return titles[currentView.value];
|
| 315 |
+
});
|
| 316 |
+
|
| 317 |
+
const showToast = (message, type = 'info', icon = 'fa-circle-info') => {
|
| 318 |
+
const id = Date.now();
|
| 319 |
+
toasts.value.push({ id, message, type, icon });
|
| 320 |
+
setTimeout(() => {
|
| 321 |
+
toasts.value = toasts.value.filter(t => t.id !== id);
|
| 322 |
+
}, 3000);
|
| 323 |
+
};
|
| 324 |
+
|
| 325 |
+
const triggerUpload = () => {
|
| 326 |
+
fileInput.value.click();
|
| 327 |
+
};
|
| 328 |
+
|
| 329 |
+
const handleFileUpload = async (event) => {
|
| 330 |
+
const file = event.target.files[0];
|
| 331 |
+
if (!file) return;
|
| 332 |
+
|
| 333 |
+
const formData = new FormData();
|
| 334 |
+
formData.append('file', file);
|
| 335 |
+
|
| 336 |
+
try {
|
| 337 |
+
const res = await fetch('/api/upload', {
|
| 338 |
+
method: 'POST',
|
| 339 |
+
body: formData
|
| 340 |
+
});
|
| 341 |
+
const data = await res.json();
|
| 342 |
+
if (res.ok) {
|
| 343 |
+
showToast(data.message, 'success', 'fa-check-circle');
|
| 344 |
+
} else {
|
| 345 |
+
showToast(data.error || '上传失败', 'error', 'fa-circle-xmark');
|
| 346 |
+
}
|
| 347 |
+
} catch (e) {
|
| 348 |
+
showToast('网络错误', 'error', 'fa-wifi');
|
| 349 |
+
}
|
| 350 |
+
// Reset input
|
| 351 |
+
event.target.value = '';
|
| 352 |
+
};
|
| 353 |
+
|
| 354 |
+
const fetchWafers = async () => {
|
| 355 |
+
try {
|
| 356 |
+
const res = await fetch('/api/wafers');
|
| 357 |
+
if (!res.ok) throw new Error("API Error");
|
| 358 |
+
wafers.value = await res.json();
|
| 359 |
+
if (wafers.value.length > 0 && !selectedWafer.value) {
|
| 360 |
+
selectWafer(wafers.value[0]);
|
| 361 |
+
}
|
| 362 |
+
} catch (e) {
|
| 363 |
+
showToast("无法获取晶圆数据", "error", "fa-server");
|
| 364 |
+
}
|
| 365 |
+
};
|
| 366 |
+
|
| 367 |
+
const fetchAssets = async () => {
|
| 368 |
+
try {
|
| 369 |
+
const res = await fetch('/api/assets');
|
| 370 |
+
assets.value = await res.json();
|
| 371 |
+
} catch (e) {
|
| 372 |
+
console.error(e);
|
| 373 |
+
}
|
| 374 |
+
};
|
| 375 |
+
|
| 376 |
+
const selectWafer = async (wafer) => {
|
| 377 |
+
// Fetch detailed data
|
| 378 |
+
try {
|
| 379 |
+
const res = await fetch(`/api/wafer/${wafer.id}`);
|
| 380 |
+
if (!res.ok) throw new Error("Wafer not found");
|
| 381 |
+
selectedWafer.value = await res.json();
|
| 382 |
+
analysisResult.value = null; // Reset analysis
|
| 383 |
+
|
| 384 |
+
if (currentView.value === 'radar') {
|
| 385 |
+
setTimeout(initMapChart, 100);
|
| 386 |
+
}
|
| 387 |
+
} catch (e) {
|
| 388 |
+
showToast("无法加载详情", "error", "fa-file-circle-xmark");
|
| 389 |
+
}
|
| 390 |
+
};
|
| 391 |
+
|
| 392 |
+
const runAnalysis = async () => {
|
| 393 |
+
if (!selectedWafer.value) return;
|
| 394 |
+
isAnalyzing.value = true;
|
| 395 |
+
try {
|
| 396 |
+
const res = await fetch('/api/analyze', {
|
| 397 |
+
method: 'POST',
|
| 398 |
+
headers: {'Content-Type': 'application/json'},
|
| 399 |
+
body: JSON.stringify({
|
| 400 |
+
wafer_id: selectedWafer.value.wafer_id,
|
| 401 |
+
pattern_desc: selectedWafer.value.status + " 模式检测到良率为 " + selectedWafer.value.yield_rate.toFixed(1) + "%"
|
| 402 |
+
})
|
| 403 |
+
});
|
| 404 |
+
if (!res.ok) throw new Error("Analysis failed");
|
| 405 |
+
analysisResult.value = await res.json();
|
| 406 |
+
showToast("AI 分析完成", "success", "fa-wand-magic-sparkles");
|
| 407 |
+
} catch (e) {
|
| 408 |
+
console.error(e);
|
| 409 |
+
showToast("分析失败: " + e.message, "error", "fa-triangle-exclamation");
|
| 410 |
+
} finally {
|
| 411 |
+
isAnalyzing.value = false;
|
| 412 |
+
}
|
| 413 |
+
};
|
| 414 |
+
|
| 415 |
+
const saveAsset = async () => {
|
| 416 |
+
if (!analysisResult.value) return;
|
| 417 |
+
isSaving.value = true;
|
| 418 |
+
try {
|
| 419 |
+
await fetch('/api/save_asset', {
|
| 420 |
+
method: 'POST',
|
| 421 |
+
headers: {'Content-Type': 'application/json'},
|
| 422 |
+
body: JSON.stringify({
|
| 423 |
+
wafer_id: selectedWafer.value.id,
|
| 424 |
+
pattern_type: selectedWafer.value.status,
|
| 425 |
+
root_cause: analysisResult.value.diagnosis,
|
| 426 |
+
recommendation: analysisResult.value.action
|
| 427 |
+
})
|
| 428 |
+
});
|
| 429 |
+
showToast("已保存到知识库", "success", "fa-floppy-disk");
|
| 430 |
+
fetchAssets();
|
| 431 |
+
} catch (e) {
|
| 432 |
+
console.error(e);
|
| 433 |
+
showToast("保存失败", "error", "fa-circle-xmark");
|
| 434 |
+
} finally {
|
| 435 |
+
isSaving.value = false;
|
| 436 |
+
}
|
| 437 |
+
};
|
| 438 |
+
|
| 439 |
+
const initMapChart = () => {
|
| 440 |
+
if (!selectedWafer.value) return;
|
| 441 |
+
const chartDom = document.getElementById('waferMap');
|
| 442 |
+
if (!chartDom) return;
|
| 443 |
+
|
| 444 |
+
if (mapChart) mapChart.dispose();
|
| 445 |
+
mapChart = echarts.init(chartDom);
|
| 446 |
+
|
| 447 |
+
const option = {
|
| 448 |
+
tooltip: { position: 'top' },
|
| 449 |
+
grid: { height: '80%', top: '10%' },
|
| 450 |
+
xAxis: { type: 'category', show: false },
|
| 451 |
+
yAxis: { type: 'category', show: false },
|
| 452 |
+
visualMap: {
|
| 453 |
+
min: 0,
|
| 454 |
+
max: 1,
|
| 455 |
+
calculable: false,
|
| 456 |
+
orient: 'horizontal',
|
| 457 |
+
left: 'center',
|
| 458 |
+
bottom: '5%',
|
| 459 |
+
inRange: { color: ['#22c55e', '#ef4444'] }, // Green for 0 (Pass), Red for 1 (Fail)
|
| 460 |
+
text: ['失效 (Fail)', '通过 (Pass)'],
|
| 461 |
+
textStyle: { color: '#fff' }
|
| 462 |
+
},
|
| 463 |
+
series: [{
|
| 464 |
+
name: '芯片状态',
|
| 465 |
+
type: 'heatmap',
|
| 466 |
+
data: selectedWafer.value.map_data,
|
| 467 |
+
itemStyle: {
|
| 468 |
+
borderColor: '#1e293b',
|
| 469 |
+
borderWidth: 1
|
| 470 |
+
},
|
| 471 |
+
emphasis: {
|
| 472 |
+
itemStyle: { shadowBlur: 10, shadowColor: 'rgba(0, 0, 0, 0.5)' }
|
| 473 |
+
}
|
| 474 |
+
}]
|
| 475 |
+
};
|
| 476 |
+
mapChart.setOption(option);
|
| 477 |
+
};
|
| 478 |
+
|
| 479 |
+
const initTrendChart = () => {
|
| 480 |
+
const chartDom = document.getElementById('yieldChart');
|
| 481 |
+
if (!chartDom) return;
|
| 482 |
+
|
| 483 |
+
trendChart = echarts.init(chartDom);
|
| 484 |
+
const option = {
|
| 485 |
+
grid: { top: 30, right: 30, bottom: 30, left: 50 },
|
| 486 |
+
tooltip: { trigger: 'axis' },
|
| 487 |
+
xAxis: {
|
| 488 |
+
type: 'category',
|
| 489 |
+
data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
|
| 490 |
+
axisLine: { lineStyle: { color: '#94a3b8' } }
|
| 491 |
+
},
|
| 492 |
+
yAxis: {
|
| 493 |
+
type: 'value',
|
| 494 |
+
min: 80,
|
| 495 |
+
max: 100,
|
| 496 |
+
axisLine: { lineStyle: { color: '#94a3b8' } },
|
| 497 |
+
splitLine: { lineStyle: { type: 'dashed' } }
|
| 498 |
+
},
|
| 499 |
+
series: [{
|
| 500 |
+
name: '良率',
|
| 501 |
+
data: [91, 93, 90, 94, 92, 95, 92],
|
| 502 |
+
type: 'line',
|
| 503 |
+
smooth: true,
|
| 504 |
+
areaStyle: {
|
| 505 |
+
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
| 506 |
+
{ offset: 0, color: 'rgba(99, 102, 241, 0.5)' },
|
| 507 |
+
{ offset: 1, color: 'rgba(99, 102, 241, 0.0)' }
|
| 508 |
+
])
|
| 509 |
+
},
|
| 510 |
+
lineStyle: { color: '#6366f1', width: 3 },
|
| 511 |
+
symbolSize: 8
|
| 512 |
+
}]
|
| 513 |
+
};
|
| 514 |
+
trendChart.setOption(option);
|
| 515 |
+
};
|
| 516 |
+
|
| 517 |
+
const getStatusColor = (rate) => {
|
| 518 |
+
if (rate > 95) return 'bg-green-100 text-green-700';
|
| 519 |
+
if (rate > 90) return 'bg-yellow-100 text-yellow-700';
|
| 520 |
+
return 'bg-red-100 text-red-700';
|
| 521 |
+
};
|
| 522 |
+
|
| 523 |
+
const formatDate = (ts) => {
|
| 524 |
+
return new Date(ts).toLocaleString('zh-CN');
|
| 525 |
+
};
|
| 526 |
+
|
| 527 |
+
watch(currentView, (newView) => {
|
| 528 |
+
setTimeout(() => {
|
| 529 |
+
if (newView === 'dashboard') initTrendChart();
|
| 530 |
+
if (newView === 'radar') initMapChart();
|
| 531 |
+
if (newView === 'assets') fetchAssets();
|
| 532 |
+
}, 100);
|
| 533 |
+
});
|
| 534 |
+
|
| 535 |
+
onMounted(() => {
|
| 536 |
+
fetchWafers();
|
| 537 |
+
setTimeout(initTrendChart, 500); // Wait for DOM
|
| 538 |
+
});
|
| 539 |
+
|
| 540 |
+
return {
|
| 541 |
+
currentView, wafers, selectedWafer, isAnalyzing, analysisResult, isSaving, assets, alertCount, viewTitle, toasts, fileInput,
|
| 542 |
+
selectWafer, runAnalysis, saveAsset, fetchWafers, getStatusColor, formatDate, triggerUpload, handleFileUpload
|
| 543 |
+
};
|
| 544 |
+
}
|
| 545 |
+
}).mount('#app');
|
| 546 |
+
</script>
|
| 547 |
+
</body>
|
| 548 |
+
</html>
|