getDeviceCode($Data['companyid'],"1,3"); if (!empty($device_code_list)){ $ResData=M()->query("SELECT count(*) as hj FROM sp_hj2017 where device_code in(".$device_code_list.") and clzt='0'"); }else{ $ResData[0]['hj']= 0; } // $ResData=M()->query("SELECT count(a.id) as hj FROM sp_hj2017 as a join sp_owner as b ON a.device_code=b.owner_code WHERE b.dwtype in(1,3) and b.company='".$Map['company']."' and a.clzt='0'"); $this->assign('wcl', $ResData[0]['hj']); $this->assign('companyid', $Data['companyid']); $this->display('Index/fire'); } 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; $where=" and clzt='0' "; break; case 'treated': $Map['clzt'] = 1; $where=" and clzt='1' "; break; default: break; } $device = M()->query("SELECT owner_code,owner_name FROM sp_owner WHERE company in(".$Map['company'].") and dwtype in(1,3)"); if (!empty($device)){ $str = ""; foreach ($device as $val) { $str .= "'" . $val['owner_code'] . "',"; } $newstr = substr($str, 0, strlen($str) - 1); $ResData = M()->query("select data2 as ftype , time ,device_code ,clzt ,id ,data4 from sp_hj2017 WHERE device_code in(".$newstr.") ".$where." order by id desc limit ".$startpage.",".$size); if (!empty($ResData)){ foreach ($ResData as $key => $value){ foreach ($device as $key1=>$value1){ if ($ResData[$key]['device_code']==$device[$key1]['owner_code']){ $ResData[$key]['owner_name']=$device[$key1]['owner_name']; } } } } } // $ResData = M()->query("select a.data2 as ftype , a.time ,b.owner_name ,a.clzt ,a.id ,a.data4 from sp_hj2017 as a join sp_owner as b ON a.device_code=b.owner_code WHERE b.dwtype in(1,3) and b.company='".$Map['company']."' ".$where." order by a.id desc limit 500"); // $ResData = M('v_hj2017_2')->where($Map)->order("time desc")->limit(500)->select(); // $this->assign('ResData', $ResData); // $this->display('Index/fire-list'); echo json_encode($ResData); } //获取设备编号 public function getDeviceCode($company,$dwtype) { $device = M()->query("SELECT owner_code FROM sp_owner WHERE company in(".$company.") and dwtype in(".$dwtype.")"); $str = ""; foreach ($device as $val) { $str .= "'" . $val['owner_code'] . "',"; } $newstr = substr($str, 0, strlen($str) - 1); return $newstr; } //无用 public function change1() { $Data = I(''); $Map['company'] = $Data['companyid']; $type = $Data['type']; switch ($type) { case 'untreated': $ResData = M()->query("select sp_hj2017.time, sp_hj2017.data2, sp_owner.owner_name, sp_hj2017.clzt, sp_hj2017.id, sp_hj2017.data4 from sp_owner join sp_hj2017 on sp_owner.owner_code=sp_hj2017.device_code where company=" . $Map['company'] . " and clzt=0 order by time desc limit 500"); break; case 'treated': $ResData = M()->query("select sp_hj2017.time, sp_hj2017.data2, sp_owner.owner_name, sp_hj2017.clzt, sp_hj2017.id, sp_hj2017.data4 from sp_owner join sp_hj2017 on sp_owner.owner_code=sp_hj2017.device_code where company=" . $Map['company'] . " and clzt=1 order by time desc limit 500"); break; default: $ResData = M()->query("select sp_hj2017.time, sp_hj2017.data2, sp_owner.owner_name, sp_hj2017.clzt, sp_hj2017.id, sp_hj2017.data4 from sp_owner join sp_hj2017 on sp_owner.owner_code=sp_hj2017.device_code where company=" . $Map['company'] . " order by time desc limit 500"); break; } $this->assign('ResData', $ResData); $this->display('Index/fire-list'); } } ?>