功率曲线
This commit is contained in:
parent
0a07aa94e3
commit
736360a915
@ -8,6 +8,12 @@
|
||||
<el-option v-for="v in statAnalysisSelectOptions.deviceId" :key="v.value" :label="v.label" :value="v.value"></el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
<div class="selectPart">
|
||||
<span>风速来源</span>
|
||||
<el-select v-model="statAnalysisSpeedSource" placeholder="请选择风速来源" class="statAnalysisSelect">
|
||||
<el-option v-for="v in statAnalysisSelectOptions.speedSource" :key="v.value" :label="v.label" :value="v.value"></el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="topRight">
|
||||
<el-button type="primary" :loading="isLoading" @click="statAnalysisOperate()">{{ t('statAnalysis.search') }}</el-button>
|
||||
@ -29,17 +35,7 @@
|
||||
:shortcuts="shortcuts"
|
||||
/>
|
||||
</div>
|
||||
<div class="selectPart">
|
||||
<span>风速来源</span>
|
||||
<el-select v-model="statAnalysisSpeedSource" placeholder="请选择风速来源" class="statAnalysisSelect">
|
||||
<el-option
|
||||
v-for="v in statAnalysisSelectOptions.speedSource"
|
||||
:key="v.value"
|
||||
:label="v.label"
|
||||
:value="v.value"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
|
||||
<div class="selectPart">
|
||||
<span>{{ t('statAnalysis.madeinfatory') }}</span>
|
||||
<el-select
|
||||
@ -56,6 +52,10 @@
|
||||
></el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
<div class="selectPart">
|
||||
<span> 显示曲线 </span>
|
||||
<el-switch v-model="AvgWindSpeedSwitch" @change="changeUpdateAvgWindSpeed"></el-switch>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -75,7 +75,8 @@ import * as echarts from 'echarts'
|
||||
import { getCutDecimalsValue } from '/@/views/backend/equipment/airBlower/utils'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const AvgWindSpeedSwitch = ref(false)
|
||||
const chartType = ref('scatter') // 默认散点图
|
||||
const statAnalysisFatory = ref('')
|
||||
const statAnalysisFatoryList: any = ref([])
|
||||
const statAnalysisSpeedSource = ref('AvgWindSpeed_10min')
|
||||
@ -88,6 +89,28 @@ const statAnalysisSelectOptions: any = reactive({
|
||||
deviceId: [],
|
||||
})
|
||||
|
||||
const changeUpdateAvgWindSpeed = (val: any) => {
|
||||
chartType.value = val ? 'line' : 'scatter'
|
||||
updateChart()
|
||||
}
|
||||
|
||||
const seriesDataInit = ref([])
|
||||
const calculateData: any = ref([])
|
||||
const updateChart = () => {
|
||||
const series = {
|
||||
type: chartType.value,
|
||||
data: chartType.value === 'scatter' ? seriesDataInit.value : calculateData.value,
|
||||
name: '实际值',
|
||||
symbolSize: 5,
|
||||
symbol: 'circle',
|
||||
}
|
||||
option.series[0] = series
|
||||
if (!option.legend.data.includes('实际值')) {
|
||||
option.legend.data.push('实际值')
|
||||
}
|
||||
chart.value.setOption(option)
|
||||
}
|
||||
|
||||
const getFormattedDate = (offset: number) => {
|
||||
const date = new Date()
|
||||
date.setDate(date.getDate() + offset)
|
||||
@ -330,19 +353,12 @@ const statAnalysisOperate = () => {
|
||||
const seriesData = iGenPower.map((item: any, index: number) => {
|
||||
return [getCutDecimalsValue(iWindSpeed[index], 2), getCutDecimalsValue(item, 2)]
|
||||
})
|
||||
seriesData.sort((a: any, b: any) => {
|
||||
return a[0] - b[0]
|
||||
})
|
||||
|
||||
const series = {
|
||||
type: 'scatter',
|
||||
data: seriesData,
|
||||
name: '实际值',
|
||||
symbolSize: 5,
|
||||
symbol: 'circle',
|
||||
}
|
||||
option.series.push(series)
|
||||
option.legend.data.push('实际值')
|
||||
// seriesData.sort((a: any, b: any) => {
|
||||
// return a[0] - b[0]
|
||||
// })
|
||||
seriesDataInit.value = seriesData
|
||||
calculateData.value = calculateAverages(seriesDataInit.value)
|
||||
updateChart()
|
||||
}
|
||||
}
|
||||
if (resData1.length) {
|
||||
@ -360,9 +376,11 @@ const statAnalysisOperate = () => {
|
||||
option.series.push(series)
|
||||
option.legend.data.push('理论值')
|
||||
}
|
||||
console.log('🚀 ~ .then ~ option.legend.data:', option.legend.data)
|
||||
chart.value.setOption(option)
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error)
|
||||
isLoading.value = false
|
||||
ElMessage.warning(error)
|
||||
})
|
||||
@ -393,6 +411,34 @@ const statAnalysisExport = () => {
|
||||
document.body.removeChild(a)
|
||||
})
|
||||
}
|
||||
|
||||
const calculateAverages = (data: any) => {
|
||||
let maxWindSpeed = Math.max(...data.map((item: any) => item[0]))
|
||||
let interval = 5 // 每5m/s一个区间
|
||||
let result = []
|
||||
|
||||
for (let windSpeed = 0; windSpeed <= maxWindSpeed; windSpeed += interval) {
|
||||
let sumPower = 0
|
||||
let count = 0
|
||||
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
let currentWindSpeed = data[i][0]
|
||||
let currentPower = data[i][1]
|
||||
|
||||
if (currentWindSpeed >= windSpeed && currentWindSpeed < windSpeed + interval) {
|
||||
sumPower += currentPower
|
||||
count++
|
||||
}
|
||||
}
|
||||
|
||||
if (count > 0) {
|
||||
let averagePower = sumPower / count
|
||||
result.push([windSpeed + interval, averagePower])
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.contain {
|
||||
|
Loading…
Reference in New Issue
Block a user