printing_log($Data, $filename_log); //需要用到的参数 $insert_id = $Data['insert_id']; $device_code = $Data['id']; $remarks = $Data['bz']; $types = $Data['types']; $time = $Data['time']; if (empty($insert_id)||empty($device_code)||empty($types)){ echo '缺少重要参数,请检查推送代码!'; exit(); } switch ($types) { case '44': $status = '离线'; $ty = 5; break; case 'H02P0': $status = '测试运行'; $ty = 0; break; case 'U21P1': case 'H02P1': $status = '火警'; $ty = 1; break; case 'U21P2': case 'H02P2': $status = '故障'; $ty = 2; break; case 'H02P3': $status = '屏蔽'; $ty = 0; break; case 'H02P4': $status = '监管'; $ty = 0; break; case 'H02P5': $status = '启动'; $ty = 1; break; case 'H02P6': $status = '反馈'; $ty = 1; break; case 'H02P7': $status = '延时'; $ty = 0; break; case 'H02P8': $status = '电源故障'; $ty = 2; break; case 'U24P0': $status = '复位'; $ty = 0; break; case 'U24P1': $status = '消音'; $ty = 0; break; case 'U24P2': $status = '手动报警'; $ty = 1; break; case 'U24P3': $status = '警情消除'; $ty = 0; break; case 'U24P4': $status = '自检'; $ty = 0; break; case 'U24P5': $status = '查岗应答'; $ty = 0; break; case 'U24P6': $status = '测试'; $ty = 0; break; case 'U21P0': $status = '正常'; $ty = 0; break; case 'U21P3': $status = '主电故障'; $ty = 2; break; case 'U21P4': $status = '备电故障'; $ty = 2; break; case 'U21P5': $status = '监控'; $ty = 0; break; case 'U21P6': $status = '接线'; $ty = 0; break; default: $status = '其他'; $ty = 0; // $this->xxxx(); break; } $data = M()->query("select s.owner_name,s.unitinfo,s.company,c.owner_address 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'] . "' AND data2 like '%" . $ty . "%' union select phone from sp_owner_phone WHERE owner_code in (select other_code from sp_owner_fujin where owner_code='" . $data[0]['company'] . "') AND data2 like '%" . $ty . "%'"); $openids = $this->array_column1($union_sql, "phone"); if (empty($openids)) { echo 'phone is null'; exit; } $op = M()->query("SELECT openid FROM sp_wx_customuser WHERE type='wx' and idphone in($openids)"); $status11 = M()->query("SELECT statustime FROM sp_devices_status where deviceid='" . $device_code . "'"); $access_token = GetAccess_Token1(); //first.DATA $address = '警报地址:' . $data[0]['owner_address'] . $data[0]['unitinfo']; //keyword2.DATA $type = $status; //keyword3.DATA if (empty($time)) { $time = $status11[0]['statustime']; } //remark.DATA if (empty($remarks)) { $remarks = '设备名称:' . $data[0]['owner_name']; } $url = "https://iot.usky.cn/jdxf/wxapp2.php/Home/Fireinfo/index/type/1/id/" . $insert_id; foreach ($op as $o) { if (!empty($o['openid'])) { $R = $this->SendDeviceAlarm($access_token, $o['openid'], $address, $device_code, $type, $time, $remarks, $url); $filename_log = "/var/www/html/jdxf/log/fire_t_log" . date("Y-m-d") . ".log"; $this->printing_log($R, $filename_log); print_r($R); } } } }