From 0c4b798032fd08f562570201c0ae6ba1d040cfba Mon Sep 17 00:00:00 2001
From: colly_wyx <wangyixiong_007@163.com>
Date: Mon, 23 Apr 2018 16:01:41 +0800
Subject: [PATCH] 添加测试日志

---
 Yfs/Domain/Data.php |   52 ++++++++++++++++++----------------------------------
 1 files changed, 18 insertions(+), 34 deletions(-)

diff --git a/Yfs/Domain/Data.php b/Yfs/Domain/Data.php
index 8a447f1..0a76dd5 100644
--- a/Yfs/Domain/Data.php
+++ b/Yfs/Domain/Data.php
@@ -7,6 +7,8 @@
     public function __construct(){
         //DI()->redis = new Redis_Lite(DI()->config->get('app.redis.servers'));
        $this->model = new Model_Data();
+       $this->hourly_model = new Model_DataHourly();
+       $this->warn_model = new Model_DataWarn();
     }
 
     /**
@@ -19,11 +21,19 @@
         $arr['lon'] = $data['lon'];
         $arr['lat'] = $data['lat'];
         $arr['address'] = $data['address'];
-        foreach ($data['data'] as $value) { 
+        foreach ($data['data'] as $value) {
             $arr['value'] = $value['value'];
             $arr['create_time'] = $value['time'];
-            $arr['date'] = date('Y-m-d', strtotime($value));
-            $this->model->add($arr);
+            $arr['date'] = date('Y-m-d', strtotime($value['time']));
+            if($value['type'] == 0){
+                $this->model->add($arr);
+                if($value['is_warn'] == 1){
+                    $this->warn_model->add($arr);
+                }
+            }
+            elseif($value['type'] == 1){
+                $this->hourly_model->add($arr);
+            }
             if(isset($arr['_id']))
                 unset($arr['_id']);
         }
@@ -37,39 +47,13 @@
         return $this->model->getList();
     }
 
-    /**
-     * ���������������������������������������
-     * @param  [type] $user_id    [description]
-     * @param  [type] $start_time [description]
-     * @param  [type] $end_time   [description]
-     * @return [type]             [description]
-     */
-    public function getUserDataList($user_id, $start_time, $end_time){
-        $result = $this->model->aggregate(
-            array(
-                array(
-                   '$match' => array('create_time' => array('$gte' => $start_time.' 00:00:00', '$lte' => $end_time.' 23:59:59'), 'user_id' => $user_id)
-                ),
-                array(
-                    '$group' => array('_id' => '$date', 'day' => array('$avg' => '$value'))
-                ),
-                array(
-                    '$project' => array('_id' => 0, 'date'=> '$_id', 'day' => 1)
-                )
-            )
-        );
-        
-        print_r($result);
-        die();
-        return $this->model->getList(array('user_id' => $user_id, 'create_time' => array('$gte' => $start_time, '$lte' => $end_time)));
-    }
 
 
-    public function updateTime($data){
-        $id = $data['_id'];
-        unset($data['_id']);
-        return $this->model->update($data, array('_id' => $id));
-    }
+    //public function updateTime($data){
+    //    $id = $data['_id'];
+   //     unset($data['_id']);
+   //     return $this->model->update($data, array('_id' => $id));
+    //}
 
     
 

--
Gitblit v1.8.0