getDeviceCode($company_code); }else{ $company_code1=M()->query("select owner_code from sp_owner_phone WHERE phone='".$phone."' GROUP BY owner_code limit 1"); $company_code=$company_code1[0]['owner_code']; $device_list = $this->getDeviceCode($company_code); } $end_time = date("Y-m-d"); $start_time = date("Y-m-d", strtotime("-1 months", strtotime($end_time))); //时间段 $statisticalPeriod = $start_time . '~' . $end_time; //报警信息统计开始 //报警主机报警总数 $alarm_host_count=M()->query("select count(*) as alarm_host_count from sp_hj2017 where time >='".$end_time."' and device_code in(".$device_list.")"); //消防水系统报警总数 $fire_water_count=M()->query("select count(*) as fire_water_count from sp_sj2017 where time >='".$end_time."' and device_code in(".$device_list.")"); //电气火灾报警总数 $electrical_fire_count=M()->query("select count(*) as electrical_fire_count from sp_ef2017 where time >='".$end_time."' and device_code in(".$device_list.")"); //视频监测报警总数 $video_monitoring_count=M()->query("select count(*) as video_monitoring_count from sp_video2017 where time >='".$end_time."' and device_code in(".$device_list.")"); //井盖 $manhole_cover_count=M()->query("select count(*) as manhole_cover_count from sp_iw2017 where time >='".$end_time."' and device_code in(".$device_list.")"); //门禁 $door_count=M()->query("select count(*) as door_count from sp_door2020 where time >='".$end_time."' and device_code in(".$device_list.")"); //可燃气体 $gas_count=M()->query("select count(*) as gas_count from sp_gas2020 where time >='".$end_time."' and device_code in(".$device_list.")"); //地磁 $geomagnetism_count=M()->query("select count(*) as geomagnetism_count from sp_dc2020 where time >='".$end_time."' and device_code in(".$device_list.")"); //RTU $rtu_count=M()->query("select count(*) as rtu_count from sp_rtu2017 where time >='".$end_time."' and device_code in(".$device_list.")"); //电梯 $elevator_count=M()->query("select count(*) as elevator_count from sp_lifter2017 where time >='".$end_time."' and device_code in(".$device_list.")"); //其他类型一个月报警总数 $other_count=(int)$manhole_cover_count[0]['manhole_cover_count']+(int)$door_count[0]['door_count']+(int)$gas_count[0]['gas_count']+(int)$geomagnetism_count[0]['geomagnetism_count']+(int)$rtu_count[0]['rtu_count'] +(int)$elevator_count[0]['elevator_count']; //报警信息统计结束 //数据等级统计开始 //告警总数 $alarm_count=(int)$other_count+(int)$video_monitoring_count[0]['video_monitoring_count']+(int)$electrical_fire_count[0]['electrical_fire_count']+(int)$fire_water_count[0]['fire_water_count'] + (int)$alarm_host_count[0]['alarm_host_count']; //真实告警 $real_alarm_count=M()->query("select count(*) as real_alarm_count from sp_hj2017 where time >='".$end_time."' and device_code in(".$device_list.") and data2='火警'"); //隐患告警 $hidden_danger_count=(int)$alarm_count-(int)$real_alarm_count[0]['real_alarm_count']; //事件告警 $event_count=0; //数据等级统计结束 //设备运行状态开始 //离线 $off_linefire_water_device_count=M()->query("select count(*) as off_linefire_water_device_count from sp_v_device_status where device_status='离线' and device_id in(".$device_list.") "); $off_linealarm_host_device_count=M()->query("SELECT COUNT(*) as off_linealarm_host_device_count FROM sp_devices_status AS a JOIN sp_owner AS b ON a.deviceid=b.owner_code WHERE b.dwtype=1 AND a.true_status in(75,300) AND b.company='".$company_code."' "); $off_line_device_count=(int)$off_linefire_water_device_count[0]['off_linefire_water_device_count']+(int)$off_linealarm_host_device_count[0]['off_linealarm_host_device_count']; //故障 $fault_device_count=0; //预警 $early_warning_device_count=0; //其他 $other_device_count=0; //正常 $normal_fire_water_device_count=M()->query("select count(*) as normal_fire_water_device_count from sp_v_device_status where device_status='在线' and device_id in(".$device_list.") "); $normal_alarm_host_device_count=M()->query("SELECT COUNT(*) as normal_alarm_host_device_count FROM sp_devices_status AS a JOIN sp_owner AS b ON a.deviceid=b.owner_code WHERE b.dwtype=1 AND a.true_status='0' AND b.company='".$company_code."' "); $normal_device_count=(int)$normal_fire_water_device_count[0]['normal_fire_water_device_count']+(int)$normal_alarm_host_device_count[0]['normal_alarm_host_device_count'];; //设备运行状态结束 $data[0]['owner_name']=$this->owner_name; $data[0]['statisticalPeriod']=$statisticalPeriod; $data[0]['alarm_host_count'] = (int)$alarm_host_count[0]['alarm_host_count']; $data[0]['fire_water_count'] = (int)$fire_water_count[0]['fire_water_count']; $data[0]['electrical_fire_count'] = (int)$electrical_fire_count[0]['electrical_fire_count']; $data[0]['video_monitoring_count'] = (int)$video_monitoring_count[0]['video_monitoring_count']; $data[0]['other_count'] = $other_count; $data[0]['alarm_count'] = $alarm_count; $data[0]['real_alarm_count'] = (int)$real_alarm_count[0]['real_alarm_count']; $data[0]['hidden_danger_count'] = $hidden_danger_count; $data[0]['event_count'] = $event_count; $data[0]['off_line_device_count'] = $off_line_device_count; $data[0]['fault_device_count'] = $fault_device_count; $data[0]['early_warning_device_count'] = $early_warning_device_count; $data[0]['normal_device_count'] = $normal_device_count; $data[0]['other_device_count'] = $other_device_count; $data[0]['company_code'] = $company_code; $res['msg'] = '操作成功'; $res['flag'] = true; $res['data'] = $data; echo json_encode($res); } public function getCompanyList(){ $Date=I(); if (!empty($_SESSION['phone'])) { $phone = $_SESSION['phone']; }else{ $res['msg'] = '操作失败,缓存中参数缺失'; $res['flag'] = 3002; echo json_encode($res); exit(); } $company=M()->query("select a.owner_code,b.owner_name from sp_owner_phone as a join sp_owner_company as b on a.owner_code=b.owner_id where a.phone='".$phone."' GROUP BY owner_code"); $res['msg'] = '操作成功'; $res['flag'] = true; $res['data'] = $company; echo json_encode($res); } public function getFunctionalModuleStatistics(){ $Date=I(); $phone=$Date['phone']; $company_code = $Date['company_code']; if (!empty($_SESSION['phone'])) { $phone = $_SESSION['phone']; } if (!empty($company_code)){ $device_list = $this->getDeviceCode($company_code); }else{ $company_code1=M()->query("select owner_code from sp_owner_phone WHERE phone='".$phone."' GROUP BY owner_code limit 1"); $company_code=$company_code1[0]['owner_code']; $device_list = $this->getDeviceCode($company_code); } //报警主机未处理数量统计 $alarm_host_count=M()->query("select count(*) as alarm_host_count from sp_hj2017 where clzt=0 and device_code in(".$device_list.")"); //消防水未处理数量统计 $fire_water_count=M()->query("select count(*) as fire_water_count from sp_sj2017 where clzt=0 and device_code in(".$device_list.")"); //电气火灾未处理数量统计 $electrical_fire_count=M()->query("select count(*) as electrical_fire_count from sp_ef2017 where clzt=0 and device_code in(".$device_list.")"); //视频监测未处理数量统计 $video_monitoring_count=M()->query("select count(*) as video_monitoring_count from sp_video2017 where clzt=0 and device_code in(".$device_list.")"); //井盖未处理数量统计 $manhole_cover_count=M()->query("select count(*) as manhole_cover_count from sp_iw2017 where clzt=0 and device_code in(".$device_list.")"); //门禁未处理数量统计 $door_count=M()->query("select count(*) as door_count from sp_door2020 where clzt=0 and device_code in(".$device_list.")"); //可燃气体未处理数量统计 $gas_count=M()->query("select count(*) as gas_count from sp_gas2020 where clzt=0 and device_code in(".$device_list.")"); //地磁未处理数量统计 $geomagnetism_count=M()->query("select count(*) as geomagnetism_count from sp_dc2020 where clzt=0 and device_code in(".$device_list.")"); //RTU未处理数量统计 $rtu_count=M()->query("select count(*) as rtu_count from sp_rtu2017 where clzt=0 and device_code in(".$device_list.")"); //电梯未处理数量统计 $elevator_count=M()->query("select count(*) as elevator_count from sp_lifter2017 where clzt=0 and device_code in(".$device_list.")"); //综合告警统计 $comprehensive_alarm_count=(int)$manhole_cover_count[0]['manhole_cover_count']+(int)$door_count[0]['door_count']+(int)$gas_count[0]['gas_count']+(int)$geomagnetism_count[0]['geomagnetism_count']+(int)$rtu_count[0]['rtu_count'] +(int)$elevator_count[0]['elevator_count']+(int)$video_monitoring_count[0]['video_monitoring_count']+(int)$electrical_fire_count[0]['electrical_fire_count']+(int)$fire_water_count[0]['fire_water_count'] + (int)$alarm_host_count[0]['alarm_host_count']; //人员督察单 $personnel_inspection_list = query_187_ytapi("select count(*) as personnel_inspection_list_count from person_data where clzt='0' and company_code='" . $company_code."'"); //电子督察单 $electronic_inspection_sheet = query_187_ytapi("select count(*) as electronic_inspection_sheet_count from jingan_analysis_data where status=0 and clzt='0' and content != '设备离线' and company_code='" . $company_code."'"); //消防支队督察单未处理数量统计 $fire_brigade_inspector_count=$personnel_inspection_list[0]['personnel_inspection_list_count']+$electronic_inspection_sheet[0]['electronic_inspection_sheet_count']; $data[0]['comprehensive_alarm_count']=$comprehensive_alarm_count; $data[0]['fire_brigade_inspector_count']=$fire_brigade_inspector_count; $res['msg'] = '操作成功'; $res['flag'] = true; $res['data'] = $data; echo json_encode($res); } }