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.
 
 
 
 
 
 

50 lines
2.0 KiB

<?php
error_reporting(0);
include '../DB.php';
try {
$conn = new DB();
if ($conn) {
$date = date('Y-m-d'); //当前时间
$sql = "SELECT distinct(latitude),longitude,upload_time,account_id from location_last ORDER BY upload_time desc limit 0,100";
$result = $conn->getAll($sql);
for($i=0;$i<sizeof($result);$i++){
// $result[$i]['latitude']= number_format($result[$i]['latitude'], 7, ',', ' ');
// $result[$i]['longitude']= number_format($result[$i]['longitude'], 7, ',', ' ');
$account_id= $result[$i]['account_id'];
$accountsql="SELECT * from account where accountid='$account_id'";
$accountinfo=$conn->getRow($accountsql);
$result[$i]['name']= $accountinfo['name'];
$result[$i]['tel']= $accountinfo['tel'];
//最新位置时间
$upload_time=strtotime($result[$i]['upload_time']);
$firstchoose_time=date('Y-m-d H:m:s',$upload_time-86400*3);
$location_logsql="SELECT distinct(latitude) as lat,longitude as lng from location_log where account_id='$account_id' and upload_time>'$firstchoose_time' limit 0,5";
$location_loginffo=$conn->getAll($location_logsql);
// $chooseloginfo=[];
// for($j=0;$j<sizeof($location_loginffo);$j++){
// $chooseloginfo[0]=$location_loginffo[0];
// $chooselenth=intval(sizeof($chooseloginfo)-1);
// $cha=abs($location_loginffo[$j]['lat']-$chooseloginfo[$chooselenth]['lat'])*1000;
//// if($cha<3&&$cha>0){
//// $chooselenth=$chooselenth+1;
//// $chooseloginfo[$chooselenth]=$location_loginffo[$j];
//// }
// $chooseloginfo[$chooselenth]=$location_loginffo[$j];
//
// }
$result[$i]['guiji']= $location_loginffo;
}
echo json_encode($result);
}
} catch (Exception $e) {
die($e->getMessage());
}