Browse Source

创建本地数据库并写入信息

周素华 10 months ago
parent
commit
b27d69858e

BIN
android/app/jniLibs/arm64-v8a/libConfigFileINI.so


BIN
android/app/jniLibs/arm64-v8a/libLabelPrinterSDK.so


BIN
android/app/jniLibs/arm64-v8a/libSimpleLogModule.so


BIN
android/app/jniLibs/arm64-v8a/libc++_shared.so


BIN
android/app/jniLibs/x86/libConfigFileINI.so


BIN
android/app/jniLibs/x86/libLabelPrinterSDK.so


BIN
android/app/jniLibs/x86/libSimpleLogModule.so


BIN
android/app/jniLibs/x86/libc++_shared.so


BIN
android/app/jniLibs/x86_64/libConfigFileINI.so


BIN
android/app/jniLibs/x86_64/libLabelPrinterSDK.so


BIN
android/app/jniLibs/x86_64/libSimpleLogModule.so


BIN
android/app/jniLibs/x86_64/libc++_shared.so


+ 225 - 42
lib/drfit/database.g.dart

@@ -15,10 +15,29 @@ class $DeviceInfoTableTable extends DeviceInfoTable
15 15
   late final GeneratedColumn<String> username = GeneratedColumn<String>(
16 16
       'username', aliasedName, false,
17 17
       type: DriftSqlType.string, requiredDuringInsert: true);
18
-  static const VerificationMeta _phoneMeta = const VerificationMeta('phone');
18
+  static const VerificationMeta _phoneBrandMeta =
19
+      const VerificationMeta('phoneBrand');
19 20
   @override
20
-  late final GeneratedColumn<String> phone = GeneratedColumn<String>(
21
-      'phone', aliasedName, false,
21
+  late final GeneratedColumn<String> phoneBrand = GeneratedColumn<String>(
22
+      'phone_brand', aliasedName, false,
23
+      type: DriftSqlType.string, requiredDuringInsert: true);
24
+  static const VerificationMeta _phoneModelMeta =
25
+      const VerificationMeta('phoneModel');
26
+  @override
27
+  late final GeneratedColumn<String> phoneModel = GeneratedColumn<String>(
28
+      'phone_model', aliasedName, false,
29
+      type: DriftSqlType.string, requiredDuringInsert: true);
30
+  static const VerificationMeta _phoneReleaseMeta =
31
+      const VerificationMeta('phoneRelease');
32
+  @override
33
+  late final GeneratedColumn<String> phoneRelease = GeneratedColumn<String>(
34
+      'phone_release', aliasedName, false,
35
+      type: DriftSqlType.string, requiredDuringInsert: true);
36
+  static const VerificationMeta _phoneAddressMeta =
37
+      const VerificationMeta('phoneAddress');
38
+  @override
39
+  late final GeneratedColumn<String> phoneAddress = GeneratedColumn<String>(
40
+      'phone_address', aliasedName, false,
22 41
       type: DriftSqlType.string, requiredDuringInsert: true);
23 42
   static const VerificationMeta _bleMacMeta = const VerificationMeta('bleMac');
24 43
   @override
@@ -32,7 +51,15 @@ class $DeviceInfoTableTable extends DeviceInfoTable
32 51
       'ble_name', aliasedName, false,
33 52
       type: DriftSqlType.string, requiredDuringInsert: true);
34 53
   @override
35
-  List<GeneratedColumn> get $columns => [username, phone, bleMac, bleName];
54
+  List<GeneratedColumn> get $columns => [
55
+        username,
56
+        phoneBrand,
57
+        phoneModel,
58
+        phoneRelease,
59
+        phoneAddress,
60
+        bleMac,
61
+        bleName
62
+      ];
36 63
   @override
37 64
   String get aliasedName => _alias ?? actualTableName;
38 65
   @override
@@ -49,11 +76,37 @@ class $DeviceInfoTableTable extends DeviceInfoTable
49 76
     } else if (isInserting) {
50 77
       context.missing(_usernameMeta);
51 78
     }
