数据接入

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

View File

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