wzh 5 năm trước cách đây
mục cha
commit
d5d2f41cf3
1 tập tin đã thay đổi với 1 bổ sung91 xóa
  1. 1 91
      api/application/controllers/Project.php

+ 1 - 91
api/application/controllers/Project.php

@@ -562,99 +562,9 @@ class Project extends Base_Controller {
                     $location_ch = $res1['chinese_name'];
                     $location_en = $res1['english_name'];
                 }
-                $project_weather = $this->db->query('select * from project_weather where projectId = '.$project_id)->row_array();
-                if (empty($project_weather) || time() - strtotime($project_weather['updatetime']) > 3600) {
-                    $url = 'https://way.jd.com/he/freeweather?city='.$res1['chinese_name'].'&appkey=a44fc7f907194098c69bb8e90003bca6';
-                    $resData = request_post($url);
-                    $arr = json_decode($resData,true);
-                    if ($arr['code'] == 10000) {
-                        if ($arr['result']['HeWeather5'][0]['status'] == 'unknown location') {
-                            $url = 'https://free-api.heweather.net/s6/weather/forecast?location='.$res1['longitude'].','.$res1['latitude'].'&key=63dbc994630941fab269ad3c3af4d5d2';
-                            // $url = 'https://way.jd.com/he/freeweather?city='.$res2['chinese_name'].'&appkey=a44fc7f907194098c69bb8e90003bca6';
-                            $resData = request_post($url);
-                            $arr = json_decode($resData,true);
-                            // var_dump($url);
-                            if ($arr['HeWeather6'][0]['status'] == 'ok') {
-                                $now = $arr['HeWeather6'][0]['daily_forecast'][0];
-                                $daily_forecast = $arr['HeWeather6'][0]['daily_forecast'];
-                                $weatherList = array();
-                                $weatherList[] = ['weatherType'=>$now['cond_txt_d'],'code'=>$now['cond_code_d'],'tmp'=>intval(($now['tmp_min'] + $now['tmp_max'])/2),'sr'=>$now['sr'],'ss'=>$now['ss'],'dateStr'=>date('D',strtotime($now['date'])),'date'=>date('m-d',strtotime($now['date']))];
-                                for ($i=1; $i < count($daily_forecast); $i++) { 
-                                    $weatherList[] = ['weatherType'=>$daily_forecast[$i]['cond_txt_d'],'code'=>$daily_forecast[$i]['cond_code_d'],'maxTmp'=>$daily_forecast[$i]['tmp_max'],'minTmp'=>$daily_forecast[$i]['tmp_min'],'sr'=>$daily_forecast[$i]['sr'],'ss'=>$daily_forecast[$i]['ss'],'dateStr'=>date('D',strtotime($daily_forecast[$i]['date'])),'date'=>date('m-d',strtotime($daily_forecast[$i]['date']))];
-                                }
-                                $data['weatherList'] = $weatherList;
-                                if (empty($project_weather)) {
-                                    $sql = "insert into project_weather (weatherInfo,projectId,updatetime) values('".json_encode($weatherList)."',".$project_id.",'".date('Y-m-d H:i:s',time())."')";
-                                    $this->db->query($sql);
-                                }else{
-                                    $sql = "update project_weather set weatherInfo = '".json_encode($weatherList)."',updatetime = '".date('Y-m-d H:i:s',time())."' where projectId = ".$project_id;
-                                    $this->db->query($sql);
-                                }
-                            }else{
-                                $data['weatherList'] = [];
-                            }
-                            // $url = 'https://way.jd.com/he/freeweather?city='.$res2['chinese_name'].'&appkey=a44fc7f907194098c69bb8e90003bca6';
-                            // $resData = request_post($url);
-                            // $arr = json_decode($resData,true);
-                        }else{
-                            if ($arr['result']['HeWeather5'][0]['status'] == 'ok') {
-                                $now = $arr['result']['HeWeather5'][0]['now'];
-                                $daily_forecast = $arr['result']['HeWeather5'][0]['daily_forecast'];
-                                $weatherList = array();
-                                $weatherList[] = ['weatherType'=>$now['cond']['txt'],'code'=>$now['cond']['code'],'tmp'=>$now['tmp'],'sr'=>$daily_forecast[0]['astro']['sr'],'ss'=>$daily_forecast[0]['astro']['ss'],'dateStr'=>date('D',strtotime($daily_forecast[0]['date'])),'date'=>date('m-d',strtotime($daily_forecast[0]['date']))];
-                                for ($i=1; $i < count($daily_forecast); $i++) { 
-                                    $weatherList[] = ['weatherType'=>$daily_forecast[$i]['cond']['txt_d'],'code'=>$daily_forecast[$i]['cond']['code_d'],'maxTmp'=>$daily_forecast[$i]['tmp']['max'],'minTmp'=>$daily_forecast[$i]['tmp']['min'],'sr'=>$daily_forecast[$i]['astro']['sr'],'ss'=>$daily_forecast[$i]['astro']['ss'],'dateStr'=>date('D',strtotime($daily_forecast[$i]['date'])),'date'=>date('m-d',strtotime($daily_forecast[$i]['date']))];
-                                }
-                                $data['weatherList'] = $weatherList;
-                                if (empty($project_weather)) {
-                                    $sql = "insert into project_weather (weatherInfo,projectId,updatetime) values('".json_encode($weatherList)."',".$project_id.",'".date('Y-m-d H:i:s',time())."')";
-                                    $this->db->query($sql);
-                                }else{
-                                    $sql = "update project_weather set weatherInfo = '".json_encode($weatherList)."',updatetime = '".date('Y-m-d H:i:s',time())."' where projectId = ".$project_id;
-                                    $this->db->query($sql);
-                                }
-                            }else{
-                                $data['weatherList'] = [];
-                            }
-                        }
-                    }else{
-                        $data['weatherList'] = [];
-                    }
-                }else{
-                    $data['weatherList'] = json_decode($project_weather['weatherInfo'],true);
-                    // var_dump($data['weatherList']);die;
-                }
-            }
-            // $data['company'] = $this->Company_model->get_data_by_id($data['company_id'], 'name');
-
-            if (empty($version)) {
-                $data['location'] = $location_ch;
-                $res = $this->Project_model->get_timezone_info(array('id'=>$data['timezone']),'name');
-                foreach ($data['weatherList'] as $key => $value) {
-                    $data['weatherList'][$key]['weatherType'] = weather_translate_cn($data['weatherList'][$key]['code']);
-                    $data['weatherList'][$key]['dateStr'] = date_translate_cn($data['weatherList'][$key]['dateStr']);
-                }
-            }else{
-                $data['location'] = $location_en;
-                foreach ($data['weatherList'] as $key => $value) {
-                    $data['weatherList'][$key]['weatherType'] = weather_translate_en($data['weatherList'][$key]['code']);
-                }
-                $res = $this->Project_model->get_timezone_info(array('id'=>$data['timezone']),'enname as name');
             }
-            $data['timezone_name'] = $res['name'];
 
-            $data['patrol_time'] = strval($this->getLeftTimeByProject($project_id));
-
-            // 获取项目下的网络列表
-            $data['network_list'] = $this->Network_model->get_list_by_filter(array('projectid'=>$project_id));
-            $temp = array();
-            foreach ($data['network_list'] as $key => $value) {
-                if (isset($value['gatewaytype']) && $value['gatewaytype'] == 'direct') {
-                    continue;
-                }
-                $temp[] = $value;
-            }
-            $data['network_list'] = $temp;
+            $data['location'] = $location_en;
 
             exit(json_result('0000', $this->response['0000'], $data));
         }