52
-    if (data.containsKey('phone')) {
79
+    if (data.containsKey('phone_brand')) {
80
+      context.handle(
81
+          _phoneBrandMeta,
82
+          phoneBrand.isAcceptableOrUnknown(
83
+              data['phone_brand']!, _phoneBrandMeta));
84
+    } else if (isInserting) {
85
+      context.missing(_phoneBrandMeta);
86
+    }
87
+    if (data.containsKey('phone_model')) {
88
+      context.handle(
89
+          _phoneModelMeta,
90
+          phoneModel.isAcceptableOrUnknown(
91
+              data['phone_model']!, _phoneModelMeta));
92
+    } else if (isInserting) {
93
+      context.missing(_phoneModelMeta);
94
+    }
95
+    if (data.containsKey('phone_release')) {
96
+      context.handle(
97
+          _phoneReleaseMeta,
98
+          phoneRelease.isAcceptableOrUnknown(
99
+              data['phone_release']!, _phoneReleaseMeta));
100
+    } else if (isInserting) {
101
+      context.missing(_phoneReleaseMeta);
102
+    }
103
+    if (data.containsKey('phone_address')) {
53 104
       context.handle(
54
-          _phoneMeta, phone.isAcceptableOrUnknown(data['phone']!, _phoneMeta));
105
+          _phoneAddressMeta,
106
+          phoneAddress.isAcceptableOrUnknown(
107
+              data['phone_address']!, _phoneAddressMeta));
55 108
     } else if (isInserting) {
56
-      context.missing(_phoneMeta);
109
+      context.missing(_phoneAddressMeta);
57 110
     }
