refactor: 移除库位状态相关代码,简化组件逻辑并清理未使用的功能
This commit is contained in:
parent
0a4f25bde6
commit
d5b7a29163
@ -16,7 +16,6 @@ export interface MapPen extends Pen {
|
|||||||
activeAttrs?: Array<string>; // 已激活的额外属性
|
activeAttrs?: Array<string>; // 已激活的额外属性
|
||||||
|
|
||||||
properties?: unknown; // 第三方附加参数
|
properties?: unknown; // 第三方附加参数
|
||||||
storageStatus?: Record<string, unknown>; // 库位状态
|
|
||||||
statusStyle?: string; // 状态颜色
|
statusStyle?: string; // 状态颜色
|
||||||
strokeStyle?: string; // 边框颜色
|
strokeStyle?: string; // 边框颜色
|
||||||
}
|
}
|
||||||
@ -49,7 +48,6 @@ export interface MapAreaInfo {
|
|||||||
routes?: Array<string>; // 绑定线路id集合
|
routes?: Array<string>; // 绑定线路id集合
|
||||||
maxAmr?: number; // 最大可容纳AMR数
|
maxAmr?: number; // 最大可容纳AMR数
|
||||||
inoutflag?: 1 | 2; // 库区规则
|
inoutflag?: 1 | 2; // 库区规则
|
||||||
storageLocations?: Record<string, string[]>; // 动作点ID对应的库位信息(内部使用)
|
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
@ -52,13 +52,6 @@ const mapAreas = (type: MapAreaType): string => {
|
|||||||
};
|
};
|
||||||
const coArea1 = computed<string>(() => mapAreas(MapAreaType.库区));
|
const coArea1 = computed<string>(() => mapAreas(MapAreaType.库区));
|
||||||
const coArea2 = computed<string>(() => mapAreas(MapAreaType.互斥区));
|
const coArea2 = computed<string>(() => mapAreas(MapAreaType.互斥区));
|
||||||
const storageStatus = computed<string>(() => {
|
|
||||||
const status = pen.value?.storageStatus;
|
|
||||||
if (!status) return '暂无';
|
|
||||||
return Object.entries(status)
|
|
||||||
.map(([key, value]) => `${key}: ${value}`)
|
|
||||||
.join(', ');
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -126,12 +119,6 @@ const storageStatus = computed<string>(() => {
|
|||||||
<a-typography-text>{{ coArea2 || $t('暂无') }}</a-typography-text>
|
<a-typography-text>{{ coArea2 || $t('暂无') }}</a-typography-text>
|
||||||
</a-flex>
|
</a-flex>
|
||||||
</a-list-item>
|
</a-list-item>
|
||||||
<a-list-item v-if="point.type === MapPointType.动作点">
|
|
||||||
<a-flex :gap="8" vertical>
|
|
||||||
<a-typography-text type="secondary">{{ $t('库位状态') }}</a-typography-text>
|
|
||||||
<a-typography-text>{{ storageStatus }}</a-typography-text>
|
|
||||||
</a-flex>
|
|
||||||
</a-list-item>
|
|
||||||
</a-list>
|
</a-list>
|
||||||
</template>
|
</template>
|
||||||
<a-empty v-else :image="sTheme.empty" />
|
<a-empty v-else :image="sTheme.empty" />
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { MapPointType } from '@api/map';
|
|
||||||
import type { RobotRealtimeInfo } from '@api/robot';
|
import type { RobotRealtimeInfo } from '@api/robot';
|
||||||
import { getSceneByGroupId, getSceneById, monitorRealSceneById, monitorSceneById } from '@api/scene';
|
import { getSceneByGroupId, getSceneById, monitorRealSceneById, monitorSceneById } from '@api/scene';
|
||||||
import { EditorService } from '@core/editor.service';
|
import { EditorService } from '@core/editor.service';
|
||||||
@ -47,53 +46,6 @@ const monitorScene = async () => {
|
|||||||
};
|
};
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region 新增: 监控库位状态
|
|
||||||
const storageStatusClient = shallowRef<WebSocket>();
|
|
||||||
|
|
||||||
const monitorStorageStatus = async () => {
|
|
||||||
storageStatusClient.value?.close();
|
|
||||||
// const ws = await monitorStorageStatusById(props.sid);
|
|
||||||
// if (isNil(ws)) return;
|
|
||||||
|
|
||||||
// --- WebSocket Simulation Start ---
|
|
||||||
const messageHandler = (data: string) => {
|
|
||||||
const { locationName, statusValue, statusAttributes } = JSON.parse(data || '{}');
|
|
||||||
if (!locationName) return;
|
|
||||||
const pen = editor.value?.find(locationName)[0];
|
|
||||||
if (pen?.id) {
|
|
||||||
editor.value?.refreshPoint(pen.id, { status: statusValue, attributes: statusAttributes });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const simulationTimer = setInterval(() => {
|
|
||||||
if (!editor.value) return;
|
|
||||||
// 仅针对动作点进行模拟
|
|
||||||
const actionPoints = editor.value.find('point').filter((p) => p.point?.type === MapPointType.动作点);
|
|
||||||
if (!actionPoints.length) return;
|
|
||||||
|
|
||||||
const randomPoint = actionPoints[Math.floor(Math.random() * actionPoints.length)];
|
|
||||||
const statuses = ['Occupied', 'Unoccupied', 'Empty', 'Disabled', 'Enabled', 'Locked', 'Unlocked'];
|
|
||||||
const randomStatus = statuses[Math.floor(Math.random() * statuses.length)];
|
|
||||||
const mockData = {
|
|
||||||
locationName: randomPoint.id,
|
|
||||||
statusValue: randomStatus,
|
|
||||||
statusAttributes: {
|
|
||||||
Status: randomStatus,
|
|
||||||
Timestamp: new Date().toISOString(),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
messageHandler(JSON.stringify(mockData));
|
|
||||||
}, 2000);
|
|
||||||
|
|
||||||
storageStatusClient.value = {
|
|
||||||
close: () => {
|
|
||||||
clearInterval(simulationTimer);
|
|
||||||
},
|
|
||||||
} as WebSocket;
|
|
||||||
// --- WebSocket Simulation End ---
|
|
||||||
};
|
|
||||||
//#endregion
|
|
||||||
|
|
||||||
const title = ref<string>('');
|
const title = ref<string>('');
|
||||||
|
|
||||||
const container = shallowRef<HTMLDivElement>();
|
const container = shallowRef<HTMLDivElement>();
|
||||||
@ -108,13 +60,11 @@ onMounted(async () => {
|
|||||||
await readScene();
|
await readScene();
|
||||||
await editor.value?.initRobots();
|
await editor.value?.initRobots();
|
||||||
await monitorScene();
|
await monitorScene();
|
||||||
await monitorStorageStatus();
|
|
||||||
// 自动保存和恢复视图状态
|
// 自动保存和恢复视图状态
|
||||||
await handleAutoSaveAndRestoreViewState();
|
await handleAutoSaveAndRestoreViewState();
|
||||||
});
|
});
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
client.value?.close();
|
client.value?.close();
|
||||||
storageStatusClient.value?.close();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const show = ref<boolean>(true);
|
const show = ref<boolean>(true);
|
||||||
|
@ -740,21 +740,6 @@ export class EditorService extends Meta2d {
|
|||||||
return { image, canvasLayer: CanvasLayer.CanvasMain };
|
return { image, canvasLayer: CanvasLayer.CanvasMain };
|
||||||
}
|
}
|
||||||
|
|
||||||
public refreshPoint(id: string, info: { status: string; attributes: Record<string, unknown> }): void {
|
|
||||||
const pen = this.getPenById(id);
|
|
||||||
if (!pen?.point) return;
|
|
||||||
|
|
||||||
const color = get(
|
|
||||||
sTheme.editor,
|
|
||||||
`point-l.stroke-${info.status.toLowerCase()}`,
|
|
||||||
get(sTheme.editor, 'point-l.stroke'),
|
|
||||||
);
|
|
||||||
|
|
||||||
this.setValue(
|
|
||||||
{ id, statusStyle: color, storageStatus: info.attributes },
|
|
||||||
{ render: true, history: false, doEvent: false },
|
|
||||||
);
|
|
||||||
}
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region 线路
|
//#region 线路
|
||||||
|
Loading…
x
Reference in New Issue
Block a user