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.
245 lines
7.4 KiB
245 lines
7.4 KiB
<?php
|
|
|
|
//$postData = file_get_contents('php://input');
|
|
#echo "收到:" . $postData . "<br>";
|
|
require_once "database.php";
|
|
$postData='[{
|
|
"flag": 1202,
|
|
"fault_time": "2023-03-22 14:55:44",
|
|
"fault_message": "开门不到位",
|
|
"imei": "864442068537934",
|
|
"fault_level": 2,
|
|
"pass_code": "123456"
|
|
}, {
|
|
"flag": 1106,
|
|
"fault_time": "2023-03-22 15:11:53",
|
|
"fault_message": "未平层停靠",
|
|
"imei": "864442068537934",
|
|
"fault_level": 2,
|
|
"pass_code": "123456"
|
|
}, {
|
|
"flag": 1202,
|
|
"fault_time": "2023-03-22 15:50:11",
|
|
"fault_message": "开门不到位",
|
|
"imei": "864442068537934",
|
|
"fault_level": 2,
|
|
"pass_code": "123456"
|
|
}, {
|
|
"flag": 1202,
|
|
"fault_time": "2023-03-22 15:58:15",
|
|
"fault_message": "开门不到位",
|
|
"imei": "864442068537934",
|
|
"fault_level": 2,
|
|
"pass_code": "123456"
|
|
}, {
|
|
"fault_message": "设备在线",
|
|
"imei": "861577063351048",
|
|
"flag": "PF004",
|
|
"fault_time": "2023-03-22 16:00:01",
|
|
"fault_level": 0
|
|
}, {
|
|
"fault_message": "设备在线",
|
|
"imei": "864442068537884",
|
|
"flag": "PF004",
|
|
"fault_time": "2023-03-22 16:00:01",
|
|
"fault_level": 0
|
|
}, {
|
|
"flag": 1202,
|
|
"fault_time": "2023-03-22 16:19:33",
|
|
"fault_message": "开门不到位",
|
|
"imei": "864442068537934",
|
|
"fault_level": 2,
|
|
"pass_code": "123456"
|
|
}, {
|
|
"flag": 1202,
|
|
"fault_time": "2023-03-22 16:51:47",
|
|
"fault_message": "开门不到位",
|
|
"imei": "864442060239414",
|
|
"fault_level": 2,
|
|
"pass_code": "123456"
|
|
}, {
|
|
"flag": 1202,
|
|
"fault_time": "2023-03-22 17:12:45",
|
|
"fault_message": "开门不到位",
|
|
"imei": "861577063352970",
|
|
"fault_level": 2,
|
|
"pass_code": "123456"
|
|
}, {
|
|
"flag": 1202,
|
|
"fault_time": "2023-03-22 17:20:54",
|
|
"fault_message": "开门不到位",
|
|
"imei": "867590063954632",
|
|
"fault_level": 2,
|
|
"pass_code": "123456"
|
|
}, {
|
|
"flag": 1202,
|
|
"fault_time": "2023-03-22 20:55:12",
|
|
"fault_message": "开门不到位",
|
|
"imei": "861577063352749",
|
|
"fault_level": 2,
|
|
"pass_code": "123456"
|
|
}, {
|
|
"flag": 1202,
|
|
"fault_time": "2023-03-22 23:52:25",
|
|
"fault_message": "开门不到位",
|
|
"imei": "861577063352749",
|
|
"fault_level": 2,
|
|
"pass_code": "123456"
|
|
}, {
|
|
"flag": 1106,
|
|
"fault_time": "2023-03-23 07:27:21",
|
|
"fault_message": "未平层停靠",
|
|
"imei": "861577063352970",
|
|
"fault_level": 2,
|
|
"pass_code": "123456"
|
|
}, {
|
|
"flag": 1202,
|
|
"fault_time": "2023-03-23 08:11:33",
|
|
"fault_message": "开门不到位",
|
|
"imei": "861577063352970",
|
|
"fault_level": 2,
|
|
"pass_code": "123456"
|
|
}, {
|
|
"flag": 1202,
|
|
"fault_time": "2023-03-23 08:42:25",
|
|
"fault_message": "开门不到位",
|
|
"imei": "861577063352749",
|
|
"fault_level": 2,
|
|
"pass_code": "123456"
|
|
}, {
|
|
"flag": 1202,
|
|
"fault_time": "2023-03-23 11:40:12",
|
|
"fault_message": "开门不到位",
|
|
"imei": "861577063352749",
|
|
"fault_level": 2,
|
|
"pass_code": "123456"
|
|
}, {
|
|
"flag": 1106,
|
|
"fault_time": "2023-03-23 11:49:36",
|
|
"fault_message": "未平层停靠",
|
|
"imei": "864442068537819",
|
|
"fault_level": 2,
|
|
"pass_code": "123456"
|
|
}, {
|
|
"fault_message": "设备离线",
|
|
"imei": "867590064367099",
|
|
"flag": "PF003",
|
|
"fault_time": "2023-03-23 12:00:01",
|
|
"fault_level": 0
|
|
}, {
|
|
"fault_message": "设备在线",
|
|
"imei": "861577063352947",
|
|
"flag": "PF004",
|
|
"fault_time": "2023-03-23 12:00:02",
|
|
"fault_level": 0
|
|
}, {
|
|
"flag": 1202,
|
|
"fault_time": "2023-03-23 13:12:15",
|
|
"fault_message": "开门不到位",
|
|
"imei": "861577063352749",
|
|
"fault_level": 2,
|
|
"pass_code": "123456"
|
|
}]';
|
|
$data=json_decode($postData,true);
|
|
|
|
foreach($data as $row){
|
|
|
|
if ($postData) {
|
|
$data= $row;
|
|
|
|
// 用mysqli_query方法执行(sql语法)将结果存在变数中
|
|
$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_message=$data['fault_message'];
|
|
$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);
|
|
//echo $db_query.";<br/>";
|
|
//推送到客户端消息
|
|
//根据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);
|
|
//echo $push_messagedb_query.";<br/>";
|
|
//插入客户受付表
|
|
|
|
$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['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,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')";
|
|
// echo $db_query1.";<br/>";
|
|
mysqli_query($link, $db_query1);
|
|
|
|
|
|
|
|
}
|
|
}
|
|
mysqli_close($link);
|
|
//$myfile = fopen("receive_inovance.txt", "a") or die("Unable to open file!");
|
|
//fwrite($myfile, "Got it: " . $postData . "\n");
|
|
//fclose($myfile);
|
|
|
|
?>
|