query("select count(*) as sl from sp_v_rtu2017_2 where company='10215' AND wtype not LIKE '%离线%' and clzt=0"); $ResData2=M()->query("select count(*) as sl from sp_v_rtu2017_2 where company='10215' AND wtype LIKE '%离线%' AND time < '2021-03-10' and clzt=0"); if (empty($ResData1)){ $ResData1[0]['sl']=0; } if (empty($ResData2)){ $ResData2[0]['sl']=0; } $ResData=$ResData1[0]['sl']+$ResData2[0]['sl']; }else{ // $ResData=M('v_rtu2017_2')->where($Map)->count('id'); $ResData3 = M()->query("SELECT count(*) as sl FROM sp_rtu2017 as a JOIN sp_owner AS b ON a.device_code=b.owner_code where company='".$Data['companyid']."' and clzt='0' and dwtype=6 order by a.id desc limit 1000"); $ResData=$ResData3[0]['sl']; } $this->assign('wjcn',$ResData); $this->assign('companyid',$Data['companyid']); $this->display('Index/measure'); } public function change() { $Data = I(''); $page = $Data['page']; $size = 20; $startpage=($page - 1) * 20; $Map['company'] = $Data['companyid']; switch ($Data['type']) { case 'untreated': $Map['clzt'] = 0; $clzt=' and clzt=0 '; break; case 'treated': $Map['clzt'] = 1; $clzt=' and clzt=1 '; break; default: break; } if ($Data['companyid']==10215){ $ResData = M()->query("SELECT * from sp_v_rtu2017_2 where company='10215' AND wtype LIKE '%离线%' AND time < '2021-03-10' ".$clzt." UNION all(SELECT * from sp_v_rtu2017_2 where company='10215' AND wtype NOT LIKE '%离线%' ".$clzt.") ORDER BY time DESC limit ".$startpage.",".$size); }else{ // $ResData = M('v_rtu2017_2')->where($Map)->order("id desc")->limit(1000)->select(); $ResData = M()->query("SELECT a.*,b.dwtype,b.owner_name,b.company,concat(a.data4,',',a.data2) AS wtype FROM sp_rtu2017 as a JOIN sp_owner AS b ON a.device_code=b.owner_code where b.company='".$Map['company']."' ".$clzt." and b.dwtype=6 order by a.id desc limit ".$startpage.",".$size); } // print_r($ResData);exit(); // $this->assign('ResData', $ResData); // $this->display('Index/measure-list'); echo json_encode($ResData); } }