HandInStorageController.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Components\AsyncResponse;
  4. use App\OracleBasLocation;
  5. use App\OracleDOCASNHeader;
  6. use App\Services\HandInStorageService;
  7. use Doctrine\DBAL\Exception\DatabaseObjectExistsException;
  8. use Illuminate\Http\Request;
  9. class HandInStorageController extends Controller
  10. {
  11. use AsyncResponse;
  12. /**
  13. * 搜索查詢asn
  14. */
  15. public function selectAsn(Request $request)
  16. {
  17. $this->gate("入库管理-手持入库-收货");
  18. /** @var HandInStorageService $handInStorageService */
  19. $handInStorageService=app('HandInStorageService');
  20. $asnno= $request->input('asnno');
  21. $asns =$handInStorageService->selectAsn($asnno);
  22. if (count($asns)>0){
  23. foreach ($asns as $asn){
  24. $asn->asnDetails=array();
  25. }
  26. $this->success($asns);
  27. }else{
  28. $this->error('未搜索到ASN单');
  29. }
  30. }
  31. /**
  32. * @param $asnno
  33. * 跳转到收货明细页面
  34. */
  35. public function receiveDetailPage($asnno,$customerid)
  36. {
  37. $this->gate("入库管理-手持入库-收货");
  38. /** @var HandInStorageService $handInStorageService */
  39. $handInStorageService=app('HandInStorageService');
  40. if (!$customerid||$customerid=='undefined')
  41. $customerid=OracleDOCASNHeader::query()->where('asnno',$asnno)->value('customerid');
  42. $qualityStatus=$handInStorageService->getQualityStatus();
  43. $attributeLocations=$handInStorageService->getAttributeLocation();
  44. return view('store.handInStorage.receiveDetailPage')
  45. ->with(['asnno'=>$asnno,'customerid'=>$customerid,'qualityStatus'=>$qualityStatus,'attributeLocations'=>$attributeLocations]);
  46. }
  47. /**
  48. * @param Request $request
  49. * 查询富勒asn_detail(集合)
  50. */
  51. public function selectAsnDetails(Request $request)
  52. {
  53. $this->gate("入库管理-手持入库-收货");
  54. $asnno= $request->input('asnno');
  55. $asnDetails =app('HandInStorageService')->selectAsnDetails($asnno);
  56. if (count($asnDetails)>0)$this->success($asnDetails);
  57. else $this->error('未搜索到ASN详情单');
  58. }
  59. /**
  60. * @param Request $request
  61. * 查询富勒bas_sku 并关联 bas_lotid
  62. */
  63. public function getBasSkuWithLot(Request $request): array
  64. {
  65. $customerid= $request->input('customerid');
  66. $skuOrBarcode= $request->input('sku');
  67. $asnno= $request->input('asnno');
  68. $asnDetail=app('HandInStorageService')->getAsnDetail($asnno,$skuOrBarcode);
  69. if (!$asnDetail)$this->error('无效条码');
  70. $basSku =app('HandInStorageService')->getBasSkuLotId($customerid,$asnDetail->sku);
  71. if (isset($basSku)&&isset($asnDetail))return ['success'=>true,'basSku'=>$basSku,'asnDetail'=>$asnDetail];
  72. else $this->error('无效条码');
  73. }
  74. /**
  75. * @throws \Throwable
  76. * 收货
  77. */
  78. public function fluxHandIn(Request $request)
  79. {
  80. $this->gate("入库管理-手持入库-收货");
  81. $info=$request->input('info');
  82. if (!$info['customerid']||!$info['sku']||!$info['asnno']) $this->error('参数错误');
  83. if ($info['amount']+$info['receivedqty']>$info['expectedqty'])$this->error('收货数大于预期数');
  84. // if ($info['location']){
  85. // $location=OracleBasLocation::query()
  86. // ->where('locationid',$info['location'])
  87. // ->where('status','OK')
  88. // ->first();
  89. // if (!$location)$this->error('目标库位不存在');
  90. // }
  91. /** @var HandInStorageService $handInStorageService */
  92. $handInStorageService=app('HandInStorageService');
  93. try {
  94. $result = $handInStorageService->fluxHandIn($info);
  95. if ($result)$this->success("收货成功");
  96. else $this->error("收货失败");
  97. } catch (\Exception $e) {
  98. app('LogService')->log(__METHOD__,'error_'.__FUNCTION__,json_encode($info).'|catch:'.$e->getMessage());
  99. }
  100. }
  101. /**
  102. * @param Request $request
  103. * 根据商品条码和跟踪号 获取要上架的任务列表
  104. */
  105. public function getTsk(Request $request)
  106. {
  107. $this->gate("入库管理-手持入库-上架");
  108. $barCode=$request->input('barCode');
  109. $trackNumber=$request->input('trackNumber');
  110. if(!$barCode)$this->error('条码不能为空');
  111. if(!$trackNumber)$this->error('容器号不能为空');
  112. /** @var HandInStorageService $handInStorageService */
  113. $handInStorageService=app('HandInStorageService');
  114. $tasks=$handInStorageService->getTsk($trackNumber,$barCode);
  115. if (count($tasks)>0)$this->success($tasks);
  116. else $this->error("该商品暂无上架任务");
  117. }
  118. /**
  119. * @throws \Throwable
  120. * 上架
  121. */
  122. public function handFluxPa(Request $request)
  123. {
  124. $this->gate("入库管理-手持入库-上架");
  125. $info=$request->input('info');
  126. if (!$info['location']||!$info['amount']||!$info['trackNumber']||!$info['barCode']) $this->error('参数错误');
  127. if (count($request->input('checkData'))==0) $this->error('请勾选要上架任务');
  128. $checkData=$request->input('checkData')[0];
  129. $location=OracleBasLocation::query()
  130. ->where('locationid',$info['location'])
  131. ->where('status','OK')
  132. ->first();
  133. if (!$location)$this->error('目标库位不存在');
  134. /** @var HandInStorageService $handInStorageService */
  135. $handInStorageService=app('HandInStorageService');
  136. try {
  137. $result = $handInStorageService->fluxHandPa($info, $checkData);
  138. if ($result)$this->success("上架成功");
  139. else $this->error("上架失败");
  140. } catch (\Exception $e) {
  141. app('LogService')->log(__METHOD__,'error_'.__FUNCTION__,json_encode($info).'|catch:'.$e->getMessage());
  142. }
  143. }
  144. }