|
@@ -710,21 +710,34 @@ class Map extends Base_Controller{
|
|
|
$lampid = intval($this->input->post('lampid',true));
|
|
|
|
|
|
if (empty($lampid)) exit(json_result('0007',$this->response['0007']));
|
|
|
- $fields = 'L.number,L.address,N.status as netStatus,L.lighteness,L.lampvoltage,L.lampcurrent,L.lamppower,L.electricleft,L.batttemper,L.chargestage,L.overtimes,L.battvoltage,L.discharcurrent,L.dischargepower,L.daydischargemincurrent,L.solarvoltage,L.solarcurrent,L.protocoltype,L.solarpower,L.temper,L.totalgeneration,L.totalconsumption,L.daychargemincurrent,L.isfaulted,L.id,L.totalLightTime,L.createtime,L.projectid';
|
|
|
- $data = $this->Lamp_model->getOne($lampid,$fields);
|
|
|
- if ($data['isfaulted'] == 1) {
|
|
|
- $res = $this->Alarm_model->get_one_by_filter(array('lampid'=>$data['id'],'status'=>0),'stralarmtype');
|
|
|
- $stralarmtype = trim($res['stralarmtype']);
|
|
|
- if (!empty($stralarmtype)) {
|
|
|
- $value['isfaulted'] = '1';
|
|
|
- }else{
|
|
|
- $value['isfaulted'] = '0';
|
|
|
- }
|
|
|
+ $fields = 'L.number,L.address,L.netstatus as netStatus,L.lighteness,L.lampvoltage,L.lampcurrent,L.lamppower,L.electricleft,L.batttemper,L.chargestage,L.overtimes,L.battvoltage,L.discharcurrent,L.dischargepower,L.daydischargemincurrent,L.solarvoltage,L.solarcurrent,L.protocoltype,L.solarpower,L.temper,L.totalgeneration,L.totalconsumption,L.daychargemincurrent,L.id,L.totalLightTime,L.createtime,L.projectid,AI.batstatus,AI.panelstatus, AI.lampstatus,AI.tempstatus,AI.id as alarmId';
|
|
|
+ $join = [];
|
|
|
+ $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'];
|
|
|
+ $data = $this->Lamp_model->get_list_by_multi_join(['L.id'=>$lampid], $fields,NULL, NULL, $join, NULL, NUll, 'L', true);
|
|
|
+ // $data = $this->Lamp_model->get_list(['id'=>$lampid],$fields);
|
|
|
+ if (isset($data['alarmId']) && ($data['batstatus'] != 0 || $data['batstatus'] != 0 || $data['batstatus'] != 0 || $data['batstatus'] != 0)) {
|
|
|
+ $data['isfaulted'] = '1';
|
|
|
+ // $batstatus = $this->config->item('batstatus');
|
|
|
+ // $panelstatus = $this->config->item('panelstatus');
|
|
|
+ // $lampstatus = $this->config->item('lampstatus');
|
|
|
+ // $tempstatus = $this->config->item('tempstatus');
|
|
|
+ // $temp2 = array();
|
|
|
+ // if (isset($batstatus[$data['batstatus']])) $temp2[] = $batstatus[$data['batstatus']];
|
|
|
+ // if (isset($panelstatus[$data['panelstatus']])) $temp2[] = $panelstatus[$data['panelstatus']];
|
|
|
+ // if (isset($lampstatus[$data['lampstatus']])) $temp2[] = $lampstatus[$data['lampstatus']];
|
|
|
+ // if (isset($tempstatus[$data['tempstatus']])) $temp2[] = $tempstatus[$data['tempstatus']];
|
|
|
+ // $data['isfaulted'] = implode(',', $temp2);
|
|
|
+
|
|
|
+ // $res = $this->Alarm_model->get_one_by_filter(array('lampid'=>$data['id'],'status'=>0),'stralarmtype');
|
|
|
+ // $stralarmtype = trim($res['stralarmtype']);
|
|
|
+ // if (!empty($stralarmtype)) {
|
|
|
+ // $value['isfaulted'] = '1';
|
|
|
+ // }else{
|
|
|
+ // $value['isfaulted'] = '0';
|
|
|
+ // }
|
|
|
+ }else{
|
|
|
+ $data['isfaulted'] = '0';
|
|
|
}
|
|
|
- if ($data['protocoltype'] == 1) {
|
|
|
- $indexArr = [2=>'16',3=>'32',4=>'48',5=>'64'];
|
|
|
- $data['chargestage'] = isset($indexArr[intval($data['chargestage'])]) ? $indexArr[intval($data['chargestage'])] : $data['chargestage'];
|
|
|
- }
|
|
|
|
|
|
$LampData = $this->db->query('select min(updatetime) as minTime from system_info_log where lampid = '.$lampid)->row_array();
|
|
|
if (empty($LampData) || empty($LampData['minTime']) || $LampData['minTime'] == '1970-01-01 08:00:00') {
|
|
@@ -738,7 +751,8 @@ class Map extends Base_Controller{
|
|
|
}
|
|
|
$data['userDate'] = round((time() - $beginTime) / (3600 * 24 * 356),1);
|
|
|
$data['userDate'] = $data['userDate'] > 100 ? 0 : $data['userDate'];
|
|
|
- $LampInfoData = $this->db->query('select id,lamppower from lamp_info_log where lighteness = 100 AND lampid = '.$lampid.' order by updatetime DESC limit 1')->row_array();
|
|
|
+ // $LampInfoData = $this->db->query('select id,lamppower from lamp_info_log where lighteness = 100 AND lampid = '.$lampid.' order by updatetime DESC limit 1')->row_array();
|
|
|
+ $LampInfoData = 0;
|
|
|
if (empty($LampInfoData) || empty($LampInfoData['id'])) {
|
|
|
$lamppower = 0;
|
|
|
}else{
|