Commit 95016b34 authored by 李增强's avatar 李增强

m

parent bec1ce93
...@@ -8,6 +8,7 @@ import 'package:crypto/crypto.dart' as crypto; ...@@ -8,6 +8,7 @@ import 'package:crypto/crypto.dart' as crypto;
class QMTJ { class QMTJ {
static DB _db; static DB _db;
static Http _http;
static String _appStartUpId; static String _appStartUpId;
static Future<bool> ready; static Future<bool> ready;
...@@ -19,16 +20,12 @@ class QMTJ { ...@@ -19,16 +20,12 @@ class QMTJ {
} }
static init() { static init() {
_http = Http(scheme: "http", host: "8.135.58.206", port: 8802);
_appStartUpId = _md5(_getDateNow().toString()); _appStartUpId = _md5(_getDateNow().toString());
ready = new Future<bool>(() async { ready = new Future<bool>(() async {
_db = new DB(); _db = new DB();
await _db.init(); await _db.init();
List<Map> list = await _db.db.query("page_tj"); uploadPageTj();
print("+++++++++++++++++++++++++++++${list.length}");
List<String> ids = [list[0]['id'],list[1]['id'],list[2]['id']];
List<Map> list2 = await _db.db
.rawQuery("select * FROM page_tj where id in('${ids.join("','")}')");
print("++++++++++++$ids+++++++++++++++++${list2.length}+++++${"select * FROM page_tj where id in(\"${ids.join('","')}\")"}");
return true; return true;
}); });
} }
...@@ -185,6 +182,42 @@ class QMTJ { ...@@ -185,6 +182,42 @@ class QMTJ {
await _db.db.insert("exposure_tj", map); await _db.db.insert("exposure_tj", map);
} }
// 上传页面统计
static void uploadPageTj() async {
List<Map> list = await _db.db.query("page_tj", limit: 100, offset: 0);
if (list.length == 0) {
return;
}
list = list.map((e) {
var item = {
"app_version": '0.0.1',
"app_channel": "APP渠道",
"devices_id": '3A26610FFE43D5838DDE7A40BA2E3E2C',
"inter": '4G',
"source": e['source'],
"page_id": e['page_id'],
"last_page_id": e['last_page_id'],
"come_time": e['appear_time'],
"out_time": e['disappear_time'],
"extras": json.decode(e['extras'])
};
Map project = {
"event_name": "page_scan",
"app": "xx",
"event_info": item
};
return project;
}).toList();
_http.post("/collection", {"project": json.encode(list)}).then((value) {
if (isDebug) {
log("upload_page_tj", value);
}
});
}
/// 获取当前时间戳,单位:秒 /// 获取当前时间戳,单位:秒
static int _getDateNow() { static int _getDateNow() {
int now = (DateTime.now().millisecondsSinceEpoch / 1000).floor(); int now = (DateTime.now().millisecondsSinceEpoch / 1000).floor();
......
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