Browse Source

LccEnvInfo 环境信息

master
修宁 6 months ago
parent
commit
1e115b884e
  1. 17
      doc/RCS数据库结构.md
  2. 67
      src/core/manager/RunManager.ts
  3. 18
      src/core/manager/WorldModel.ts
  4. 37
      src/editor/ModelMain.vue
  5. 17
      src/types/model.d.ts

17
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_device1 on rcs_task_device (biz_task_id);
create index idx_rcs_task_device2 on rcs_task_device (plan_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);
``` ```

67
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<ServerResponse<EnvInfo[]>> {
// 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

18
src/core/manager/WorldModel.ts

@ -30,6 +30,14 @@ export interface WorldModelState {
stateManagerId: string // 当前楼层的状态管理器id stateManagerId: string // 当前楼层的状态管理器id
isDraft: boolean // 是否是草稿数据 isDraft: boolean // 是否是草稿数据
runState: {
currentEnvId: number,
isLoading: boolean,
isRunning: boolean,
isVirtual: boolean,
timeRate: number,
}
} }
/** /**
@ -53,7 +61,15 @@ export default class WorldModel {
catalogCode: '', // 当前楼层的目录代码 catalogCode: '', // 当前楼层的目录代码
stateManagerId: '', // 当前楼层的状态管理器id, 一般是 项目ID+目录项ID stateManagerId: '', // 当前楼层的状态管理器id, 一般是 项目ID+目录项ID
isDraft: false // 是否是草稿数据, 如果是草稿数据, 则不需要再从服务器加载数据 isDraft: false, // 是否是草稿数据, 如果是草稿数据, 则不需要再从服务器加载数据
runState: {
currentEnvId: 0,
isLoading: false,
isRunning: false,
isVirtual: false,
timeRate: 1,
}
}) })
get gridOption(): IGridHelper { get gridOption(): IGridHelper {

37
src/editor/ModelMain.vue

@ -8,6 +8,35 @@
>{{ rootMenu.label }} >{{ rootMenu.label }}
<component :is="renderIcon('element ArrowDown')"></component> <component :is="renderIcon('element ArrowDown')"></component>
</div> </div>
<div style="flex-grow: 1;"></div>
<div style="display: flex; flex-direction: row; align-items: center; margin-right: 10px;">
<div class="field-block" style="margin-right: 5px;">
<el-select style="width:130px;" placeholder="运行环境"
v-model="worldModel.state.currentEnvId">
<template #footer>
<el-button size="small" type="primary" plain>创建运行环境</el-button>
<el-button size="small" :icon="renderIcon('Refresh')" @click="reloadEnvList" />
</template>
</el-select>
</div>
<div class="field-block" style="margin-right: 5px;">
<el-select style="width:130px;" placeholder="时间速率"
v-model="worldModel.state.timeRate">
<el-option label="1x" :value="1"></el-option>
<el-option label="2x" :value="2"></el-option>
<el-option label="10x" :value="10"></el-option>
</el-select>
</div>
<el-button :icon="renderIcon('Play')" type="primary"
v-if="!worldModel.state.runState.isRunning"
:disabled="!worldModel.state.runState.currentEnvId"
:loading="worldModel.state.runState.isLoading">启动
</el-button>
<el-button :icon="renderIcon('Stop')" type="danger" plain
v-if="worldModel.state.runState.isRunning"
:loading="worldModel.state.runState.isLoading">停止
</el-button>
</div>
</div> </div>
<div class="user"> <div class="user">
<span style="margin-right: 10px;"> <span style="margin-right: 10px;">
@ -121,6 +150,7 @@ import Logo from '@/assets/images/logo.png'
import './ModelMain.less' import './ModelMain.less'
import EventBus from '@/runtime/EventBus.js' import EventBus from '@/runtime/EventBus.js'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import runManager from '@/core/manager/RunManager.js'
export default { export default {
components: { Model2DEditor, Model3DViewer, Split, SplitArea, CatalogDefine }, components: { Model2DEditor, Model3DViewer, Split, SplitArea, CatalogDefine },
@ -158,6 +188,7 @@ export default {
} }
}) })
}) })
this.reloadEnvList()
EventBus.on('dataLoadComplete', (data) => { EventBus.on('dataLoadComplete', (data) => {
const { stateManager } = data const { stateManager } = data
if (stateManager) { if (stateManager) {
@ -174,6 +205,7 @@ export default {
data() { data() {
return { return {
Logo, Logo,
envList: [],
isShowEditor: false, isShowEditor: false,
editorHash: 0, editorHash: 0,
currentViewport: null, currentViewport: null,
@ -245,6 +277,11 @@ export default {
methods: { methods: {
renderIcon, renderIcon,
getWidgetBySide, getWidgetBySide,
reloadEnvList() {
runManager.getAllEnv(this.worldModel.state.project_uuid).then(res => {
this.envList = res.data
})
},
toHome() { toHome() {
system.router.push({ name: 'home' }) system.router.push({ name: 'home' })
}, },

17
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 ClxIf extends EntityIf, Carry, Walk, ForkArm, LiftingArm {
} }
interface ServerResponse<T> {
success: boolean,
msg: string,
data: T
}
/**
*
*/
interface EnvInfo {
env_id: string
world_id: string
env_name: string
is_virtual: boolean
env_payload: any
}

Loading…
Cancel
Save