DESKTOP-9JTA2JJ\HP 5 年之前
父节点
当前提交
4692df0840
共有 2 个文件被更改,包括 24 次插入17 次删除
  1. 2 1
      api/application/controllers/Lampcontrol.php
  2. 22 16
      api/application/controllers/Project.php

+ 2 - 1
api/application/controllers/Lampcontrol.php

@@ -56,7 +56,8 @@ class Lampcontrol extends Base_Controller {
                 $filter .= ' AND L.po = '.$company;
                 $filter .= ' AND L.po = '.$company;
             }else {
             }else {
                 // $filter['L.upazilla'] = $company;
                 // $filter['L.upazilla'] = $company;
-                $filter .= ' AND L.upazilla = '.$company;
+                // $filter .= ' AND L.upazilla = '.$company;
+                $filter .= ' AND P.cityid = '.$company;
             }
             }
         }
         }
         // if (!empty($section)) $filter['L.section'] = $section;
         // if (!empty($section)) $filter['L.section'] = $section;

+ 22 - 16
api/application/controllers/Project.php

@@ -45,33 +45,38 @@ class Project extends Base_Controller {
 
 
         $where = array();
         $where = array();
         $where['projectid'] = $project_id;
         $where['projectid'] = $project_id;
-        $where2['L.projectid'] = $project_id;
+        $where2[] = 'L.projectid = '.$project_id;
         if ($section !== '' && $section !== NUll) {
         if ($section !== '' && $section !== NUll) {
             $where['section'] = $section;
             $where['section'] = $section;
-            $where2['L.section'] = $section;
+            $where2[] = 'L.section = "'.$section.'"';
         }
         }
         if (!empty($company) && !empty($type)) {
         if (!empty($company) && !empty($type)) {
             if ($type == 2) {
             if ($type == 2) {
                 $where['manu'] = $company;
                 $where['manu'] = $company;
-                $where2['L.manu'] = $company;
+                $where2[] = 'L.manu = '.$company;
             }elseif ($type == 3) {
             }elseif ($type == 3) {
                 $where['supplier'] = $company;
                 $where['supplier'] = $company;
-                $where2['L.supplier'] = $company;
+                $where2[] = 'L.supplier = '.$company;
             }elseif ($type == 4) {
             }elseif ($type == 4) {
                 $where['po'] = $company;
                 $where['po'] = $company;
-                $where2['L.po'] = $company;
+                $where2[] = 'L.po = '.$company;
             }else {
             }else {
-                $where['upazilla'] = $company;
-                $where2['L.upazilla'] = $company;
+                // $where['upazilla'] = $company;
+                // $where2['L.upazilla'] = $company;
             }
             }
         }
         }
 
 
         $data['total_lamp'] = $this->Lamp_model->get_count($where);
         $data['total_lamp'] = $this->Lamp_model->get_count($where);
 
 
-        $where['isfaulted'] = 1;
-        $data['failure_count'] = $this->Lamp_model->get_count($where);
+        $join = [];
+        $join[] = ['table'=>'(select lampid,max(updatetime) as maxTime from warning_info_log group by lampid) as t1','cond'=>'t1.lampid = L.id','type'=>'inner'];
+        $join[] = ['table'=>'warning_info_log as AI','cond'=>'AI.lampid = t1.lampid AND t1.maxTime = AI.updatetime','type'=>'inner'];
+        $where2[] = 'L.netstatus = 1';
+        $where2[] = '(AI.batstatus != 0 OR AI.panelstatus != 0 OR AI.lampstatus != 0 OR AI.tempstatus != 0)';
+        $where2 = implode(' AND ', $where2);
+        $res = $this->Lamp_model->get_list_by_multi_join($where2, 'count(*) as total',NULL, NULL, $join, NULL, NUll, 'L', true);
+        $data['failure_count'] = $res['total'];
 
 
-        unset($where['isfaulted']);
         $where['netstatus'] = 1;
         $where['netstatus'] = 1;
         $data['online_count'] = $this->Lamp_model->get_count($where);
         $data['online_count'] = $this->Lamp_model->get_count($where);
 
 
@@ -443,11 +448,12 @@ class Project extends Base_Controller {
                 $order = 'convert(C.name using gbk) asc';
                 $order = 'convert(C.name using gbk) asc';
                 $fields = 'C.name as company,P.projectname,P.id,C.id as cId';
                 $fields = 'C.name as company,P.projectname,P.id,C.id as cId';
             }else {
             }else {
-                $sectionWhere = ['upazilla !='=>0];
-                $join[] = ['table'=>'company as C','cond'=>'L.upazilla = C.id','type'=>'inner'];
-                $group = 'L.upazilla,L.projectid';
-                $order = 'convert(C.name using gbk) asc';
-                $fields = 'C.name as company,P.projectname,P.id,C.id as cId';
+                // $sectionWhere = ['upazilla !='=>0];
+                $join[] = ['table'=>'global_location as G','cond'=>'G.id = P.cityid','type'=>'left'];
+                // $join[] = ['table'=>'project as P','cond'=>'P.id = L.projectid','type'=>'left'];
+                $group = 'P.cityid,p.id';
+                $order = 'convert(G.english_name using gbk) asc';
+                $fields = 'G.english_name as company,P.projectname,P.id,G.id as cId';
             }
             }
 
 
             $data = $this->Lamp_model->get_list_by_join($where, $fields,NULL, NULL, $join, $order, $group, 'L');
             $data = $this->Lamp_model->get_list_by_join($where, $fields,NULL, NULL, $join, $order, $group, 'L');
@@ -461,7 +467,7 @@ class Project extends Base_Controller {
                 }
                 }
                 $projectIdArr = array_column($data, 'id');
                 $projectIdArr = array_column($data, 'id');
                 $sectionWhere['projectid'] = $projectIdArr;
                 $sectionWhere['projectid'] = $projectIdArr;
-                $sectionList = $this->Lamp_model->get_list($sectionWhere, 'section as name,projectid',NULL, NULL, 'convert(section using gbk) asc', 'projectid,section');
+                $sectionList = $this->Lamp_model->get_list($sectionWhere, 'section as name,projectid',NULL, NULL, 'convert(section using gbk) asc', NUll);
                 foreach ($sectionList as $key => $value) {
                 foreach ($sectionList as $key => $value) {
                     if (isset($temp[$value['projectid']])) {
                     if (isset($temp[$value['projectid']])) {
                         unset($value['projectid']);
                         unset($value['projectid']);