初始提交
This commit is contained in:
75
bin/repository/StatisticsRepository.dart
Normal file
75
bin/repository/StatisticsRepository.dart
Normal file
@@ -0,0 +1,75 @@
|
||||
import 'package:EasyDartModule/EasyDartModule.dart';
|
||||
|
||||
import '../model/Bed.dart';
|
||||
|
||||
class StatisticsRepository {
|
||||
// 获取床位列表,支持查询条件
|
||||
Future<List> fetchBedList(Bed query) async {
|
||||
var db = EasyDartModule.dataBase;
|
||||
SelectorBuilder select = SelectorBuilder();
|
||||
|
||||
// 添加查询条件
|
||||
if (query.id != null) {
|
||||
select.eq('_id', query.id);
|
||||
}
|
||||
if (query.tid != null) {
|
||||
select.eq('oid', query.tid);
|
||||
}
|
||||
if (query.level != null) {
|
||||
select.gte('data_level', query.level);
|
||||
}
|
||||
if (query.bed_type_id != null) {
|
||||
select.eq('bed_type_id', query.bed_type_id);
|
||||
}
|
||||
if (query.bed_type_name != null) {
|
||||
select.match('bed_type_name', query.bed_type_name!,
|
||||
caseInsensitive: true);
|
||||
}
|
||||
if (query.bed_name != null) {
|
||||
select.match('bed_name', query.bed_name!, caseInsensitive: true);
|
||||
}
|
||||
if (query.is_mapped != null) {
|
||||
select.eq('is_mapped', query.is_mapped == true ? 1 : 0);
|
||||
}
|
||||
if (query.device_model != null) {
|
||||
select.match('device_model', query.device_model!, caseInsensitive: true);
|
||||
}
|
||||
if (query.device_name != null) {
|
||||
select.match('device_name', query.device_name!, caseInsensitive: true);
|
||||
}
|
||||
if (query.device_id != null) {
|
||||
select.eq('device_id', query.device_id);
|
||||
}
|
||||
if (query.status != null) {
|
||||
select.eq('status', query.status);
|
||||
}
|
||||
if (query.created_by_id != null) {
|
||||
select.eq('created_by_id', query.created_by_id);
|
||||
}
|
||||
if (query.updated_by_id != null) {
|
||||
select.eq('updated_by_id', query.updated_by_id);
|
||||
}
|
||||
if (query.oid != null) {
|
||||
select.eq('oid', query.oid);
|
||||
}
|
||||
if (query.start_time != null) {
|
||||
select.gte('created_at', query.start_time);
|
||||
}
|
||||
if (query.end_time != null) {
|
||||
select.lte('created_at', query.end_time);
|
||||
}
|
||||
if (query.deleted != null) {
|
||||
select.eq('deleted', query.deleted);
|
||||
}
|
||||
|
||||
// 执行查询
|
||||
var result = await db.query('bus_bed_info', condition: select);
|
||||
|
||||
// 如果查询结果为空,返回空列表
|
||||
return result.isEmpty ? [] : result;
|
||||
}
|
||||
|
||||
addStatisticsDayResult() {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user