From d3534714ed8f07f19e0a648ab2d07c73d0bed156 Mon Sep 17 00:00:00 2001 From: colly_wyx <wangyixiong_007@163.com> Date: Wed, 09 May 2018 16:03:12 +0800 Subject: [PATCH] 调整存入值类型 --- Yfs/Domain/Data.php | 76 ++++++++++++++++++++++++++++++++++++- 1 files changed, 73 insertions(+), 3 deletions(-) diff --git a/Yfs/Domain/Data.php b/Yfs/Domain/Data.php index c5851ec..9ed9c3c 100644 --- a/Yfs/Domain/Data.php +++ b/Yfs/Domain/Data.php @@ -7,6 +7,10 @@ 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(); + $this->task_model = new Model_Task(); + $this->data_original_model = new Model_DataOriginal(); } /** @@ -19,10 +23,40 @@ $arr['lon'] = $data['lon']; $arr['lat'] = $data['lat']; $arr['address'] = $data['address']; - foreach ($data['data'] as $value) { - $arr['value'] = $value['value']; + foreach ($data['data'] as $value) { + + $arr['value'] = (float)$value['value']; $arr['create_time'] = $value['time']; - $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){ + + $arr['hour'] = (int)date('H', strtotime($value['time'])); + $hourly = $this->hourly_model->get(array('hour' => $arr['hour'], 'date' => $arr['date'], 'user_id' => $arr['user_id'])); + + if($hourly){ + $_id = $hourly['_id']; + //������������������ + $hourly = $arr; + $this->hourly_model->update($hourly, array('_id' => $_id)); + } + else{ + $this->hourly_model->add($arr); + } + $task_arr = array(); + $task_date = $this->task_model->get(array('date' => $arr['date'], 'user_id' => $arr['user_id'])); + if(!$task_date){ + $task_arr['date'] = $arr['date']; + $task_arr['user_id'] = $arr['user_id']; + $this->task_model->add($task_arr); + } + + } if(isset($arr['_id'])) unset($arr['_id']); } @@ -32,6 +66,42 @@ } + /** + * ������������������������ + * @return [type] [description] + */ + public function originalUpload($param){ + $arr = array(); + if(!empty($param->data)){ + $data = $param->data; + } + else{ + $data = $param->data_1; + } + + $arr['data'] = $data; + $arr['time'] = $param->time; + $arr['user_id'] = $param->user_id; + $arr['create_time'] = date('Y-m-d H:i:s'); + if($this->data_original_model->add($arr)) + return true; + else + return false; + } + + + 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)); + //} + } -- Gitblit v1.8.0