LabelDealCsJob.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace App\Jobs;
  3. use App\Service\DwyService;
  4. use App\Service\LabelDealService;
  5. use Illuminate\Bus\Queueable;
  6. use Illuminate\Contracts\Queue\ShouldQueue;
  7. use Illuminate\Foundation\Bus\Dispatchable;
  8. use Illuminate\Queue\InteractsWithQueue;
  9. use Illuminate\Queue\SerializesModels;
  10. use Illuminate\Support\Facades\Log;
  11. use Symfony\Component\Console\Output\ConsoleOutput;
  12. use Symfony\Component\Console\Output\OutputInterface;
  13. class LabelDealCsJob implements ShouldQueue
  14. {
  15. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  16. protected $data;
  17. protected $header;
  18. protected $id;
  19. /**
  20. * Create a new job instance.
  21. *
  22. * @return void
  23. */
  24. public function __construct($data,$header)
  25. {
  26. $this->data = $data;
  27. $this->header = $header;
  28. }
  29. public function handle()
  30. {
  31. try {
  32. $data = $this->data;
  33. $dv = $data['key'];
  34. $return = $box_list = [];
  35. Log::channel('apiLog')->info('测试--出库源数据', ["param" => $data]);
  36. //处理数据
  37. LabelDealService::getInstance()->clearData($data,$return,$box_list);
  38. Log::channel('apiLog')->info('测试--出库(清洗数据)', ["param" => $return]);
  39. //调用外部方法
  40. list($lead_bind,$lead_out) = DwyService::getInstance()->setBoxData1($this->header,$dv,$return,$box_list,$data);
  41. //删除限制
  42. DwyService::getInstance()->delLimitForBoxOut($lead_bind);
  43. //调用保存接口 cs todo
  44. LabelDealService::getInstance()->boxOut1($lead_bind,$lead_out,$this->header,$this->id);
  45. }catch (\Throwable $exception){
  46. Log::channel('apiLog')->info('测试--队列捕获(出库异常)', ["message" => $exception->getFile() . "|" . $exception->getLine() . "|" . $exception->getMessage(). "|" . $exception->getCode()]);
  47. $this->delete();
  48. }
  49. }
  50. protected function echoMessage(OutputInterface $output)
  51. {
  52. $output->writeln($this->data);
  53. }
  54. }