query("SELECT device_code FROM sp_fire_backup WHERE device_code='".$Data['id']."'"); if(!empty($deviceCode)){ echo '该设备做限制,不进行推送'; exit(); } switch ($Data['types']) { case '44': $status = '离线'; $ty = 5; break; case 'H02P0': $status = '测试运行'; $ty = 0; break; case 'H02P1': $status = '火警'; $ty = 1; break; 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 'U21P1': $status = '火警'; $ty = 1; break; case 'U21P2': $status = '故障'; $ty = 2; 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; } $company = 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 ='" . $Data['id'] . "'"); $union_sql = M()->query("select phone from sp_owner_phone WHERE owner_code='" . $company[0]['company'] . "' AND data2 like '%" . $ty . "%' and statusbb=1 union select phone from sp_owner_phone WHERE owner_code in (select other_code from sp_owner_fujin where owner_code='" . $company[0]['company'] . "') AND data2 like '%" . $ty . "%' and statusbb=1 "); $openids = $this->array_column1($union_sql, "phone"); if (empty($openids)) { echo '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='" . $Data['id'] . "'"); $access_token = GetAccess_Token1(); $address = '警报地址:' . $company[0]['owner_address'] . $company[0]['unitinfo']; $deviceid = $Data['id']; $type = $status; $time = $status11[0]['statustime']; if (!empty($bz)) { $remark = $bz; } else { $remark = '设备名称:' . $company[0]['owner_name']; } $ljurl = "https://qhome.usky.cn/jdxf/wxapp2.php/Home/Fireinfo/index/type/1/id/" . $insert_id; foreach ($op as $o) { if (!empty($o['openid'])) { $a = $this->SendDeviceAlarm($access_token, $o['openid'], $address, $deviceid, $type, $time, $remark, $ljurl, $url = ''); print_r($a); } } } //测试 function xxxx() { $access_token = GetAccess_Token1(); $data = array( "touser" => 'o83OY1ctQP1pVo7zCWtjCsXzK-Ok', "template_id" => "xJPLfWkpjUZlrumL5sgYbOfauAP3nqdSumqlGE5IsGg", "url" => "http://zt-iot.com/ztcrm/index.php/home/Warnlist/index2/code_id/1/uid/install_id/types/1", "data" => array( "first" => array( "value" => '', "color" => "#44b549" ), "keyword1" => array( "value" => '未解析', "color" => "#173177" ), "keyword2" => array( "value" => '', "color" => "#173177" ), "keyword3" => array( "value" => date('Y-m-d H:i:s'), "color" => "#173177" ), "remark" => array( "value" => '', "color" => "#aaaaaa" ) ) ); $data = json_encode($data); $QUEST_URL = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" . $access_token; $res = $this->curl($QUEST_URL, $data); return json_decode($res, true); } }