DESKTOP-9JTA2JJ\HP 5 years ago
parent
commit
0b2239366e
1 changed files with 27 additions and 9 deletions
  1. 27 9
      api/application/controllers/Home.php

+ 27 - 9
api/application/controllers/Home.php

@@ -689,12 +689,19 @@ class Home extends Base_Controller {
         $where = array();
 
         if ($role != SYSTEM_ADMIN) $where['P.company'] = $company;
+        $where['G3.level'] = 2;
+        $where['G3.pid'] = 92;
         $join = array();
 
-        $join[] = ['table'=>'global_location as G1','cond'=>'G1.id = P.cityid AND G1.level = 4','type'=>'inner'];
-        $join[] = ['table'=>'global_location as G2','cond'=>'G2.id = G1.pid AND G2.level = 3','type'=>'inner'];
-        $join[] = ['table'=>'global_location as G3','cond'=>'G3.id = G2.pid AND G3.level = 2','type'=>'inner'];
-        $list = $this->Project_model->get_list_by_join($where, 'G3.id,G3.english_name as name,sum(P.lampcount) as lampcount',NULL, NULL, $join, NULL, 'G3.id', 'P');
+        $join[] = ['table'=>'global_location as G2','cond'=>'G3.id = G2.pid AND G2.level = 3','type'=>'left'];
+        $join[] = ['table'=>'global_location as G1','cond'=>'G2.id = G1.pid AND G1.level = 4','type'=>'left'];
+        $join[] = ['table'=>'project as P','cond'=>'G1.id = P.cityid AND G1.level = 4','type'=>'left'];
+        
+        // $join[] = ['table'=>'global_location as G3','cond'=>'G3.id = G2.pid AND G3.level = 2','type'=>'left'];
+        $list = $this->Global_location_model->get_list_by_join($where, 'G3.id,G3.english_name as name,sum(P.lampcount) as lampcount',NULL, NULL, $join, NULL, 'G3.id', 'G3');
+        foreach ($list as $key => $value) {
+            $list[$key]['lampcount'] = intval($value['lampcount']);
+        }
         exit(json_result('0000',$this->response['0000'],array('list'=>$list)));
     }
 
@@ -707,11 +714,16 @@ class Home extends Base_Controller {
 
         if (!empty($proId)) $where['G2.pid'] = $proId;
         if ($role != SYSTEM_ADMIN) $where['P.company'] = $company;
+        $where['G2.level'] = 3;
         $join = array();
 
-        $join[] = ['table'=>'global_location as G1','cond'=>'G1.id = P.cityid','type'=>'left'];
-        $join[] = ['table'=>'global_location as G2','cond'=>'G2.id = G1.pid','type'=>'left'];
-        $list = $this->Project_model->get_list_by_join($where, 'G2.id,G2.english_name as name,sum(P.lampcount) as lampcount',NULL, NULL, $join, NULL, 'G2.id', 'P');
+        $join[] = ['table'=>'global_location as G1','cond'=>'G2.id = G1.pid','type'=>'left'];
+        $join[] = ['table'=>'project as P','cond'=>'G1.id = P.cityid AND G1.level = 4','type'=>'left'];
+        // $join[] = ['table'=>'global_location as G2','cond'=>'G2.id = G1.pid','type'=>'left'];
+        $list = $this->Global_location_model->get_list_by_join($where, 'G2.id,G2.english_name as name,sum(P.lampcount) as lampcount',NULL, NULL, $join, NULL, 'G2.id', 'G2');
+        foreach ($list as $key => $value) {
+            $list[$key]['lampcount'] = intval($value['lampcount']);
+        }
         exit(json_result('0000',$this->response['0000'],array('list'=>$list)));
     }
 
@@ -724,10 +736,16 @@ class Home extends Base_Controller {
 
         if (!empty($cityId)) $where['G1.pid'] = $cityId;
         if ($role != SYSTEM_ADMIN) $where['P.company'] = $company;
+        $where['G1.level'] = 4;
         $join = array();
 
-        $join[] = ['table'=>'global_location as G1','cond'=>'G1.id = P.cityid','type'=>'left'];
-        $list = $this->Project_model->get_list_by_join($where, 'G1.id,G1.english_name as name,sum(P.lampcount) as lampcount',NULL, NULL, $join, NULL, 'G1.id', 'P');
+        $join[] = ['table'=>'project as P','cond'=>'G1.id = P.cityid AND G1.level = 4','type'=>'left'];
+        // $join[] = ['table'=>'global_location as G1','cond'=>'G1.id = P.cityid','type'=>'left'];
+
+        $list = $this->Global_location_model->get_list_by_join($where, 'G1.id,G1.english_name as name,sum(P.lampcount) as lampcount',NULL, NULL, $join, NULL, 'G1.id', 'G1');
+        foreach ($list as $key => $value) {
+            $list[$key]['lampcount'] = intval($value['lampcount']);
+        }
         exit(json_result('0000',$this->response['0000'],array('list'=>$list)));
     }
 }