From 8ef7650be0363908b675827e732ec52fbb996900 Mon Sep 17 00:00:00 2001 From: colly_wyx <wangyixiong_007@163.com> Date: Fri, 18 May 2018 09:22:20 +0800 Subject: [PATCH] 修改名称 --- Yfs/Api/Data.php | 96 +++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 82 insertions(+), 14 deletions(-) diff --git a/Yfs/Api/Data.php b/Yfs/Api/Data.php index 3ccdf4e..a53a7bb 100644 --- a/Yfs/Api/Data.php +++ b/Yfs/Api/Data.php @@ -8,7 +8,19 @@ public function getRules() { return array( 'upload' => array( - 'data' => array('name' => 'data', 'type' => 'string' ,'require' => true, 'desc' => '������������'), + 'data' => array('name' => 'data', 'type' => 'string' ,'require' => false, 'source' => 'post', 'desc' => '������������'), + 'data_1' => array('name' => 'data_1', 'type' => 'array' ,'require' => false, 'source' => 'post', 'desc' => '������������'), + ), + 'originalUpload' => array( + 'data' => array('name' => 'data', 'type' => 'string' ,'require' => false, 'source' => 'post', 'desc' => '������������'), + 'data_1' => array('name' => 'data_1', 'type' => 'array' ,'require' => false, 'source' => 'post', 'desc' => '������������'), + 'user_id' => array( + 'name' => 'user_id', 'type' => 'string', 'require' => true, 'desc' => '������id' + ), + 'time' => array( + 'name' => 'time', 'type' => 'string', 'require' => true, 'desc' => '������' + ), + ), 'getUserDataList' => array( 'user_id' => array( @@ -34,16 +46,41 @@ public function upload(){ $rs = array('code' => 0, 'msg' => ''); $data_service = new Domain_Data(); - $data = json_decode($this->data, true); + + if(!empty($this->data)){ + $data = json_decode($this->data,true); + } + else{ + $data = $this->data_1; + } + //$data = json_decode($this->data, true); //print_r(count($data['data']));die(); - if(json_last_error() == JSON_ERROR_NONE){ + //if(json_last_error() == JSON_ERROR_NONE){ + + if(count($data) > 0){ + $data_service->upload($data); $rs['msg'] = "������������������"; } - else{ - $rs['code'] = 1; - $rs['msg'] = "json������������"; - } + // } + // else{ + // $rs['code'] = 1; + // $rs['msg'] = "json������������"; + // } + return $rs; + } + + /** + * ������������������ + * @return [type] [description] + */ + public function originalUpload(){ + $rs = array('code' => 0, 'msg' => ''); + $data_service = new Domain_Data(); + if($data_service->originalUpload($this)) + $rs['msg'] = "������������������������"; + else + $rs['msg'] = "������������������������"; return $rs; } @@ -56,19 +93,50 @@ */ public function getUserDataList(){ $rs = array('code' => 0, 'msg' => '', 'info' => array()); - $data_service = new Domain_Data(); - $data_list = $data_service->getUserDataList($this->user_id, $this->start_time, $this->end_time); - if($data_list){ - $rs['msg'] = '������������������'; - $rs['info'] = $data_list; + $data_daily_service = new Domain_DataDaily(); + if($this->start_time == $this->end_time || $data_daily_service->checkTime($this->start_time, $this->end_time)){ + $result = $data_daily_service->getUserDataList($this->user_id, $this->start_time, $this->end_time); + if($result){ + $res_avg = $data_daily_service->getUserDataAvg($this->user_id, $this->start_time, $this->end_time); + if($res_avg < 0.16){ + + $res_status = '������������'; + } + elseif($res_avg >= 0.16 && $res_avg < 0.8){ + $res_status = '������������'; + } + elseif($res_avg >= 0.8 && $res_avg < 2){ + $res_status = '������������'; + } + else{ + $res_status = '������������'; + } + $rs['msg'] = '������������������'; + $rs['info'] = array('data' => $result, 'avg' => $res_avg, 'status' => $res_status); + } + else{ + $rs['msg'] = '������������'; + $rs['info'] = array('data' => array(), 'avg' => 0, 'status' => '������'); + } } - else{print_r($data_lsit); + else{ $rs['code'] = 1; - $rs['msg'] = '������������������'; + $rs['msg'] = '���������������������������������������������������������������������������7���'; } return $rs; } + //public function updateTime(){ + // $data_service = new Domain_Data(); + // $datas = $data_service->getList(); + // foreach ($datas as $value) { + // $data['_id'] = $value['_id']; + // $data['date'] = date('Y-m-d', strtotime($value['create_time'])); + // $data_service->updateTime($data); + // } + + // } + -- Gitblit v1.8.0