数据接入

This commit is contained in:
szz 2025-06-06 09:07:11 +08:00
parent 35782897d0
commit d76a1d2686
2 changed files with 419 additions and 127 deletions

View File

@ -26,39 +26,32 @@ const dialogVisible = ref(false)
const form = ref({ const form = ref({
dataType: [] dataType: []
}) })
let lists = [
const options = [ // {
// name: '',
// value: '',
// unit: 'mm',
// label: 'bjmkztxd', //
// },
{ {
value: 'conductorDiameter',
label: '导体直径',
children: [
{
value: {
title: '导体直径',
calculationValue: 'DmCORE@0',
productValue: '',
lists: [
{
name: '同心度报警门槛值',
value: '',
unit: 'mm',
label: 'bjmkztxd', //
}, {
name: '同心度公差', name: '同心度公差',
value: '', value: '',
unit: 'mm', unit: 'mm',
label: 'gctxd' label: 'gctxd'
}, { },
name: '偏心报警门槛值', // {
value: '', // name: '',
unit: 'mm', // value: '',
label: 'bjmkzpx' // unit: 'mm',
}, { // label: 'bjmkzpx'
// },
{
name: '偏心度公差', name: '偏心度公差',
value: '', value: '',
unit: 'mm', unit: 'mm',
label: 'gcpxd' label: 'gcpxd'
}, { },
{
name: '偏心公差', name: '偏心公差',
value: '', value: '',
unit: 'mm', unit: 'mm',
@ -66,19 +59,21 @@ const options = [
}, { }, {
name: '收缩率', name: '收缩率',
value: '', value: '',
unit: 'mm', unit: '%',
label: 'ssl' label: 'ssl'
}, { },
name: '负报警门槛值', // {
value: '', // name: '',
unit: 'mm', // value: '',
label: 'fbjmkz' // unit: 'mm',
}, { // label: 'fbjmkz'
name: '正报警门槛值', // }, {
value: '', // name: '',
unit: 'mm', // value: '',
label: 'zbjmkz' // unit: 'mm',
}, { // label: 'zbjmkz'
// },
{
name: '负公差', name: '负公差',
value: '', value: '',
unit: 'mm', unit: 'mm',
@ -93,34 +88,56 @@ const options = [
value: '', value: '',
unit: 'mm', unit: 'mm',
label: 'bcz' label: 'bcz'
}], }]
const options = [
{
value: 'conductorDiameter',
label: '导体直径',
children: [
{
value: {
title: '导体直径',
calculationValue: 'DmCORE@0',
productValue: 'DmCORE',
lists,
defIndex: 0, defIndex: 0,
value:'', value:'',
unit:'' unit:'',
xy:'xy'
}, },
label: '导体直径' label: '导体直径'
}, },
{ {
value: { value: {
title: '导体直径X', title: '导体直径X',
calculationValue: ['DmCORE@1'], calculationValue: 'DmCORE@1',
productValue: [''] productValue: 'DmCORE',
lists,
defIndex: 0,
value: '',
unit: '',
xy:'xy'
}, },
label: '导体直径X' label: '导体直径X'
}, },
{ {
value: { value: {
title: '导体直径Y', title: '导体直径Y',
calculationValue: ['DmCORE@2'], calculationValue: 'DmCORE@2',
productValue: [''] productValue: 'DmCORE',
lists,
defIndex: 0,
value: '',
unit: '',
xy:'xy'
}, },
label: '导体直径Y' label: '导体直径Y'
}, },
{ {
value: { value: {
title: '导体直径椭圆度', title: '导体直径椭圆度',
calculationValue: ['DmCORE'], calculationValue: 'EllipticityDmCORE',
productValue: ['DmCORE'] productValue: ''
}, },
label: '导体直径椭圆度' label: '导体直径椭圆度'
} }
@ -131,19 +148,54 @@ const options = [
label: '热外径', label: '热外径',
children: [ children: [
{ {
value: 'hotOuterDiameter', value: {
title: '热外径',
calculationValue: 'DmALL@0',
productValue: 'DmALL',
lists,
defIndex: 0,
value: '',
unit: '',
xy:'xy'
},
label: '热外径' label: '热外径'
}, },
{ {
value: 'hotOuterDiameterX', value: {
title: '热外径X',
calculationValue: 'DmALL@1',
productValue: 'DmALL',
lists,
defIndex: 0,
value: '',
unit: '',
xy:'xy'
},
label: '热外径X' label: '热外径X'
}, },
{ {
value: 'hotOuterDiameterY', value: {
title: '热外径Y',
calculationValue: 'DmALL@2',
productValue: 'DmALL',
lists,
defIndex: 0,
value: '',
unit: '',
xy:'xy'
},
label: '热外径Y' label: '热外径Y'
}, },
{ {
value: 'hotOuterDiameterOval', value: {
title: '热外径椭圆度',
calculationValue: 'EllipticityDmALL',
productValue: 'DmALL',
lists,
defIndex: 0,
value: '',
unit: '',
},
label: '热外径椭圆度' label: '热外径椭圆度'
} }
] ]
@ -157,23 +209,63 @@ const options = [
label: '总厚度', label: '总厚度',
children: [ children: [
{ {
value: 'totalThickness', value: {
title: '总厚度',
calculationValue: 'AvgALL',
productValue: 'WtALL',
lists,
defIndex: 0,
value: '',
unit: '',
},
label: '总厚度' label: '总厚度'
}, },
{ {
value: 'totalThicknessMin', value: {
title: '总厚度',
calculationValue: 'MinALL',
productValue: 'WtALL',
lists,
defIndex: 0,
value: '',
unit: ''
},
label: '总厚度最小厚度' label: '总厚度最小厚度'
}, },
{ {
value: 'totalThickness', value: {
title: '总厚度偏心',
calculationValue: 'EccentricALL',
productValue: 'WtALL',
lists,
defIndex: 0,
value: '',
unit: ''
},
label: '总厚度偏心' label: '总厚度偏心'
}, },
{ {
value: 'totalThicknessOval', value: {
title: '总厚度偏心度',
calculationValue: 'EccentricityALL',
productValue: 'WtALL',
lists,
defIndex: 0,
value: '',
unit: ''
},
label: '总厚度偏心度' label: '总厚度偏心度'
}, },
{ {
value: 'totalThicknessMax', value: {
title: '总厚度同心度',
calculationValue: 'ConcentricityALL',
productValue: 'WtALL',
lists,
defIndex: 0,
value: '',
unit: ''
},
label: '总厚度同心度' label: '总厚度同心度'
} }
] ]
@ -183,23 +275,63 @@ const options = [
label: '内屏层厚度', label: '内屏层厚度',
children: [ children: [
{ {
value: 'innerShieldThickness', value: {
title: '内屏层厚度',
calculationValue: 'AvgISC',
productValue: 'WtISC',
lists,
defIndex: 0,
value: '',
unit: ''
},
label: '内屏层厚度' label: '内屏层厚度'
}, },
{ {
value: 'innerShieldThicknessMin', value: {
title: '内屏层最小厚度',
calculationValue: 'WtISC',
productValue: '',
lists,
defIndex: 0,
value: '',
unit: ''
},
label: '内屏层最小厚度' label: '内屏层最小厚度'
}, },
{ {
value: 'innerShieldThicknessMax', value: {
title: '内屏层偏心',
calculationValue: 'EccentricISC',
productValue: 'WtISC',
lists,
defIndex: 0,
value: '',
unit: ''
},
label: '内屏层偏心' label: '内屏层偏心'
}, },
{ {
value: 'innerShieldThicknessOval', value: {
title: '内屏层同心度',
calculationValue: 'ConcentricityISC',
productValue: 'WtISC',
lists,
defIndex: 0,
value: '',
unit: ''
},
label: '内屏层同心度' label: '内屏层同心度'
}, },
{ {
value: 'innerShieldThicknessMax', value: {
title: '内屏层偏心度',
calculationValue: 'EccentricityISC',
productValue: 'WtISC',
lists,
defIndex: 0,
value: '',
unit: ''
},
label: '内屏层偏心度' label: '内屏层偏心度'
} }
] ]
@ -209,23 +341,63 @@ const options = [
label: '绝缘层厚度', label: '绝缘层厚度',
children: [ children: [
{ {
value: 'insulationThickness', value: {
title: '绝缘层厚度',
calculationValue: 'AvgINS',
productValue: 'WtINS',
lists,
defIndex: 0,
value: '',
unit: ''
},
label: '绝缘层厚度' label: '绝缘层厚度'
}, },
{ {
value: 'insulationThicknessMin', value: {
title: '绝缘层最小厚度',
calculationValue: 'MinINS',
productValue: 'WtINS',
lists,
defIndex: 0,
value: '',
unit: ''
},
label: '绝缘层最小厚度' label: '绝缘层最小厚度'
}, },
{ {
value: 'insulationThicknessMax', value: {
title: '绝缘层偏心',
calculationValue: 'EccentricINS',
productValue: '',
lists,
defIndex: 0,
value: '',
unit: ''
},
label: '绝缘层偏心' label: '绝缘层偏心'
}, },
{ {
value: 'insulationThicknessOval', value: {
title: '绝缘层同心度',
calculationValue: 'ConcentricityINS',
productValue: '',
lists,
defIndex: 0,
value: '',
unit: ''
},
label: '绝缘层同心度' label: '绝缘层同心度'
}, },
{ {
value: 'insulationThicknessMax', value: {
title: '绝缘层偏心度',
calculationValue: 'EccentricINS',
productValue: '',
lists,
defIndex: 0,
value: '',
unit: ''
},
label: '绝缘层偏心度' label: '绝缘层偏心度'
} }
] ]
@ -235,31 +407,71 @@ const options = [
label: '外屏层厚度', label: '外屏层厚度',
children: [ children: [
{ {
value: 'outerShieldThickness', value: {
title: '外屏层厚度',
calculationValue: 'AvgOSC',
productValue: '',
lists,
defIndex: 0,
value: '',
unit: ''
},
label: '外屏层厚度' label: '外屏层厚度'
}, },
{ {
value: 'outerShieldThicknessMin', value: {
title: '外屏层最小厚度',
calculationValue: 'MinOSC',
productValue: '',
lists,
defIndex: 0,
value: '',
unit: ''
},
label: '外屏层最小厚度' label: '外屏层最小厚度'
}, },
{ {
value: 'outerShieldThicknessMax', value: {
title: '外屏层偏心',
calculationValue: 'EccentricOSC',
productValue: '',
lists,
defIndex: 0,
value: '',
unit: ''
},
label: '外屏层偏心' label: '外屏层偏心'
}, },
{ {
value: 'outerShieldThicknessOval', value: {
title: '外屏层同心度',
calculationValue: 'ConcentricityOSC',
productValue: '',
lists,
defIndex: 0,
value: '',
unit: ''
},
label: '外屏层同心度' label: '外屏层同心度'
}, },
{ {
value: 'outerShieldThicknessMax', value: {
title: '外屏层偏心度',
calculationValue: 'EccentricityOSC',
productValue: '',
lists,
defIndex: 0,
value: '',
unit: ''
},
label: '外屏层偏心度' label: '外屏层偏心度'
} }
] ]
}, },
{ // {
value: 'productionInfo', // value: 'productionInfo',
label: '生产线信息' // label: '线'
} // }
] ]
// //

View File

@ -70,19 +70,19 @@
<div class="card-content"> <div class="card-content">
<div class="card-text"> <div class="card-text">
<div> <div>
<div class="difference"> <div class="difference" v-show="item.ssl">
<span class="plus">收缩率</span> <span class="plus">收缩率</span>
<span class="label">9%</span> <span class="label">{{ item.ssl }}%</span>
</div> </div>
<div class="difference"> <div class="difference" v-show="!item.isgc">
<span class="plus">+</span> <span class="plus">{{ item.isaddorsub }}</span>
<span class="label">公差</span> <span class="label">公差</span>
</div> </div>
</div> </div>
<div class="value"> <div class="value" :class="{'value1': !item.isgc}">
{{ item.value }}<span class="unit">{{ item.unit }}</span> {{ item.value }}
</div> </div>
</div> </div>
@ -97,7 +97,10 @@
</el-button> </el-button>
<div class="tolerance-text"> <div class="tolerance-text">
{{ item.lists[item.defIndex].name }}{{ item.lists[item.defIndex].value }} {{
`${item.lists[item.defIndex].name || ''}
${item.lists[item.defIndex].value || ''}${item.lists[item.defIndex].unit || ''}`
}}
</div> </div>
<el-button <el-button
@ -260,7 +263,7 @@
</template> </template>
<script setup> <script setup>
import {computed, onMounted, ref} from 'vue' import {computed, onMounted, ref, watch} from 'vue'
import {getDeviceDetailApi} from "@/api/equipment/index.js"; import {getDeviceDetailApi} from "@/api/equipment/index.js";
import {ArrowLeft, ArrowRight, Close, Plus, Timer} from '@element-plus/icons-vue' import {ArrowLeft, ArrowRight, Close, Plus, Timer} from '@element-plus/icons-vue'
import TemperatureChart from './common/TemperatureChart.vue' import TemperatureChart from './common/TemperatureChart.vue'
@ -277,8 +280,9 @@ import {useRoute} from 'vue-router';
import {useEquipmentStore} from '@/store/modules/equipment.js'; import {useEquipmentStore} from '@/store/modules/equipment.js';
import AddMonitorData from './common/AddMonitorData.vue'; import AddMonitorData from './common/AddMonitorData.vue';
import { base64Decode, base64Encode } from '@/utils/base64' import {base64Decode} from '@/utils/base64'
import { timestampArrayToTime } from '@/utils/time' import {timestampArrayToTime} from '@/utils/time'
const deviceShowStatus = ref('') const deviceShowStatus = ref('')
const { const {
connected, connected,
@ -288,8 +292,7 @@ const {
disconnect, disconnect,
publish publish
} = useMqtt() } = useMqtt()
// const clientId = ref('vue-client-' + Math.random().toString(16).substring(2, 8)) const clientId = ref('vue-client-' + Math.random().toString(16).substring(2, 8))
const clientId = ref('lkk40a9bc')
const deviceInfo = ref({}) const deviceInfo = ref({})
const deviceData = ref(null) const deviceData = ref(null)
const deviceMode = ref(null) const deviceMode = ref(null)
@ -343,17 +346,12 @@ const modeTypeMap = {
'normal':'正常速度', 'normal':'正常速度',
'slow':'慢速模式' 'slow':'慢速模式'
}; };
const cardList = ref([ //
{ title: '外屏层偏心度' }, let productInfo = ref(null)
{ title: '内屏层偏心度' },
{ title: '绝缘层偏心度' },
{ title: '外屏层厚度' },
{ title: '内屏层厚度' },
// { title: '' }
])
const warningList = ref([]) const warningList = ref([])
const warningInserted = ref(false) const warningInserted = ref(false)
const useEquipment = useEquipmentStore(); const useEquipment = useEquipmentStore();
//
let chartDataList = computed(() => useEquipment.getDeviceStatus()); let chartDataList = computed(() => useEquipment.getDeviceStatus());
// //
@ -395,6 +393,8 @@ const cardClick = (e) => {
const handleDataConfirm = (dataType) => { const handleDataConfirm = (dataType) => {
console.log('选择的数据项:', dataType) console.log('选择的数据项:', dataType)
useEquipment.setDeviceData(activeIndex.value, dataType) useEquipment.setDeviceData(activeIndex.value, dataType)
console.log(chartDataList.value, '数据')
changeMode()
// //
} }
// mqtt // mqtt
@ -591,11 +591,42 @@ const handleDeviceShare = () => {
} }
const initSubscribe = async () => { const initSubscribe = async () => {
console.log(clientId.value, 'clientId') console.log(clientId.value, 'clientId')
try {
await publish(`v1/cpy/${deviceInfo.value.deviceCode}/control`, JSON.stringify({ await publish(`v1/cpy/${deviceInfo.value.deviceCode}/control`, JSON.stringify({
method: 'follow', method: 'follow',
cid: clientId.value, cid: clientId.value,
value: "true" // 1 0 value: "true" // 1 0
})) }))
//
subscribe(`v1/cpy/${deviceInfo.value?.deviceCode}/product`, (message) => {
console.log('产品表消息:', message)
productInfo.value = JSON.parse(message.info)
console.log(productInfo.value, '产品信息')
// chartDataList.value.forEach(item => {
// item.list.forEach(listItem => {
// if (listItem.calculationValue) {
// let values = listItem.calculationValue.split('@')
// if (values[1]) {
// listItem.value = message[values[0]][values[1]]
// } else {
// listItem.value = message[values[0]]
// }
//
// }
//
// })
// })
// deviceData.value = message
// if(message){
// deviceMode.value = message.global_dev.device.sports_mode
// console.log(deviceMode.value)
// xRayStatus.value = message.scanner1.xray.enable_status
// }
})
} catch (e) {
}
// //
subscribe(`v1/cpy/${deviceInfo.value?.deviceCode}/infos`, (message) => { subscribe(`v1/cpy/${deviceInfo.value?.deviceCode}/infos`, (message) => {
console.log('设备信息消息:', message) console.log('设备信息消息:', message)
@ -633,13 +664,22 @@ const initSubscribe = async () => {
console.log('计算数据:', message) console.log('计算数据:', message)
chartDataList.value.forEach(item => { chartDataList.value.forEach(item => {
item.list.forEach(listItem => { item.list.forEach(listItem => {
if (listItem.calculationValue.length > 0) { if (listItem.calculationValue) {
let values = listItem.calculationValue.split('@') let values = listItem.calculationValue.split('@')
if (values[1]) {
listItem.value = message[values[0]][values[1]] listItem.value = message[values[0]][values[1]]
} else {
listItem.value = message[values[0]]
}
if (listItem.xy === 'xy') {
listItem.xy = message[values[0]].splice(1)
}
} }
}) })
}) })
// deviceData.value = message // deviceData.value = message
// if(message){ // if(message){
// deviceMode.value = message.global_dev.device.sports_mode // deviceMode.value = message.global_dev.device.sports_mode
@ -702,10 +742,6 @@ const sendDeviceTrend = async () => {
publish(`v1/cpy/1/request`, JSON.stringify({ publish(`v1/cpy/1/request`, JSON.stringify({
method: 'temperature', method: 'temperature',
})) }))
//
subscribe(`v1/cpy/${deviceInfo.value?.deviceCode}/product`, (message) => {
console.log('产品表:', message)
})
// try { // try {
// publish(`v1/cpy/1/request`, JSON.stringify({ // publish(`v1/cpy/1/request`, JSON.stringify({
@ -741,9 +777,48 @@ onMounted(async() => {
await sendDeviceTrend() await sendDeviceTrend()
generateData() generateData()
}) })
const changeMode = () => {
chartDataList.value.forEach(item => {
item.list.forEach(listItem => {
console.log(listItem, 'listItem')
let values = listItem.productValue
listItem.lists.forEach(listItem1 => {
listItem1.value = productInfo.value[values][listItem1.label]
listItem[listItem1.label] = productInfo.value[values][listItem1.label]
console.log(values, listItem[listItem1.label], productInfo.value[values][listItem1.label])
})
listItem.lists.push({
name: '公差',
unit: 'mm',
label: 'allgc',
value: `+${productInfo.value[values]['zgc']} / - ${productInfo.value[values]['fgc']}`
})
if (listItem.xy) {
listItem.lists.push({
name: '',
unit: '',
label: '',
value: `X = ${listItem.xy[0]} mm Y = ${listItem.xy[1]}mm`
})
}
listItem.lists = listItem.lists.filter(item1 => {
return item1.value !== undefined && item1.label !== 'fgc' && item1.label !== 'zgc'
})
listItem.isgc = listItem.value > (Number(listItem.zgc) + Number(listItem.bcz)) || listItem.value < Number(listItem.fgc) + Number(listItem.bcz)
listItem.isaddorsub = listItem.value > Number(listItem.zgc) + Number(listItem.bcz) ? '+' : '-'
})
})
}
onBeforeUnmount(() => { onBeforeUnmount(() => {
disconnect() disconnect()
}) })
watch(() => productInfo.value, (newVal) => {
if (newVal) {
console.log(newVal, chartDataList.value, '数据监听')
changeMode()
}
}, {immediate: true, deep: true})
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@ -888,15 +963,20 @@ onBeforeUnmount(() => {
.value { .value {
font-size: 32px; font-size: 32px;
font-weight: bold; font-weight: bold;
color: red;
margin-bottom: 15px;
margin-bottom: 15px;
color: #000000;
.unit { .unit {
font-size: 16px; font-size: 16px;
margin-left: 5px; margin-left: 5px;
} }
} }
.value1 {
color: red;
}
.tolerance-section { .tolerance-section {
display: flex; display: flex;
align-items: center; align-items: center;