|
@@ -18,7 +18,7 @@ class Home extends Base_Controller {
|
|
|
$cityList = array();
|
|
|
$proList = array();
|
|
|
if (!empty($proId)) {
|
|
|
- $proList[] = array('id'=>$proId,'level'=>1);
|
|
|
+ $proList[] = array('id'=>$proId,'level'=>2);
|
|
|
$list = $this->Global_location_model->get_list(['pid'=>$proId],'id,level');
|
|
|
foreach ($list as $key => $value) {
|
|
|
if ($value['level'] == 3) {
|
|
@@ -29,7 +29,11 @@ class Home extends Base_Controller {
|
|
|
}
|
|
|
}
|
|
|
if (!empty($cityId)) {
|
|
|
- $cityList[] = array('id'=>$cityId,'level'=>2);
|
|
|
+ $areaList = array();
|
|
|
+ $cityList = array(['id'=>$cityId,'level'=>3]);
|
|
|
+ }
|
|
|
+ if (!empty($cityList)){
|
|
|
+ $cityId = array_unique(array_filter(array_column($cityList, 'id')));
|
|
|
$list = $this->Global_location_model->get_list(['pid'=>$cityId],'id,level');
|
|
|
foreach ($list as $key => $value) {
|
|
|
if ($value['level'] == 4) $areaList[] = $value;
|
|
@@ -41,6 +45,7 @@ class Home extends Base_Controller {
|
|
|
$res = $this->Project_model->get_list(['cityid'=>$cityArr],'id');
|
|
|
$projectIdArr = array_unique(array_column($res, 'id'));
|
|
|
}
|
|
|
+
|
|
|
return $projectIdArr;
|
|
|
}
|
|
|
|
|
@@ -62,9 +67,12 @@ class Home extends Base_Controller {
|
|
|
|
|
|
$role = $this->get_user_info('role');
|
|
|
if ($role == SYSTEM_ADMIN) {
|
|
|
- $data['total_light_count'] = $this->Lamp_model->get_count();
|
|
|
+ $where = [];
|
|
|
+ if (!empty($projectIdArr)) $where['projectid'] = $projectIdArr;
|
|
|
+ $data['total_light_count'] = $this->Lamp_model->get_count($where);
|
|
|
$where = ['createtime >='=>$date];
|
|
|
if (!empty($projectIdArr)) $where['projectid'] = $projectIdArr;
|
|
|
+
|
|
|
$data['day_new_count'] = $this->Lamp_model->get_count($where);
|
|
|
|
|
|
$where = ['netstatus'=>1,'status'=>1];
|
|
@@ -238,9 +246,12 @@ class Home extends Base_Controller {
|
|
|
// $where[] = 'L.upazilla != ""';
|
|
|
}
|
|
|
|
|
|
+ // $cityId = $this->input->post('cityId',true);
|
|
|
+ // $proId = $this->input->post('proId',true);
|
|
|
+
|
|
|
if (!empty($projectIdArr)) $where[] = 'L.projectid in ('.implode(',', $projectIdArr).')';
|
|
|
$where1 = empty($where) ? '' : 'where '.implode(' AND ', $where);
|
|
|
- $query = 'select t1.total,C.name,C.id,t1.id as cityid,t1.company from (select count(*) as total,'.$fields.' from lampinfo AS L left join project AS P on P.id = L.projectid left join global_location G on P.cityid = G.id '.$where1.' '.$group.') as t1 left join company as C on t1.company = C.id order by total DESC limit 10';
|
|
|
+ $query = 'select t1.total,C.name,C.no,C.id,t1.id as cityid,t1.company from (select count(*) as total,'.$fields.' from lampinfo AS L left join project AS P on P.id = L.projectid left join global_location G on P.cityid = G.id '.$where1.' '.$group.') as t1 left join company as C on t1.company = C.id order by total DESC limit 10';
|
|
|
// var_dump($query);
|
|
|
$list = $this->db->query($query)->result_array();
|
|
|
// var_dump($list);die;
|
|
@@ -249,6 +260,7 @@ class Home extends Base_Controller {
|
|
|
$allDev = array_sum(array_column($list, 'total'));
|
|
|
foreach ($list as $key => $value) {
|
|
|
$totalPer = empty($allDev) ? '0%' : round($value['total']/$allDev*100,2).'%';
|
|
|
+ $value['name'] = empty($value['no']) ? $value['name'] : $value['no'];
|
|
|
$temp2 = array('name'=>$value['name'],'total'=>$value['total'],'onlineCount'=>0,'offlineCount'=>0,'faultCount'=>0,'totalPer'=>$totalPer);
|
|
|
if ($type == 5) {
|
|
|
$temp2['name'] = $value['company'];
|