@ledvance/ui-biz-bundle 1.1.142 → 1.1.143

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/package.json +1 -1
  2. package/src/hooks/DeviceDpStateHooks.ts +1 -1
  3. package/src/modules/flags/FlagPage.tsx +4 -1
  4. package/src/modules/timeSchedule/TimeScheduleEditpage.tsx +1 -1
  5. package/src/modules/timer/TimerPage.tsx +1 -1
  6. package/src/newModules/biorhythm/BiorhythmActions.ts +403 -451
  7. package/src/newModules/biorhythm/BiorhythmBean.ts +230 -230
  8. package/src/newModules/biorhythm/BiorhythmEditPage.tsx +18 -20
  9. package/src/newModules/biorhythm/BiorhythmPage.tsx +653 -698
  10. package/src/newModules/biorhythm/IconSelect.tsx +88 -88
  11. package/src/newModules/biorhythm/Router.ts +33 -33
  12. package/src/newModules/biorhythm/iconListData.ts +30 -30
  13. package/src/newModules/biorhythm/pIdList.ts +35 -35
  14. package/src/newModules/energyConsumption/EnergyConsumptionActions.ts +66 -28
  15. package/src/newModules/energyConsumption/EnergyConsumptionCard.tsx +172 -0
  16. package/src/newModules/energyConsumption/EnergyConsumptionChart.tsx +204 -118
  17. package/src/newModules/energyConsumption/EnergyConsumptionDetail.tsx +3 -0
  18. package/src/newModules/energyConsumption/EnergyConsumptionPage.tsx +16 -0
  19. package/src/newModules/energyConsumption/co2Data.ts +5 -0
  20. package/src/newModules/energyConsumption/component/NewBarChart.tsx +172 -168
  21. package/src/newModules/energyConsumption/component/PowerLineChart.tsx +108 -0
  22. package/src/newModules/energyConsumption/res/energy-chart.png +0 -0
  23. package/src/newModules/energyConsumption/res/index.ts +3 -0
  24. package/src/newModules/fixedTime/FixedTimeDetailPage.tsx +1 -1
  25. package/src/newModules/sleepWakeUp/SleepWakeUpDetailPage.tsx +1 -1
  26. package/src/newModules/swithInching/SwithInching.tsx +1 -1
  27. package/src/newModules/timeSchedule/TimeScheduleActions.ts +12 -12
  28. package/tsconfig.json +73 -46
@@ -1,88 +1,88 @@
1
- import { useNavigation, useRoute } from '@react-navigation/native'
2
- import React, { useEffect, useState } from 'react'
3
- import { Image, ScrollView, Text, TouchableOpacity, View } from 'react-native'
4
- import { Utils } from 'tuya-panel-kit'
5
- import iconList from '../biorhythm/iconListData'
6
- import LDVTopBar from '@ledvance/base/src/components/ldvTopBar'
7
- import I18n from '@ledvance/base/src/i18n'
8
- import ThemeType from '@ledvance/base/src/config/themeType'
9
-
10
- const cx = Utils.RatioUtils.convertX
11
- const { withTheme } = Utils.ThemeUtils
12
-
13
- interface SceneDetailPageParams {
14
- backText?: string
15
- id: any
16
- setIcon: (id) => void,
17
- iconIdList: any
18
- }
19
-
20
- function IconSelect(props: { theme?: ThemeType }) {
21
- const [list, setList] = useState(iconList)
22
- const navigation = useNavigation()
23
- const params = useRoute().params as SceneDetailPageParams
24
- const setColor = id => {
25
- const newList = list?.map(item => {
26
- return {
27
- ...item,
28
- selectStatus: item?.id === id,
29
- }
30
- })
31
- setList(newList)
32
- }
33
- useEffect(() => {
34
- const iconIdList = params?.iconIdList
35
- const iconId = params?.id
36
- const newList = list?.map(item => {
37
- return {
38
- ...item,
39
- selectStatus: item?.id === iconId,
40
- disabled: iconIdList?.some(val => val === item?.id && val !== iconId),
41
- }
42
- })
43
- setList(newList)
44
- }, [])
45
- useEffect(() =>{
46
- console.log(list, '< --- listttt')
47
- }, [list])
48
- return (
49
- <View style={{ flex: 1, flexDirection: 'column' }}>
50
- <LDVTopBar
51
- title={params.backText ?? I18n.getLang('add_new_trigger_time_system_back_text')}
52
- onBackPress={() => {
53
- navigation.goBack()
54
- }}
55
- />
56
- <ScrollView nestedScrollEnabled={true} style={{ marginHorizontal: cx(24) }}>
57
- <View style={{ marginTop: cx(40), marginBottom: cx(20) }}>
58
- <Text style={{ fontSize: cx(24), color: props.theme?.global.brand }}>{I18n.getLang('add_new_trigger_time_icon_selection_headline_text')}</Text>
59
- </View>
60
- <View
61
- style={{ flexDirection: 'row', flex: 1, flexWrap: 'wrap', justifyContent: 'space-between', alignItems: 'flex-start' }}>
62
- {list?.map(item => {
63
- return <TouchableOpacity
64
- onPress={() => {
65
- setColor(item?.id)
66
- params?.setIcon(item?.id)
67
- }}
68
- disabled={item?.disabled}
69
- key={item.id}
70
- >
71
- <Image
72
- source={{ uri: item?.icon }}
73
- style={{
74
- width: cx(32),
75
- height: cx(32),
76
- margin: cx(10),
77
- tintColor: item?.selectStatus ? props.theme?.icon.primary : item?.disabled && props.theme?.icon.disable || props.theme?.icon.normal,
78
- }}
79
- />
80
- </TouchableOpacity>
81
- })}
82
- </View>
83
- </ScrollView>
84
- </View>
85
- )
86
- }
87
-
88
- export default withTheme(IconSelect)
1
+ import { useNavigation, useRoute } from '@react-navigation/native'
2
+ import React, { useEffect, useState } from 'react'
3
+ import { Image, ScrollView, Text, TouchableOpacity, View } from 'react-native'
4
+ import { Utils } from 'tuya-panel-kit'
5
+ import iconList from '../biorhythm/iconListData'
6
+ import LDVTopBar from '@ledvance/base/src/components/ldvTopBar'
7
+ import I18n from '@ledvance/base/src/i18n'
8
+ import ThemeType from '@ledvance/base/src/config/themeType'
9
+
10
+ const cx = Utils.RatioUtils.convertX
11
+ const { withTheme } = Utils.ThemeUtils
12
+
13
+ interface SceneDetailPageParams {
14
+ backText?: string
15
+ id: any
16
+ setIcon: (id) => void,
17
+ iconIdList: any
18
+ }
19
+
20
+ function IconSelect(props: { theme?: ThemeType }) {
21
+ const [list, setList] = useState(iconList)
22
+ const navigation = useNavigation()
23
+ const params = useRoute().params as SceneDetailPageParams
24
+ const setColor = id => {
25
+ const newList = list?.map(item => {
26
+ return {
27
+ ...item,
28
+ selectStatus: item?.id === id,
29
+ }
30
+ })
31
+ setList(newList)
32
+ }
33
+ useEffect(() => {
34
+ const iconIdList = params?.iconIdList
35
+ const iconId = params?.id
36
+ const newList = list?.map(item => {
37
+ return {
38
+ ...item,
39
+ selectStatus: item?.id === iconId,
40
+ disabled: iconIdList?.some(val => val === item?.id && val !== iconId),
41
+ }
42
+ })
43
+ setList(newList)
44
+ }, [])
45
+ useEffect(() =>{
46
+ console.log(list, '< --- listttt')
47
+ }, [list])
48
+ return (
49
+ <View style={{ flex: 1, flexDirection: 'column' }}>
50
+ <LDVTopBar
51
+ title={params.backText ?? I18n.getLang('add_new_trigger_time_system_back_text')}
52
+ onBackPress={() => {
53
+ navigation.goBack()
54
+ }}
55
+ />
56
+ <ScrollView nestedScrollEnabled={true} style={{ marginHorizontal: cx(24) }}>
57
+ <View style={{ marginTop: cx(40), marginBottom: cx(20) }}>
58
+ <Text style={{ fontSize: cx(24), color: props.theme?.global.brand }}>{I18n.getLang('add_new_trigger_time_icon_selection_headline_text')}</Text>
59
+ </View>
60
+ <View
61
+ style={{ flexDirection: 'row', flex: 1, flexWrap: 'wrap', justifyContent: 'space-between', alignItems: 'flex-start' }}>
62
+ {list?.map(item => {
63
+ return <TouchableOpacity
64
+ onPress={() => {
65
+ setColor(item?.id)
66
+ params?.setIcon(item?.id)
67
+ }}
68
+ disabled={item?.disabled}
69
+ key={item.id}
70
+ >
71
+ <Image
72
+ source={{ uri: item?.icon }}
73
+ style={{
74
+ width: cx(32),
75
+ height: cx(32),
76
+ margin: cx(10),
77
+ tintColor: item?.selectStatus ? props.theme?.icon.primary : item?.disabled && props.theme?.icon.disable || props.theme?.icon.normal,
78
+ }}
79
+ />
80
+ </TouchableOpacity>
81
+ })}
82
+ </View>
83
+ </ScrollView>
84
+ </View>
85
+ )
86
+ }
87
+
88
+ export default withTheme(IconSelect)
@@ -1,34 +1,34 @@
1
- import {NavigationRoute} from "tuya-panel-kit";
2
- import BiorhythmPage from "./BiorhythmPage";
3
- import BiorhythmEditPage from "./BiorhythmEditPage";
4
- import BiorhythmIconSelectPage from "./IconSelect"
5
- import {ui_biz_routerKey} from "../../navigation/Routers";
6
-
7
- const BiorhythmPageRouters: NavigationRoute[] = [
8
- {
9
- name: ui_biz_routerKey.bi_biz_biological,
10
- component: BiorhythmPage,
11
- options:{
12
- hideTopbar: true,
13
- showOfflineView: false,
14
- }
15
- },
16
- {
17
- name: ui_biz_routerKey.bi_biz_biological_edit,
18
- component: BiorhythmEditPage,
19
- options:{
20
- hideTopbar: true,
21
- showOfflineView: false,
22
- }
23
- },
24
- {
25
- name: ui_biz_routerKey.bi_biz_biological_icon_select,
26
- component: BiorhythmIconSelectPage,
27
- options:{
28
- hideTopbar: true,
29
- showOfflineView: false,
30
- }
31
- },
32
- ]
33
-
1
+ import {NavigationRoute} from "tuya-panel-kit";
2
+ import BiorhythmPage from "./BiorhythmPage";
3
+ import BiorhythmEditPage from "./BiorhythmEditPage";
4
+ import BiorhythmIconSelectPage from "./IconSelect"
5
+ import {ui_biz_routerKey} from "../../navigation/Routers";
6
+
7
+ const BiorhythmPageRouters: NavigationRoute[] = [
8
+ {
9
+ name: ui_biz_routerKey.bi_biz_biological,
10
+ component: BiorhythmPage,
11
+ options:{
12
+ hideTopbar: true,
13
+ showOfflineView: false,
14
+ }
15
+ },
16
+ {
17
+ name: ui_biz_routerKey.bi_biz_biological_edit,
18
+ component: BiorhythmEditPage,
19
+ options:{
20
+ hideTopbar: true,
21
+ showOfflineView: false,
22
+ }
23
+ },
24
+ {
25
+ name: ui_biz_routerKey.bi_biz_biological_icon_select,
26
+ component: BiorhythmIconSelectPage,
27
+ options:{
28
+ hideTopbar: true,
29
+ showOfflineView: false,
30
+ }
31
+ },
32
+ ]
33
+
34
34
  export default BiorhythmPageRouters
@@ -1,30 +1,30 @@
1
- import res from '@ledvance/base/src/res'
2
-
3
- const iconList = [
4
- {id: 1, icon: res.biorhythom_icon1, selectStatus: false, disabled: false},
5
- {id: 2, icon: res.biorhythom_icon2, selectStatus: false, disabled: false},
6
- {id: 3, icon: res.biorhythom_icon3, selectStatus: false, disabled: false},
7
- {id: 4, icon: res.biorhythom_icon4, selectStatus: false, disabled: false},
8
- {id: 5, icon: res.biorhythom_icon5, selectStatus: false, disabled: false},
9
- {id: 6, icon: res.biorhythom_icon6, selectStatus: false, disabled: false},
10
- {id: 7, icon: res.biorhythom_icon7, selectStatus: false, disabled: false},
11
- {id: 8, icon: res.biorhythom_icon8, selectStatus: false, disabled: false},
12
- {id: 9, icon: res.biorhythom_icon9, selectStatus: false, disabled: false},
13
- {id: 10, icon: res.biorhythom_icon10, selectStatus: false, disabled: false},
14
- {id: 11, icon: res.biorhythom_icon11, selectStatus: false, disabled: false},
15
- {id: 12, icon: res.biorhythom_icon12, selectStatus: false, disabled: false},
16
- {id: 13, icon: res.biorhythom_icon13, selectStatus: false, disabled: false},
17
- {id: 14, icon: res.biorhythom_icon14, selectStatus: false, disabled: false},
18
- {id: 15, icon: res.biorhythom_icon15, selectStatus: false, disabled: false},
19
- {id: 16, icon: res.biorhythom_icon16, selectStatus: false, disabled: false},
20
- {id: 17, icon: res.biorhythom_icon17, selectStatus: false, disabled: false},
21
- {id: 18, icon: res.biorhythom_icon18, selectStatus: false, disabled: false},
22
- {id: 19, icon: res.biorhythom_icon19, selectStatus: false, disabled: false},
23
- {id: 20, icon: res.biorhythom_icon20, selectStatus: false, disabled: false},
24
- {id: 21, icon: res.biorhythom_icon21, selectStatus: false, disabled: false},
25
- {id: 22, icon: res.biorhythom_icon22, selectStatus: false, disabled: false},
26
- {id: 23, icon: res.biorhythom_icon23, selectStatus: false, disabled: false},
27
- {id: 24, icon: res.biorhythom_icon24, selectStatus: false, disabled: false},
28
- ]
29
-
30
- export default iconList
1
+ import res from '@ledvance/base/src/res'
2
+
3
+ const iconList = [
4
+ {id: 1, icon: res.biorhythom_icon1, selectStatus: false, disabled: false},
5
+ {id: 2, icon: res.biorhythom_icon2, selectStatus: false, disabled: false},
6
+ {id: 3, icon: res.biorhythom_icon3, selectStatus: false, disabled: false},
7
+ {id: 4, icon: res.biorhythom_icon4, selectStatus: false, disabled: false},
8
+ {id: 5, icon: res.biorhythom_icon5, selectStatus: false, disabled: false},
9
+ {id: 6, icon: res.biorhythom_icon6, selectStatus: false, disabled: false},
10
+ {id: 7, icon: res.biorhythom_icon7, selectStatus: false, disabled: false},
11
+ {id: 8, icon: res.biorhythom_icon8, selectStatus: false, disabled: false},
12
+ {id: 9, icon: res.biorhythom_icon9, selectStatus: false, disabled: false},
13
+ {id: 10, icon: res.biorhythom_icon10, selectStatus: false, disabled: false},
14
+ {id: 11, icon: res.biorhythom_icon11, selectStatus: false, disabled: false},
15
+ {id: 12, icon: res.biorhythom_icon12, selectStatus: false, disabled: false},
16
+ {id: 13, icon: res.biorhythom_icon13, selectStatus: false, disabled: false},
17
+ {id: 14, icon: res.biorhythom_icon14, selectStatus: false, disabled: false},
18
+ {id: 15, icon: res.biorhythom_icon15, selectStatus: false, disabled: false},
19
+ {id: 16, icon: res.biorhythom_icon16, selectStatus: false, disabled: false},
20
+ {id: 17, icon: res.biorhythom_icon17, selectStatus: false, disabled: false},
21
+ {id: 18, icon: res.biorhythom_icon18, selectStatus: false, disabled: false},
22
+ {id: 19, icon: res.biorhythom_icon19, selectStatus: false, disabled: false},
23
+ {id: 20, icon: res.biorhythom_icon20, selectStatus: false, disabled: false},
24
+ {id: 21, icon: res.biorhythom_icon21, selectStatus: false, disabled: false},
25
+ {id: 22, icon: res.biorhythom_icon22, selectStatus: false, disabled: false},
26
+ {id: 23, icon: res.biorhythom_icon23, selectStatus: false, disabled: false},
27
+ {id: 24, icon: res.biorhythom_icon24, selectStatus: false, disabled: false},
28
+ ]
29
+
30
+ export default iconList
@@ -1,36 +1,36 @@
1
- const pIdList = [
2
- '2tb7pu47xmtakusc',
3
- 'jde6i6cjuqafvhep',
4
- 'nertorg6rigv9kcs',
5
- 'upbvn0aceeduokg8',
6
- 'vz1ecmcefgtcjmze',
7
- '9pub2u7xzwe3luhn',
8
- 'eyqghznptocb0c09',
9
- 'qrj3ubhrz2udkkp3',
10
- 'edlnwro9m0jhogfk',
11
- 'qaf91tzgkjhzxdlg',
12
- 'yy0mpo6vahmhhnyx',
13
- 'pfdsrf1aa9p2iqm7',
14
- 'aanbfdroxoikeemq',
15
- 'n19x26xmhzsoduoc',
16
- 'cnwub7a6xrvr8tg1',
17
- 'ix2a1uedckqziihs',
18
- 'hlodwjcku419f9q3',
19
- 'ntdbtyr4e5rk0nva',
20
- 'ck9ujelnqptkc2gu',
21
- 'poor3eeaue1xtmtj',
22
- 'f84gfg5bqwopeh6b',
23
- '11w17umtgr8i7pzr',
24
- 'bivme7hztqwtansf',
25
- '3eeippeoos24ebym',
26
- 'greysrcf5qraouxc',
27
- 'zadmgcev0sjzfzxx',
28
- 'wdk5pdrtqlguvbhx',
29
- 'rfzv1m0tt7bczqaf',
30
- 'qusibjjgjyarjs6w',
31
- 'hqad0c0jizozhhzl',
32
- 'bvctkpyefwowjfnh',
33
- 'z7g5wwtayzypqhdo',
34
- ]
35
-
1
+ const pIdList = [
2
+ '2tb7pu47xmtakusc',
3
+ 'jde6i6cjuqafvhep',
4
+ 'nertorg6rigv9kcs',
5
+ 'upbvn0aceeduokg8',
6
+ 'vz1ecmcefgtcjmze',
7
+ '9pub2u7xzwe3luhn',
8
+ 'eyqghznptocb0c09',
9
+ 'qrj3ubhrz2udkkp3',
10
+ 'edlnwro9m0jhogfk',
11
+ 'qaf91tzgkjhzxdlg',
12
+ 'yy0mpo6vahmhhnyx',
13
+ 'pfdsrf1aa9p2iqm7',
14
+ 'aanbfdroxoikeemq',
15
+ 'n19x26xmhzsoduoc',
16
+ 'cnwub7a6xrvr8tg1',
17
+ 'ix2a1uedckqziihs',
18
+ 'hlodwjcku419f9q3',
19
+ 'ntdbtyr4e5rk0nva',
20
+ 'ck9ujelnqptkc2gu',
21
+ 'poor3eeaue1xtmtj',
22
+ 'f84gfg5bqwopeh6b',
23
+ '11w17umtgr8i7pzr',
24
+ 'bivme7hztqwtansf',
25
+ '3eeippeoos24ebym',
26
+ 'greysrcf5qraouxc',
27
+ 'zadmgcev0sjzfzxx',
28
+ 'wdk5pdrtqlguvbhx',
29
+ 'rfzv1m0tt7bczqaf',
30
+ 'qusibjjgjyarjs6w',
31
+ 'hqad0c0jizozhhzl',
32
+ 'bvctkpyefwowjfnh',
33
+ 'z7g5wwtayzypqhdo',
34
+ ]
35
+
36
36
  export default pIdList
@@ -1,19 +1,24 @@
1
- import {useDp} from "@ledvance/base/src/models/modules/NativePropsSlice";
2
- import {exportCsvFile, localeNumber, loopsText, monthFormat, monthFormatShort} from "@ledvance/base/src/utils/common";
3
- import {EnergyData} from "./component/EnergyModal";
4
- import {NativeApi} from "@ledvance/base/src/api/native";
1
+ import { NativeApi } from '@ledvance/base/src/api/native'
2
+ import I18n from '@ledvance/base/src/i18n'
3
+ import { useDp } from '@ledvance/base/src/models/modules/NativePropsSlice'
5
4
  import {
5
+ DpReportSataData,
6
6
  DpResultByMonthResData,
7
7
  getDataWithSpecified,
8
8
  getDpResultByHour,
9
- getDpResultByMonth
10
- } from "@ledvance/base/src/models/TuyaApi";
11
- import {DateType} from "./co2Data";
12
- import {OverviewItem} from "./EnergyConsumptionPage";
13
- import {overDays} from "@ledvance/base/src/utils/index";
14
- import dayjs from "dayjs";
15
- import {isEmpty} from "lodash";
16
- import I18n from "@ledvance/base/src/i18n";
9
+ getDpResultByMonth,
10
+ getSpecifiedTimeDpReportLogs
11
+ } from '@ledvance/base/src/models/TuyaApi'
12
+ import { exportCsvFile, localeNumber, loopsText, monthFormat, monthFormatShort } from '@ledvance/base/src/utils/common'
13
+ import { overDays, xLog } from '@ledvance/base/src/utils'
14
+ import dayjs from 'dayjs'
15
+ import CustomParseFormat from 'dayjs/plugin/customParseFormat'
16
+ import { isEmpty } from 'lodash'
17
+ import { DateType } from './co2Data'
18
+ import { EnergyData } from './component/EnergyModal'
19
+ import { OverviewItem } from './EnergyConsumptionPage'
20
+
21
+ dayjs.extend(CustomParseFormat)
17
22
 
