diff --git a/Application/Admin/Controller/StatController.class.php b/Application/Admin/Controller/StatController.class.php index 56b3dea74..f8bba8cbb 100644 --- a/Application/Admin/Controller/StatController.class.php +++ b/Application/Admin/Controller/StatController.class.php @@ -1512,17 +1512,21 @@ class StatController extends ThinkController $unique_code = []; foreach($modelData as $key => $value) { $resolveData = json_decode($value['model'],true); +// dump($resolveData); foreach($resolveData as $k => $v) { - if(!isset($modelNew[$v['model']])) { + + if (!isset($modelNew[$v['model']][$v['version']])) { $modelNew[$v['model']][$v['version']] = 1; - array_push($unique_code,$v['unique_code']); - } else if(!in_array($v['unique_code'],$unique_code)){ + $unique_code[$v['unique_code']] = 1; + } else if(!$unique_code[$v['unique_code']]){ $modelNew[$v['model']][$v['version']]++; - array_push($unique_code,$v['unique_code']); + $unique_code[$v['unique_code']] = 1; +// array_push($unique_code,$v['unique_code']); } } } + $unique_code = []; $modelNewData = []; $modelKey = 0; @@ -1536,7 +1540,12 @@ class StatController extends ThinkController $modelKey++; } + $last_names = array_column($modelNewData,'count'); + array_multisort($last_names,SORT_DESC,$modelNewData); +// dump($modelNewData); +// die(); // $model = $device->model(['create_time'=>['between',[$starttime,$endtime]]]); +// dump($model);die(); $model = $modelNewData; foreach($datelist as $v) { diff --git a/Data/update.sql b/Data/update.sql index 381714bb4..a0eb6d8c2 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -259,5 +259,28 @@ ADD COLUMN `bind_coin_count` decimal(10,2) NULL DEFAULT 0.00 COMMENT '绑币消 ALTER TABLE `tab_spend_user_count` ADD COLUMN `bind_coin_count` decimal(10,2) NULL DEFAULT 0.00 COMMENT '绑定币消耗' AFTER `balance_coin_count`; +-- 2019-11-20 zyx +DROP TABLE IF EXISTS `tab_device_statistics`; +CREATE TABLE `tab_device_statistics` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `time` int(11) NOT NULL DEFAULT 0 COMMENT '日期时间戳', + `new_device` int(11) NOT NULL DEFAULT 0 COMMENT '当日新增设备', + `active_device` int(11) NOT NULL DEFAULT 0 COMMENT '当日活跃设备', + `today_new_device` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL COMMENT '当日新增设备按小时划分的json字符串', + `today_active_device` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL COMMENT '当日活跃设备按小时划分的json字符串', + `today_model_device` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL COMMENT '当日启动机型(机型,系统,数量)', + `model` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL COMMENT '当日启动设备', + `version` int(11) NOT NULL DEFAULT 1 COMMENT '机型', + `duration7` int(255) NOT NULL DEFAULT 0 COMMENT '七天的平均使用时间', + PRIMARY KEY (`id`) USING BTREE, + INDEX `time`(`time`) USING BTREE +) ENGINE = MyISAM AUTO_INCREMENT = 163 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Dynamic; + +SET FOREIGN_KEY_CHECKS = 1; +ALTER TABLE `platform`.`tab_device_record` +ADD INDEX `create_time`(`create_time`) USING BTREE, +ADD INDEX `unique_code`(`unique_code`) USING BTREE, +ADD INDEX `idx_unique_version`(`version`, `unique_code`) USING BTREE, +ADD INDEX `version`(`version`) USING BTREE; UPDATE `platform_new`.`tab_quick_menu` SET `url` = '/index.php?s=/Home/TestResource/index.html' WHERE `id` = 11 UPDATE `platform_new`.`tab_quick_menu` SET `url` = '/index.php?s=/Home/TestResource/lists.html' WHERE `id` = 12 \ No newline at end of file