wzh 4 vuotta sitten
vanhempi
commit
7980f2e6f8
1 muutettua tiedostoa jossa 36 lisäystä ja 33 poistoa
  1. 36 33
      api/application/controllers/Lampcontrol.php

+ 36 - 33
api/application/controllers/Lampcontrol.php

@@ -1613,7 +1613,8 @@ class Lampcontrol extends Base_Controller {
             $dataList = array();
 
             // 路灯
-            $lampInfoList = $this->Lamp_model->getListForInfoLog($lamp_id, 'lamp_info_log', null, null,$beginDate,$endDate);
+            // $lampInfoList = $this->Lamp_model->getListForInfoLog($lamp_id, 'lamp_info_log', null, null,$beginDate,$endDate);
+            $lampInfoList = $this->RealtimeInfoLog_model->get_list(['lampid'=>$lamp_id,'updatetime >='=>$beginDate,'updatetime <='=>$endDate], 'loadvoltage as lampvoltage,lighteness,loadcurrent as lampcurrent,loadpower as lamppower,updatetime,loadWorkTimeDay as daychargemincurrent,daydischarmaxpow',$count, ($page-1)*$count, 'updatetime desc,id desc', NUll);
             $temp = array();
             $i = 1;
             if (empty($this->version)) {
@@ -1626,12 +1627,13 @@ class Lampcontrol extends Base_Controller {
                 $name = 'Lamp';
             }
             foreach ($lampInfoList as $k=>$l) {
+                $l['lampstatus'] = $l['lighteness'] > 0 ? 1 : 0;
                 $temp[$k][] = $i;
                 $temp[$k][] = $l['lighteness'];
                 $temp[$k][] = $lampStatusArr[$l['lampstatus']];
                 $temp[$k][] = $l['lampvoltage'];
                 $temp[$k][] = $l['lampcurrent'];
-                $temp[$k][] = $l['loadpower'];
+                $temp[$k][] = $l['lamppower'];
                 $temp[$k][] = $l['daydischarmaxpow'];
                 $h = floor($l['daychargemincurrent'] / 3600);
                 $h = $h < 10 ? '0'.$h : $h;
@@ -1649,7 +1651,9 @@ class Lampcontrol extends Base_Controller {
             $dataList[] = array('name'=>$name,'dataList'=>$data);
 
             // 蓄电池
-            $lampInfoList = $this->Lamp_model->getListForInfoLog($lamp_id, 'battery_info_log', null, null,$beginDate,$endDate);
+            // $lampInfoList = $this->Lamp_model->getListForInfoLog($lamp_id, 'battery_info_log', null, null,$beginDate,$endDate);
+            $fields = 'batvoltage as battvoltage,chgtemper as batttemper,updatetime,DayOverDisChgTimes as overtimes,battstatus,chargestage,voltagedaymin,voltagedaymax,daybattmintemper,daybattmaxtemper';
+            $lampInfoList = $this->RealtimeInfoLog_model->get_list($where, $fields,null,null, 'updatetime desc,id desc');
             $temp = array();
             $i = 1;
             if (empty($this->version)) {
@@ -1661,7 +1665,7 @@ class Lampcontrol extends Base_Controller {
                 }
                 $battstatusArr = array(0=>'空闲',1=>'放电',2=>'充电',3=>'一边充电一边放电',''=>'未知状态');
                 $unknown = '未知状态';
-                $title = array('序号','系统电压(V)','系统电流(A)','MOS温度(℃)','电池状态','充电阶段','电池电压(V)','当天最低电压(V)','当天最高电压(V)','电池温度(℃)','当天电池最低温度(℃)','当天电池最高温度(℃)','更新时间');
+                $title = array('序号','电池状态','充电阶段','电池电压(V)','当天最低电压(V)','当天最高电压(V)','电池温度(℃)','当天电池最低温度(℃)','当天电池最高温度(℃)','更新时间');
             }else{
                 $name = 'Battery';
                 if ($lampData['protocoltype'] == 2) {
@@ -1671,14 +1675,11 @@ class Lampcontrol extends Base_Controller {
                 }
                 $battstatusArr = array(0=>'Free',1=>'Discharge',2=>'Charge',3=>'Discharge while charging',''=>'Unknown state');
                 $unknown = 'Unknown state';
-                $title = array('Serial number','System voltage(V)','System current(A)','MOS temperature(℃)','Battery status','Charging stage','Battery voltage(V)','The lowest voltage of the day(V)','Maximum Voltage of the Day(V)','Battery temperature(℃)','Battery minimum temperature for the day(℃)','The highest temperature of the battery on that day(℃)','Update time');
+                $title = array('Serial number','Battery status','Charging stage','Battery voltage(V)','The lowest voltage of the day(V)','Maximum Voltage of the Day(V)','Battery temperature(℃)','Battery minimum temperature for the day(℃)','The highest temperature of the battery on that day(℃)','Update time');
             }
             $indexArr = [2=>'16',3=>'32',4=>'48',5=>'64'];
             foreach ($lampInfoList as $k=>$l) {
                 $temp[$k][] = $i;
-                $temp[$k][] = $l['sysvoltage'];
-                $temp[$k][] = $l['syscurrent'];
-                $temp[$k][] = $l['temper'];
                 $temp[$k][] = $battstatusArr[$l['battstatus']];
                 if ($lampData['protocoltype'] == 1) {
                     $l['chargestage'] = isset($indexArr[intval($l['chargestage'])]) ? $indexArr[intval($l['chargestage'])] : $l['chargestage'];
@@ -1701,7 +1702,9 @@ class Lampcontrol extends Base_Controller {
             $dataList[] = array('name'=>$name,'dataList'=>$data);
 
             // 太阳能
-            $lampInfoList = $this->Lamp_model->getListForInfoLog($lamp_id, 'solar_info_log', null, null,$beginDate,$endDate);
+            $fields = 'panelvoltage as solarvoltage,updatetime,panelcurrent as solarcurrent,panelpower as solarpower,daychargemaxpow';
+            $lampInfoList = $this->RealtimeInfoLog_model->get_list($where, $fields,null,null, 'updatetime desc,id desc');
+            // $lampInfoList = $this->Lamp_model->getListForInfoLog($lamp_id, 'solar_info_log', null, null,$beginDate,$endDate);
             $temp = array();
             $i = 1;
             if (empty($this->version)) {
@@ -1733,30 +1736,30 @@ class Lampcontrol extends Base_Controller {
             $dataList[] = array('name'=>$name,'dataList'=>$data);
 
             // 系统
-            $lampInfoList = $this->Lamp_model->getListForInfoLog($lamp_id, 'system_info_log', null, null,$beginDate,$endDate);
-            $temp = array();
-            $i = 1;
-            if (empty($this->version)) {
-                $name = '系统';
-                $title = array('序号','系统电压(V)','系统电流(A)','控制器温度(℃)','更新时间');
-            }else{
-                $name = 'System';
-                $title = array('Serial number','System voltage(V)','System current(A)','Control temperature(℃)','Update time');
-            }
-            foreach ($lampInfoList as $k=>$l) {
-                $temp[$k][] = $i;
-                $temp[$k][] = $l['sysvoltage'];
-                $temp[$k][] = $l['syscurrent'];
-                $temp[$k][] = $l['temper'];
-                $temp[$k][] = date_change($l["updatetime"],8,$timezone['value']);
-                $i ++;
-            }
-            $title1 = [];
-            foreach ($title as $t) {
-                $title1[0][] = $t;
-            }
-            $data = array_merge($title1,$temp);
-            $dataList[] = array('name'=>$name,'dataList'=>$data);
+            // $lampInfoList = $this->Lamp_model->getListForInfoLog($lamp_id, 'system_info_log', null, null,$beginDate,$endDate);
+            // $temp = array();
+            // $i = 1;
+            // if (empty($this->version)) {
+            //     $name = '系统';
+            //     $title = array('序号','系统电压(V)','系统电流(A)','控制器温度(℃)','更新时间');
+            // }else{
+            //     $name = 'System';
+            //     $title = array('Serial number','System voltage(V)','System current(A)','Control temperature(℃)','Update time');
+            // }
+            // foreach ($lampInfoList as $k=>$l) {
+            //     $temp[$k][] = $i;
+            //     $temp[$k][] = $l['sysvoltage'];
+            //     $temp[$k][] = $l['syscurrent'];
+            //     $temp[$k][] = $l['temper'];
+            //     $temp[$k][] = date_change($l["updatetime"],8,$timezone['value']);
+            //     $i ++;
+            // }
+            // $title1 = [];
+            // foreach ($title as $t) {
+            //     $title1[0][] = $t;
+            // }
+            // $data = array_merge($title1,$temp);
+            // $dataList[] = array('name'=>$name,'dataList'=>$data);
 
             $path = push_excel($dataList,'historyInfoExcel_'.date('Ymd'),1);
             exit(json_result('0000', $this->response['0000'], array('path'=>$path)));