StorageController.php 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace App\Http\Controllers\api\thirdPart\haiq;
  3. use App\Services\LogService;
  4. use Illuminate\Support\Facades\Http;
  5. use Illuminate\Support\Facades\Request;
  6. class StorageController
  7. {
  8. protected $request;
  9. public function __construct()
  10. {
  11. $stockInfo = [
  12. "skuCode" => "TEST-BSSKU",//商品编码 sku
  13. "qty" => 9,//数量
  14. ];
  15. $bin = [
  16. "taskCode" => "TEST-BS2010100001",//任务编号
  17. "binCode" => "TEST-BIN01",//料箱编码
  18. "fromLocCode" => "TEST-J04-058-3",//源库位编码
  19. "toLocCode" => "TEST-J24-128-7",//目标库位编码 出库填多个,表示这些库位都可以支持
  20. "sequence" => -1,//出库顺序 -1表示没有顺序,只有移库出库时需要指定顺序,其他可为-1
  21. "stockInfo" => [$stockInfo],//商品信息
  22. ];
  23. $this->request = [[
  24. "groupCode" => 1,//组号/波次号 决定了出库的顺序,越大优先级越高
  25. "taskMode" => 1,//任务模式 1(拣货出库) 2(入库指定料箱出库) 3(盘点出库) 4(移库出库) 5(入库不指定料箱出库)
  26. "priority" => 99,//优先级 1-100 1最低
  27. "sequenceFlag" => -1,//出库顺序 -1表示没有顺序,只有移库出库时需要指定顺序,其他可为-1
  28. "bins" => [$bin],//可执行货箱任务
  29. ]];
  30. }
  31. public function out(Request $request){
  32. $bin = [
  33. "taskCode" => "TEST-BS2010100001",//任务编号
  34. "binCode" => "TEST-BIN01",//料箱编码
  35. "sequence" => -1,//出库顺序 -1表示没有顺序,只有移库出库时需要指定顺序,其他可为-1
  36. "fromLocCode" => "TEST-J04-058-3",//源库位编码
  37. "toLocCode" => "TEST-J24-128-7",//目标库位编码 出库填多个,表示这些库位都可以支持
  38. ];
  39. $req = [[
  40. "groupCode" => 1,//组号/波次号 决定了出库的顺序,越大优先级越高
  41. "priority" => 99,//优先级 1-100 1最低
  42. "taskMode" => 1,//任务模式 1(拣货出库) 2(入库指定料箱出库) 3(盘点出库) 4(移库出库) 5(入库不指定料箱出库)
  43. "emptyBinQty" => -1,//需求空料箱数量 taskMode 为 3 时必填, 其他时候可以传-1
  44. "toWorkStations" => ["TEST-HQ01","TEST-HQ02",],//出库工作站 不指定具体一个,指定多个
  45. "bins" => [$bin],//可执行货箱任务
  46. ]];
  47. $response = Http::post(config('api.haiq.storage.out'),$this->request);
  48. return $response;
  49. if ($response["code"] != 200){
  50. LogService::log(__METHOD__,"haiq-料箱出库失败","REQUEST:".json_encode($req)." | RESPONSE:".$response);
  51. return ['success'=>false,"data"=>$response["errMsg"]];
  52. }
  53. LogService::log(__METHOD__,"haiq-料箱出库成功","REQUEST:".json_encode($req)." | RESPONSE:".$response);
  54. return ["success"=>true];
  55. }
  56. public function in(Request $request){
  57. $stockInfo = [
  58. "skuCode" => "TEST-BSSKU",//商品编码 sku
  59. "qty" => 9,//数量
  60. ];
  61. $req = [[
  62. "taskCode" => "TEST-BSSTIN2010100001",//任务编号
  63. "taskMode" => 1,//任务类型 1(出库回库) 2(入库回库) 3(盘点回库) 4(移库回库)
  64. "binCode" => "TEST-BIN01",//料箱编号
  65. "fromWorkStation" => "TEST-HQ01",//回库工作站
  66. "fromLocCode" => "TEST-JH-0025",//源库位编码
  67. "toLocCode" => "TEST-JH-001",//目标库位编码
  68. "isEmpty" => 1,//料箱是否为空 0(为空) 1(不为空)
  69. "stockInfo" => [$stockInfo],//商品信息
  70. ]];
  71. $response = Http::post(config('api.haiq.storage.in'),$this->request);
  72. return $response;
  73. if ($response["code"] != 200){
  74. LogService::log(__METHOD__,"haiq-料箱回库失败","REQUEST:".json_encode($req)." | RESPONSE:".$response);
  75. return ['success'=>false,'data'=>$response["errMsg"]];
  76. }
  77. LogService::log(__METHOD__,"haiq-料箱回库成功","REQUEST:".json_encode($req)." | RESPONSE:".$response);
  78. return ["success"=>true];
  79. }
  80. }