This commit is contained in:
mkm 2023-08-21 15:14:39 +08:00
parent e2b585f3c5
commit fc9c0d52d3
3 changed files with 79 additions and 127 deletions

View File

@ -9,6 +9,7 @@ use app\common\model\task_scheduling_plan\TaskSchedulingPlan;
use app\common\model\task_template\TaskTemplate; use app\common\model\task_template\TaskTemplate;
use think\facade\Log; use think\facade\Log;
use app\job\TaskInformationJob; use app\job\TaskInformationJob;
use Symfony\Component\HttpClient\HttpClient;
class CeshiController extends BaseApiController class CeshiController extends BaseApiController
{ {
@ -53,6 +54,26 @@ halt(2);
public function ceshi(){ public function ceshi(){
$parmas=[
'car_id'=>3,
'start_time'=>'2023-08-18',
'end_time'=>'2023-08-18 23:59:59',
];
$res = HttpClient::create()->request('GET', 'http://logistics.lihaink.cn/api/getCarHistory', [
'query' => $parmas,
]);
$json=json_decode($res->getContent(),true);
$points=$json['data'];
$target =[
"lat"=> 28.917378,
"lon"=> 105.443005
];
$closestPoint = $this->getClosestPoint($points, $target);
halt($this->calculateDistance($target['lon'], $target['lat'], $closestPoint[0]['lon'], $closestPoint[0]['lat'],1));
halt($closestPoint);
$time=strtotime(date('Y-m-d')); $time=strtotime(date('Y-m-d'));
// $time=strtotime(date('Y-m-d')); // $time=strtotime(date('Y-m-d'));
// $tiem_end=$time+86399; // $tiem_end=$time+86399;
@ -64,94 +85,6 @@ halt(2);
TaskLogic::CronAdd($v); TaskLogic::CronAdd($v);
$company_id=$v['company_id']; $company_id=$v['company_id'];
} }
halt(1);
$points = [
[
"lat"=> 28.914962,
"lon"=>105.442355
],
[
"lat"=> 28.915456,
"lon"=> 105.443891
],
[
"lat"=> 28.917516,
"lon"=> 105.443371
],
[
"lat"=> 28.917536,
"lon"=> 105.443415
],
[
"lat"=> 28.917001,
"lon"=> 105.442421
],
[
"lat"=> 28.917103,
"lon"=> 105.442291
],
[
"lat"=> 28.916658,
"lon"=> 105.442897
],
[
"lat"=> 28.916428,
"lon"=> 105.44278
],
[
"lat"=> 28.917073,
"lon"=> 105.443507
],
[
"lat"=> 28.917073,
"lon"=> 105.443522
],
[
"lat"=> 28.916796,
"lon"=> 105.443466
],
[
"lat"=> 28.916665,
"lon"=> 105.443357
],
[
"lat"=> 28.916674,
"lon"=> 105.442294
],
[
"lat"=> 28.916698,
"lon"=> 105.442268
],
[
"lat"=> 28.917279,
"lon"=> 105.443006
],
[
"lat"=> 28.917234,
"lon"=> 105.442979
]
];
$target =[
"lat"=> 28.917378,
"lon"=> 105.443005
];
$closestPoint = $this->getClosestPoint($points, $target);
halt($closestPoint);
// $time=strtotime(date('Y-m-d',strtotime('+1 day')));
$time=strtotime(date('Y-m-d'));
$tiem_end=$time+86399;
$all=TaskSchedulingPlan::where('start_time','between',[$time,$tiem_end])->where('is_execute',0)->with(['template_info','scheduling','company'])->select()->toArray();
$company_id=0;
foreach($all as $k=>$v){
TaskLogic::CronAdd($v);
$company_id=$v['company_id'];
}
if($company_id!=0){
Company::where('id',$company_id)->inc('day_count')->update();
}
halt(TaskLogic::getError());
} }
function getClosestPoint($points, $target) { function getClosestPoint($points, $target) {
@ -169,4 +102,18 @@ halt(1);
return [$closestPoint,$distance]; 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;
}
} }

View File

@ -68,7 +68,11 @@ class RemoteController extends BaseApiController
//基础金额*(每日基户数*天数)//且户数小于公司总户数 //基础金额*(每日基户数*天数)//且户数小于公司总户数
$user_count = UserInformationg::where('company_id', $company['id'])->count(); $user_count = UserInformationg::where('company_id', $company['id'])->count();
// //
if($company['day_count']==0){
$user_count_two = 5 * 1;
}else{
$user_count_two = 5 * $company['day_count']; $user_count_two = 5 * $company['day_count'];
}
if ($user_count_two > $user_count) { if ($user_count_two > $user_count) {
$user_count_money = 58 * $user_count; $user_count_money = 58 * $user_count;
} else { } else {

View File

@ -23,6 +23,8 @@ class TaskInformationJob
// if ($job->attempts() > 1) { // if ($job->attempts() > 1) {
// //通过这个方法可以检查这个任务已经重试了几次了 // //通过这个方法可以检查这个任务已经重试了几次了
// } // }
try {
$company = Company::where('id', $data['company_id'])->field('id,deposit,company_money,user_id,day_count,company_type,province,city,area,street,village,brigade')->find(); // 可能要判断预存金是否满足 $company = Company::where('id', $data['company_id'])->field('id,deposit,company_money,user_id,day_count,company_type,province,city,area,street,village,brigade')->find(); // 可能要判断预存金是否满足
$arr['status'] = 0; $arr['status'] = 0;
//信息更新 //信息更新
@ -57,7 +59,6 @@ class TaskInformationJob
$arr['status'] = 1; $arr['status'] = 1;
} }
try {
$arr['money'] = $data['template_info']['money']; $arr['money'] = $data['template_info']['money'];
$arr['company_id'] = $data['scheduling']['company_id']; $arr['company_id'] = $data['scheduling']['company_id'];
$arr['msg'] = '来自任务【' . $data['template_info']['title'] . '】,完成人:' . $name . ',的任务结算'; $arr['msg'] = '来自任务【' . $data['template_info']['title'] . '】,完成人:' . $name . ',的任务结算';