ForeignHaiRoboticsController.php 923 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Services\StationTaskBatchService;
  4. use App\StationTaskBatch;
  5. use Illuminate\Http\Request;
  6. use App\Traits\TestableInstant;
  7. class ForeignHaiRoboticsController
  8. {
  9. use TestableInstant;
  10. /** @var StationTaskBatchService $stationTaskBatchService */
  11. private $stationTaskBatchService=null;
  12. function runBatch(Request $request){
  13. $request->validate(
  14. ['id'=>'required|exists:station_task_batches,id']
  15. );
  16. $batchTask=StationTaskBatch::query()->first($request['id']);
  17. $batchesFailed=$this->stationTaskBatchService->runMany(collect([$batchTask]));//执行波次任务
  18. if($batchesFailed && $batchesFailed->isNotEmpty()){
  19. return [
  20. 'success'=>false,
  21. 'errorMsg'=>'有部分失败波次:'.$batchesFailed->toJson()
  22. ];
  23. }
  24. return ['success'=>true];
  25. }
  26. }