StorageController.php 4.3 KB

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