colly_wyx
2018-04-28 d50ec1d43fd3b57305425d38ecc7c84f201e74cf
Yfs/Api/Data.php
@@ -14,6 +14,13 @@
            '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(
@@ -41,7 +48,7 @@
        $data_service = new Domain_Data();
        if(!empty($this->data)){
          $data = $this->data;
          $data = json_decode($this->data,true);
        }
        else{
          $data = $this->data_1;
@@ -70,19 +77,11 @@
    public function originalUpload(){
        $rs = array('code' => 0, 'msg' => '');
        $data_service = new Domain_Data();
        if(!empty($this->data)){
          $data = $this->data;
        }
        else{
          $data = $this->data_1;
        }
        if(count($data) > 0){
            $data_service->originalUpload($data);
            $rs['msg'] = "原始数据上报成功";
        }
        if($data_service->originalUpload($this))
          $rs['msg'] = "原始数据上报成功";
        else
          $rs['msg'] = "原始数据上报失败";
        return $rs;
    }
    /**
@@ -99,17 +98,17 @@
            $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.25){
                    $res_status = '安全';
                if($res_avg < 0.16){
                    $res_status = '绝对安全';
                }
                elseif($res_avg >= 0.25 && $res_avg < 0.8){
                    $res_status = '轻微';
                elseif($res_avg >= 0.16 && $res_avg < 0.8){
                    $res_status = '建议回避';
                }
                elseif($res_avg >= 0.8 && $res_avg < 2){
                    $res_status = '中度';
                    $res_status = '及时闪躲';
                }
                else{
                    $res_status = '严重';
                    $res_status = '紧急撤离';
                }
                $rs['msg'] = '数据获取成功';
                $rs['info'] = array('data' => $result, 'avg' => $res_avg, 'status' => $res_status);