Commit 856382f9 by 吴斌

update:简单的减薄因子计算

parent 3a97339d
<template> <template>
<div class="w-full h-full flex flex-col"> <div class="w-full h-full flex flex-col">
<div id="tool-bar" class="pl-1 pr-1 bg-white h-10 flex items-center space-x-1 border-0.5 border-gray-500 border-solid rounded-t-[8px] p-1"> <div id="tool-bar" class="pl-1 pr-1 bg-white h-10 flex items-center space-x-1 border-0.5 border-gray-500 border-solid rounded-t-[8px] p-1">
<el-button text icon="Setting"></el-button> <el-button text icon="Setting" @click="console.log(diagramConfig)"></el-button>
<div class="flex-1"></div> <div class="flex-1"></div>
<el-radio-group v-model="diagramConfig.mode" @change="freshDiagramConfig"> <el-radio-group v-model="diagramConfig.mode">
<el-radio-button label="readonly"> <el-radio-button label="readonly">
<template #default> <template #default>
<el-icon> <el-icon>
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
</el-row> </el-row>
</div> </div>
<div id="myDiagram" class="flex-1 border-0.5 border-solid border-gray-500 border-t-0 "></div> <div id="myDiagram" class="flex-1 border-0.5 border-solid border-gray-500 border-t-0 "></div>
<div id="info-panel" class="w-[200px] rounded-br-[8px]"> <div id="info-panel" class="w-[250px] rounded-br-[8px]">
<el-tabs type="border-card" class="info-tabs w-full h-full"> <el-tabs type="border-card" class="info-tabs w-full h-full">
<el-tab-pane label="节点"> <el-tab-pane label="节点">
<el-empty description="未选择节点或连接线" v-if="!ifSelectNode && !ifSelectLink"></el-empty> <el-empty description="未选择节点或连接线" v-if="!ifSelectNode && !ifSelectLink"></el-empty>
...@@ -162,7 +162,7 @@ ...@@ -162,7 +162,7 @@
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import {onMounted, ref, triggerRef} from "vue"; import {onMounted, reactive, ref, triggerRef, watch} from "vue";
import SourceNodeCollection from "./components/source/source-node-collection.vue"; import SourceNodeCollection from "./components/source/source-node-collection.vue";
import go from "gojs"; import go from "gojs";
import { import {
...@@ -183,11 +183,18 @@ import {uuid} from "vue3-uuid"; ...@@ -183,11 +183,18 @@ import {uuid} from "vue3-uuid";
import {SnapLinkReshapingTool} from "./kit/extensions/SnapLinkReshapingTool.ts"; import {SnapLinkReshapingTool} from "./kit/extensions/SnapLinkReshapingTool.ts";
import {Edit, View} from "@element-plus/icons-vue"; import {Edit, View} from "@element-plus/icons-vue";
import {ElMessage} from "element-plus"; import {ElMessage} from "element-plus";
import {PolylineLinkingTool} from "./kit/extensions/PolylineLinkingTool.ts"; import {
DeviceType,
getAverageFailurePossibility,
getDeviceCorrectionCoefficient,
getDeviceFailurePossibility,
getExceedingDefectInfluenceCoefficient,
getManagementSystemEvaluationCoefficient
} from "./kit/core/Analyse.ts";
// 变量定义 // 变量定义
// region // region
// 图表配置 // 图表配置
const diagramConfig = ref<Record<string, any>>({ const diagramConfig = reactive<Record<string, any>>({
mode: "edit", mode: "edit",
}) })
...@@ -256,22 +263,19 @@ onMounted(()=>{ ...@@ -256,22 +263,19 @@ onMounted(()=>{
changeDataRealTime() changeDataRealTime()
}) })
watch(diagramConfig, (newVal)=>{
function changeDiagramConfig(key:string, value:string){ if (newVal.mode === 'readonly'){
diagramConfig.value[key] = value
freshDiagramConfig()
}
function freshDiagramConfig(){
let mode = diagramConfig.value.mode
if (mode === 'readonly'){
myDiagram.isReadOnly = true myDiagram.isReadOnly = true
}else if(mode === 'edit'){ }else if(newVal.mode === 'edit'){
myDiagram.isReadOnly = false myDiagram.isReadOnly = false
} }
} })
function changeDiagramConfig(key:string, value:string){
diagramConfig[key] = value
}
// 素材区相关函数 // 素材区相关函数
// region // region
// endregion // endregion
...@@ -284,6 +288,7 @@ function importData(){ ...@@ -284,6 +288,7 @@ function importData(){
"copiesArrayObjects": true, "copiesArrayObjects": true,
"linkFromPortIdProperty": "fromPort", "linkFromPortIdProperty": "fromPort",
"linkToPortIdProperty": "toPort", "linkToPortIdProperty": "toPort",
'linkKeyProperty': "key",
"nodeDataArray": [ "nodeDataArray": [
{"name":"氨分离罐","nodeCollection":"ammonia","img":"src/assets/models/ammonia/氨分离罐.svg","category":"svg","key":-1,"loc":"-450 -400","size":"100 209.94475138121547","portArray":[{"name":"端口1","portId":"11c8ba71-e7cc-41ee-b7d3-cd2814e26f0f","alignment":"0.7939024142622645 0.4946518480722313 0 0","fromLinkable":true,"toLinkable":true,"fromMaxLinks":999,"toMaxLinks":999,"fromSpot":"1 0.5 0 0","toSpot":"1 0.5 0 0","isHighlighted":false},{"name":"端口2","portId":"256b782d-5870-4e05-94ff-34f130c5060e","alignment":"0.5 0 0 0","fromLinkable":true,"toLinkable":true,"fromMaxLinks":999,"toMaxLinks":999,"fromSpot":"0.5 0 0 0","toSpot":"0.5 0 0 0","isHighlighted":false},{"name":"端口3","portId":"dcd15cc2-ec1b-4a35-b861-377b6f75d0b9","alignment":"0.5 1 0 0","fromLinkable":true,"toLinkable":true,"fromMaxLinks":999,"toMaxLinks":999,"fromSpot":"0.5 1 0 0","toSpot":"0.5 1 0 0"}]}, {"name":"氨分离罐","nodeCollection":"ammonia","img":"src/assets/models/ammonia/氨分离罐.svg","category":"svg","key":-1,"loc":"-450 -400","size":"100 209.94475138121547","portArray":[{"name":"端口1","portId":"11c8ba71-e7cc-41ee-b7d3-cd2814e26f0f","alignment":"0.7939024142622645 0.4946518480722313 0 0","fromLinkable":true,"toLinkable":true,"fromMaxLinks":999,"toMaxLinks":999,"fromSpot":"1 0.5 0 0","toSpot":"1 0.5 0 0","isHighlighted":false},{"name":"端口2","portId":"256b782d-5870-4e05-94ff-34f130c5060e","alignment":"0.5 0 0 0","fromLinkable":true,"toLinkable":true,"fromMaxLinks":999,"toMaxLinks":999,"fromSpot":"0.5 0 0 0","toSpot":"0.5 0 0 0","isHighlighted":false},{"name":"端口3","portId":"dcd15cc2-ec1b-4a35-b861-377b6f75d0b9","alignment":"0.5 1 0 0","fromLinkable":true,"toLinkable":true,"fromMaxLinks":999,"toMaxLinks":999,"fromSpot":"0.5 1 0 0","toSpot":"0.5 1 0 0"}]},
{"name":"冷却器","nodeCollection":"ammonia","img":"src/assets/models/ammonia/冷却器.svg","category":"svg","key":-5,"loc":"-250 -330","size":"97.77777777777777 40","portArray":[{"name":"端口1","portId":"51b9d16b-8eea-4c4e-92a2-5bb9d99d294f","alignment":"0 0.5 0 0","fromLinkable":true,"toLinkable":true,"fromMaxLinks":999,"toMaxLinks":999,"fromSpot":"0 0.5 0 0","toSpot":"0 0.5 0 0","isHighlighted":false},{"name":"端口2","portId":"a8e9572b-53fb-4791-a173-e272c28bc8af","alignment":"1 0.5 0 0","fromLinkable":true,"toLinkable":true,"fromMaxLinks":999,"toMaxLinks":999,"fromSpot":"1 0.5 0 0","toSpot":"1 0.5 0 0","isHighlighted":false}]}, {"name":"冷却器","nodeCollection":"ammonia","img":"src/assets/models/ammonia/冷却器.svg","category":"svg","key":-5,"loc":"-250 -330","size":"97.77777777777777 40","portArray":[{"name":"端口1","portId":"51b9d16b-8eea-4c4e-92a2-5bb9d99d294f","alignment":"0 0.5 0 0","fromLinkable":true,"toLinkable":true,"fromMaxLinks":999,"toMaxLinks":999,"fromSpot":"0 0.5 0 0","toSpot":"0 0.5 0 0","isHighlighted":false},{"name":"端口2","portId":"a8e9572b-53fb-4791-a173-e272c28bc8af","alignment":"1 0.5 0 0","fromLinkable":true,"toLinkable":true,"fromMaxLinks":999,"toMaxLinks":999,"fromSpot":"1 0.5 0 0","toSpot":"1 0.5 0 0","isHighlighted":false}]},
...@@ -301,27 +306,27 @@ function importData(){ ...@@ -301,27 +306,27 @@ function importData(){
{"name":"三头","nodeCollection":"pipe","geometry":"F1 M0 0 L60 0 60 20 50 20 Q40 20 40 30 L40 40 20 40 20 30 Q20 20 10 20 L0 20z","fill":"rgba(128, 128, 128, 0.5)","category":"geometry","portArray":[{"name":"端口1","portId":"854f9c8e-0652-44aa-9705-95dc825ad577","alignment":"0 0.25 0 0","fromLinkable":true,"toLinkable":true,"fromMaxLinks":999,"toMaxLinks":999,"fromSpot":"0 0.5 0 0","toSpot":"0 0.5 0 0","isHighlighted":false},{"name":"端口2","portId":"9c6c8565-d1f4-46fa-b67b-db673fd127aa","alignment":"1 0.25 0 0","fromLinkable":true,"toLinkable":true,"fromMaxLinks":999,"toMaxLinks":999,"fromSpot":"1 0.5 0 0","toSpot":"1 0.5 0 0","isHighlighted":false},{"name":"端口3","portId":"d88aaad3-7e10-47ab-81ec-0040f3c21cf7","alignment":"0.5 1 0 0","fromLinkable":true,"toLinkable":true,"fromMaxLinks":999,"toMaxLinks":999,"fromSpot":"0.5 1 0 0","toSpot":"0.5 1 0 0","isHighlighted":false}],"key":-15,"loc":"357.5 -620","angle":0} {"name":"三头","nodeCollection":"pipe","geometry":"F1 M0 0 L60 0 60 20 50 20 Q40 20 40 30 L40 40 20 40 20 30 Q20 20 10 20 L0 20z","fill":"rgba(128, 128, 128, 0.5)","category":"geometry","portArray":[{"name":"端口1","portId":"854f9c8e-0652-44aa-9705-95dc825ad577","alignment":"0 0.25 0 0","fromLinkable":true,"toLinkable":true,"fromMaxLinks":999,"toMaxLinks":999,"fromSpot":"0 0.5 0 0","toSpot":"0 0.5 0 0","isHighlighted":false},{"name":"端口2","portId":"9c6c8565-d1f4-46fa-b67b-db673fd127aa","alignment":"1 0.25 0 0","fromLinkable":true,"toLinkable":true,"fromMaxLinks":999,"toMaxLinks":999,"fromSpot":"1 0.5 0 0","toSpot":"1 0.5 0 0","isHighlighted":false},{"name":"端口3","portId":"d88aaad3-7e10-47ab-81ec-0040f3c21cf7","alignment":"0.5 1 0 0","fromLinkable":true,"toLinkable":true,"fromMaxLinks":999,"toMaxLinks":999,"fromSpot":"0.5 1 0 0","toSpot":"0.5 1 0 0","isHighlighted":false}],"key":-15,"loc":"357.5 -620","angle":0}
], ],
"linkDataArray": [ "linkDataArray": [
{"from":-5,"to":-1,"fromPort":"51b9d16b-8eea-4c4e-92a2-5bb9d99d294f","toPort":"11c8ba71-e7cc-41ee-b7d3-cd2814e26f0f","points":[-301.3888888888889,-330,-311.3888888888889,-330,-311.3888888888889,-330,-311.3888888888889,-401.1228164268244,-408.10975857377355,-401.1228164268244,-418.10975857377355,-401.1228164268244],"category":"Arrow", 'highlightColor':'red', 'color':'black'}, {"key":-1,"from":-5,"to":-1,"fromPort":"51b9d16b-8eea-4c4e-92a2-5bb9d99d294f","toPort":"11c8ba71-e7cc-41ee-b7d3-cd2814e26f0f","points":[-301.3888888888889,-330,-311.3888888888889,-330,-311.3888888888889,-330,-311.3888888888889,-401.1228164268244,-408.10975857377355,-401.1228164268244,-418.10975857377355,-401.1228164268244],"category":"Arrow", 'highlightColor':'red', 'color':'black'},
{"from":-1,"fromPort":"256b782d-5870-4e05-94ff-34f130c5060e","toPort":"","points":[-450,-507.47237569060775,-450,-517.4723756906078,-450,-547.6190476190478,-519.0476190476192,-547.6190476190478,-588.0952380952383,-547.6190476190478,-598.0952380952383,-547.6190476190478],"from_text":"","middle_text":"","to_text":"燃料气","category":"Arrow", 'highlightColor':'red', 'color':'black'}, {"key":-2,"from":-1,"fromPort":"256b782d-5870-4e05-94ff-34f130c5060e","toPort":"","points":[-450,-507.47237569060775,-450,-517.4723756906078,-450,-547.6190476190478,-519.0476190476192,-547.6190476190478,-588.0952380952383,-547.6190476190478,-598.0952380952383,-547.6190476190478],"from_text":"","middle_text":"","to_text":"燃料气","category":"Arrow", 'highlightColor':'red', 'color':'black'},
{"from":-1,"fromPort":"dcd15cc2-ec1b-4a35-b861-377b6f75d0b9","toPort":"","points":[-450,-292.5276243093923,-450,-282.5276243093923,-450,-248.57142857142867,-519.0476190476192,-248.57142857142867,-588.0952380952383,-248.57142857142867,-598.0952380952383,-248.57142857142867],"from_text":"","middle_text":"","to_text":"氨产品","category":"Arrow", 'highlightColor':'red', 'color':'black'}, {"key":-3,"from":-1,"fromPort":"dcd15cc2-ec1b-4a35-b861-377b6f75d0b9","toPort":"","points":[-450,-292.5276243093923,-450,-282.5276243093923,-450,-248.57142857142867,-519.0476190476192,-248.57142857142867,-588.0952380952383,-248.57142857142867,-598.0952380952383,-248.57142857142867],"from_text":"","middle_text":"","to_text":"氨产品","category":"Arrow", 'highlightColor':'red', 'color':'black'},
{"from":-7,"to":-6,"fromPort":"3f0de33c-e4c4-4187-b7bf-d8192b0708d9","toPort":"0be6a460-df3a-423f-be3d-b38a4adead36","points":[-415,-60,-405,-60,-370,-60,-370,-102.8125,-301.14268500612275,-102.8125,-301.14268500612275,-92.8125],"category":"Arrow", 'highlightColor':'red', 'color':'black'}, {"key":-4,"from":-7,"to":-6,"fromPort":"3f0de33c-e4c4-4187-b7bf-d8192b0708d9","toPort":"0be6a460-df3a-423f-be3d-b38a4adead36","points":[-415,-60,-405,-60,-370,-60,-370,-102.8125,-301.14268500612275,-102.8125,-301.14268500612275,-92.8125],"category":"Arrow", 'highlightColor':'red', 'color':'black'},
{"from":-2,"to":-5,"fromPort":"d88aaad3-7e10-47ab-81ec-0040f3c21cf7","toPort":"a8e9572b-53fb-4791-a173-e272c28bc8af","points":[-180,-221.75,-180,-231.75,-180,-330,-184.30555555555557,-330,-188.61111111111114,-330,-198.61111111111114,-330],"category":"Arrow", 'highlightColor':'red', 'color':'black'}, {"key":-5,"from":-2,"to":-5,"fromPort":"d88aaad3-7e10-47ab-81ec-0040f3c21cf7","toPort":"a8e9572b-53fb-4791-a173-e272c28bc8af","points":[-180,-221.75,-180,-231.75,-180,-330,-184.30555555555557,-330,-188.61111111111114,-330,-198.61111111111114,-330],"category":"Arrow", 'highlightColor':'red', 'color':'black'},
{"from":-2,"to":-7,"fromPort":"9c6c8565-d1f4-46fa-b67b-db673fd127aa","toPort":"4226d10a-0eb2-4c7a-b839-287003f573ff","points":[-213,-188.5,-223,-188.5,-455.89285714285734,-188.5,-455.89285714285734,-143.83333333333331,-455.89285714285734,-99.16666666666663,-455.89285714285734,-89.16666666666663],"category":"Arrow", 'highlightColor':'red', 'color':'black'}, {"key":-6,"from":-2,"to":-7,"fromPort":"9c6c8565-d1f4-46fa-b67b-db673fd127aa","toPort":"4226d10a-0eb2-4c7a-b839-287003f573ff","points":[-213,-188.5,-223,-188.5,-455.89285714285734,-188.5,-455.89285714285734,-143.83333333333331,-455.89285714285734,-99.16666666666663,-455.89285714285734,-89.16666666666663],"category":"Arrow", 'highlightColor':'red', 'color':'black'},
{"to":-7,"fromPort":"","toPort":"55950fe5-ebe1-4d75-b6b4-30da5e97af17","points":[-599.2109634992121,-61.18966252420353,-589.2109634992121,-61.18966252420353,-550,-61.18966252420353,-550,-60,-510,-60,-500,-60],"from_text":"原料气","middle_text":"","to_text":"","category":"Arrow", 'highlightColor':'red', 'color':'black'}, {"key":-7,"to":-7,"fromPort":"","toPort":"55950fe5-ebe1-4d75-b6b4-30da5e97af17","points":[-599.2109634992121,-61.18966252420353,-589.2109634992121,-61.18966252420353,-550,-61.18966252420353,-550,-60,-510,-60,-500,-60],"from_text":"原料气","middle_text":"","to_text":"","category":"Arrow", 'highlightColor':'red', 'color':'black'},
{"from":-6,"to":-9,"fromPort":"0d7b8599-993d-4474-9fb7-a1f1425cbe32","toPort":"d17eb676-1f01-43f1-b658-b16fde8e4159","points":[-301.14268500612275,-47.8125,-301.14268500612275,-37.8125,-301.14268500612275,100,-64.19634250306137,100,172.75,100,182.75,100],"category":"Arrow", 'highlightColor':'red', 'color':'black'}, {"key":-8,"from":-6,"to":-9,"fromPort":"0d7b8599-993d-4474-9fb7-a1f1425cbe32","toPort":"d17eb676-1f01-43f1-b658-b16fde8e4159","points":[-301.14268500612275,-47.8125,-301.14268500612275,-37.8125,-301.14268500612275,100,-64.19634250306137,100,172.75,100,182.75,100],"category":"Arrow", 'highlightColor':'red', 'color':'black'},
{"from":-9,"to":-8,"fromPort":"d5501d1f-5fa8-4d71-8a77-37c64482de72","toPort":"17fac662-e52f-43de-8c27-d24452d9ed2a","points":[251.25,70.5,251.25,60.5,251.25,12.155062499999984,175.1293103448276,12.155062499999984,99.00862068965517,12.155062499999984,89.00862068965517,12.155062499999984],"category":"Arrow", 'highlightColor':'red', 'color':'black'}, {"key":-9,"from":-9,"to":-8,"fromPort":"d5501d1f-5fa8-4d71-8a77-37c64482de72","toPort":"17fac662-e52f-43de-8c27-d24452d9ed2a","points":[251.25,70.5,251.25,60.5,251.25,12.155062499999984,175.1293103448276,12.155062499999984,99.00862068965517,12.155062499999984,89.00862068965517,12.155062499999984],"category":"Arrow", 'highlightColor':'red', 'color':'black'},
{"from":-9,"fromPort":"96dee2d1-babb-4b4d-b5cb-0bafad3131d9","toPort":"","points":[251.25,129.5,251.25,139.5,251.25,208.17973750000021,251.60979375000034,208.17973750000021,251.60979375000034,276.85947500000043,251.60979375000034,286.85947500000043],"category":"Arrow", 'highlightColor':'red', 'color':'black'}, {"key":-10,"from":-9,"fromPort":"96dee2d1-babb-4b4d-b5cb-0bafad3131d9","toPort":"","points":[251.25,129.5,251.25,139.5,251.25,208.17973750000021,251.60979375000034,208.17973750000021,251.60979375000034,276.85947500000043,251.60979375000034,286.85947500000043],"category":"Arrow", 'highlightColor':'red', 'color':'black'},
{"from":-3,"to":-2,"fromPort":"e8cd7aef-9139-480c-ade2-1ef79cc4261d","toPort":"854f9c8e-0652-44aa-9705-95dc825ad577","points":[-50.258620689655174,-100.88701875000004,-60.258620689655174,-100.88701875000004,-98.62931034482759,-100.88701875000004,-98.62931034482759,-188.5,-137,-188.5,-147,-188.5],"category":"Arrow", 'highlightColor':'red', 'color':'black'}, {"key":-11,"from":-3,"to":-2,"fromPort":"e8cd7aef-9139-480c-ade2-1ef79cc4261d","toPort":"854f9c8e-0652-44aa-9705-95dc825ad577","points":[-50.258620689655174,-100.88701875000004,-60.258620689655174,-100.88701875000004,-98.62931034482759,-100.88701875000004,-98.62931034482759,-188.5,-137,-188.5,-147,-188.5],"category":"Arrow", 'highlightColor':'red', 'color':'black'},
{"from":-8,"to":-3,"fromPort":"fdc201ee-d40d-4d87-bd11-df445f3f976d","toPort":"2b860c7b-eafc-49b2-90ba-d32d007a2e7b","points":[18.75,-6.25,18.75,-16.25,18.75,-44.375,19,-44.375,19,-72.5,19,-82.5],"category":"Arrow", 'highlightColor':'red', 'color':'black'}, {"key":-12,"from":-8,"to":-3,"fromPort":"fdc201ee-d40d-4d87-bd11-df445f3f976d","toPort":"2b860c7b-eafc-49b2-90ba-d32d007a2e7b","points":[18.75,-6.25,18.75,-16.25,18.75,-44.375,19,-44.375,19,-72.5,19,-82.5],"category":"Arrow", 'highlightColor':'red', 'color':'black'},
{"from":-10,"to":-3,"fromPort":"16d8e009-b1b1-45c2-a94f-1a90943ee090","toPort":"fdc201ee-d40d-4d87-bd11-df445f3f976d","points":[18.75,-316.75,18.75,-306.75,18.75,-217.125,19.786697850832525,-217.125,19.786697850832525,-127.5,19.786697850832525,-117.5],"category":"Arrow", 'highlightColor':'red', 'color':'black'}, {"key":-13,"from":-10,"to":-3,"fromPort":"16d8e009-b1b1-45c2-a94f-1a90943ee090","toPort":"fdc201ee-d40d-4d87-bd11-df445f3f976d","points":[18.75,-316.75,18.75,-306.75,18.75,-217.125,19.786697850832525,-217.125,19.786697850832525,-127.5,19.786697850832525,-117.5],"category":"Arrow", 'highlightColor':'red', 'color':'black'},
{"from":-3,"to":-12,"fromPort":"17fac662-e52f-43de-8c27-d24452d9ed2a","toPort":"9c6c8565-d1f4-46fa-b67b-db673fd127aa","points":[90.25862068965517,-102.10252500000001,100.25862068965517,-102.10252500000001,263.62931034482756,-102.10252500000001,263.62931034482756,-103.0625,427,-103.0625,437,-103.0625],"category":"Arrow", 'highlightColor':'red', 'color':'black'}, {"key":-14,"from":-3,"to":-12,"fromPort":"17fac662-e52f-43de-8c27-d24452d9ed2a","toPort":"9c6c8565-d1f4-46fa-b67b-db673fd127aa","points":[90.25862068965517,-102.10252500000001,100.25862068965517,-102.10252500000001,263.62931034482756,-102.10252500000001,263.62931034482756,-103.0625,427,-103.0625,437,-103.0625],"category":"Arrow", 'highlightColor':'red', 'color':'black'},
{"from":-12,"to":-4,"fromPort":"d88aaad3-7e10-47ab-81ec-0040f3c21cf7","toPort":"3a24769a-5f3a-49e6-953d-a5e1fce7e8be","points":[470,-136.3125,470,-146.3125,470,-204.65625,470,-204.65625,470,-263,470,-273],"category":"Arrow", 'highlightColor':'red', 'color':'black'}, {"key":-15,"from":-12,"to":-4,"fromPort":"d88aaad3-7e10-47ab-81ec-0040f3c21cf7","toPort":"3a24769a-5f3a-49e6-953d-a5e1fce7e8be","points":[470,-136.3125,470,-146.3125,470,-204.65625,470,-204.65625,470,-263,470,-273],"category":"Arrow", 'highlightColor':'red', 'color':'black'},
{"from":-12,"to":-13,"fromPort":"854f9c8e-0652-44aa-9705-95dc825ad577","toPort":"9c6c8565-d1f4-46fa-b67b-db673fd127aa","points":[503,-103.0625,513,-103.0625,691.5,-103.0625,691.5,-150.03125,691.5,-197,691.5,-207],"category":"Arrow", 'highlightColor':'red', 'color':'black'}, {"key":-16,"from":-12,"to":-13,"fromPort":"854f9c8e-0652-44aa-9705-95dc825ad577","toPort":"9c6c8565-d1f4-46fa-b67b-db673fd127aa","points":[503,-103.0625,513,-103.0625,691.5,-103.0625,691.5,-150.03125,691.5,-197,691.5,-207],"category":"Arrow", 'highlightColor':'red', 'color':'black'},
{"from":-13,"to":-11,"fromPort":"d88aaad3-7e10-47ab-81ec-0040f3c21cf7","toPort":"415f271d-1dd7-415f-ab4f-d5a7221b095a","points":[658.25,-240,648.25,-240,481.0977750000001,-240,481.0977750000001,-238.20473125000035,313.94555000000025,-238.20473125000035,303.94555000000025,-238.20473125000035],"category":"Arrow", 'highlightColor':'red', 'color':'black'}, {"key":-17,"from":-13,"to":-11,"fromPort":"d88aaad3-7e10-47ab-81ec-0040f3c21cf7","toPort":"415f271d-1dd7-415f-ab4f-d5a7221b095a","points":[658.25,-240,648.25,-240,481.0977750000001,-240,481.0977750000001,-238.20473125000035,313.94555000000025,-238.20473125000035,303.94555000000025,-238.20473125000035],"category":"Arrow", 'highlightColor':'red', 'color':'black'},
{"from":-4,"to":-15,"fromPort":"58c1fc66-36b0-4e21-af4f-85e52828ac76","toPort":"d88aaad3-7e10-47ab-81ec-0040f3c21cf7","points":[419.2806687500005,-498.35756250000065,409.2806687500005,-498.35756250000065,412,-498.35756250000065,412,-498.35756250000065,357.5,-498.35756250000065,357.5,-588.25,357.5,-598.25],"category":"Arrow", 'highlightColor':'red', 'color':'black'}, {"key":-18,"from":-4,"to":-15,"fromPort":"58c1fc66-36b0-4e21-af4f-85e52828ac76","toPort":"d88aaad3-7e10-47ab-81ec-0040f3c21cf7","points":[419.2806687500005,-498.35756250000065,409.2806687500005,-498.35756250000065,412,-498.35756250000065,412,-498.35756250000065,357.5,-498.35756250000065,357.5,-588.25,357.5,-598.25],"category":"Arrow", 'highlightColor':'red', 'color':'black'},
{"from":-15,"to":-11,"fromPort":"854f9c8e-0652-44aa-9705-95dc825ad577","toPort":"ab215031-702e-4d22-9663-8c4f631c19ed","points":[324.5,-631.5,314.5,-631.5,314.5,-631.5,314.5,-600,295,-600,285,-600],"category":"Arrow", 'highlightColor':'red', 'color':'black'}, {"key":-19,"from":-15,"to":-11,"fromPort":"854f9c8e-0652-44aa-9705-95dc825ad577","toPort":"ab215031-702e-4d22-9663-8c4f631c19ed","points":[324.5,-631.5,314.5,-631.5,314.5,-631.5,314.5,-600,295,-600,285,-600],"category":"Arrow", 'highlightColor':'red', 'color':'black'},
{"from":-13,"to":-15,"fromPort":"854f9c8e-0652-44aa-9705-95dc825ad577","toPort":"9c6c8565-d1f4-46fa-b67b-db673fd127aa","points":[691.5,-273,691.5,-283,691.5,-631.5,546,-631.5,400.5,-631.5,390.5,-631.5],"category":"Arrow", 'highlightColor':'red', 'color':'black'}, {"key":-20,"from":-13,"to":-15,"fromPort":"854f9c8e-0652-44aa-9705-95dc825ad577","toPort":"9c6c8565-d1f4-46fa-b67b-db673fd127aa","points":[691.5,-273,691.5,-283,691.5,-631.5,546,-631.5,400.5,-631.5,390.5,-631.5],"category":"Arrow", 'highlightColor':'red', 'color':'black'},
{"from":-11,"to":-10,"fromPort":"ec58dcb4-39fb-400e-bb0e-018ecee51d56","toPort":"ba564564-2ac8-48da-a430-3af06ea4997d","category":"Arrow", 'highlightColor':'red', 'color':'black',"points":[220,-733.25,220,-743.25,92.125,-743.25,92.125,-401.25,58.25,-401.25,48.25,-401.25]} {"key":-21,"from":-11,"to":-10,"fromPort":"ec58dcb4-39fb-400e-bb0e-018ecee51d56","toPort":"ba564564-2ac8-48da-a430-3af06ea4997d","category":"Arrow", 'highlightColor':'red', 'color':'black',"points":[220,-733.25,220,-743.25,92.125,-743.25,92.125,-401.25,58.25,-401.25,48.25,-401.25]}
]} ]}
myDiagram.model = go.Model.fromJson(json) myDiagram.model = go.Model.fromJson(json)
changeDiagramConfig('mode', 'readonly') changeDiagramConfig('mode', 'readonly')
...@@ -396,10 +401,11 @@ function initDiagram(){ ...@@ -396,10 +401,11 @@ function initDiagram(){
// tool.temporaryLink.routing = go.Link.Orthogonal; // optional, but need to keep link template in sync, below // tool.temporaryLink.routing = go.Link.Orthogonal; // optional, but need to keep link template in sync, below
// myDiagram.toolManager.linkingTool = tool; // myDiagram.toolManager.linkingTool = tool;
myDiagram.model.linkFromPortIdProperty = "fromPort"; // necessary to remember portIds
myDiagram.model.linkToPortIdProperty = "toPort";
myDiagram.model.copiesArrays = true; myDiagram.model.copiesArrays = true;
myDiagram.model.copiesArrayObjects = true; myDiagram.model.copiesArrayObjects = true;
myDiagram.model.linkFromPortIdProperty = "fromPort"; // necessary to remember portIds
myDiagram.model.linkToPortIdProperty = "toPort";
myDiagram.model.linkKeyProperty = "key";
//多种类型的连接线 //多种类型的连接线
myDiagram.linkTemplateMap.add('Arrow', ArrowLink) myDiagram.linkTemplateMap.add('Arrow', ArrowLink)
...@@ -423,13 +429,14 @@ function listenDiagram(){ ...@@ -423,13 +429,14 @@ function listenDiagram(){
selectedNode.value = null selectedNode.value = null
selectedLink.value = null selectedLink.value = null
let currentSelected = myDiagram.selection.first() let currentSelected = myDiagram.selection.first()
console.log(currentSelected)
if (currentSelected === null) { if (currentSelected === null) {
ifSelectNode.value = false ifSelectNode.value = false
ifSelectLink.value = false ifSelectLink.value = false
return return
} }
// 存在 key 说明是节点 // 不存在 points 说明是节点
if(currentSelected.data.key){ if(!currentSelected.data.points){
freshSelectionNode() freshSelectionNode()
} }
// 存在 points 说明是连接线 // 存在 points 说明是连接线
...@@ -500,17 +507,25 @@ function initInspector(){ ...@@ -500,17 +507,25 @@ function initInspector(){
"key": {show: Inspector.showIfPresent, readOnly:true}, "key": {show: Inspector.showIfPresent, readOnly:true},
"name": {show: Inspector.showIfNode, name:'名称'}, "name": {show: Inspector.showIfNode, name:'名称'},
//连接线基本信息 //连接线基本信息
"from":{show: Inspector.showIfLink, name:"源", readOnly:true}, // "from":{show: Inspector.showIfLink, name:"源", readOnly:true},
"to":{show: Inspector.showIfLink, name:"目的", readOnly:true}, // "to":{show: Inspector.showIfLink, name:"目的", readOnly:true},
"from_text": {show:Inspector.showIfLink, name:"源标签"}, // "from_text": {show:Inspector.showIfLink, name:"源标签"},
"middle_text": {show:Inspector.showIfLink, name:"中间标签"}, // "middle_text": {show:Inspector.showIfLink, name:"中间标签"},
"to_text": {show:Inspector.showIfLink, name:"目的标签"}, // "to_text": {show:Inspector.showIfLink, name:"目的标签"},
"category": {show:Inspector.showIfLink, name:"类别", type: "select", choices: ["Arrow", "Flow"]}, // "category": {show:Inspector.showIfLink, name:"类别", type: "select", choices: ["Arrow", "Flow"]},
"thick":{show: Inspector.showIfNode, name:"厚度", unit:"mm"}, // "thick":{show: Inspector.showIfNode, name:"厚度", unit:"mm"},
"temperature":{show: Inspector.showIfNode, name:"温度高低", unit:"℃"}, // "temperature":{show: Inspector.showIfNode, name:"温度高低", unit:"℃"},
"press": {show: Inspector.showIfNode, name:"压力", unit:'MPa'}, // "press": {show: Inspector.showIfNode, name:"压力", unit:'MPa'},
"thing":{show: Inspector.showIfNode, name:"物料"}, // "thing":{show: Inspector.showIfNode, name:"物料"},
"trd":{show:Inspector.showIfPresent, name:"检测厚度", unit:"mm", readOnly:true},
"a":{show:Inspector.showIfPresent, name:"服役时间", unit:"year", readOnly:true},
"r":{show:Inspector.showIfPresent, name:"腐蚀速率", unit:"mm/year", readOnly:true},
"tmin":{show:Inspector.showIfPresent, name:"计算厚度", unit:"mm", readOnly:true},
"CA":{show:Inspector.showIfPresent, name:"腐蚀裕量", unit:"mm", readOnly:true},
"t":{show:Inspector.showIfPresent, name:"名义厚度", unit:"mm", readOnly:true},
"failurePossibility":{show:Inspector.showIfPresent, name:"失效可能性", readOnly:true}
} }
} }
) )
...@@ -614,13 +629,43 @@ function highlightPort(portId:string, highlight:boolean){ ...@@ -614,13 +629,43 @@ function highlightPort(portId:string, highlight:boolean){
function changeDeviceData(){ function changeDeviceData(){
let model = myDiagram.model let model = myDiagram.model
let nodeDataArray = myDiagram.model.nodeDataArray let nodeDataArray = myDiagram.model.nodeDataArray
let linkDataArray = myDiagram.model.linkDataArray
nodeDataArray.forEach((item:any)=>{ nodeDataArray.forEach((item:any)=>{
if (item.nodeCollection === "ammonia"){ // model.set(item, "press", Math.floor(Math.random()*100))
model.set(item, "press", Math.floor(Math.random()*100)) // model.set(item, "thick", Math.random().toFixed(2))
model.set(item, "thick", Math.random().toFixed(2)) // model.set(item, "temperature", Math.floor(Math.random()*10))
model.set(item, "temperature", Math.floor(Math.random()*10)) model.set(item, "trd", (Math.random()*180+20).toFixed(2))
} model.set(item, "a", (Math.random()*2).toFixed(2))
model.set(item, "r", (Math.random()*4.5+0.5).toFixed(2))
model.set(item, "tmin", (Math.random()*100+100).toFixed(2))
model.set(item, "CA", (Math.random()*50+50).toFixed(2))
let averageFailurePossibility = getAverageFailurePossibility(DeviceType.CONTAINER)
let managementSystemEvaluationCoefficient = getManagementSystemEvaluationCoefficient()
let deviceCorrectionCoefficient = getDeviceCorrectionCoefficient(DeviceType.CONTAINER, item['trd'], item['a'], item['r'], item['tmin'], item['CA'])
let exceedingDefectInfluenceCoefficient = getExceedingDefectInfluenceCoefficient()
let deviceFailurePossibility = getDeviceFailurePossibility(averageFailurePossibility, managementSystemEvaluationCoefficient, deviceCorrectionCoefficient, exceedingDefectInfluenceCoefficient)
model.set(item, 'failurePossibility', deviceFailurePossibility.valueOf())
}) })
linkDataArray.forEach((item:any)=>{
model.set(item, "trd", (Math.random()*180+20).toFixed(2))
model.set(item, "a", (Math.random()*2).toFixed(2))
model.set(item, "r", (Math.random()*4.5+0.5).toFixed(2))
model.set(item, "t", (Math.random()*30+10).toFixed(2))
model.set(item, "CA", (Math.random()*50+50).toFixed(2))
let averageFailurePossibility = getAverageFailurePossibility(DeviceType.PUMP)
let managementSystemEvaluationCoefficient = getManagementSystemEvaluationCoefficient()
let deviceCorrectionCoefficient = getDeviceCorrectionCoefficient(DeviceType.PUMP, item['trd'], item['a'], item['r'], item['t'], item['CA'])
let exceedingDefectInfluenceCoefficient = getExceedingDefectInfluenceCoefficient()
let deviceFailurePossibility = getDeviceFailurePossibility(averageFailurePossibility, managementSystemEvaluationCoefficient, deviceCorrectionCoefficient, exceedingDefectInfluenceCoefficient)
model.set(item, 'failurePossibility', deviceFailurePossibility.valueOf())
}
)
} }
function changeDataRealTime(){ function changeDataRealTime(){
......
...@@ -135,53 +135,6 @@ export function cancelHighlightLink(from:number, to:number, myDiagram:any){ ...@@ -135,53 +135,6 @@ export function cancelHighlightLink(from:number, to:number, myDiagram:any){
}) })
} }
/**
* 这里只以计算压力数据为例。
*/
export function computeData(pathNodesMap:any, analyzeResult:any){
let nodesDataMap:Record<any, any> = {}
let offset = 0.1
console.log("compute", pathNodesMap);
for (let key in pathNodesMap){
let path = pathNodesMap[key]
for (let node of path.nodes){
if (node.data.key in nodesDataMap){
let currentNodeIndex = path.nodes.indexOf(node)
if (currentNodeIndex == 0){
continue
}
let lastNode = path.nodes[currentNodeIndex-1]
nodesDataMap[node.data.key]['predict'] += lastNode.data.press * path.weight
}
else{
nodesDataMap[node.data.key] = {'predict': 0, 'real': node.data.press}
let currentNodeIndex = path.nodes.indexOf(node)
if (currentNodeIndex == 0){
nodesDataMap[node.data.key]['predict'] = node.data.press
continue
}
let lastNode = path.nodes[currentNodeIndex-1]
nodesDataMap[node.data.key]['predict'] += lastNode.data.press * path.weight
}
}
}
analyzeResult.value = {}
for (let key in nodesDataMap){
let value = nodesDataMap[key]
if(value['predict'] < value['real']*(1-offset)){
analyzeResult.value[key] = "压力过高"
}
else if(value['predict'] > value['real']*(1+offset)){
analyzeResult.value[key] = "压力过低"
}
else{
analyzeResult.value[key] = "压力正常"
}
}
console.log(analyzeResult.value)
return nodesDataMap
}
export function spliceListMapWithKey(list:any, key:string, spliceKey?:string){ export function spliceListMapWithKey(list:any, key:string, spliceKey?:string){
let spliceList = [] let spliceList = []
for (let item of list){ for (let item of list){
......
import * as math from 'mathjs'
export class DeviceType{
static CONTAINER = 'container';
static PUMP = 'pump';
}
export const thingFactoryData:Record<string, number> = {
'0.02': 1,
'0.04': 1,
'0.06': 1,
'0.08': 1,
'0.1': 1,
'0.12': 2,
'0.14': 10,
'0.16': 50,
'0.18': 130,
'0.2': 210,
'0.25': 290,
'0.3': 400,
'0.35': 550,
'0.4': 700,
'0.45': 810,
'0.5': 970,
'0.55': 1130,
'0.6': 1250,
'0.65': 1400,
}
//计算设备失效可能性
//失效概率 = 同类设备失效平均概率 * 管理系统评价系数 * 设备修正系数 * 超标缺陷影响系数
export function getDeviceFailurePossibility(averageFailurePossibility:math.BigNumber, managementSystemEvaluationCoefficient:math.BigNumber, deviceCorrectionCoefficient:math.BigNumber, exceedingDefectInfluenceCoefficient:math.BigNumber){
return math.chain(averageFailurePossibility).multiply(managementSystemEvaluationCoefficient).multiply(deviceCorrectionCoefficient).multiply(exceedingDefectInfluenceCoefficient).done()
}
// 计算同类设备平均失效概率
export function getAverageFailurePossibility(deviceType:string){
if (deviceType == DeviceType.CONTAINER){
return math.bignumber(8e-6)
}else if(deviceType == DeviceType.PUMP){
return math.bignumber(8e-6)
}else{
return math.bignumber(0)
}
}
// 计算管理系统评价系数
export function getManagementSystemEvaluationCoefficient(){
return math.bignumber(0.1)
}
// 计算设备修正系数
export function getDeviceCorrectionCoefficient(deviceType: string = DeviceType.CONTAINER, trd: number | string, a: number | string, r: number | string, tmin: number | string, CA: number | string){
// 计算单个设备的减薄因子
let thinningFactor
if (deviceType === DeviceType.CONTAINER){
thinningFactor = getContainerThinningFactor(trd, a, r, tmin, CA)
}else if(deviceType === DeviceType.PUMP){
thinningFactor = getPumpThinningFactor(trd, a, r, tmin, CA)
}else{
thinningFactor = math.bignumber(0)
}
let thinningData = convertThinningFactor(thinningFactor)
return math.chain(25).add(thinningData).done() as math.BigNumber
}
// 计算超标缺陷影响系数
export function getExceedingDefectInfluenceCoefficient(){
return math.bignumber(1.0)
}
/**
* @param trd 检测厚度 mm
* @param a 使用年限 year
* @param r 腐蚀速率 mm/year
* @param tmin 计算厚度 mm
* @param CA 腐蚀裕量 mm
* @return 容器减薄次因子
*/
export function getContainerThinningFactor(trd: number|string, a: number|string, r:number|string, tmin:number|string, CA:number|string) {
let m_trd = math.bignumber(trd)
let m_a = math.bignumber(a)
let m_r = math.bignumber(r)
let m_tmin = math.bignumber(tmin)
let m_CA = math.bignumber(CA)
let molecular = math.chain(m_trd).subtract(math.chain(m_a).multiply(m_r).done()).done()
let denominator = math.chain(m_tmin).add(m_CA).done()
let division = math.chain(molecular).divide(denominator).done()
let result = math.chain(math.bignumber(1)).subtract(division).done() as math.BigNumber
if (math.compare(result, 0) == -1) {
result = math.bignumber(0);
}
return result
}
/**
* @param trd 检测厚度 mm
* @param a 使用年限 year
* @param r 腐蚀速率 mm/year
* @param t 名义厚度 mm
* @param CA 腐蚀裕量 mm
* @return 管道减薄次因子
*/
export function getPumpThinningFactor(trd:number|string, a:number|string, r:number|string, t:number|string, CA:number|string){
let m_trd = math.bignumber(trd),
m_a = math.bignumber(a),
m_r = math.bignumber(r),
m_t = math.bignumber(t),
m_CA = math.bignumber(CA)
let molecular = math.chain(m_t).subtract(m_trd).add(math.chain(m_a).multiply(m_r).done()).done()
let denominator = math.chain(m_t).subtract(m_CA).done()
let result = math.chain(molecular).divide(denominator).done() as math.BigNumber
return result
}
export function convertThinningFactor(thinningFactor:math.BigNumber){
let m_thinningFactor = thinningFactor
let keys = Object.keys(thingFactoryData)
if (m_thinningFactor < math.bignumber(keys[0])){
return math.bignumber(thingFactoryData[keys[0]])
}
if (m_thinningFactor > math.bignumber(keys[keys.length-1])){
return math.bignumber(thingFactoryData[keys[keys.length-1]])
}
//找到m_thinningFactor 夹在中间的地方
for(let i=0;i<keys.length-1; i++){
if (math.compare(m_thinningFactor, Number(keys[i])) == 1 && math.compare(m_thinningFactor, Number(keys[i+1])) == -1){
let a = math.bignumber(thingFactoryData[keys[i]])
let b = math.bignumber(thingFactoryData[keys[i+1]])
let c = math.subtract(m_thinningFactor, a)
let d = math.subtract(b, m_thinningFactor)
if (math.compare(c, d) == 1){
return b
}else{
return a
}
}
}
return math.bignumber(1)
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment