diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c7ace92dc7ca3df0946b4242990773b6e645d4da..032358ebb6fbb9864830a612146d720ed52d9f43 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1397,42 +1397,36 @@ packages: engines: {node: '>= 10.0.0'} cpu: [arm] os: [linux] - libc: [glibc] '@parcel/watcher-linux-arm-musl@2.5.0': resolution: {integrity: sha512-6uHywSIzz8+vi2lAzFeltnYbdHsDm3iIB57d4g5oaB9vKwjb6N6dRIgZMujw4nm5r6v9/BQH0noq6DzHrqr2pA==} engines: {node: '>= 10.0.0'} cpu: [arm] os: [linux] - libc: [musl] '@parcel/watcher-linux-arm64-glibc@2.5.0': resolution: {integrity: sha512-BfNjXwZKxBy4WibDb/LDCriWSKLz+jJRL3cM/DllnHH5QUyoiUNEp3GmL80ZqxeumoADfCCP19+qiYiC8gUBjA==} engines: {node: '>= 10.0.0'} cpu: [arm64] os: [linux] - libc: [glibc] '@parcel/watcher-linux-arm64-musl@2.5.0': resolution: {integrity: sha512-S1qARKOphxfiBEkwLUbHjCY9BWPdWnW9j7f7Hb2jPplu8UZ3nes7zpPOW9bkLbHRvWM0WDTsjdOTUgW0xLBN1Q==} engines: {node: '>= 10.0.0'} cpu: [arm64] os: [linux] - libc: [musl] '@parcel/watcher-linux-x64-glibc@2.5.0': resolution: {integrity: sha512-d9AOkusyXARkFD66S6zlGXyzx5RvY+chTP9Jp0ypSTC9d4lzyRs9ovGf/80VCxjKddcUvnsGwCHWuF2EoPgWjw==} engines: {node: '>= 10.0.0'} cpu: [x64] os: [linux] - libc: [glibc] '@parcel/watcher-linux-x64-musl@2.5.0': resolution: {integrity: sha512-iqOC+GoTDoFyk/VYSFHwjHhYrk8bljW6zOhPuhi5t9ulqiYq1togGJB5e3PwYVFFfeVgc6pbz3JdQyDoBszVaA==} engines: {node: '>= 10.0.0'} cpu: [x64] os: [linux] - libc: [musl] '@parcel/watcher-win32-arm64@2.5.0': resolution: {integrity: sha512-twtft1d+JRNkM5YbmexfcH/N4znDtjgysFaV9zvZmmJezQsKpkfLYJ+JFV3uygugK6AtIM2oADPkB2AdhBrNig==} @@ -1536,55 +1530,46 @@ packages: resolution: {integrity: sha512-9OwUnK/xKw6DyRlgx8UizeqRFOfi9mf5TYCw1uolDaJSbUmBxP85DE6T4ouCMoN6pXw8ZoTeZCSEfSaYo+/s1w==} cpu: [arm] os: [linux] - libc: [glibc] '@rollup/rollup-linux-arm-musleabihf@4.27.4': resolution: {integrity: sha512-Vgdo4fpuphS9V24WOV+KwkCVJ72u7idTgQaBoLRD0UxBAWTF9GWurJO9YD9yh00BzbkhpeXtm6na+MvJU7Z73A==} cpu: [arm] os: [linux] - libc: [musl] '@rollup/rollup-linux-arm64-gnu@4.27.4': resolution: {integrity: sha512-pleyNgyd1kkBkw2kOqlBx+0atfIIkkExOTiifoODo6qKDSpnc6WzUY5RhHdmTdIJXBdSnh6JknnYTtmQyobrVg==} cpu: [arm64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-arm64-musl@4.27.4': resolution: {integrity: sha512-caluiUXvUuVyCHr5DxL8ohaaFFzPGmgmMvwmqAITMpV/Q+tPoaHZ/PWa3t8B2WyoRcIIuu1hkaW5KkeTDNSnMA==} cpu: [arm64] os: [linux] - libc: [musl] '@rollup/rollup-linux-powerpc64le-gnu@4.27.4': resolution: {integrity: sha512-FScrpHrO60hARyHh7s1zHE97u0KlT/RECzCKAdmI+LEoC1eDh/RDji9JgFqyO+wPDb86Oa/sXkily1+oi4FzJQ==} cpu: [ppc64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-riscv64-gnu@4.27.4': resolution: {integrity: sha512-qyyprhyGb7+RBfMPeww9FlHwKkCXdKHeGgSqmIXw9VSUtvyFZ6WZRtnxgbuz76FK7LyoN8t/eINRbPUcvXB5fw==} cpu: [riscv64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-s390x-gnu@4.27.4': resolution: {integrity: sha512-PFz+y2kb6tbh7m3A7nA9++eInGcDVZUACulf/KzDtovvdTizHpZaJty7Gp0lFwSQcrnebHOqxF1MaKZd7psVRg==} cpu: [s390x] os: [linux] - libc: [glibc] '@rollup/rollup-linux-x64-gnu@4.27.4': resolution: {integrity: sha512-Ni8mMtfo+o/G7DVtweXXV/Ol2TFf63KYjTtoZ5f078AUgJTmaIJnj4JFU7TK/9SVWTaSJGxPi5zMDgK4w+Ez7Q==} cpu: [x64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-x64-musl@4.27.4': resolution: {integrity: sha512-5AeeAF1PB9TUzD+3cROzFTnAJAcVUGLuR8ng0E0WXGkYhp6RD6L+6szYVX+64Rs0r72019KHZS1ka1q+zU/wUw==} cpu: [x64] os: [linux] - libc: [musl] '@rollup/rollup-win32-arm64-msvc@4.27.4': resolution: {integrity: sha512-yOpVsA4K5qVwu2CaS3hHxluWIK5HQTjNV4tWjQXluMiiiu4pJj4BN98CvxohNCpcjMeTXk/ZMJBRbgRg8HBB6A==} @@ -1630,28 +1615,24 @@ packages: engines: {node: '>=10'} cpu: [arm64] os: [linux] - libc: [glibc] '@swc/core-linux-arm64-musl@1.9.3': resolution: {integrity: sha512-tzVH480RY6RbMl/QRgh5HK3zn1ZTFsThuxDGo6Iuk1MdwIbdFYUY034heWUTI4u3Db97ArKh0hNL0xhO3+PZdg==} engines: {node: '>=10'} cpu: [arm64] os: [linux] - libc: [musl] '@swc/core-linux-x64-gnu@1.9.3': resolution: {integrity: sha512-ivXXBRDXDc9k4cdv10R21ccBmGebVOwKXT/UdH1PhxUn9m/h8erAWjz5pcELwjiMf27WokqPgaWVfaclDbgE+w==} engines: {node: '>=10'} cpu: [x64] os: [linux] - libc: [glibc] '@swc/core-linux-x64-musl@1.9.3': resolution: {integrity: sha512-ILsGMgfnOz1HwdDz+ZgEuomIwkP1PHT6maigZxaCIuC6OPEhKE8uYna22uU63XvYcLQvZYDzpR3ms47WQPuNEg==} engines: {node: '>=10'} cpu: [x64] os: [linux] - libc: [musl] '@swc/core-win32-arm64-msvc@1.9.3': resolution: {integrity: sha512-e+XmltDVIHieUnNJHtspn6B+PCcFOMYXNJB1GqoCcyinkEIQNwC8KtWgMqUucUbEWJkPc35NHy9k8aCXRmw9Kg==} diff --git a/src/api/iot/statistics/index.ts b/src/api/iot/statistics/index.ts index 1ca00d65dc8707d33bcebc305077bb733bdf4621..0f88217abac5b4bcbf12a9adc0e0b11dddd3c2a2 100644 --- a/src/api/iot/statistics/index.ts +++ b/src/api/iot/statistics/index.ts @@ -16,10 +16,16 @@ export interface IotStatisticsSummaryRespVO { productCategoryDeviceCounts: Record } +/** 时间戳-数值的键值对类型 */ +interface TimeValueItem { + [key: string]: number +} + /** IoT 消息统计数据类型 */ export interface IotStatisticsDeviceMessageSummaryRespVO { - upstreamCounts: Record - downstreamCounts: Record + statType: number + upstreamCounts: TimeValueItem[] + downstreamCounts: TimeValueItem[] } // IoT 数据统计 API diff --git a/src/utils/formatTime.ts b/src/utils/formatTime.ts index 99eb428c3c60528d1c5d3d87fa86fd8b108cbb67..89f40281e507f7d2a880ff8dfc79b3dd2f94a4e8 100644 --- a/src/utils/formatTime.ts +++ b/src/utils/formatTime.ts @@ -330,3 +330,30 @@ export function getDateRange( dayjs(endDate).endOf('d').format('YYYY-MM-DD HH:mm:ss') ] } + +/** + * 获取指定小时前的时间戳 + * @param hours 小时数 + * @returns 返回指定小时前的时间戳(毫秒) + */ +export function getHoursAgo(hours: number): number { + return dayjs().subtract(hours, 'hour').valueOf() +} + +/** + * 获取标准时间范围的时间戳 + * @param range 时间范围,支持 '8h' | '24h' | '7d' + * @returns 返回开始时间戳(毫秒) + */ +export function getTimeRangeStart(range: '8h' | '24h' | '7d'): number { + switch (range) { + case '8h': + return getHoursAgo(8) + case '24h': + return getHoursAgo(24) + case '7d': + return dayjs().subtract(7, 'day').valueOf() + default: + return dayjs().valueOf() + } +} diff --git a/src/views/iot/home/components/ComparisonCard.vue b/src/views/iot/home/components/ComparisonCard.vue new file mode 100644 index 0000000000000000000000000000000000000000..4ccda6609a1aa9ff802851645208a46f6c9b294f --- /dev/null +++ b/src/views/iot/home/components/ComparisonCard.vue @@ -0,0 +1,50 @@ + + + + + diff --git a/src/views/iot/home/components/DeviceCountCard.vue b/src/views/iot/home/components/DeviceCountCard.vue new file mode 100644 index 0000000000000000000000000000000000000000..a09706ff4d97c633f61825da8441ab970402a359 --- /dev/null +++ b/src/views/iot/home/components/DeviceCountCard.vue @@ -0,0 +1,127 @@ + + + diff --git a/src/views/iot/home/components/DeviceStateCountCard.vue b/src/views/iot/home/components/DeviceStateCountCard.vue new file mode 100644 index 0000000000000000000000000000000000000000..849a3b8995caa7bad46baf9823a15dee0e1841e3 --- /dev/null +++ b/src/views/iot/home/components/DeviceStateCountCard.vue @@ -0,0 +1,162 @@ + + + diff --git a/src/views/iot/home/components/MessageTrendCard.vue b/src/views/iot/home/components/MessageTrendCard.vue new file mode 100644 index 0000000000000000000000000000000000000000..c8b2d0b4ed858dd30a86f5d3f5f79d88b90db471 --- /dev/null +++ b/src/views/iot/home/components/MessageTrendCard.vue @@ -0,0 +1,325 @@ + + + diff --git a/src/views/iot/home/index.vue b/src/views/iot/home/index.vue index bee4116bf0c05227d3c7e22809dc27afbdf63725..153b20ea741dc6aed54c1318d86e2ec2a75c5771 100644 --- a/src/views/iot/home/index.vue +++ b/src/views/iot/home/index.vue @@ -2,145 +2,65 @@ - -
-
- 分类数量 - -
- - {{ statsData.productCategoryCount }} - - -
- 今日新增 - +{{ statsData.productCategoryTodayCount }} -
-
-
+
- -
-
- 产品数量 - -
- {{ statsData.productCount }} - -
- 今日新增 - +{{ statsData.productTodayCount }} -
-
-
+
- -
-
- 设备数量 - -
- {{ statsData.deviceCount }} - -
- 今日新增 - +{{ statsData.deviceTodayCount }} -
-
-
+
- -
-
- 设备消息数 - -
- - {{ statsData.deviceMessageCount }} - - -
- 今日新增 - +{{ statsData.deviceMessageTodayCount }} -
-
-
+
- - -
-
+
- - - - -
-
- 在线设备 -
-
- -
-
- 离线设备 -
-
- -
-
- 待激活设备 -
-
-
-
+
- - -
-
+
@@ -148,356 +68,76 @@