<?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($value['type'] == 0){
|
$this->model->add($arr);
|
if($arr['is_warn'] == 1){
|
$this->warn_model->add($arr);
|
}
|
}
|
elseif($value['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));
|
//}
|
|
|
|
}
|