更新
This commit is contained in:
parent
0ad0213870
commit
aa548966b5
app
@ -13,7 +13,7 @@ use Symfony\Component\HttpClient\HttpClient;
|
|||||||
|
|
||||||
class CeshiController extends BaseApiController
|
class CeshiController extends BaseApiController
|
||||||
{
|
{
|
||||||
public array $notNeedLogin = ['index','ceshi'];
|
public array $notNeedLogin = ['index','ceshi','ceshi1'];
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
@ -41,33 +41,23 @@ class CeshiController extends BaseApiController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getClosestPoint($points, $target) {
|
public function ceshi1(){
|
||||||
$minDistance = PHP_INT_MAX;
|
$params=[
|
||||||
$closestPoint = null;
|
'car_id'=>3,
|
||||||
foreach ($points as $point) {
|
'start_time'=>'2023-08-18',
|
||||||
// halt($point,$target);
|
'end_time'=>'2023-08-18 23:59:59'
|
||||||
$distance = sqrt(pow(($point['lat'] - $target['lat']), 2) + pow(($point['lon'] - $target['lon']), 2));
|
];
|
||||||
|
$task=Task::where('id',485)->select()->toArray();
|
||||||
if ($distance < $minDistance) {
|
foreach($task as $k=>$v){
|
||||||
$minDistance = $distance;
|
if(isset($v['extend']['terminus']['lnglat'])){
|
||||||
$closestPoint = $point;
|
$arr=$v['extend']['terminus']['lnglat'];
|
||||||
|
app(RemoteController::class)->coordinate($params,$arr[0],$arr[1]);
|
||||||
|
}
|
||||||
|
if(isset($v['extend']['transfer']['lnglat'])){
|
||||||
|
$arr=$v['extend']['transfer']['lnglat'];
|
||||||
|
app(RemoteController::class)->coordinate($params,$arr[0],$arr[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [$closestPoint,$distance];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function calculateDistance( $longitude1,$latitude1, $longitude2,$latitude2 ) {
|
|
||||||
$earthRadius = 6371; // 地球半径,单位为公里
|
|
||||||
|
|
||||||
$dLat = deg2rad($latitude2 - $latitude1);
|
|
||||||
$dLon = deg2rad($longitude2 - $longitude1);
|
|
||||||
|
|
||||||
$a = sin($dLat/2) * sin($dLat/2) +
|
|
||||||
cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) *
|
|
||||||
sin($dLon/2) * sin($dLon/2);
|
|
||||||
$c = 2 * asin(sqrt($a));
|
|
||||||
|
|
||||||
return $earthRadius * $c*1000;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -17,6 +17,7 @@ namespace app\common\model;
|
|||||||
use app\common\model\contract\Contract;
|
use app\common\model\contract\Contract;
|
||||||
use app\common\model\dict\DictData;
|
use app\common\model\dict\DictData;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Company模型
|
* Company模型
|
||||||
@ -25,6 +26,9 @@ use think\facade\Db;
|
|||||||
*/
|
*/
|
||||||
class Company extends BaseModel
|
class Company extends BaseModel
|
||||||
{
|
{
|
||||||
|
use SoftDelete;
|
||||||
|
|
||||||
|
protected $deleteTime = 'delete_time';
|
||||||
|
|
||||||
protected $name = 'company';
|
protected $name = 'company';
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user