ComprehensiveAlarmController.class.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?php
  2. namespace Home\Controller;
  3. use Think\Controller;
  4. class ComprehensiveAlarmController extends ComController {
  5. public function index()
  6. {
  7. $Data=I();
  8. $companys=$Data['companyid'];
  9. $hj_x=$Data['hj_x'];
  10. $sj_x=$Data['sj_x'];
  11. $rtu_x=$Data['rtu_x'];
  12. $efire_x=$Data['efire_x'];
  13. $video_x=$Data['video_x'];
  14. $elevator_x=$Data['elevator_x'];
  15. $mc_x=$Data['mc_x'];
  16. $combustible_gas_x=$Data['combustible_gas_x'];
  17. $iw_x = $Data['iw_x'];
  18. $fire_hydrant_x=$Data['fire_hydrant_x'];
  19. $device_code_list=$this->getdevice1($companys);
  20. if (empty($hj_x)&&empty($sj_x)&&empty($rtu_x)&&empty($efire_x)&&empty($video_x)){
  21. $where2['company_code'] = $companys;
  22. $data_statistics = M('company_sync')->where($where2)->find();
  23. $hj_wcl_count=$data_statistics['device_01_alarm']-$data_statistics['device_01_alarm_confirm']+$data_statistics['device_01_out']-$data_statistics['device_01_out_confirm'];
  24. $sj_wcl_count=$data_statistics['device_02_alarm']+$data_statistics['device_00_alarm']-($data_statistics['device_02_alarm_confirm']+$data_statistics['device_00_alarm_confirm'])
  25. +$data_statistics['device_00_out']-$data_statistics['device_00_out_confirm']+$data_statistics['device_02_out']-$data_statistics['device_02_out_confirm'];
  26. $rtu_wcl_count=$data_statistics['device_06_alarm'] - $data_statistics['device_06_alarm_confirm']+$data_statistics['device_06_out']-$data_statistics['device_06_out_confirm'];
  27. $efire_wcl_count= $data_statistics['device_07_alarm'] - $data_statistics['device_07_alarm_confirm']+$data_statistics['device_07_out']-$data_statistics['device_07_out_confirm'];
  28. $video_wcl_count=$data_statistics['device_16_alarm'] - $data_statistics['device_16_alarm_confirm']+$data_statistics['device_16_out']-$data_statistics['device_16_out_confirm'];
  29. //火警报警未处理数量
  30. if($hj_wcl_count>99){
  31. $hj_x = '99+';
  32. }else{
  33. $hj_x = $hj_wcl_count;
  34. }
  35. //水警报警未处理数量
  36. if ($sj_wcl_count>99){
  37. $sj_x = '99+';
  38. }else{
  39. $sj_x = $sj_wcl_count;
  40. }
  41. //rtu报警未处理数量
  42. if ($rtu_wcl_count>99){
  43. $rtu_x = '99+';
  44. }else{
  45. $rtu_x = $rtu_wcl_count;
  46. }
  47. //电气火灾未处理数量
  48. if ($efire_wcl_count>99){
  49. $efire_x='99+';
  50. }else{
  51. $efire_x=$efire_wcl_count;
  52. }
  53. //视频监测未处理数量
  54. if ($video_wcl_count>99){
  55. $video_x='99+';
  56. }else{
  57. $video_x=$video_wcl_count;
  58. }
  59. }
  60. //电梯监测未处理数量
  61. if (is_null($elevator_x)&&$elevator_x==''){
  62. $elevator=M()->query("SELECT count(*) FROM sp_lifter2017 where device_code in (".$device_code_list.") and clzt='0'");
  63. if ($elevator[0]['count(*)']>99){
  64. $elevator_x = '99+';
  65. }else{
  66. $elevator_x = $elevator[0]['count(*)'];
  67. }
  68. }
  69. //门磁未处理数量
  70. if (is_null($mc_x)&&$mc_x==''){
  71. $mc=M()->query("SELECT count(*) FROM sp_door2020 where device_code in (".$device_code_list.") and clzt='0'");
  72. if ($mc[0]['count(*)']>99){
  73. $mc_x = '99+';
  74. }else{
  75. $mc_x = $mc[0]['count(*)'];
  76. }
  77. }
  78. //
  79. //可燃气体
  80. if (is_null($combustible_gas_x)&&$combustible_gas_x==''){
  81. $combustible_gas=M()->query("SELECT count(*) FROM sp_gas2020 where device_code in (".$device_code_list.") and clzt='0'");
  82. if($combustible_gas[0]['count(*)']>99){
  83. $combustible_gas_x = '99+';
  84. }else{
  85. $combustible_gas_x = $combustible_gas[0]['count(*)'];
  86. }
  87. }
  88. //井盖监测未处理数量
  89. if (is_null($iw_x)&&$iw_x==''){
  90. $iw=M()->query("SELECT count(*) as sl FROM sp_iw2017 where device_code in (".$device_code_list.") and clzt='0'");
  91. if ($iw[0]['sl']>99){
  92. $iw_x = '99+';
  93. }else{
  94. $iw_x = $iw[0]['sl'];
  95. }
  96. }
  97. //消防栓监测未处理数量
  98. if (is_null($fire_hydrant_x)&&$fire_hydrant_x==''){
  99. $fire_hydrant=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='".$companys."' AND b.dwtype='4' and a.clzt='0'");
  100. if ($fire_hydrant[0]['sl']>99){
  101. $fire_hydrant_x = '99+';
  102. }else{
  103. $fire_hydrant_x = $fire_hydrant[0]['sl'];
  104. }
  105. }
  106. $this->assign('companys',$companys);
  107. $this->assign('hj_x',$hj_x);
  108. $this->assign('sj_x',$sj_x);
  109. $this->assign('rtu_x',$rtu_x);
  110. $this->assign('efire_x',$efire_x);
  111. $this->assign('video_x',$video_x);
  112. $this->assign('elevator_x',$elevator_x);
  113. $this->assign('mc_x',$mc_x);
  114. $this->assign('iw_x',$iw_x);
  115. $this->assign('fire_hydrant_x',$fire_hydrant_x);
  116. $this->assign('combustible_gas_x',$combustible_gas_x);
  117. $this->display('Index/comprehensive_alarm');
  118. }
  119. //获取 权限 设备编号 001,001
  120. public function getdevice1($company){
  121. $device=M()->query("SELECT o.owner_code,c.owner_name FROM sp_owner o join sp_owner_company c ON o.company =c.owner_id WHERE o.company ='".$company."'");
  122. $this->owner_name=$device[0]['owner_name'];
  123. $str="";
  124. foreach ($device as $val) {
  125. $str.="'".$val['owner_code']."',";
  126. }
  127. $newstr = substr($str,0,strlen($str)-1);
  128. return $newstr;
  129. }
  130. }