Commit fcae3536 authored by 李增强's avatar 李增强

m

parent 7d22ad6f
......@@ -29,11 +29,11 @@ class QMTJ {
_tap = Tap(_db);
_exposure = Exposure(_db);
_db.init();
Future.delayed(Duration(seconds: 5)).then((value) {
_app.upload();
_page.upload();
_tap.upload();
_exposure.upload();
Future.delayed(Duration(seconds: 5)).then((value) async {
await _app.upload();
await _page.upload();
await _tap.upload();
await _exposure.upload();
});
}
......
......@@ -6,6 +6,7 @@ import '../../src/utils.dart';
class App {
DB _db;
String _appStartUpId;
int startUpTime = Utils.getDateNow();
App(DB db) {
_db = db;
......@@ -17,7 +18,7 @@ class App {
// APP 启动生成本次启动ID
if (_appStartUpId == null) {
type = 1;
_appStartUpId = Utils.md5(Utils.getDateNow().toString());
_appStartUpId = Utils.md5(startUpTime.toString());
}
int disappearTime = 0;
int appearTime = Utils.getDateNow();
......@@ -49,9 +50,9 @@ class App {
}
// 上传数据至接口
void upload() async {
Future<void> upload() async {
await _db.ready;
List<Map> list = await _db.db.query("app_tj", limit: 100, offset: 0);
List<Map> list = await _db.db.query("app_tj", where: "disappear_time < ?",whereArgs: [startUpTime], limit: 100, offset: 0);
if (list.length == 0) {
return;
}
......@@ -71,7 +72,7 @@ class App {
Utils.log("app upload_result", {"ok": result, "length": list.length});
}
if (list.length == 100) {
upload();
await upload();
}
}
}
......@@ -29,7 +29,7 @@ class Exposure {
}
// 上传数据至接口
void upload() async {
Future<void> upload() async {
await _db.ready;
List<Map> list = await _db.db.query("exposure_tj", limit: 100, offset: 0);
if (list.length == 0) {
......@@ -52,7 +52,10 @@ class Exposure {
"exposure_tj upload_result", {"ok": result, "length": list.length});
}
if (list.length == 100) {
upload();
await upload();
}
}
}
......@@ -5,6 +5,7 @@ import '../../src/utils.dart';
class Page {
DB _db;
int startUpTime = Utils.getDateNow();
Page(DB db) {
_db = db;
......@@ -57,9 +58,9 @@ class Page {
}
// 上传数据至接口
void upload() async {
Future<void> upload() async {
await _db.ready;
List<Map> list = await _db.db.query("page_tj", limit: 100, offset: 0);
List<Map> list = await _db.db.query("page_tj", where: 'disappear_time < ?',whereArgs: [startUpTime], limit: 100, offset: 0);
if (list.length == 0) {
return;
}
......@@ -79,7 +80,7 @@ class Page {
Utils.log("page upload_result", {"ok": result, "length": list.length});
}
if (list.length == 100) {
upload();
await upload();
}
}
}
......@@ -32,7 +32,7 @@ class Tap {
}
// 上传数据至接口
void upload() async {
Future<void> upload() async {
await _db.ready;
List<Map> list = await _db.db.query("tap_tj", limit: 100, offset: 0);
if (list.length == 0) {
......@@ -54,7 +54,7 @@ class Tap {
Utils.log("tap_tj upload_result", {"ok": result, "length": list.length});
}
if (list.length == 100) {
upload();
await upload();
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment