From 74adf3a72663f151dc2c1b87ecb4ea4b0e080a50 Mon Sep 17 00:00:00 2001
From: colly_wyx <wangyixiong_007@163.com>
Date: Fri, 27 Apr 2018 16:21:52 +0800
Subject: [PATCH] 优化
---
Yfs/Domain/Data.php | 24 +++++++++++++++++++-----
1 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/Yfs/Domain/Data.php b/Yfs/Domain/Data.php
index b70b495..8237215 100644
--- a/Yfs/Domain/Data.php
+++ b/Yfs/Domain/Data.php
@@ -24,7 +24,8 @@
$arr['lat'] = $data['lat'];
$arr['address'] = $data['address'];
foreach ($data['data'] as $value) {
- $arr['value'] = $value['value'];
+
+ $arr['value'] = (float)$value['value'];
$arr['create_time'] = $value['time'];
$arr['date'] = date('Y-m-d', strtotime($value['time']));
if($value['type'] == 0){
@@ -34,11 +35,24 @@
}
}
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();
- if(!in_arrar($task_arr)){
+ $task_date = $this->task_model->get(array('date' => $arr['date']));
+ if(!$task_date){
$task_arr['date'] = $arr['date'];
- $this->task_model->add($arr);
+ $this->task_model->add($task_arr);
}
}
@@ -55,7 +69,7 @@
* ������������������������
* @return [type] [description]
*/
- public function originalUpload(){
+ public function originalUpload($data){
$arr = array();
$arr['data'] = $data['data'];
$arr['time'] = $data['time'];
--
Gitblit v1.8.0