Browse Source

数据监控接口字段修改

develop
fuguobin 11 months ago
parent
commit
d470a3b169
  1. 27
      src/api/dashboard/index.ts
  2. 14
      src/api/table/list.ts
  3. 240
      src/views/dashboard/components/BarChart.vue
  4. 20
      src/views/dashboard/components/LineChart.vue
  5. 340
      src/views/dashboard/components/returnChart.vue
  6. 6
      src/views/dashboard/index.vue
  7. 3
      src/views/monitoring/screen/components/main.vue
  8. 16
      src/views/monitoring/screenData/components/main.vue

27
src/api/dashboard/index.ts

@ -52,3 +52,30 @@ export function getDeviceCountApi() {
method: 'get'
});
}
/**
*
*/
export function getFirstLineApi() {
return request({
url: '/home/first/line',
method: 'get'
});
}
/**
*
*/
export function getSupplyTemperatureRanking() {
return request({
url: '/home/first/supplyTemperatureRanking',
method: 'get'
});
}
/**
*
*/
export function getBackTemperatureRanking() {
return request({
url: '/home/first/backTemperatureRanking',
method: 'get'
});
}

14
src/api/table/list.ts

@ -59,6 +59,17 @@ export function getTableData(data: any) {
});
}
/**
* header
*/
export function getMockTableHeader(): AxiosPromise<[]> {
return request({
// url: '/bi/opt/getTableHeader',
url: '/dc/mock/data/monitor/table/header',
method: 'get'
});
}
/**
*
*
@ -66,7 +77,8 @@ export function getTableData(data: any) {
*/
export function getMockTableData(data: any) {
return request({
url: '/bi/opt/mock/getTableDataPage',
// url: '/bi/opt/mock/getTableDataPage',
url: '/dc/mock/data/monitor/table/data',
method: 'post',
data: data
});

240
src/views/dashboard/components/BarChart.vue

@ -1,11 +1,18 @@
<!-- 线 + 柱混合图 -->
<template>
<div :id="id" :class="className" :style="{ height, width }" />
<div ref="complaintRef" id="stackedLine" class="complaintLine" :style="{ height, width }" />
</template>
<script setup>
import * as echarts from 'echarts';
import { randomColor } from '@/utils/index';
import { randomColor, endTime, debounce } from '@/utils/index';
import { getSupplyTemperatureRanking } from '@/api/dashboard/index';
// import { Ref } from 'vue';
// const complaintRef: Ref<HTMLElement | any> = ref(null);
import useCounter from '@/store/modules/date';
const counterStore = useCounter();
const yearMonthDay = ref();
const timer = ref();
const isCurrentRoute = ref(true);
const mapEcharts = ref();
const props = defineProps({
id: {
@ -28,70 +35,93 @@ const props = defineProps({
}
});
const defualData = [
{
cdate: '2016',
cname: '换热站1,换热站2,换热站3,换热站4,换热站5,换热站6,换热站7,换热站8,换热站9,换热站10',
cut: '20.9,13.82,3.6,0.56,1.49,9.48,32,21,65,19'
},
{
cdate: '2017',
cname: '换热站1,换热站2,换热站3,换热站4,换热站5,换热站6,换热站7,换热站8,换热站9,换热站10',
cut: '18.7,12.82,13.6,9.56,12.49,13.48,21,23,52,53'
},
{
cdate: '2018',
cname: '换热站1,换热站2,换热站3,换热站4,换热站5,换热站6,换热站7,换热站8,换热站9,换热站10',
cut: '14.9,18.82,7.6,19.56,13.49,17.48,80,33,63,42'
},
{
cdate: '2019',
cname: '换热站1,换热站2,换热站3,换热站4,换热站5,换热站6,换热站7,换热站8,换热站9,换热站10',
cut: '16.9,3.82,13.6,15.56,12.49,14.48,54,35,40,20'
},
{
cdate: '2020',
cname: '换热站1,换热站2,换热站3,换热站4,换热站5,换热站6,换热站7,换热站8,换热站9,换热站10',
cut: '3.8,8.82,13.6,21.56,15.49,19.2,16,19,24,52'
},
{
cdate: '2021',
cname: '换热站1,换热站2,换热站3,换热站4,换热站5,换热站6,换热站7,换热站8,换热站9,换热站10',
cut: '23.9,16.82,13.6,17.56,14.49,19.98,18,12,30,35'
},
{
cdate: '2022',
cname: '换热站1,换热站2,换热站3,换热站4,换热站5,换热站6,换热站7,换热站8,换热站9,换热站10',
cut: '12,23,46,52,39,32,25,28,31,37'
},
{
cdate: '2023',
cname: '换热站1,换热站2,换热站3,换热站4,换热站5,换热站6,换热站7,换热站8,换热站9,换热站10',
cut: '52,59,60,49,42,36,10,9,21,28'
}
];
const colors = ['#5470c6', '#91cc75', '#fac858', '#1a94bc', '#f26b1f', '#5bae23'];
const ccolors = {};
var updateFrequency = 1000; //
var years = [];
var startIndex = 0;
for (var i = 0; i < defualData.length; ++i) {
years.push(defualData[i]);
onMounted(() => {
getHeatRate();
});
// watchEffect(() => {
// const dataStr = counterStore.dateStr;
// if (dataStr != '') {
// yearMonthDay.value = counterStore.dateStr.split('-');
// getHeatRate();
// }
// });
function getHeatRate() {
//
const params = {};
getSupplyTemperatureRanking().then(res => {
if (res.code === 200 && Object.keys(res.data).length != 0) {
dataInfo(res.data);
}
});
}
//
var startYear = years[startIndex].cdate;
var startName = years[startIndex].cname.split(',');
var startCut = years[startIndex].cut.split(',');
for (let i = 0; i < startName.length; i++) {
function dataInfo(data) {
const defualData = data;
// const defualData = [
// {
// cdate: '2016',
// cname: '1,2,3,4,5,6,7,8,9,10',
// cut: '20.9,13.82,3.6,0.56,1.49,9.48,32,21,65,19'
// },
// {
// cdate: '2017',
// cname: '1,2,3,4,5,6,7,8,9,10',
// cut: '18.7,12.82,13.6,9.56,12.49,13.48,21,23,52,53'
// },
// {
// cdate: '2018',
// cname: '1,2,3,4,5,6,7,8,9,10',
// cut: '14.9,18.82,7.6,19.56,13.49,17.48,80,33,63,42'
// },
// {
// cdate: '2019',
// cname: '1,2,3,4,5,6,7,8,9,10',
// cut: '16.9,3.82,13.6,15.56,12.49,14.48,54,35,40,20'
// },
// {
// cdate: '2020',
// cname: '1,2,3,4,5,6,7,8,9,10',
// cut: '3.8,8.82,13.6,21.56,15.49,19.2,16,19,24,52'
// },
// {
// cdate: '2021',
// cname: '1,2,3,4,5,6,7,8,9,10',
// cut: '23.9,16.82,13.6,17.56,14.49,19.98,18,12,30,35'
// },
// {
// cdate: '2022',
// cname: '1,2,3,4,5,6,7,8,9,10',
// cut: '12,23,46,52,39,32,25,28,31,37'
// },
// {
// cdate: '2023',
// cname: '1,2,3,4,5,6,7,8,9,10',
// cut: '52,59,60,49,42,36,10,9,21,28'
// }
// ];
const colors = ['#5470c6', '#91cc75', '#fac858', '#1a94bc', '#f26b1f', '#5bae23'];
const ccolors = {};
const chart = echarts.init(document.getElementById('stackedLine'));
mapEcharts.value = chart;
var updateFrequency = 1000; //
var years = [];
var startIndex = 0;
for (var i = 0; i < defualData.length; ++i) {
years.push(defualData[i]);
}
//
var startYear = years[startIndex].cdate;
var startName = years[startIndex].cname.split(',');
var startCut = years[startIndex].cut.split(',');
for (let i = 0; i < startName.length; i++) {
if (i < 6) {
ccolors[startName[i]] = colors[i];
} else {
ccolors[startName[i]] = randomColor();
}
}
console.log(ccolors);
}
console.log(ccolors);
const options = {
const options = {
// tooltip: {
// trigger: 'axis',
// axisPointer: {
@ -108,10 +138,32 @@ const options = {
grid: {
top: '0',
left: '0',
right: '0',
right: '10%',
bottom: '0',
containLabel: true
},
dataZoom: [
//Y
{
type: 'slider',
show: true,
yAxisIndex: [0],
width: 8,
height: '90%',
right: '10',
startValue: 0,
endValue: 10,
zoomLoxk: true,
top: 'middle'
},
{
type: 'inside',
yAxisIndex: [0],
zoomOnMouseWheel: true,
moveOnMouseMove: true,
moveOnMouseWheel: true
}
],
xAxis: {
max: 'dataMax',
type: 'value',
@ -176,7 +228,7 @@ const options = {
{
// name: '2023',
type: 'bar',
barWidth: 20, //
// barWidth: 20, //
showBackground: false,
realtimeSort: true, //
itemStyle: {
@ -220,11 +272,7 @@ const options = {
}
]
}
};
onMounted(() => {
//
const chart = echarts.init(document.getElementById(props.id));
};
chart.setOption(options);
for (var i = startIndex; i < defualData.length - 1; ++i) {
(function (i) {
@ -233,18 +281,60 @@ onMounted(() => {
}, (i + 1) * updateFrequency);
})(i);
}
//
window.addEventListener('resize', () => {
chart.resize();
});
function getDeviceInfos(year) {
options.yAxis.data = year.cname.split(',');
options.series[0].data = year.cut.split(',');
options.graphic.elements[0].style.text = year.cdate;
const chart = echarts.init(document.getElementById(props.id));
const chart = echarts.init(document.getElementById('stackedLine'));
chart.setOption(options);
}
//
window.addEventListener('resize', () => {
chart.resize();
});
}
onUnmounted(() => {
if (mapEcharts.value) {
//echarts
echarts.dispose(mapEcharts.value);
mapEcharts.value = null;
}
});
// function getDeviceInfoss() {
// //
// const params = filterForm;
// params.startTime = currentEndTime.value;
// params.step = 6;
// params.stepType = '3';
// params.queryType = 2;
// console.log(params);
// getDeviceInfos(params).then(res => {
// if (res.code === 200 && Object.keys(res.data).length != 0) {
// if (isCurrentRoute.value) {
// timer.value = setTimeout(async () => {
// await (timer.value && clearTimeout(timer.value));
// await getDeviceInfoss();
// }, 360000);
// }
// if (res.data.additionalInfo != null) {
// currentEndTime.value = res.data.additionalInfo.endTime;
// console.log(currentEndTime.value, res.data.mainInfos);
// }
// options.series.forEach(originalObj => {
// res.data.mainInfos.forEach(newObj => {
// if (originalObj.name === newObj.name) {
// newObj.data.map(item => {
// originalObj.data.push(item);
// });
// }
// });
// });
// console.log(options.series);
// const chart = echarts.init(document.getElementById('stackedLine'));
// chart.setOption(options);
// } else {
// clearTimeout(timer.value);
// }
// });
// }
</script>

20
src/views/dashboard/components/LineChart.vue

@ -1,10 +1,11 @@
<!-- 线 + 柱混合图 -->
<template>
<div :id="id" :class="className" :style="{ height, width }" />
<div :ref="id" :id="id" :class="className" :style="{ height, width }" />
</template>
<script lang="ts" setup>
import * as echarts from 'echarts';
import { getFirstLineApi } from '@/api/dashboard/index';
const props = defineProps({
id: {
@ -53,9 +54,9 @@ const options = {
dataset: {
source: [
['product', '2024-01-01', '2024-01-02', '2024-01-03', '2024-01-04', '2024-01-05', '2024-01-06', '2024-01-07'],
['温', 59.2, 78.9, 87.8, 79.5, 52.4, 90.7, 55],
['温', 59.2, 78.9, 87.8, 79.5, 52.4, 90.7, 55],
['回温', 42.0, 60.1, 62.8, 55.9, 30.2, 79.2, 20],
['温均温', 52, 77, 75, 70.1, 53.4, 50, 40],
['温均温', 52, 77, 75, 70.1, 53.4, 50, 40],
['回温均温', 40, 52, 61, 49, 20.4, 61.8, 10]
]
},
@ -136,10 +137,23 @@ onMounted(() => {
//
const chart = echarts.init(document.getElementById(props.id) as HTMLDivElement);
chart.setOption(options);
getFirstLine();
//
window.addEventListener('resize', () => {
chart.resize();
});
});
function getFirstLine() {
//
const params = {};
getFirstLineApi().then((res: any) => {
if (res.code === 200 && Object.keys(res.data).length != 0) {
options.dataset.source = res.data.source;
options.yAxis[0].name = `单位(${res.data.unit})`;
const chart = echarts.init(document.getElementById(props.id) as HTMLDivElement);
chart.setOption(options);
}
});
}
</script>

340
src/views/dashboard/components/returnChart.vue

@ -0,0 +1,340 @@
<template>
<div ref="complaintRef" id="returnChart" class="complaintLine" :style="{ height, width }" />
</template>
<script setup>
import * as echarts from 'echarts';
import { randomColor, endTime, debounce } from '@/utils/index';
import { getBackTemperatureRanking } from '@/api/dashboard/index';
// import { Ref } from 'vue';
// const complaintRef: Ref<HTMLElement | any> = ref(null);
import useCounter from '@/store/modules/date';
const counterStore = useCounter();
const yearMonthDay = ref();
const timer = ref();
const isCurrentRoute = ref(true);
const mapEcharts = ref();
const props = defineProps({
id: {
type: String,
default: 'lineChart'
},
className: {
type: String,
default: ''
},
width: {
type: String,
default: '200px',
required: true
},
height: {
type: String,
default: '200px',
required: true
}
});
onMounted(() => {
getHeatRate();
});
// watchEffect(() => {
// const dataStr = counterStore.dateStr;
// if (dataStr != '') {
// yearMonthDay.value = counterStore.dateStr.split('-');
// getHeatRate();
// }
// });
function getHeatRate() {
//
const params = {};
getBackTemperatureRanking().then(res => {
if (res.code === 200 && Object.keys(res.data).length != 0) {
dataInfo(res.data);
}
});
}
function dataInfo(data) {
const defualData = data;
// const defualData = [
// {
// cdate: '2016',
// cname: '1,2,3,4,5,6,7,8,9,10',
// cut: '20.9,13.82,3.6,0.56,1.49,9.48,32,21,65,19'
// },
// {
// cdate: '2017',
// cname: '1,2,3,4,5,6,7,8,9,10',
// cut: '18.7,12.82,13.6,9.56,12.49,13.48,21,23,52,53'
// },
// {
// cdate: '2018',
// cname: '1,2,3,4,5,6,7,8,9,10',
// cut: '14.9,18.82,7.6,19.56,13.49,17.48,80,33,63,42'
// },
// {
// cdate: '2019',
// cname: '1,2,3,4,5,6,7,8,9,10',
// cut: '16.9,3.82,13.6,15.56,12.49,14.48,54,35,40,20'
// },
// {
// cdate: '2020',
// cname: '1,2,3,4,5,6,7,8,9,10',
// cut: '3.8,8.82,13.6,21.56,15.49,19.2,16,19,24,52'
// },
// {
// cdate: '2021',
// cname: '1,2,3,4,5,6,7,8,9,10',
// cut: '23.9,16.82,13.6,17.56,14.49,19.98,18,12,30,35'
// },
// {
// cdate: '2022',
// cname: '1,2,3,4,5,6,7,8,9,10',
// cut: '12,23,46,52,39,32,25,28,31,37'
// },
// {
// cdate: '2023',
// cname: '1,2,3,4,5,6,7,8,9,10',
// cut: '52,59,60,49,42,36,10,9,21,28'
// }
// ];
const colors = ['#5470c6', '#91cc75', '#fac858', '#1a94bc', '#f26b1f', '#5bae23'];
const ccolors = {};
const chart = echarts.init(document.getElementById('returnChart'));
mapEcharts.value = chart;
var updateFrequency = 1000; //
var years = [];
var startIndex = 0;
for (var i = 0; i < defualData.length; ++i) {
years.push(defualData[i]);
}
//
var startYear = years[startIndex].cdate;
var startName = years[startIndex].cname.split(',');
var startCut = years[startIndex].cut.split(',');
for (let i = 0; i < startName.length; i++) {
if (i < 6) {
ccolors[startName[i]] = colors[i];
} else {
ccolors[startName[i]] = randomColor();
}
}
console.log(ccolors);
const options = {
// tooltip: {
// trigger: 'axis',
// axisPointer: {
// type: 'shadow'
// }
// },
legend: {
right: 100,
itemWidth: 11,
itemHeight: 2,
color: '#fff',
fontSize: 14
},
grid: {
top: '0',
left: '0',
right: '10%',
bottom: '0',
containLabel: true
},
dataZoom: [
//Y
{
type: 'slider',
show: true,
yAxisIndex: [0],
width: 8,
height: '90%',
right: '10',
startValue: 0,
endValue: 10,
zoomLoxk: true,
top: 'middle'
},
{
type: 'inside',
yAxisIndex: [0],
zoomOnMouseWheel: true,
moveOnMouseMove: true,
moveOnMouseWheel: true
}
],
xAxis: {
max: 'dataMax',
type: 'value',
nameTextStyle: {
color: '#000',
fontSize: 12,
padding: [0, 0, 0, 0] //name
},
axisTick: {
//
show: false
},
axisLabel: {
show: true,
color: '#000',
formatter: function (n) {
return Math.round(n) + '';
}
},
splitLine: {
// 线
show: true,
lineStyle: {
//线
type: 'dashed',
color: '#306269',
width: 1,
opacity: 0.2
}
}
},
dataset: {
source: defualData
},
yAxis: {
type: 'category',
nameTextStyle: {
color: '#000',
fontSize: 12,
padding: [0, 0, 0, 0] //name
},
axisTick: {
//
show: false
},
axisLabel: {
show: true,
color: '#000',
rich: {
flag: {
fontSize: 25,
padding: 5
}
}
},
inverse: true,
animationDuration: 300, //
animationDurationUpdate: 300, //
data: startName
},
series: [
{
// name: '2023',
type: 'bar',
// barWidth: 20, //
showBackground: false,
realtimeSort: true, //
itemStyle: {
color: function (param) {
return ccolors[param.name];
}
},
encode: {
x: 0,
y: 3
},
label: {
show: true,
precision: 1,
position: 'right',
color: '#000',
valueAnimation: false //
},
emphasis: {
focus: 'series' //
},
data: startCut
}
],
animationDuration: 0,
animationDurationUpdate: 3000,
animationEasing: 'linear',
animationEasingUpdate: 'linear',
graphic: {
elements: [
{
type: 'text',
right: 50,
bottom: 50,
style: {
text: startYear,
font: 'bolder 80px monospace',
fill: 'rgba(100, 100, 100, 0.25)'
},
z: 100
}
]
}
};
chart.setOption(options);
for (var i = startIndex; i < defualData.length - 1; ++i) {
(function (i) {
setTimeout(function () {
getDeviceInfos(years[i + 1]);
}, (i + 1) * updateFrequency);
})(i);
}
function getDeviceInfos(year) {
options.yAxis.data = year.cname.split(',');
options.series[0].data = year.cut.split(',');
options.graphic.elements[0].style.text = year.cdate;
const chart = echarts.init(document.getElementById('returnChart'));
chart.setOption(options);
}
//
window.addEventListener('resize', () => {
chart.resize();
});
}
onUnmounted(() => {
if (mapEcharts.value) {
//echarts
echarts.dispose(mapEcharts.value);
mapEcharts.value = null;
}
});
// function getDeviceInfoss() {
// //
// const params = filterForm;
// params.startTime = currentEndTime.value;
// params.step = 6;
// params.stepType = '3';
// params.queryType = 2;
// console.log(params);
// getDeviceInfos(params).then(res => {
// if (res.code === 200 && Object.keys(res.data).length != 0) {
// if (isCurrentRoute.value) {
// timer.value = setTimeout(async () => {
// await (timer.value && clearTimeout(timer.value));
// await getDeviceInfoss();
// }, 360000);
// }
// if (res.data.additionalInfo != null) {
// currentEndTime.value = res.data.additionalInfo.endTime;
// console.log(currentEndTime.value, res.data.mainInfos);
// }
// options.series.forEach(originalObj => {
// res.data.mainInfos.forEach(newObj => {
// if (originalObj.name === newObj.name) {
// newObj.data.map(item => {
// originalObj.data.push(item);
// });
// }
// });
// });
// console.log(options.series);
// const chart = echarts.init(document.getElementById('returnChart'));
// chart.setOption(options);
// } else {
// clearTimeout(timer.value);
// }
// });
// }
</script>

6
src/views/dashboard/index.vue

@ -72,14 +72,14 @@
</el-col>
<el-col :span="8">
<el-card>
<template #header> 一网温排行 </template>
<template #header> 一网温排行 </template>
<BarChart id="barChart" height="300px" width="100%" />
</el-card>
</el-col>
<el-col :span="8">
<el-card>
<template #header> 一网回温排行 </template>
<BarChart id="barCharts" height="300px" width="100%" />
<ReturnChart id="returnChart" height="300px" width="100%" />
</el-card>
</el-col>
</el-row>
@ -102,7 +102,7 @@ import calendar from '@/utils/lunar';
import countTo from '@/utils/countTo';
import LineChart from './components/LineChart.vue';
import BarChart from './components/BarChart.vue';
import PieChart from './components/PieChart.vue';
import ReturnChart from './components/returnChart.vue';
import avatar from '@/assets/images/avatar.png';
import mitt from '@/plugins/bus';

3
src/views/monitoring/screen/components/main.vue

@ -308,7 +308,7 @@ mitt.on('tableMessage', (res: any) => {
tableArray.splice(index, 1, item);
}
});
console.log('tableData--', tableArray);
// console.log('tableData--', tableArray);
$table.loadData(tableArray);
// if (res.code === 'datareal') {
// const index = tableData.value.findIndex((obj) => obj.id === res.data.id);
@ -440,6 +440,7 @@ const cellDBLClickEvent: VxeTableEvents.CellDblclick<TableVo> = ({ row, column }
cellRow.value = row;
cellColumn.value = column;
cellField.value = cellField;
debugger;
if (cellField.canBeControl === '1' && controlPerm) {
modalTitle.value = column.title;
///formData.value.url = data.url;

16
src/views/monitoring/screenData/components/main.vue

@ -36,19 +36,19 @@
show-overflow
@cell-dblclick="cellDBLClickEvent"
>
<template #deviceuuid_default="{ row }">
<template #assetInfo_default="{ row }">
<div class="title">
<svg-icon
icon-class="warning_lights"
style="fill: currentColor; width: 15px; height: 15px; color: green"
v-if="row.deviceuuid.deviceStatus === 0"
v-if="row.assetInfo.assetStatus === '0'"
/>
<svg-icon
icon-class="warning_lights"
style="fill: currentColor; width: 15px; height: 15px; color: red"
v-if="row.deviceuuid.deviceStatus === 2"
v-if="row.assetInfo.assetStatus === '2'"
/>
<span class="name" @click.native="nameClick(row.deviceuuid)">{{ row.gTitle }}</span>
<span class="name" @click.native="nameClick(row.assetInfo)">{{ row.gTitle }}</span>
</div>
</template>
<template #pager>
@ -128,7 +128,7 @@ import {
VxeTablePropTypes,
VxePagerEvents
} from 'vxe-table';
import { getTableHeader, getStationInfo, getMockTableData, editConfig, sendCtrl } from '@/api/table/list';
import { getMockTableHeader, getStationInfo, getMockTableData, editConfig, sendCtrl } from '@/api/table/list';
import { TableVo } from '@/api/table/types';
import { tableStore } from '@/store/modules/table';
import mitt from '@/plugins/bus';
@ -167,7 +167,7 @@ const tablePage = reactive({
currentPage: 1,
pageSize: 10
});
// const fields = ref(['deviceuuid']) //
// const fields = ref(['assetInfo']) //
// const waringArrow = ref([])
interface FormDataVO {
@ -357,7 +357,7 @@ function stationInfo() {
function tableHeader() {
//header
getTableHeader().then((res: any) => {
getMockTableHeader().then((res: any) => {
console.log(res);
//
const tableCessText = [
@ -389,7 +389,7 @@ function tableHeader() {
// {
// id: 1,
// title: '',
// field: 'deviceuuid',
// field: 'assetInfo',
// colSort: 2,
// colType: '2',
// width: 150,

Loading…
Cancel
Save