|
@@ -12,6 +12,50 @@ class Home extends Base_Controller {
|
|
|
|
|
|
// 设备统计信息
|
|
|
public function data(){
|
|
|
+ $countryId = intval($this->input->post('countryId',true));
|
|
|
+ $proId = intval($this->input->post('proId',true));
|
|
|
+ $projectIdArr = array();
|
|
|
+ $areaList = array();
|
|
|
+ $cityList = array();
|
|
|
+ $proList = array();
|
|
|
+ $comList = array();
|
|
|
+ if (!empty($countryId)) {
|
|
|
+ $comList[] = array('id'=>$countryId,'level'=>1);
|
|
|
+ $list = $this->Global_location_model->get_list(['pid'=>$countryId],'id,level');
|
|
|
+ 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($proId)) {
|
|
|
+ $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) {
|
|
|
+ $cityList[] = $value;
|
|
|
+ }elseif ($value['level'] == 4) {
|
|
|
+ $areaList[] = $value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!empty($cityList)) {
|
|
|
+ $cityArr = array_unique(array_column($cityList, 'id'));
|
|
|
+ $list = $this->Global_location_model->get_list(['pid'=>$cityArr],'id,level');
|
|
|
+ foreach ($list as $key => $value) {
|
|
|
+ if ($value['level'] == 4) $areaList[] = $value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $cityArr = array_unique(array_merge(array_column($comList, 'id'),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'));
|
|
|
+ }
|
|
|
$data = array(
|
|
|
'day_new_count' => 0,
|
|
|
'day_faulty_count' => 0,
|
|
@@ -27,18 +71,29 @@ class Home extends Base_Controller {
|
|
|
$role = $this->get_user_info('role');
|
|
|
if ($role == SYSTEM_ADMIN) {
|
|
|
$data['total_light_count'] = $this->Lamp_model->get_count();
|
|
|
- $data['day_new_count'] = $this->Lamp_model->get_count(['createtime >='=>$date]);
|
|
|
+ $where = ['createtime >='=>$date];
|
|
|
+ if (!empty($projectIdArr)) $where['projectid'] = $projectIdArr;
|
|
|
+ $data['day_new_count'] = $this->Lamp_model->get_count($where);
|
|
|
|
|
|
- $data['day_faulty_count'] = $this->Lamp_model->get_count(['netstatus'=>1,'logtime >='=>$date,'devstatus !='=>0]);
|
|
|
+ $where = ['netstatus'=>1,'logtime >='=>$date,'devstatus !='=>0];
|
|
|
+ if (!empty($projectIdArr)) $where['projectid'] = $projectIdArr;
|
|
|
+ $data['day_faulty_count'] = $this->Lamp_model->get_count($where);
|
|
|
|
|
|
- $data['light_up_count'] = $this->Lamp_model->get_count(['netstatus'=>1,'status'=>1]);
|
|
|
+ $where = ['netstatus'=>1,'status'=>1];
|
|
|
+ if (!empty($projectIdArr)) $where['projectid'] = $projectIdArr;
|
|
|
+ $data['light_up_count'] = $this->Lamp_model->get_count($where);
|
|
|
|
|
|
- $data['online_count'] = $this->Lamp_model->get_count(['netstatus'=>1]);
|
|
|
+ $where = ['netstatus'=>1];
|
|
|
+ if (!empty($projectIdArr)) $where['projectid'] = $projectIdArr;
|
|
|
+ $data['online_count'] = $this->Lamp_model->get_count($where);
|
|
|
|
|
|
- $data['faulty_count'] = $this->Lamp_model->get_count(['netstatus'=>1,'devstatus !='=>0]);
|
|
|
+ $where = ['netstatus'=>1,'devstatus !='=>0];
|
|
|
+ if (!empty($projectIdArr)) $where['projectid'] = $projectIdArr;
|
|
|
+ $data['faulty_count'] = $this->Lamp_model->get_count($where);
|
|
|
}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']
|
|
|
];
|