58 111
     if (data.containsKey('ble_mac')) {
59 112
       context.handle(_bleMacMeta,
@@ -78,8 +131,14 @@ class $DeviceInfoTableTable extends DeviceInfoTable
78 131
     return DeviceInfo(
79 132
       username: attachedDatabase.typeMapping
80 133
           .read(DriftSqlType.string, data['${effectivePrefix}username'])!,
81
-      phone: attachedDatabase.typeMapping
82
-          .read(DriftSqlType.string, data['${effectivePrefix}phone'])!,
134
+      phoneBrand: attachedDatabase.typeMapping
135
+          .read(DriftSqlType.string, data['${effectivePrefix}phone_brand'])!,
136
+      phoneModel: attachedDatabase.typeMapping
137
+          .read(DriftSqlType.string, data['${effectivePrefix}phone_model'])!,
138
+      phoneRelease: attachedDatabase.typeMapping
139
+          .read(DriftSqlType.string, data['${effectivePrefix}phone_release'])!,
140
+      phoneAddress: attachedDatabase.typeMapping
141
+          .read(DriftSqlType.string, data['${effectivePrefix}phone_address'])!,
83 142
       bleMac: attachedDatabase.typeMapping
84 143
           .read(DriftSqlType.string, data['${effectivePrefix}ble_mac'])!,
85 144
       bleName: attachedDatabase.typeMapping
@@ -97,8 +156,17 @@ class DeviceInfo extends DataClass implements Insertable<DeviceInfo> {
97 156
   /// 登录用户名
98 157
   final String username;
99 158
 
100
-  /// 登录手机型号
101
-  final String phone;
159
+  /// 登录手机品牌,如Redmi
160
+  final String phoneBrand;
161
+
162
+  /// 登录手机认证型号,如22120RN86C
163
+  final String phoneModel;
164
+
165
+  /// 登录手机版本,如14
166
+  final String phoneRelease;
167
+
168
+  /// 登录手机所在地址,如"北京市西城区月坛北街18号靠近物资大院"
169
+  final String phoneAddress;
102 170
 
103 171
   /// 登录蓝牙mac地址
104 172
   final String bleMac;
@@ -107,14 +175,20 @@ class DeviceInfo extends DataClass implements Insertable<DeviceInfo> {
107 175
   final String bleName;
108 176
   const DeviceInfo(
109 177
       {required this.username,
110
-      required this.phone,
178
+      required this.phoneBrand,
179
+      required this.phoneModel,
180
+      required this.phoneRelease,
181
+      required this.phoneAddress,
111 182
       required this.bleMac,
112 183
       required this.bleName});
113 184
   @override
114 185
   Map<String, Expression> toColumns(bool nullToAbsent) {
115 186
     final map = <String, Expression>{};
116 187
     map['username'] = Variable<String>(username);
117
-    map['phone'] = Variable<String>(phone);
188
+    map['phone_brand'] = Variable<String>(phoneBrand);
189
+    map['phone_model'] = Variable<String>(phoneModel);
190
+    map['phone_release'] = Variable<String>(phoneRelease);
191
+    map['phone_address'] = Variable<String>(phoneAddress);
118 192
     map['ble_mac'] = Variable<String>(bleMac);
119 193
     map['ble_name'] = Variable<String>(bleName);
120 194
     return map;
@@ -123,7 +197,10 @@ class DeviceInfo extends DataClass implements Insertable<DeviceInfo> {
123 197
   DeviceInfoTableCompanion toCompanion(bool nullToAbsent) {
124 198
     return DeviceInfoTableCompanion(
125 199
       username: Value(username),
126
-      phone: Value(phone),
200
+      phoneBrand: Value(phoneBrand),
201
+      phoneModel: Value(phoneModel),
202
+      phoneRelease: Value(phoneRelease),
203
+      phoneAddress: Value(phoneAddress),
127 204
       bleMac: Value(bleMac),
128 205
       bleName: Value(bleName),
129 206
     );
@@ -134,7 +211,10 @@ class DeviceInfo extends DataClass implements Insertable<DeviceInfo> {
134 211
     serializer ??= driftRuntimeOptions.defaultSerializer;
135 212
     return DeviceInfo(
136 213
       username: serializer.fromJson<String>(json['username']),
137
-      phone: serializer.fromJson<String>(json['phone']),
214
+      phoneBrand: serializer.fromJson<String>(json['phoneBrand']),
215
+      phoneModel: serializer.fromJson<String>(json['phoneModel']),
216
+      phoneRelease: serializer.fromJson<String>(json['phoneRelease']),
217
+      phoneAddress: serializer.fromJson<String>(json['phoneAddress']),
138 218
       bleMac: serializer.fromJson<String>(json['bleMac']),
139 219
       bleName: serializer.fromJson<String>(json['bleName']),
140 220
     );
@@ -144,17 +224,29 @@ class DeviceInfo extends DataClass implements Insertable<DeviceInfo> {
144 224
     serializer ??= driftRuntimeOptions.defaultSerializer;
145 225
     return <String, dynamic>{
146 226
       'username': serializer.toJson<String>(username),
147
-      'phone': serializer.toJson<String>(phone),
227
+      'phoneBrand': serializer.toJson<String>(phoneBrand),
228
+      'phoneModel': serializer.toJson<String>(phoneModel),
229
+      'phoneRelease': serializer.toJson<String>(phoneRelease),
230
+      'phoneAddress': serializer.toJson<String>(phoneAddress),
148 231
       'bleMac': serializer.toJson<String>(bleMac),
149 232
       'bleName': serializer.toJson<String>(bleName),
150 233
     };
151 234
   }
152 235
 
153 236
   DeviceInfo copyWith(
154
-          {String? username, String? phone, String? bleMac, String? bleName}) =>
237
+          {String? username,
238
+          String? phoneBrand,
239
+          String? phoneModel,
240
+          String? phoneRelease,
241
+          String? phoneAddress,
242
+          String? bleMac,
243
+          String? bleName}) =>
155 244
       DeviceInfo(
156 245
         username: username ?? this.username,
157
-        phone: phone ?? this.phone,
246
+        phoneBrand: phoneBrand ?? this.phoneBrand,
247
+        phoneModel: phoneModel ?? this.phoneModel,
248
+        phoneRelease: phoneRelease ?? this.phoneRelease,
249
+        phoneAddress: phoneAddress ?? this.phoneAddress,
158 250
         bleMac: bleMac ?? this.bleMac,
159 251
         bleName: bleName ?? this.bleName,
160 252
       );
@@ -162,7 +254,10 @@ class DeviceInfo extends DataClass implements Insertable<DeviceInfo> {
162 254
   String toString() {
163 255
     return (StringBuffer('DeviceInfo(')
164 256
           ..write('username: $username, ')
165
-          ..write('phone: $phone, ')
257
+          ..write('phoneBrand: $phoneBrand, ')
258
+          ..write('phoneModel: $phoneModel, ')
259
+          ..write('phoneRelease: $phoneRelease, ')
260
+          ..write('phoneAddress: $phoneAddress, ')
166 261
           ..write('bleMac: $bleMac, ')
167 262
           ..write('bleName: $bleName')
168 263
           ..write(')'))
@@ -170,50 +265,72 @@ class DeviceInfo extends DataClass implements Insertable<DeviceInfo> {
170 265
   }
171 266
 
172 267
   @override
173
-  int get hashCode => Object.hash(username, phone, bleMac, bleName);
268
+  int get hashCode => Object.hash(username, phoneBrand, phoneModel,
269
+      phoneRelease, phoneAddress, bleMac, bleName);
174 270
   @override
175 271
   bool operator ==(Object other) =>
176 272
       identical(this, other) ||
177 273
       (other is DeviceInfo &&
178 274
           other.username == this.username &&
179
-          other.phone == this.phone &&
275
+          other.phoneBrand == this.phoneBrand &&
276
+          other.phoneModel == this.phoneModel &&
277
+          other.phoneRelease == this.phoneRelease &&
278
+          other.phoneAddress == this.phoneAddress &&
180 279
           other.bleMac == this.bleMac &&
181 280
           other.bleName == this.bleName);
182 281
 }
183 282
 
184 283
 class DeviceInfoTableCompanion extends UpdateCompanion<DeviceInfo> {
185 284
   final Value<String> username;
186
-  final Value<String> phone;
285
+  final Value<String> phoneBrand;
286
+  final Value<String> phoneModel;
287
+  final Value<String> phoneRelease;
288
+  final Value<String> phoneAddress;
187 289
   final Value<String> bleMac;
188 290
   final Value<String> bleName;
189 291
   final Value<int> rowid;
190 292
   const DeviceInfoTableCompanion({
191 293
     this.username = const Value.absent(),
192
-    this.phone = const Value.absent(),
294
+    this.phoneBrand = const Value.absent(),
295
+    this.phoneModel = const Value.absent(),
296
+    this.phoneRelease = const Value.absent(),
297
+    this.phoneAddress = const Value.absent(),
193 298
     this.bleMac = const Value.absent(),
194 299
     this.bleName = const Value.absent(),
195 300
     this.rowid = const Value.absent(),
196 301
   });
197 302
   DeviceInfoTableCompanion.insert({
198 303
     required String username,
199
-    required String phone,
304
+    required String phoneBrand,
305
+    required String phoneModel,
306
+    required String phoneRelease,
307
+    required String phoneAddress,
200 308
     required String bleMac,
201 309
     required String bleName,
202 310
     this.rowid = const Value.absent(),
203 311
   })  : username = Value(username),
204
-        phone = Value(phone),
312
+        phoneBrand = Value(phoneBrand),
313
+        phoneModel = Value(phoneModel),
314
+        phoneRelease = Value(phoneRelease),
315
+        phoneAddress = Value(phoneAddress),
205 316
         bleMac = Value(bleMac),
206 317
         bleName = Value(bleName);
207 318
   static Insertable<DeviceInfo> custom({
208 319
     Expression<String>? username,
209
-    Expression<String>? phone,
320
+    Expression<String>? phoneBrand,
321
+    Expression<String>? phoneModel,
322
+    Expression<String>? phoneRelease,
323
+    Expression<String>? phoneAddress,
210 324
     Expression<String>? bleMac,
211 325
     Expression<String>? bleName,
212 326
     Expression<int>? rowid,
213 327
   }) {
214 328
     return RawValuesInsertable({
215 329
       if (username != null) 'username': username,
216
-      if (phone != null) 'phone': phone,
330
+      if (phoneBrand != null) 'phone_brand': phoneBrand,
331
+      if (phoneModel != null) 'phone_model': phoneModel,
332
+      if (phoneRelease != null) 'phone_release': phoneRelease,
333
+      if (phoneAddress != null) 'phone_address': phoneAddress,
217 334
       if (bleMac != null) 'ble_mac': bleMac,
218 335
       if (bleName != null) 'ble_name': bleName,
219 336
       if (rowid != null) 'rowid': rowid,
@@ -222,13 +339,19 @@ class DeviceInfoTableCompanion extends UpdateCompanion<DeviceInfo> {
222 339
 
223 340
   DeviceInfoTableCompanion copyWith(
224 341
       {Value<String>? username,
225
-      Value<String>? phone,
342
+      Value<String>? phoneBrand,
343
+      Value<String>? phoneModel,
344
+      Value<String>? phoneRelease,
345
+      Value<String>? phoneAddress,
226 346
       Value<String>? bleMac,
227 347
       Value<String>? bleName,
228 348
       Value<int>? rowid}) {
229 349
     return DeviceInfoTableCompanion(
230 350
       username: username ?? this.username,
231
-      phone: phone ?? this.phone,
351
+      phoneBrand: phoneBrand ?? this.phoneBrand,
352
+      phoneModel: phoneModel ?? this.phoneModel,
353
+      phoneRelease: phoneRelease ?? this.phoneRelease,
354
+      phoneAddress: phoneAddress ?? this.phoneAddress,
232 355
       bleMac: bleMac ?? this.bleMac,
233 356
       bleName: bleName ?? this.bleName,
234 357
       rowid: rowid ?? this.rowid,
@@ -241,8 +364,17 @@ class DeviceInfoTableCompanion extends UpdateCompanion<DeviceInfo> {
241 364
     if (username.present) {
242 365
       map['username'] = Variable<String>(username.value);
243 366
     }
244
-    if (phone.present) {
245
-      map['phone'] = Variable<String>(phone.value);
367
+    if (phoneBrand.present) {
368
+      map['phone_brand'] = Variable<String>(phoneBrand.value);
369
+    }
370
+    if (phoneModel.present) {
371
+      map['phone_model'] = Variable<String>(phoneModel.value);
372
+    }
373
+    if (phoneRelease.present) {
374
+      map['phone_release'] = Variable<String>(phoneRelease.value);
375
+    }
376
+    if (phoneAddress.present) {
377
+      map['phone_address'] = Variable<String>(phoneAddress.value);
246 378
     }
247 379
     if (bleMac.present) {
248 380
       map['ble_mac'] = Variable<String>(bleMac.value);
@@ -260,7 +392,10 @@ class DeviceInfoTableCompanion extends UpdateCompanion<DeviceInfo> {
260 392
   String toString() {
261 393
     return (StringBuffer('DeviceInfoTableCompanion(')
262 394
           ..write('username: $username, ')
263
-          ..write('phone: $phone, ')
395
+          ..write('phoneBrand: $phoneBrand, ')
396
+          ..write('phoneModel: $phoneModel, ')
397
+          ..write('phoneRelease: $phoneRelease, ')
398
+          ..write('phoneAddress: $phoneAddress, ')
264 399
           ..write('bleMac: $bleMac, ')
265 400
           ..write('bleName: $bleName, ')
266 401
           ..write('rowid: $rowid')
@@ -286,7 +421,10 @@ abstract class _$MyDatabase extends GeneratedDatabase {
286 421
 typedef $$DeviceInfoTableTableInsertCompanionBuilder = DeviceInfoTableCompanion
287 422
     Function({
288 423
   required String username,
289
-  required String phone,
424
+  required String phoneBrand,
425
+  required String phoneModel,
426
+  required String phoneRelease,
427
+  required String phoneAddress,
290 428
   required String bleMac,
291 429
   required String bleName,
292 430
   Value<int> rowid,
@@ -294,7 +432,10 @@ typedef $$DeviceInfoTableTableInsertCompanionBuilder = DeviceInfoTableCompanion
294 432
 typedef $$DeviceInfoTableTableUpdateCompanionBuilder = DeviceInfoTableCompanion
295 433
     Function({
296 434
   Value<String> username,
297
-  Value<String> phone,
435
+  Value<String> phoneBrand,
436
+  Value<String> phoneModel,
437
+  Value<String> phoneRelease,
438
+  Value<String> phoneAddress,
298 439
   Value<String> bleMac,
299 440
   Value<String> bleName,
300 441
   Value<int> rowid,
@@ -322,28 +463,40 @@ class $$DeviceInfoTableTableTableManager extends RootTableManager<
322 463
               $$DeviceInfoTableTableProcessedTableManager(p),
323 464
           getUpdateCompanionBuilder: ({
324 465
             Value<String> username = const Value.absent(),
325
-            Value<String> phone = const Value.absent(),
466
+            Value<String> phoneBrand = const Value.absent(),
467
+            Value<String> phoneModel = const Value.absent(),
468
+            Value<String> phoneRelease = const Value.absent(),
469
+            Value<String> phoneAddress = const Value.absent(),
326 470
             Value<String> bleMac = const Value.absent(),
327 471
             Value<String> bleName = const Value.absent(),
328 472
             Value<int> rowid = const Value.absent(),
329 473
           }) =>
330 474
               DeviceInfoTableCompanion(
331 475
             username: username,
332
-            phone: phone,
476
+            phoneBrand: phoneBrand,
477
+            phoneModel: phoneModel,
478
+            phoneRelease: phoneRelease,
479
+            phoneAddress: phoneAddress,
333 480
             bleMac: bleMac,
334 481
             bleName: bleName,
335 482
             rowid: rowid,
336 483
           ),
337 484
           getInsertCompanionBuilder: ({
338 485
             required String username,
339
-            required String phone,
486
+            required String phoneBrand,
487
+            required String phoneModel,
488
+            required String phoneRelease,
489
+            required String phoneAddress,
340 490
             required String bleMac,
341 491
             required String bleName,
342 492
             Value<int> rowid = const Value.absent(),
343 493
           }) =>
344 494
               DeviceInfoTableCompanion.insert(
345 495
             username: username,
346
-            phone: phone,
496
+            phoneBrand: phoneBrand,
497
+            phoneModel: phoneModel,
498
+            phoneRelease: phoneRelease,
499
+            phoneAddress: phoneAddress,
347 500
             bleMac: bleMac,
348 501
             bleName: bleName,
349 502
             rowid: rowid,
@@ -371,8 +524,23 @@ class $$DeviceInfoTableTableFilterComposer
371 524
       builder: (column, joinBuilders) =>
372 525
           ColumnFilters(column, joinBuilders: joinBuilders));
373 526
 
374
-  ColumnFilters<String> get phone => $state.composableBuilder(
375
-      column: $state.table.phone,
527
+  ColumnFilters<String> get phoneBrand => $state.composableBuilder(
528
+      column: $state.table.phoneBrand,
529
+      builder: (column, joinBuilders) =>
530
+          ColumnFilters(column, joinBuilders: joinBuilders));
531
+
532
+  ColumnFilters<String> get phoneModel => $state.composableBuilder(
533
+      column: $state.table.phoneModel,
534
+      builder: (column, joinBuilders) =>
535
+          ColumnFilters(column, joinBuilders: joinBuilders));
536
+
537
+  ColumnFilters<String> get phoneRelease => $state.composableBuilder(
538
+      column: $state.table.phoneRelease,
539
+      builder: (column, joinBuilders) =>
540
+          ColumnFilters(column, joinBuilders: joinBuilders));
541
+
542
+  ColumnFilters<String> get phoneAddress => $state.composableBuilder(
543
+      column: $state.table.phoneAddress,
376 544
       builder: (column, joinBuilders) =>
377 545
           ColumnFilters(column, joinBuilders: joinBuilders));
378 546
 
@@ -395,8 +563,23 @@ class $$DeviceInfoTableTableOrderingComposer
395 563
       builder: (column, joinBuilders) =>
396 564
           ColumnOrderings(column, joinBuilders: joinBuilders));
397 565
 
398
-  ColumnOrderings<String> get phone => $state.composableBuilder(
399
-      column: $state.table.phone,
566
+  ColumnOrderings<String> get phoneBrand => $state.composableBuilder(
567
+      column: $state.table.phoneBrand,
568
+      builder: (column, joinBuilders) =>
569
+          ColumnOrderings(column, joinBuilders: joinBuilders));
570
+
571
+  ColumnOrderings<String> get phoneModel => $state.composableBuilder(
572
+      column: $state.table.phoneModel,
573
+      builder: (column, joinBuilders) =>
574
+          ColumnOrderings(column, joinBuilders: joinBuilders));
575
+
576
+  ColumnOrderings<String> get phoneRelease => $state.composableBuilder(
577
+      column: $state.table.phoneRelease,
578
+      builder: (column, joinBuilders) =>
579
+          ColumnOrderings(column, joinBuilders: joinBuilders));
580
+
581
+  ColumnOrderings<String> get phoneAddress => $state.composableBuilder(
582
+      column: $state.table.phoneAddress,
400 583
       builder: (column, joinBuilders) =>
401 584
           ColumnOrderings(column, joinBuilders: joinBuilders));
402 585
 

+ 8 - 2
lib/drfit/device_info_table.dart

@@ -5,8 +5,14 @@ class DeviceInfoTable extends Table {
5 5
 
6 6
   /// 登录用户名
7 7
   TextColumn get username => text()();
8
-  /// 登录手机型号
9
-  TextColumn get phone => text()();
8
+  /// 登录手机品牌,如Redmi
9
+  TextColumn get phoneBrand => text()();
10
+  /// 登录手机认证型号,如22120RN86C
11
+  TextColumn get phoneModel=> text()();
12
+  /// 登录手机版本,如14
13
+  TextColumn get phoneRelease => text()();
14
+  /// 登录手机所在地址,如"北京市西城区月坛北街18号靠近物资大院"
15
+  TextColumn get phoneAddress => text()();
10 16
   /// 登录蓝牙mac地址
11 17
   TextColumn get bleMac => text()();
12 18
   /// 登录蓝牙名称

+ 8 - 2
lib/drfit/model_factory.dart

@@ -1,17 +1,23 @@
1 1
 
2 2
 
3
+import 'package:device_info_plus/device_info_plus.dart';
3 4
 import 'package:drift/drift.dart';
4 5
 import 'package:lszlgl/drfit/database.dart';
6
+import 'package:lszlgl/service/print_service.dart';
5 7
 
6 8
 import '../model/rsp/user_rsp.dart';
7 9
 import '../service/user_service.dart';
8 10
 
9 11
 class ModelFactory {
10
-  static DeviceInfoTableCompanion convertToTSlideComp(String bleMac, String bleName) {
12
+  static Future<DeviceInfoTableCompanion> convertToTSlideComp(String bleMac, String bleName, String phoneAddress) async {
11 13
     UserRsp? userRsp =  UserService.get().getUser();
14
+    AndroidDeviceInfo? androidDeviceInfo = await PrintService.getDeviceInfo();
12 15
     var tsc = DeviceInfoTableCompanion(
13 16
       username: Value.absentIfNull(userRsp?.username),
14
-      phone: const Value.absentIfNull(''),
17
+      phoneBrand: Value.absentIfNull(androidDeviceInfo?.board),
18
+      phoneModel: Value.absentIfNull(androidDeviceInfo?.model),
19
+      phoneRelease: Value.absentIfNull(androidDeviceInfo?.version.release),
20
+      phoneAddress: Value(phoneAddress),
15 21
       bleMac: Value(bleMac),
16 22
       bleName: Value(bleName),
17 23
     );

+ 2 - 0
lib/main.dart

@@ -11,6 +11,7 @@ import 'package:logger/logger.dart';
11 11
 import 'package:lszlgl/config/colors.dart';
12 12
 import 'package:lszlgl/drfit/database.dart';
13 13
 import 'package:lszlgl/router/my_navigator.dart';
14
+import 'package:lszlgl/service/print_service.dart';
14 15
 import 'package:path_provider/path_provider.dart';
15 16
 import 'package:path/path.dart' as p;
16 17
 
@@ -32,6 +33,7 @@ void main() async {
32 33
 
33 34
     runApp(const MyApp());
34 35
     database = MyDatabase();
36
+    PrintService.getDeviceInfo();
35 37
   });
36 38
 }
37 39
 

+ 40 - 8
lib/page/print/print_page.dart

@@ -1,3 +1,7 @@
1
+import 'dart:async';
2
+import 'dart:convert';
3
+
4
+import 'package:amap_flutter_location/amap_location_option.dart';
1 5
 import 'package:flutter/material.dart';
2 6
 import 'package:flutter/services.dart';
3 7
 import 'package:lszlgl/base/base_lifecycle_state.dart';
@@ -10,6 +14,7 @@ import '../../drfit/model_factory.dart';
10 14
 import '../../main.dart';
11 15
 import '../../plugin/bluetooth_plugin.dart';
12 16
 import '../../service/print_service.dart';
17
+import '../../utils/location_utils.dart';
13 18
 import '../home/home_page.dart';
14 19
 import 'dart:ui' as ui;
15 20
 
@@ -47,6 +52,12 @@ class _PrintPageState extends BaseLifecycleState<PrintPage> {
47 52
 
48 53
   String scanDeviceState = '';
49 54
 
55
+  StreamSubscription? locationListener;
56
+  StreamSubscription? onReceiveDataStreamListener;
57
+  StreamSubscription? onDeviceStateStreamListener;
58
+  String phoneAddress = '';
59
+
60
+
50 61
   @override
51 62
   void initState() {
52 63
     super.initState();
@@ -63,12 +74,13 @@ class _PrintPageState extends BaseLifecycleState<PrintPage> {
63 74
         PrintService.connectedDeviceMacList = [];
64 75
       }
65 76
     });
77
+
78
+    getLocation();
66 79
   }
67 80
 
68 81
   /// 去打印
69 82
   Future<void> startPrint() async {
70 83
 
71
-
72 84
     int targetWidth = 560;
73 85
     if(PrintService.connectedDeviceList.last.deviceName.contains("BTP-UP321")) {
74 86
       targetWidth = 500;
@@ -102,7 +114,7 @@ class _PrintPageState extends BaseLifecycleState<PrintPage> {
102 114
   }
103 115
 
104 116
   Future<int> savaToSqlite(BlueDeviceInfo deviceInfo) async {
105
-    DeviceInfoTableCompanion tableCompanion = ModelFactory.convertToTSlideComp(deviceInfo.deviceMac, deviceInfo.deviceName);
117
+    DeviceInfoTableCompanion tableCompanion = await ModelFactory.convertToTSlideComp(deviceInfo.deviceMac, deviceInfo.deviceName, phoneAddress);
106 118
     return await database.deviceInfoTableDao.addOneDeviceComp(tableCompanion);
107 119
   }
108 120
 
@@ -153,10 +165,27 @@ class _PrintPageState extends BaseLifecycleState<PrintPage> {
153 165
     }
154 166
   }
155 167
 
168
+  void getLocation() async {
169
+    bool granted = await LocationUtils.requestLocationPermission();
170
+    if (!granted) {
171
+      MyNavigator.showToast('请打开APP的定位权限');
172
+      return;
173
+    }
174
+    LocationUtils.setLocationOption(AMapLocationOption(onceLocation: true));
175
+    LocationUtils.startLocation();
176
+  }
177
+
178
+  void initLocation() {
179
+    locationListener = LocationUtils.onLocationChanged().listen((value) async {
180
+
181
+      phoneAddress = value['address'] as String;
182
+    });
183
+  }
184
+
156 185
   @override
157 186
   void onInit() {
158 187
 
159
-    BluetoothPlugin.instance.onReceiveDataStream.listen((deviceInfo) {
188
+    onReceiveDataStreamListener = BluetoothPlugin.instance.onReceiveDataStream.listen((deviceInfo) {
160 189
       if(deviceInfo != null) {
161 190
         if(deviceMacList.contains(deviceInfo.deviceMac)) {
162 191
           setState(() {
@@ -174,7 +203,7 @@ class _PrintPageState extends BaseLifecycleState<PrintPage> {
174 203
       }
175 204
     });
176 205
 
177
-    BluetoothPlugin.instance.onDeviceStateStream.listen((deviceState) {
206
+    onDeviceStateStreamListener = BluetoothPlugin.instance.onDeviceStateStream.listen((deviceState) {
178 207
       if(deviceState == DeviceState.pairEnd) {
179 208
         MyNavigator.dismiss();
180 209
       }
@@ -182,14 +211,17 @@ class _PrintPageState extends BaseLifecycleState<PrintPage> {
182 211
         scanDeviceState = deviceState ?? "";
183 212
       });
184 213
     });
214
+
215
+    initLocation();
185 216
   }
186 217
 
187 218
   @override
188 219
   void onDestroy() {
189
-    SystemChrome.setPreferredOrientations([
190
-      DeviceOrientation.portraitUp,
191
-      DeviceOrientation.portraitDown,
192
-    ]);
220
+    LocationUtils.stopLocation();
221
+    LocationUtils.destroy();
222
+    locationListener?.cancel();
223
+    onDeviceStateStreamListener?.cancel();
224
+    onReceiveDataStreamListener?.cancel();
193 225
   }
194 226
 
195 227
   @override

+ 19 - 1
lib/service/print_service.dart

@@ -1,7 +1,8 @@
1 1
 
2 2
 
3 3
 import 'dart:ffi';
4
-
4
+import 'dart:io';
5
+import 'package:device_info_plus/device_info_plus.dart';
5 6
 import 'package:lszlgl/utils/permission_utils.dart';
6 7
 import 'package:permission_handler/permission_handler.dart';
7 8
 
@@ -13,9 +14,26 @@ import 'package:flutter/services.dart';
13 14
 class PrintService {
14 15
   PrintService._();
15 16
 
17
+  static final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
18
+
16 19
   static List<BlueDeviceInfo> connectedDeviceList = [];
17 20
   static List<String> connectedDeviceMacList = [];
18 21
 
22
+  static AndroidDeviceInfo? deviceInfo;
23
+
24
+  static Future<AndroidDeviceInfo?> getDeviceInfo() async {
25
+    if (Platform.isIOS) {
26
+
27
+    } else if(Platform.isAndroid) {
28
+      if(deviceInfo != null) {
29
+        deviceInfo;
30
+      }
31
+      AndroidDeviceInfo androidInfo = await deviceInfoPlugin.androidInfo;
32
+      deviceInfo = androidInfo;
33
+      return deviceInfo;
34
+    }
35
+  }
36
+
19 37
   //是否打开蓝牙
20 38
   static Future<bool> isBleOpen() async {
21 39
     return await BluetoothPlugin.instance.isBleOpen();