提交更改

This commit is contained in:
zhujiyan
2024-10-14 15:09:58 +08:00
parent 3e91dae797
commit 3fd897fca2
5 changed files with 223 additions and 159 deletions

View File

@@ -34,13 +34,21 @@ export function getBasicRealData(id: any) {
} }
/**** 获取谐波实时数据 ****/ /**** 获取谐波实时数据 ****/
export function getHarmRealData(target: any) { export function getHarmRealData(id: any, target: any) {
return createAxios({ return createAxios({
url: `/cs-harmonic-boot/realData/getHarmRealData?lineId=${id}&target=${target}`, url: `/cs-harmonic-boot/realData/getHarmRealData?lineId=${id}&target=${target}`,
method: 'POST' method: 'POST'
}) })
} }
/**** 获取国标限值 ****/
export function getOverLimitData(id: any) {
return createAxios({
url: `/cs-device-boot/csline/getOverLimitData?id=${id}`,
method: 'POST'
})
}
//获取实时数据列表数据 //获取实时数据列表数据
export function getRealTimeTableList() { export function getRealTimeTableList() {
return createAxios({ return createAxios({

View File

@@ -111,10 +111,10 @@
</el-form-item> </el-form-item>
<el-button type="primary" icon="el-icon-Search" @click="handleClick">查询</el-button> <el-button type="primary" icon="el-icon-Search" @click="handleClick">查询</el-button>
<el-button type="primary" v-if="realTimeFlag" :icon="DataLine" @click="handleHarmonicSpectrum"> <el-button type="primary" v-if="realTimeFlag" :icon="DataLine" @click="handleHarmonicSpectrum">
实时趋势 谐波频谱
</el-button> </el-button>
<el-button type="primary" v-if="realTimeFlag" :icon="TrendCharts" @click="handleTrend"> <el-button type="primary" v-if="realTimeFlag" :icon="TrendCharts" @click="handleTrend">
谐波频谱 实时趋势
</el-button> </el-button>
</el-form> </el-form>
<div <div
@@ -252,8 +252,8 @@
<el-button type="primary" :icon="Platform" @click="handleRecordWaves"> <el-button type="primary" :icon="Platform" @click="handleRecordWaves">
实时录波 实时录波
</el-button> </el-button>
<el-button type="primary" :icon="DataLine" @click="handleHarmonicSpectrum">实时趋势</el-button> <el-button type="primary" :icon="DataLine" @click="handleHarmonicSpectrum">谐波频谱</el-button>
<el-button type="primary" :icon="TrendCharts" @click="handleTrend">谐波频谱</el-button> <el-button type="primary" :icon="TrendCharts" @click="handleTrend">实时趋势</el-button>
</div> --> </div> -->
<div class="view_top_btn" v-if="!realTimeFlag"> <div class="view_top_btn" v-if="!realTimeFlag">
<el-button :icon="Back" @click="handleReturn">返回</el-button> <el-button :icon="Back" @click="handleReturn">返回</el-button>
@@ -294,7 +294,13 @@ import Detail from './detail.vue'
import PointTree from '@/components/tree/govern/pointTree.vue' import PointTree from '@/components/tree/govern/pointTree.vue'
import { mainHeight } from '@/utils/layout' import { mainHeight } from '@/utils/layout'
import { queryByCode, queryByid, queryCsDictTree } from '@/api/system-boot/dictTree' import { queryByCode, queryByid, queryCsDictTree } from '@/api/system-boot/dictTree'
import { getDeviceData, getTabsDataByType, getBasicRealData } from '@/api/cs-device-boot/EquipmentDelivery' import {
getDeviceData,
getTabsDataByType,
getBasicRealData,
getHarmRealData,
getOverLimitData
} from '@/api/cs-device-boot/EquipmentDelivery'
import { deviceHisData, deviceRtData, getGroup } from '@/api/cs-device-boot/csGroup' import { deviceHisData, deviceRtData, getGroup } from '@/api/cs-device-boot/csGroup'
import { ref, reactive, nextTick, onMounted, watch, onUnmounted } from 'vue' import { ref, reactive, nextTick, onMounted, watch, onUnmounted } from 'vue'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
@@ -364,14 +370,30 @@ const handleRecordWaves = () => {
} }
//实时趋势 //实时趋势
const realTrendRef = ref() const realTrendRef = ref()
//谐波频谱
const harmonicSpectrumRef = ref()
//实时趋势
const handleTrend = () => { const handleTrend = () => {
realTimeFlag.value = false realTimeFlag.value = false
sonTab.value = 1 sonTab.value = 1
clearInterval(timer.value)
clearInterval(realDataTimer.value)
getHarmRealData(lineId.value, 0).then((res: any) => {
if (res.code == 'A0000') {
mqttRef.value.on('message', (topic: any, message: any) => {
// console.log('mqtt接收到消息', message,topic)
console.log('mqtt接收到消息', JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message)))))
let obj = JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message))))
realTrendRef.value && realTrendRef.value.setRealTrendData(obj)
})
}
})
getOverLimitData(lineId.value).then((res: any) => {
console.log(res, '获取国标限制')
})
realTrendRef.value && realTrendRef.value.open({ devId: deviceId.value, lineId: lineId.value }) realTrendRef.value && realTrendRef.value.open({ devId: deviceId.value, lineId: lineId.value })
window.clearInterval(timer.value)
} }
//谐波频谱 //谐波频谱
const harmonicSpectrumRef = ref()
const handleHarmonicSpectrum = () => { const handleHarmonicSpectrum = () => {
realTimeFlag.value = false realTimeFlag.value = false
sonTab.value = 2 sonTab.value = 2
@@ -576,22 +598,15 @@ const handleClick = async (tab?: any) => {
} }
//查询实时数据 //查询实时数据
if (dataSet.value.includes('_realtimedata')) { if (dataSet.value.includes('_realtimedata')) {
console.log(66666)
//查询实时数据显示实时录波、实时趋势、谐波频谱 //查询实时数据显示实时录波、实时趋势、谐波频谱
realTimeFlag.value = true realTimeFlag.value = true
let obj = {
type: 2,
dataLevel: formInline.dataLevel,
devId: deviceId.value, //e.id
lineId: lineId.value //e.pid
}
setTimeout(() => { setTimeout(() => {
tableLoading.value = false tableLoading.value = false
}, 1500) }, 1500)
//新的实时数据 //新的实时数据
//1.调用接口 //1.调用接口 mqtt推送数据
getBasicRealData(lineId.value).then((res: any) => { await getBasicRealData(lineId.value).then((res: any) => {
console.log(res, '获取基础实时数据') console.log(res, '获取基础实时数据')
}) })
//2.建立mqtt通讯 //2.建立mqtt通讯
@@ -599,7 +614,7 @@ const handleClick = async (tab?: any) => {
const mqttMessage = ref<any>({}) const mqttMessage = ref<any>({})
//每隔30s调用一下接口通知后台推送mqtt消息 //每隔30s调用一下接口通知后台推送mqtt消息
realDataTimer.value = setInterval(() => { realDataTimer.value = setInterval(() => {
getBasicRealData(lineId.value).then((res: any) => { getBasicRealData(lineId.value).then((res: any) => {
console.log(res, '获取基础实时数据') console.log(res, '获取基础实时数据')
}) })
@@ -617,7 +632,6 @@ const handleClick = async (tab?: any) => {
// console.log('mqtt接收到消息', message,topic) // console.log('mqtt接收到消息', message,topic)
console.log('mqtt接收到消息', JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message))))) console.log('mqtt接收到消息', JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message)))))
let obj = JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message)))) let obj = JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message))))
console.log(obj, '620=================>')
//处理mqtt数据 1转2除 2转1乘 //处理mqtt数据 1转2除 2转1乘
//如果消息返回值是二次值,下拉框是二次值只需要单位换算 除以1000 //如果消息返回值是二次值,下拉框是二次值只需要单位换算 除以1000
//如果消息返回值是一次值,下拉框是一次值只需要单位换算 除以1000 //如果消息返回值是一次值,下拉框是一次值只需要单位换算 除以1000
@@ -825,31 +839,6 @@ queryByCode('Device_Type').then(res => {
const echoName = (value: any, arr: any[]) => { const echoName = (value: any, arr: any[]) => {
return value ? arr.find(item => item.value == value).label : '/' return value ? arr.find(item => item.value == value).label : '/'
} }
const openGroup = () => {
if (!dataSet.value) {
return ElMessage.warning('暂无数据')
}
getGroupLoading.value = true
getGroup(dataSet.value).then((res: any) => {
const call = (data: any[]) => {
data.forEach(item => {
item.label = item.name
item.isShow = item.isShow == 1
if (item.children && item.children.length > 0) {
call(item.children)
}
})
}
call(res.data)
getGroupLoading.value = false
mangePopup.value.open({
deviceData: deviceData.value,
dataSetName: deviceData.value.dataSetList.filter((item: any) => item.id == dataSet.value)[0]?.name,
dataSet: dataSet.value,
tree: res.data
})
})
}
onMounted(() => {}) onMounted(() => {})
onUnmounted(() => { onUnmounted(() => {

View File

@@ -5,14 +5,14 @@
<el-tab-pane v-for="(item, index) in tabsList" :label="item.groupName" :name="index" :key="index"> <el-tab-pane v-for="(item, index) in tabsList" :label="item.groupName" :name="index" :key="index">
<div v-loading="loading"> <div v-loading="loading">
<div class="realtrend_top"> <div class="realtrend_top">
<div class="thead"> <!-- <div class="thead">
<ul v-for="(table, tableIndex) in newTableList" :key="tableIndex"> <ul v-for="(table, tableIndex) in newTableList" :key="tableIndex">
<li> <li>
{{ table[0].value }} {{ table[0].value }}
</li> </li>
</ul> </ul>
</div> </div>
<div class="table" > <div class="table">
<ul v-for="(table, tableIndex) in newTableList" :key="tableIndex"> <ul v-for="(table, tableIndex) in newTableList" :key="tableIndex">
<span v-for="(key, keys) in table"> <span v-for="(key, keys) in table">
<li v-if="keys != 0"> <li v-if="keys != 0">
@@ -20,6 +20,33 @@
</li> </li>
</span> </span>
</ul> </ul>
</div> -->
<div class="realtrend_table">
<div class="thead_left">
<p>次数</p>
<p>{{ item.groupName }}</p>
</div>
<div class="thead_right">
<div class="right_cell" v-for="(value, key, index) in tableData" :key="index">
<p style="color: red; margin: 0 10px">
<span style="color: green">
{{ String(key).replace('data', ' ') }}
</span>
</p>
<p style="color: red; margin: 0 10px">
<span
v-if="
String(key).includes('data') &&
String(key) != 'dataLevel' &&
String(key) != 'dataTime'
"
style="color: green"
>
{{ value }}
</span>
</p>
</div>
</div>
</div> </div>
</div> </div>
<div class="tab_info"> <div class="tab_info">
@@ -150,7 +177,6 @@ const findRealTrendDataByGroupId = (obj: any) => {
item.unshift({ value: myColumns.value[index].title, count: '' }) item.unshift({ value: myColumns.value[index].title, count: '' })
}) })
newTableList.value = list newTableList.value = list
console.log("🚀 ~ getDeviceTrendData ~ newTableList.value:", newTableList.value)
loading.value = false loading.value = false
init() init()
}) })
@@ -184,13 +210,11 @@ const reverseTable = () => {
reverseTable() reverseTable()
const echartsData: any = ref([]), const echartsData: any = ref([])
barCharts = ref() const barCharts = ref()
//加载echarts //加载echarts
const init = () => { const init = () => {
// let list: any = []
let timeList: any = []
let xAxisList: any = [] let xAxisList: any = []
chartsData.value.map((item: any, index: any) => { chartsData.value.map((item: any, index: any) => {
chartsYxiasData.value.map((vv: any, vvs: any) => { chartsYxiasData.value.map((vv: any, vvs: any) => {
@@ -294,7 +318,7 @@ const init = () => {
let list: any = [] let list: any = []
list = [] list = []
chartsYxiasData.value.map((item: any) => { chartsYxiasData.value.map((item: any) => {
console.log(item.gbList, 'guobialist340') // console.log(item.gbList, 'guobialist340')
if (item.gbList.length != 0) { if (item.gbList.length != 0) {
list.push({ phase: item.phase, title: '国标限值', list: item.gbList }) list.push({ phase: item.phase, title: '国标限值', list: item.gbList })
} }
@@ -319,9 +343,12 @@ const init = () => {
data: item.list data: item.list
}) })
}) })
nextTick(() => { // nextTick(() => {
barCharts.value && barCharts.value.initChart() if (barCharts.value) {
}) console.log(barCharts.value, '+++++++++++++++++++#@!')
barCharts.value[activeName.value]?.initChart()
}
// })
return return
} }
@@ -330,8 +357,22 @@ const handleClick = (tab: any, event: any) => {
findRealTrendDataByGroupId(params.value) findRealTrendDataByGroupId(params.value)
init() init()
} }
onMounted(() => { }) //获取mqtt传送的实时数据
defineExpose({ open }) const mqttMessage: any = ref()
const tableData: any = ref({})
const setRealTrendData = (val: any) => {
console.log(val, '7777777777773555')
mqttMessage.value = val
for (let key in val) {
if (String(key).includes('data') && String(key) != 'dataLevel' && String(key) != 'dataTime') {
console.log(val[key], '0000000')
tableData.value[key] = val[key]
}
}
console.log(tableData.value, 'kkkkjjjjjsssslllmmmmmssdddd')
}
onMounted(() => {})
defineExpose({ open, setRealTrendData })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.realtrend { .realtrend {
@@ -345,42 +386,41 @@ defineExpose({ open })
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
.thead { // .thead {
height: 100%; // height: 100%;
overflow-y: hidden; // // overflow-y: hidden;
border: 1px solid #eee; // border: 1px solid #eee;
border-right: 0; // border-right: 0;
ul { // ul {
width: auto; // width: auto;
height: 40px; // height: 40px;
display: flex; // display: flex;
li { // li {
flex: none; // flex: none;
width: 100px; // width: 100px;
line-height: 40px; // line-height: 40px;
border: 1px solid #eee; // border: 1px solid #eee;
text-align: center; // text-align: center;
list-style: none; // list-style: none;
} // }
li:nth-child(1) { // li:nth-child(1) {
flex: none; // flex: none;
width: 200px; // width: 200px;
} // }
// }
} // ul:nth-child(1) {
// li {
ul:nth-child(1) { // font-weight: 800;
li { // background: #f4f6f9;
font-weight: 800; // }
background: #f4f6f9; // }
} // ul:nth-child(4) {
} // height: 48px;
ul:nth-child(4) { // }
height: 48px; // }
}
}
.table { .table {
flex: 1; flex: 1;
@@ -419,6 +459,40 @@ defineExpose({ open })
// .table::-webkit-scrollbar { // .table::-webkit-scrollbar {
// display: none; // display: none;
// } // }
.realtrend_table {
width: 100%;
height: 100px;
display: flex;
border: 2px solid green;
.thead_left {
width: 120px;
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
line-height: 50px;
}
.thead_right {
flex: 1;
align-items: center;
overflow-x: auto;
border: 2px solid yellowgreen;
display: flex;
.right_cell {
width: 100%;
display: flex;
flex-direction: column;
p {
flex: none;
width: 40px;
height: 100%;
line-height: 50px;
}
}
}
}
} }
} }

View File

@@ -60,6 +60,7 @@ const handleClose = () => {
//文件信息 //文件信息
const fileData: any = ref({}) const fileData: any = ref({})
const open = async (row: any, id: any) => { const open = async (row: any, id: any) => {
status.value = 0
fileData.value = {} fileData.value = {}
dialogVisible.value = true dialogVisible.value = true
loading.value = true loading.value = true
@@ -126,7 +127,7 @@ const handleDownLoad = () => {
onMounted(() => {}) onMounted(() => {})
onUnmounted(() => {}) onUnmounted(() => {})
const status = ref(0) const status = ref(0)
const fileName=ref('') const fileName = ref('')
const setStatus = (val: any) => { const setStatus = (val: any) => {
status.value = parseInt(Number((val.nowStep / val.allStep) * 100)) status.value = parseInt(Number((val.nowStep / val.allStep) * 100))
fileName.value = val.fileName fileName.value = val.fileName
@@ -140,11 +141,11 @@ defineExpose({ open, setStatus })
margin: 10px 0; margin: 10px 0;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
.progress_left{ .progress_left {
width: auto; width: auto;
} }
.progress_right{ .progress_right {
flex:1; flex: 1;
padding-left: 10px; padding-left: 10px;
box-sizing: border-box; box-sizing: border-box;
} }

View File

@@ -421,7 +421,6 @@ const init = (flag: boolean) => {
dataLevel: searchForm.value.dataLevel, dataLevel: searchForm.value.dataLevel,
valueType: searchForm.value.type valueType: searchForm.value.type
} }
if (flag) { if (flag) {
loading.value = true loading.value = true
getHistoryTrend(obj) getHistoryTrend(obj)
@@ -429,27 +428,14 @@ const init = (flag: boolean) => {
if (res.code === 'A0000') { if (res.code === 'A0000') {
historyDataList.value = res.data historyDataList.value = res.data
let chartsList = JSON.parse(JSON.stringify(res.data)) let chartsList = JSON.parse(JSON.stringify(res.data))
echartsData.value = null echartsData.value = {}
//icon图标替换legend图例 //icon图标替换legend图例
const iconThree =
'path://M512 85.333333c235.637333 0 426.666667 191.029333 426.666667 426.666667S747.637333 938.666667 512 938.666667 85.333333 747.637333 85.333333 512 276.362667 85.333333 512 85.333333z m214.592 318.677334a32 32 0 0 0-45.248 0.064L544.736 541.066667l-81.792-89.109334a32 32 0 0 0-46.613333-0.576l-119.36 123.733334a32 32 0 1 0 46.058666 44.437333l95.754667-99.264 81.418667 88.704a32 32 0 0 0 46.24 0.96l160.213333-160.693333a32 32 0 0 0-0.064-45.248z'
// let xAxis: any = [] //x轴数据数组
// let timeList: any = [] //x轴数据数组
// y轴单位数组 // y轴单位数组
let unitList: any = [] let unitList: any = []
let allUnitArray: any = [] let allUnitArray: any = []
chartsList.map((item: any) => { chartsList.map((item: any) => {
// timeList.push(item.time)
// if (unitList.indexOf(item.unit) == -1) {
// unitList.push(item.unit)
// }
allUnitArray.push({ name: item.anotherName, unit: item.unit }) allUnitArray.push({ name: item.anotherName, unit: item.unit })
}) })
// xAxis = new Set(
// timeList.sort((a: any, b: any) => {
// return new Date(a).getTime() - new Date(b).getTime()
// })
// )
//去除重复的unit单位数据 //去除重复的unit单位数据
unitList = allUnitArray.reduce((result: any, obj: any) => { unitList = allUnitArray.reduce((result: any, obj: any) => {
if (!result.some((item: any) => JSON.stringify(item) === JSON.stringify(obj))) { if (!result.some((item: any) => JSON.stringify(item) === JSON.stringify(obj))) {
@@ -594,7 +580,8 @@ const init = (flag: boolean) => {
} }
}, },
splitNumber: 5, splitNumber: 5,
minInterval: 1 minInterval: 1,
yAxisIndex: 0
} }
], ],
series: [] series: []
@@ -602,55 +589,6 @@ const init = (flag: boolean) => {
} }
echartsData.value.options.legend.data = [] echartsData.value.options.legend.data = []
list.map((item: any, index: any) => {
item.map((vv: any, indexs: any) => {
//处理legend
if (chartsList.length != 0) {
echartsData.value.options.legend.data.push({
name: vv.phase + '相' + vv.showName
// icon: iconThree
})
}
if (
unitList.findIndex((item: any) => {
return item.unit == vv.unit && item.name == vv.showName
}) != -1
) {
vv.yAxisIndex = unitList.findIndex((item: any) => {
return item.unit == vv.unit && item.name == vv.showName
})
} else {
vv.yAxisIndex = 0
}
echartsData.value.options.series.push({
name: vv.phase + '相' + vv.showName,
type: 'line',
smooth: true,
symbol: 'none',
emphasis: {
focus: 'series'
},
itemStyle: {},
//数据
data: filterArray(
chartsList
.map((kk: any, kks: any) => {
if (kk.statisticalName == vv.name) {
// xAxis[kks]
return [kk.time, kk.statisticalData]
} else {
return ''
}
})
.filter((kk: any) => kk !== '')
),
//数据对应的y轴
// yAxisIndex:0,
yAxisIndex: vv.yAxisIndex
})
})
})
//处理多y轴 //处理多y轴
// if (unitList.length != 0 && unitList.length > 1) { // if (unitList.length != 0 && unitList.length > 1) {
// console.log(max, min) // console.log(max, min)
@@ -694,6 +632,56 @@ const init = (flag: boolean) => {
} }
}) })
// } // }
list.map((item: any, index: any) => {
console.log(item, '++++++++++++596')
item.map((vv: any, indexs: any) => {
//处理legend
if (chartsList.length != 0) {
echartsData.value.options.legend.data.push({
name: vv.phase + '相' + vv.showName
})
}
if (
unitList.findIndex((item: any) => {
return item.unit == vv.unit && item.name == vv.showName
}) != -1
) {
vv.yAxisIndex = unitList.findIndex((item: any) => {
return item.unit == vv.unit && item.name == vv.showName
})
} else {
vv.yAxisIndex = 0
}
console.log(vv, '<================>', vv.unit)
echartsData.value.options.series.push({
name: vv.phase + '相' + vv.showName,
type: 'line',
smooth: true,
symbol: 'none',
emphasis: {
focus: 'series'
},
itemStyle: {},
//数据
data: filterArray(
chartsList
.map((kk: any, kks: any) => {
if (kk.statisticalName == vv.name) {
// xAxis[kks]
return [kk.time, kk.statisticalData]
} else {
return ''
}
})
.filter((kk: any) => kk !== '')
),
//数据对应的y轴
yAxisIndex: vv.yAxisIndex
})
})
})
console.log(list, '6444和那个的哈哈哈哈呀哈哈哈哈哈哈哈哈哈哈哈')
//设置数据项颜色 //设置数据项颜色
echartsData.value.options.series.map((item: any, index: any) => { echartsData.value.options.series.map((item: any, index: any) => {
item.itemStyle = { item.itemStyle = {
@@ -706,6 +694,10 @@ const init = (flag: boolean) => {
} }
// item.data = filterArray(item.data) // item.data = filterArray(item.data)
}) })
// echartsData.value.options.series = echartsData.value.options.series.sort((a: any, b: any) => {
// return a.yAxisIndex - b.yAxisIndex
// })
console.log(echartsData.value.options.series, '...............709')
loading.value = false loading.value = false
} }
}) })