Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
smart_hotel_app
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张宏
smart_hotel_app
Commits
13eec49e
Commit
13eec49e
authored
Jun 10, 2026
by
张宏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
3
parent
1a461d59
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
74 additions
and
14 deletions
+74
-14
alert_list_repository.dart
lib/repositories/alert_list_repository.dart
+10
-1
alert_list_service.dart
lib/services/alert_list_service.dart
+6
-1
abnormal_list_cubit.dart
lib/views/home/abnormal_list/cubit/abnormal_list_cubit.dart
+36
-5
abnormal_list_state.dart
lib/views/home/abnormal_list/cubit/abnormal_list_state.dart
+7
-1
index_view.dart
lib/views/home/abnormal_list/index_view.dart
+12
-3
device_detail_view.dart
lib/views/report/device/device_detail_view.dart
+0
-0
对接方案.md
对接方案.md
+3
-3
No files found.
lib/repositories/alert_list_repository.dart
View file @
13eec49e
...
@@ -4,13 +4,22 @@ import '../models/bo/alert_list_bo.dart';
...
@@ -4,13 +4,22 @@ import '../models/bo/alert_list_bo.dart';
class
AlertListRepository
{
class
AlertListRepository
{
/// 获取告警列表
/// 获取告警列表
/// [alertStatus] 告警状态码:0=待处理 2=已处理 3=误报,不传则查询全部
Future
<
ResponseModel
<
AlertListBO
>>
getList
({
Future
<
ResponseModel
<
AlertListBO
>>
getList
({
required
int
pageSize
,
required
int
pageSize
,
required
int
pageNum
,
required
int
pageNum
,
String
?
alertStatus
,
})
{
})
{
final
params
=
<
String
,
dynamic
>{
'pageSize'
:
pageSize
,
'pageNum'
:
pageNum
,
};
if
(
alertStatus
!=
null
)
{
params
[
'alertStatus'
]
=
alertStatus
;
}
return
DioRequest
.
instance
.
get
<
AlertListBO
>(
return
DioRequest
.
instance
.
get
<
AlertListBO
>(
'/app/alert/list'
,
'/app/alert/list'
,
queryParameters:
{
'pageSize'
:
pageSize
,
'pageNum'
:
pageNum
}
,
queryParameters:
params
,
fromJsonT:
(
data
)
=>
fromJsonT:
(
data
)
=>
AlertListBO
.
fromJson
(
data
as
Map
<
String
,
dynamic
>),
AlertListBO
.
fromJson
(
data
as
Map
<
String
,
dynamic
>),
);
);
...
...
lib/services/alert_list_service.dart
View file @
13eec49e
...
@@ -7,10 +7,15 @@ class AlertListService {
...
@@ -7,10 +7,15 @@ class AlertListService {
AlertListService
({
required
AlertListRepository
repository
})
AlertListService
({
required
AlertListRepository
repository
})
:
_repository
=
repository
;
:
_repository
=
repository
;
Future
<
AlertListBO
>
getList
({
required
int
pageSize
,
required
int
pageNum
})
async
{
Future
<
AlertListBO
>
getList
({
required
int
pageSize
,
required
int
pageNum
,
String
?
alertStatus
,
})
async
{
final
result
=
await
_repository
.
getList
(
final
result
=
await
_repository
.
getList
(
pageSize:
pageSize
,
pageSize:
pageSize
,
pageNum:
pageNum
,
pageNum:
pageNum
,
alertStatus:
alertStatus
,
);
);
if
(
result
.
success
&&
result
.
data
!=
null
)
{
if
(
result
.
success
&&
result
.
data
!=
null
)
{
return
result
.
data
!;
return
result
.
data
!;
...
...
lib/views/home/abnormal_list/cubit/abnormal_list_cubit.dart
View file @
13eec49e
import
'package:auto_route/auto_route.dart'
;
import
'package:auto_route/auto_route.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_bloc/flutter_bloc.dart'
;
import
'package:flutter_bloc/flutter_bloc.dart'
;
import
'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'
;
import
'package:smart_hotel_app/repositories/alert_list_repository.dart'
;
import
'package:smart_hotel_app/repositories/alert_list_repository.dart'
;
import
'package:smart_hotel_app/routes/app_router.gr.dart'
;
import
'package:smart_hotel_app/routes/app_router.gr.dart'
;
import
'package:smart_hotel_app/services/alert_list_service.dart'
;
import
'package:smart_hotel_app/services/alert_list_service.dart'
;
import
'package:smart_hotel_app/views/home/abnormal_list/cubit/abnormal_list_state.dart'
;
import
'package:smart_hotel_app/views/home/abnormal_list/cubit/abnormal_list_state.dart'
;
/// AlarmStatus → 告警状态码(API 入参)
String
?
alarmStatusToApi
(
AlarmStatus
filter
)
{
switch
(
filter
)
{
case
AlarmStatus
.
all
:
return
null
;
case
AlarmStatus
.
pending
:
return
'0'
;
case
AlarmStatus
.
processed
:
return
'2'
;
case
AlarmStatus
.
falseAlarm
:
return
'3'
;
}
}
class
AbnormalListCubit
extends
Cubit
<
AbnormalListState
>
{
class
AbnormalListCubit
extends
Cubit
<
AbnormalListState
>
{
final
AlertListService
_service
;
final
AlertListService
_service
;
static
const
int
_pageSize
=
20
;
static
const
int
pageSize
=
20
;
PagingController
<
int
,
AlarmItem
>?
_pagingController
;
AbnormalListCubit
()
AbnormalListCubit
()
:
_service
=
AlertListService
(
:
_service
=
AlertListService
(
...
@@ -17,16 +34,28 @@ class AbnormalListCubit extends Cubit<AbnormalListState> {
...
@@ -17,16 +34,28 @@ class AbnormalListCubit extends Cubit<AbnormalListState> {
),
),
super
(
const
AbnormalListState
());
super
(
const
AbnormalListState
());
/// 绑定 PagingController(View initState 中调用)
void
bindPagingController
(
PagingController
<
int
,
AlarmItem
>
controller
)
{
_pagingController
=
controller
;
}
/// 解绑 PagingController(View dispose 中调用)
void
unbindPagingController
()
{
_pagingController
=
null
;
}
/// 供 PagingController.fetchPage 回调使用,每次加载新的一页
/// 供 PagingController.fetchPage 回调使用,每次加载新的一页
Future
<
List
<
AlarmItem
>>
fetchPage
(
int
pageKey
)
async
{
Future
<
List
<
AlarmItem
>>
fetchPage
(
int
pageKey
)
async
{
final
alertList
=
await
_service
.
getList
(
final
alertList
=
await
_service
.
getList
(
pageSize:
_
pageSize
,
pageSize:
pageSize
,
pageNum:
pageKey
,
pageNum:
pageKey
,
alertStatus:
alarmStatusToApi
(
state
.
currentFilter
),
);
);
// 首
頁時更新 tab 统计
数
// 首
页时更新 tab 统计数和总
数
if
(
pageKey
==
1
)
{
if
(
pageKey
==
1
)
{
emit
(
state
.
copyWith
(
emit
(
state
.
copyWith
(
totalCount:
alertList
.
total
,
allCount:
alertList
.
tabCount
.
all
,
allCount:
alertList
.
tabCount
.
all
,
pendingCount:
alertList
.
tabCount
.
pending
,
pendingCount:
alertList
.
tabCount
.
pending
,
processedCount:
alertList
.
tabCount
.
processed
,
processedCount:
alertList
.
tabCount
.
processed
,
...
@@ -39,12 +68,15 @@ class AbnormalListCubit extends Cubit<AbnormalListState> {
...
@@ -39,12 +68,15 @@ class AbnormalListCubit extends Cubit<AbnormalListState> {
.
toList
();
.
toList
();
}
}
/// 切换筛选 Tab,触发重新请求
void
setFilter
(
AlarmStatus
filter
)
{
void
setFilter
(
AlarmStatus
filter
)
{
if
(
state
.
currentFilter
==
filter
)
return
;
emit
(
state
.
copyWith
(
currentFilter:
filter
));
emit
(
state
.
copyWith
(
currentFilter:
filter
));
_pagingController
?.
refresh
();
}
}
void
onAlarmItemTap
(
AlarmItem
item
,
BuildContext
context
)
{
void
onAlarmItemTap
(
AlarmItem
item
,
BuildContext
context
)
{
final
alertId
=
int
.
tryParse
(
item
.
id
)
??
0
;
final
alertId
=
int
.
tryParse
(
item
.
id
)
??
0
;
context
.
pushRoute
(
AbnormalDetailRoute
(
alertId:
alertId
));
context
.
pushRoute
(
AbnormalDetailRoute
(
alertId:
alertId
));
}
}
}
}
\ No newline at end of file
lib/views/home/abnormal_list/cubit/abnormal_list_state.dart
View file @
13eec49e
...
@@ -61,6 +61,7 @@ class AbnormalListState extends Equatable {
...
@@ -61,6 +61,7 @@ class AbnormalListState extends Equatable {
final
bool
isLoading
;
final
bool
isLoading
;
final
String
?
error
;
final
String
?
error
;
final
AlarmStatus
currentFilter
;
final
AlarmStatus
currentFilter
;
final
int
totalCount
;
final
int
allCount
;
final
int
allCount
;
final
int
pendingCount
;
final
int
pendingCount
;
final
int
processedCount
;
final
int
processedCount
;
...
@@ -70,6 +71,7 @@ class AbnormalListState extends Equatable {
...
@@ -70,6 +71,7 @@ class AbnormalListState extends Equatable {
this
.
isLoading
=
false
,
this
.
isLoading
=
false
,
this
.
error
,
this
.
error
,
this
.
currentFilter
=
AlarmStatus
.
all
,
this
.
currentFilter
=
AlarmStatus
.
all
,
this
.
totalCount
=
0
,
this
.
allCount
=
0
,
this
.
allCount
=
0
,
this
.
pendingCount
=
0
,
this
.
pendingCount
=
0
,
this
.
processedCount
=
0
,
this
.
processedCount
=
0
,
...
@@ -80,15 +82,18 @@ class AbnormalListState extends Equatable {
...
@@ -80,15 +82,18 @@ class AbnormalListState extends Equatable {
bool
?
isLoading
,
bool
?
isLoading
,
String
?
error
,
String
?
error
,
AlarmStatus
?
currentFilter
,
AlarmStatus
?
currentFilter
,
int
?
totalCount
,
int
?
allCount
,
int
?
allCount
,
int
?
pendingCount
,
int
?
pendingCount
,
int
?
processedCount
,
int
?
processedCount
,
int
?
falseAlarmCount
,
int
?
falseAlarmCount
,
bool
clearError
=
false
,
})
{
})
{
return
AbnormalListState
(
return
AbnormalListState
(
isLoading:
isLoading
??
this
.
isLoading
,
isLoading:
isLoading
??
this
.
isLoading
,
error:
error
,
error:
clearError
?
null
:
(
error
??
this
.
error
)
,
currentFilter:
currentFilter
??
this
.
currentFilter
,
currentFilter:
currentFilter
??
this
.
currentFilter
,
totalCount:
totalCount
??
this
.
totalCount
,
allCount:
allCount
??
this
.
allCount
,
allCount:
allCount
??
this
.
allCount
,
pendingCount:
pendingCount
??
this
.
pendingCount
,
pendingCount:
pendingCount
??
this
.
pendingCount
,
processedCount:
processedCount
??
this
.
processedCount
,
processedCount:
processedCount
??
this
.
processedCount
,
...
@@ -101,6 +106,7 @@ class AbnormalListState extends Equatable {
...
@@ -101,6 +106,7 @@ class AbnormalListState extends Equatable {
isLoading
,
isLoading
,
error
,
error
,
currentFilter
,
currentFilter
,
totalCount
,
allCount
,
allCount
,
pendingCount
,
pendingCount
,
processedCount
,
processedCount
,
...
...
lib/views/home/abnormal_list/index_view.dart
View file @
13eec49e
...
@@ -30,23 +30,32 @@ class _AbnormalListBody extends StatefulWidget {
...
@@ -30,23 +30,32 @@ class _AbnormalListBody extends StatefulWidget {
class
_AbnormalListBodyState
extends
State
<
_AbnormalListBody
>
{
class
_AbnormalListBodyState
extends
State
<
_AbnormalListBody
>
{
late
final
PagingController
<
int
,
AlarmItem
>
_pagingController
;
late
final
PagingController
<
int
,
AlarmItem
>
_pagingController
;
late
final
AbnormalListCubit
_cubit
;
@override
@override
void
initState
()
{
void
initState
()
{
super
.
initState
();
super
.
initState
();
_cubit
=
context
.
read
<
AbnormalListCubit
>();
_pagingController
=
PagingController
<
int
,
AlarmItem
>(
_pagingController
=
PagingController
<
int
,
AlarmItem
>(
getNextPageKey:
(
state
)
{
getNextPageKey:
(
state
)
{
if
(
state
.
keys
==
null
||
state
.
keys
!.
isEmpty
)
return
1
;
if
(
state
.
keys
==
null
||
state
.
keys
!.
isEmpty
)
return
1
;
return
state
.
lastPageIsEmpty
?
null
:
state
.
nextIntPageKey
;
final
total
=
_cubit
.
state
.
totalCount
;
final
nextKey
=
state
.
nextIntPageKey
;
if
(
nextKey
==
null
)
return
null
;
if
((
nextKey
-
1
)
*
AbnormalListCubit
.
pageSize
>=
total
)
{
return
null
;
}
return
nextKey
;
},
},
fetchPage:
(
pageKey
)
=>
fetchPage:
(
pageKey
)
=>
_cubit
.
fetchPage
(
pageKey
),
context
.
read
<
AbnormalListCubit
>().
fetchPage
(
pageKey
),
);
);
_cubit
.
bindPagingController
(
_pagingController
);
}
}
@override
@override
void
dispose
()
{
void
dispose
()
{
_pagingController
.
dispose
();
_pagingController
.
dispose
();
_cubit
.
unbindPagingController
();
super
.
dispose
();
super
.
dispose
();
}
}
...
...
lib/views/report/device/device_detail_view.dart
deleted
100644 → 0
View file @
1a461d59
对接方案.md
View file @
13eec49e
# 智慧酒
店 App 接口对接方案
# 智慧酒
店 App 接口对接方案
...
@@ -232,8 +232,8 @@ class xxxBO extends Equatable {
...
@@ -232,8 +232,8 @@ class xxxBO extends Equatable {
|
全部设备 |GET | /app/device/list | 已对接 | 全部设备 | |
|
全部设备 |GET | /app/device/list | 已对接 | 全部设备 | |
|
联动规则管理 |GET | /app/linkage/rules |
未
对接 | 联动规则管理 | |
|
联动规则管理 |GET | /app/linkage/rules |
已
对接 | 联动规则管理 | |
|
联动规则管理-启用/禁用 |PUT | /app/linkage/rules/toggle |
未
对接 | 联动规则管理-启用/禁用 | |
|
联动规则管理-启用/禁用 |PUT | /app/linkage/rules/toggle |
已
对接 | 联动规则管理-启用/禁用 | |
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment