diff --git a/business-css/frontend/src/api/business/project/index.ts b/business-css/frontend/src/api/business/project/index.ts index fcd9685..98683f2 100644 --- a/business-css/frontend/src/api/business/project/index.ts +++ b/business-css/frontend/src/api/business/project/index.ts @@ -59,4 +59,20 @@ export function topologyDevicesLsit(queryParams:any){ }); } +//初始化项目模拟数据 +export function simulationInit(queryParams:any){ + return request({ + url:'/projects/simulation/init' , + method: 'Post', + params:queryParams + }); +} +// 运行项目模拟 +export function simulationRun(projectId:string,scenarioId:string, data:any){ + return request({ + url:'/projects/simulation/run?projectId='+projectId+'&scenarioId='+scenarioId , + method: 'Post', + data: data + }); +} diff --git a/business-css/frontend/src/api/business/scenario/index.ts b/business-css/frontend/src/api/business/scenario/index.ts index 7c082f1..87fbdd6 100644 --- a/business-css/frontend/src/api/business/scenario/index.ts +++ b/business-css/frontend/src/api/business/scenario/index.ts @@ -48,3 +48,12 @@ export function deleteBatchScenarios(queryParams:any){ data: queryParams }); } + +//获取所有项目列表 +export function getActiveAlgorithms(){ + return request({ + url: '/algorithms/getActiveAlgorithms' , + method: 'get' + }); +} + diff --git a/business-css/frontend/src/assets/table/moni.png b/business-css/frontend/src/assets/table/moni.png new file mode 100644 index 0000000..8c8e5f1 Binary files /dev/null and b/business-css/frontend/src/assets/table/moni.png differ diff --git a/business-css/frontend/src/assets/table/moni_disabled.png b/business-css/frontend/src/assets/table/moni_disabled.png new file mode 100644 index 0000000..bb92611 Binary files /dev/null and b/business-css/frontend/src/assets/table/moni_disabled.png differ diff --git a/business-css/frontend/src/assets/table/result.png b/business-css/frontend/src/assets/table/result.png new file mode 100644 index 0000000..b9c033d Binary files /dev/null and b/business-css/frontend/src/assets/table/result.png differ diff --git a/business-css/frontend/src/assets/table/result_disabled.png b/business-css/frontend/src/assets/table/result_disabled.png new file mode 100644 index 0000000..51f37fe Binary files /dev/null and b/business-css/frontend/src/assets/table/result_disabled.png differ diff --git a/business-css/frontend/src/assets/table/see.png b/business-css/frontend/src/assets/table/see.png new file mode 100644 index 0000000..6671804 Binary files /dev/null and b/business-css/frontend/src/assets/table/see.png differ diff --git a/business-css/frontend/src/assets/table/shifa.png b/business-css/frontend/src/assets/table/shifa.png new file mode 100644 index 0000000..558bbf7 Binary files /dev/null and b/business-css/frontend/src/assets/table/shifa.png differ diff --git a/business-css/frontend/src/assets/table/u267.png b/business-css/frontend/src/assets/table/u267.png new file mode 100644 index 0000000..90509c2 Binary files /dev/null and b/business-css/frontend/src/assets/table/u267.png differ diff --git a/business-css/frontend/src/assets/table/u419_disabled.png b/business-css/frontend/src/assets/table/u419_disabled.png new file mode 100644 index 0000000..32c8e2e Binary files /dev/null and b/business-css/frontend/src/assets/table/u419_disabled.png differ diff --git a/business-css/frontend/src/assets/table/view.png b/business-css/frontend/src/assets/table/view.png new file mode 100644 index 0000000..77e27ac Binary files /dev/null and b/business-css/frontend/src/assets/table/view.png differ diff --git a/business-css/frontend/src/components/antvx6/adddevice.vue b/business-css/frontend/src/components/antvx6/adddevice.vue index 6c882d4..c757e8f 100644 --- a/business-css/frontend/src/components/antvx6/adddevice.vue +++ b/business-css/frontend/src/components/antvx6/adddevice.vue @@ -120,7 +120,7 @@ function confirmDevice(){ // 确定添加设备 } addDevices(params).then((res:any) => { if(res == true){ - emit('closeAdddevice', selectedDevice.value) + emit('closeAdddevice', params) } }); } @@ -213,8 +213,6 @@ function addClick() { - - diff --git a/business-css/frontend/src/components/antvx6/changesettings.vue b/business-css/frontend/src/components/antvx6/changesettings.vue new file mode 100644 index 0000000..1ff3255 --- /dev/null +++ b/business-css/frontend/src/components/antvx6/changesettings.vue @@ -0,0 +1,374 @@ + + + + + + + + diff --git a/business-css/frontend/src/components/antvx6/index.vue b/business-css/frontend/src/components/antvx6/index.vue index 56e5f61..31f8bf2 100644 --- a/business-css/frontend/src/components/antvx6/index.vue +++ b/business-css/frontend/src/components/antvx6/index.vue @@ -35,7 +35,7 @@ import line6 from '@/assets/x6/line6.png' import AdddeviceModel from './adddevice.vue'; import EditdeviceModel from './editdevice.vue'; import MaterialModels from './materialmodel.vue'; - +import ChangesettingsModels from './changesettings.vue'; const emit = defineEmits([ 'closeAntvx6']); @@ -639,7 +639,6 @@ graph.on('blank:mouseup', (e) => { }, }), ) - console.log(imageNodes) stencil.load(imageNodes, 'group2') // 创建管线节点 @@ -858,51 +857,7 @@ function copyNode() { // 复制节点 function closeAntvx6() { emit('closeAntvx6') } -function saveDesign() { // 保存设计 - try { - // 获取画布内容并转换为JSON - const designData:any = graph.toJSON() - let cells = [] - if(designData !=null && designData.cells.length>0){ - cells = designData.cells - } - const topology = { - projectId: projectInfo.value.projectId, - name: projectInfo.value.name, - devices:[], - pipelines:[], - systemboundaries:[], - globalDisplay:{ - device:{ - showProperties:[] - }, - material:{ - showProperties:[] - }, - - }, - designData:cells - } - // 添加保存信息 - const saveData = { - projectId: projectInfo.value.projectId, - topology: JSON.stringify(topology) - } - updateProjects(saveData).then((res:any) => { - if(res === true){ - ElMessage({ - type: "success", - message: "保存成功", - }); - } - }); - // 返回保存的数据 - return saveData - } catch (error) { - console.error('保存设计失败:', error) - return null - } -} + function revokeClick(){ graph.undo() } @@ -989,14 +944,183 @@ function dialogMaterialModel(){ // 关闭物料信息弹窗 } function closeMaterialModel(e:any){ // 关闭物料信息弹窗 if(e == false){ - isEditdevice.value = false; + isMaterialModel.value = false; return } selectedMaterial.value = e let retrievedNode:any = graph.getCellById(nodeId.value) retrievedNode.store.data.materialInfo = e - isEditdevice.value = false; + isMaterialModel.value = false; +} + +const isChangesettings = ref(false) +const changesettingsData:any = ref([]) // 是否变动设置 +function dialogChangesettings(){ // 关闭变动设置弹窗 + isChangesettings.value = false; +} +function ChangesettingsClick(){ // 打开变动设置弹窗 + changesettingsData.value = [] + if(selectedNode.value.store.data.deviceInfo == null){ + ElMessage({ + type: "error", + message: "请先添加设备信息", + }); + return + } + if(selectedNode.value.store.data.materialInfo == null){ + ElMessage({ + type: "error", + message: "请先添加物料信息", + }); + return + } + deviceInfo.value = selectedNode.value.store.data.deviceInfo + materialInfo.value = selectedNode.value.store.data.materialInfo + + if(selectedNode.value.store.data.changesettings != null){ + changesettingsData.value = selectedNode.value.store.data.changesettings + } + + nodeId.value = selectedNode.value.id + if(materialInfo.value != null){ + deviceTypetype.value = materialInfo.value.type + } + isChangesettings.value = true; +} + +function closeChangesettingsModel(e:any){ // 关闭变动设置弹窗 + if(e == false){ + isChangesettings.value = false; + return + } + selectedMaterial.value = e + let retrievedNode:any = graph.getCellById(nodeId.value) + retrievedNode.store.data.changesettings = e + isChangesettings.value = false; +} + +function setFormulaInit(formula:any) { + // const formula = "【(圆柱槽B)*0.2+(环形槽A)*1.0+0.5】"; + // 匹配*号后、+或)前的数字(支持整数和小数) + const regex = /\*(\d+\.?\d*)/g; + const coefficients = []; + let match; + + // 循环提取所有匹配项 + while ((match = regex.exec(formula)) !== null) { + coefficients.push(parseFloat(match[1])); // 转为数字类型 + } + console.log(coefficients); // 输出: [0.2, 1.0] + return coefficients + +} + +function getBias(formula:any){ + // 从后往前找最后一个+的位置 +// 匹配最后一个+号后面的数字(支持整数、小数) + const regex = /\+(\d+\.?\d*)$/; + const match = formula.match(regex); + const constant = parseFloat(match[1]); + return constant +} + + +function saveDesign() { // 保存设计 + try { + // 获取画布内容并转换为JSON + const designData:any = graph.toJSON() + let cells:any = [] + if(designData !=null && designData.cells.length>0){ + cells = designData.cells + } + let devices = [] + for(let i=0;i 0){ + for(let j=0;j { + if(res === true){ + ElMessage({ + type: "success", + message: "保存成功", + }); + } + }); + // 返回保存的数据 + return saveData + } catch (error) { + console.error('保存设计失败:', error) + return null + } } @@ -1062,7 +1186,7 @@ function closeMaterialModel(e:any){ // 关闭物料信息弹窗
图标 图标 - 图标 + 图标 图标 图标 @@ -1100,20 +1224,17 @@ function closeMaterialModel(e:any){ // 关闭物料信息弹窗 :deviceTypetype="deviceTypetype" ref="Editdevice" @closeEditdevice="closeEditdevice"/> - - - - - + + + + + + +
diff --git a/business-css/frontend/src/components/antvx6/materialmodel.vue b/business-css/frontend/src/components/antvx6/materialmodel.vue index fccec7c..7f7ba6b 100644 --- a/business-css/frontend/src/components/antvx6/materialmodel.vue +++ b/business-css/frontend/src/components/antvx6/materialmodel.vue @@ -215,7 +215,7 @@ function handleClick(item:any, index:any){ for(let i = 0; i < tempData.length; i++){ let attr = tempData[i] ingredientData.value.push({ - key: attr.name, + key: attr.key, value: attr.value, unit: attr.unit, }) @@ -443,6 +443,7 @@ function confirmMaterial(){ font-style: normal; font-size: 14px; color: #333333; + cursor: pointer; } .choiceMateria-left-item:hover{ background-color: #f5f8ff; diff --git a/business-css/frontend/src/components/antvx6/viewx6.vue b/business-css/frontend/src/components/antvx6/viewx6.vue new file mode 100644 index 0000000..31f8bf2 --- /dev/null +++ b/business-css/frontend/src/components/antvx6/viewx6.vue @@ -0,0 +1,1518 @@ + + + + + + + \ No newline at end of file diff --git a/business-css/frontend/src/views/component/scenario/createscenario.vue b/business-css/frontend/src/views/component/scenario/createscenario.vue index 997833d..937bc6d 100644 --- a/business-css/frontend/src/views/component/scenario/createscenario.vue +++ b/business-css/frontend/src/views/component/scenario/createscenario.vue @@ -10,7 +10,7 @@ import { ElForm, ElMessage, ElMessageBox } from "element-plus"; import { getDictItemById } from '@/api/dict'; import { eventsBatchSave } from '@/api/business/event'; import ConditionModel from '@/views/component/scenario/condition.vue' -import { addScenarios,updateScenarios} from "@/api/business/scenario"; +import { addScenarios,updateScenarios,getActiveAlgorithms } from "@/api/business/scenario"; const emit = defineEmits([ 'closeCreatescenario']); const props = defineProps({ // 接收父组件传递的项目信息 @@ -41,15 +41,8 @@ function handleScenarioClose(){ } const getAlgorithmType = async () => { try { - let params = { - dictId: '595502b91e7741b5033b53622d8731a3', - size:99, - current:1 - } - const result:any = await getDictItemById(params); - if (result.code == '0') { - algorithmTypeData.value = result.data.records - } + const result:any = await getActiveAlgorithms(); + algorithmTypeData.value = result } catch (error) { } } @@ -152,7 +145,7 @@ onMounted(() => { - + diff --git a/business-css/frontend/src/views/component/scenario/index.vue b/business-css/frontend/src/views/component/scenario/index.vue index a16374c..85f3766 100644 --- a/business-css/frontend/src/views/component/scenario/index.vue +++ b/business-css/frontend/src/views/component/scenario/index.vue @@ -8,6 +8,9 @@ export default { import { onMounted, ref, nextTick } from "vue"; import { ElForm, ElMessage, ElMessageBox } from "element-plus"; import { searchScenariosLsit,addScenarios,updateScenarios,deleteScenarios,deleteBatchScenarios} from "@/api/business/scenario"; + +import { simulationInit,simulationRun } from "@/api/business/project"; + import Page from '@/components/Pagination/page.vue' import { getDictItemById } from '@/api/dict'; // import ConditionModel from '@/views/component/scenario/condition.vue' @@ -268,6 +271,48 @@ function closeCreatescenario(){ dialogVisible.value = false; gettableData(); } + +function confirmationAnalysis(row: any) { + ElMessageBox.confirm("确定对"+ row.name +"故情景分析进行模拟吗?", "确认模拟", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning", + }) + .then(() => { + let params = { + projectId: row.projectId, + scenarioId: row.scenarioId, + }; + simulationInit(params).then((res:any) => { + if (res.code == '0') { + let data = { + data: res.data + } + simulationRun(row.projectId, row.scenarioId, data || {}).then((res) => { + gettableData(); + }).catch((error) => { + console.error('模拟运行失败:', error); + ElMessage({ + type: "error", + message: "模拟运行失败,请检查后端服务是否正常", + }); + }) + }else{ + ElMessage({ + type: "error", + message: "模拟初始化失败", + }); + } + + + + }); + }) +} + + + +