You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
254 lines
11 KiB
254 lines
11 KiB
<?php
|
|
#header("Content-Type:text/html;charset=utf-8");
|
|
require_once "database.php";
|
|
$postData = file_get_contents('php://input');
|
|
#echo "收到:" . $postData . "<br>";
|
|
#var_dump($postData); // php://input
|
|
#var_dump($_POST);
|
|
|
|
print_r(urldecode($postData));
|
|
$myfile = fopen("receive_aijiati.txt", "a") or die("Unable to open file!");
|
|
#fwrite($myfile, "Got it: " . json_encode($postData) . "\n");
|
|
fwrite($myfile, "Got it: " . urldecode($postData) . date('Y/m/d H:i:s') . "\n"); #解決亂碼問題
|
|
#fwrite($myfile, "Got it: " . $_POST . "\n");
|
|
fclose($myfile);
|
|
|
|
$urldata=urldecode($postData);
|
|
$wornDataarr=explode("=",$urldata);
|
|
$wornData=$wornDataarr[1];
|
|
if ($wornData) {
|
|
$data=json_decode($wornData,true);
|
|
$imei=$data['imei'];
|
|
$db_query = "SELECT * FROM facility WHERE imei=$imei";
|
|
$data1 = mysqli_query($link,$db_query);
|
|
$row = mysqli_fetch_array($data1, MYSQLI_ASSOC);
|
|
$facilityno=$row['facilityno'];
|
|
$source='aijiati';
|
|
$flag=$data['flag'];
|
|
|
|
$fault_messagedata = array(
|
|
"1108" => "運行時開門",
|
|
"1207" => "門開時運行",
|
|
"1100" => "運行中急停(安全回路斷路)",
|
|
"1103" => "運行速度異常偏大",
|
|
"1102" => "運行速度異常偏小",
|
|
"1101" => "運行超時",
|
|
"1106" => "開鎖區域外停止",
|
|
"1104" => "轎廂沖頂",
|
|
"1105" => "轎廂蹲底",
|
|
"1205" => "關門不到位",
|
|
"1202" => "開門不到位",
|
|
"1206" => "關門過程異常",
|
|
"1203" => "開門過程異常",
|
|
"1201" => "平層不開門",
|
|
"1204" => "長時間不關門",
|
|
"1107" => "轎廂意外移動",
|
|
"1301" => "電梯不運行",
|
|
"1302" => "運行時有異常振動",
|
|
"301" => "電瓶車進入",
|
|
"1303" => "電梯困人",
|
|
"1208" => "反覆開關門",
|
|
"6" => "檢修模式停止",
|
|
"1400" => "檢修模式",
|
|
"PF004" => "設備在線",
|
|
"PF003" => "設備離線"
|
|
|
|
);
|
|
|
|
//$fault_message=$data['fault_message'];
|
|
|
|
$fault_message=$fault_messagedata[$flag];
|
|
$fault_level=$data['fault_level'];
|
|
|
|
$fault_time=$data['fault_time'];
|
|
$fault_level=$data['fault_level'];
|
|
|
|
$pass_code=$data['pass_code'];
|
|
$start_date=$data['start_date'];
|
|
$end_date=$data['end_date'];
|
|
$creater = $data['creater'];
|
|
$create_at = date('Y/m/d H:i:s');
|
|
//插入错误记录表
|
|
$db_query = "insert into fault_log(facilityno,source,imei,flag,fault_message";
|
|
$db_query .= ",fault_level,fault_time,pass_code,start_date,end_date,creater,create_at) values (";
|
|
$db_query .= "'$facilityno', '$source', '$imei', '$flag', '$fault_message', '$fault_level',";
|
|
$db_query .= "'$fault_time', '$pass_code', '$start_date', '$end_date',";
|
|
$db_query .= "'$creater','$create_at')";
|
|
$result = mysqli_query($link, $db_query);
|
|
|
|
//推送到客户端消息
|
|
//根据imei值查询电梯信息
|
|
|
|
$accountid=$row['customerid'];
|
|
$message_detail='電梯編號:'.$row['facilityno'].'地址:'.$row['address'].'-'.$fault_message;//消息内容
|
|
$pushed_time=date('Y/m/d H:i:s');//系统推送时间
|
|
$push_messagecreater='system';
|
|
$push_messagecreate_at=date('Y/m/d H:i:s');
|
|
$push_messagedb_query = "insert into push_message(accountid,message_detail,pushed_time,source";
|
|
$push_messagedb_query .= ",creater,create_at) values (";
|
|
$push_messagedb_query .= "'$accountid', '$message_detail', '$pushed_time','$source',";
|
|
$push_messagedb_query .= "'$push_messagecreater','$push_messagecreate_at')";
|
|
mysqli_query($link, $push_messagedb_query);
|
|
|
|
//插入客户受付表
|
|
|
|
|
|
$repairerid=$row['repairerid'];//保养员id;
|
|
$repairername=$row['repairername'];//保养员i姓名;
|
|
//查询客户姓名
|
|
$accountidA=$row['customerid'];
|
|
$db_query4 = "SELECT * FROM account WHERE accountid='$accountidA'";
|
|
$data4 = mysqli_query($link,$db_query4);
|
|
$row4 = mysqli_fetch_array($data4, MYSQLI_ASSOC);
|
|
|
|
$facilityno=$row['facilityno'];
|
|
$sitename=$row['customerid'];
|
|
$customname=$row4['name'];//客户姓名;
|
|
$customtel=$row4['tel'];//客户电话;
|
|
$caller='system/aijiati';
|
|
$customerconfirmationbar='';
|
|
$address=$row['address'];
|
|
$buildingnumber='';
|
|
$positionnumber='';
|
|
$maintenanceoperationcategory='';
|
|
$brandmodel='';
|
|
$faultstate=$fault_message;
|
|
$investigationprocess='';
|
|
$causeanalysis='';
|
|
$processingprocess='';
|
|
$calltime=date('Y/m/d H:i:s');
|
|
$arrivaltime='';
|
|
$completiontime='';
|
|
$returntime='';
|
|
$handlestaff=$repairerid;
|
|
$handstaffname=$repairername;
|
|
$supportstaff='';
|
|
$supporttime='';
|
|
$faultcode=$data['flag'];
|
|
$remarks='';
|
|
$operationstaff='system';
|
|
$filingstaff='';
|
|
$supervisor= '';
|
|
$creater = 'system';
|
|
$create_at = date('Y/m/d H:i:s');
|
|
$updatee_at=date('Y/m/d H:i:s');
|
|
|
|
$db_query1 = "insert into fault_notification_job_handling(facilityno,sitename,customtel,customname,caller,customerconfirmationbar,address";
|
|
$db_query1 .= ",buildingnumber,positionnumber,maintenanceoperationcategory,brandmodel,faultstate,investigationprocess";
|
|
$db_query1 .= ",causeanalysis,processingprocess,calltime,arrivaltime,completiontime,returntime";
|
|
$db_query1 .= ",handlestaff,handstaffname,supportstaff,supporttime,faultcode,remarks,operationstaff,filingstaff";
|
|
$db_query1 .= ",imei,supervisor,creater,create_at,updatee_at) values (";
|
|
$db_query1 .= "'$facilityno', '$sitename','$customtel','$customname','$caller', '$customerconfirmationbar', '$address', '$buildingnumber',";
|
|
$db_query1 .= "'$positionnumber', '$maintenanceoperationcategory', '$brandmodel', '$faultstate','$investigationprocess',";
|
|
$db_query1 .= "'$causeanalysis','$processingprocess','$calltime','$arrivaltime','$completiontime','$returntime',";
|
|
$db_query1 .= "'$handlestaff','$handstaffname','$supportstaff','$supporttime','$faultcode','$remarks','$operationstaff','$filingstaff',";
|
|
$db_query1 .= "'$imei','$supervisor','$creater','$create_at','$updatee_at')";
|
|
mysqli_query($link, $db_query1);
|
|
|
|
if ($mid = mysqli_insert_id($link)) {
|
|
|
|
if (mysqli_affected_rows($link) > 0) {
|
|
echo "<script type ='text/JavaScript'>";
|
|
echo "alert('新增成功')";
|
|
echo "</script>";
|
|
|
|
} else {
|
|
echo "<script type ='text/JavaScript'>";
|
|
echo "alert('新增失敗,請重新操作[I]')";
|
|
echo "</script>";
|
|
}
|
|
} else {
|
|
echo "<script type ='text/JavaScript'>";
|
|
echo "alert('新增失敗,請重新操作[M]')";
|
|
echo "</script>";
|
|
}
|
|
|
|
mysqli_close($link);
|
|
|
|
//过滤掉推送消息是1106,PF004的数据
|
|
if($flag==1106 || $flag=='1106' || $flag=='PF004'){
|
|
echo "拦截数据";
|
|
}else{
|
|
//以下推送到客户端消息
|
|
$access_token = array();
|
|
$access_token[]="blymLDSO21gDaCXA6nJ2jf6fEZTNE0wEwANbLAhKMhM";
|
|
$TargetCount = count($access_token);
|
|
$Push_Content['message'] = $faultstate . "\n";
|
|
$Push_Content['message'] = $Push_Content['message'] . "電梯編號: " . $facilityno . "\n";
|
|
$Push_Content['message'] = $Push_Content['message'] . "故障代碼: " . $faultcode . "\n";
|
|
$Push_Content['message'] = $Push_Content['message'] . "故障時間: " . $calltime . "\n";
|
|
$Push_Content['message'] = $Push_Content['message'] . "電梯地址: " . $address . "\n";
|
|
$Push_Content['message'] = $Push_Content['message'] . "客戶名稱: " . $customname . "\n";
|
|
$Push_Content['message'] = $Push_Content['message'] . "客戶電話: " . $customtel . "\n";
|
|
$Push_Content['message'] = $Push_Content['message'] . "保養員: " . $handstaffname . "(" . $handlestaff . ")";
|
|
#$Push_Content['message'] = $Push_Content['message'] . "發生時間: " . date('Y-m-d H:i:s');
|
|
|
|
for ($i=0;$i<$TargetCount;$i++) {
|
|
$ch = curl_init("https://notify-api.line.me/api/notify");
|
|
curl_setopt($ch, CURLOPT_POST, true);
|
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($Push_Content));
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
|
'Content-Type: application/x-www-form-urlencoded',
|
|
'Authorization: Bearer '.$access_token[$i]
|
|
));
|
|
$response_json_str = curl_exec($ch);
|
|
curl_close($ch);
|
|
}
|
|
//以上推送到客户端消息
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
$data = json_decode(file_get_contents('php://input'), true);
|
|
$fp = fopen('receive_aijiati.txt', 'a+');
|
|
fwrite($fp, print_r($data, true));
|
|
echo json_encode($data);
|
|
*/
|
|
|
|
/*
|
|
$url_array = Array("getMd5Token" => "http://192.168.20.65/api/postandsave/2.php",
|
|
"getAccessToken" => "http://139.196.43.134:61088//zaagtech-1.0.0/iotinterface/getAccessToken",
|
|
"getSessionToken" => "http://139.196.43.134:61088//zaagtech-1.0.0/iotinterface/getSessionToken",
|
|
"getElvByCompany" => "http://139.196.43.134:61088/zaagtech-1.0.0/iotinterface/getElvByCompany",
|
|
"getElvInfo" => "http://139.196.43.134:61088/zaagtech-1.0.0/iotinterface/getElvInfo",
|
|
"getElvReport" => "http://139.196.43.134:61088/zaagtech-1.0.0/iotinterface/getElvReport",
|
|
"getRunTime" => "http://139.196.43.134:61088/zaagtech-1.0.0/iotinterface/getRunTime",
|
|
"getFault" => "http://139.196.43.134:61088/zaagtech-1.0.0/iotinterface/getFault",
|
|
"getEvent" => "http://139.196.43.134:61088/zaagtech-1.0.0/iotinterface/getEvent",
|
|
"getHisRuntime" => "http://139.196.43.134:61088/zaagtech-1.0.0/iotinterface/getHisRuntime",
|
|
"getHisFault" => "http://139.196.43.134:61088/zaagtech-1.0.0/iotinterface/getHisFault",
|
|
"getHisEvent" => "http://139.196.43.134:61088/zaagtech-1.0.0/iotinterface/getHisEvent",
|
|
"getMaintainList" => "http://139.196.43.134:61088/zaagtech-1.0.0/iotinterface/getMaintainList",
|
|
"getFaultList" => "http://139.196.43.134:61088/zaagtech-1.0.0/iotinterface/getFaultList",
|
|
"getElevatorParameter" => "http://139.196.43.134:61088/zaagtech-1.0.0/iotinterface/getElevatorParameter",
|
|
"getDeviceRunInfo" => "http://139.196.43.134:61088/zaagtech-1.0.0/iotinterface/getDeviceRunInfo",
|
|
"getPreviewURLsByImei" => "http://139.196.43.134:61088/zaagtech-1.0.0/iotinterface/getPreviewURLsByImei",
|
|
"setWarningPost" => "http://139.196.43.134:61088/zaagtech-1.0.0/iotinterface/setWarningPost",
|
|
"setTestAlarm" => "http://localhost:61096/test/setTestAlarm"
|
|
);
|
|
|
|
echo json_encode($url_array);
|
|
*/
|
|
|
|
|
|
//echo '{"code":1,"msg":"the API!"}';
|
|
|
|
|
|
/*
|
|
if ($data == ""){
|
|
echo "0000";
|
|
}else{
|
|
echo "1111" . $data;
|
|
}
|
|
*/
|
|
|
|
?>
|