18
23
  export function useElectricCurrent(dpCode: string): number {
19
24
  const current = useDp<number, any>(dpCode)[0] || 0
@@ -21,12 +26,12 @@ export function useElectricCurrent(dpCode: string): number {
21
26
  }
22
27
 
23
28
  export function useVoltage(dpCode: string): number {
24
- const voltage = useDp<number, any>(dpCode)[0] / 10 || 0;
29
+ const voltage = useDp<number, any>(dpCode)[0] / 10 || 0
25
30
  return localeNumber(voltage, 1)
26
31
  }
27
32
 
28
33
  export function usePower(dpCode: string): number {
29
- const power = useDp<number, any>(dpCode)[0] / 10 || 0;
34
+ const power = useDp<number, any>(dpCode)[0] / 10 || 0
30
35
  return localeNumber(power, 1)
31
36
  }
32
37
 
@@ -44,7 +49,7 @@ export async function getElectricity(devId: string, addEleDpCode: string, date:
44
49
  res = await getDpResultByYearMonth(devId, addEleDpCode, date)
45
50
  break
46
51
  case DateType.Day:
47
- res = await getDpResultByDate(devId, addEleDpCode, date);
52
+ res = await getDpResultByDate(devId, addEleDpCode, date)
48
53
  break
49
54
  }
50
55
  return res
@@ -52,19 +57,19 @@ export async function getElectricity(devId: string, addEleDpCode: string, date:
52
57
 
53
58
  let dpResultByMonthCache: DpResultByMonthResData | undefined = undefined
54
59
  const getDpResultByYear = async (devId: string, addEleDpCode: string, dateStr: string): Promise<OverviewItem[]> => {
55
- let res: DpResultByMonthResData | undefined;
60
+ let res: DpResultByMonthResData | undefined
56
61
  if (!dpResultByMonthCache) {
57
62
  dpResultByMonthCache = await getDpResultByMonth(devId, addEleDpCode, 'sum')
58
63
  }
59
- res = dpResultByMonthCache;
64
+ res = dpResultByMonthCache
60
65
  if (!isEmpty(res)) {
61
66
  if (!isEmpty(res.years)) {
62
- const year = dateStr;
67
+ const year = dateStr
63
68
  const curMonth = res.years[year]
64
- if (!curMonth){
65
- return [];
69
+ if (!curMonth) {
70
+ return []
66
71
  }
67
- const curMonthList = Object.keys(curMonth).sort((a, b) => parseInt(b) - parseInt(a));
72
+ const curMonthList = Object.keys(curMonth).sort((a, b) => parseInt(b) - parseInt(a))
68
73
  return curMonthList.map(month => {
69
74
  return {
70
75
  key: `${monthFormat(month)} ${year}`,
@@ -88,15 +93,15 @@ const getDpResultByYearMonth = async (devId: string, addEleDpCode: string, dateS
88
93
  const dayList = res.result
89
94
  return Object.keys(dayList).filter(v => Number(dayList[v]) > 0).map(time => {
90
95
  // 提取年、月和日
91
- const year = time.slice(0, 4);
92
- const month = time.slice(4, 6);
93
- const day = time.slice(6, 8);
96
+ const year = time.slice(0, 4)
97
+ const month = time.slice(4, 6)
98
+ const day = time.slice(6, 8)
94
99
 
95
100
  // 格式化为 'YYYY/MM/DD' 格式
96
101
  const formattedDate = `${year}/${month}/${day}`
97
102
  const dateStr = `${day}/${month}/${year}`
98
- const dateObj = dayjs(formattedDate, "YYYY/MM/DD");
99
- const dayOfWeek = dateObj.day() % 7;
103
+ const dateObj = dayjs(formattedDate, 'YYYY/MM/DD')
104
+ const dayOfWeek = dateObj.day() % 7
100
105
  const key = `${dateStr} (${loopsText[dayOfWeek]})`
101
106
  return {
102
107
  key,
@@ -112,7 +117,7 @@ const getDpResultByYearMonth = async (devId: string, addEleDpCode: string, dateS
112
117
 
113
118
  const getDpResultByDate = async (devId: string, addEleDpCode: string, date: string): Promise<OverviewItem[]> => {
114
119
  if (overDays(date, 7)) {
115
- console.log("getDpResultByDate overDays true")
120
+ console.log('getDpResultByDate overDays true')
116
121
  return []
117
122
  }
118
123
  const res = await getDpResultByHour(devId, addEleDpCode, date, 'sum')
@@ -121,7 +126,7 @@ const getDpResultByDate = async (devId: string, addEleDpCode: string, date: stri
121
126
  }
122
127
  const list: Array<OverviewItem> = []
123
128
  const resData = Object.keys(res)?.map(val => {
124
- return {key: Number(val?.slice(8, 10)), value: Number(res[val])}
129
+ return { key: Number(val?.slice(8, 10)), value: Number(res[val]) }
125
130
  })
126
131
  for (let i = 0; i <= 23; i++) {
127
132
  const hourData = resData?.find(val => val?.key === i)
@@ -137,6 +142,39 @@ const getDpResultByDate = async (devId: string, addEleDpCode: string, date: stri
137
142
  return list
138
143
  }
139
144
 
145
+ export interface PowerDataItem {
146
+ key: string
147
+ chartTitle: string
148
+ value: number
149
+ }
150
+
151
+ export async function getPowerData(devId: string, powerDpCode: string, interval: number): Promise<PowerDataItem[]> {
152
+ const now = dayjs()
153
+ const startTime = now.add(-1 * interval, 'minute').valueOf().toString()
154
+ const endTime = now.valueOf().toString()
155
+ const dpResult = await getSpecifiedTimeDpReportLogs(
156
+ devId,
157
+ [powerDpCode],
158
+ 'ASC',
159
+ startTime,
160
+ endTime,
161
+ {
162
+ maxRetries: 5,
163
+ initialDelay: 1000,
164
+ maxDelay: 30000,
165
+ backoffFactor: 2
166
+ }
167
+ ) as DpReportSataData[]
168
+ xLog('powerData', dpResult)
169
+ return dpResult.map(dp => {
170
+ return {
171
+ key: dp.timeStr,
172
+ chartTitle: dayjs.unix(dp.timeStamp).format('HH:mm:ss'),
173
+ value: parseFloat(dp.value) / 10
174
+ }
175
+ })
176
+ }
177
+
140
178
  export const exportEnergyCsv = (values: any[][], unit: string) => {
141
179
  const headers = [I18n.getLang('date'), `${I18n.getLang('consumption_data_annual_bar_chart_system_back_text')} (kWh)`, `Price(${unit})`]
142
180
  const functionName = 'EnergyConsumption'