Merge remote-tracking branch 'origin/main'

This commit is contained in:
huguanghan 2025-01-17 09:26:13 +08:00
commit 91fbce7d98
3 changed files with 47 additions and 32 deletions

View File

@ -288,7 +288,7 @@ const getDateRange = (type: 'week' | 'month') => {
return [startOfMonth, endOfMonth]
}
}
const theoryData = ref([])
const isLoading = ref(false)
const statAnalysisOperate = () => {
const deviceId = statAnalysisDeviceId.value.split(':')[2]
@ -359,9 +359,7 @@ 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]
// })
seriesDataInit.value = seriesData
calculateData.value = calculateAverages(seriesDataInit.value)
updateChart()
@ -371,6 +369,7 @@ const statAnalysisOperate = () => {
const seriesData = resData1.map((item: any) => {
return [getCutDecimalsValue(item.speed, 2), getCutDecimalsValue(item.power, 2)]
})
theoryData.value = seriesData
const series = {
type: 'line',
data: seriesData,
@ -391,33 +390,49 @@ const statAnalysisOperate = () => {
})
}
const statAnalysisExport = () => {
const params = statAnalysisFatory.value ? statAnalysisFatory.value : statAnalysisDeviceId.value
const windSource = statAnalysisSelectOptions.speedSource.filter((item: any) => item.value == statAnalysisSpeedSource.value)
const requestData = {
devices: [
{
deviceId: statAnalysisDeviceId.value.split(':')[2],
attributes: [statAnalysisSpeedSource.value, 'AvgActivePower_10min'],
},
],
startTime: new Date(statAnalysisTime.value[0]).getTime(),
endTime: new Date(statAnalysisTime.value[1]).getTime(),
madeinfactory: params.split(':')[0],
model: params.split(':')[1],
windSource: windSource[0]['label'],
displayCurve: AvgWindSpeedSwitch.value ? 1 : 0,
const escapeCsvValue = (value: any) => {
if (typeof value === 'string') {
//
return `"${value.replace(/"/g, '""')}"`
}
powerCurveExport(requestData).then((res: any) => {
const downloadUrl = window.URL.createObjectURL(res)
const a = document.createElement('a')
a.href = downloadUrl
a.download = '功率曲线' + new Date().getTime()
document.body.appendChild(a)
a.click()
window.URL.revokeObjectURL(downloadUrl)
document.body.removeChild(a)
return value
}
const statAnalysisExport = () => {
const windSource = statAnalysisSelectOptions.speedSource.filter((item: any) => item.value == statAnalysisSpeedSource.value)
const csvHeaders = ['风机名称' + '\t', windSource[0]['label'] + '\t', '功率' + '\t', '理论风速' + '\t', '理论功率' + '\t'].join(',') + '\n'
const deviceRow = statAnalysisSelectOptions.deviceId.filter((item: any) => item.value == statAnalysisDeviceId.value)
let sortseriesDataInit = [...seriesDataInit.value]
sortseriesDataInit.sort((a: any, b: any) => {
return a[0] - b[0]
})
const exportExcelData1 = chartType.value === 'scatter' ? sortseriesDataInit : calculateData.value
const exportExcelData: any = []
exportExcelData1.forEach((item: any, index: number) => {
let theoryItem0 = (theoryData.value[index] && theoryData.value[index][0]) || ''
let theoryItem1 = (theoryData.value[index] && theoryData.value[index][1]) || ''
const dataItem = [
escapeCsvValue(deviceRow[0]['label']) + '\t',
escapeCsvValue(item[0]) + '\t',
escapeCsvValue(item[1]) + '\t',
escapeCsvValue(theoryItem0) + '\t',
escapeCsvValue(theoryItem1) + '\t',
]
exportExcelData.push(dataItem.join(','))
})
const csvContent = csvHeaders + exportExcelData.join('\n')
const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' })
const link = document.createElement('a')
if (link.download !== undefined) {
const url = URL.createObjectURL(blob)
link.setAttribute('href', url)
link.setAttribute('download', '功率曲线' + new Date().getTime() + '.csv')
link.style.visibility = 'hidden'
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
}
}
const calculateAverages = (data: any) => {

View File

@ -637,7 +637,7 @@ const statAnalysisExport = () => {
if (link.download !== undefined) {
const url = URL.createObjectURL(blob)
link.setAttribute('href', url)
link.setAttribute('download', '趋势分析_' + new Date().getTime() + '.csv')
link.setAttribute('download', '单机分析_' + new Date().getTime() + '.csv')
link.style.visibility = 'hidden'
document.body.appendChild(link)
link.click()

View File

@ -689,8 +689,8 @@ const escapeCsvValue = (value: any) => {
}
const statAnalysisExport = () => {
const tables = [
{ data: highcsvContent.value, filename: '高频.csv' },
{ data: lowcsvContent.value, filename: '低频.csv' },
{ data: highcsvContent.value, filename: '多机对比_高频' + new Date().getTime() + '.csv' },
{ data: lowcsvContent.value, filename: '多机对比_低频' + new Date().getTime() + '.csv' },
]
tables.forEach((table) => {