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

m

parent 7d22ad6f
...@@ -29,11 +29,11 @@ class QMTJ { ...@@ -29,11 +29,11 @@ class QMTJ {
_tap = Tap(_db); _tap = Tap(_db);
_exposure = Exposure(_db); _exposure = Exposure(_db);
_db.init(); _db.init();
Future.delayed(Duration(seconds: 5)).then((value) { Future.delayed(Duration(seconds: 5)).then((value) async {
_app.upload(); await _app.upload();
_page.upload(); await _page.upload();
_tap.upload(); await _tap.upload();
_exposure.upload(); await _exposure.upload();
}); });
} }
......
...@@ -6,6 +6,7 @@ import '../../src/utils.dart'; ...@@ -6,6 +6,7 @@ import '../../src/utils.dart';
class App { class App {
DB _db; DB _db;
String _appStartUpId; String _appStartUpId;
int startUpTime = Utils.getDateNow();
App(DB db) { App(DB db) {
_db = db; _db = db;
...@@ -17,7 +18,7 @@ class App { ...@@ -17,7 +18,7 @@ class App {
// APP 启动生成本次启动ID // APP 启动生成本次启动ID
if (_appStartUpId == null) { if (_appStartUpId == null) {
type = 1; type = 1;
_appStartUpId = Utils.md5(Utils.getDateNow().toString()); _appStartUpId = Utils.md5(startUpTime.toString());
} }
int disappearTime = 0; int disappearTime = 0;
int appearTime = Utils.getDateNow(); int appearTime = Utils.getDateNow();
...@@ -49,9 +50,9 @@ class App { ...@@ -49,9 +50,9 @@ class App {
} }
// 上传数据至接口 // 上传数据至接口
void upload() async { Future<void> upload() async {
await _db.ready; 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) { if (list.length == 0) {
return; return;
} }
...@@ -71,7 +72,7 @@ class App { ...@@ -71,7 +72,7 @@ class App {
Utils.log("app upload_result", {"ok": result, "length": list.length}); Utils.log("app upload_result", {"ok": result, "length": list.length});
} }
if (list.length == 100) { if (list.length == 100) {
upload(); await upload();
} }
} }
} }
...@@ -29,7 +29,7 @@ class Exposure { ...@@ -29,7 +29,7 @@ class Exposure {
} }
// 上传数据至接口 // 上传数据至接口
void upload() async { Future<void> upload() async {
await _db.ready; await _db.ready;
List<Map> list = await _db.db.query("exposure_tj", limit: 100, offset: 0); List<Map> list = await _db.db.query("exposure_tj", limit: 100, offset: 0);
if (list.length == 0) { if (list.length == 0) {
...@@ -52,7 +52,10 @@ class Exposure { ...@@ -52,7 +52,10 @@ class Exposure {
"exposure_tj upload_result", {"ok": result, "length": list.length}); "exposure_tj upload_result", {"ok": result, "length": list.length});
} }
if (list.length == 100) { if (list.length == 100) {
upload(); await upload();
} }
} }
} }
...@@ -5,6 +5,7 @@ import '../../src/utils.dart'; ...@@ -5,6 +5,7 @@ import '../../src/utils.dart';
class Page { class Page {
DB _db; DB _db;
int startUpTime = Utils.getDateNow();
Page(DB db) { Page(DB db) {
_db = db; _db = db;
...@@ -57,9 +58,9 @@ class Page { ...@@ -57,9 +58,9 @@ class Page {
} }
// 上传数据至接口 // 上传数据至接口
void upload() async { Future<void> upload() async {
await _db.ready; 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) { if (list.length == 0) {
return; return;
} }
...@@ -79,7 +80,7 @@ class Page { ...@@ -79,7 +80,7 @@ class Page {
Utils.log("page upload_result", {"ok": result, "length": list.length}); Utils.log("page upload_result", {"ok": result, "length": list.length});
} }
if (list.length == 100) { if (list.length == 100) {
upload(); await upload();
} }
} }
} }
...@@ -32,7 +32,7 @@ class Tap { ...@@ -32,7 +32,7 @@ class Tap {
} }
// 上传数据至接口 // 上传数据至接口
void upload() async { Future<void> upload() async {
await _db.ready; await _db.ready;
List<Map> list = await _db.db.query("tap_tj", limit: 100, offset: 0); List<Map> list = await _db.db.query("tap_tj", limit: 100, offset: 0);
if (list.length == 0) { if (list.length == 0) {
...@@ -54,7 +54,7 @@ class Tap { ...@@ -54,7 +54,7 @@ class Tap {
Utils.log("tap_tj upload_result", {"ok": result, "length": list.length}); Utils.log("tap_tj upload_result", {"ok": result, "length": list.length});
} }
if (list.length == 100) { 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