query("select owner_code, owner_name, unitinfo, sim, install_time,rtmp,hls from sp_owner where owner_code='".$Data['deviceid']."'"); $owner_address=M()->query("select owner_address from sp_owner_company where owner_id='".$Data['companyid']."'"); $gzsj=M()->query("select data4,time from sp_video2017 where device_code='".$Data['deviceid']."' order by time desc"); if ( !empty($owner_xx[0]['rtmp']) ){ $owner_xx[0]['rtmp']=$owner_xx[0]['rtmp']; }else{ $owner_xx[0]['rtmp']='     无'; } // print_r($owner_xx); $this->assign('type_name',"视频监控"); $this->assign('type',"video"); $this->assign('companyid',$Data['companyid']); $this->assign('owner_xx',$owner_xx); $this->assign('owner_address',$owner_address); $this->assign('gzsj',$gzsj); $this->display('Index/05'); }else if ($Data['dwtype']==17){ $owner_xx=M()->query("select owner_code, owner_name, unitinfo, sim, install_time,rtmp,hls from sp_owner where owner_code='".$Data['deviceid']."'"); $owner_address=M()->query("select owner_address from sp_owner_company where owner_id='".$Data['companyid']."'"); $gzsj=M()->query("select data4,time from sp_lifter2017 where device_code='".$Data['deviceid']."' order by time desc"); if ( !empty($owner_xx[0]['rtmp']) ){ $owner_xx[0]['rtmp']=$owner_xx[0]['rtmp']; }else{ $owner_xx[0]['rtmp']='     无'; } // print_r($owner_xx); $this->assign('type_name',"电梯监控"); $this->assign('type',"elevator"); $this->assign('companyid',$Data['companyid']); $this->assign('owner_xx',$owner_xx); $this->assign('owner_address',$owner_address); $this->assign('gzsj',$gzsj); $this->display('Index/05'); }else if ($Data['dwtype']==4){ $owner_xx=M()->query("select owner_code, owner_name, unitinfo, sim, install_time,rtmp,hls from sp_owner where owner_code='".$Data['deviceid']."'"); $owner_address=M()->query("select owner_address from sp_owner_company where owner_id='".$Data['companyid']."'"); $gzsj=M()->query("select data4,time from sp_d".$Data['deviceid']." where device_code='".$Data['deviceid']."' order by time desc"); if ( !empty($owner_xx[0]['rtmp']) ){ $owner_xx[0]['rtmp']=$owner_xx[0]['rtmp']; }else{ $owner_xx[0]['rtmp']='     无'; } $this->assign('type_name',"消防栓监控"); $this->assign('type',"firehydrant"); $this->assign('companyid',$Data['companyid']); $this->assign('owner_xx',$owner_xx); $this->assign('owner_address',$owner_address); $this->assign('gzsj',$gzsj); $this->display('Index/05'); } else if ($Data['dwtype']==128){ $owner_xx=M()->query("select owner_code, owner_name, unitinfo, sim, install_time,rtmp,hls from sp_owner where owner_code='".$Data['deviceid']."'"); $owner_address=M()->query("select owner_address from sp_owner_company where owner_id='".$Data['companyid']."'"); $gzsj=M()->query("select device_status,time from sp_iw2017 where device_code='".$Data['deviceid']."' order by time desc"); if ( !empty($owner_xx[0]['rtmp']) ){ $owner_xx[0]['rtmp']=$owner_xx[0]['rtmp']; }else{ $owner_xx[0]['rtmp']='     无'; } if ($gzsj[0]['device_status']){ $gzsj[0]['data4']='正常'; }else{ $gzsj[0]['data4']='打开告警'; } $this->assign('type_name',"井盖监控"); $this->assign('type',"firehydrant"); $this->assign('companyid',$Data['companyid']); $this->assign('owner_xx',$owner_xx); $this->assign('owner_address',$owner_address); $this->assign('gzsj',$gzsj); $this->display('Index/05'); }else{ $res=M()->query("SELECT * FROM sp_v_deviceall WHERE deviceid='".$Data['deviceid']."'"); $azwz=M()->query("select unitinfo from sp_owner where owner_code='".$Data['deviceid']."'"); $res[0]['azwz']=$azwz[0]['unitinfo']; //在线离线权限问题 $login_phone=M()->query("SELECT * FROM sp_login_phone"); $phone_arr=array(); foreach ($login_phone as $key=>$value){ $phone_arr[$key]=$login_phone[$key]['phone']; } // print_r($phone_arr); // print_r('手机'.$_SESSION['phone']); $phone=$_SESSION['phone']; // print_r($_SESSION); $isin = in_array($phone,$phone_arr); // print_r('aaa'+$isin); if ($isin){ $phone_pd=1; }else{ $phone_pd=0; } $time=M()->query("SELECT device_id,MAX(data_time) as data_time FROM sp_owner_status WHERE device_id='".$Data['deviceid']."'"); if (!empty($time)){ // print_r($time[0]['data_time'].'时间2'.date('Y-m-d h:i:s', time())); $stime=date('Y-m-d h:i:s', time()); $etime=$time[0]['data_time']; $hour=intval((strtotime($stime)-strtotime($etime))/3600); // $hour=floor((strtotime(date('Y-m-d h:i:s', time()))-strtotime($time[0]['data_time']))%86400/3600); // print_r($hour); if ($hour<24){ $zs_status='在线'; }else{ $zs_status='离线'; } }else{ $zs_status='状态不存在'; } // print_r($zs_status); if ($res[0]['dwtype']!=1){ if ($phone_pd==1){ $res[0]['zs_status']=$zs_status; } } if ( !empty($res[0]['rtmp']) ){ // $res[0]['rtmp']=''; $res[0]['rtmp']=$res[0]['rtmp']; }else{ $res[0]['rtmp']='     无'; } $this->assign('list',$res[0]); $this->assign('companyid',$Data['companyid']); // if($_SESSION['idphone']=='15000012454'){ $dwtype=$res[0]['dwtype']; $deviceid=$Data['deviceid']; if ($dwtype==1) { $j2017=M('hj2017'); $counts= $j2017->order('time desc')->where(array('device_code'=>$deviceid))->count('id');//总数 $j_counts= $j2017->where(array('device_code'=>$deviceid,'clzt'=>'1'))->count('id');//解决总数 $d_counts= $j2017->where(array('device_code'=>$deviceid,'clwb'=>'否'))->count('id');//真实总数 $w_counts= $j2017->where(array('device_code'=>$deviceid,'clwb'=>'是'))->count('id');//wb总数 $this->assign('counts',$counts); $this->assign('j_counts',$j_counts); $this->assign('z_counts',$d_counts); $this->assign('w_counts',$w_counts); $this->display('Index/04-01'); } if ($dwtype==2) { // $j2017=M('sj2017'); // $shui=$j2017->query("SELECT time,IF(ISNULL(data4),0,data4) as data4 FROM sp_d".$deviceid." where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(time) ORDER BY time DESC"); $shui=M()->query("select * from sp_owner_sync_data where device_id='".$Data['deviceid']."' and point_code=4 order by data_time desc"); $electric_data=M()->query("select point_data from sp_owner_sync_data where device_id='".$Data['deviceid']."' and point_code=2 order by data_time desc"); $signal_data=M()->query("select point_data from sp_owner_sync_data where device_id='".$Data['deviceid']."' and point_code=3 order by data_time desc"); $a=array();$b=array();$electric=array();$signal=array(); foreach ($shui as $value) { $a[]=$value['data_time']; $b[]=$value['point_data']; } foreach ($electric_data as $value){ $electric[]= $value['point_data']; } foreach ($signal_data as $value){ $signal[]= $value['point_data']*20; } //$bb=$shui[count($shui)-1]; $bb=$shui[0]; $this->assign('bb',$bb['point_data']); $this->assign('dwtype',2); $this->assign('time',json_encode($a)); $this->assign('data4',json_encode($b)); $this->assign('electric',json_encode($electric)); $this->assign('signal',json_encode($signal)); $this->display('Index/04-02'); } if ($dwtype==3) { //$j2017=M('sj2017'); // $fume=$j2017->query("SELECT time,IF(ISNULL(data3),0,data3) as data3 FROM sp_y".$deviceid." where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(time) ORDER BY time DESC limit 10"); $fume = M()->query("select RSRQ, DeviceStatus, BatteryLevel, storeTime, device_id from sp_y".$deviceid." ORDER BY storeTime DESC limit 1"); $a = M()->query("select dwtype, sim,install_time,rtmp,hls from sp_owner where owner_code='".$deviceid."'"); if($a[0]['dwtype']==3){ $a[0]['dwtype']='烟感'; } if ( !empty($a[0]['rtmp']) ){ $a[0]['rtmp']=$a[0]['rtmp']; }else{ $a[0]['rtmp']='     无'; } foreach ($fume as $key=>$arr){ if ($fume[$key]['devicestatus']==7){ $fume[$key]['type']='正常'; }else if ($fume[$key]['devicestatus']==5){ $fume[$key]['type']='故障'; }else if ($fume[$key]['devicestatus']==4){ $fume[$key]['type']='低压'; }else if ($fume[$key]['devicestatus']==2){ $fume[$key]['type']='报警静音'; }else if ($fume[$key]['devicestatus']==1){ $fume[$key]['type']='报警'; } } // print_r($fume); // print_r($a);exit(); $this->assign('a', $a); $this->assign('fume', $fume); $this->display('Index/03-3'); } //液位 if ($dwtype==5) { $shui=M()->query("select * from sp_owner_sync_data where device_id='".$Data['deviceid']."' and point_code=4 order by data_time desc"); // $j2017=M('yj2017'); // $shui=$j2017->query("SELECT time,IF(ISNULL(data3),0,data4) as data4 FROM sp_d".$deviceid." where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(time) ORDER BY time DESC"); // $a=array();$b=array(); // foreach ($shui as $value) { // $a[]=$value['time']; // $b[]=$value['data4']; // } // $bb=$b[0]; // $this->assign('bb',$b[0]); $a=array();$b=array(); foreach ($shui as $value) { $a[]=$value['data_time']; $b[]=$value['point_data']; } //$bb=$shui[count($shui)-1]; // print_r($bb); $bb=$shui[0]; $this->assign('bb',$bb['point_data']); $this->assign('dwtype',5); $this->assign('time',json_encode($a)); $this->assign('data4',json_encode($b)); $this->display('Index/04-08'); } if ($dwtype==6) { //$rtu=M()->query("SELECT * FROM sp_d".$Data['id']." WHERE id in(SELECT MAX(id) FROM sp_d".$Data['id']." GROUP BY ncmd) AND ncmd !=''"); //$rtu=M()->query("SELECT * FROM sp_rtu2017 WHERE id in(SELECT MAX(id) FROM sp_rtu2017 GROUP BY device_code,ncmd,`port`) AND device_code='".$Data['id']."' AND ncmd !='' ORDER BY time DESC"); $rtu=M()->query("SELECT id,data4,ncmd,`time`,data1,data2,CASE WHEN `port`='E6' THEN '模拟量' WHEN `port`='E3' THEN '开关量' END as types FROM sp_d".$deviceid." WHERE id in(SELECT MAX(id) FROM sp_d".$deviceid." GROUP BY `port`,ncmd) AND ncmd !='' " .(($deviceid=='4023363030303635')?" AND (ncmd !='02' OR `port`!='E6') ": (($deviceid=='4023363030303639')?" AND (ncmd !='03' OR `port`!='E6') ": (($deviceid=='4023363030303434')?" AND (ncmd !='04' OR `port`!='E3') AND (ncmd !='05' OR `port`!='E3')": (($deviceid=='4023363030303336')? " AND (ncmd !='01' OR `port`!='E6') ": (($deviceid=='4023363030303733')?" AND (ncmd !='05' AND ncmd !='06' )":"")))))//山海大酒店B1楼水泵房02端口模拟量因设备故障,暂时屏蔽 ); // foreach ($rtu as $key=>$value){ // if ($rtu[$key]['ncmd']=='01'|| $rtu[$key]['ncmd']=='02'|| $rtu[$key]['ncmd']=='03'|| $rtu[$key]['ncmd']=='04'|| $rtu[$key]['ncmd']=='05' // ||$rtu[$key]['ncmd']=='06'||$rtu[$key]['ncmd']=='07'|| $rtu[$key]['ncmd']=='07'|| $rtu[$key]['ncmd']=='08'||$rtu[$key]['ncmd']=='09'){ // $rtu[$key]['ncmd']='0'.hexdec($rtu[$key]['ncmd']); // }else{ // $rtu[$key]['ncmd']=hexdec($rtu[$key]['ncmd']); // } // // } $this->assign('rtu',$rtu); // dump($rtu); $res=M()->query("SELECT systype FROM sp_owner_port where owner_code='".$deviceid."'"); $this->assign("trues",'0'.$res[0]['systype']); $this->display('Index/04-03'); } // 电气火灾 if($dwtype==7){ $install_time=M()->query("select install_time,rtmp,hls,owner_name,sim from sp_owner where owner_code='".$Data['deviceid']."'"); $owner_address=M()->query("select owner_address from sp_owner_company where owner_id=".$Data['companyid']); $true_status=M()->query("select true_status from sp_devices_status where deviceid=".$Data['deviceid']); $xssj=M()->query("select * from sp_owner_status where device_id='".$Data['deviceid']."'"); $zxsj=M()->query("select max(data_time) as zxsj from sp_owner_status where device_id='".$Data['deviceid']."'"); if($true_status[0]['true_status']=='75'){ $dstatus='离线'; }else{ $dstatus='在线'; } if ( !empty($install_time[0]['rtmp']) ){ $install_time[0]['rtmp']=$install_time[0]['rtmp']; }else{ $install_time[0]['rtmp']='     无'; } $data=array( 'owner_name' => $install_time[0]['owner_name'], 'dstatus' => $dstatus, 'dthz' => '电气火灾', 'deviceid' => $Data['deviceid'], 'sim' => $install_time[0]['sim'], 'install_time' => $install_time[0]['install_time'], 'owner_address' => $owner_address[0]['owner_address'], 'rtmp' => $install_time[0]['rtmp'], 'hls' => $install_time[0]['hls'], ); $this->assign('xssj',$xssj); $this->assign('zxsj',$zxsj); $this->assign('data',$data); $this->display('Index/04-04'); } } } }