rabin 5 tahun lalu
induk
melakukan
9d1a8b372e
2 mengubah file dengan 109 tambahan dan 26 penghapusan
  1. 91 25
      database/data.php
  2. 18 1
      lib/Cron.php

+ 91 - 25
database/data.php

@@ -1,5 +1,14 @@
 <?php
-
+$project = function()
+{
+    $array = array();
+    $info = Dever::db('log/project')->state();
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
 return array
 (
 	# 表名
@@ -20,30 +29,95 @@ return array
 			'match' 	=> 'is_numeric',
 			//'search'	=> 'order',
 			'order'		=> 'desc',
-			'list'		=> true,
+			//'list'		=> true,
 		),
 		
-		'name'		=> array
+		'project_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '项目',
+            'default'   => '1',
+            'desc'      => '项目',
+            'match'     => 'is_numeric',
+            'option'    => $project,
+            //'update'    => 'select',
+            'search'    => 'select',
+            'list'        => true,
+        ),
+
+        'year'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '时间',
+			'default' 	=> '',
+			'desc' 		=> '年',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			'list'        => '"{year}年{month}月{day}日{hour}时"',
+		),
+
+		'month'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '月',
+			'default' 	=> '',
+			'desc' 		=> '月',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+		),
+
+		'day'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '日',
+			'default' 	=> '',
+			'desc' 		=> '日',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+		),
+
+		'hour'		=> array
 		(
-			'type' 		=> 'varchar-60',
-			'name' 		=> '项目名称',
+			'type' 		=> 'int-11',
+			'name' 		=> '小时',
+			'default' 	=> '',
+			'desc' 		=> '小时',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+		),
+
+		'time'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '时间',
+			'default' 	=> '',
+			'desc' 		=> '时间',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'time',
+			'update'	=> 'text',
+		),
+
+		'pv'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'PV',
 			'default' 	=> '',
-			'desc' 		=> '请输入项目名称',
-			'match' 	=> 'is_string',
+			'desc' 		=> 'PV',
+			'match' 	=> 'is_numeric',
 			'update'	=> 'text',
-			'search'	=> 'fulltext',
+			'search'	=> 'order',
 			'list'		=> true,
 		),
 
-		'key'		=> array
+		'uv'		=> array
 		(
-			'type' 		=> 'varchar-60',
-			'name' 		=> '项目标识',
+			'type' 		=> 'int-11',
+			'name' 		=> 'UV',
 			'default' 	=> '',
-			'desc' 		=> '请输入项目标识',
-			'match' 	=> 'is_string',
+			'desc' 		=> 'UV',
+			'match' 	=> 'is_numeric',
 			'update'	=> 'text',
-			'search'	=> 'fulltext',
+			'search'	=> 'order',
 			'list'		=> true,
 		),
 
@@ -70,17 +144,9 @@ return array
 	
 	'manage' => array
 	(
-
-	),
-
-	# 默认值
-	'default' => array
-	(
-		'col' => 'name,`key`,state,cdate',
-		'value' => array
-		(
-			'"默认项目","default",1,' . time(),
-		),
+		'delete' => false,
+		'edit' => false,
+		'insert' => false,
 	),
 	
 	# request 请求接口定义

+ 18 - 1
lib/Cron.php

@@ -21,12 +21,29 @@ class Cron extends Core
 				}
 			}
 		}
+		return 'ok';
 	}
 
 	private function write($data)
 	{
 		//$data[0]写入到data表中,data[1]写入到es中
-		
+		$source = $data[0];
+		$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'];
+		$update['uv'] = $source['uv'];
+		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);
+		}
 	}
 
 	private function getDataByProject($day, $id, $key)