Commit e874dbcf authored by yinxiaoling's avatar yinxiaoling

任务数据定时任务

parent b6d91f61
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use App\Models\StrategyTask;
class CreatedTaskCommand extends Command class CreatedTaskCommand extends Command
{ {
...@@ -18,7 +19,7 @@ class CreatedTaskCommand extends Command ...@@ -18,7 +19,7 @@ class CreatedTaskCommand extends Command
* *
* @var string * @var string
*/ */
protected $description = '每月1号创建任务'; protected $description = '每天早上6点创建任务';
/** /**
* Create a new command instance. * Create a new command instance.
...@@ -37,6 +38,11 @@ class CreatedTaskCommand extends Command ...@@ -37,6 +38,11 @@ class CreatedTaskCommand extends Command
*/ */
public function handle() public function handle()
{ {
// //新建任务、失败原任务重呼3次,接口调用失败重试3次
$taskInfo = StrategyTask::where('is_created',0)->get()->toArray(); //获取需要新建任务的数据
//dd($taskInfo);
foreach ($taskInfo as $k=>$v){//批量调用接口新建任务
}
} }
} }
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
//use App\Service\StrategyService;
use App\Models\StrategySet;
use App\Jobs\StrategyTaskJob;
class CreatedTaskDataCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'command:CreatedTaskDataCommand';
/**
* The console command description.
*
* @var string
*/
protected $description = '每月1号4点创建任务数据';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$setInfo = StrategySet::where([['disabled',0]])->get('strategy_sn')->toArray();
if (!empty($setInfo)){
//$StrategyService = new StrategyService();
foreach ($setInfo as $k=>$v){
//$StrategyService->createTaskDataJob($v['strategy_sn']);
$jobParams = ['strategySn'=>$v['strategy_sn']];
$job = (new StrategyTaskJob($jobParams))->onQueue('StrategyTask');
dispatch($job);
}
}
}
}
...@@ -13,7 +13,8 @@ class Kernel extends ConsoleKernel ...@@ -13,7 +13,8 @@ class Kernel extends ConsoleKernel
* @var array * @var array
*/ */
protected $commands = [ protected $commands = [
Commands\CreatedTaskCommand::class, //流程录音上传ftp服务器 Commands\CreatedTaskCommand::class, //创建任务
Commands\CreatedTaskDataCommand::class, //创建任务数据
]; ];
/** /**
...@@ -26,7 +27,9 @@ class Kernel extends ConsoleKernel ...@@ -26,7 +27,9 @@ class Kernel extends ConsoleKernel
{ {
// $schedule->command('inspire') // $schedule->command('inspire')
// ->hourly(); // ->hourly();
$schedule->command("command:CreatedTaskCommand")->cron('1 6 * * *'); $schedule->command("command:CreatedTaskCommand")->cron('0 6 * * *'); //每天6点执行,注意与command:CreatedTaskDataCommand 的前后关系
$schedule->command("command:CreatedTaskDataCommand")->cron('0 4 1 * *'); //每月1号5点执行
} }
/** /**
......
...@@ -100,7 +100,8 @@ class StrategySetController extends Controller ...@@ -100,7 +100,8 @@ class StrategySetController extends Controller
// 删除逻辑 注意多表关联的情况 // 删除逻辑 注意多表关联的情况
StrategySet::where('strategy_sn', $strategySn)->delete(); StrategySet::where('strategy_sn', $strategySn)->delete();
StrategyExcel::where('strategy_sn', $strategySn)->delete(); StrategyExcel::where('strategy_sn', $strategySn)->delete();
StrategyTask::where('strategy_sn', $strategySn)->delete(); //StrategyTask::where('strategy_sn', $strategySn)->delete();
StrategyTask::where([['strategy_sn', $strategySn],['is_created',0]])->delete(); //删除未新建的任务数据
}); });
return $this->successWithInfo('操作完成'); return $this->successWithInfo('操作完成');
} }
......
...@@ -29,7 +29,7 @@ class DatabaseSeeder extends Seeder ...@@ -29,7 +29,7 @@ class DatabaseSeeder extends Seeder
$table->unsignedSmallInteger('day_type')->default(0)->comment('外呼日期类型 0每天 1日期前一天和当天'); $table->unsignedSmallInteger('day_type')->default(0)->comment('外呼日期类型 0每天 1日期前一天和当天');
$table->unsignedSmallInteger('frequency_type')->default(1)->comment('外呼频率类型 (1 一天一次 2 一天两次)'); $table->unsignedSmallInteger('frequency_type')->default(1)->comment('外呼频率类型 (1 一天一次 2 一天两次)');
$table->char('call_time_set',50)->comment('呼叫设置时间点,两个用#号分割'); $table->char('call_time_set',50)->comment('呼叫设置时间点,两个用#号分割');
$table->unsignedSmallInteger('disabled')->default(1)->comment('是否不可用 0启用 1停用'); $table->unsignedSmallInteger('disabled')->default(0)->comment('是否不可用 0启用 1停用');
$table->integer('total')->default(0)->comment('excel导入号码总数量'); $table->integer('total')->default(0)->comment('excel导入号码总数量');
$table->integer('latest_total')->default(0)->comment('最新一次导入excel号码数量'); $table->integer('latest_total')->default(0)->comment('最新一次导入excel号码数量');
$table->timestamp('updated_at')->nullable()->comment('更新时间'); $table->timestamp('updated_at')->nullable()->comment('更新时间');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment