| 12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- namespace App\Http\Controllers\api\thirdPart\haiq;
- use App\Services\StationTaskBatchService;
- use App\StationTaskBatch;
- use Illuminate\Http\Request;
- use App\Traits\TestableInstant;
- class HaiRoboticsController
- {
- use TestableInstant;
- /** @var StationTaskBatchService $stationTaskBatchService */
- private $stationTaskBatchService=null;
- function runTaskBatch(Request $request){
- $this->instant($this->stationTaskBatchService,'StationTaskBatchService');
- $request->validate(
- ['station_task_batch_id'=>'required|exists:station_task_batches,id']
- );
- if(!$request['station_task_batch_id'])return [
- 'success'=>false,
- 'errorMsg'=>'波次任务不能为空'
- ];
- $batchTask=StationTaskBatch::query()->find($request['station_task_batch_id']);
- $batchesFailed=$this->stationTaskBatchService->runMany(collect([$batchTask]));//执行波次任务
- if($batchesFailed && $batchesFailed->isNotEmpty()){
- return [
- 'success'=>false,
- 'errorMsg'=>'有部分失败波次:'.$batchesFailed->toJson()
- ];
- }
- return ['success'=>true];
- }
- }
|