query("SELECT owner_id,owner_name FROM sp_v_jd_wxindex WHERE phone='" . $phone . "'GROUP BY owner_id"); $this->assign('company', $arr); $comp = ''; if (!empty($company)) { $comp = $this->getdevice($company); $device_code_list = $comp; if (empty($comp)) { $this->assign('title', '无数据'); $this->assign('hj0', 0); $this->assign('hj1', 0); $this->assign('hjall', 0); $this->assign('gz0', 0); $this->assign('gz1', 0); $this->assign('gzall', 0); $this->assign('sj', 0); $this->assign('rtu', 0); $this->assign('cns', 0); // 第二饼图 $this->assign('zx', 0); $this->assign('lx', 0); $this->assign('gj', 0); // $this->display(); $this->display('Index2/index'); exit; } else { $this->assign('title', $this->owner_name); } } else { if (count($arr) > 0) { $company = $arr[0]['owner_id']; $comp = $this->getdevice($arr[0]['owner_id']); $device_code_list = $comp; $this->assign('title', $this->owner_name); } else { $this->assign('title', '无数据'); $this->assign('hj0', 0); $this->assign('hj1', 0); $this->assign('hjall', 0); $this->assign('gz0', 0); $this->assign('gz1', 0); $this->assign('gzall', 0); $this->assign('sj', 0); $this->assign('rtu', 0); $this->assign('cns', 0); // 第二饼图 $this->assign('zx', 0); $this->assign('lx', 0); $this->assign('gj', 0); // $this->display(); // $this->display('Index2/index'); $this->display('Public/index-1'); exit; } } $this->assign('companys', $company); $this->assign('phone', $_SESSION["idphone"]); $deviceid = "and deviceid in($comp)"; $comp = "and device_code in($comp)"; $res = M()->procedure(" SELECT COUNT(id) as gz1 FROM sp_hj2017 WHERE clzt='1'$comp AND data2 = '故障'; SELECT COUNT(id) as gzall FROM sp_hj2017 WHERE data2 = '故障' $comp; SELECT COUNT(id) as cn FROM sp_owner WHERE company=$company; SELECT COUNT(id) as zx FROM sp_devices_status WHERE true_status='0' $deviceid; SELECT COUNT(id) as lx FROM sp_devices_status WHERE true_status='75' $deviceid; SELECT COUNT(id) as gj FROM sp_devices_status WHERE devicestatus !='0' $deviceid; "); $where2['company_code'] = $company; $data_statistics = M('company_sync')->where($where2)->find(); //火报警总数量 $hj_total = $data_statistics['device_01_alarm']+$data_statistics['device_01_out']; //水报警总数 $sj_total = $data_statistics['device_02_alarm'] + $data_statistics['device_00_alarm']+$data_statistics['device_00_out']+$data_statistics['device_02_out']; //RTU报警总数 $rtu_total = $data_statistics['device_06_alarm']+$data_statistics['device_06_out']; // 电气火灾报警总数 $efire_total = $data_statistics['device_07_alarm']+$data_statistics['device_07_out']; //视频监测总数 $video_total=$data_statistics['device_16_alarm']+$data_statistics['device_16_out']; if (!empty($device_code_list)) { $array = explode(',', $device_code_list); $where['device_code'] = array('in', $array); $elevator_total = M('lifter2017')->where($where)->count(); } else { $elevator_total = 0; } //该单位总共报警总数 if ($company == 10215) { //RTU报警总数 $ResData1 = M()->query("select count(*) as sl from sp_v_rtu2017_2 where company='10215' AND wtype not LIKE '%离线%'"); $ResData2 = M()->query("select count(*) as sl from sp_v_rtu2017_2 where company='10215' AND wtype LIKE '%离线%' AND time < '2021-03-10'"); if (empty($ResData1)) { $ResData1[0]['sl'] = 0; } if (empty($ResData2)) { $ResData2[0]['sl'] = 0; } $ResData = $ResData1[0]['sl'] + $ResData2[0]['sl']; $commm = $hj_total + $sj_total + $ResData + $efire_total + $elevator_total + $video_total; } else { $commm = $hj_total + $sj_total + $rtu_total + $efire_total + $elevator_total + $video_total; } //该单位总共报警总数 $this->assign('commm', $commm); //消防支队人工督察单 $rgdcd = ytapi_query("select count(*) from person_data where clzt='0' and company_code='" . $company . "'"); $dzdcd = ytapi_query("select count(*) from jingan_analysis_data where status=0 and clzt='0' and content != '设备离线' and company_code='" . $company . "'"); $xfzdrydcd = $rgdcd[0]['count(*)'] + $dzdcd[0]['count(*)']; $this->assign('xfzdrydcd', $xfzdrydcd); if ($company == 10209 || $company == 10198 || $company == 10195 || $company == 10078 || $company == 10069 || $company == 10083 || $company == 10064 || $company == 10067 || $company == 10215 || $company == 10216 || $company == 10214 || $company == 10212 || $company == 10206 || $company == 10114 || $company == 10077 || $company == 10122 || $company == 10074 || $company == 10076 || $company == 10079 || $company == 10066 || $company == 10065 || $company == 10070 || $company == 10063 || $company == 10113 || $company == 10012 || $company == 10229 || $company == 10219) { $pd = 1; } else { $pd = 0; } $this->assign('pd', $pd); // 火警未处理 $hj88 = $data_statistics['device_01_alarm']-$data_statistics['device_01_alarm_confirm']+$data_statistics['device_01_out']-$data_statistics['device_01_out_confirm']; //水警未处理 $sj88 = $data_statistics['device_02_alarm']+$data_statistics['device_00_alarm']-($data_statistics['device_02_alarm_confirm']+$data_statistics['device_00_alarm_confirm']) +$data_statistics['device_00_out']-$data_statistics['device_00_out_confirm']+$data_statistics['device_02_out']-$data_statistics['device_02_out_confirm']; if ($hj88 > 99) { $hj_x = '99+'; } else { $hj_x = $hj88; } if ($sj88 > 99) { $sj_x = '99+'; } else { $sj_x = $sj88; } // 水 $this->assign('sj', $sj88); $this->assign('sj_x', $sj_x); //RTU if ($company == 10215) { $ResData1 = M()->query("select count(*) as sl from sp_v_rtu2017_2 where company='10215' AND wtype not LIKE '%离线%' and clzt=0"); $ResData2 = M()->query("select count(*) as sl from sp_v_rtu2017_2 where company='10215' AND wtype LIKE '%离线%' AND time < '2021-03-10' and clzt=0"); if (empty($ResData1)) { $ResData1[0]['sl'] = 0; } if (empty($ResData2)) { $ResData2[0]['sl'] = 0; } $rtu_wcl = $ResData1[0]['sl'] + $ResData2[0]['sl']; } else { $rtu_wcl =$data_statistics['device_06_alarm'] - $data_statistics['device_06_alarm_confirm']+$data_statistics['device_06_out']-$data_statistics['device_06_out_confirm']; } if ($rtu_wcl > 99) { $rtu_x = '99+'; } else { $rtu_x = $rtu_wcl; } $this->assign('rtu', $rtu_wcl); $this->assign('rtu_x', $rtu_x); // 电气火灾未处理 $efire = $data_statistics['device_07_alarm'] - $data_statistics['device_07_alarm_confirm']+$data_statistics['device_07_out']-$data_statistics['device_07_out_confirm']; //视频监测未处理 $video = $data_statistics['device_16_alarm'] - $data_statistics['device_16_alarm_confirm']+$data_statistics['device_16_out']-$data_statistics['device_16_out_confirm']; if (!empty($device_code_list)) { $array1 = explode(',', $device_code_list); $where1['device_code'] = array('in', $array1); $where1['clzt'] = '0'; //电梯 $elevator = M('lifter2017')->where($where1)->count(); //门磁 $mc = M('door2020')->where($where1)->count(); //可燃气体 $combustible_gas = M('gas2020')->where($where1)->count(); }else{ $elevator = 0; $mc = 0; $combustible_gas = 0; } if ($efire > 99) { $efire_x = '99+'; } else { $efire_x = $efire; } if ($video > 99) { $video_x = '99+'; } else { $video_x = $video; } if ($elevator > 99) { $elevator_x = '99+'; } else { $elevator_x = $elevator; } if ($mc > 99) { $mc_x = '99+'; } else { $mc_x = $mc; } if ($combustible_gas > 99) { $combustible_gas_x = '99+'; } else { $combustible_gas_x = $combustible_gas; } $this->assign('efire_x', $efire_x); $this->assign('hj_x', $hj_x); $this->assign('video_x', $video_x); $this->assign('elevator_x', $elevator_x); $this->assign('mc_x', $mc_x); $this->assign('combustible_gas_x', $combustible_gas_x); $this->assign('hjall', $data_statistics['device_01_alarm']); $this->assign('gz0', $res[1][0]['gzall']-$res[0][0]['gz1']); $this->assign('gz1', $res[0][0]['gz1']); $this->assign('gzall', $res[1][0]['gzall']); $this->assign('cns', $res[2][0]['cn']); // 第二饼图 $this->assign('zx', $res[3][0]['zx']); $this->assign('lx', $res[4][0]['lx']); $this->assign('gj', $res[5][0]['gj']); $rtu88 = $data_statistics['device_06_alarm'] - $data_statistics['device_06_alarm_confirm']+$data_statistics['device_06_out']-$data_statistics['device_06_out_confirm']; $qt = $rtu88+ $efire; $this->assign('qt', $qt); //综合消防总数 $zhxfzs = $hj88 + $sj88 + $rtu88 + $efire + $video + $elevator + $mc; if ($zhxfzs > 99) { $zhxfzs = '99+'; } $this->assign('zhxfzs', $zhxfzs); $Data = I(); $return_key = $Data['return_key']; if (empty($return_key)) { $return_key = 0; } $this->assign('return_key', $return_key); $appid = 'wx41e478e592f9e04a'; # 公众号获取 $appSecret = 'fc165de4aa5cd24b628baa30b100e146'; $accessToken = GetAccess_Token1(); # 实例化 $wx = new \JSSDK5($appid, $appSecret, $accessToken); # 获取参数 $info = $wx->getWxConfig(); # 传参页面 $this->assign('wxConfig', $info); $this->display('Index2/index'); } //获取 权限 设备编号 001,001 public function getdevice($company) { $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 in($company);"); $this->owner_name = $device[0]['owner_name']; $str = ""; foreach ($device as $val) { $str .= "'" . $val['owner_code'] . "',"; } $newstr = substr($str, 0, strlen($str) - 1); return $newstr; } }