DmangerController.class.php 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace Home\Controller;
  3. use Think\Controller;
  4. class DmangerController extends ComController {
  5. public function index()
  6. { $Data=I();
  7. $firezs=M()->query("SELECT count(*) as zs FROM sp_owner where dwtype=1 AND company=".$Data['companyid']);
  8. $waterzs=M()->query("SELECT count(*) as zs FROM sp_owner where dwtype in(2,5) AND company=".$Data['companyid']);
  9. $fumezs=M()->query("SELECT count(*) as zs FROM sp_owner where dwtype=3 AND company=".$Data['companyid']);
  10. $rtuzs=M()->query("SELECT count(*) as zs FROM sp_owner where dwtype=6 AND company=".$Data['companyid']);
  11. $efirezs=M()->query("SELECT count(*) as zs FROM sp_owner where dwtype=7 AND company=".$Data['companyid']);
  12. $videozs=M()->query("SELECT count(*) as zs FROM sp_owner where dwtype=16 AND company=".$Data['companyid']);
  13. $elevatorzs=M()->query("SELECT count(*) as zs FROM sp_owner where dwtype=17 AND company=".$Data['companyid']);
  14. $firehydrant=M()->query("SELECT count(*) as zs FROM sp_owner where dwtype=4 AND company=".$Data['companyid']);
  15. $wellcover=M()->query("SELECT count(*) as zs FROM sp_owner where dwtype=128 AND company=".$Data['companyid']);
  16. $typezs=array();
  17. $typezs['firezs']=$firezs[0]['zs'];
  18. $typezs['waterzs']=$waterzs[0]['zs'];
  19. $typezs['fumezs']=$fumezs[0]['zs'];
  20. $typezs['rtuzs']=$rtuzs[0]['zs'];
  21. $typezs['efirezs']=$efirezs[0]['zs'];
  22. $typezs['videozs']=$videozs[0]['zs'];
  23. $typezs['elevatorzs']=$elevatorzs[0]['zs'];
  24. $typezs['firehydrant']=$firehydrant[0]['zs'];
  25. $typezs['wellcover']=$wellcover[0]['zs'];
  26. $this->assign('typezs',$typezs);
  27. $this->assign('companyid',$Data['companyid']);
  28. $this->display('Index/device_manger');
  29. }
  30. public function change()
  31. {
  32. $Data=I('');
  33. $Map['company']=$Data['companyid'];
  34. switch ($Data['type'])
  35. {
  36. case 'fire':
  37. $Map['dwtype']=1;
  38. break;
  39. case 'water':
  40. $Map['dwtype']=array('in','2,5');
  41. break;
  42. case 'fume':
  43. $Map['dwtype']=3;
  44. break;
  45. case 'rtu':
  46. $Map['dwtype']=6;
  47. break;
  48. case 'efire':
  49. $Map['dwtype']=7;
  50. $ResData=M()->query("SELECT a.owner_code, a.owner_name, a.company, b.true_status,a.dwtype FROM sp_owner a INNER JOIN sp_devices_status b ON a.owner_code=b.deviceid where dwtype=7 AND company=".$Map['company']);
  51. // print_r($ResData);
  52. foreach ($ResData as $key=>$value){
  53. if($ResData[$key]['true_status']=='75'){
  54. $ResData[$key]['dstatus']='离线';
  55. }else{
  56. $ResData[$key]['dstatus']='在线';
  57. }
  58. }
  59. break;
  60. case 'video':
  61. $Map['dwtype']=16;
  62. $ResData=M()->query("SELECT owner_code, owner_name, company, dwtype FROM sp_owner where dwtype=16 AND company=".$Map['company']);
  63. break;
  64. case 'elevator':
  65. $Map['dwtype']=17;
  66. // print_r("SELECT owner_code, owner_name, company FROM sp_owner where dwtype=17 AND company=".$Map['company']);
  67. $ResData=M()->query("SELECT owner_code, owner_name, company, dwtype FROM sp_owner where dwtype=17 AND company=".$Map['company']);
  68. // print_r($ResData);
  69. break;
  70. case 'firehydrant':
  71. $Map['dwtype']=4;
  72. $ResData=M()->query("SELECT owner_code, owner_name, company, dwtype FROM sp_owner where dwtype=4 AND company=".$Map['company']);
  73. break;
  74. case 'wellcover':
  75. $Map['dwtype']=128;
  76. $ResData=M()->query("SELECT owner_code, owner_name, company, dwtype FROM sp_owner where dwtype=128 AND company=".$Map['company']);
  77. break;
  78. default:
  79. break;
  80. }
  81. if($Map['dwtype']!=7&&$Map['dwtype']!=16&&$Map['dwtype']!=17&&$Map['dwtype']!=4&&$Map['dwtype']!=128){
  82. $ResData=M('monitor')->where($Map)->select();
  83. }
  84. $this->assign('company',$Data['companyid']);
  85. $this->assign('ResData',$ResData);
  86. $this->display('Index/dmanger-list');
  87. }
  88. }
  89. ?>