73 lines
2.5 KiB
PHP
73 lines
2.5 KiB
PHP
<?php
|
|
namespace app\api\controller;
|
|
|
|
use app\common\logic\finance\ShareProfit;
|
|
use app\common\logic\task\TaskLogic;
|
|
use app\common\model\Company;
|
|
use app\common\model\task\Task;
|
|
use app\common\model\task_scheduling_plan\TaskSchedulingPlan;
|
|
use app\common\model\task_template\TaskTemplate;
|
|
use think\facade\Log;
|
|
use app\job\TaskInformationJob;
|
|
use Symfony\Component\HttpClient\HttpClient;
|
|
|
|
class CeshiController extends BaseApiController
|
|
{
|
|
public array $notNeedLogin = ['index','ceshi'];
|
|
|
|
public function index()
|
|
{
|
|
// $all=TaskSchedulingPlan::whereDay('end_time','yesterday')->where('is_pay',0)->with(['template_info','scheduling'])->select()->toArray();
|
|
// halt($all);
|
|
$all=TaskSchedulingPlan::whereDay('end_time')->where('is_pay',0)->with(['template_info','scheduling'])->select()->toArray();
|
|
foreach($all as $k=>$v){
|
|
queue(TaskInformationJob::class,$v);
|
|
}
|
|
halt(1);
|
|
}
|
|
|
|
public function ceshi(){
|
|
|
|
$time=strtotime(date('Y-m-d'));
|
|
// $time=strtotime(date('Y-m-d'));
|
|
// $tiem_end=$time+86399;
|
|
// $all=TaskTemplate::where('cron_time','<',$time)->where('status',1)->with('company')->select()->toArray();
|
|
$all=TaskTemplate::where('id',73)->with('company')->select()->toArray();
|
|
// $all=TaskSchedulingPlan::where('start_time','between',[$time,$tiem_end])->where('is_execute',0)->with(['template_info','scheduling'])->select()->toArray();
|
|
$company_id=0;
|
|
foreach($all as $k=>$v){
|
|
TaskLogic::CronAdd($v);
|
|
$company_id=$v['company_id'];
|
|
}
|
|
}
|
|
|
|
function getClosestPoint($points, $target) {
|
|
$minDistance = PHP_INT_MAX;
|
|
$closestPoint = null;
|
|
foreach ($points as $point) {
|
|
// halt($point,$target);
|
|
$distance = sqrt(pow(($point['lat'] - $target['lat']), 2) + pow(($point['lon'] - $target['lon']), 2));
|
|
|
|
if ($distance < $minDistance) {
|
|
$minDistance = $distance;
|
|
$closestPoint = $point;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
} |