123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- <?php
- namespace Home\Controller;
- use Think\Controller;
- include '../Common/function.php';
- class ElevatorwarnController extends PushWarnController
- {
- /**
- * "evt" => "09",
- * "IMEI" => 设备编号,
- * "DateTime" => 时间,
- * "Interval" => 间隔时间,
- * "Status" => 状态,
- * "Battery" => 电量,
- * "Signal" => 信号,
- * "Unit" => 单位,
- * "Pressure" => 水压值,
- * "phone" => 电话,
- * "insert_id" => 插入表id
- * @return [type] [description]
- */
- public function message_elevator()
- {
- $Data = I('post.');
- if (empty($Data['phone'])) {
- dump($Data['phone']);
- exit;
- }
- if (!empty($Data['IMEI'])) {
- $dataid = $Data['IMEI'];
- } else if (!empty($Data['IEMI'])) {
- $dataid = $Data['IEMI'];
- } else {
- exit;
- }
- $statustime = $Data['time'];
- $openids = $Data['phone'];
- $insert_id = $Data['insert_id'];
- $user_from = $Data['user_from'];
- $bz = $Data['bz'];
- addInt("insert into aaa (user_from,insert_id,dataid,txt) values ('" . $user_from . "'," . $insert_id . ",'" . $dataid . "','" . $Data . "')");
- if (!empty($Data['evt_name'])) {
- $status = $Data['evt_name'];
- } else {
- switch ($Data['evt']) {
- case 'LF01':
- $status = '声音报警';
- $where = " AND data2 like '%9%'";
- break;
- case 'LF03':
- $status = '电梯检修';
- $where = " AND data2 like '%9%'";
- break;
- case 'LF04':
- $status = '电梯检修恢复';
- $where = " AND data2 like '%9%'";
- break;
- case 'LF05':
- $status = '电梯故障';
- $where = " AND data2 like '%9%'";
- break;
- case 'LF0501':
- $status = '电梯异常停留';
- $where = " AND data2 like '%9%'";
- break;
- case 'LF0502':
- $status = '电梯异常开门';
- $where = " AND data2 like '%9%'";
- break;
- case 'LF0503':
- $status = '电梯异常关门';
- $where = " AND data2 like '%9%'";
- break;
- case 'LF0504':
- $status = '电梯异常走梯';
- $where = " AND data2 like '%9%'";
- break;
- case 'LF06':
- $status = '电梯故障恢复';
- $where = " AND data2 like '%9%'";
- break;
- default:
- $status = '其他' . $Data['Status'];
- $where = " AND data2 like '%9%'";
- 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 ='" . $dataid . "'");
- $union_sql = M()->query("select phone from sp_owner_phone WHERE owner_code='" . $company[0]['company'] . "' " . $where . " 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'] . "') " . $where . " and statusbb=1 ");
- if (count($union_sql) == 0) {
- exit;
- }
- $openids = $this->array_column1($union_sql, "phone");
- if (empty($openids)) {
- echo 'open is null';
- exit;
- }
- // $status11=M()->query("SELECT statustime FROM sp_devices_status where deviceid='".$dataid."'");
- $op = M()->query("SELECT openid FROM sp_wx_customuser WHERE type='wx' and idphone in($openids)");
- $access_token = GetAccess_Token1();
- $address = '警报地址:' . $company[0]['owner_address'] . $company[0]['unitinfo'];
- $deviceid = $dataid;
- $type = $status;
- $time = $statustime;
- // $remark='设备名称:'.$company[0]['owner_name'];
- // $ljcompany=$company[0]['company'];
- // $ljurl = "http://www.jd-ioe.com/jdxf/wxapp2.php/Home/Lifter/index/companyid/".$ljcompany;
- if (!empty($bz)) {
- $remark = $bz;
- } else {
- $remark = '设备名称:' . $company[0]['owner_name'];
- }
- $ljurl = "https://qhome.usky.cn/jdxf/wxapp2.php/Home/Fireinfo/index/type/17/id/" . $insert_id;
- foreach ($op as $o) {
- if (!empty($o['openid'])) {
- //token,微信id,地址,设备号,类型,时间,设备名称(或者其他内容)
- //{{first.DATA}}$address
- //设备号:{{keyword1.DATA}}$deviceid
- //报警类型:{{keyword2.DATA}}$type
- //时间:{{keyword3.DATA}}$time
- //{{remark.DATA}}$remark
- $this->SendDeviceAlarm($access_token, $o['openid'], $address, $deviceid, $type, $time, $remark, $ljurl, $url = '');
- }
- }
- }
- }
|