HaiRoboticsController.php 1.2 KB

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