FireHydrantController.class.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace Home\Controller;
  3. use Think\Controller;
  4. //include '../Common/function.php';
  5. class FireHydrantController extends ComController {
  6. public function index()
  7. {
  8. $Data=I();
  9. $ResData=M()->query("SELECT count(a.id) as sl FROM sp_sj2017 a JOIN sp_owner b ON a.device_code=b.owner_code WHERE b.company=".$Data['companyid']." AND b.dwtype='4' and a.clzt=0;");
  10. $this->assign('wcl',$ResData[0]['sl']);
  11. $this->assign('companyid',$Data['companyid']);
  12. $this->display('Index/fire_hydrant');
  13. }
  14. public function change()
  15. {
  16. $Data=I('');
  17. // print_r($Data);exit();
  18. $page = $Data['page'];
  19. $size = 20;
  20. $startpage=($page - 1) * 20;
  21. switch ($Data['type'])
  22. {
  23. case 'untreated':
  24. $sql = "select a.id,a.data1,a.time,b.owner_name,a.clzt from sp_sj2017 a join sp_owner b on a.device_code=b.owner_code where b.company=".$Data['companyid']." and b.dwtype='4' and a.clzt=0 order by time desc limit ".$startpage.",".$size;
  25. break;
  26. case 'treated':
  27. $sql = "select a.id,a.data1,a.time,b.owner_name,a.clzt from sp_sj2017 a join sp_owner b on a.device_code=b.owner_code where b.company=".$Data['companyid']." and b.dwtype='4' and a.clzt=1 order by time desc limit ".$startpage.",".$size;
  28. break;
  29. default:
  30. $sql = "select a.id,a.data1,a.time,b.owner_name,a.clzt from sp_sj2017 a join sp_owner b on a.device_code=b.owner_code where b.company=".$Data['companyid']." and b.dwtype='4' order by time desc limit ".$startpage.",".$size;
  31. break;
  32. }
  33. // print_r($sql);exit();
  34. $ResData=M()->query($sql);
  35. // print_r($ResData);exit();
  36. // $this->assign('ResData',$ResData);
  37. // $this->display('Index/fire_hydrant-list');
  38. // $ResData[0]['totalCount'] = count($ResData);
  39. echo json_encode($ResData);
  40. }
  41. }
  42. ?>