|
@@ -37,7 +37,8 @@ class Lampcontrol extends Base_Controller {
|
|
|
$pid_arr = $project_id;
|
|
|
$timezone = $this->Project_model->get_timezone_by_projectid($project_id);
|
|
|
|
|
|
- $filter = array('L.projectid'=>$project_id);
|
|
|
+ // $filter = array('L.projectid'=>$project_id);
|
|
|
+ $filter = 'L.projectid = '.$project_id;
|
|
|
$network_id = $this->input->post('network_id', true);
|
|
|
$section = $this->input->post('section', true);
|
|
|
$type = intval($this->input->post('type', true));
|
|
@@ -45,22 +46,27 @@ class Lampcontrol extends Base_Controller {
|
|
|
if (!empty($type) && !empty($company)) {
|
|
|
|
|
|
if ($type == 2) {
|
|
|
- $filter['L.manu'] = $company;
|
|
|
+ // $filter['L.manu'] = $company;
|
|
|
+ $filter .= ' AND L.manu = '.$company;
|
|
|
}elseif ($type == 3) {
|
|
|
- $filter['L.supplier'] = $company;
|
|
|
+ // $filter['L.supplier'] = $company;
|
|
|
+ $filter .= ' AND L.supplier = '.$company;
|
|
|
}elseif ($type == 4) {
|
|
|
- $filter['L.po'] = $company;
|
|
|
+ // $filter['L.po'] = $company;
|
|
|
+ $filter .= ' AND L.po = '.$company;
|
|
|
}else {
|
|
|
- $filter['L.upazilla'] = $company;
|
|
|
+ // $filter['L.upazilla'] = $company;
|
|
|
+ $filter .= ' AND L.upazilla = '.$company;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if (!empty($network_id)) $filter['L.networkid'] = $network_id;
|
|
|
- if (!empty($section)) $filter['L.section'] = $section;
|
|
|
+ // if (!empty($section)) $filter['L.section'] = $section;
|
|
|
+ if (!empty($section)) $filter .= ' AND L.section = "'.$section.'"';
|
|
|
$offline = $this->input->post('offline', true);
|
|
|
- if (!empty($offline)) $filter['L.netstatus'] = 0;
|
|
|
+ // if (!empty($offline)) $filter['L.netstatus'] = 0;
|
|
|
+ if (!empty($offline)) $filter .= ' AND L.netstatus = 0';
|
|
|
$online = $this->input->post('online', true);
|
|
|
- if (!empty($online)) $filter['L.netstatus'] = 1;
|
|
|
+ // if (!empty($online)) $filter['L.netstatus'] = 1;
|
|
|
+ if (!empty($online)) $filter .= ' AND L.netstatus= 1';
|
|
|
|
|
|
// 分页数据
|
|
|
$page = intval($this->input->post('page',true));
|
|
@@ -70,16 +76,16 @@ class Lampcontrol extends Base_Controller {
|
|
|
$offset = ($page - 1)*$count;
|
|
|
|
|
|
$keyword = $this->input->post('keyword', true);
|
|
|
- if ($keyword !== '' && $keyword !== null) $filter['L.number|L.section|L.address'] = $keyword;
|
|
|
+ // if ($keyword !== '' && $keyword !== null) $filter['L.number|L.section|L.address'] = $keyword;
|
|
|
+ if ($keyword !== '' && $keyword !== null) $filter .= ' AND (L.number like "%'.$keyword.'%" OR L.section like "%'.$keyword.'%" OR L.address like "%'.$keyword.'%")';
|
|
|
|
|
|
$status = $this->input->post('status', true);
|
|
|
if (!empty($status)) {
|
|
|
- $filter['L.isfaulted'] = $status;
|
|
|
- $filter['AI.stralarmtype !='] = '';
|
|
|
- $filter['AI.status'] = 0;
|
|
|
+ // $filter['AI.isfaulted'] = $status;
|
|
|
+ $filter .= ' AND (AI.batstatus != 0 OR AI.panelstatus != 0 OR AI.lampstatus != 0 OR AI.tempstatus != 0)';
|
|
|
}
|
|
|
- $alarmtype = $this->input->post('alarmtype', true);
|
|
|
- if (!empty($alarmtype)) $filter['AI.alarmtype'] = $alarmtype;
|
|
|
+ // $alarmtype = $this->input->post('alarmtype', true);
|
|
|
+ // if (!empty($alarmtype)) $filter['AI.alarmtype'] = $alarmtype;
|
|
|
// 记录用户选择的字段
|
|
|
if (!empty($field1)) {
|
|
|
$fieldData = array('userid'=>$userid,'lampfield'=>$field1);
|
|
@@ -112,7 +118,8 @@ class Lampcontrol extends Base_Controller {
|
|
|
$join = array();
|
|
|
|
|
|
$join[] = ['table'=>'project as P', 'cond'=>'L.projectid = P.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 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'];
|
|
|
$join[] = ['table'=>'(select t1.* from realtime_info_log t1, (select lampid, max(updatetime) as maxtime from realtime_info_log group by lampid) t2 where t1.lampid = t2.lampid and t1.updatetime = t2.maxtime) as RI', 'cond'=>'L.id = RI.lampid', 'type'=>'left'];
|
|
|
$data['lamps'] = $this->Lamp_model->get_list_by_join($filter, $fields,$limit, $offset, $join, "L.number ASC", NUll, 'L');
|
|
@@ -143,8 +150,8 @@ class Lampcontrol extends Base_Controller {
|
|
|
$value['lamppower'] = !empty($value['lamppower']) ? $value['lamppower'] : "0";
|
|
|
}
|
|
|
// 故障信息处理
|
|
|
- if (array_key_exists('isfaulted',$value)) {
|
|
|
- if ($value['isfaulted'] == 0) {
|
|
|
+ if (array_key_exists('alarmStatus',$value)) {
|
|
|
+ if (empty($value['batstatus']) && $value['panelstatus'] && $value['lampstatus'] && $value['tempstatus']) {
|
|
|
if (empty($version)) {
|
|
|
$value['isfaulted'] = '无';
|
|
|
}else{
|
|
@@ -152,39 +159,23 @@ class Lampcontrol extends Base_Controller {
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
+ $batstatus = $this->config->item('batstatus');
|
|
|
+ $panelstatus = $this->config->item('panelstatus');
|
|
|
+ $lampstatus = $this->config->item('lampstatus');
|
|
|
+ $tempstatus = $this->config->item('tempstatus');
|
|
|
$res = $this->Alarm_model->get_one_by_filter(array('lampid'=>$value['id'],'status'=>0),'stralarmtype');
|
|
|
- if (empty($version)) {
|
|
|
- $stralarmtype = trim($res['stralarmtype']);
|
|
|
- if (!empty($stralarmtype)) {
|
|
|
- $alarmArr = explode(',', $stralarmtype);
|
|
|
- $temp2 = array();
|
|
|
- foreach ($alarmArr as $a) {
|
|
|
- if ($a == '电池故障') {
|
|
|
- $a = '电池电压异常';
|
|
|
- }
|
|
|
- $temp2[] = $a;
|
|
|
- }
|
|
|
- $value['isfaulted'] = implode(',', $temp2);
|
|
|
- }else{
|
|
|
- $value['isfaulted'] = '无';
|
|
|
- }
|
|
|
+ $temp2 = array();
|
|
|
+ if (isset($batstatus[$value['batstatus']])) $temp2[] = $batstatus[$value['batstatus']];
|
|
|
+ if (isset($panelstatus[$value['panelstatus']])) $temp2[] = $panelstatus[$value['panelstatus']];
|
|
|
+ if (isset($lampstatus[$value['lampstatus']])) $temp2[] = $lampstatus[$value['lampstatus']];
|
|
|
+ if (isset($tempstatus[$value['tempstatus']])) $temp2[] = $tempstatus[$value['tempstatus']];
|
|
|
+ $stralarmtype = trim($res['stralarmtype']);
|
|
|
+ if (!empty($temp2)) {
|
|
|
+ $value['isfaulted'] = implode(',', $temp2);
|
|
|
}else{
|
|
|
- $stralarmtype = trim($res['stralarmtype']);
|
|
|
- if (!empty($stralarmtype)) {
|
|
|
- $alarmArr = explode(',', $stralarmtype);
|
|
|
- $temp2 = array();
|
|
|
- foreach ($alarmArr as $a) {
|
|
|
- if ($a == '电池故障') {
|
|
|
- $a = '电池电压异常';
|
|
|
- }
|
|
|
- $temp[] = alarm_translate($a);
|
|
|
- }
|
|
|
- $value['isfaulted'] = implode(',', $temp2);
|
|
|
- }else{
|
|
|
- $value['isfaulted'] = 'Nothing';
|
|
|
- }
|
|
|
-
|
|
|
+ $value['isfaulted'] = 'Nothing';
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
if (array_key_exists('lampstatus',$value)) {
|
|
@@ -279,7 +270,6 @@ class Lampcontrol extends Base_Controller {
|
|
|
$path = push_excel($data,'lampinfoExcel_'.date('Ymd'));
|
|
|
exit(json_result('0000', $this->response['0000'], array('path'=>$path)));
|
|
|
}
|
|
|
- $timezone = null;
|
|
|
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') {
|
|
@@ -290,8 +280,8 @@ class Lampcontrol extends Base_Controller {
|
|
|
}
|
|
|
|
|
|
// 故障信息处理
|
|
|
- if (array_key_exists('isfaulted',$value)) {
|
|
|
- if ($value['isfaulted'] == 0) {
|
|
|
+ if (array_key_exists('alarmStatus',$value)) {
|
|
|
+ if (empty($value['batstatus']) && $value['panelstatus'] && $value['lampstatus'] && $value['tempstatus']) {
|
|
|
if (empty($version)) {
|
|
|
$value['isfaulted'] = '无';
|
|
|
}else{
|
|
@@ -299,43 +289,26 @@ class Lampcontrol extends Base_Controller {
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
+ $batstatus = $this->config->item('batstatus');
|
|
|
+ $panelstatus = $this->config->item('panelstatus');
|
|
|
+ $lampstatus = $this->config->item('lampstatus');
|
|
|
+ $tempstatus = $this->config->item('tempstatus');
|
|
|
$res = $this->Alarm_model->get_one_by_filter(array('lampid'=>$value['id'],'status'=>0),'stralarmtype');
|
|
|
- if (empty($version)) {
|
|
|
- // $value['isfaulted'] = empty($res['stralarmtype']) ? '无' : $res['stralarmtype'];
|
|
|
- $stralarmtype = trim($res['stralarmtype']);
|
|
|
- if (!empty($stralarmtype)) {
|
|
|
- $alarmArr = explode(',', $stralarmtype);
|
|
|
- $temp = array();
|
|
|
- foreach ($alarmArr as $a) {
|
|
|
- if ($a == '电池故障') {
|
|
|
- $a = '电池电压异常';
|
|
|
- }
|
|
|
- $temp[] = $a;
|
|
|
- }
|
|
|
- $value['isfaulted'] = implode(',', $temp);
|
|
|
- }else{
|
|
|
- $value['isfaulted'] = '无';
|
|
|
- }
|
|
|
+ $temp2 = array();
|
|
|
+ if (isset($batstatus[$value['batstatus']])) $temp2[] = $batstatus[$value['batstatus']];
|
|
|
+ if (isset($panelstatus[$value['panelstatus']])) $temp2[] = $panelstatus[$value['panelstatus']];
|
|
|
+ if (isset($lampstatus[$value['lampstatus']])) $temp2[] = $lampstatus[$value['lampstatus']];
|
|
|
+ if (isset($tempstatus[$value['tempstatus']])) $temp2[] = $tempstatus[$value['tempstatus']];
|
|
|
+ $stralarmtype = trim($res['stralarmtype']);
|
|
|
+ if (!empty($temp2)) {
|
|
|
+ $value['isfaulted'] = implode(',', $temp2);
|
|
|
}else{
|
|
|
- $stralarmtype = trim($res['stralarmtype']);
|
|
|
- if (!empty($stralarmtype)) {
|
|
|
- $alarmArr = explode(',', $stralarmtype);
|
|
|
- $temp = array();
|
|
|
- foreach ($alarmArr as $a) {
|
|
|
- if ($a == '电池故障') {
|
|
|
- $a = '电池电压异常';
|
|
|
- }
|
|
|
- $temp[] = alarm_translate($a);
|
|
|
- }
|
|
|
- $value['isfaulted'] = implode(',', $temp);
|
|
|
- }else{
|
|
|
- $value['isfaulted'] = 'Nothing';
|
|
|
- }
|
|
|
-
|
|
|
+ $value['isfaulted'] = 'Nothing';
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
+
|
|
|
if (array_key_exists('lampstatus',$value)) {
|
|
|
$value['lampstatus'] = !empty($value['lampstatus']) ? $value['lampstatus'] : "0";
|
|
|
}
|
|
@@ -378,6 +351,7 @@ class Lampcontrol extends Base_Controller {
|
|
|
if (!empty($value['updatetime'])) {
|
|
|
// $value['timezoneid'];
|
|
|
if($timezone === null) $timezone = $this->db->query('select value from timezone where id = '.$value['timezoneid'])->row_array();
|
|
|
+ // var_dump($timezone);die;
|
|
|
$value['updatetime'] = set_timezone($value['updatetime'],$timezone['value']);
|
|
|
// if ($timezone['value'] != 8) {
|
|
|
// $value['updatetime'] = date_change($value['updatetime'],0,$timezone['value']);
|
|
@@ -389,8 +363,8 @@ class Lampcontrol extends Base_Controller {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
- unset($filter['page']);
|
|
|
- unset($filter['count']);
|
|
|
+ // unset($filter['page']);
|
|
|
+ // unset($filter['count']);
|
|
|
$data['total_data']['install_num'] = $this->Lamp_model->get_count(array('projectid'=>$project_id));
|
|
|
$data['total_data']['light_num'] = $this->Lamp_model->get_count(array('projectid'=>$project_id,'netstatus'=>1,'status'=>1));
|
|
|
$data['total_data']['online_num'] = $this->Lamp_model->get_count(array('projectid'=>$project_id,'netstatus'=>1));
|