初始化2

This commit is contained in:
SunYF
2026-08-28 15:06:01 +08:00
parent b34325a16f
commit a9c3fbeb41
537 changed files with 176215 additions and 17 deletions
+125
View File
@@ -0,0 +1,125 @@
import type { DashboardData, Station, ToolStatus } from './types';
/** 生成演示设备状态(装配线:扫码枪 + 拧紧枪) */
function buildStations(): Station[] {
const statusPool: ToolStatus[] = ['online', 'busy', 'busy', 'online', 'alarm', 'busy'];
return Array.from({ length: 12 }, (_, i) => {
const id = i + 1;
const scan = statusPool[id % statusPool.length];
const tight: ToolStatus =
id % 6 === 0 ? 'offline' : id % 5 === 0 ? 'alarm' : 'busy';
const css = scan === 'alarm' || tight === 'alarm' ? 'alarm' : 'running';
return {
id,
name: `工位${id}`,
status: id % 6 === 0 ? 'offline' : css,
scanGun: { status: scan, processedCount: 30 + id * 13 },
tighteningGun: {
status: tight,
currentSn: tight === 'busy' ? `SN-${2500 + id * 7}` : undefined,
processedCount: 28 + id * 11,
},
currentSn: `SN-${2400 + id * 5}`,
};
});
}
/** 演示数据(无 MES 时使用,页面不空白) */
export function getMockData(): DashboardData {
const now = Date.now();
const hour = new Date().getHours();
const trends = Array.from({ length: 12 }, (_, i) => {
const t = new Date(now - (11 - i) * 30 * 60_000);
const hh = `${String(t.getHours()).padStart(2, '0')}:${String(
t.getMinutes(),
).padStart(2, '0')}`;
return {
time: hh,
output: 18 + i * 4 + (i % 3),
qualifiedRate: 94 + (i % 5),
};
});
return {
production: {
outputToday: 168 + hour,
targetToday: 260,
qualifiedRate: 96.4,
qualityOk: 162,
qualityNg: 6,
stationSummary: { running: 10, idle: 1, offline: 1, alarm: 1 },
},
warehouse: {
totalStock: 12860,
materialTypes: 46,
inboundToday: 1320,
outboundToday: 890,
movements: [
{ id: 'm1', time: '09:12', type: 'in', material: '电路板 PCBA-01', qty: 200, operator: '李工' },
{ id: 'm2', time: '09:28', type: 'out', material: '装配螺丝 M6', qty: 500, operator: '王工' },
{ id: 'm3', time: '10:05', type: 'in', material: '外壳上盖-铝合金', qty: 120, operator: '李工' },
{ id: 'm4', time: '10:41', type: 'out', material: '密封圈 硅胶', qty: 300, operator: '赵工' },
{ id: 'm5', time: '11:03', type: 'in', material: '端子排 T-38', qty: 80, operator: '李工' },
{ id: 'm6', time: '11:20', type: 'out', material: '装配螺栓 M8', qty: 460, operator: '王工' },
],
},
equipment: buildStations(),
progress: {
orderNo: 'WO-20260828-007',
productName: '智能电能表 DDS-02',
totalQty: 260,
doneQty: 168,
completedQty: 162,
currentProcess: '工序8 / 12',
status: '生产中',
},
alarms: [
{
id: 'a1',
level: 'critical',
type: 'equipment',
target: '工位6 拧紧枪',
message: '拧紧扭矩超上限(目标 5.0 N·m,实测 5.6 N·m)',
time: '10:52',
status: 'active',
},
{
id: 'a2',
level: 'warning',
type: 'material',
target: '工位4',
message: '结构件 装配螺丝 M6 余量不足(剩余 12 件)',
time: '11:08',
status: 'active',
},
{
id: 'a3',
level: 'critical',
type: 'equipment',
target: '工位6 扫码枪',
message: '连续 5 次扫码未识别',
time: '11:12',
status: 'active',
},
{
id: 'a4',
level: 'warning',
type: 'material',
target: '库房',
message: '端子排 T-38 库存低于安全库存',
time: '11:15',
status: 'active',
},
{
id: 'a5',
level: 'warning',
type: 'equipment',
target: '工位3 拧紧枪',
message: '角度偏差过大,已复检',
time: '09:44',
status: 'resolved',
},
],
trends: { production: trends },
};
}