load->model('Lamp_model'); $this->load->model('Project_model'); $this->load->model('Global_location_model'); } private function get_project_id(){ $cityId = intval($this->input->post('cityId',true)); $proId = intval($this->input->post('proId',true)); $projectIdArr = array(); $areaList = array(); $cityList = array(); $proList = array(); if (!empty($proId)) { $proList[] = array('id'=>$proId,'level'=>1); $list = $this->Global_location_model->get_list(['pid'=>$proId],'id,level'); foreach ($list as $key => $value) { if ($value['level'] == 3) { $cityList[] = $value; }elseif ($value['level'] == 4) { $areaList[] = $value; } } } if (!empty($cityId)) { $cityList[] = array('id'=>$cityId,'level'=>2); $list = $this->Global_location_model->get_list(['pid'=>$cityId],'id,level'); foreach ($list as $key => $value) { if ($value['level'] == 4) $areaList[] = $value; } } $cityArr = array_unique(array_merge(array_column($proList, 'id'),array_column($cityList, 'id'),array_column($areaList, 'id'))); if (!empty($cityArr)) { $res = $this->Project_model->get_list(['cityid'=>$cityArr],'id'); $projectIdArr = array_unique(array_column($res, 'id')); } return $projectIdArr; } // 设备统计信息 public function data(){ $projectIdArr = $this->get_project_id(); $data = array( 'day_new_count' => 0, 'day_faulty_count' => 0, 'total_light_count' => 0, 'light_up_count' => 0, 'online_count' => 0, 'faulty_count' => 0 ); $data['logCount'] = $this->get_user_info('logCount'); $date = date('Y-m-d H:i:s',strtotime(date('Y-m-d 00:00:00',time())) - 6*3600); $role = $this->get_user_info('role'); if ($role == SYSTEM_ADMIN) { $data['total_light_count'] = $this->Lamp_model->get_count(); $where = ['createtime >='=>$date]; if (!empty($projectIdArr)) $where['projectid'] = $projectIdArr; $data['day_new_count'] = $this->Lamp_model->get_count($where); $where = ['netstatus'=>1,'status'=>1]; if (!empty($projectIdArr)) $where['projectid'] = $projectIdArr; $data['light_up_count'] = $this->Lamp_model->get_count($where); $where = ['netstatus'=>1]; if (!empty($projectIdArr)) $where['projectid'] = $projectIdArr; $data['online_count'] = $this->Lamp_model->get_count($where); // $where = ['netstatus'=>1,'devstatus !='=>0]; // if (!empty($projectIdArr)) $where['projectid'] = $projectIdArr; // $data['faulty_count'] = $this->Lamp_model->get_count($where); // $where = ['netstatus'=>1,'logtime >='=>$date,'devstatus !='=>0]; // if (!empty($projectIdArr)) $where['projectid'] = $projectIdArr; // $data['day_faulty_count'] = $this->Lamp_model->get_count($where); $where = ['L.netstatus ='=>1]; if (!empty($projectIdArr)) $where['L.projectid'] = $projectIdArr; $where1 = []; foreach ($where as $key => $value) { if (is_array($value)) { $where1[] = $key.' in ('.implode(',', $value).')'; }else{ $where1[] = $key.' '.$value; } } $where1[] = '(WI.batstatus != 0 OR WI.panelstatus != 0 OR WI.lampstatus != 0 OR WI.tempstatus != 0)'; $where1 = implode(' AND ', $where1); $join = []; $join[] = ['table'=>'(select w1.* from warning_info_log as w1 join (select lampid,max(updatetime) as maxTime from warning_info_log group by lampid) as w2 on w1.lampid = w2.lampid AND w1.updatetime = w2.maxTime) as WI','cond'=>'L.id = WI.lampid','type'=>'inner']; $total = $this->Lamp_model->get_list_by_multi_join($where1, 'count(*) as total',NULL, NULL, $join, NULL, NUll, 'L', true); $data['faulty_count'] = $total['total']; $where1 .= ' AND WI.updatetime >= "'.$date.'"'; $total = $this->Lamp_model->get_list_by_multi_join($where1, 'count(*) as total',NULL, NULL, $join, NULL, NUll, 'L', true); $data['day_faulty_count'] = $total['total']; }else{ $company = $this->get_user_info('company'); $where = ['P.company ='=>$company]; if (!empty($projectIdArr)) $where['P.id'] = $projectIdArr; $join = [ ['table'=>'project as P','cond'=>'P.id = L.projectid','type'=>'inner'] ]; $total = $this->Lamp_model->get_list_by_multi_join($where, 'count(*) as total',NULL, NULL, $join, NULL, NUll, 'L', true); $data['total_light_count'] = $total['total']; $where['L.createtime >='] = $date; $total = $this->Lamp_model->get_list_by_multi_join($where, 'count(*) as total',NULL, NULL, $join, NULL, NUll, 'L', true); $data['day_new_count'] = $total['total']; unset($where['L.createtime >=']); $where['L.netstatus ='] = 1; $total = $this->Lamp_model->get_list_by_multi_join($where, 'count(*) as total',NULL, NULL, $join, NULL, NUll, 'L', true); $data['online_count'] = $total['total']; $where['L.status ='] = 1; $total = $this->Lamp_model->get_list_by_multi_join($where, 'count(*) as total',NULL, NULL, $join, NULL, NUll, 'L', true); $data['light_up_count'] = $total['total']; unset($where['L.status']); // $where['L.devstatus !='] = 0; $where1 = []; foreach ($where as $key => $value) { if (is_array($value)) { $where1[] = $key.' in ('.implode(',', $value).')'; }else { $where1[] = $key.' '.$value; } } $where1[] = '(WI.batstatus != 0 OR WI.panelstatus != 0 OR WI.lampstatus != 0 OR WI.tempstatus != 0)'; $where1 = implode(' AND ', $where1); $join[] = ['table'=>'(select w1.* from warning_info_log as w1 join (select lampid,max(updatetime) as maxTime from warning_info_log group by lampid) on w1.lampid = w2.lampid AND w1.updatetime = w2.maxTime) as WI','cond'=>'L.id = WI.lampid','type'=>'inner']; $total = $this->Lamp_model->get_list_by_multi_join($where1, 'count(*) as total',NULL, NULL, $join, NULL, NUll, 'L', true); $data['faulty_count'] = $total['total']; // $where['L.devstatus !='] = 0; $where1 .= ' AND WI.updatetime >= "'.$date.'"'; $total = $this->Lamp_model->get_list_by_multi_join($where1, 'count(*) as total',NULL, NULL, $join, NULL, NUll, 'L', true); $data['day_faulty_count'] = $total['total']; } exit(json_result('0000',$this->response['0000'],$data)); } // 发用电量统计信息 public function sta_info(){ $data = array( 'electricity' => 0, 'CO2_reduction' => 0, 'SO2_reduction' => 0, 'TCE_reduction' => 0 ); $type = intval($this->input->post('type',true)); $projectIdArr = $this->get_project_id(); $role = $this->get_user_info('role'); $type = $this->input->post('type',true); $where = array(); if ($role != SYSTEM_ADMIN){ $company = $this->get_user_info('company'); $where['P.company'] = $company; } if (!empty($projectIdArr)) $where['L.projectid'] = $projectIdArr; if ($type == 0) { $join = []; $join[] = ['table'=>'project as P','cond'=>'L.projectid = P.id','type'=>'left']; $join[] = ['table'=>'(select w1.* from realtime_info_log as w1 join (select lampid,max(updatetime) as maxTime from realtime_info_log group by lampid) as w2 on w1.lampid = w2.lampid AND w1.updatetime = w2.maxTime) as RI','cond'=>'L.id = RI.lampid','type'=>'inner']; $res = $this->Lamp_model->get_list_by_multi_join($where, 'sum(RI.dischargeday) as discharge,sum(RI.chargeday) as charge',NULL, NULL, $join, NULL, NUll, 'L', true); }elseif ($type == 1) { $join = []; $join[] = ['table'=>'project as P','cond'=>'L.projectid = P.id','type'=>'left']; $join[] = ['table'=>'(select w1.* from history_info_log as w1 join (select lampid,max(updatetime) as maxTime from history_info_log group by lampid) as w2 on w1.lampid = w2.lampid AND w1.updatetime = w2.maxTime) as RI','cond'=>'L.id = RI.lampid','type'=>'inner']; $res = $this->Lamp_model->get_list_by_multi_join($where, 'sum(RI.weekdischarg) as discharge,sum(RI.weekchargeah) as charge',NULL, NULL, $join, NULL, NUll, 'L', true); }elseif ($type == 2) { $join = []; $join[] = ['table'=>'project as P','cond'=>'L.projectid = P.id','type'=>'left']; $join[] = ['table'=>'(select w1.* from history_info_log as w1 join (select lampid,max(updatetime) as maxTime from history_info_log group by lampid) as w2 on w1.lampid = w2.lampid AND w1.updatetime = w2.maxTime) as RI','cond'=>'L.id = RI.lampid','type'=>'inner']; $res = $this->Lamp_model->get_list_by_multi_join($where, 'sum(RI.monthdischarge) as discharge,sum(RI.monthchargeah) as charge',NULL, NULL, $join, NULL, NUll, 'L', true); }else{ $join = []; $join[] = ['table'=>'project as P','cond'=>'L.projectid = P.id','type'=>'left']; $join[] = ['table'=>'(select w1.* from history_info_log as w1 join (select lampid,max(updatetime) as maxTime from history_info_log group by lampid) as w2 on w1.lampid = w2.lampid AND w1.updatetime = w2.maxTime) as RI','cond'=>'L.id = RI.lampid','type'=>'inner']; $res = $this->Lamp_model->get_list_by_multi_join($where, 'sum(RI.totaldischarah) as discharge,sum(RI.totalchargeah) as charge',NULL, NULL, $join, NULL, NUll, 'L', true); } $data['electricity'] = $res['discharge']; $data['CO2_reduction'] = $res['discharge']; $data['SO2_reduction'] = $res['discharge']; $data['TCE_reduction'] = $res['discharge']; $data['CO2_reduction'] = round($res['charge']*0.977, 3); $data['SO2_reduction'] = round($res['charge']*0.977/2620*8.5*1000, 3); $data['TCE_reduction'] = round($res['charge']*0.977/2620*1000, 3); exit(json_result('0000',$this->response['0000'],$data)); } // 设备统计列表 public function dev_list(){ $projectIdArr = $this->get_project_id(); $role = $this->get_user_info('role'); $type = $this->input->post('type',true); $where = array(); if ($role != SYSTEM_ADMIN){ $company = $this->get_user_info('company'); $where[] = 'P.company = '.$company; } if ($type == 2) { $fields = 'L.manu as company'; $group = 'group by L.manu'; $where[] = 'L.manu != 0'; $where[] = 'L.manu != ""'; }elseif ($type == 3) { $fields = 'L.supplier as company'; $group = 'group by L.supplier'; $where[] = 'L.supplier != 0'; $where[] = 'L.supplier != ""'; }elseif ($type == 4) { $fields = 'L.po as company'; $group = 'group by L.po'; $where[] = 'L.po != 0'; $where[] = 'L.po != ""'; }else{ $fields = 'L.upazilla as company'; $group = 'group by L.upazilla'; $where[] = 'L.upazilla != 0'; $where[] = 'L.upazilla != ""'; } if (!empty($projectIdArr)) $where[] = 'L.projectid in ('.implode(',', $projectIdArr).')'; $where1 = empty($where) ? '' : 'where '.implode(' AND ', $where); $query = 'select t1.total,C.name,C.id from (select count(*) as total,'.$fields.' from lampinfo AS L left join project AS P on P.id = L.projectid '.$where1.' '.$group.') as t1 left join company as C on t1.company = C.id order by total DESC limit 10'; $list = $this->db->query($query)->result_array(); if (empty($list)) exit(json_result('0000',$this->response['0000'],array('list'=>array()))); $temp = array(); foreach ($list as $key => $value) { $temp2 = array('name'=>$value['name'],'total'=>$value['total'],'onlineCount'=>0,'offlineCount'=>0,'faultCount'=>0); $temp[$value['id']] = $temp2; } $companyArr = array_unique(array_column($list, 'id')); if ($type == 2) { $where[] = 'L.manu in ('.implode(',', $companyArr).')'; }elseif ($type == 3) { $where[] = 'L.supplier in ('.implode(',', $companyArr).')'; }elseif ($type == 4) { $where[] = 'L.po in ('.implode(',', $companyArr).')'; }else{ $where[] = 'L.upazilla in ('.implode(',', $companyArr).')'; } $where1 = $where; $where1[] = 'L.netstatus = 0'; $where1 = 'where '.implode(' AND ', $where1); $query = 'select t1.total,C.id from (select count(*) as total,'.$fields.' from lampinfo AS L left join project AS P on P.id = L.projectid '.$where1.' '.$group.') as t1 left join company as C on t1.company = C.id order by total DESC limit 10'; $list = $this->db->query($query)->result_array(); foreach ($list as $key => $value) { if (isset($temp[$value['id']])) $temp[$value['id']]['offlineCount'] = $value['total']; } $where1 = $where; $where1[] = 'L.netstatus = 1'; $where1 = 'where '.implode(' AND ', $where1); $query = 'select t1.total,C.id from (select count(*) as total,'.$fields.' from lampinfo AS L left join project AS P on P.id = L.projectid '.$where1.' '.$group.') as t1 left join company as C on t1.company = C.id order by total DESC limit 10'; $list = $this->db->query($query)->result_array(); foreach ($list as $key => $value) { if (isset($temp[$value['id']])) $temp[$value['id']]['onlineCount'] = $value['total']; } $where1 = $where; $where1[] = 'L.netstatus = 1'; $where1[] = '(WI.batstatus != 0 OR WI.panelstatus != 0 OR WI.lampstatus != 0 OR WI.tempstatus != 0)'; $where1 = 'where '.implode(' AND ', $where1); $query = 'select t1.total,C.id from (select count(*) as total,'.$fields.' from lampinfo AS L join project AS P on P.id = L.projectid join (select w1.lampid,w1.batstatus,w1.panelstatus,w1.lampstatus,w1.tempstatus from warning_info_log as w1 join (select lampid,max(updatetime) as maxTime from warning_info_log group by lampid) as w2 on w1.updatetime = w2.maxTime AND w1.lampid = w2.lampid) as WI on WI.lampid = L.id '.$where1.' '.$group.') as t1 left join company as C on t1.company = C.id order by total DESC limit 10'; $list = $this->db->query($query)->result_array(); foreach ($list as $key => $value) { if (isset($temp[$value['id']])) $temp[$value['id']]['faultCount'] = $value['total']; } $list = array_values($temp); exit(json_result('0000',$this->response['0000'],array('list'=>$list))); } // 故障信息列表 public function alarm_list(){ $projectIdArr = $this->get_project_id(); $role = $this->get_user_info('role'); $where = array(); if ($role != SYSTEM_ADMIN){ $company = $this->get_user_info('company'); $where[] = 'P.company = '.$company; } if (!empty($projectIdArr)) $where[] = 'P.id in ('.implode(',', $projectIdArr).')'; $where[] = '(WI.batstatus != 0 OR WI.panelstatus != 0 OR WI.lampstatus != 0 OR WI.tempstatus != 0)'; $where[] = 'L.netstatus = 1'; $where1 = implode(' AND ', $where); $join = [ ['table'=>'project as P','cond'=>'P.id = L.projectid','type'=>'inner'] ]; $join[] = ['table'=>'(select w1.* from warning_info_log as w1 join (select lampid,max(updatetime) as maxTime from warning_info_log group by lampid) as w2 on w1.lampid = w2.lampid AND w1.updatetime = w2.maxTime) as WI','cond'=>'L.id = WI.lampid','type'=>'inner']; $join[] = ['table'=>'global_location as G1','cond'=>'G1.id = P.cityid','type'=>'inner']; $join[] = ['table'=>'global_location as G2','cond'=>'G2.id = G1.pid','type'=>'inner']; $join[] = ['table'=>'global_location as G3','cond'=>'G3.id = G2.pid','type'=>'inner']; $list = $this->Lamp_model->get_list_by_join($where1, 'P.projectname as project,WI.batstatus,WI.id,WI.panelstatus,WI.lampstatus,WI.tempstatus,P.cityid,L.address,L.section,G1.english_name as areaName,G2.english_name as cityName,G3.english_name as proName,WI.updatetime,G1.timezone',NULL, NULL, $join, NULL, NUll, 'L'); $batstatus = $this->config->item('batstatus'); $panelstatus = $this->config->item('panelstatus'); $lampstatus = $this->config->item('lampstatus'); $tempstatus = $this->config->item('tempstatus'); foreach ($list as $key => $value) { $location = $value['proName'].'/'.$value['cityName'].'/'.$value['areaName']; $location = empty($value['section']) ? $location : $location.'/'.$value['section']; $list[$key]['location'] = $location; $list[$key]['fault_time'] = set_timezone($value['updatetime'],$value['timezone']); $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']]; $list[$key]['fault_type'] = implode(',', $temp2); unset($list[$key]['cityName']); unset($list[$key]['proName']); unset($list[$key]['areaName']); unset($list[$key]['section']); unset($list[$key]['timezone']); unset($list[$key]['updatetime']); } exit(json_result('0000',$this->response['0000'],array('list'=>$list))); } // 字段管理 public function fields(){ $userid = $this->get_user_info('id'); $data = $this->User_model->get_user_field($userid); if (empty($data) || empty($data['lampfield'])) { // $fieldstr = "number,lampstatus,updatetime,lighteness,address,lamppower,chargestage,battvoltage,overtimes,solarpower,isfaulted,status,section"; $fieldstr = "number,lampstatus,updatetime,lighteness,address,lamppower,chargestage,battvoltage,overtimes,solarpower,isfaulted,status,section"; }else{ if ($data['lampfield'] == 'number,lampstatus,updatetime,lighteness,address,lamppower,chargestage,battvoltage,overtimes,solarpower,isfaulted,status') { $data['lampfield'] .= ',section'; } $fieldstr = $data['lampfield']; } // 系统默认 $def = array( array('name'=>'路灯编号','field'=>'L.number','fields1'=>'number','enname'=>'Lamp number'), array('name'=>'路段','field'=>'L.section','fields1'=>'section','enname'=>'Road'), // array('name'=>'路灯状态','field'=>'L.status as lampstatus,L.lighteness','fields1'=>'lampstatus','enname'=>'Lamp status'), array('name'=>'信号状态','field'=>'L.protocoltype,L.netstatus as status,L.rssi','fields1'=>'status','enname'=>'Network status'), // array('name'=>'信号状态','field'=>'L.protocoltype,L.netstatus as status,N.rssi,N.snr','fields1'=>'status','enname'=>'Network status'), array('name'=>'更新时间','field'=>'RI.updatetime','fields1'=>'updatetime','enname'=>'Update time'), array('name'=>'路灯亮度(%)','field'=>'L.lighteness','fields1'=>'lighteness','enname'=>'Brightness(%)'), array('name'=>'无线模块地址','field'=>'L.address','fields1'=>'address','enname'=>'Wireless module address'), array('name'=>'负载功率(W)','field'=>'RI.loadpower','fields1'=>'loadpower','enname'=>'LED power(W)'), array('name'=>'蓄电池电压(V)','field'=>'RI.batpower as battvoltage','fields1'=>'battvoltage','enname'=>'Battery voltage(V)'), 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'), ); // $def = array( // array('name'=>'路灯编号','field'=>'L.number','fields1'=>'number','enname'=>'Lamp number'), // array('name'=>'路段','field'=>'L.section','fields1'=>'section','enname'=>'Road'), // array('name'=>'路灯状态','field'=>'L.status as lampstatus,L.lighteness','fields1'=>'lampstatus','enname'=>'Lamp status'), // array('name'=>'信号状态','field'=>'L.protocoltype,L.netstatus as status','fields1'=>'status','enname'=>'Network status'), // // array('name'=>'信号状态','field'=>'L.protocoltype,L.netstatus as status,N.rssi,N.snr','fields1'=>'status','enname'=>'Network status'), // array('name'=>'更新时间','field'=>'L.logtime as updatetime','fields1'=>'updatetime','enname'=>'Update time'), // array('name'=>'路灯亮度(%)','field'=>'L.lighteness','fields1'=>'lighteness','enname'=>'Brightness(%)'), // array('name'=>'无线模块地址','field'=>'L.address','fields1'=>'address','enname'=>'Wireless module address'), // array('name'=>'路灯功率(W)','field'=>'L.lamppower','fields1'=>'lamppower','enname'=>'Lamp power(W)'), // array('name'=>'蓄电池充电阶段','field'=>'L.chargestage','fields1'=>'chargestage','enname'=>'Charging stage'), // array('name'=>'蓄电池电压(V)','field'=>'L.battvoltage','fields1'=>'battvoltage','enname'=>'Battery voltage(V)'), // array('name'=>'蓄电池总过放次数','field'=>'L.overtimes','fields1'=>'overtimes','enname'=>'Over discharge times'), // array('name'=>'太阳能板功率(W)','field'=>'L.solarpower','fields1'=>'solarpower','enname'=>'Solar panel power(W)'), // array('name'=>'是否故障','field'=>'L.isfaulted','fields1'=>'isfaulted','enname'=>'Fault'), // ); // 路灯信息 $lampinfo = array( array('name'=>'当前策略','field'=>'L.policyid','fields1'=>'policyid','enname'=>'Current strategy'), array('name'=>'路灯id','field'=>'L.id','fields1'=>'id','enname'=>'Lamp ID'), // array('name'=>'网络名称','field'=>'N.networkname','fields1'=>'networkname','enname'=>'Network name'), array('name'=>'项目名称','field'=>'P.projectname','fields1'=>'projectname','enname'=>'Project name'), array('name'=>'经度','field'=>'L.longitude','fields1'=>'longitude','enname'=>'Longitude'), array('name'=>'纬度','field'=>'L.latitude','fields1'=>'latitude','enname'=>'Latitude'), // array('name'=>'sim卡号','field'=>'N.simid','fields1'=>'simid','enname'=>'SIM card number'), // array('name'=>'套餐剩余','field'=>'N.packageSurplus','fields1'=>'packageSurplus','enname'=>'Package surplus'), array('name'=>'路灯类型','field'=>'L.lamptype','fields1'=>'lamptype','enname'=>'Lamp type'), array('name'=>'太阳能板类型','field'=>'L.boardtype','fields1'=>'boardtype','enname'=>'Solar panel type'), // array('name'=>'太阳能板功率(W)','field'=>'L.boardpower','fields1'=>'boardpower','enname'=>'Solar panel power(W)'), // array('name'=>'蓄电池类型','field'=>'L.batterytype','fields1'=>'batterytype','enname'=>'Battery type'), array('name'=>'蓄电池AH数(ah)','field'=>'HI.totalchargeah as batteryah','fields1'=>'batteryah','enname'=>'Battery capacity(ah)'), // array('name'=>'负载功率(W)','field'=>'L.loadpower','fields1'=>'loadpower','enname'=>'Load power(W)'), // array('name'=>'蓄电池剩余电量','field'=>'L.electricleft','fields1'=>'electricleft','enname'=>'Remaining battery capacity(Ah)'), ); // 路灯信息日志 $lamp_info_log = array( array('name'=>'路灯电压(V)','field'=>'RI.loadvoltage as lampvoltage','fields1'=>'lampvoltage','enname'=>'Lamp voltage(V)'), array('name'=>'路灯电流(A)','field'=>'RI.loadcurrent as lampcurrent','fields1'=>'lampcurrent','enname'=>'Lamp current(A)'), // array('name'=>'灯头温度(℃)','field'=>'L.lamptemper as temper','fields1'=>'temper','enname'=>'Lamp temperature(℃)'), ); $solar_info_log = array( array('name'=>'太阳能板电压(V)','field'=>'RI.panelvoltage as solarvoltage','fields1'=>'solarvoltage','enname'=>'Solar panel voltage(V)'), array('name'=>'太阳能板电流(A)','field'=>'RI.panelcurrent as solarcurrent','fields1'=>'solarcurrent','enname'=>'Solar panel current(A)') ); // 蓄电池信息日志 // $battery_info_log = array( // array('name'=>'蓄电池状态','field'=>'L.battstatus','fields1'=>'battstatus','enname'=>'Battery status'), // array('name'=>'蓄电池充电电流(A)','field'=>'L.chargecurrent','fields1'=>'chargecurrent','enname'=>'Charging current(A)'), // array('name'=>'蓄电池放电电流(A)','field'=>'L.discharcurrent','fields1'=>'discharcurrent','enname'=>'Discharging current(A)'), // array('name'=>'蓄电池充电功率(w)','field'=>'L.chargepower','fields1'=>'chargepower','enname'=>'Charging power(w)'), // array('name'=>'蓄电池放电功率(w)','field'=>'L.dischargepower','fields1'=>'dischargepower','enname'=>'Discharging power(w)'), // array('name'=>'蓄电池表面温度(℃)','field'=>'L.batttemper','fields1'=>'batttemper','enname'=>'Battery surface temperature(℃)'), // array('name'=>'蓄电池总电量','field'=>'L.electrictotal','fields1'=>'electrictotal','enname'=>'Total battery capacity(Ah)'), // array('name'=>'蓄电池电量SOC(%)','field'=>'L.electricSOC','fields1'=>'electricSOC','enname'=>'Battery SOC(%)'), // array('name'=>'当天最低电压(V)','field'=>'L.voltagedaymin','fields1'=>'voltagedaymin','enname'=>'Minimum voltage(V)'), // array('name'=>'当天最高电压(V)','field'=>'L.voltagedaymax','fields1'=>'voltagedaymax','enname'=>'Highest voltage(V)'), // array('name'=>'当天充电安时数(ah)','field'=>'L.daychargeah','fields1'=>'daychargeah','enname'=>'Charging AH(ah)'), // array('name'=>'当天放电安时数(ah)','field'=>'L.daydischarah','fields1'=>'daydischarah','enname'=>'Discharging AH(ah)'), // array('name'=>'当天充电最大功率(W)','field'=>'L.daychargemaxpow','fields1'=>'daychargemaxpow','enname'=>'Charging max-power(W)'), // array('name'=>'当天放电最大功率(W)','field'=>'L.daydischarmaxpow','fields1'=>'daydischarmaxpow','enname'=>'Discharging max-power(W)'), // array('name'=>'当天灯亮时间(hh:mm)','field'=>'L.daychargemincurrent','fields1'=>'daychargemincurrent','enname'=>'Turn-on duration'), // array('name'=>'当天充电最大电流(A)','field'=>'L.daycharmaxcurrent','fields1'=>'daycharmaxcurrent','enname'=>'Highest charging current(A)'), // array('name'=>'当天充电时间(hh:mm)','field'=>'L.daydischargemincurrent','fields1'=>'daydischargemincurrent','enname'=>'Charging duration'), // array('name'=>'当天放电最大电流(A)','field'=>'L.daydischarmaxcurrent','fields1'=>'daydischarmaxcurrent','enname'=>'Highest discharging current(A)'), // array('name'=>'当天蓄电池最低温度(℃)','field'=>'L.daybattmintemper','fields1'=>'daybattmintemper','enname'=>'Battery min-temperature(℃)'), // array('name'=>'当天蓄电池最高温度(℃)','field'=>'L.daybattmaxtemper','fields1'=>'daybattmaxtemper','enname'=>'Battery max-temperature(℃)'), // ); $electric_info_log = array( array('name'=>'当天发电量(kWh)','field'=>'RI.chargeday as daygeneration','fields1'=>'daygeneration','enname'=>'Power generation(kWh)'), array('name'=>'当天用电量(kWh)','field'=>'RI.dischargeday as dayconsumption','fields1'=>'dayconsumption','enname'=>'Power consumption(kWh)'), array('name'=>'累计发电量(kWh)','field'=>'HI.totalchargeah as totalgeneration','fields1'=>'totalgeneration','enname'=>'Cumulative power generation(kWh)'), array('name'=>'累计用电量(kWh)','field'=>'HI.totaldischarah as totalconsumption','fields1'=>'totalconsumption','enname'=>'Cumulative power consumption(kWh)'), ); // $system_info_log = array( // array('name'=>'系统电压(V)','field'=>'L.sysvoltage','fields1'=>'sysvoltage','enname'=>'System voltage(V)'), // array('name'=>'系统电流(A)','field'=>'L.syscurrent','fields1'=>'syscurrent','enname'=>'System current(A)'), // array('name'=>'控制器温度(℃)','field'=>'L.temper as controlTemper','fields1'=>'controlTemper','enname'=>'Controller temperature(℃)'), // ); // 历史信息日志 // $history_info_log = array( // array('name'=>'运行天数','field'=>'L.rundays','fields1'=>'rundays','enname'=>'Running duration'), // array('name'=>'蓄电池总充满次数','field'=>'L.fulltimes','fields1'=>'fulltimes','enname'=>'Full charge times'), // array('name'=>'蓄电池总充电安时数(ah)','field'=>'L.totalchargeah','fields1'=>'totalchargeah','enname'=>'Total charge AH(ah)'), // array('name'=>'蓄电池总放电安时数(ah)','field'=>'L.totaldischarah','fields1'=>'totaldischarah','enname'=>'Total discharge AH(ah)'), // ); // $fields = array_merge($def,$lampinfo,$lamp_info_log,$solar_info_log,$battery_info_log,$electric_info_log,$system_info_log,$history_info_log); $fields = array_merge($def,$lampinfo,$lamp_info_log,$solar_info_log,$electric_info_log); // $fields = $def; $def = explode(',', $fieldstr); foreach ($fields as &$v) { if (in_array($v['fields1'], $def)) { $v['select'] = '1'; }else{ $v['select'] = '0'; } } exit(json_result('0000',$this->response['0000'],array('list'=>$fields))); } // 路灯下拉列表 public function lamp_list(){ $networkid = intval($this->input->post('networkid',true)); $projectid = intval($this->input->post('projectid',true)); if (empty($networkid) && empty($projectid)) { exit(json_result('0405',$this->response['0405'],array())); } if (!empty($networkid)) { $data = $this->Lamp_model->get_list(array('networkid'=>$networkid), 'number,id'); }else{ $data = $this->Lamp_model->get_list(array('projectid'=>$projectid), 'number,id'); } exit(json_result('0000',$this->response['0000'],$data)); } // 获取单个路灯的经纬度 public function get_lng_lat(){ $lampid = $this->input->post('lampid',true); $projectid = $this->input->post('projectid',true); $section = $this->input->post('section',true); $lampData = array(); if (!empty($lampid)) { $where = array('id'=>$lampid,'longitude !='=>0,'latitude !='=>0); if (!empty($section)) { $where['section'] = $section; } $lampData = $this->Lamp_model->get_one($where,'longitude,latitude'); } if (!empty($projectid)) { $where = array('projectid'=>$projectid,'longitude !='=>0,'latitude !='=>0); if (!empty($section)) { $where['section'] = $section; } $lampData = $this->Lamp_model->get_one($where,'longitude,latitude'); } if (empty($lampData)) { $lampData = array('longitude'=>0,'latitude'=>0); } exit(json_result('0000',$this->response['0000'],$lampData)); } public function get_province(){ // $countryId = intval($this->input->post('countryId',true)); $role = $this->get_user_info('role'); $where = array(); if ($role != SYSTEM_ADMIN) { $company = $this->get_user_info('company'); $where['company'] = $company; } $pro_list = $this->Project_model->get_list($where,'cityid'); $cityArr = array_unique(array_column($pro_list, 'cityid')); $list = $this->Global_location_model->get_list(['id'=>$cityArr],'id,english_name as name,level,pid'); $areaList = array(); $cityList = array(); $proList = array(); foreach ($list as $key => $value) { if ($value['level'] == 2) { $proList[] = $value; }elseif ($value['level'] == 3) { $cityList[] = $value; }elseif ($value['level'] == 4) { $areaList[] = $value; } } if (!empty($areaList)) { $cityArr = array_unique(array_column($areaList, 'pid')); $list = $this->Global_location_model->get_list(['id'=>$cityArr],'id,english_name as name,level,pid'); foreach ($list as $key => $value) { if ($value['level'] == 2) { $proList[] = $value; }elseif ($value['level'] == 3) { $cityList[] = $value; } } } if (!empty($cityList)) { $cityArr = array_unique(array_column($cityList, 'pid')); $list = $this->Global_location_model->get_list(['id'=>$cityArr],'id,english_name as name,level,pid'); foreach ($list as $key => $value) { if ($value['level'] == 2) $proList[] = $value; } } if (empty($proList)) exit(json_result('0000',$this->response['0000'],array('list'=>array()))); $cityArr = array_unique(array_column($proList, 'id')); $list = $this->Global_location_model->get_list(['id'=>$cityArr],'id,english_name as name',null,null,'convert(english_name using gbk) ASC,id DESC'); exit(json_result('0000',$this->response['0000'],array('list'=>$list))); } public function get_city(){ $proId = intval($this->input->post('proId',true)); $role = $this->get_user_info('role'); $where = array(); if ($role != SYSTEM_ADMIN) { $company = $this->get_user_info('company'); $where['company'] = $company; } $pro_list = $this->Project_model->get_list($where,'cityid'); $cityArr = array_unique(array_column($pro_list, 'cityid')); $list = $this->Global_location_model->get_list(['id'=>$cityArr],'id,english_name as name,level,pid'); $areaList = array(); $cityList = array(); foreach ($list as $key => $value) { if ($value['level'] == 3) { $cityList[] = $value; }elseif ($value['level'] == 4) { $areaList[] = $value; } } if (!empty($areaList)) { $cityArr = array_unique(array_column($areaList, 'pid')); $list = $this->Global_location_model->get_list(['id'=>$cityArr],'id,english_name as name,level,pid'); foreach ($list as $key => $value) { if ($value['level'] == 3) $cityList[] = $value; } } if (empty($cityList)) exit(json_result('0000',$this->response['0000'],array('list'=>array()))); $cityArr = array_unique(array_column($cityList, 'id')); $where = ['id'=>$cityArr]; if (!empty($proId)) $where['pid'] = $proId; $list = $this->Global_location_model->get_list($where,'id,english_name as name',null,null,'convert(english_name using gbk) ASC,id DESC'); exit(json_result('0000',$this->response['0000'],array('list'=>$list))); } // 告警状态下拉列表 public function alarm_type_list(){ $version = $this->session->userdata('version'); $batstatus = $this->config->item('batstatus'); $panelstatus = $this->config->item('panelstatus'); $lampstatus = $this->config->item('lampstatus'); $tempstatus = $this->config->item('tempstatus'); $list = array(); foreach ($batstatus as $key => $value) { $list[] = ['name'=>$value,'value'=>'1'.$key]; } foreach ($panelstatus as $key => $value) { $list[] = ['name'=>$value,'value'=>'2'.$key]; } foreach ($lampstatus as $key => $value) { $list[] = ['name'=>$value,'value'=>'3'.$key]; } foreach ($tempstatus as $key => $value) { $list[] = ['name'=>$value,'value'=>'4'.$key]; } exit(json_result('0000',$this->response['0000'],$list)); } }