CombustibleGasController.class.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace Home\Controller;
  3. use Think\Controller;
  4. class CombustibleGasController extends ComController{
  5. public function index()
  6. {
  7. $Data=I('');
  8. $ResData=M()->query("SELECT count(*) FROM sp_gas2020 a JOIN sp_owner b ON device_code=owner_code WHERE b.company=".$Data['companyid']." AND b.dwtype=131 and clzt=0;");
  9. $this->assign('gassl',$ResData);
  10. $this->assign('companyid',$Data['companyid']);
  11. $this->display('Index/combustible_gas_system');
  12. }
  13. public function change()
  14. {
  15. $Data=I('');
  16. $Map['company']=$Data['companyid'];
  17. $page = $Data['page'];
  18. $size = 20;
  19. $startpage=($page - 1) * 20;
  20. switch ($Data['type'])
  21. {
  22. case 'untreated':
  23. $Map['clzt']=0;
  24. $ResData=M()->query("select a.id,a.device_code,a.data1,a.clzt,a.time,d.owner_name from sp_gas2020 a join sp_owner d ON a.device_code=d.owner_code where company=".$Map['company']." AND clzt=".$Map['clzt']." order by a.time desc limit ".$startpage.",".$size);
  25. break;
  26. case 'treated':
  27. $Map['clzt']=1;
  28. $ResData=M()->query("select a.id,a.device_code,a.data1,a.clzt,a.time,d.owner_name from sp_gas2020 a join sp_owner d ON a.device_code=d.owner_code where company=".$Map['company']." AND clzt=".$Map['clzt']." order by a.time desc limit ".$startpage.",".$size);
  29. break;
  30. default:
  31. $ResData=M()->query("select a.id,a.device_code,a.data1,a.clzt,a.time,d.owner_name from sp_gas2020 a join sp_owner d ON a.device_code=d.owner_code where company=".$Map['company']." order by a.time desc limit ".$startpage.",".$size);//." and data1!='EF9'"
  32. break;
  33. }
  34. foreach ($ResData as $key=>$value){
  35. if ($ResData[$key]['data1']=='GS01'){
  36. $ResData[$key]['wtype']='可燃气体告警';
  37. }elseif ($ResData[$key]['data1']=='GS02'){
  38. $ResData[$key]['wtype']='电池电量低';
  39. }elseif ($ResData[$key]['data1']=='GS03'){
  40. $ResData[$key]['wtype']='设备防拆';
  41. }
  42. }
  43. echo json_encode($ResData);
  44. // $this->assign('ResData',$ResData);
  45. // $this->display('Index/combustible_gas-list');
  46. }
  47. }
  48. ?>