From 7ceb1c731cbc9cbfa453c60d9176d4513140e547 Mon Sep 17 00:00:00 2001 From: jiangAB Date: Mon, 5 Jan 2026 16:28:49 +0800 Subject: [PATCH] update --- public/map/components/ShorePowerUsageRate.vue | 92 ++---- .../components/ShorePowerUsageSingleData.vue | 81 +---- public/map/components/ShowData.vue | 6 +- public/map/components/cesiumMap.vue | 16 +- .../components/charts/ComparisonBarChart.vue | 24 +- public/map/components/dictionaryTable.ts | 27 +- public/map/index.vue | 276 ++++++++---------- src/types/shorepower.d.ts | 5 + 8 files changed, 209 insertions(+), 318 deletions(-) diff --git a/public/map/components/ShorePowerUsageRate.vue b/public/map/components/ShorePowerUsageRate.vue index 5d36d95..d634b96 100644 --- a/public/map/components/ShorePowerUsageRate.vue +++ b/public/map/components/ShorePowerUsageRate.vue @@ -40,17 +40,17 @@
+ previousColor="#FF6384" chartType="percentage" />
+ currentColor="#36A2EB" previousColor="#FF6384" chartType="percentage" />
+ previousColor="#FF6384" chartType="percentage" />
@@ -60,14 +60,14 @@ import { ref, computed, onMounted, onBeforeUnmount } from 'vue' import { MapApi } from "@/api/shorepower/map"; import ComparisonBarChart from './charts/ComparisonBarChart.vue' -import { ComparativeData, RealtimeDeviceData } from '@/types/shorepower'; +import { ComparativeData, MetricData, RealtimeDeviceData } from '@/types/shorepower'; interface Props { // realtimeDeviceData: RealtimeDeviceData[]; // activeHeadGroup?: number; handleClose: () => void; realtimeDeviceDataTime: string; - // comparativeData: ComparativeData; + comparativeData: MetricData; initialTimeRange?: 'realtime' | 'day' | 'month' | 'year'; } @@ -125,75 +125,43 @@ export interface deviceData { const getYearlyData = computed(() => { return [{ name: '本期上期对比', - growthRate: .11, - currentValue: 22, - previousValue: 33, - currentPeriod: '2024', - previousPeriod: '2025', + growthRate: props.comparativeData.year.growthRate, + currentValue: convertPowerUsage(props.comparativeData.year.current.value, selectedCard.value), + previousValue: convertPowerUsage(props.comparativeData.year.previous.value, selectedCard.value), + currentPeriod: props.comparativeData.year.current.period, + previousPeriod: props.comparativeData.year.previous.period, }] }) -// 日对比数据(根据对比类型选择环比或同比)- 本地模拟数据 +// 日对比数据(根据对比类型选择环比或同比) const getDailyComparisonData = computed(() => { - // 本地模拟岸电使用率数据 - const mockDailyData = { - chain: { // 环比数据 - name: '本期上期对比', - growthRate: .52, // 增长率5.2% - currentValue: 85.5, // 当前值85.5% - previousValue: 81.3, // 上期值81.3% - currentPeriod: new Date().toISOString().split('T')[0], // 当前期间 - previousPeriod: new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString().split('T')[0], // 前一天 - }, - yearOnYear: { // 同比数据 - name: '本期去年同期对比', - growthRate: .128, // 同比增长率12.8% - currentValue: 85.5, // 当前值85.5% - previousValue: 75.8, // 去年同期值75.8% - currentPeriod: new Date().toISOString().split('T')[0], // 当前期间 - previousPeriod: new Date(Date.now() - 365 * 24 * 60 * 60 * 1000).toISOString().split('T')[0], // 去年同期 - } - }; + const comparisonData = comparisonType.value === 'yearOnYear' + ? props.comparativeData.dayYearOnYear + : props.comparativeData.day; return [{ - name: mockDailyData[comparisonType.value].name, - growthRate: mockDailyData[comparisonType.value].growthRate, - currentValue: convertPowerUsage(mockDailyData[comparisonType.value].currentValue, selectedCard.value), - previousValue: convertPowerUsage(mockDailyData[comparisonType.value].previousValue, selectedCard.value), - currentPeriod: mockDailyData[comparisonType.value].currentPeriod, - previousPeriod: mockDailyData[comparisonType.value].previousPeriod, + name: comparisonType.value === 'yearOnYear' ? '本期去年同期对比' : '本期上期对比', + growthRate: comparisonData.growthRate, + currentValue: convertPowerUsage(comparisonData.current.value, selectedCard.value), + previousValue: convertPowerUsage(comparisonData.previous.value, selectedCard.value), + currentPeriod: comparisonData.current.period, + previousPeriod: comparisonData.previous.period, }] }) -// 月对比数据(根据对比类型选择环比或同比)- 本地模拟数据 +// 月对比数据(根据对比类型选择环比或同比) const getMonthlyComparisonData = computed(() => { - // 本地模拟岸电使用率数据 - const mockMonthlyData = { - chain: { // 环比数据 - name: '本期上期对比', - growthRate: .83, // 增长率8.3% - currentValue: 87.2, // 当前值87.2% - previousValue: 80.5, // 上期值80.5% - currentPeriod: new Date().toISOString().slice(0, 7), // 当前月份,格式为YYYY-MM - previousPeriod: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000).toISOString().slice(0, 7), // 上个月,格式为YYYY-MM - }, - yearOnYear: { // 同比数据 - name: '本期去年同期对比', - growthRate: .156, // 同比增长率15.6% - currentValue: 87.2, // 当前值87.2% - previousValue: 75.4, // 去年同期值75.4% - currentPeriod: new Date().toISOString().slice(0, 7), // 当前月份,格式为YYYY-MM - previousPeriod: new Date(Date.now() - 365 * 24 * 60 * 60 * 1000).toISOString().slice(0, 7), // 去年同期月份 - } - }; + const comparisonData = comparisonType.value === 'yearOnYear' + ? props.comparativeData.monthYearOnYear + : props.comparativeData.month; return [{ - name: mockMonthlyData[comparisonType.value].name, - growthRate: mockMonthlyData[comparisonType.value].growthRate, - currentValue: convertPowerUsage(mockMonthlyData[comparisonType.value].currentValue, selectedCard.value), - previousValue: convertPowerUsage(mockMonthlyData[comparisonType.value].previousValue, selectedCard.value), - currentPeriod: mockMonthlyData[comparisonType.value].currentPeriod, - previousPeriod: mockMonthlyData[comparisonType.value].previousPeriod, + name: comparisonType.value === 'yearOnYear' ? '本期去年同期对比' : '本期上期对比', + growthRate: comparisonData.growthRate, + currentValue: convertPowerUsage(comparisonData.current.value, selectedCard.value), + previousValue: convertPowerUsage(comparisonData.previous.value, selectedCard.value), + currentPeriod: comparisonData.current.period, + previousPeriod: comparisonData.previous.period, }] }) diff --git a/public/map/components/ShorePowerUsageSingleData.vue b/public/map/components/ShorePowerUsageSingleData.vue index 81bf195..34ed6b1 100644 --- a/public/map/components/ShorePowerUsageSingleData.vue +++ b/public/map/components/ShorePowerUsageSingleData.vue @@ -219,55 +219,6 @@ - @@ -280,7 +231,7 @@ import WaveLineChart from './charts/WaveLineChart.vue' import { MapApi } from "@/api/shorepower/map"; import dayjs from 'dayjs'; import ComparisonBarChart from './charts/ComparisonBarChart.vue' -import { ComparativeData, RealtimeDeviceData } from '@/types/shorepower'; +import { MetricData, RealtimeDeviceData } from '@/types/shorepower'; import { formatTimestamp, parseRangeToTimestamp } from './utils'; @@ -289,7 +240,7 @@ interface Props { activeHeadGroup?: number; handleGoBack: () => void; realtimeDeviceDataTime: string; - comparativeData: ComparativeData; + comparativeData: MetricData; // 用电量对比数据 initialTimeRange?: 'realtime' | 'day' | 'month' | 'year'; yearData: RealtimeDeviceData[]; monthData: RealtimeDeviceData[]; @@ -374,35 +325,7 @@ export interface deviceData { const pageType = ref<'realtime' | 'history'>('realtime') const dateRange = ref([]) -const totalPower = ref('0') -const fuelReduction = ref('0') -const co2Reduction = ref('0') -const pm25Reduction = ref('0') -const noxReduction = ref('0') -const so2Reduction = ref('0') - -// const yearlyData = ref({}) -const getDailyData = computed(() => { - return [{ - name: '本期上期对比', - growthRate: props.comparativeData.day.growthRate, - currentValue: convertPowerUsage(props.comparativeData.day.current.value, selectedCard.value), - previousValue: convertPowerUsage(props.comparativeData.day.previous.value, selectedCard.value), - currentPeriod: props.comparativeData.day.current.period, - previousPeriod: props.comparativeData.day.previous.period, - }] -}) -const getMonthlyData = computed(() => { - return [{ - name: '本期上期对比', - growthRate: props.comparativeData.month.growthRate, - currentValue: convertPowerUsage(props.comparativeData.month.current.value, selectedCard.value), - previousValue: convertPowerUsage(props.comparativeData.month.previous.value, selectedCard.value), - currentPeriod: props.comparativeData.month.current.period, - previousPeriod: props.comparativeData.month.previous.period, - }] -}) const getYearlyData = computed(() => { return [{ name: '本期上期对比', diff --git a/public/map/components/ShowData.vue b/public/map/components/ShowData.vue index 5c73ee9..088216a 100644 --- a/public/map/components/ShowData.vue +++ b/public/map/components/ShowData.vue @@ -159,7 +159,8 @@
- +
+ :comparative-data="comparativeData.electricityConsumption" :year-data="yearDataRes" :month-data="monthDataRes" + :day-data="dayDataRes" /> @@ -312,6 +313,7 @@ import { CompanyShorePowerBuildDataItem, CompanyShorePowerData, ComparativeData, import { BERTH_TYPE, DOCK_DISTRICT, getOperationTypeLabel, HARBOR_DISTRICT, SHORE_POWER_FIRST_STATUS, SHORE_POWER_SECOND_STATUS_MAP, SHORE_POWER_STATUS, UNUSED_SHORE_POWER_REASON } from './components/dictionaryTable' import { formatDuration, formatTimestamp, getValueById, showStatus } from './components/utils' defineOptions({ name: 'PublicMap' }) + let getRealtimeIntervalId: NodeJS.Timeout | null = null @@ -808,7 +810,6 @@ onMounted(async () => { handleBuildCompanyShorePowerYear(tempBuildShipData) getDistributionBoxDataList() await handleGetBuildData() - buildShorePowerUsageRatio() dataLoad.value = true getRealtimeIntervalId = setInterval(async () => { @@ -1231,6 +1232,7 @@ const handleGetBuildData = async () => { const handleBuildTimeComparison = async (): Promise => { const now = dayjs(); + console.log(getShorePowerIds.value, getBerthingShipsIds.value, getDepartingShipsIds.value, getElectricityUsageIds.value) /** * 计算每个分组的周期用量(last.measureValue - first.measureValue 的总和) */ @@ -1244,6 +1246,36 @@ const handleBuildTimeComparison = async (): Promise => { }, 0); }; + /** + * 计算所有分组中 measureValue 的总和(即累计用量) + */ + const calculateTotalUsage = (apiResponse: Record): number => { + const dataArrays = Object.values(apiResponse).filter(Array.isArray) as { measureValue: number }[][]; + return dataArrays.reduce((total, row) => { + const rowSum = row.reduce((sum, item) => sum + item.measureValue, 0); + return total + rowSum; + }, 0); + }; + + /** + * 根据指定的 deviceId 数组,从数据源中筛选出对应的数据 + * @param {Object} dataSource - 数据源,格式如 {1: [...], 2: [...], ...} + * @param {Array} deviceIds - 要筛选的 deviceId 数组,如 [1, 2] + * @returns {Object} 筛选后的对象,只包含 deviceIds 中存在的键 + */ + function filterByDeviceIds(dataSource, deviceIds) { + const result = {}; + for (const id of deviceIds) { + // 使用 String(id) 确保类型一致(因为对象的 key 始终是字符串) + const key = String(id); + if (key in dataSource) { + result[key] = dataSource[key]; + } + } + return result; + } + + /** * 安全计算环比增长率:(current - previous) / previous * - 若 previous 为 0 且 current 也为 0 → 返回 0 @@ -1326,157 +1358,45 @@ const handleBuildTimeComparison = async (): Promise => { ]); // ===== 计算各周期用量 ===== - const todayUsage = calculatePeriodUsage(todayRes); - const yesterdayUsage = calculatePeriodUsage(yesterdayRes); - const lastYearTodayUsage = calculatePeriodUsage(lastYearTodayRes); - const thisMonthUsage = calculatePeriodUsage(thisMonthRes); - const lastMonthUsage = calculatePeriodUsage(lastMonthRes); - const lastYearMonthUsage = calculatePeriodUsage(lastYearMonthRes); - const thisYearUsage = calculatePeriodUsage(thisYearRes); - const lastYearUsage = calculatePeriodUsage(lastYearRes); + const todayUsage = calculatePeriodUsage(filterByDeviceIds(todayRes, getShorePowerIds.value)); + const yesterdayUsage = calculatePeriodUsage(filterByDeviceIds(yesterdayRes, getShorePowerIds.value)); + const lastYearTodayUsage = calculatePeriodUsage(filterByDeviceIds(lastYearTodayRes, getShorePowerIds.value)); + const thisMonthUsage = calculatePeriodUsage(filterByDeviceIds(thisMonthRes, getShorePowerIds.value)); + const lastMonthUsage = calculatePeriodUsage(filterByDeviceIds(lastMonthRes, getShorePowerIds.value)); + const lastYearMonthUsage = calculatePeriodUsage(filterByDeviceIds(lastYearMonthRes, getShorePowerIds.value)); + const thisYearUsage = calculatePeriodUsage(filterByDeviceIds(thisYearRes, getShorePowerIds.value)); + const lastYearUsage = calculatePeriodUsage(filterByDeviceIds(lastYearRes, getShorePowerIds.value)); + + // ===== 计算船舶使用率 ===== + const ship_todayUsage = calculateTotalUsage(filterByDeviceIds(todayRes, getElectricityUsageIds.value)) / calculateTotalUsage(filterByDeviceIds(todayRes, getBerthingShipsIds.value)); + const ship_yesterdayUsage = calculateTotalUsage(filterByDeviceIds(yesterdayRes, getElectricityUsageIds.value)) / calculateTotalUsage(filterByDeviceIds(yesterdayRes, getBerthingShipsIds.value)); + const ship_lastYearTodayUsage = calculateTotalUsage(filterByDeviceIds(lastYearTodayRes, getElectricityUsageIds.value)) / calculateTotalUsage(filterByDeviceIds(lastYearTodayRes, getBerthingShipsIds.value)); + const ship_thisMonthUsage = calculateTotalUsage(filterByDeviceIds(thisMonthRes, getElectricityUsageIds.value)) / calculateTotalUsage(filterByDeviceIds(thisMonthRes, getBerthingShipsIds.value)); + const ship_lastMonthUsage = calculateTotalUsage(filterByDeviceIds(lastMonthRes, getElectricityUsageIds.value)) / calculateTotalUsage(filterByDeviceIds(lastMonthRes, getBerthingShipsIds.value)); + const ship_lastYearMonthUsage = calculateTotalUsage(filterByDeviceIds(lastYearMonthRes, getElectricityUsageIds.value)) / calculateTotalUsage(filterByDeviceIds(lastYearMonthRes, getBerthingShipsIds.value)); + const ship_thisYearUsage = calculateTotalUsage(filterByDeviceIds(thisYearRes, getElectricityUsageIds.value)) / calculateTotalUsage(filterByDeviceIds(thisYearRes, getBerthingShipsIds.value)); + const ship_lastYearUsage = calculateTotalUsage(filterByDeviceIds(lastYearRes, getElectricityUsageIds.value)) / calculateTotalUsage(filterByDeviceIds(lastYearRes, getBerthingShipsIds.value)); + + + /* const ship_todayUsage = .5 + const ship_yesterdayUsage = .2 + const ship_lastYearTodayUsage = .3 + const ship_thisMonthUsage = .4 + const ship_lastMonthUsage = .1 + const ship_lastYearMonthUsage = .6 + const ship_thisYearUsage = .8 + const ship_lastYearUsage = .9 */ + /* 计算使用率 */ + /* const calculateUsageRate = () => { + const aa = calculateTotalUsage(filterByDeviceIds(todayRes, getBerthingShipsIds.value)) + const bb = calculateTotalUsage(filterByDeviceIds(todayRes, getElectricityUsageIds.value)) - // ===== 返回结构化结果 ===== - return { - day: { - growthRate: calculateGrowthRate(todayUsage, yesterdayUsage), - current: { period: now.format('YYYY-MM-DD'), value: todayUsage }, - previous: { period: yesterday.format('YYYY-MM-DD'), value: yesterdayUsage } - }, - dayYearOnYear: { - growthRate: calculateGrowthRate(todayUsage, lastYearTodayUsage), - current: { period: now.format('YYYY-MM-DD'), value: todayUsage }, - previous: { period: lastYearToday.format('YYYY-MM-DD'), value: lastYearTodayUsage } - }, - month: { - growthRate: calculateGrowthRate(thisMonthUsage, lastMonthUsage), - current: { period: now.format('YYYY-MM'), value: thisMonthUsage }, - previous: { period: lastMonth.format('YYYY-MM'), value: lastMonthUsage } - }, - monthYearOnYear: { - growthRate: calculateGrowthRate(thisMonthUsage, lastYearMonthUsage), - current: { period: now.format('YYYY-MM'), value: thisMonthUsage }, - previous: { period: lastYearMonth.format('YYYY-MM'), value: lastYearMonthUsage } - }, - year: { - growthRate: calculateGrowthRate(thisYearUsage, lastYearUsage), - current: { period: now.format('YYYY'), value: thisYearUsage }, - previous: { period: lastYear.format('YYYY'), value: lastYearUsage } - } }; -}; -/** - * 构建岸电使用率环比和同比 - */ -const buildShorePowerUsageRatio = () => { - const handleBuildTimeComparison = async (): Promise => { - const now = dayjs(); - - /** - * 计算每个分组的周期用量(last.measureValue - first.measureValue 的总和) - */ - const calculatePeriodUsage = (apiResponse: Record): number => { - const dataArrays = Object.values(apiResponse).filter(Array.isArray) as { measureValue: number }[][]; - return dataArrays.reduce((total, row) => { - if (row.length === 0) return total; - const firstValue = row[0].measureValue; - const lastValue = row[row.length - 1].measureValue; - return total + (lastValue - firstValue); - }, 0); - }; - - /** - * 安全计算环比增长率:(current - previous) / previous - * - 若 previous 为 0 且 current 也为 0 → 返回 0 - * - 若 previous 为 0 但 current > 0 → 返回 null(表示“新增”) - */ - const calculateGrowthRate = (current: number | null, previous: number | null): number => { - if (previous === 0) { - return current === 0 ? 0 : null; // null 表示无法计算(如从 0 到正数) - } - return (current - previous) / previous; - }; - - // ===== 构建日环比参数 ===== - const todayStart = now.startOf('day').valueOf(); - const todayEnd = now.valueOf(); - const yesterday = now.subtract(1, 'day'); - const yesterdayStart = yesterday.startOf('day').valueOf(); - const yesterdayEnd = yesterday.valueOf(); - - // ===== 构建日同比参数 ===== - const lastYearToday = now.subtract(1, 'year'); - const lastYearTodayStart = lastYearToday.startOf('day').valueOf(); - const lastYearTodayEnd = lastYearToday.valueOf(); - - // ===== 构建月环比参数(对齐天数)===== - const thisMonthStart = now.startOf('month').valueOf(); - const thisMonthEnd = now.valueOf(); - - const lastMonth = now.subtract(1, 'month'); - const lastMonthStart = lastMonth.startOf('month').valueOf(); - // 上月可能没有"今天"这个日期(如今天31号,上月只有30天),取最小值避免跨月 - const daysInLastMonth = lastMonth.daysInMonth(); - const todayDate = now.date(); - const alignedDay = Math.min(todayDate, daysInLastMonth); - const lastMonthEnd = lastMonth.date(alignedDay).endOf('day').valueOf(); - - // ===== 构建月同比参数(对齐天数)===== - const lastYearMonth = now.subtract(1, 'year'); - const lastYearMonthStart = lastYearMonth.startOf('month').valueOf(); - // 同样处理闰年/年末问题 - const daysInLastYearMonth = lastYearMonth.daysInMonth(); - const lastYearAlignedDay = Math.min(todayDate, daysInLastYearMonth); - const lastYearMonthEnd = lastYearMonth.date(lastYearAlignedDay).endOf('day').valueOf(); - - // ===== 构建年环比参数(对齐天数)===== - const thisYearStart = now.startOf('year').valueOf(); - const thisYearEnd = now.valueOf(); - - const lastYear = now.subtract(1, 'year'); - const lastYearStart = lastYear.startOf('year').valueOf(); - // 同样处理闰年/年末问题(如今天是 2 月 29 日,去年不是闰年) - let lastYearEnd: number; - try { - // 尝试设置为去年同月同日 - lastYearEnd = lastYear.month(now.month()).date(now.date()).endOf('day').valueOf(); - } catch { - // 如果失败(如 2/29 不存在),则取该月最后一天 - lastYearEnd = lastYear.month(now.month()).endOf('month').valueOf(); - } + calculateUsageRate() */ - // ===== 并发请求所有8个时间段的数据 ===== - const [ - todayRes, - yesterdayRes, - lastYearTodayRes, - thisMonthRes, - lastMonthRes, - lastYearMonthRes, - thisYearRes, - lastYearRes - ] = await Promise.all([ - MapApi.getByStartAndEndTimeAndTimeType({ start: todayStart, end: todayEnd, timeType: 2 }), - MapApi.getByStartAndEndTimeAndTimeType({ start: yesterdayStart, end: yesterdayEnd, timeType: 2 }), - MapApi.getByStartAndEndTimeAndTimeType({ start: lastYearTodayStart, end: lastYearTodayEnd, timeType: 2 }), - MapApi.getByStartAndEndTimeAndTimeType({ start: thisMonthStart, end: thisMonthEnd, timeType: 3 }), - MapApi.getByStartAndEndTimeAndTimeType({ start: lastMonthStart, end: lastMonthEnd, timeType: 3 }), - MapApi.getByStartAndEndTimeAndTimeType({ start: lastYearMonthStart, end: lastYearMonthEnd, timeType: 3 }), - MapApi.getByStartAndEndTimeAndTimeType({ start: thisYearStart, end: thisYearEnd, timeType: 4 }), - MapApi.getByStartAndEndTimeAndTimeType({ start: lastYearStart, end: lastYearEnd, timeType: 4 }) - ]); - - // ===== 计算各周期用量 ===== - const todayUsage = calculatePeriodUsage(todayRes); - const yesterdayUsage = calculatePeriodUsage(yesterdayRes); - const lastYearTodayUsage = calculatePeriodUsage(lastYearTodayRes); - const thisMonthUsage = calculatePeriodUsage(thisMonthRes); - const lastMonthUsage = calculatePeriodUsage(lastMonthRes); - const lastYearMonthUsage = calculatePeriodUsage(lastYearMonthRes); - const thisYearUsage = calculatePeriodUsage(thisYearRes); - const lastYearUsage = calculatePeriodUsage(lastYearRes); - - // ===== 返回结构化结果 ===== - return { + // ===== 返回结构化结果 ===== + return { + electricityConsumption: { day: { growthRate: calculateGrowthRate(todayUsage, yesterdayUsage), current: { period: now.format('YYYY-MM-DD'), value: todayUsage }, @@ -1502,9 +1422,57 @@ const buildShorePowerUsageRatio = () => { current: { period: now.format('YYYY'), value: thisYearUsage }, previous: { period: lastYear.format('YYYY'), value: lastYearUsage } } - }; - }; -} + }, + utilizationRate: { + day: { + growthRate: calculateGrowthRate(ship_todayUsage, ship_yesterdayUsage), + current: { period: now.format('YYYY-MM-DD'), value: ship_todayUsage }, + previous: { period: yesterday.format('YYYY-MM-DD'), value: ship_yesterdayUsage } + }, + dayYearOnYear: { + growthRate: calculateGrowthRate(ship_todayUsage, ship_lastYearTodayUsage), + current: { period: now.format('YYYY-MM-DD'), value: ship_todayUsage }, + previous: { period: lastYearToday.format('YYYY-MM-DD'), value: ship_lastYearTodayUsage } + }, + month: { + growthRate: calculateGrowthRate(ship_thisMonthUsage, ship_lastMonthUsage), + current: { period: now.format('YYYY-MM'), value: ship_thisMonthUsage }, + previous: { period: lastMonth.format('YYYY-MM'), value: ship_lastMonthUsage } + }, + monthYearOnYear: { + growthRate: calculateGrowthRate(ship_thisMonthUsage, ship_lastYearMonthUsage), + current: { period: now.format('YYYY-MM'), value: ship_thisMonthUsage }, + previous: { period: lastYearMonth.format('YYYY-MM'), value: ship_lastYearMonthUsage } + }, + year: { + growthRate: calculateGrowthRate(ship_thisYearUsage, ship_lastYearUsage), + current: { period: now.format('YYYY'), value: ship_thisYearUsage }, + previous: { period: lastYear.format('YYYY'), value: ship_lastYearUsage } + } + } + + } +}; + +const getShorePowerIds = computed(() => { + return realtimeDeviceData.value.filter(item => item.deviceCode.includes('Kwh')).map(item => item.deviceId) +}) + +/* 靠泊数量 */ +const getBerthingShipsIds = computed(() => { + return realtimeDeviceData.value.filter(item => item.deviceCode.includes('arrive')).map(item => item.deviceId) +}) + +/* 离泊数量 */ +const getDepartingShipsIds = computed(() => { + return realtimeDeviceData.value.filter(item => item.deviceCode.includes('depart')).map(item => item.deviceId) +}) + +/* 用电数量 */ +const getElectricityUsageIds = computed(() => { + return realtimeDeviceData.value.filter(item => item.deviceCode.includes('usage')).map(item => item.deviceId) +}) +