2023-08-10 17:10:12 +08:00
|
|
|
<?php
|
|
|
|
namespace app\api\controller;
|
|
|
|
|
|
|
|
use app\common\logic\finance\ShareProfit;
|
|
|
|
use app\common\logic\task\TaskLogic;
|
2023-08-14 17:44:55 +08:00
|
|
|
use app\common\model\Company;
|
2023-08-10 17:10:12 +08:00
|
|
|
use app\common\model\task\Task;
|
|
|
|
use app\common\model\task_scheduling_plan\TaskSchedulingPlan;
|
2023-08-18 16:32:41 +08:00
|
|
|
use app\common\model\task_template\TaskTemplate;
|
2023-08-14 17:44:55 +08:00
|
|
|
use think\facade\Log;
|
2023-08-15 14:38:20 +08:00
|
|
|
use app\job\TaskInformationJob;
|
2023-08-21 15:14:39 +08:00
|
|
|
use Symfony\Component\HttpClient\HttpClient;
|
2023-08-10 17:10:12 +08:00
|
|
|
|
|
|
|
class CeshiController extends BaseApiController
|
|
|
|
{
|
|
|
|
public array $notNeedLogin = ['index','ceshi'];
|
|
|
|
|
|
|
|
public function index()
|
|
|
|
{
|
2023-08-18 17:29:51 +08:00
|
|
|
// $all=TaskSchedulingPlan::whereDay('end_time','yesterday')->where('is_pay',0)->with(['template_info','scheduling'])->select()->toArray();
|
|
|
|
// halt($all);
|
2023-08-18 18:11:32 +08:00
|
|
|
$all=TaskSchedulingPlan::whereDay('end_time')->where('is_pay',0)->with(['template_info','scheduling'])->select()->toArray();
|
2023-08-15 14:38:20 +08:00
|
|
|
foreach($all as $k=>$v){
|
|
|
|
queue(TaskInformationJob::class,$v);
|
|
|
|
}
|
|
|
|
halt(1);
|
2023-08-10 17:10:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public function ceshi(){
|
2023-08-18 16:32:41 +08:00
|
|
|
|
2023-08-10 17:10:12 +08:00
|
|
|
$time=strtotime(date('Y-m-d'));
|
2023-08-21 15:14:39 +08:00
|
|
|
// $time=strtotime(date('Y-m-d'));
|
|
|
|
// $tiem_end=$time+86399;
|
2023-08-21 16:32:56 +08:00
|
|
|
// $all=TaskTemplate::where('cron_time','<',$time)->where('status',1)->with('company')->select()->toArray();
|
|
|
|
$all=TaskTemplate::where('id',73)->with('company')->select()->toArray();
|
2023-08-21 15:14:39 +08:00
|
|
|
// $all=TaskSchedulingPlan::where('start_time','between',[$time,$tiem_end])->where('is_execute',0)->with(['template_info','scheduling'])->select()->toArray();
|
2023-08-14 17:44:55 +08:00
|
|
|
$company_id=0;
|
2023-08-10 17:10:12 +08:00
|
|
|
foreach($all as $k=>$v){
|
|
|
|
TaskLogic::CronAdd($v);
|
2023-08-14 17:44:55 +08:00
|
|
|
$company_id=$v['company_id'];
|
|
|
|
}
|
2023-08-10 17:10:12 +08:00
|
|
|
}
|
2023-08-18 10:12:56 +08:00
|
|
|
|
|
|
|
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];
|
|
|
|
}
|
2023-08-21 15:14:39 +08:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2023-08-10 17:10:12 +08:00
|
|
|
}
|