printing_log($Data, $filename_log); //需要用到的参数 $device_code = $Data['device_code']; $unique_number = $device_code; $insert_id = $Data['insert_id']; $remarks = $Data['bz']; $time = $Data['time']; $evt_name = $Data['evt_name']; $where = " AND data2 like '%8%'"; if (empty($insert_id) || empty($device_code) || empty($evt_name) || empty($unique_number)) { echo '缺少重要参数,请检查推送代码!'; exit(); } //3小时以内相同设备报警未处理则不推送; $redis = new \Redis(); $result = $redis->connect('127.0.0.1', 6379); $if_push = 1; if ($result == 1) { $res = $redis->get("$unique_number"); if ($res == 1) { $if_push = 1; } else if (!empty($res)) { if (floor((strtotime($Data['time']) - strtotime($res)) / 3600) > 3) { $if_push = 1; } else { $if_push = 0; } } else { $if_push = 1; } $redis->get("$unique_number"); $redis->set("$unique_number", "$time"); $redis->close(); } $data = M()->query("select s.push_param2,s.owner_name,s.unitinfo,s.company,c.owner_address,s.dwtype from sp_owner s ,sp_owner_company c where s.company=c.owner_id and s.owner_code ='" . $device_code . "'"); $union_sql = M()->query("select phone from sp_owner_phone WHERE owner_code='" . $data[0]['company'] . "' " . $where . " union select phone from sp_owner_phone WHERE owner_code in (select other_code from sp_owner_fujin where owner_code='" . $data[0]['company'] . "') " . $where); $openids = $this->array_column1($union_sql, "phone"); if (empty($openids)) { echo 'open is null'; exit; } $op = M()->query("SELECT openid FROM sp_wx_customuser WHERE type='wx' and idphone in($openids)"); $status11 = M()->query("SELECT time FROM sp_video2017 where id='" . $insert_id . "'"); $access_token = GetAccess_Token1(); $address = '警报地址:' . $data[0]['owner_address'] . $data[0]['unitinfo']; //keyword3.DATA if (empty($time)) { $time = $status11[0]['time']; } //remark.DATA if (empty($remarks)) { $remarks = '设备名称:' . $data[0]['owner_name']; } if ($data[0]['company'] == "11111") { $url = "https://qhome.usky.cn/jdxf/wxapp7.php/Home/Fireinfo/index/type/16/id/" . $insert_id . "/zdid/" . $data[0]['push_param2']; $access_token2 = GetAccess_Token2(); foreach ($op as $key => $o) { if (!empty($o['openid'])) { $R = $this->SendDeviceAlarm3($access_token2, $o['openid'], $address, $device_code, $evt_name, $time, $remarks, $url); print_r($R); } } } else { $url = "https://iot.usky.cn/jdxf/wxapp2.php/Home/Fireinfo/index/type/16/id/" . $insert_id; if ($if_push == 1) { foreach ($op as $key => $o) { if (!empty($o['openid'])) { $R = $this->SendDeviceAlarm($access_token, $o['openid'], $address, $device_code, $evt_name, $time, $remarks, $url); $filename_log = "/var/www/html/jdxf/log/video_t_log" . date("Y-m-d") . ".log"; $this->printing_log($R, $filename_log); print_r($R); } } } } } }