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.
181 lines
6.3 KiB
181 lines
6.3 KiB
<?php
|
|
//$postData = file_get_contents('php://input');
|
|
#echo "收到:" . $postData . "<br>";
|
|
require_once "database.php";
|
|
$postData='{
|
|
"callbackType": "4",
|
|
"data": {
|
|
"aliasOfAddress": "TN02-01",
|
|
"eventCode": 6,
|
|
"eventData": "E42",
|
|
"eventRealTimeDatas": {
|
|
"一体机F版本": "0",
|
|
"一体机L版本": "0",
|
|
"一体机V版本": "202",
|
|
"一体机型号": "0",
|
|
"上报时间": "2023-01-31 16:20:41",
|
|
"串口通信异常": "正常",
|
|
"供电状态": "正常",
|
|
"信号强度": "22",
|
|
"停机状态": "无",
|
|
"厂家编号": "0",
|
|
"开关门状态": "关门",
|
|
"故障状态": "正常",
|
|
"是否有人": "有人",
|
|
"显示楼层_1": " ",
|
|
"显示楼层_2": "2",
|
|
"显示楼层位数": "2",
|
|
"服务模式": "低速返平层",
|
|
"检修状态": "正常",
|
|
"楼层": "2层",
|
|
"电梯平层信号": "非平层",
|
|
"电梯控制器有密码": "无密码",
|
|
"电梯故障代码": "0",
|
|
"电梯故障困人信号": "故障",
|
|
"电梯故障子码": "0",
|
|
"电梯门区信号": "门区外",
|
|
"网络类型": "4G",
|
|
"负载状态": "轻载",
|
|
"负载百分比": "0.00%",
|
|
"运行方向": "运行上行",
|
|
"运行速度": "0.00m/s"
|
|
},
|
|
"eventStatus": 0,
|
|
"eventTime": 1675153241000,
|
|
"factoryNO": "01",
|
|
"failureCodeDesc": "運行中門鎖斷開",
|
|
"msgSeq": 1675181900,
|
|
"regCode": "74886568852007RKH2P000000000",
|
|
"registerCode": "TN02-01",
|
|
"tdSerial": "1"
|
|
}
|
|
}';
|
|
|
|
|
|
if ($postData) {
|
|
$data=json_decode($postData,true);
|
|
// 用mysqli_query方法执行(sql语法)将结果存在变数中
|
|
$iotnumber=$data['data']['regCode'];
|
|
$db_queryf = "SELECT * FROM facility WHERE iotnumber='$iotnumber'";
|
|
$data1 = mysqli_query($link,$db_queryf);
|
|
$row = mysqli_fetch_array($data1, MYSQLI_ASSOC);
|
|
$facilityno=$row['facilityno'];
|
|
$source='Monarch';
|
|
$flag=$data['data']['eventCode'].'/'.$data['data']['eventData'];
|
|
//插入错误记录表
|
|
$imei='';
|
|
$fault_message=$data['data']['failureCodeDesc'];;
|
|
$fault_level='';
|
|
$fault_time=$data['data']['eventTime'];
|
|
$fault_level='';
|
|
|
|
$pass_code='';
|
|
$start_date='';
|
|
$end_date='';
|
|
|
|
$eventStatus=$data['data']['eventStatus'];
|
|
if(empty($data['data']['eventData'])){
|
|
$eventData='';
|
|
}else{
|
|
$eventData=$data['data']['eventData'];
|
|
}
|
|
|
|
if(empty($data['data']['failureCodeDesc'])){
|
|
$failureCodeDesc='';
|
|
}else{
|
|
$failureCodeDesc=$data['data']['failureCodeDesc'];
|
|
}
|
|
|
|
$creater = 'system';
|
|
$create_at = date('Y/m/d H:i:s');
|
|
$db_query = "insert into fault_log(facilityno,source,imei,flag,fault_message,eventStatus,eventData,failureCodeDesc";
|
|
$db_query .= ",fault_level,fault_time,pass_code,start_date,end_date,creater,create_at) values (";
|
|
$db_query .= "'$facilityno', '$source', '$imei', '$flag', '$fault_message','$eventStatus','$eventData','$failureCodeDesc','$fault_level',";
|
|
$db_query .= "'$fault_time', '$pass_code', '$start_date', '$end_date',";
|
|
$db_query .= "'$creater','$create_at')";
|
|
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";
|
|
$push_messagedb_query .= ",creater,create_at) values (";
|
|
$push_messagedb_query .= "'$accountid', '$message_detail', '$pushed_time',";
|
|
$push_messagedb_query .= "'$push_messagecreater','$push_messagecreate_at')";
|
|
mysqli_query($link, $push_messagedb_query);
|
|
|
|
// //插入客户受付表
|
|
|
|
$facilityno=$row['facilityno'];
|
|
$sitename=$row['customerid'];
|
|
$caller='system';
|
|
$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='';
|
|
$supportstaff='';
|
|
$supporttime='';
|
|
$faultcode=$data['data']['eventCode'].'/'.$data['data']['eventData'];
|
|
$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,caller,customerconfirmationbar,address";
|
|
$db_query1 .= ",buildingnumber,positionnumber,maintenanceoperationcategory,brandmodel,faultstate,investigationprocess";
|
|
$db_query1 .= ",causeanalysis,processingprocess,calltime,arrivaltime,completiontime,returntime";
|
|
$db_query1 .= ",handlestaff,supportstaff,supporttime,faultcode,remarks,operationstaff,filingstaff";
|
|
$db_query1 .= ",supervisor,creater,create_at,updatee_at) values (";
|
|
$db_query1 .= "'$facilityno', '$sitename', '$caller', '$customerconfirmationbar', '$address', '$buildingnumber',";
|
|
$db_query1 .= "'$positionnumber', '$maintenanceoperationcategory', '$brandmodel', '$faultstate','$investigationprocess',";
|
|
$db_query1 .= "'$causeanalysis','$processingprocess','$calltime','$arrivaltime','$completiontime','$returntime',";
|
|
$db_query1 .= "'$handlestaff','$supportstaff','$supporttime','$faultcode','$remarks','$operationstaff','$filingstaff',";
|
|
$db_query1 .= "'$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);
|
|
}else{
|
|
echo "2222";
|
|
}
|
|
//$myfile = fopen("receive_inovance.txt", "a") or die("Unable to open file!");
|
|
//fwrite($myfile, "Got it: " . $postData . "\n");
|
|
//fclose($myfile);
|
|
|
|
?>
|