refactor: 移除库位状态相关代码,简化组件逻辑并清理未使用的功能

This commit is contained in:
xudan 2025-07-15 15:02:02 +08:00
parent 0a4f25bde6
commit d5b7a29163
4 changed files with 0 additions and 80 deletions

View File

@ -16,7 +16,6 @@ export interface MapPen extends Pen {
activeAttrs?: Array<string>; // 已激活的额外属性
properties?: unknown; // 第三方附加参数
storageStatus?: Record<string, unknown>; // 库位状态
statusStyle?: string; // 状态颜色
strokeStyle?: string; // 边框颜色
}
@ -49,7 +48,6 @@ export interface MapAreaInfo {
routes?: Array<string>; // 绑定线路id集合
maxAmr?: number; // 最大可容纳AMR数
inoutflag?: 1 | 2; // 库区规则
storageLocations?: Record<string, string[]>; // 动作点ID对应的库位信息内部使用
}
//#endregion

View File

@ -52,13 +52,6 @@ const mapAreas = (type: MapAreaType): string => {
};
const coArea1 = 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>
<template>
@ -126,12 +119,6 @@ const storageStatus = computed<string>(() => {
<a-typography-text>{{ coArea2 || $t('暂无') }}</a-typography-text>
</a-flex>
</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>
</template>
<a-empty v-else :image="sTheme.empty" />

View File

@ -1,5 +1,4 @@
<script setup lang="ts">
import { MapPointType } from '@api/map';
import type { RobotRealtimeInfo } from '@api/robot';
import { getSceneByGroupId, getSceneById, monitorRealSceneById, monitorSceneById } from '@api/scene';
import { EditorService } from '@core/editor.service';
@ -47,53 +46,6 @@ const monitorScene = async () => {
};
//#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 container = shallowRef<HTMLDivElement>();
@ -108,13 +60,11 @@ onMounted(async () => {
await readScene();
await editor.value?.initRobots();
await monitorScene();
await monitorStorageStatus();
//
await handleAutoSaveAndRestoreViewState();
});
onUnmounted(() => {
client.value?.close();
storageStatusClient.value?.close();
});
const show = ref<boolean>(true);

View File

@ -740,21 +740,6 @@ export class EditorService extends Meta2d {
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
//#region 线路