wzh 5 anni fa
parent
commit
b30802dfa4

+ 2 - 0
api/application/controllers/Home.php

@@ -498,6 +498,8 @@ class Home extends Base_Controller {
             array('name'=>'蓄电池总过放次数','field'=>'HI.overtimes','fields1'=>'overtimes','enname'=>'Over discharge times'),
             array('name'=>'太阳能板功率(W)','field'=>'RI.panelpower as solarpower','fields1'=>'solarpower','enname'=>'Solar panel power(W)'),
             array('name'=>'是否故障','field'=>'AI.batstatus,AI.panelstatus,AI.lampstatus,AI.tempstatus,AI.status as alarmStatus','fields1'=>'isfaulted','enname'=>'Fault'),
+            array('name'=>'型号','field'=>'MI.name as model_name','fields1'=>'model_name','enname'=>'Model'),
+            
         );
 
         // $def = array(

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

@@ -147,6 +147,7 @@ class Lampcontrol extends Base_Controller {
             $join[] = ['table'=>'company as C1', 'cond'=>'L.po = C1.id', 'type'=>'left'];
             $join[] = ['table'=>'company as C2', 'cond'=>'L.supplier = C2.id', 'type'=>'left'];
             $join[] = ['table'=>'company as C3', 'cond'=>'L.manu = C3.id', 'type'=>'left'];
+            $join[] = ['table'=>'model_info as MI', 'cond'=>'L.model = MI.id', 'type'=>'left'];
             // $join[] = ['table'=>'(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', 'cond'=>'L.id = AI.lampid', 'type'=>'left'];
             $join[] = ['table'=>'(select t1.* from warning_info_log t1, (select lampid, max(updatetime) as maxtime from warning_info_log group by lampid) t2 where t1.lampid = t2.lampid and t1.updatetime = t2.maxtime) as AI', 'cond'=>'L.id = AI.lampid', 'type'=>'left'];
             $join[] = ['table'=>'(select t1.* from history_info_log t1, (select lampid, max(updatetime) as maxtime from history_info_log group by lampid) t2 where t1.lampid = t2.lampid and t1.updatetime = t2.maxtime) as HI', 'cond'=>'L.id = HI.lampid', 'type'=>'left'];
@@ -412,7 +413,9 @@ class Lampcontrol extends Base_Controller {
         // unset($filter['page']);
         // unset($filter['count']);
         $countWheret1 = implode(' AND ', $countWhere);
+        // var_dump($countWheret1);die;
         $data['total_data']['install_num'] = $this->Lamp_model->get_count($countWheret1);
+        // var_dump($data['total_data']['install_num']);die;
         $countWheret = $countWhere;
         $countWheret[] = 'lighteness > 0';
         $countWheret[] = 'netstatus = 1';
@@ -1506,10 +1509,17 @@ class Lampcontrol extends Base_Controller {
 
             exit(json_result('0000', $this->response['0000'], $data));
         }elseif ($datatype == 'lamp_info_log') {
-            $fields = "lighteness,lampvoltage,lampcurrent,lamppower,updatetime";
+            $fields = "lighteness,lampvoltage,lampcurrent,lamppower,updatetime,model";
 
             $res = $this->Lamp_model->get_one(['id'=>$lamp_id],$fields);
             $res["updatetime"] = date_change($res["updatetime"],0,DEF_TIMEZONE);
+
+            if (!empty($res['model'])) {
+                $model = $this->db->query('select name from model_info where id = '.$res['model'])->row_array();
+                $res['model'] = empty($model['name']) ? '' : $model['name'];
+            }else{
+                $res['model'] = '';
+            }
             exit(json_result('0000', $this->response['0000'], $res));
         }elseif ($datatype == 'solar_info_log') {
             $fields = "solarvoltage,solarcurrent,boardpower as solarpower,updatetime";

+ 1 - 0
api/application/helpers/function_helper.php

@@ -908,6 +908,7 @@ function get_fields_by_type($fileds,$type){
         'supplier_name' => array('name'=>'Supplier name','enname'=>'Supplier name'),
         'MFRS_name' => array('name'=>'MFRS name','enname'=>'MFRS name'),
         'softwareVersion' => array('name'=>'版本号','enname'=>'Version information'),
+        'model_name' => array('name'=>'型号','enname'=>'Model'),
     );
     $temp = [];
     $filedArr = explode(',', $fileds);