DESKTOP-9JTA2JJ\HP пре 5 година
родитељ
комит
b5eedeaeb9
2 измењених фајлова са 14 додато и 14 уклоњено
  1. 5 5
      api/application/controllers/Lampcontrol.php
  2. 9 9
      api/application/models/Lamp_model.php

+ 5 - 5
api/application/controllers/Lampcontrol.php

@@ -275,6 +275,7 @@ class Lampcontrol extends Base_Controller {
                 $path = push_excel($data,'lampinfoExcel_'.date('Ymd'));
                 exit(json_result('0000', $this->response['0000'], array('path'=>$path)));
             }
+
             foreach ($data['lamps'] as $key => &$value) {
                 $value['section'] = empty($value['section']) ? '' : $value['section'];
                 if (isset($value['updatetime']) && $value['updatetime'] == '0000-00-00 00:00:00') {
@@ -366,6 +367,7 @@ class Lampcontrol extends Base_Controller {
                 
             }
         }
+
         // unset($filter['page']);
         // unset($filter['count']);
         $countWheret1 = implode(' AND ', $countWhere);
@@ -386,6 +388,7 @@ class Lampcontrol extends Base_Controller {
         $join2[] = ['table'=>'(select lampid,max(updatetime) as maxTime from warning_info_log group by lampid) as WI','cond'=>'WI.lampid = L.id','type'=>'inner'];
         $join2[] = ['table'=>'warning_info_log as AI','cond'=>'WI.lampid = AI.lampid AND WI.maxTime = AI.updatetime','type'=>'inner'];
         $res = $this->Lamp_model->get_list_by_multi_join($filter2, 'count(*) total',null, null, $join2, "L.number ASC", NUll, 'L',true);
+
         $data['total_data']['fault_count'] = $res['total'];
         $data['total_data']['light_rate'] = empty($data['total_data']['install_num']) ? '0' : round($data['total_data']['light_num']/$data['total_data']['install_num'],4)*100;
         $data['total_data']['light_rate'] .= '%';
@@ -396,7 +399,8 @@ class Lampcontrol extends Base_Controller {
         // $data['total_data']['network_num'] = $this->Network_model->get_count(['projectid'=>$project_id,'type'=>1]);
 
         $res = $this->Lamp_model->get_list_by_multi_join($filter, 'count(*) total',$limit, $offset, $join, "L.number ASC", NUll, 'L',true);
-        $result = !empty($pid_arr) ? $this->Lamp_model->get_total('L.projectid', $pid_arr, 'L.id') : array();
+        $result = !empty($pid_arr) ? $this->Lamp_model->get_count(['projectid'=>$pid_arr]) : array();
+
         $result = $this->Lamp_model->get_count(['projectid'=>$pid_arr]);
         $data['total'] = $res['total'];
         $data['count'] = $result;
@@ -612,10 +616,6 @@ class Lampcontrol extends Base_Controller {
                             $alarmInfo['stralarmtype'] = implode(',', $t);
                         }
                     }
-                    if (!empty($alarmInfo['stralarmtype'])) {
-                        $this->db->insert('alarm_info_log', $alarmInfo);
-                        $isfaulted = 1;
-                    }
                     $this->Lamp_model->update(array('id'=>$lamp_id),array('status'=>$lampInfo['lampstatus'],'lighteness'=>$lampInfo['lighteness'],'isfaulted'=>$isfaulted));
                     if ($lampData['status'] == 0) $this->Network_model->update(array('id'=>$lampData['networkid']),array('status'=>1));
                 }

+ 9 - 9
api/application/models/Lamp_model.php

@@ -208,14 +208,14 @@ class Lamp_model extends Base_model {
 			$this->db->where('L.networkid', $filter['networkid']);
 		}
 		
-		if(isset($filter['alarmtype']) && !empty($filter['alarmtype'])){
-			$this->db->where('AI.alarmtype', $filter['alarmtype']);
-		}
-		if(isset($filter['status']) && is_numeric($filter['status'])){
-			$this->db->where('L.isfaulted', $filter['status']);
-			$this->db->where('AI.stralarmtype !=', '');
-			$this->db->where('AI.status', 0);
-		}
+		// if(isset($filter['alarmtype']) && !empty($filter['alarmtype'])){
+		// 	$this->db->where('AI.alarmtype', $filter['alarmtype']);
+		// }
+		// if(isset($filter['status']) && is_numeric($filter['status'])){
+		// 	$this->db->where('L.isfaulted', $filter['status']);
+		// 	$this->db->where('AI.stralarmtype !=', '');
+		// 	$this->db->where('AI.status', 0);
+		// }
 		if(isset($filter['section']) && !empty($filter['section'])){
 			$this->db->where('L.section', $filter['section']);
 		}
@@ -277,7 +277,7 @@ class Lamp_model extends Base_model {
 		}
     
         $this->db->from($this->table.' as L');
-        $this->db->join('(select t1.* from alarm_info_log t1, (select lampid, max(updatetime) as maxtime from alarm_info_log group by lampid) t2 where t1.lampid = t2.lampid and t1.updatetime = t2.maxtime) as AI', 'L.id = AI.lampid', 'left');
+        // $this->db->join('(select t1.* from alarm_info_log t1, (select lampid, max(updatetime) as maxtime from alarm_info_log group by lampid) t2 where t1.lampid = t2.lampid and t1.updatetime = t2.maxtime) as AI', 'L.id = AI.lampid', 'left');
         // $this->db->join('network as N', 'N.id = L.networkid', 'left');
 
         if(!empty($filter['page']) && !empty($filter['count'])){