From 40417edce32320cc8f6f558adf9b8ee8b4ff23c2 Mon Sep 17 00:00:00 2001 From: colly_wyx <wangyixiong_007@163.com> Date: Thu, 26 Apr 2018 16:44:14 +0800 Subject: [PATCH] 调整上传接口 --- Yfs/Domain/Data.php | 38 +++++++++++++++++++++++++++++++++++++- 1 files changed, 37 insertions(+), 1 deletions(-) diff --git a/Yfs/Domain/Data.php b/Yfs/Domain/Data.php index 0a76dd5..6cfa98c 100644 --- a/Yfs/Domain/Data.php +++ b/Yfs/Domain/Data.php @@ -9,6 +9,8 @@ $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(); } /** @@ -22,6 +24,7 @@ $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'])); @@ -32,7 +35,26 @@ } } elseif($value['type'] == 1){ - $this->hourly_model->add($arr); + + $arr['hour'] = 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->hourly_model->get(array('date' => $arr['date'])); + if(!$task_date){ + $task_arr['date'] = $arr['date']; + $this->task_model->add($task_arr); + } + } if(isset($arr['_id'])) unset($arr['_id']); @@ -43,6 +65,20 @@ } + /** + * ������������������������ + * @return [type] [description] + */ + public function originalUpload(){ + $arr = array(); + $arr['data'] = $data['data']; + $arr['time'] = $data['time']; + $arr['create_time'] = date('Y-m-d H:i:s'); + $this->data_original_model->add($arr); + return true; + } + + public function getList(){ return $this->model->getList(); } -- Gitblit v1.8.0