StorageController.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. namespace App\Http\Controllers\api\thirdPart\haiq;
  3. use App\Services\ForeignHaiRoboticsService;
  4. use Illuminate\Http\Request;
  5. use Illuminate\Support\Facades\Http;
  6. class StorageController
  7. {
  8. protected $request;
  9. /** @var ForeignHaiRoboticsService $service */
  10. private $service;
  11. public function __construct()
  12. {
  13. $this->service=app('ForeignHaiRoboticsService');
  14. $stockInfo = [
  15. "skuCode" => "TEST-BSSKU",//商品编码 sku
  16. "qty" => 9,//数量
  17. ];
  18. $bin = [
  19. "taskCode" => "TEST-BS2010100001",//任务编号 全局唯一
  20. "binCode" => "TEST-BIN01",//料箱编码
  21. "fromLocCode" => "HAIB1-02-01",//源库位编码
  22. "toLocCode" => "HAIB1-02-01",//目标库位编码 出库填多个,表示这些库位都可以支持
  23. "sequence" => -1,//出库顺序 -1表示没有顺序,只有移库出库时需要指定顺序,其他可为-1
  24. "stockInfo" => [$stockInfo],//商品信息
  25. ];
  26. /*$this->request = [[
  27. "groupCode" => 1,//组号/波次号 一组任务需要一起完成,再开始下一组任务;没有组任务的限制默认传-1或空
  28. "taskMode" => 3,//任务模式 值 1 (输送线入库)值 2 (输送线出库)值 3(货架到缓存货架)值4(货架到流利货架)
  29. "priority" => 99,//优先级 1-2147483647 1最低
  30. "sequenceFlag" => -1,//是否需要有序 1:需要有序 0:不需要有序
  31. "bins" => [$bin],//可执行货箱任务
  32. ]];*/
  33. $this->request = [[
  34. "taskMode" => 2,
  35. "bins"=>[[
  36. "taskCode" =>"TEST-BS2011160004",
  37. "binCode" => "IDE0000034",
  38. // "fromLocCode" => "BIN-IN1",
  39. "toLocCode" => "BIN-OUT1",
  40. ]],
  41. "groupCode" => 4,
  42. "priority" => 20,
  43. "sequenceFlag" => -1,
  44. ]];
  45. $this->lightOn = [
  46. "areaCode"=> "1004",
  47. "PTLAction"=> 1,
  48. "PTLSettings"=> [
  49. "color"=> 1,
  50. "frequency"=> 1
  51. ],
  52. "displayInfo"=> [
  53. "detail01"=> "detail01",
  54. "detail02"=> "detail02",
  55. "detail03"=> "detail03",
  56. "qrCode"=> "qrCode",
  57. "qty00"=> "qty00",
  58. "qty01"=> 1,
  59. "qty02"=> 2,
  60. "title"=> "title",
  61. "uomDesc01"=> "uo",
  62. "uomDesc02"=> "uo"
  63. ],
  64. "locCode"=> "1004-BZ04-01-01"
  65. ];
  66. }
  67. public function relocate(Request $request){
  68. $response = Http::post(config('api.haiq.storage.moveBin'),$this->request);
  69. if (!$response->ok()){
  70. app('LogService')->log(__METHOD__,"haiq-请求失败,路径异常","REQUEST:".json_encode($this->request)." | RESPONSE:".$response);
  71. return ['success'=>false,"data"=>$response->body()];
  72. }
  73. if (($response["code"] ?? false) && $response["code"] != 200){
  74. app('LogService')->log(__METHOD__,"haiq-料箱出库失败","REQUEST:".json_encode($this->request)." | RESPONSE:".$response);
  75. return ['success'=>false,"data"=>$response["errMsg"]];
  76. }
  77. if (($response["status"] ?? false) && $response["status"] == 500){
  78. app('LogService')->log(__METHOD__,"haiq-料箱出库失败","REQUEST:".json_encode($this->request)." | RESPONSE:".$response);
  79. return ['success'=>false,"data"=>$response["msg"]];
  80. }
  81. app('LogService')->log(__METHOD__,"haiq-料箱出库成功","REQUEST:".json_encode($this->request)." | RESPONSE:".$response);
  82. return ["success"=>true];
  83. }
  84. public function light(Request $request,$post){
  85. $response = Http::post(config('api.haiq.storage.moveBin'),$post);
  86. if (!$response->ok()){
  87. app('LogService')->log(__METHOD__,"haiq-请求失败,路径异常","REQUEST:".json_encode($this->post)." | RESPONSE:".$response);
  88. return ['success'=>false,"data"=>$response->body()];
  89. }
  90. if (($response["code"] ?? false) && $response["code"] != 200){
  91. app('LogService')->log(__METHOD__,"haiq-料箱出库失败","REQUEST:".json_encode($this->post)." | RESPONSE:".$response);
  92. return ['success'=>false,"data"=>$response["errMsg"]];
  93. }
  94. if (($response["status"] ?? false) && $response["status"] == 500){
  95. app('LogService')->log(__METHOD__,"haiq-料箱出库失败","REQUEST:".json_encode($this->post)." | RESPONSE:".$response);
  96. return ['success'=>false,"data"=>$response["msg"]];
  97. }
  98. app('LogService')->log(__METHOD__,"haiq-料箱出库成功","REQUEST:".json_encode($this->post)." | RESPONSE:".$response);
  99. return ["success"=>true];
  100. }
  101. public function moveBin(Request $request){
  102. }
  103. public function lightOn(Request $request){
  104. return $this->relocate($request,$this->lightOn);
  105. }
  106. public function taskUpdate(Request $request){
  107. $this->service->taskUpdate();
  108. app('LogService')->log(__METHOD__,__FUNCTION__,json_encode($request->all()));
  109. return ['code'=>200,'errMsg'=>'','data'=>$request->all()];
  110. }
  111. public function exception(Request $request){
  112. $this->service->taskUpdate();
  113. app('LogService')->log(__METHOD__,__FUNCTION__,json_encode($request->all()));
  114. return ['code'=>200,'errMsg'=>'','data'=>$request->all()];
  115. }
  116. }