Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
98b1348a4c
@ -61,7 +61,7 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const selectedIndex = ref(null)
|
const selectedIndex: any = ref(null)
|
||||||
const tableColumn = [
|
const tableColumn = [
|
||||||
{
|
{
|
||||||
type: 'selection',
|
type: 'selection',
|
||||||
@ -98,12 +98,12 @@ const tableColumn = [
|
|||||||
]
|
]
|
||||||
const tableData = ref<any[]>([])
|
const tableData = ref<any[]>([])
|
||||||
const emit = defineEmits(['handleRadioChange'])
|
const emit = defineEmits(['handleRadioChange'])
|
||||||
const handleRadioChange = (row) => {
|
const handleRadioChange = (row: any) => {
|
||||||
selectedIndex.value = row.attributeCode
|
selectedIndex.value = row.attributeCode
|
||||||
emit('handleRadioChange', row)
|
emit('handleRadioChange', row)
|
||||||
}
|
}
|
||||||
const getAttributeList = () => {
|
const getAttributeList = () => {
|
||||||
const requestData: GetModelAttributeType = {
|
const requestData: any = {
|
||||||
iotModelId: props.iotModelId,
|
iotModelId: props.iotModelId,
|
||||||
pageNum: pageSetting.current,
|
pageNum: pageSetting.current,
|
||||||
pageSize: pageSetting.pageSize,
|
pageSize: pageSetting.pageSize,
|
||||||
|
@ -18,7 +18,7 @@ const activeIndex = ref(1)
|
|||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const headerList = [t('statAnalysis.PowerCurveAnalysis'), t('statAnalysis.trendAnalysis'), t('statAnalysis.trendComparison')]
|
const headerList = [t('statAnalysis.PowerCurveAnalysis'), t('statAnalysis.trendAnalysis'), t('statAnalysis.trendComparison')]
|
||||||
|
|
||||||
const handleSelect = (index) => {
|
const handleSelect = (index: number) => {
|
||||||
activeIndex.value = index
|
activeIndex.value = index
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -24,12 +24,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="selectPart">
|
<div class="selectPart">
|
||||||
<span>{{ t('statAnalysis.interval') }}</span>
|
<span>{{ t('statAnalysis.interval') }}</span>
|
||||||
<el-select
|
<el-select v-model="statAnalysisSelect.interval" :placeholder="'请选择' + t('statAnalysis.interval')" class="statAnalysisSelect">
|
||||||
v-model="statAnalysisSelect.interval"
|
|
||||||
@change="selectstatAnalysis('interval')"
|
|
||||||
:placeholder="'请选择' + t('statAnalysis.interval')"
|
|
||||||
class="statAnalysisSelect"
|
|
||||||
>
|
|
||||||
<el-option v-for="v in statAnalysisSelectOptions.interval" :key="v.value" :label="v.label" :value="v.value"></el-option>
|
<el-option v-for="v in statAnalysisSelectOptions.interval" :key="v.value" :label="v.label" :value="v.value"></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</div>
|
</div>
|
||||||
@ -103,10 +98,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onUnmounted, reactive, ref, watch, nextTick, onMounted, computed } from 'vue'
|
import { reactive, ref, onMounted } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import { queryWindTurbinesPages, historyReq } from '/@/api/backend/statAnalysis/request'
|
import { queryWindTurbinesPages, historyReq } from '/@/api/backend/statAnalysis/request'
|
||||||
import { ElMessage, ElMenu } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { DArrowRight, Plus, Delete } from '@element-plus/icons-vue'
|
import { DArrowRight, Plus, Delete } from '@element-plus/icons-vue'
|
||||||
import MeasurementPage from './analysisAttributes.vue'
|
import MeasurementPage from './analysisAttributes.vue'
|
||||||
import * as echarts from 'echarts'
|
import * as echarts from 'echarts'
|
||||||
@ -118,23 +113,22 @@ const statAnalysisSelect = reactive({
|
|||||||
interval: '',
|
interval: '',
|
||||||
time: '',
|
time: '',
|
||||||
})
|
})
|
||||||
const times = reactive([{ time: '' }])
|
const times: any = reactive([{ time: '' }])
|
||||||
const addTime = (index) => {
|
const addTime = (index: any) => {
|
||||||
times.push({ time: '' })
|
times.push({ time: '' })
|
||||||
customName.push(String(index + 2))
|
customName.push(statAnalysisSelect.attributes + String(index + 2))
|
||||||
}
|
}
|
||||||
const switchTime = (index) => {
|
const switchTime = (index: number) => {
|
||||||
times.splice(index, 1)
|
times.splice(index, 1)
|
||||||
customName.splice(index, 1)
|
customName.splice(index, 1)
|
||||||
calculate.splice(index, 1)
|
calculate.splice(index, 1)
|
||||||
xData.splice(index, 1)
|
|
||||||
}
|
}
|
||||||
const timechange = (value) => {
|
const timechange = (value: any) => {
|
||||||
const count = getTimeIntervals(times[0][0], times[0][1])
|
const count = getTimeIntervals(times[0][0], times[0][1])
|
||||||
const count1 = getTimeIntervals(times[value][0], times[value][1])
|
const count1 = getTimeIntervals(times[value][0], times[value][1])
|
||||||
if (count !== count1) {
|
if (count !== count1) {
|
||||||
times[value] = { time: '' }
|
times[value] = { time: '' }
|
||||||
value = ElMessage.warning('查询时间点错误,请重新输入')
|
ElMessage.warning('查询时间点错误,请重新输入')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const isExpand = ref(false)
|
const isExpand = ref(false)
|
||||||
@ -145,7 +139,7 @@ const handleClick = () => {
|
|||||||
const iotModelId = ref('')
|
const iotModelId = ref('')
|
||||||
const irn = ref('')
|
const irn = ref('')
|
||||||
const attributesChange = () => {
|
const attributesChange = () => {
|
||||||
const row = statAnalysisSelectOptions.deviceId.filter((item) => {
|
const row: any = statAnalysisSelectOptions.deviceId.filter((item: any) => {
|
||||||
return item.value == statAnalysisSelect.deviceId
|
return item.value == statAnalysisSelect.deviceId
|
||||||
})
|
})
|
||||||
if (row.length) {
|
if (row.length) {
|
||||||
@ -163,11 +157,11 @@ const deviceIdChange = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const showMeasure = ref(false)
|
const showMeasure = ref(false)
|
||||||
const selectedAttrRow = ref({
|
const selectedAttrRow: any = ref({
|
||||||
attributeCode: '',
|
attributeCode: '',
|
||||||
attributeName: '',
|
attributeName: '',
|
||||||
})
|
})
|
||||||
const handleRadioChange = (value) => {
|
const handleRadioChange = (value: any) => {
|
||||||
const { attributeCode, attributeName } = { ...value }
|
const { attributeCode, attributeName } = { ...value }
|
||||||
selectedAttrRow.attributeCode = attributeCode
|
selectedAttrRow.attributeCode = attributeCode
|
||||||
selectedAttrRow.attributeName = attributeName
|
selectedAttrRow.attributeName = attributeName
|
||||||
@ -176,11 +170,14 @@ const selectstatAnalysisAttributes = () => {
|
|||||||
statAnalysisSelect.attributes = selectedAttrRow.attributeName
|
statAnalysisSelect.attributes = selectedAttrRow.attributeName
|
||||||
statAnalysisSelect.attributeCode = selectedAttrRow.attributeCode
|
statAnalysisSelect.attributeCode = selectedAttrRow.attributeCode
|
||||||
showMeasure.value = false
|
showMeasure.value = false
|
||||||
|
customName.forEach((item: any, index: number, arr: any) => {
|
||||||
|
arr[index] = statAnalysisSelect.attributes + String(index + 1)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const chartContainer = ref<HTMLElement | null>(null)
|
const chartContainer = ref<HTMLElement | null>(null)
|
||||||
|
|
||||||
const option = {
|
const option: any = {
|
||||||
tooltip: {},
|
tooltip: {},
|
||||||
legend: {
|
legend: {
|
||||||
icon: 'circle',
|
icon: 'circle',
|
||||||
@ -203,7 +200,7 @@ const option = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
const statAnalysisSelectOptions = reactive({
|
const statAnalysisSelectOptions: any = reactive({
|
||||||
interval: [
|
interval: [
|
||||||
{ label: '五分钟', value: '5m' },
|
{ label: '五分钟', value: '5m' },
|
||||||
{ label: '十五分钟', value: '15m' },
|
{ label: '十五分钟', value: '15m' },
|
||||||
@ -213,8 +210,8 @@ const statAnalysisSelectOptions = reactive({
|
|||||||
],
|
],
|
||||||
deviceId: [],
|
deviceId: [],
|
||||||
})
|
})
|
||||||
const customName = reactive(['1'])
|
const customName = reactive([statAnalysisSelect.attributes + '1'])
|
||||||
const chart = ref(null)
|
const chart: any = ref(null)
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (chartContainer.value) {
|
if (chartContainer.value) {
|
||||||
@ -226,7 +223,7 @@ onMounted(() => {
|
|||||||
const queryWindTurbines = () => {
|
const queryWindTurbines = () => {
|
||||||
queryWindTurbinesPages().then((res) => {
|
queryWindTurbinesPages().then((res) => {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
statAnalysisSelectOptions.deviceId = res.data.map((item) => {
|
statAnalysisSelectOptions.deviceId = res.data.map((item: any) => {
|
||||||
return {
|
return {
|
||||||
value: item.irn,
|
value: item.irn,
|
||||||
label: item.name ?? '-',
|
label: item.name ?? '-',
|
||||||
@ -241,11 +238,6 @@ window.onresize = () => {
|
|||||||
chart.value.resize()
|
chart.value.resize()
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleSelect = (index) => {
|
|
||||||
activeIndex.value = index
|
|
||||||
}
|
|
||||||
const selectstatAnalysis = () => {}
|
|
||||||
|
|
||||||
const shortcuts = [
|
const shortcuts = [
|
||||||
{
|
{
|
||||||
text: '今天',
|
text: '今天',
|
||||||
@ -284,7 +276,7 @@ const shortcuts = [
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
const getFormattedDate = (offset) => {
|
const getFormattedDate = (offset: number) => {
|
||||||
const date = new Date()
|
const date = new Date()
|
||||||
date.setDate(date.getDate() + offset)
|
date.setDate(date.getDate() + offset)
|
||||||
|
|
||||||
@ -313,9 +305,9 @@ const getDateRange = (type: 'week' | 'month') => {
|
|||||||
return [startOfMonth, endOfMonth]
|
return [startOfMonth, endOfMonth]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const getTimeIntervals = (startTimestamp, endTimestamp) => {
|
const getTimeIntervals = (startTimestamp: number, endTimestamp: number) => {
|
||||||
const startDate = new Date(startTimestamp)
|
const startDate: any = new Date(startTimestamp)
|
||||||
const endDate = new Date(endTimestamp)
|
const endDate: any = new Date(endTimestamp)
|
||||||
let count = 0
|
let count = 0
|
||||||
|
|
||||||
switch (statAnalysisSelect.interval) {
|
switch (statAnalysisSelect.interval) {
|
||||||
@ -332,7 +324,7 @@ const getTimeIntervals = (startTimestamp, endTimestamp) => {
|
|||||||
count = Math.floor((endDate - startDate) / (1 * 60 * 60 * 1000))
|
count = Math.floor((endDate - startDate) / (1 * 60 * 60 * 1000))
|
||||||
break
|
break
|
||||||
case '1d':
|
case '1d':
|
||||||
count = c((endDate - startDate) / (1 * 24 * 60 * 60 * 1000))
|
count = Math.floor((endDate - startDate) / (1 * 24 * 60 * 60 * 1000))
|
||||||
break
|
break
|
||||||
// default:
|
// default:
|
||||||
// throw new Error('Invalid interval')
|
// throw new Error('Invalid interval')
|
||||||
@ -340,14 +332,14 @@ const getTimeIntervals = (startTimestamp, endTimestamp) => {
|
|||||||
|
|
||||||
return count
|
return count
|
||||||
}
|
}
|
||||||
const calculate = reactive([{ max: '', min: '', average: '' }])
|
const calculate: any = reactive([{ max: '', min: '', average: '' }])
|
||||||
var xDatas = []
|
var xDatas: any = []
|
||||||
const statAnalysisOperate = () => {
|
const statAnalysisOperate = () => {
|
||||||
option.series = []
|
option.series = []
|
||||||
option.legend.data = []
|
option.legend.data = []
|
||||||
xDatas = []
|
xDatas = []
|
||||||
chart.value.setOption(option, { notMerge: true })
|
chart.value.setOption(option, { notMerge: true })
|
||||||
times.forEach((time, index) => {
|
times.forEach((time: any, index: number) => {
|
||||||
if (time[0] && time[1]) {
|
if (time[0] && time[1]) {
|
||||||
const requestData = {
|
const requestData = {
|
||||||
devices: [
|
devices: [
|
||||||
@ -365,7 +357,7 @@ const statAnalysisOperate = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const historyDataReq = (data, index) => {
|
const historyDataReq = (data: any, index: number) => {
|
||||||
historyReq(data).then((res) => {
|
historyReq(data).then((res) => {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
const deviceId = statAnalysisSelect.deviceId
|
const deviceId = statAnalysisSelect.deviceId
|
||||||
@ -374,19 +366,15 @@ const historyDataReq = (data, index) => {
|
|||||||
if (resData) {
|
if (resData) {
|
||||||
const xData = resData['times']
|
const xData = resData['times']
|
||||||
const yData = resData['values']
|
const yData = resData['values']
|
||||||
calculate[index] = {
|
calculate[index] = calculateStats(yData)
|
||||||
max: Math.floor(Math.max(...yData)),
|
|
||||||
min: Math.floor(Math.min(...yData)),
|
|
||||||
average: Math.floor(yData.reduce((a, b) => a + b, 0) / yData.length),
|
|
||||||
}
|
|
||||||
xDatas.push({
|
xDatas.push({
|
||||||
series: String(customName[index]),
|
series: String(customName[index]),
|
||||||
data: xData,
|
data: xData,
|
||||||
})
|
})
|
||||||
option.tooltip = {
|
option.tooltip = {
|
||||||
show: true,
|
show: true,
|
||||||
formatter: function (params) {
|
formatter: function (params: any) {
|
||||||
const matchData = xDatas.filter((x) => x.series == params.seriesName)
|
const matchData = xDatas.filter((x: any) => x.series == params.seriesName)
|
||||||
const x = timestampToTime(matchData[0]['data'][params.dataIndex])
|
const x = timestampToTime(matchData[0]['data'][params.dataIndex])
|
||||||
return `${params.marker} ${params.seriesName} <br/> ${x} <b>${params.data}</b>`
|
return `${params.marker} ${params.seriesName} <br/> ${x} <b>${params.data}</b>`
|
||||||
},
|
},
|
||||||
@ -413,7 +401,19 @@ const historyDataReq = (data, index) => {
|
|||||||
const statAnalysisExport = () => {}
|
const statAnalysisExport = () => {}
|
||||||
const statAnalysiImport = () => {}
|
const statAnalysiImport = () => {}
|
||||||
|
|
||||||
const timestampToTime = (timestamp) => {
|
function calculateStats(numbers: any) {
|
||||||
|
const max = Math.max(...numbers)
|
||||||
|
const min = Math.min(...numbers)
|
||||||
|
const sum = numbers.reduce((acc: number, current: number) => acc + current, 0)
|
||||||
|
const average = sum / numbers.length
|
||||||
|
|
||||||
|
return {
|
||||||
|
max: max.toFixed(2),
|
||||||
|
min: min.toFixed(2),
|
||||||
|
average: average.toFixed(2),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const timestampToTime = (timestamp: any) => {
|
||||||
timestamp = timestamp ? timestamp : null
|
timestamp = timestamp ? timestamp : null
|
||||||
let date = new Date(timestamp)
|
let date = new Date(timestamp)
|
||||||
let Y = date.getFullYear() + '-'
|
let Y = date.getFullYear() + '-'
|
||||||
@ -482,7 +482,7 @@ const timestampToTime = (timestamp) => {
|
|||||||
color: #0064aa;
|
color: #0064aa;
|
||||||
}
|
}
|
||||||
.customName {
|
.customName {
|
||||||
width: 80px;
|
width: fit-content;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,8 +116,8 @@ const statAnalysisTime = ref('')
|
|||||||
const statAnalysisInterval = ref('')
|
const statAnalysisInterval = ref('')
|
||||||
const statAnalysisDeviceId = reactive([''])
|
const statAnalysisDeviceId = reactive([''])
|
||||||
const statAnalysisAttributes = reactive([''])
|
const statAnalysisAttributes = reactive([''])
|
||||||
const statAnalysisAttributeCode = reactive([])
|
const statAnalysisAttributeCode: any = reactive([])
|
||||||
const statAnalysisSelectOptions = reactive({
|
const statAnalysisSelectOptions: any = reactive({
|
||||||
interval: [
|
interval: [
|
||||||
{ label: '五分钟', value: '5m' },
|
{ label: '五分钟', value: '5m' },
|
||||||
{ label: '十五分钟', value: '15m' },
|
{ label: '十五分钟', value: '15m' },
|
||||||
@ -128,13 +128,12 @@ const statAnalysisSelectOptions = reactive({
|
|||||||
deviceId: [],
|
deviceId: [],
|
||||||
})
|
})
|
||||||
const openModelIndex = ref(0)
|
const openModelIndex = ref(0)
|
||||||
const selectediotModelId = ref('')
|
const addDevice = (index: number) => {
|
||||||
const addDevice = (index) => {
|
|
||||||
statAnalysisDeviceId.push('')
|
statAnalysisDeviceId.push('')
|
||||||
statAnalysisAttributes.push('')
|
statAnalysisAttributes.push('')
|
||||||
customName.push(String(index + 2))
|
customName.push(String(index + 2))
|
||||||
}
|
}
|
||||||
const switchDevice = (index) => {
|
const switchDevice = (index: number) => {
|
||||||
statAnalysisDeviceId.splice(index, 1)
|
statAnalysisDeviceId.splice(index, 1)
|
||||||
statAnalysisAttributes.splice(index, 1)
|
statAnalysisAttributes.splice(index, 1)
|
||||||
statAnalysisAttributeCode.splice(index, 1)
|
statAnalysisAttributeCode.splice(index, 1)
|
||||||
@ -148,8 +147,8 @@ const handleClick = () => {
|
|||||||
}
|
}
|
||||||
const iotModelId = ref('')
|
const iotModelId = ref('')
|
||||||
const irn = ref('')
|
const irn = ref('')
|
||||||
const selectAtteibutes = (index) => {
|
const selectAtteibutes = (index: number) => {
|
||||||
const row = statAnalysisSelectOptions.deviceId.filter((item) => {
|
const row = statAnalysisSelectOptions.deviceId.filter((item: any) => {
|
||||||
return item.value == statAnalysisDeviceId[index]
|
return item.value == statAnalysisDeviceId[index]
|
||||||
})
|
})
|
||||||
if (row.length) {
|
if (row.length) {
|
||||||
@ -162,7 +161,7 @@ const selectAtteibutes = (index) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const deviceIdChange = (index) => {
|
const deviceIdChange = (index: number) => {
|
||||||
statAnalysisAttributeCode[index] = ''
|
statAnalysisAttributeCode[index] = ''
|
||||||
statAnalysisAttributes[index] = ''
|
statAnalysisAttributes[index] = ''
|
||||||
}
|
}
|
||||||
@ -172,7 +171,7 @@ const selectedAttrRow = reactive({
|
|||||||
attributeCode: '',
|
attributeCode: '',
|
||||||
attributeName: '',
|
attributeName: '',
|
||||||
})
|
})
|
||||||
const handleRadioChange = (value) => {
|
const handleRadioChange = (value: any) => {
|
||||||
const { attributeCode, attributeName } = { ...value }
|
const { attributeCode, attributeName } = { ...value }
|
||||||
selectedAttrRow.attributeCode = attributeCode
|
selectedAttrRow.attributeCode = attributeCode
|
||||||
selectedAttrRow.attributeName = attributeName
|
selectedAttrRow.attributeName = attributeName
|
||||||
@ -181,11 +180,14 @@ const selectstatAnalysisAttributes = () => {
|
|||||||
statAnalysisAttributes[openModelIndex.value] = selectedAttrRow.attributeName
|
statAnalysisAttributes[openModelIndex.value] = selectedAttrRow.attributeName
|
||||||
statAnalysisAttributeCode[openModelIndex.value] = selectedAttrRow.attributeCode
|
statAnalysisAttributeCode[openModelIndex.value] = selectedAttrRow.attributeCode
|
||||||
showMeasure.value = false
|
showMeasure.value = false
|
||||||
|
customName.forEach((item: any, index: number, arr: any) => {
|
||||||
|
arr[openModelIndex.value] = statAnalysisAttributes[openModelIndex.value] + String(index + 1)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const chartContainer = ref<HTMLElement | null>(null)
|
const chartContainer = ref<HTMLElement | null>(null)
|
||||||
|
|
||||||
const option = {
|
const option: any = {
|
||||||
tooltip: {},
|
tooltip: {},
|
||||||
legend: {
|
legend: {
|
||||||
icon: 'circle',
|
icon: 'circle',
|
||||||
@ -212,7 +214,7 @@ const option = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const customName = reactive(['1'])
|
const customName = reactive(['1'])
|
||||||
const chart = ref(null)
|
const chart: any = ref(null)
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (chartContainer.value) {
|
if (chartContainer.value) {
|
||||||
chart.value = echarts.init(chartContainer.value)
|
chart.value = echarts.init(chartContainer.value)
|
||||||
@ -223,7 +225,7 @@ onMounted(() => {
|
|||||||
const queryWindTurbines = () => {
|
const queryWindTurbines = () => {
|
||||||
queryWindTurbinesPages().then((res) => {
|
queryWindTurbinesPages().then((res) => {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
statAnalysisSelectOptions.deviceId = res.data.map((item) => {
|
statAnalysisSelectOptions.deviceId = res.data.map((item: any) => {
|
||||||
return {
|
return {
|
||||||
value: item.irn,
|
value: item.irn,
|
||||||
label: item.name ?? '-',
|
label: item.name ?? '-',
|
||||||
@ -238,11 +240,6 @@ window.onresize = () => {
|
|||||||
chart.value.resize()
|
chart.value.resize()
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleSelect = (index) => {
|
|
||||||
activeIndex.value = index
|
|
||||||
}
|
|
||||||
const selectstatAnalysis = () => {}
|
|
||||||
|
|
||||||
const shortcuts = [
|
const shortcuts = [
|
||||||
{
|
{
|
||||||
text: '今天',
|
text: '今天',
|
||||||
@ -281,7 +278,7 @@ const shortcuts = [
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
const getFormattedDate = (offset) => {
|
const getFormattedDate = (offset: number) => {
|
||||||
const date = new Date()
|
const date = new Date()
|
||||||
date.setDate(date.getDate() + offset)
|
date.setDate(date.getDate() + offset)
|
||||||
|
|
||||||
@ -315,8 +312,8 @@ const statAnalysisOperate = () => {
|
|||||||
option.series = []
|
option.series = []
|
||||||
chart.value.setOption(option, { notMerge: true })
|
chart.value.setOption(option, { notMerge: true })
|
||||||
const attributes = statAnalysisAttributeCode
|
const attributes = statAnalysisAttributeCode
|
||||||
const devices = statAnalysisDeviceId.reduce((deviceId, curr, index) => {
|
const devices = statAnalysisDeviceId.reduce((deviceId: any, curr, index) => {
|
||||||
const existing = deviceId.find((item) => item.deviceId === curr)
|
const existing: any = deviceId.find((item: any) => item.deviceId === curr)
|
||||||
if (existing) {
|
if (existing) {
|
||||||
existing.attributes.push(statAnalysisAttributeCode[index])
|
existing.attributes.push(statAnalysisAttributeCode[index])
|
||||||
} else {
|
} else {
|
||||||
@ -330,10 +327,10 @@ const statAnalysisOperate = () => {
|
|||||||
startTime: new Date(statAnalysisTime.value[0]).getTime(),
|
startTime: new Date(statAnalysisTime.value[0]).getTime(),
|
||||||
endTime: new Date(statAnalysisTime.value[1]).getTime(),
|
endTime: new Date(statAnalysisTime.value[1]).getTime(),
|
||||||
}
|
}
|
||||||
historyDataReq(requestData, devices)
|
historyDataReq(requestData)
|
||||||
}
|
}
|
||||||
const calculate = reactive([{ max: '', min: '', average: '' }])
|
const calculate: any = reactive([{ max: '', min: '', average: '' }])
|
||||||
const historyDataReq = (data, devices) => {
|
const historyDataReq = (data: any) => {
|
||||||
historyReq(data).then((res) => {
|
historyReq(data).then((res) => {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
const resData = res.data
|
const resData = res.data
|
||||||
@ -353,13 +350,9 @@ const historyDataReq = (data, devices) => {
|
|||||||
type: 'line',
|
type: 'line',
|
||||||
data: yData,
|
data: yData,
|
||||||
}
|
}
|
||||||
calculate[dataIndex] = {
|
calculate[dataIndex] = calculateStats(yData)
|
||||||
max: Math.floor(Math.max(...yData)),
|
|
||||||
min: Math.floor(Math.min(...yData)),
|
|
||||||
average: Math.floor(yData.reduce((a, b) => a + b, 0) / yData.length),
|
|
||||||
}
|
|
||||||
option.legend.data.push(customName[dataIndex])
|
option.legend.data.push(customName[dataIndex])
|
||||||
option.xAxis.data = xData.map((item) => timestampToTime(item))
|
option.xAxis.data = xData.map((item: any) => timestampToTime(item))
|
||||||
option.series.push(seriesData)
|
option.series.push(seriesData)
|
||||||
chart.value.setOption(option)
|
chart.value.setOption(option)
|
||||||
})
|
})
|
||||||
@ -371,17 +364,28 @@ const historyDataReq = (data, devices) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const findAllOccurrences = (arr, target) => {
|
const findAllOccurrences = (arr: any, target: any) => {
|
||||||
return arr.map((value, index) => (value === target ? index : -1)).filter((index) => index !== -1)
|
return arr.map((value: any, index: number) => (value === target ? index : -1)).filter((index: number) => index !== -1)
|
||||||
}
|
}
|
||||||
|
|
||||||
const getCommonElements = (arr1, arr2) => {
|
const getCommonElements = (arr1: any, arr2: any) => {
|
||||||
return arr1.filter((item) => arr2.some((x) => x === item))
|
return arr1.filter((item: any) => arr2.some((x: any) => x === item))
|
||||||
}
|
}
|
||||||
const statAnalysisExport = () => {}
|
const statAnalysisExport = () => {}
|
||||||
const statAnalysiImport = () => {}
|
const statAnalysiImport = () => {}
|
||||||
|
function calculateStats(numbers: any) {
|
||||||
|
const max = Math.max(...numbers)
|
||||||
|
const min = Math.min(...numbers)
|
||||||
|
const sum = numbers.reduce((acc: number, current: number) => acc + current, 0)
|
||||||
|
const average = sum / numbers.length
|
||||||
|
|
||||||
const timestampToTime = (timestamp) => {
|
return {
|
||||||
|
max: max.toFixed(2),
|
||||||
|
min: min.toFixed(2),
|
||||||
|
average: average.toFixed(2),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const timestampToTime = (timestamp: any) => {
|
||||||
timestamp = timestamp ? timestamp : null
|
timestamp = timestamp ? timestamp : null
|
||||||
let date = new Date(timestamp)
|
let date = new Date(timestamp)
|
||||||
let Y = date.getFullYear() + '-'
|
let Y = date.getFullYear() + '-'
|
||||||
@ -417,7 +421,7 @@ const timestampToTime = (timestamp) => {
|
|||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
.customName {
|
.customName {
|
||||||
width: 80px;
|
width: fit-content;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
.statAnalysisSelect {
|
.statAnalysisSelect {
|
||||||
|
Loading…
Reference in New Issue
Block a user