diff --git a/app/home/controller/Api.php b/app/home/controller/Api.php index bba9c30..aa57571 100644 --- a/app/home/controller/Api.php +++ b/app/home/controller/Api.php @@ -133,7 +133,28 @@ class api extends BaseController $data_first = Db::name('AdminLog')->field('create_time')->whereBetween('create_time', "$begin_first,$end_first")->select(); $data_second = Db::name('AdminLog')->field('create_time')->whereBetween('create_time', "$begin_second,$end_second")->select(); $data_three = Db::name('AdminLog')->field('create_time')->whereBetween('create_time', "$begin_three,$end_first")->select(); - return to_assign(0, '', ['data_first' => hour_document($data_first), 'data_second' => hour_document($data_second), 'data_three' => date_document($data_three)]); + + //获取员工活跃数据 + $times = strtotime("-30 day"); + $where = []; + $where[] = ['uid','<>',1]; + $where[] = ['create_time', '>', $times]; + $content = Db::name('AdminLog')->field("id,uid,name")->where($where)->select(); + $logs = array(); + foreach ($content as $index => $value) { + $uid = $value['uid']; + if (empty($logs[$uid])) { + $logs[$uid]['count'] = 1; + $logs[$uid]['name'] = $value['name']; + } else { + $logs[$uid]['count'] += 1; + } + } + $counts = array_column($logs, 'count'); + array_multisort($counts, SORT_DESC, $logs); + //攫取前10 + $data_logs = array_slice($logs, 0, 10); + return to_assign(0, '', ['data_first' => hour_document($data_first), 'data_second' => hour_document($data_second), 'data_three' => date_document($data_three),'data_logs' => $data_logs]); } //修改个人信息 diff --git a/app/home/view/index/main.html b/app/home/view/index/main.html index e43c0c6..ae1b2b3 100644 --- a/app/home/view/index/main.html +++ b/app/home/view/index/main.html @@ -285,6 +285,12 @@ +