修改情景模式

This commit is contained in:
limengnan 2026-05-18 16:23:09 +08:00
parent 06e42c2e4a
commit fe23b7a17f
6 changed files with 212 additions and 79 deletions

View File

@ -50,7 +50,7 @@ export function deleteBatchCriticalData (queryParams:any){
}
// 导出临界数据
export function exportAllExports(deviceType:any){
let url = '/critical-data/v2/export/?deviceType='+deviceType
let url = '/critical-data/v2/export?deviceType='+deviceType
return request({
url: url ,

View File

@ -61,7 +61,7 @@ export function sizeSchemaAll(queryParams:any){
// 导出全部结果
export function exportAllExports(deviceType:any){
let url = '/devices/v2/export/?deviceType='+deviceType
let url = '/devices/v2/export?deviceType='+deviceType
return request({
url: url ,

View File

@ -12,6 +12,7 @@ import { getDictItemById } from '@/api/dict';
import { topologyDevicesLsit } from '@/api/business/project';
import { getToken } from '@/utils/auth';
import { searchEventsByScenarioId } from '@/api/business/event';
import { sizeSchemaAll } from "@/api/business/database/device";
const url = import.meta.env.VITE_APP_BASE_API;
const conditionData:any = ref([{ //
@ -69,7 +70,7 @@ function initConditionData(){
}
}
if(res.length > 0){
getDeviceInfo(menuList.value[0].device)
getInitDeviceInfo(menuList.value[0].device)
}
})
@ -78,13 +79,25 @@ onMounted(() => {
DicInit()
initDeviceData()
initConditionData()
getSizeSchemaList()
});
//
const sizeSchemaInfo:any = ref({});
async function getSizeSchemaList(){ //
let result = await sizeSchemaAll({})
sizeSchemaInfo.value = result
}
const deviceData:any = ref([]) //
const attributeData:any = ref([]) //
const materialData:any = ref([]) //
const menuList:any = ref([
{
label: '条件1',
deviceType: '',
target:{
entityType: '',
entityId: '',
@ -136,6 +149,7 @@ function addMenu(){ //添加导菜单
menuList.value.push({
label: '条件' + (menuList.value.length + 1),
deviceType: '',
target:{
entityType: '',
entityId: '',
@ -159,18 +173,6 @@ function delMenu(){ // 删除导菜单
//
function DicInit() {
let params = {
dictId: 'dc7419e5f8a655966e6bb90b0cb5c0c2',
size:99,
current:1
}
getDictItemById(params).then((result: any) => {
attributeData.value = result.data.records;
}).catch((err: any) => {
if(menuList.value[menuIndex.value].target.entityType == 'device'){
getDeviceInfo(menuList.value[menuIndex.value].device)
}
});
let paramss = {
dictId: '9d87f873bc80e79c6d399131cbe01016',
size:99,
@ -179,7 +181,7 @@ function DicInit() {
getDictItemById(paramss).then((result: any) => {
materialData.value = result.data.records;
if(menuList.value[menuIndex.value].target.entityType == 'device'){
getDeviceInfo(menuList.value[menuIndex.value].device)
getInitDeviceInfo(menuList.value[menuIndex.value].device)
}
}).catch((err: any) => {
});
@ -195,15 +197,13 @@ function changeAttribute(e:any){ // 设备属性改变时,清空变化物料
menuList.value[menuIndex.value].target.entityType = 'device'
menuList.value[menuIndex.value].target.property = e
deviceData.value.forEach((item:any) => {
if(item.deviceName == menuList.value[menuIndex.value].device){
if(item.deviceId == menuList.value[menuIndex.value].device){
menuList.value[menuIndex.value].target.entityId = item.deviceId
}
})
}
getDeviceInfo(e)
getAttributeMaterial(e)
}
function changeMaterial(e:any){ //
menuList.value[menuIndex.value].target.entityType = ''
@ -213,14 +213,13 @@ function changeMaterial(e:any){ // 设备属性改变时,清空变化物料
menuList.value[menuIndex.value].target.entityId = ''
deviceData.value.forEach((item:any) => {
if(item.deviceName == menuList.value[menuIndex.value].device){
if(item.deviceId == menuList.value[menuIndex.value].device){
menuList.value[menuIndex.value].target.entityId = item.materialId
}
})
menuList.value[menuIndex.value].target.property = e
}
getDeviceInfo(e)
getAttributeMaterial(e)
}
const devicename = ref('') //
@ -237,21 +236,61 @@ function getTimelineList(){
})
})
}
function getDeviceInfo(e:any){ //
function getDeviceInfo(e:any){ //()
devicename.value = ""
deviceMaterial.value = ""
menuList.value[menuIndex.value].attribute = ""
menuList.value[menuIndex.value].material = ""
deviceData.value.forEach((item:any) => {
if(item.deviceId == menuList.value[menuIndex.value].device){
devicename.value = item.deviceName
menuList.value[menuIndex.value].deviceType = item.deviceType
for(let key in sizeSchemaInfo.value){
if(item.deviceType == key){
attributeData.value = sizeSchemaInfo.value[key].fields
attributeData.value.forEach((item:any) => {
item.dictName = item.label,
item.itemCode = item.key
})
}
}
}
})
}
function getInitDeviceInfo(e:any){ //
devicename.value = ""
deviceMaterial.value = ""
deviceData.value.forEach((item:any) => {
if(item.deviceName == menuList.value[menuIndex.value].device){
if(item.deviceId == menuList.value[menuIndex.value].device){
devicename.value = item.deviceName
menuList.value[menuIndex.value].deviceType = item.deviceType
for(let key in sizeSchemaInfo.value){
if(item.deviceType == key){
attributeData.value = sizeSchemaInfo.value[key].fields
attributeData.value.forEach((item:any) => {
item.dictName = item.label,
item.itemCode = item.key
})
}
}
}
})
if(menuList.value[menuIndex.value].target.entityType == 'device'){
attributeData.value.forEach((item:any) => {
if(item.itemCode == menuList.value[menuIndex.value].attribute){
deviceMaterial.value = item.dictName
}
})
//
// getSizeSchemaList()
}
if(menuList.value[menuIndex.value].target.entityType == 'material'){
@ -265,7 +304,26 @@ function getDeviceInfo(e:any){ // 获取设备信息
}
function getAttributeMaterial(e:any){ //
if(menuList.value[menuIndex.value].target.entityType == 'device'){
attributeData.value.forEach((item:any) => {
if(item.itemCode == menuList.value[menuIndex.value].attribute){
deviceMaterial.value = item.dictName
}
})
//
// getSizeSchemaList()
}
if(menuList.value[menuIndex.value].target.entityType == 'material'){
materialData.value.forEach((item:any) => {
if(item.itemCode == menuList.value[menuIndex.value].material){
deviceMaterial.value = item.dictName
}
})
}
}
const upload:any = ref(null)
function handleSuccess(file: any) {
if(file.code =="0"){
@ -299,19 +357,24 @@ function handleSuccess(file: any) {
<el-form-item label="始发设备(物料)" prop="code">
<el-select v-model="menuList[menuIndex].device" placeholder="请选择" style="width:100%;" clearable @change="getDeviceInfo"
:disabled="isEdit == false">
<el-option v-for="item in deviceData" :key="item.deviceName" :label="item.deviceName +'('+item.materialName+')'" :value="item.deviceName" />
<el-option v-for="item in deviceData" :key="item.deviceName" :label="item.deviceName +'('+item.materialName+')'"
:value="item.deviceId" />
</el-select>
</el-form-item>
<div style="display: flex; width: 100%;justify-content: space-between;">
<el-form-item label="设备属性" prop="name" style="width: 49%;">
<el-select v-model="menuList[menuIndex].attribute" placeholder="请选择" style="width:100%;" clearable
:disabled="(menuList[menuIndex].material!='' && menuList[menuIndex].material!=null) || isEdit == false" @change="changeAttribute">
<el-select v-model="menuList[menuIndex].attribute"
placeholder="请选择" style="width:100%;" clearable
:disabled="(menuList[menuIndex].material!='' && menuList[menuIndex].material!=null && menuList[menuIndex].device!='' &&
menuList[menuIndex].device!=null) || isEdit == false
|| menuList[menuIndex].device == '' || menuList[menuIndex].device == null" @change="changeAttribute">
<el-option v-for="item in attributeData" :key="item.itemCode" :label="item.dictName" :value="item.itemCode" />
</el-select>
</el-form-item>
<el-form-item label="变化物料" style="width: 49%;">
<el-select v-model="menuList[menuIndex].material" placeholder="请选择" style="width:100%;" clearable
:disabled="(menuList[menuIndex].attribute!='' && menuList[menuIndex].attribute!=null)|| isEdit == false" @change="changeMaterial">
:disabled="(menuList[menuIndex].attribute!='' && menuList[menuIndex].attribute!=null)|| isEdit == false
|| menuList[menuIndex].device == '' || menuList[menuIndex].device == null" @change="changeMaterial">
<el-option v-for="item in materialData" :key="item.itemCode" :label="item.dictName" :value="item.itemCode" />
</el-select>
</el-form-item>
@ -492,6 +555,7 @@ function handleSuccess(file: any) {
.segmentation-content{
width: 590px;
height: calc(100vh - 530px);
/* height: calc(100vh - 400px); */
background: rgba(250, 250, 250, 1);
box-sizing: border-box;
border: 1px solid rgba(242, 242, 242, 1);
@ -691,6 +755,8 @@ function handleSuccess(file: any) {
.condition-right-content{
border-left: 1px solid #f0f1f2;
border-top: 1px solid #f0f1f2;
overflow: auto;
max-height: calc(100vh - 400px);
}
.condition-right-tableheader{
display: flex;

View File

@ -12,6 +12,7 @@ import { eventsBatchSave } from '@/api/business/event';
import ConditionModels from '@/views/component/scenario/condition.vue'
import { addScenarios,updateScenarios,getActiveAlgorithms } from "@/api/business/scenario";
import { topologyDevicesLsit } from '@/api/business/project';
import { searchAlgorithmsModelPage } from '@/api/business/algorithmModel';
const emit = defineEmits([ 'closeCreatescenario']);
const props = defineProps({ //
projectInfo: {
@ -49,28 +50,26 @@ const getAlgorithmType = async () => {
}
//-/
function confirmClick(formEl: any) {
console.log(info.value)
formEl.validate((valid: any) => {
if (valid) {
let isAlgorithmType = false
let isSonAlgorithmType = 0
let isAlgorithmModelId = false
let isSonAlgorithmModelId = 0
for(let i = 0;i<deviceData.value.length;i++){
if(deviceData.value[i].algorithmType != null && deviceData.value[i].algorithmType != ''){
isSonAlgorithmType = isSonAlgorithmType + 1
if(deviceData.value[i].algorithmModelId != null && deviceData.value[i].algorithmModelId != ''){
isSonAlgorithmModelId = isSonAlgorithmModelId + 1
}
}
if(info.value.algorithmType == null || info.value.algorithmType == ''){
isAlgorithmType = true
isAlgorithmModelId = true
}
if( isAlgorithmType == true && isSonAlgorithmType == 0){
if( isAlgorithmModelId == true && isSonAlgorithmModelId == 0){
ElMessage({
type: "error",
message: "请选择算法类型",
});
return
}
if( isSonAlgorithmType != deviceData.value.length && isAlgorithmType == true){
if( isSonAlgorithmModelId != deviceData.value.length && isAlgorithmModelId == true){
ElMessage({
type: "error",
message: "设备算法配置映射没有填写完全",
@ -85,11 +84,16 @@ function confirmClick(formEl: any) {
description: info.value.description,
keffThreshold: info.value.keffThreshold,
};
let device_algo_config:any = {}
let device_algo_config:any = []
let isTrue:any = false
deviceData.value.forEach((item: any) => {
if(item.algorithmType !=null && item.algorithmType != ''){
device_algo_config[item.deviceId] = item.algorithmType
device_algo_config.push({
deviceId: item.deviceId,
algorithmType: item.algorithmType,
algorithmModelId: item.algorithmModelId,
})
// device_algo_config[item.deviceId] = item.algorithmType
isTrue = true
}
})
@ -185,7 +189,10 @@ function initDeviceData(){
deviceData.value.push({
deviceId: item.deviceId,
deviceName: item.deviceName,
algorithmType: ''
deviceType: item.deviceType,
algorithmType: '',
algorithmModelId: '',
algorithmModelsData: []
})
})
}
@ -201,8 +208,27 @@ function changeAlgorithmType(){
item.algorithmType = ""
})
}
function changeSonAlgorithmType(){
function changeSonAlgorithmType(e:any,deviceType:any,index:any){
info.value.algorithmType = ""
deviceData.value[index].algorithmModelId = ""
deviceData.value[index].algorithmModelsData =[]
if(e == null || e == ''){
return
}
getAlgorithmModels(e,deviceType,index)
}
function getAlgorithmModels(algorithmType:any,deviceType:any,index:any){
searchAlgorithmsModelPage({
algorithmType: algorithmType,
deviceType: deviceType,
pageNum: 1,
pageSize: 1000
}).then((res:any) => {
deviceData.value[index].algorithmModelsData = res.records
if(res.records.length > 0 && res.records[0].isCurrent == 1){
deviceData.value[index].algorithmModelId = res.records[0].algorithmModelId
}
})
}
</script>
<template>
@ -217,7 +243,7 @@ function changeAlgorithmType(){
</el-steps>
</div>
<div class="scenario-setting-bottombox">
<el-form ref="infoForm" :model="info" :rules="rules" label-width="160px" style="width:600px;height: calc(100vh - 300px);overflow: auto;padding-top: 10px;"
<el-form ref="infoForm" :model="info" :rules="rules" label-width="160px" style="width:820px;height: calc(100vh - 300px);overflow: auto;padding-top: 10px;"
v-if="stepsActive == 0">
<el-form-item label="事故情景名称:" prop="name">
<el-input v-model="info.name" style="width: 100%" placeholder="输入事故情景名称" ></el-input>
@ -230,15 +256,17 @@ function changeAlgorithmType(){
<el-form-item label="设备算法配置映射:">
<div style="width: 100%;padding-top: 40px;">
<div v-for="item in deviceData" :key="item.deviceId" style="display: flex;align-items: center;margin-bottom: 10px;">
<div v-for="(item,index) in deviceData" :key="item.deviceId" style="display: flex;align-items: center;margin-bottom: 10px;">
<div style="width: 150px;text-align: right;padding-right: 10px;">{{item.deviceName}}</div>
<el-select v-model="item.algorithmType" placeholder="请选择" style="width:100%;" clearable @change="changeSonAlgorithmType">
<el-select v-model="item.algorithmType" placeholder="请选择" style="width:300px;margin-right: 10px;" clearable
@change="changeSonAlgorithmType(item.algorithmType,item.deviceType,index)">
<el-option v-for="item in algorithmTypeData" :key="item.algorithmType" :label="item.name" :value="item.algorithmType" />
</el-select>
<el-select v-model="item.algorithmModelId" placeholder="请选择" style="width:180px;" >
<el-option v-for="items in item.algorithmModelsData" :key="items.algorithmModelId" :label="items.versionTag" :value="items.algorithmModelId" />
</el-select>
</div>
</div>
</el-form-item>
<el-form-item label="Keff预警阈值" prop="keffThreshold">

View File

@ -19,7 +19,7 @@ import { topologyDevicesLsit } from '@/api/business/project';
import TableModels from '@/components/antvx6/tableModel.vue';
import EchartsModels from '@/components/antvx6/echartsModel.vue';
import Viewx6 from '@/components/antvx6/viewx6.vue';
import { searchAlgorithmsModelPage } from '@/api/business/algorithmModel';
import { useUserStore } from '@/store/modules/user';
const userStore = useUserStore();
const username = ref(userStore.username)
@ -121,10 +121,17 @@ function editClick(row: any,type: string) {
}
if(info.value.deviceAlgoConfig !=null && info.value.deviceAlgoConfig != ''){
let device_algo_config = JSON.parse(info.value.deviceAlgoConfig)
for(let key in device_algo_config){
for(let j = 0;j<device_algo_config.length;j++ ){
for(let i = 0;i<deviceData.value.length;i++){
if(deviceData.value[i].deviceId == key){
deviceData.value[i].algorithmType = device_algo_config[key]
if(deviceData.value[i].deviceId == device_algo_config[j].deviceId){
deviceData.value[i].deviceId = device_algo_config[j].algorithmType
deviceData.value[i].algorithmType = device_algo_config[j].algorithmType
deviceData.value[i].algorithmModelId = device_algo_config[j].algorithmModelId
for(let k = 0;k<algorithmModelsData.value.length;k++){
if(algorithmModelsData.value[k].algorithmModelId == device_algo_config[j].algorithmModelId){
deviceData.value[i].algorithmModelsData.push(algorithmModelsData.value[k])
}
}
}
}
}
@ -213,25 +220,24 @@ const getAlgorithmType = async () => {
}
}
function submitClick(){
let isAlgorithmType = false
let isSonAlgorithmType = 0
let isAlgorithmModelId = false
let isSonAlgorithmModelId = 0
for(let i = 0;i<deviceData.value.length;i++){
if(deviceData.value[i].algorithmType != null && deviceData.value[i].algorithmType != ''){
isSonAlgorithmType = isSonAlgorithmType + 1
if(deviceData.value[i].algorithmModelId != null && deviceData.value[i].algorithmModelId != ''){
isSonAlgorithmModelId = isSonAlgorithmModelId + 1
}
}
if(info.value.algorithmType == null || info.value.algorithmType == ''){
isAlgorithmType = true
isAlgorithmModelId = true
}
if( isAlgorithmType == true && isSonAlgorithmType == 0){
if( isAlgorithmModelId == true && isSonAlgorithmModelId == 0){
ElMessage({
type: "error",
message: "请选择算法类型",
});
return
}
if( isSonAlgorithmType != deviceData.value.length){
if( isSonAlgorithmModelId != deviceData.value.length && isAlgorithmModelId == true){
ElMessage({
type: "error",
message: "设备算法配置映射没有填写完全",
@ -239,18 +245,22 @@ function submitClick(){
return
}
let data:any = {
scenarioId: info.value.scenarioId,
algorithmType: info.value.algorithmType,
const data:any = {
projectId: props.projectInfo.projectId,
name: info.value.name,
algorithmType: info.value.algorithmType,
description: info.value.description,
keffThreshold: info.value.keffThreshold,
}
let device_algo_config:any = {}
};
let device_algo_config:any = []
let isTrue:any = false
deviceData.value.forEach((item: any) => {
if(item.algorithmType !=null && item.algorithmType != ''){
device_algo_config[item.deviceId] = item.algorithmType
device_algo_config.push({
deviceId: item.deviceId,
algorithmType: item.algorithmType,
algorithmModelId: item.algorithmModelId,
})
isTrue = true
}
})
@ -270,13 +280,19 @@ function submitClick(){
gettableData();
}
})
}
const algorithmModelsData = ref<any>([])
onMounted(() => {
getAlgorithmType()
gettableData();
initDeviceData()
searchAlgorithmsModelPage({
pageNum: 1,
pageSize: 9999
}).then((res:any) => {
algorithmModelsData.value = res.records
})
});
function closeCreatescenario(){
dialogVisible.value = false;
@ -412,7 +428,10 @@ function initDeviceData(){
deviceData.value.push({
deviceId: item.deviceId,
deviceName: item.deviceName,
algorithmType: ''
deviceType: item.deviceType,
algorithmType: '',
algorithmModelId: '',
algorithmModelsData: []
})
})
}
@ -424,10 +443,28 @@ function initDeviceData(){
item.algorithmType = ""
})
}
function changeSonAlgorithmType(){
function changeSonAlgorithmType(e:any,deviceType:any,index:any){
info.value.algorithmType = ""
deviceData.value[index].algorithmModelId = ""
deviceData.value[index].algorithmModelsData = []
if(e == null || e == ''){
return
}
getAlgorithmModels(e,deviceType,index)
}
function getAlgorithmModels(algorithmType:any,deviceType:any,index:any){
searchAlgorithmsModelPage({
algorithmType: algorithmType,
deviceType: deviceType,
pageNum: 1,
pageSize: 1000
}).then((res:any) => {
deviceData.value[index].algorithmModelsData = res.records
if(res.records.length > 0 && res.records[0].isCurrent == 1){
deviceData.value[index].algorithmModelId = res.records[0].algorithmModelId
}
})
}
function downloadFile(obj :any, name :any, suffix :any) {
const url = window.URL.createObjectURL(new Blob([obj]))
const link = document.createElement('a')
@ -500,7 +537,6 @@ function handlefailDetail(row:any){
<el-table-column type="selection" width="50" align="center"></el-table-column>
<el-table-column prop="name" label="事故情景名称" min-width="180"></el-table-column>
<el-table-column prop="algorithmType" label="算法模型" min-width="180"></el-table-column>
<el-table-column prop="createdAt" label="模拟时间" width="200">
<template #default="scope">
<span v-if="scope.row.createdAt != null">{{ dateFormat(scope.row.createdAt) }}</span>
@ -557,8 +593,8 @@ function handlefailDetail(row:any){
<Createscenario v-if="dialogVisible" :projectInfo="projectInfo" @closeCreatescenario ="closeCreatescenario"/>
<el-dialog v-model="dialogEditVisible" :close-on-click-modal="false"
:modal="false" draggable :before-close="handleClose" :title="title"
append-to-body width="590px">
<el-form ref="infoForm" :model="info" :rules="rules" label-width="140px" style="width:500px;height: calc(100vh - 300px);overflow: auto;padding-top: 10px;">
append-to-body width="800px">
<el-form ref="infoForm" :model="info" :rules="rules" label-width="140px" style="width:750px;height: calc(100vh - 300px);overflow: auto;padding-top: 10px;">
<el-form-item label="事故情景名称:" prop="name">
<el-input v-model="info.name" style="width: 100%" placeholder="输入事故情景名称" :disabled="title == '查看事故情景'"></el-input>
</el-form-item>
@ -570,12 +606,15 @@ function handlefailDetail(row:any){
</el-form-item>
<el-form-item label="设备算法配置映射:">
<div style="width: 100%;padding-top: 40px;">
<div v-for="item in deviceData" :key="item.deviceType" style="display: flex;align-items: center;margin-bottom: 10px;">
<div v-for="(item,index) in deviceData" :key="item.deviceId" style="display: flex;align-items: center;margin-bottom: 10px;">
<div style="width: 150px;text-align: right;padding-right: 10px;">{{item.deviceName}}</div>
<el-select v-model="item.algorithmType" placeholder="请选择" style="width:100%;"
clearable :disabled="title == '查看事故情景'" @change="changeSonAlgorithmType">
<el-select v-model="item.algorithmType" placeholder="请选择" style="width:300px;margin-right: 10px;" clearable
@change="changeSonAlgorithmType(item.algorithmType,item.deviceType,index)">
<el-option v-for="item in algorithmTypeData" :key="item.algorithmType" :label="item.name" :value="item.algorithmType" />
</el-select>
<el-select v-model="item.algorithmModelId" placeholder="请选择" style="width:180px;" >
<el-option v-for="items in item.algorithmModelsData" :key="items.algorithmModelId" :label="items.versionTag" :value="items.algorithmModelId" />
</el-select>
</div>
</div>
</el-form-item>