StorageController.php 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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 $post;
  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->post = [[
  34. "taskMode" => 1,
  35. "bins"=>[[
  36. "taskCode" =>"TESTx1za3X14",
  37. "binCode" => "IDE0000130",
  38. "fromLocCode" => "BIN-IN1",
  39. "toLocCode" => "BIN-OUT1",
  40. ],[
  41. "taskCode" =>"TESTx2za3X43",
  42. "binCode" => "IDE0000131",
  43. "fromLocCode" => "BIN-IN1",
  44. "toLocCode" => "BIN-OUT1",
  45. ]],
  46. "groupCode" => 'WMxz3acX14',
  47. "priority" => 20,
  48. "sequenceFlag" => 1,
  49. ]];
  50. $this->post2 = [[
  51. "taskMode" => 2,
  52. "bins"=>[[
  53. "taskCode" =>"TESTxx2zbaa1",
  54. "binCode" => "IDE0000034",
  55. "fromLocCode" => "BIN-IN1",
  56. "toLocCode" => "BIN-OUT1",
  57. ],[
  58. "taskCode" =>"TESTxx3zbaa1",
  59. "binCode" => "IDE0000093",
  60. "fromLocCode" => "BIN-IN1",
  61. "toLocCode" => "BIN-OUT1",
  62. ],[
  63. "taskCode" =>"TESTxx4zbaa1",
  64. "binCode" => "IDE0000128",
  65. "fromLocCode" => "BIN-IN1",
  66. "toLocCode" => "BIN-OUT1",
  67. ],[
  68. "taskCode" =>"TESTxx5zbaa1",
  69. "binCode" => "IDE0000129",
  70. "fromLocCode" => "BIN-IN1",
  71. "toLocCode" => "BIN-OUT1",
  72. ],[
  73. "taskCode" =>"TESTxx6zbaa1",
  74. "binCode" => "IDE0000127",
  75. "fromLocCode" => "BIN-IN1",
  76. "toLocCode" => "BIN-OUT1",
  77. ]],
  78. "groupCode" => 'WMxz64b2a1',
  79. "priority" => 20,
  80. "sequenceFlag" => 1,
  81. ]];;
  82. $this->backIn = [[
  83. "taskMode" => 1,
  84. "bins"=>[[
  85. "taskCode" =>"testIn1ax",
  86. "binCode" => "IDE0000007",
  87. "fromLocCode" => "BIN-IN1",
  88. "toLocCode" => "",
  89. ],[
  90. "taskCode" =>"testIn2ax",
  91. "binCode" => "IDE0000129",
  92. "fromLocCode" => "BIN-IN1",
  93. "toLocCode" => "",
  94. ],],
  95. "groupCode" => 'WMx135ax',
  96. "priority" => 20,
  97. "sequenceFlag" => 1,
  98. ]];
  99. $this->backIn2 = [[
  100. "taskMode" => 6,
  101. "bins"=>[[
  102. "taskCode" =>"testIn123",
  103. "binCode" => "IDE0000130",
  104. "fromLocCode" => "HAIB2-01-03",
  105. "toLocCode" => "",
  106. ],[
  107. "taskCode" =>"testIn223",
  108. "binCode" => "IDE0000034",
  109. "fromLocCode" => "HAIB2-02-03",
  110. "toLocCode" => "",
  111. ],[
  112. "taskCode" =>"testIn323",
  113. "binCode" => "IDE0000093",
  114. "fromLocCode" => "HAIB2-03-03",
  115. "toLocCode" => "",
  116. ]],
  117. "groupCode" => 'WMx14',
  118. "priority" => 20,
  119. "sequenceFlag" => 1,
  120. ]];
  121. $this->move = [[
  122. "taskMode" => 1,
  123. "bins"=>[[
  124. "taskCode" =>"testm1z6",
  125. "binCode" => "IDE0000034",
  126. "fromLocCode" => "BIN-IN1",
  127. "toLocCode" => "",
  128. ],[
  129. "taskCode" =>"testm2z6",
  130. "binCode" => "IDE0000093",
  131. "fromLocCode" => "BIN-IN1",
  132. "toLocCode" => "",
  133. ],[
  134. "taskCode" =>"testm3z6",
  135. "binCode" => "IDE0000130",
  136. "fromLocCode" => "BIN-IN1",
  137. "toLocCode" => "",
  138. ],],
  139. "groupCode" => 'WMm1z6',
  140. "priority" => 20,
  141. "sequenceFlag" => 1,
  142. ]];//128,129.127
  143. $this->move2 = [[
  144. "taskMode" => 6,
  145. "bins"=>[[
  146. "taskCode" =>"testm11",
  147. "binCode" => "IDE0000128",
  148. "fromLocCode" => "HAIB2-01-01",
  149. "toLocCode" => "",
  150. ],[
  151. "taskCode" =>"testm21",
  152. "binCode" => "IDE000129",
  153. "fromLocCode" => "HAIB2-02-01",
  154. "toLocCode" => "",
  155. ],[
  156. "taskCode" =>"testm31",
  157. "binCode" => "IDE0000127",
  158. "fromLocCode" => "HAIB2-03-01",
  159. "toLocCode" => "",
  160. ],],
  161. "groupCode" => 'WMm2',
  162. "priority" => 20,
  163. "sequenceFlag" => 1,
  164. ]];
  165. $this->lightOn = [
  166. "areaCode"=> "1004",
  167. "PTLAction"=> 1,
  168. "PTLSettings"=> [
  169. "color"=> 1,
  170. "frequency"=> 1
  171. ],
  172. "displayInfo"=> [
  173. "detail01"=> "detail01",
  174. "detail02"=> "detail02",
  175. "detail03"=> "detail03",
  176. "qrCode"=> "qrCode",
  177. "qty00"=> "11",
  178. "qty01"=> 1,
  179. "qty02"=> 2,
  180. "title"=> "title",
  181. "uomDesc01"=> "uo",
  182. "uomDesc02"=> "uo"
  183. ],
  184. "locCode"=> "HAIB2-02-03"
  185. ];
  186. $this->lightOff = [
  187. "PTLAction"=> 0,
  188. "locCode"=> "HAIB2-02-03"
  189. ];
  190. }
  191. public function relocate(Request $request,$post){
  192. $response = Http::post(config('api.haiq.storage.moveBin'),$post);
  193. if (!$response->ok()){
  194. app('LogService')->log(__METHOD__,"haiq-请求失败,路径异常","REQUEST:".json_encode($this->post)." | RESPONSE:".$response);
  195. return ['success'=>false,"data"=>$response->body()];
  196. }
  197. if (($response["code"] ?? false) && $response["code"] != 200){
  198. app('LogService')->log(__METHOD__,"haiq-料箱出库失败","REQUEST:".json_encode($this->post)." | RESPONSE:".$response);
  199. return ['success'=>false,"data"=>$response["errMsg"]];
  200. }
  201. if (($response["status"] ?? false) && $response["status"] == 500){
  202. app('LogService')->log(__METHOD__,"haiq-料箱出库失败","REQUEST:".json_encode($this->post)." | RESPONSE:".$response);
  203. return ['success'=>false,"data"=>$response["msg"]];
  204. }
  205. app('LogService')->log(__METHOD__,"haiq-料箱出库成功","REQUEST:".json_encode($this->post)." | RESPONSE:".$response);
  206. return ["success"=>true];
  207. }
  208. public function light(Request $request,$post){
  209. $response = Http::post(config('api.haiq.storage.light'),$post);
  210. return $response->body();
  211. }
  212. public function moveBinOut(Request $request){
  213. return $this->relocate($request,$this->post);
  214. }
  215. public function moveBin2(Request $request){
  216. return $this->relocate($request,$this->post2);
  217. }
  218. public function moveBinIn(Request $request){
  219. return $this->relocate($request,$this->backIn);
  220. }
  221. public function moveBinIn2(Request $request){
  222. return $this->relocate($request,$this->backIn2);
  223. }
  224. public function moveBinM(Request $request){
  225. return $this->relocate($request,$this->move);
  226. }
  227. public function moveBinM2(Request $request){
  228. return $this->relocate($request,$this->move2);
  229. }
  230. public function lightOn(Request $request){
  231. return $this->light($request,$this->lightOn);
  232. }
  233. public function lightOff(Request $request){
  234. return $this->light($request,$this->lightOff);
  235. }
  236. public function taskUpdate(Request $request){
  237. $this->service->taskUpdate();
  238. app('LogService')->log(__METHOD__,__FUNCTION__,json_encode($request->all()));
  239. return ['code'=>200,'errMsg'=>'','data'=>$request->all()];
  240. }
  241. public function exception(Request $request){
  242. $this->service->throwException();
  243. app('LogService')->log(__METHOD__,__FUNCTION__,json_encode($request->all()));
  244. return ['code'=>200,'errMsg'=>'','data'=>$request->all()];
  245. }
  246. }