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.
193 lines
7.5 KiB
193 lines
7.5 KiB
<?php
|
|
#抓出愛佳梯(aijiati)與默納克(inovance)當日所有電梯的故障明細
|
|
#抓出愛佳梯(aijiati)與默納克(inovance)當月所有電梯的故障明細
|
|
#抓出愛佳梯(aijiati)與默納克(inovance)所有電梯現在狀態。
|
|
#抓出愛佳梯(aijiati)與默納克(inovance),特定電梯現在的狀態。
|
|
|
|
$query_date = $_REQUEST["query_date"];
|
|
$apikey = $_REQUEST["apikey"];
|
|
|
|
#昶屹
|
|
#$sys_code = "CSVIP1";
|
|
#$api_password = "DqgAtA";
|
|
|
|
#永佳捷
|
|
$sys_code = "OPBIOD";
|
|
$api_password = "123456";
|
|
|
|
#普來特富
|
|
#$sys_code = "6TJQBP";
|
|
#$api_password = "123456";
|
|
|
|
$url_array = Array("getMd5Token" => "http://139.196.43.134:61088//zaagtech-1.0.0/iotinterface/getMd5Token",
|
|
"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"
|
|
);
|
|
|
|
function postdata($parm, $url){
|
|
$curl = curl_init($url);
|
|
curl_setopt($curl, CURLOPT_HEADER, false);
|
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查
|
|
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2); // 从证书中检查SSL加密算法是否存在
|
|
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type: application/json"));
|
|
curl_setopt($curl, CURLOPT_POST, true);
|
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $parm);
|
|
$results = curl_exec($curl);
|
|
curl_close($curl);
|
|
return json_decode($results, true);
|
|
}
|
|
|
|
function aijiati_30dayserror($sys_code, $api_password, $url_array, $query_date){
|
|
|
|
# 1.取得MD5
|
|
$parm = [
|
|
"sys_code" => $sys_code,
|
|
"password" => $api_password
|
|
];
|
|
$parm = json_encode($parm);
|
|
$results = postdata($parm, $url_array["getMd5Token"]);
|
|
#print_r($results). "<br>";
|
|
$md5_status = $results["response_code"];
|
|
$md5 = $results["resp"];
|
|
#echo $md5 . "<br>";
|
|
|
|
/*
|
|
$parm = json_encode(["sys_code" => $sys_code, "token" => "cb96e982266a6b9670af3930607e043f"]);
|
|
$results = postdata($parm, $url_array["getAccessToken"]);
|
|
print_r($results);
|
|
*/
|
|
|
|
# 2.获取access_token
|
|
|
|
if ($md5_status == 200){
|
|
$parm = [
|
|
"sys_code" => $sys_code,
|
|
"token"=>$md5
|
|
];
|
|
$parm = json_encode($parm);
|
|
$results = postdata($parm, $url_array["getAccessToken"]);
|
|
#print_r($results);
|
|
$access_token_status = $results["response_code"];
|
|
$access_token = $results["response_data"]["access_token"];
|
|
#echo $access_token;
|
|
}
|
|
|
|
# 3.获取session_token
|
|
if ($access_token_status == 200){
|
|
$parm = [
|
|
"access_token"=>$access_token
|
|
];
|
|
$parm = json_encode($parm);
|
|
$results = postdata($parm, $url_array["getSessionToken"]);
|
|
#print_r($results);
|
|
$session_token_status = $results["response_code"];
|
|
$session_token = $results["resp"];
|
|
#echo $session_token;
|
|
}
|
|
|
|
# 4.获取企业电梯信息
|
|
if ($session_token_status == 200){
|
|
$parm = [
|
|
"sys_code" => $sys_code,
|
|
"session_token" => $session_token,
|
|
"param"=> [
|
|
"code" => $sys_code //邀请码
|
|
]
|
|
];
|
|
$parm = json_encode($parm);
|
|
$results = postdata($parm, $url_array["getElvByCompany"]);
|
|
#print_r($results);
|
|
$getElvByCompany_status = $results["response_code"];
|
|
$elevator_amount = $results["resp"]["elv_count"];
|
|
$elevator_company = $results["resp"]["company_name"];
|
|
$elevator_array = $results["resp"]["elvs"];
|
|
|
|
$elevator_registe_code_array = array_column($elevator_array, "registe_code"); //电梯注册码
|
|
$elevator_imei_array = array_column($elevator_array, "imei"); //设备imei编号
|
|
$elevator_province_array = array_column($elevator_array, "province"); //省
|
|
$elevator_city_array = array_column($elevator_array, "city"); //市
|
|
$elevator_district_array = array_column($elevator_array, "district"); //区
|
|
$elevator_street_array = array_column($elevator_array, "street"); //街道
|
|
$elevator_community_array = array_column($elevator_array, "community"); //小区
|
|
$elevator_name_array = array_column($elevator_array, "name"); //梯号
|
|
#print_r($elevator_imei_array);
|
|
#echo "<br>" . "------------" . "<br>";
|
|
|
|
}
|
|
|
|
# 11.历史故障集合------(total_count為總筆數)
|
|
$page_number = 1; //页码
|
|
$page_size = pow(2,10); //每页总数,最多1024
|
|
$end_date = $query_date; //要查詢的結束日期
|
|
$start_date = date('Y-m-d',strtotime("$end_date -30 day")); //要查詢的開始日期
|
|
$final = array();
|
|
if ($session_token_status == 200){
|
|
foreach ($elevator_imei_array as $imei_value ){
|
|
//echo 'value='.$value.'<br>';
|
|
$parm = [
|
|
"sys_code" => $sys_code,
|
|
"session_token" => $session_token,
|
|
"param"=> [
|
|
"page_number" => $page_number, //页码
|
|
"page_size" => $page_size, //每页总数
|
|
"imei" => $imei_value, //imei号 和注册码二选一填写
|
|
"register_code" => "", //注册码 和imei二选一填写
|
|
"start_date" => $start_date, //要查詢的開始日期
|
|
"end_date" => $end_date //要查詢的結束日期
|
|
]
|
|
];
|
|
$parm = json_encode($parm);
|
|
$results = postdata($parm, $url_array["getHisFault"]);
|
|
#print_r($results);
|
|
#echo "<br>" . "------------" . "<br>";
|
|
#echo count($results["resp"]["fault_infos"]) . "<br>";
|
|
if (count($results["resp"]["fault_infos"]) > 0){
|
|
#$results["resp"]["fault_infos"][0] += ["elevId" => $imei_value]; #插入elevator id
|
|
#print_r($results["resp"]["fault_infos"]);
|
|
#echo "<br>" . "------------" . "<br>";
|
|
#$final += $results["resp"]["fault_infos"];
|
|
|
|
for ($i = 0; $i < count($results["resp"]["fault_infos"]); $i++) {
|
|
#print_r($results["resp"]["fault_infos"][$i]);
|
|
#echo "<br>" . "------------" . "<br>";
|
|
array_push($final, $results["resp"]["fault_infos"][$i]);
|
|
}
|
|
}
|
|
}
|
|
|
|
#print_r($final);
|
|
$final = json_encode($final);
|
|
header('Content-type:application/json;charset=utf-8');
|
|
echo $final;
|
|
#print_r($final, True);
|
|
#echo "<br>" . "------------" . "<br>";
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if ($apikey == "Masada90491339") {
|
|
#aijiati_30dayserror($sys_code, $api_password, $url_array, date("Y-m-d"));
|
|
#aijiati_30dayserror($sys_code, $api_password, $url_array, "2022-11-17");
|
|
aijiati_30dayserror($sys_code, $api_password, $url_array, $query_date);
|
|
}
|
|
|
|
?>
|