|
@@ -37,8 +37,8 @@ class Lampcontrol extends Base_Controller {
|
|
$pid_arr = $project_id;
|
|
$pid_arr = $project_id;
|
|
$timezone = $this->Project_model->get_timezone_by_projectid($project_id);
|
|
$timezone = $this->Project_model->get_timezone_by_projectid($project_id);
|
|
|
|
|
|
- // $filter = array('L.projectid'=>$project_id);
|
|
|
|
$filter = 'L.projectid = '.$project_id;
|
|
$filter = 'L.projectid = '.$project_id;
|
|
|
|
+ $countWhere = array('projectid = '.$project_id);
|
|
$network_id = $this->input->post('network_id', true);
|
|
$network_id = $this->input->post('network_id', true);
|
|
$section = $this->input->post('section', true);
|
|
$section = $this->input->post('section', true);
|
|
$type = intval($this->input->post('type', true));
|
|
$type = intval($this->input->post('type', true));
|
|
@@ -46,28 +46,32 @@ class Lampcontrol extends Base_Controller {
|
|
if (!empty($type) && !empty($company)) {
|
|
if (!empty($type) && !empty($company)) {
|
|
|
|
|
|
if ($type == 2) {
|
|
if ($type == 2) {
|
|
- // $filter['L.manu'] = $company;
|
|
|
|
$filter .= ' AND L.manu = '.$company;
|
|
$filter .= ' AND L.manu = '.$company;
|
|
|
|
+ $countWhere[] = 'manu = '.$company;
|
|
}elseif ($type == 3) {
|
|
}elseif ($type == 3) {
|
|
- // $filter['L.supplier'] = $company;
|
|
|
|
$filter .= ' AND L.supplier = '.$company;
|
|
$filter .= ' AND L.supplier = '.$company;
|
|
|
|
+ $countWhere[] = 'supplier = '.$company;
|
|
}elseif ($type == 4) {
|
|
}elseif ($type == 4) {
|
|
- // $filter['L.po'] = $company;
|
|
|
|
$filter .= ' AND L.po = '.$company;
|
|
$filter .= ' AND L.po = '.$company;
|
|
|
|
+ $countWhere[] = 'po = '.$company;
|
|
}else {
|
|
}else {
|
|
- // $filter['L.upazilla'] = $company;
|
|
|
|
- // $filter .= ' AND L.upazilla = '.$company;
|
|
|
|
$filter .= ' AND P.cityid = '.$company;
|
|
$filter .= ' AND P.cityid = '.$company;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- // if (!empty($section)) $filter['L.section'] = $section;
|
|
|
|
- if (!empty($section)) $filter .= ' AND L.section = "'.$section.'"';
|
|
|
|
|
|
+ if (!empty($section)) {
|
|
|
|
+ $filter .= ' AND L.section = "'.$section.'"';
|
|
|
|
+ $countWhere[] = 'section = "'.$section.'"';
|
|
|
|
+ }
|
|
$offline = $this->input->post('offline', true);
|
|
$offline = $this->input->post('offline', true);
|
|
- // if (!empty($offline)) $filter['L.netstatus'] = 0;
|
|
|
|
- if (!empty($offline)) $filter .= ' AND L.netstatus = 0';
|
|
|
|
|
|
+ if (!empty($offline)) {
|
|
|
|
+ $filter .= ' AND L.netstatus = 0';
|
|
|
|
+ $countWhere[] = 'netstatus = 0';
|
|
|
|
+ }
|
|
$online = $this->input->post('online', true);
|
|
$online = $this->input->post('online', true);
|
|
- // if (!empty($online)) $filter['L.netstatus'] = 1;
|
|
|
|
- if (!empty($online)) $filter .= ' AND L.netstatus= 1';
|
|
|
|
|
|
+ if (!empty($online)) {
|
|
|
|
+ $filter .= ' AND L.netstatus= 1';
|
|
|
|
+ $countWhere[] = 'netstatus = 1';
|
|
|
|
+ }
|
|
|
|
|
|
// 分页数据
|
|
// 分页数据
|
|
$page = intval($this->input->post('page',true));
|
|
$page = intval($this->input->post('page',true));
|
|
@@ -77,8 +81,10 @@ class Lampcontrol extends Base_Controller {
|
|
$offset = ($page - 1)*$count;
|
|
$offset = ($page - 1)*$count;
|
|
|
|
|
|
$keyword = $this->input->post('keyword', true);
|
|
$keyword = $this->input->post('keyword', true);
|
|
- // 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.'%")';
|
|
|
|
|
|
+ if ($keyword !== '' && $keyword !== null) {
|
|
|
|
+ $filter .= ' AND (L.number like "%'.$keyword.'%" OR L.section like "%'.$keyword.'%" OR L.address like "%'.$keyword.'%")';
|
|
|
|
+ $countWhere[] = '(number like "%'.$keyword.'%" OR section like "%'.$keyword.'%" OR address like "%'.$keyword.'%")';
|
|
|
|
+ }
|
|
|
|
|
|
$status = $this->input->post('status', true);
|
|
$status = $this->input->post('status', true);
|
|
if (!empty($status)) {
|
|
if (!empty($status)) {
|
|
@@ -362,11 +368,24 @@ class Lampcontrol extends Base_Controller {
|
|
}
|
|
}
|
|
// unset($filter['page']);
|
|
// unset($filter['page']);
|
|
// unset($filter['count']);
|
|
// 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));
|
|
|
|
-
|
|
|
|
- $data['total_data']['fault_count'] = $this->Lamp_model->get_fault_count(array('L.projectid'=>$project_id,'L.isfaulted'=>1,'AI.status'=>0), $role, '', $userid,$project_id);
|
|
|
|
|
|
+ $countWheret1 = implode(' AND ', $countWhere);
|
|
|
|
+ $data['total_data']['install_num'] = $this->Lamp_model->get_count($countWheret1);
|
|
|
|
+ $countWheret = $countWhere;
|
|
|
|
+ $countWheret[] = 'status = 1';
|
|
|
|
+ $countWheret[] = 'netstatus = 1';
|
|
|
|
+ $countWheret1 = implode(' AND ', $countWheret);
|
|
|
|
+ $data['total_data']['light_num'] = $this->Lamp_model->get_count($countWheret1);
|
|
|
|
+ $countWheret = $countWhere;
|
|
|
|
+ $countWheret[] = 'netstatus = 1';
|
|
|
|
+ $countWheret1 = implode(' AND ', $countWhere);
|
|
|
|
+ $data['total_data']['online_num'] = $this->Lamp_model->get_count($countWheret1);
|
|
|
|
+
|
|
|
|
+ $filter2 = $filter.' AND (AI.batstatus != 0 OR AI.panelstatus != 0 OR AI.lampstatus != 0 OR AI.tempstatus != 0)';
|
|
|
|
+ $join = array();
|
|
|
|
+ $join2[] = ['table'=>'(select lampid,max(updatetime) as maxTime from warning_info_log group by lampid) as WI','cond'=>'WI.lampid = L.id','type'=>'inner'];
|
|
|
|
+ $join2[] = ['table'=>'warning_info_log as AI','cond'=>'WI.lampid = AI.lampid AND WI.maxTime = AI.updatetime','type'=>'inner'];
|
|
|
|
+ $res = $this->Lamp_model->get_list_by_multi_join($filter2, 'count(*) total',null, null, $join2, "L.number ASC", NUll, 'L',true);
|
|
|
|
+ $data['total_data']['fault_count'] = $res['total'];
|
|
$data['total_data']['light_rate'] = empty($data['total_data']['install_num']) ? '0' : round($data['total_data']['light_num']/$data['total_data']['install_num'],4)*100;
|
|
$data['total_data']['light_rate'] = empty($data['total_data']['install_num']) ? '0' : round($data['total_data']['light_num']/$data['total_data']['install_num'],4)*100;
|
|
$data['total_data']['light_rate'] .= '%';
|
|
$data['total_data']['light_rate'] .= '%';
|
|
$data['total_data']['online_rate'] = empty($data['total_data']['install_num']) ? '0' : round($data['total_data']['online_num']/$data['total_data']['install_num'],4)*100;
|
|
$data['total_data']['online_rate'] = empty($data['total_data']['install_num']) ? '0' : round($data['total_data']['online_num']/$data['total_data']['install_num'],4)*100;
|
|
@@ -1230,6 +1249,46 @@ class Lampcontrol extends Base_Controller {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 新控制器更新蓄电池设置
|
|
|
|
+ public function modbus_set_battery(){
|
|
|
|
+ $data['username'] = $this->input->post('username',true);
|
|
|
|
+ $data['client_key'] = $this->input->post('client_key',true);
|
|
|
|
+ $data['token'] = $this->input->post('token',true);
|
|
|
|
+ $lamp_id = $this->input->post('lamp_id',true);
|
|
|
|
+ $data['clientid'] = $this->input->post('clientid',true);
|
|
|
|
+ $data['role'] = $this->input->post('role',true);
|
|
|
|
+ $data['version'] = $this->session->userdata('version');
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $data['battery_type'] = $this->input->post('battery_type',true); //蓄电池类型
|
|
|
|
+ $data['system_voltage'] = $this->input->post('system_voltage',true); // 电池电压
|
|
|
|
+ $data['overvoltage'] = $this->input->post('overvoltage',true); // 超压电压
|
|
|
|
+ $data['char_limit_voltage'] = $this->input->post('char_limit_voltage',true); // 充电限制电压
|
|
|
|
+ $data['equ_char_voltage'] = $this->input->post('equ_char_voltage',true); // 均衡充电电压
|
|
|
|
+ $data['increa_char_voltage'] = $this->input->post('increa_char_voltage',true); // 提升充电电压
|
|
|
|
+ $data['float_char_voltage'] = $this->input->post('float_char_voltage',true); // 浮充充电电压
|
|
|
|
+ $data['increa_char_return_voltage'] = $this->input->post('increa_char_return_voltage',true); // 提升充电返回电压
|
|
|
|
+ $data['over_dischar_return_voltage'] = $this->input->post('over_dischar_return_voltage',true); // 过放返回电压
|
|
|
|
+ $data['over_dischar_voltage'] = $this->input->post('over_dischar_voltage',true); // 过放电压
|
|
|
|
+ $data['equ_char_time'] = $this->input->post('equ_char_time',true) * 60; // 均衡充电时间
|
|
|
|
+ $data['increa_char_time'] = $this->input->post('increa_char_time',true) * 60; // 提升充电时间
|
|
|
|
+ $data['balan_char_interval'] = $this->input->post('balan_char_interval',true); // 均衡充电间隔
|
|
|
|
+ $data['temper_compen_coeff'] = $this->input->post('temper_compen_coeff',true); // 温度补偿系数
|
|
|
|
+ $data['char_upper_limit_temper'] = $this->input->post('char_upper_limit_temper',true); // 上限温度
|
|
|
|
+ $data['char_lower_limit_temper'] = $this->input->post('char_lower_limit_temper',true); // 下限温度
|
|
|
|
+ $data['light_voltage'] = $this->input->post('light_voltage',true); // 光控电压
|
|
|
|
+
|
|
|
|
+ $lampArr = explode(',', $lamp_id);
|
|
|
|
+ // $lampList = $this->Lamp_model->get_list_in('L.id', $lampArr, 'L.id,N.protocoltype', array());
|
|
|
|
+ $url = $_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['SERVER_NAME'].'/api/device/modbus_set_battery_asy';
|
|
|
|
+
|
|
|
|
+ foreach ($lampArr as $l) {
|
|
|
|
+ $data['lampid'] = $l;
|
|
|
|
+ doAsyncRequest($url,$data);
|
|
|
|
+ }
|
|
|
|
+ exit();
|
|
|
|
+ }
|
|
|
|
+
|
|
// public function set_battery_asy(){
|
|
// public function set_battery_asy(){
|
|
// $res = $this->battery_update();
|
|
// $res = $this->battery_update();
|
|
// $clientid = $this->input->post('clientid',true);
|
|
// $clientid = $this->input->post('clientid',true);
|