colly_wyx
2018-04-17 bf600de624ac26b99cecdec37c1f1aef63b09634
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/**
 * 用户业务类
 */
class Domain_Data {
 
    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();
    }
 
    /**
     * 上传数据并保存入redis
     * @return [type] [description]
     */
    public function upload($data){
        $arr = array();
        $arr['user_id'] = $data['userid'];
        $arr['lon'] = $data['lon'];
        $arr['lat'] = $data['lat'];
        $arr['address'] = $data['address'];
        foreach ($data['data'] as $value) {
            $arr['value'] = $value['value'];
            $arr['create_time'] = $value['time'];
            $arr['date'] = date('Y-m-d', strtotime($value['time']));
            if($data['type'] == 0){
                $this->model->add($arr);
                if($arr['is_warn'] == 1){
                    $this->warn_model->add($arr);
                }
            }
            elseif($data['type'] == 1){
                $this->hourly_model->add($arr);
            }
            if(isset($arr['_id']))
                unset($arr['_id']);
        }
        return true;
        //$a = rand(1,100);
        //DI()->redis->set_lPush('test', $a, 'master');
 
    }
 
    public function getList(){
        return $this->model->getList();
    }
 
 
 
    //public function updateTime($data){
    //    $id = $data['_id'];
   //     unset($data['_id']);
   //     return $this->model->update($data, array('_id' => $id));
    //}
 
    
 
}