rabin 5 years ago
parent
commit
e1e59c8407
3 changed files with 20 additions and 7 deletions
  1. 0 1
      database/data.php
  2. 18 6
      lib/Cron.php
  3. 2 0
      lib/Manage.php

+ 0 - 1
database/data.php

@@ -16,7 +16,6 @@ return array
 	# 显示给用户看的名称
 	'lang' => '数据统计',
 	'order' => 1,
-	'check' => 'key',
 	# 数据结构
 	'struct' => array
 	(

+ 18 - 6
lib/Cron.php

@@ -14,36 +14,48 @@ class Cron extends Core
 		$day[0] = date('Y-m-d-H');
 		$day[1] = date('Y-m-d-H', strtotime("-1 hour"));
 		if (isset($config['project'])) {
+			$log = Dever::config('base', 'project')->log;
 			foreach ($config['project'] as $k => $v) {
 				foreach ($day as $i => $j) {
 					$data = $this->getDataByProject($j, $v['id'], $v['key']);
-					$this->write($data);
+					$this->write($data, $log);
 				}
 			}
 		}
 		return 'ok';
 	}
 
-	private function write($data)
+	private function write($data, $log)
 	{
 		//$data[0]写入到data表中,data[1]写入到es中
 		$source = $data[0];
+		$desc = $data[1];
 		$time = explode('-', $source['time']);
 		$update['project_id'] = $source['project_id'];
 		$update['time'] = Dever::maketime($time[0] . '-' . $time[1] . '-' . $time[2] . ' ' . $time[3] . ':00:00');
 		$info = Dever::db('log/data')->one($update);
 		$update['pv'] = $source['pv'] ? $source['pv'] : 0;
 		$update['uv'] = $source['uv'] ? $source['uv'] : 0;
+		$update['year'] = $time[0];
+		$update['month'] = $time[1];
+		$update['day'] = $time[2];
+		$update['hour'] = $time[3];
 		if (!$info) {
-			$update['year'] = $time[0];
-			$update['month'] = $time[1];
-			$update['day'] = $time[2];
-			$update['hour'] = $time[3];
 			Dever::db('log/data')->insert($update);
 		} else {
 			$update['where_id'] = $info['id'];
 			Dever::db('log/data')->update($update);
 		}
+
+		# desc写入到elk中?
+
+		# 如果有其他的系统,则进行处理
+		if (isset($log['cron']) && $log['cron']) {
+			$data[2] = $update;
+			foreach ($log['cron'] as $k => $v) {
+				Dever::load($v, $data);
+			}
+		}
 	}
 
 	private function getDataByProject($day, $id, $key)

+ 2 - 0
lib/Manage.php

@@ -16,6 +16,8 @@ class Manage extends Core
         } else {
             $this->addColOne($col);
         }
+
+        $this->create();
     }
 
     private function addColOne($col)