getDeviceCode($company_code); $device_list1 = $this->getDeviceCode1($company_code); if (!empty($device_list)){ //报警主机未处理数量统计 $untreated_alarm_host_count = M()->query("select count(a.id) as untreated_alarm_host_count from sp_hj2017 as a join sp_owner as b on a.device_code=b.owner_code where a.clzt=0 and b.dwtype=1 and b.company='".$company_code."'"); // $untreated_alarm_host_count = M()->query("select count(*) as untreated_alarm_host_count from sp_hj2017 where clzt=0 and device_code in(" . $device_list . ")"); //消防水未处理数量统计 // $untreated_fire_water_count1 = M()->query("select count(*) as untreated_fire_water_count from sp_sj2017 where clzt=0 and device_code in(" . $device_list . ")"); $untreated_fire_water_count1 = M()->query("select count(a.id) as untreated_fire_water_count from sp_sj2017 as a join sp_owner as b on a.device_code=b.owner_code where a.clzt=0 and b.dwtype in(2,3) and b.company='".$company_code."'"); //$untreated_fire_water_count = (int)$untreated_fire_water_count1[0]['untreated_fire_water_count'] - (int)$untreated_fire_hydrant_count[0]['untreated_fire_hydrant_count']; //电气火灾未处理数量统计 $untreated_electrical_fire_count = M()->query("select count(*) as untreated_electrical_fire_count from sp_ef2017 where clzt=0 and device_code in(" . $device_list . ")"); //视频监测未处理数量统计 $untreated_video_monitoring_count = M()->query("select count(*) as untreated_video_monitoring_count from sp_video2017 where clzt=0 and device_code in(" . $device_list . ")"); //井盖未处理数量统计 $untreated_manhole_cover_count = M()->query("select count(*) as untreated_manhole_cover_count from sp_iw2017 where clzt=0 and device_code in(" . $device_list . ")"); //门禁未处理数量统计 $untreated_door_count = M()->query("select count(*) as untreated_door_count from sp_door2020 where clzt=0 and device_code in(" . $device_list . ")"); //可燃气体未处理数量统计 $untreated_gas_count = M()->query("select count(*) as untreated_gas_count from sp_gas2020 where clzt=0 and device_code in(" . $device_list . ")"); //地磁未处理数量统计 $untreated_geomagnetism_count = M()->query("select count(*) as untreated_geomagnetism_count from sp_dc2020 where clzt=0 and device_code in(" . $device_list . ")"); //RTU未处理数量统计 $untreated_rtu_count = M()->query("select count(*) as untreated_rtu_count from sp_rtu2017 where clzt=0 and device_code in(" . $device_list . ")"); //电梯未处理数量统计 $untreated_elevator_count = M()->query("select count(*) as untreated_elevator_count from sp_lifter2017 where clzt=0 and device_code in(" . $device_list . ")"); $data[0]['untreated_alarm_host_count'] = (int)$untreated_alarm_host_count[0]['untreated_alarm_host_count']; $data[0]['untreated_fire_water_count'] = (int)$untreated_fire_water_count1[0]['untreated_fire_water_count']; $data[0]['untreated_electrical_fire_count'] = (int)$untreated_electrical_fire_count[0]['untreated_electrical_fire_count']; $data[0]['untreated_video_monitoring_count'] = (int)$untreated_video_monitoring_count[0]['untreated_video_monitoring_count']; $data[0]['untreated_manhole_cover_count'] = (int)$untreated_manhole_cover_count[0]['untreated_manhole_cover_count']; $data[0]['untreated_door_count'] = (int)$untreated_door_count[0]['untreated_door_count']; $data[0]['untreated_gas_count'] = (int)$untreated_gas_count[0]['untreated_gas_count']; $data[0]['untreated_geomagnetism_count'] = (int)$untreated_geomagnetism_count[0]['untreated_geomagnetism_count']; $data[0]['untreated_rtu_count'] = (int)$untreated_rtu_count[0]['untreated_rtu_count']; $data[0]['untreated_elevator_count'] = (int)$untreated_elevator_count[0]['untreated_elevator_count']; }else{ $data[0]['untreated_alarm_host_count'] = 0; $data[0]['untreated_fire_water_count'] = 0; $data[0]['untreated_electrical_fire_count'] = 0; $data[0]['untreated_video_monitoring_count'] = 0; $data[0]['untreated_manhole_cover_count'] = 0; $data[0]['untreated_door_count'] = 0; $data[0]['untreated_gas_count'] = 0; $data[0]['untreated_geomagnetism_count'] = 0; $data[0]['untreated_rtu_count'] = 0; $data[0]['untreated_elevator_count'] = 0; } if (!empty($device_list1)){ //消火栓未处理统计 $untreated_fire_hydrant_count = M()->query("select count(*) as untreated_fire_hydrant_count from sp_sj2017 where clzt=0 and device_code in(" . $device_list1 . ")"); $data[0]['untreated_fire_hydrant_count'] = (int)$untreated_fire_hydrant_count[0]['untreated_fire_hydrant_count']; }else{ $data[0]['untreated_fire_hydrant_count'] = 0; } $data[0]['company_code'] = $company_code; $res['msg'] = '操作成功'; $res['flag'] = true; $res['data'] = $data; echo json_encode($res); } public function getIntegratedAlarmList() { $Date = I(); $company_code = $Date['company_code']; $type = $Date['type']; $processing_status = $Date['processing_status']; if (empty($company_code) && empty($type) && empty($processing_status)) { $res['msg'] = '操作失败,缺少关键参数'; $res['flag'] = false; echo json_encode($res); exit(); } switch ($type) { case '1'://报警主机 $table = 'sp_hj2017'; $types = '1'; break; case '2'://水表和液位 $table = 'sp_sj2017'; $types = '2,5'; break; case '3'://烟感 $table = 'sp_hj2017'; $types = '3'; break; case '4'://消防栓 $table = 'sp_sj2017'; $types = $type; break; case '5'://液位 $table = 'sp_sj2017'; $types = '5'; break; case '6'://RTU $table = 'sp_rtu2017'; $types = $type; break; case '7'://电气火灾 $table = 'sp_ef2017'; $types = $type; break; case '16'://视频监测 $table = 'sp_video2017'; $types = $type; break; case '17'://电梯监测 $table = 'sp_lifter2017'; $types = $type; break; case '128'://井盖 $table = 'sp_iw2017'; $types = $type; break; case '129'://地磁 $table = 'sp_dc2020'; $types = $type; break; case '130'://门禁 $table = 'sp_door2020'; $types = $type; break; case '131'://可燃气体 $table = 'sp_gas2020'; $types = $type; break; default: $res['msg'] = '操作失败,设备类型尚未定义,请联系管理员'; $res['flag'] = 3002; echo json_encode($res); exit(); break; } // $alarm_count = M()->query("SELECT count(*) as alarm_count FROM " . $table . " AS a JOIN sp_owner AS b ON a.device_code=b.owner_code WHERE b.dwtype in(" . $types . ") AND b.company='" . $company_code . "' AND clzt=" . $processing_status); $alarm_list = M()->query("SELECT a.id,a.device_code,a.time,a.data1,a.data4,a.data2,a.clzt,b.company AS company_code,b.owner_name,b.unitinfo,b.dwtype as type FROM " . $table . " AS a JOIN sp_owner AS b ON a.device_code=b.owner_code WHERE b.dwtype in(" . $types . ") AND b.company='" . $company_code . "' AND a.clzt=" . $processing_status . " ORDER BY a.id DESC LIMIT 1000"); $alarm_count =sizeof($alarm_list); if ($type == 2 || $type == 4) { foreach ($alarm_list as $key => $value) { switch ($alarm_list[$key]['data1']) { case 'WP1': $alarm_list[$key]['data4'] = '低压'; break; case 'WP2': $alarm_list[$key]['data4'] = '高压'; break; case 'WP3': $alarm_list[$key]['data4'] = '故障'; break; case 'WP4': $alarm_list[$key]['data4'] = '离线'; break; case 'LL1': $alarm_list[$key]['data4'] = '低水位'; break; case 'LL2': $alarm_list[$key]['data4'] = '高水位'; break; default: $alarm_list[$key]['data4'] = '其他' . $alarm_list[$key]['data1']; break; } } } else if ($type == 7) { foreach ($alarm_list as $key => $value) { if ($alarm_list[$key]['data1'] == 'EF1') { $alarm_list[$key]['data4'] = '欠压报警'; } elseif ($alarm_list[$key]['data1'] == 'EF2') { $alarm_list[$key]['data4'] = '过压报警'; } elseif ($alarm_list[$key]['data1'] == 'EF3') { $alarm_list[$key]['data4'] = '过流报警'; } elseif ($alarm_list[$key]['data1'] == 'EF4') { $alarm_list[$key]['data4'] = '漏电报警'; } elseif ($alarm_list[$key]['data1'] == 'EF5') { $alarm_list[$key]['data4'] = '回路1温度超限报警'; } elseif ($alarm_list[$key]['data1'] == 'EF6') { $alarm_list[$key]['data4'] = '回路2温度超限报警'; } elseif ($alarm_list[$key]['data1'] == 'EF7') { $alarm_list[$key]['data4'] = '回路3温度超限报警'; } elseif ($alarm_list[$key]['data1'] == 'EF8') { $alarm_list[$key]['data4'] = '回路4温度超限报警'; } elseif ($alarm_list[$key]['data1'] == 'EF9') { $alarm_list[$key]['data4'] = '离线'; } else { $alarm_list[$key]['data4'] = '其他' . $alarm_list[$key]['data1']; } } } $res['msg'] = '操作成功'; $res['flag'] = true; $res['alarm_count'] = (int)$alarm_count; $res['data'] = $alarm_list; echo json_encode($res); } public function getAlarmDetails() { $Date = I(); // print_r($Date); $id = $Date['id']; $type = $Date['type']; // $processing_status = $Date['processing_status']; if (empty($id) && empty($type)) { $res['msg'] = '操作失败,缺少关键参数'; $res['flag'] = 3001; echo json_encode($res); exit(); } switch ($type) { case '1'://报警主机 $table = 'sp_hj2017'; $types = '1'; break; case '2'://水表和液位 $table = 'sp_sj2017'; $types = '2,'; break; case '3'://烟感 $table = 'sp_hj2017'; $types = '3'; break; case '4'://消防栓 $table = 'sp_sj2017'; $types = $type; break; case '5'://液位 $table = 'sp_sj2017'; $types = '5'; break; case '6'://RTU $table = 'sp_rtu2017'; $types = $type; break; case '7'://电气火灾 $table = 'sp_ef2017'; $types = $type; break; case '16'://视频监测 $table = 'sp_video2017'; $types = $type; break; case '17'://电梯监测 $table = 'sp_lifter2017'; $types = $type; break; case '128'://井盖 $table = 'sp_iw2017'; $types = $type; break; case '129'://地磁 $table = 'sp_dc2020'; $types = $type; break; case '130'://门禁 $table = 'sp_door2020'; $types = $type; break; case '131'://可燃气体 $table = 'sp_gas2020'; $types = $type; break; default: $res['msg'] = '操作失败,设备类型尚未定义,请联系管理员'; $res['flag'] = 3002; echo json_encode($res); exit(); break; } if ($type == 128){ $list = M()->query("SELECT a.device_status,a.id,a.port,a.device_code,b.owner_name as device_name,a.data1,a.data4,a.data2,a.data3,a.data5,a.clwb,a.clzt,a.clr,a.clnr,b.company AS company_code,a.time,b.unitinfo,b.dwtype,a.ncmd,a.clsj FROM " . $table . " AS a JOIN sp_owner AS b ON a.device_code=b.owner_code WHERE a.id=" . $id); }elseif($type == 130||$type == 131){ $list = M()->query("SELECT a.id,a.device_code,b.owner_name as device_name,a.data1,a.data4,a.data2,a.data3,a.data5,a.clwb,a.clzt,a.clr,a.clnr,b.company AS company_code,a.time,b.unitinfo,b.dwtype,a.ncmd,a.clsj FROM " . $table . " AS a JOIN sp_owner AS b ON a.device_code=b.owner_code WHERE a.id=" . $id); }else{ // print_r("SELECT a.id,a.port,a.device_code,b.owner_name as device_name,a.data1,a.data4,a.data2,a.data3,a.data5,a.clwb,a.clzt,a.clr,a.clnr,b.company AS company_code,a.time,b.unitinfo,b.dwtype,a.ncmd,a.clsj FROM " . $table . " AS a JOIN sp_owner AS b ON a.device_code=b.owner_code WHERE a.id=" . $id); $list = M()->query("SELECT a.id,a.port,a.device_code,b.owner_name as device_name,a.data1,a.data4,a.data2,a.data3,a.data5,a.clwb,a.clzt,a.clr,a.clnr,b.company AS company_code,a.time,b.unitinfo,b.dwtype,a.ncmd,a.clsj FROM " . $table . " AS a JOIN sp_owner AS b ON a.device_code=b.owner_code WHERE a.id=" . $id); } if($type == 1){ $list[0]['alarm_information'] = $list[0]['data2']; }elseif ($type == 2 || $type == 4) { switch ($list[0]['data1']) { case 'WP1': $list[0]['alarm_information'] = '低压'; break; case 'WP2': $list[0]['alarm_information'] = '高压'; break; case 'WP3': $list[0]['alarm_information'] = '故障'; break; case 'WP4': $list[0]['alarm_information'] = '离线'; break; case 'LL1': $list[0]['alarm_information'] = '低水位'; break; case 'LL2': $list[0]['alarm_information'] = '高水位'; break; default: $list[0]['alarm_information'] = '其他' . $list[0]['data1']; break; } if ($list[0]['dwtype'] == 5) { $list[0]['numerical_value'] = '水位值:' . $list[0]['data4'] . 'M'; } else { $list[0]['numerical_value'] = '水压值:' . $list[0]['data4'] . 'Mpa'; } }else if ($type == 6){ $list[0]['alarm_information'] =$list[0]['data2']; if ($list[0]['port'] == 'E6') { if ($list[0]['data2'] == '低压' || $list[0]['data2'] == '高压') { $list[0]['numerical_value'] = '水压值:' . $list[0]['data1'] . 'Mpa'; } elseif ($list[0]['data2'] == '低水位' || $list[0]['data2'] == '高水位') { $list[0]['numerical_value'] = '水位:' . $list[0]['data1'] . 'M'; } elseif ($list[0]['data2'] == '低温' || $list[0]['data2'] == '高温') { $list[0]['numerical_value'] = '温度:' . $list[0]['data1'] . '℃'; } elseif ($list[0]['data2'] == '低湿度' || $list[0]['data2'] == '高湿度') { $list[0]['numerical_value'] = '湿度:' . $list[0]['data1'] . '%'; }else if ($list[0]['data2'] == '设备异常'){ $list[0]['numerical_value'] = $list[0]['data4'].':'.$list[0]['data1']; } else { $list[0]['numerical_value'] = $list[0]['data4']; } } else { $list[0]['numerical_value'] = $list[0]['data4']; } }else if ($type == 7) { if ($list[0]['data1'] == 'EF1') { $list[0]['alarm_information'] = '欠压报警'; $list[0]['numerical_value'] = 'A相欠压值:' . $list[0]['data2'] . 'V B相欠压值:' . $list[0]['data3'] . 'V C相欠压值:' . $list[0]['data4'] . 'V'; } elseif ($list[0]['data1'] == 'EF2') { $list[0]['alarm_information'] = '过压报警'; $list[0]['numerical_value'] = 'A相过压值:' . $list[0]['data2'] . 'V B相过压值:' . $list[0]['data3'] . 'V C相过压值:' . $list[0]['data4'] . 'V'; } elseif ($list[0]['data1'] == 'EF3') { $list[0]['alarm_information'] = '过流报警'; $list[0]['numerical_value'] = 'A相过流值:' . $list[0]['data2'] . 'mA B相过流值:' . $list[0]['data3'] . 'mA C相过流值:' . $list[0]['data4'] . 'mA'; } elseif ($list[0]['data1'] == 'EF4') { $list[0]['alarm_information'] = '漏电报警'; $list[0]['numerical_value'] = '漏电流值:' . $list[0]['data2'] . 'mA'; } elseif ($list[0]['data1'] == 'EF5') { $list[0]['alarm_information'] = '回路1温度超限报警'; $list[0]['numerical_value'] = '温度1值:' . $list[0]['data2'] . '℃'; } elseif ($list[0]['data1'] == 'EF6') { $list[0]['alarm_information'] = '回路2温度超限报警'; $list[0]['numerical_value'] = '温度2值:' . $list[0]['data2'] . '℃'; } elseif ($list[0]['data1'] == 'EF7') { $list[0]['alarm_information'] = '回路3温度超限报警'; $list[0]['numerical_value'] = '温度3值:' . $list[0]['data2'] . '℃'; } elseif ($list[0]['data1'] == 'EF8') { $list[0]['alarm_information'] = '回路4温度超限报警'; $list[0]['numerical_value'] = '温度4值:' . $list[0]['data2'] . '℃'; } elseif ($list[0]['data1'] == 'EF9') { $list[0]['alarm_information'] = '离线'; $list[0]['numerical_value'] = '设备离线'; } else { $list[0]['alarm_information'] = '其他' . $list[0]['data1']; } }elseif($type == 128){ if ($list[0]['device_status']==1){ $list[0]['alarm_information'] = "设备异常"; }else{ $list[0]['alarm_information'] = "设备正常"; } }else{ $list[0]['alarm_information'] = $list[0]['data4']; } $res['msg'] = '操作成功'; $res['flag'] = true; $res['data'] = $list; echo json_encode($res); } public function setAlarmHandling(){ $Data = I(); $id = $Data['id']; $type = $Data['type']; $device_code = $Data['device_code']; $if_batch = $Data['if_batch']; $clwb = $Data['clwb']; $clnr = $Data['clnr']; $clr = $_SESSION['phone']; $port = $Data['port']; $Source_code=$Data['ncmd']; if (empty($id) && empty($type)&& empty($device_code)&& empty($clwb)&& empty($Data['data2'])&& empty($Data['data5'])&& empty($Data['data1'])&& empty($Source_code)) { $res['msg'] = '操作失败,缺少关键参数'; $res['flag'] = false; echo json_encode($res); exit(); } switch ($type) { case '1'://报警主机 $table = 'sp_hj2017'; $Tabs = M('hj2017'); $types = '1'; // $where['data2'] = $Data['data2']; $where['data3'] = $Data['data3']; $where['data5'] = $Data['data5']; break; case '2'://水表和液位 $table = 'sp_sj2017'; $Tabs = M('sj2017'); $types = '2'; $where['data1'] = $Data['data1']; break; case '3'://烟感 $table = 'sp_hj2017'; $Tabs = M('hj2017'); $types = '3'; $where['data2'] = $Data['data2']; break; case '4'://消防栓 $table = 'sp_sj2017'; $Tabs = M('sj2017'); $types = $type; break; case '5'://液位 $table = 'sp_sj2017'; $Tabs = M('sj2017'); $types = '5'; break; case '6'://RTU $table = 'sp_rtu2017'; $Tabs = M('rtu2017'); $types = $type; $where['ncmd'] = $Data['ncmd']; $where['data2'] = $Data['data2']; $where['data4'] = $Data['data4']; break; case '7'://电气火灾 $table = 'sp_ef2017'; $Tabs = M('ef2017'); $types = $type; $where['data1'] = $Data['data1']; break; case '16'://视频监测 $table = 'sp_video2017'; $Tabs = M('video2017'); $types = $type; break; case '17'://电梯监测 $table = 'sp_lifter2017'; $Tabs = M('lifter2017'); $types = $type; break; case '128'://井盖 $table = 'sp_iw2017'; $Tabs = M('iw2017'); $types = $type; break; case '129'://地磁 $table = 'sp_dc2020'; $Tabs = M('dc2020'); $types = $type; break; case '130'://门禁 $table = 'sp_door2020'; $Tabs = M('door2020'); $types = $type; break; case '131'://可燃气体 $table = 'sp_gas2020'; $Tabs = M('gas2020'); $types = $type; break; default: $res['msg'] = '操作失败,设备类型尚未定义,请联系管理员'; $res['flag'] = false; echo json_encode($res); exit(); break; } //修改条件 $data['clzt']=1; $data['clwb']=$clwb; $data['clnr']=$clnr; $data['cldh']=$clr; $data['clr']=$clr; $data['clsj']=date("Y-m-d H:i:s"); $types_data=M()->query("select dwtype from sp_owner where owner_code='".$Data['device_code']."'"); $typess=$types_data[0]['dwtype']; if ($if_batch==1){//批量处理 $where['device_code']=$device_code; $where['clzt']=0; $R=$Tabs->where($where)->save($data); }else{ $where['id']=$id; // print_r($where); // print_r($data); // exit(); $R=$Tabs->where($where)->save($data); } $url1 = 'http://47.98.201.187:55335/report'; if ($if_batch==1){ if ($typess==1){ $res_id = M()->query("select id,data3,data4 from sp_hj2017 where device_code='" . $Data['device_code'] . "' and data3='" . $Data['data3'] . "' and data5='" . $Data['data5'] . "' and clzt=1 order by time desc LIMIT 1;"); $cs66 = [ 'SubType' => 1, 'DeviceId' => $Data['device_code'], 'InsertId' => $res_id[0]['id'], 'Confirmed' => true, ]; $cs88 = json_encode($cs66); $result = http_post_advertise($url1, $cs88); if (!empty($res_id[0]['data4'])){ $port=mb_substr($res_id[0]['data4'],4,1,'utf-8'); // $port=substr($res_id[0]['data4'],3,1); }else{ $port=''; } if (!empty($res_id[0]['data3'])){ $Source_code=str_replace(',','',$res_id[0]['data3']); }else{ $Source_code=''; } $unique_number=$Data['device_code'].$port.$Source_code; }elseif ($typess==2){ $res_id = M()->query("select id from sp_sj2017 where device_code='" . $Data['device_code'] . "' and data1='" . $Data['data1'] . "' and clzt=1 order by time desc limit 1"); $cs66 = [ 'SubType' => 2, 'DeviceId' => $Data['device_code'], 'InsertId' => $res_id[0]['id'], 'Confirmed' => true, ]; $cs88 = json_encode($cs66); $result = http_post_advertise($url1, $cs88); $unique_number=$Data['device_code']; }elseif ($typess==3){ $res_id = M()->query("select id from sp_hj2017 where device_code='" . $Data['device_code'] . "' and data2='" . $Data['ftypewtype'] . "' and clzt=1 order by time desc limit 1"); $cs66 = [ 'SubType' => 3, 'DeviceId' => $Data['device_code'], 'InsertId' => $res_id[0]['id'], 'Confirmed' => true, ]; $url1 = 'http://47.98.201.187:55335/report'; $cs88 = json_encode($cs66); $result = http_post_advertise($url1, $cs88); $unique_number=$Data['device_code']; }elseif ($typess==6){ $unique_number=$Data['device_code'].$port.$Source_code.$Data['data4'].' '.$Data['data2']; }elseif ($typess==7){ $res_id = M()->query("select * from sp_ef2017 where device_code='" . $Data['device_code'] . "' and data1='" . $Data['data1'] . "' and clzt=1 order by time desc limit 1"); $cs66 = [ 'SubType' => 7, 'DeviceId' => $Data['device_code'], 'InsertId' => $res_id[0]['id'], 'Confirmed' => true, ]; $url1 = 'http://47.98.201.187:55335/report'; $cs88 = json_encode($cs66); $result = http_post_advertise($url1, $cs88); $port=$res_id[0]['port']; $unique_number=$Data['device_code'].$port; }else{ $unique_number=$Data['device_code']; } //redis链接 // $redis = new \Redis(); // $result = $redis->connect('127.0.0.1', 6379); // if ($result==1){ // $redis->set("$unique_number",1); // $redis->close(); // } }else{ $cs = [ 'SubType' => $typess, 'DeviceId' => $Data['device_code'], 'InsertId' => $Data['id'], 'Confirmed' => true, ]; if ($typess == 1 || $typess == 2 || $typess == 3 || $typess == 7) { $url = 'http://47.98.201.187:55335/report'; $cs3 = json_encode($cs); $result = http_post_advertise($url, $cs3); } if ($typess==1){ $res_id = M()->query("select data3,data4 from sp_hj2017 where id=" . $Data['id']); if (!empty($res_id[0]['data4'])){ $port=mb_substr($res_id[0]['data4'],4,1,'utf-8'); // $port=substr($res_id[0]['data4'],3,1); }else{ $port=''; } if (!empty($res_id[0]['data3'])){ $Source_code=str_replace(',','',$res_id[0]['data3']); }else{ $Source_code=''; } $unique_number=$Data['device_code'].$port.$Source_code; }else if ($typess==6){ $port=$Data['port']; $Source_code=$Data['ncmd']; $unique_number=$Data['device_code'].$port.$Source_code.$Data['data4'].' '.$Data['data2']; }else if ($typess==7){ $res_id = M()->query("select port from sp_ef2017 where id=" . $Data['id']); $port=$res_id[0]['port']; $unique_number=$Data['device_code'].$port; }else{ $unique_number=$Data['device_code']; } //redis储存处理的设备 // $redis = new \Redis(); // $result = $redis->connect('127.0.0.1', 6379); // if ($result==1){ // $redis->set("$unique_number",1); // $redis->close(); // } } // $data = array("devicestatus" => 0); // $str_where = "deviceid='" . $Data['device_code'] . "'"; // $str_sql_upd = M('devices_status')->where($str_where)->save($data); if ($R){ $res['msg'] = '操作成功'; $res['flag'] = true; echo json_encode($res); }else{ $res['msg'] = '操作失败'; $res['flag'] = false; echo json_encode($res); } } //获取消防栓设备编号 public function getDeviceCode1($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.dwtype=4 and o.company in(".$company.")"); $str = ""; foreach ($device as $val) { $str .= "'" . $val['owner_code'] . "',"; } $newstr = substr($str, 0, strlen($str) - 1); return $newstr; } }