|
|
@ -1,19 +1,36 @@ |
|
|
|
<template> |
|
|
|
<template> |
|
|
|
<div class="fault-rule-drawer"> |
|
|
|
<div class="fault-rule-drawer"> |
|
|
|
|
|
|
|
<el-drawer v-model="isShowDrawer" :title="title" direction="rtl" size="90%" |
|
|
|
<el-drawer v-model="isShowDrawer" :title="title" direction="rtl" size="90%" modal-class="model-dev-opn" |
|
|
|
modal-class="model-dev-opn" |
|
|
|
:before-close="handleBeforeClose" @opened="onDrawerOpened"> |
|
|
|
:before-close="handleBeforeClose" @opened="onDrawerOpened"> |
|
|
|
<main class="wh-full flex"> |
|
|
|
<main class="wh-full flex"> |
|
|
|
<EdfsWrap title="点位组" class="p-r-4 h-full border-r-1 border-solid border-r-#e4e7ed"> |
|
|
|
<EdfsWrap title="点位组" class="p-r-4 h-full border-r-1 border-solid border-r-#e4e7ed"> |
|
|
|
<PointGroupTree v-if="isShowDrawer" :data="pointGroup" @device-select="onGroupChange" |
|
|
|
<PointGroupTree v-if="isShowDrawer" :data="pointGroup" @device-select="onGroupChange" |
|
|
|
:groupChangeLoading="groupChangeLoading" @onchangePoints="onchangePoints" :devicePoints="pointList" |
|
|
|
:groupChangeLoading="groupChangeLoading" @onchangePoints="onchangePoints" |
|
|
|
:loadingPoints="loadingPoints" :isTransfer="props.isTransfer" :siteInfo="props.siteInfo" |
|
|
|
:devicePoints="pointList" |
|
|
|
ref="pointGroupTreeRef" /> |
|
|
|
:loadingPoints="loadingPoints" :isTransfer="props.isTransfer" |
|
|
|
|
|
|
|
:siteInfo="props.siteInfo" |
|
|
|
|
|
|
|
ref="pointGroupTreeRef"/> |
|
|
|
</EdfsWrap> |
|
|
|
</EdfsWrap> |
|
|
|
<div class="flex-1 p-4 h-full overflow-hidden" v-loading="loadingChart" element-loading-text="点位数据加载中..."> |
|
|
|
<div class="flex-1 p-4 h-full overflow-hidden relative" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<div class="absolute w-full h-full bg-[#ffffffe5] z-99" v-if="loadingChart"> |
|
|
|
|
|
|
|
<div class="w-full h-full flex flex-col justify-center items-center"> |
|
|
|
|
|
|
|
<el-progress |
|
|
|
|
|
|
|
style="width: 70%" |
|
|
|
|
|
|
|
:text-inside="true" |
|
|
|
|
|
|
|
:stroke-width="18" |
|
|
|
|
|
|
|
:percentage="progress" |
|
|
|
|
|
|
|
status="success" |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
<div class="text-xl"> |
|
|
|
|
|
|
|
<div>当前加载数据量较大请稍等。。。</div> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</div> |
|
|
|
<el-button class="mb-4" type="primary" @click="loadChardData">查询数据</el-button> |
|
|
|
<el-button class="mb-4" type="primary" @click="loadChardData">查询数据</el-button> |
|
|
|
<NewDataChart v-if="isShowChart" :chart-datas="chartDatas" :legends="legends" |
|
|
|
<NewDataChart v-if="isShowChart" :chart-datas="chartDatas" :legends="legends" |
|
|
|
:axis-data="Array.from(axisData)" ref="chartRef" /> |
|
|
|
:axis-data="Array.from(axisData)" ref="chartRef"/> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</main> |
|
|
|
</main> |
|
|
|
</el-drawer> |
|
|
|
</el-drawer> |
|
|
@ -23,12 +40,7 @@ |
|
|
|
<script setup lang="ts"> |
|
|
|
<script setup lang="ts"> |
|
|
|
import NewDataChart from './newDataChart.vue' |
|
|
|
import NewDataChart from './newDataChart.vue' |
|
|
|
import PointGroupTree from './PointGroupTree.vue' |
|
|
|
import PointGroupTree from './PointGroupTree.vue' |
|
|
|
import { |
|
|
|
import { type ManualAction, } from '@/utils/zmq' |
|
|
|
getPubInitData, |
|
|
|
|
|
|
|
type ManualAction, |
|
|
|
|
|
|
|
type PubMsgData, |
|
|
|
|
|
|
|
type TimeoutMsg, |
|
|
|
|
|
|
|
} from '@/utils/zmq' |
|
|
|
|
|
|
|
import ZMQWorker from '@/composables/useZMQJsonWorker' |
|
|
|
import ZMQWorker from '@/composables/useZMQJsonWorker' |
|
|
|
import type { IMyPoint, IOfflineDevice, IOnlineDevice } from '../type' |
|
|
|
import type { IMyPoint, IOfflineDevice, IOnlineDevice } from '../type' |
|
|
|
import { |
|
|
|
import { |
|
|
@ -42,8 +54,9 @@ import { |
|
|
|
type ISite, |
|
|
|
type ISite, |
|
|
|
} from '@/api/module/transfer' |
|
|
|
} from '@/api/module/transfer' |
|
|
|
import { useMessage } from '@/composables/useMessage' |
|
|
|
import { useMessage } from '@/composables/useMessage' |
|
|
|
import { getTransferTopic, postTransferTopic } from '../utils' |
|
|
|
|
|
|
|
import dayjs from 'dayjs' |
|
|
|
import dayjs from 'dayjs' |
|
|
|
|
|
|
|
import { nextTick } from "vue"; |
|
|
|
|
|
|
|
|
|
|
|
const env = import.meta.env |
|
|
|
const env = import.meta.env |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -67,6 +80,7 @@ const pubIdWithDevice = new Map< |
|
|
|
const pointList = ref<IMyPoint[]>([]) |
|
|
|
const pointList = ref<IMyPoint[]>([]) |
|
|
|
|
|
|
|
|
|
|
|
const curDevice = ref<IOfflineDevice | IOnlineDevice>() |
|
|
|
const curDevice = ref<IOfflineDevice | IOnlineDevice>() |
|
|
|
|
|
|
|
|
|
|
|
async function open(device: IOfflineDevice | IOnlineDevice) { |
|
|
|
async function open(device: IOfflineDevice | IOnlineDevice) { |
|
|
|
curDevice.value = device |
|
|
|
curDevice.value = device |
|
|
|
await loadPointGroup() |
|
|
|
await loadPointGroup() |
|
|
@ -86,6 +100,7 @@ async function open(device: IOfflineDevice | IOnlineDevice) { |
|
|
|
|
|
|
|
|
|
|
|
const loadingPoints = ref(false) |
|
|
|
const loadingPoints = ref(false) |
|
|
|
const columsParams = computed(() => ['ts', ...checkPointList.value.map(i => i.addr)]) |
|
|
|
const columsParams = computed(() => ['ts', ...checkPointList.value.map(i => i.addr)]) |
|
|
|
|
|
|
|
|
|
|
|
async function loadPoints() { |
|
|
|
async function loadPoints() { |
|
|
|
if (!curGroup.value) { |
|
|
|
if (!curGroup.value) { |
|
|
|
message.error('请先选择点位组') |
|
|
|
message.error('请先选择点位组') |
|
|
@ -141,23 +156,36 @@ async function loadDeviceDetails() { |
|
|
|
groupChangeLoading.value = false |
|
|
|
groupChangeLoading.value = false |
|
|
|
fullscreenLoading.value?.close() |
|
|
|
fullscreenLoading.value?.close() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const chartDatas = reactive(new Map<string, any[]>()) |
|
|
|
const chartDatas = reactive(new Map<string, any[]>()) |
|
|
|
const axisData = new Set<string>() |
|
|
|
const axisData = new Set<string>() |
|
|
|
const legends = ref<{ addr: string; label: string, unit: string }[]>([]) |
|
|
|
const legends = ref<{ addr: string; label: string, unit: string }[]>([]) |
|
|
|
|
|
|
|
|
|
|
|
const loadingChart = ref(false) |
|
|
|
const loadingChart = ref(false) |
|
|
|
|
|
|
|
const chartAllTotal = ref(0) |
|
|
|
|
|
|
|
const chartLimit = ref(1000) |
|
|
|
|
|
|
|
const chartOffset = ref(0) |
|
|
|
|
|
|
|
const progress = ref(0) |
|
|
|
|
|
|
|
|
|
|
|
async function loadChardData() { |
|
|
|
async function loadChardData() { |
|
|
|
if (!columsParams.value.filter(i => i !== 'ts').length) { |
|
|
|
if (!columsParams.value.filter(i => i !== 'ts').length) { |
|
|
|
message.error('请选择点位') |
|
|
|
message.error('请选择点位') |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
clearData() |
|
|
|
const params: IGetDeviceDataParams = { |
|
|
|
const limit = chartLimit.value |
|
|
|
|
|
|
|
const offset = chartOffset.value |
|
|
|
|
|
|
|
const options = { |
|
|
|
columns: columsParams.value, |
|
|
|
columns: columsParams.value, |
|
|
|
isLocal: props.isTransfer ? false : true, |
|
|
|
isLocal: props.isTransfer ? false : true, |
|
|
|
host: props.isTransfer ? (curDevice.value as IOnlineDevice).clientIp : '', |
|
|
|
host: props.isTransfer ? (curDevice.value as IOnlineDevice).clientIp : '', |
|
|
|
name: curGroupName.value as string |
|
|
|
name: curGroupName.value as string, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const params: IGetDeviceDataParams = { |
|
|
|
|
|
|
|
...options, |
|
|
|
|
|
|
|
limit, |
|
|
|
|
|
|
|
offset |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (env.VITE_APP_ENV !== 'local' || !props.isTransfer) { |
|
|
|
if (env.VITE_APP_ENV !== 'local' || !props.isTransfer) { |
|
|
@ -166,46 +194,81 @@ async function loadChardData() { |
|
|
|
} |
|
|
|
} |
|
|
|
loadingChart.value = true |
|
|
|
loadingChart.value = true |
|
|
|
isShowChart.value = false |
|
|
|
isShowChart.value = false |
|
|
|
|
|
|
|
|
|
|
|
const res = await getDeviceDetails(params) |
|
|
|
const res = await getDeviceDetails(params) |
|
|
|
|
|
|
|
|
|
|
|
if (res.code === 0) { |
|
|
|
if (res.code !== 0) { |
|
|
|
pointData.value = Array.isArray(res.data.results) ? res.data.results : [] |
|
|
|
resetChartStatus() |
|
|
|
chartDatas.clear() |
|
|
|
message.error('获取设备数据失败') |
|
|
|
axisData.clear() |
|
|
|
return |
|
|
|
legends.value = [] |
|
|
|
} |
|
|
|
for (const addr of columsParams.value.filter(i => i !== 'ts')) { |
|
|
|
|
|
|
|
const label = pointList.value.find(i => i.addr === addr)?.label || addr |
|
|
|
chartAllTotal.value = res?.data?.total ?? 0 |
|
|
|
const find = legends.value.find(i => i.addr === addr) |
|
|
|
if (chartAllTotal.value === 0) { |
|
|
|
const unit = pointList.value.find(i => i.addr === addr)?.unit || '' |
|
|
|
resetChartStatus() |
|
|
|
if (!find) { |
|
|
|
message.info('暂无数据') |
|
|
|
legends.value.push({ addr, label, unit }) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const pointData = Array.isArray(res.data.results) ? res.data.results : [] |
|
|
|
|
|
|
|
setChartData(pointData) |
|
|
|
|
|
|
|
const pageCount = Math.ceil(chartAllTotal.value / Number(limit)) |
|
|
|
|
|
|
|
if (pageCount <= 1) { |
|
|
|
|
|
|
|
progress.value = 100 |
|
|
|
|
|
|
|
setTimeout(()=>{resetChartStatus()}) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (let i = 1; i < pageCount; i++) { |
|
|
|
|
|
|
|
const params: IGetDeviceDataParams = { |
|
|
|
|
|
|
|
...options, |
|
|
|
|
|
|
|
limit, |
|
|
|
|
|
|
|
offset: i * Number(limit) |
|
|
|
} |
|
|
|
} |
|
|
|
pointData.value.forEach((data: any[]) => { |
|
|
|
const res = await getDeviceDetails(params) |
|
|
|
const [ts, val, addr] = data |
|
|
|
if (res.code !== 0) { |
|
|
|
if (checkPointList.value.some(i => i.addr === addr)) { |
|
|
|
clearData() |
|
|
|
const time = dayjs(Number(ts)).format('YYYY-MM-DD HH:mm:ss') |
|
|
|
resetChartStatus() |
|
|
|
if (addr) { |
|
|
|
message.error('获取设备数据失败') |
|
|
|
const colData = chartDatas.get(addr) |
|
|
|
return |
|
|
|
if (colData) { |
|
|
|
} |
|
|
|
colData.push([time, val]) |
|
|
|
const pointData = Array.isArray(res.data.results) ? res.data.results : [] |
|
|
|
} else { |
|
|
|
setChartData(pointData) |
|
|
|
chartDatas.set(addr, [[time, val]]) |
|
|
|
progress.value = Math.min(100, Math.floor(((i + 1) / pageCount) * 100)) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
resetChartStatus() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ts) { |
|
|
|
function setChartData(pointData: any[]) { |
|
|
|
axisData.add(time) |
|
|
|
for (const addr of columsParams.value.filter(i => i !== 'ts')) { |
|
|
|
|
|
|
|
const label = pointList.value.find(i => i.addr === addr)?.label || addr |
|
|
|
|
|
|
|
const find = legends.value.find(i => i.addr === addr) |
|
|
|
|
|
|
|
const unit = pointList.value.find(i => i.addr === addr)?.unit || '' |
|
|
|
|
|
|
|
if (!find) { |
|
|
|
|
|
|
|
legends.value.push({ addr, label, unit }) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
pointData.forEach((data: any[]) => { |
|
|
|
|
|
|
|
const [ts, val, addr] = data |
|
|
|
|
|
|
|
if (checkPointList.value.some(i => i.addr === addr)) { |
|
|
|
|
|
|
|
const time = dayjs(Number(ts)).format('YYYY-MM-DD HH:mm:ss') |
|
|
|
|
|
|
|
if (addr) { |
|
|
|
|
|
|
|
const colData = chartDatas.get(addr) |
|
|
|
|
|
|
|
if (colData) { |
|
|
|
|
|
|
|
colData.push([time, val]) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
chartDatas.set(addr, [[time, val]]) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
} else { |
|
|
|
if (ts) { |
|
|
|
message.error('获取设备数据失败') |
|
|
|
axisData.add(time) |
|
|
|
} |
|
|
|
} |
|
|
|
loadingChart.value = false |
|
|
|
} |
|
|
|
nextTick(() => { |
|
|
|
|
|
|
|
isShowChart.value = true |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// function zmqImport(device: IOfflineDevice) { |
|
|
|
// function zmqImport(device: IOfflineDevice) { |
|
|
@ -249,15 +312,31 @@ async function loadChardData() { |
|
|
|
|
|
|
|
|
|
|
|
function handleBeforeClose(done: () => void) { |
|
|
|
function handleBeforeClose(done: () => void) { |
|
|
|
isShowDrawer.value = false |
|
|
|
isShowDrawer.value = false |
|
|
|
pointList.value = [] |
|
|
|
clearData() |
|
|
|
chartDatas.clear() |
|
|
|
|
|
|
|
axisData.clear() |
|
|
|
|
|
|
|
fullscreenLoading.value = null |
|
|
|
fullscreenLoading.value = null |
|
|
|
done() |
|
|
|
done() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function clearData() { |
|
|
|
|
|
|
|
chartLimit.value = 1000 |
|
|
|
|
|
|
|
chartOffset.value = 0 |
|
|
|
|
|
|
|
chartAllTotal.value = 0 |
|
|
|
|
|
|
|
progress.value = 0 |
|
|
|
|
|
|
|
legends.value = [] |
|
|
|
|
|
|
|
chartDatas.clear() |
|
|
|
|
|
|
|
axisData.clear() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function resetChartStatus() { |
|
|
|
|
|
|
|
loadingChart.value = false |
|
|
|
|
|
|
|
nextTick(() => { |
|
|
|
|
|
|
|
isShowChart.value = true |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const chartRef = ref<InstanceType<typeof NewDataChart>>() |
|
|
|
const chartRef = ref<InstanceType<typeof NewDataChart>>() |
|
|
|
const isShowChart = ref(false) |
|
|
|
const isShowChart = ref(false) |
|
|
|
|
|
|
|
|
|
|
|
function onDrawerOpened() { |
|
|
|
function onDrawerOpened() { |
|
|
|
nextTick(() => { |
|
|
|
nextTick(() => { |
|
|
|
isShowChart.value = true |
|
|
|
isShowChart.value = true |
|
|
@ -302,6 +381,7 @@ async function loadPointGroup() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const groupChangeLoading = ref<boolean>(false) |
|
|
|
const groupChangeLoading = ref<boolean>(false) |
|
|
|
|
|
|
|
|
|
|
|
function onGroupChange(item: IPointGroupOV) { |
|
|
|
function onGroupChange(item: IPointGroupOV) { |
|
|
|
if (!item?.type) { |
|
|
|
if (!item?.type) { |
|
|
|
return |
|
|
|
return |
|
|
|