diff --git a/doc/RCS数据库结构.md b/doc/RCS数据库结构.md index a67df05..806cc37 100644 --- a/doc/RCS数据库结构.md +++ b/doc/RCS数据库结构.md @@ -68,4 +68,21 @@ create table rcs_task_device create index idx_rcs_task_device1 on rcs_task_device (biz_task_id); create index idx_rcs_task_device2 on rcs_task_device (plan_task_id); + +drop table if exists lcc_env_info; +create table lcc_env_info +( + env_id bigint not null comment '环境ID', + world_id varchar(50) not null comment '世界地图ID', + env_name varchar(50) not null comment '环境名称', + is_virtual boolean not null default false comment '是否虚拟环境', + env_payload varchar(3000) not null default 'N/A' comment '环境负载信息', + create_at timestamp not null comment '创建时间', + create_by varchar(50) not null comment '创建人', + update_at timestamp not null comment '更新时间', + update_by varchar(50) not null comment '更新人', + primary key (env_id) +); +create index idx_lcc_env_info_1 on lcc_env_info (world_id); + ``` diff --git a/src/core/manager/RunManager.ts b/src/core/manager/RunManager.ts new file mode 100644 index 0000000..72e167c --- /dev/null +++ b/src/core/manager/RunManager.ts @@ -0,0 +1,67 @@ +import { Request } from '@ease-forge/shared' + +/** + * 运行管理器 + */ +class RunManager { + + // 是否正在运行 + isRunning: boolean = false + + /** + * 获取所有运行环境 + */ + async getAllEnv(worldId: string): Promise> { + // system.invokeServer('') + if (!worldId) { + return Promise.resolve({ success: true, data: [], msg: '' }) + } + const res = await Request.request.post('/api/workbench/EnvController@getAllEnv', { + worldId: worldId + }) + for (const env of res.data) { + // payload 转换为 json 数据 + if (env.env_payload) { + try { + env.env_payload = JSON.parse(env.env_payload) + } catch (e) { + console.error('解析环境负载失败:', e) + env.env_payload = {} + } + } + } + + return res + } + + /** + * 创建运行环境 + * @param worldId 世界ID + * @param envName 运行环境名称 + * @param isVirtual 是否是虚拟环境 + */ + async createEnv(worldId: string, envName: string, isVirtual: boolean) { + throw new Error('Method not implemented.') + } + + /** + * 开始运行 + */ + async run(timeRate: number, envId: number) { + if (this.isRunning) { + await this.stop() + } + + // 启动 websocket 监听等等 + } + + /** + * 停止运行 + */ + async stop() { + // 停止 websocket 监听等等 + } +} + +const runManager = new RunManager() +export default runManager diff --git a/src/core/manager/WorldModel.ts b/src/core/manager/WorldModel.ts index 5dc4972..4f9a839 100644 --- a/src/core/manager/WorldModel.ts +++ b/src/core/manager/WorldModel.ts @@ -30,6 +30,14 @@ export interface WorldModelState { stateManagerId: string // 当前楼层的状态管理器id isDraft: boolean // 是否是草稿数据 + + runState: { + currentEnvId: number, + isLoading: boolean, + isRunning: boolean, + isVirtual: boolean, + timeRate: number, + } } /** @@ -53,7 +61,15 @@ export default class WorldModel { catalogCode: '', // 当前楼层的目录代码 stateManagerId: '', // 当前楼层的状态管理器id, 一般是 项目ID+目录项ID - isDraft: false // 是否是草稿数据, 如果是草稿数据, 则不需要再从服务器加载数据 + isDraft: false, // 是否是草稿数据, 如果是草稿数据, 则不需要再从服务器加载数据 + + runState: { + currentEnvId: 0, + isLoading: false, + isRunning: false, + isVirtual: false, + timeRate: 1, + } }) get gridOption(): IGridHelper { diff --git a/src/editor/ModelMain.vue b/src/editor/ModelMain.vue index c60df39..a1a0ae5 100644 --- a/src/editor/ModelMain.vue +++ b/src/editor/ModelMain.vue @@ -8,6 +8,35 @@ >{{ rootMenu.label }} +
+
+
+ + + +
+
+ + + + + +
+ 启动 + + 停止 + +
@@ -121,6 +150,7 @@ import Logo from '@/assets/images/logo.png' import './ModelMain.less' import EventBus from '@/runtime/EventBus.js' import { useRouter } from 'vue-router' +import runManager from '@/core/manager/RunManager.js' export default { components: { Model2DEditor, Model3DViewer, Split, SplitArea, CatalogDefine }, @@ -158,6 +188,7 @@ export default { } }) }) + this.reloadEnvList() EventBus.on('dataLoadComplete', (data) => { const { stateManager } = data if (stateManager) { @@ -174,6 +205,7 @@ export default { data() { return { Logo, + envList: [], isShowEditor: false, editorHash: 0, currentViewport: null, @@ -245,6 +277,11 @@ export default { methods: { renderIcon, getWidgetBySide, + reloadEnvList() { + runManager.getAllEnv(this.worldModel.state.project_uuid).then(res => { + this.envList = res.data + }) + }, toHome() { system.router.push({ name: 'home' }) }, diff --git a/src/types/model.d.ts b/src/types/model.d.ts index e32ce04..20df69d 100644 --- a/src/types/model.d.ts +++ b/src/types/model.d.ts @@ -460,3 +460,20 @@ interface Cl2If extends EntityIf, Carry, Walk, ForkArm, LiftingArm { */ interface ClxIf extends EntityIf, Carry, Walk, ForkArm, LiftingArm { } + +interface ServerResponse { + success: boolean, + msg: string, + data: T +} + +/** + * 环境信息 + */ +interface EnvInfo { + env_id: string + world_id: string + env_name: string + is_virtual: boolean + env_payload: any +}