HandInStorageController.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. public function checkAsnOperation(Request $request)
  32. {
  33. $this->gate("入库管理-手持入库-收货");
  34. /** @var HandInStorageService $handInStorageService */
  35. $handInStorageService=app('HandInStorageService');
  36. $info= $request->input('info');
  37. $res=$handInStorageService->checkAsnOperation($info);
  38. if ($res===1)$this->error('无有效的ASN的订单');
  39. elseif ($res===2)$this->error('该asn无预约,暂不可收货');
  40. else $this->success($res);
  41. }
  42. /**
  43. * @param $asnno
  44. * 跳转到收货明细页面
  45. */
  46. public function receiveDetailPage($asnno,$customerid)
  47. {
  48. $this->gate("入库管理-手持入库-收货");
  49. /** @var HandInStorageService $handInStorageService */
  50. $handInStorageService=app('HandInStorageService');
  51. if (!$customerid||$customerid=='undefined')
  52. $customerid=OracleDOCASNHeader::query()->where('asnno',$asnno)->value('customerid');
  53. $qualityStatus=$handInStorageService->getQualityStatus();
  54. $attributeLocations=$handInStorageService->getAttributeLocation();
  55. return view('store.handInStorage.receiveDetailPage')
  56. ->with(['asnno'=>$asnno,'customerid'=>$customerid,'qualityStatus'=>$qualityStatus,'attributeLocations'=>$attributeLocations]);
  57. }
  58. /**
  59. * @param Request $request
  60. * 查询富勒asn_detail(集合)
  61. */
  62. public function selectAsnDetails(Request $request)
  63. {
  64. $this->gate("入库管理-手持入库-收货");
  65. $asnno= $request->input('asnno');
  66. $asnDetails =app('HandInStorageService')->selectAsnDetails($asnno);
  67. if (count($asnDetails)>0)$this->success($asnDetails);
  68. else $this->error('未查询到相应的asn明细');
  69. }
  70. /**
  71. * @param Request $request
  72. * 查询富勒bas_sku 并关联 bas_lotid
  73. */
  74. public function getBasSkuWithLot(Request $request): array
  75. {
  76. $customerid= $request->input('customerid');
  77. $skuOrBarcode= $request->input('sku');
  78. $asnno= $request->input('asnno');
  79. $asnDetail=app('HandInStorageService')->getAsnDetail($asnno,$skuOrBarcode);
  80. if (!$asnDetail)$this->error('无效条码');
  81. $basSku =app('HandInStorageService')->getBasSkuLotId($customerid,$asnDetail->sku);
  82. if (isset($basSku)&&isset($asnDetail))return ['success'=>true,'basSku'=>$basSku,'asnDetail'=>$asnDetail];
  83. else $this->error('无效条码');
  84. }
  85. /**
  86. * @throws \Throwable
  87. * 收货
  88. */
  89. public function fluxHandIn(Request $request)
  90. {
  91. $this->gate("入库管理-手持入库-收货");
  92. $info=$request->input('info');
  93. if (!$info['customerid']||!$info['sku']||!$info['asnno']) $this->error('参数错误');
  94. if ($info['amount']+$info['receivedqty']>$info['expectedqty'])$this->error('收货数大于预期数');
  95. // if ($info['location']){
  96. // $location=OracleBasLocation::query()
  97. // ->where('locationid',$info['location'])
  98. // ->where('status','OK')
  99. // ->first();
  100. // if (!$location)$this->error('目标库位不存在');
  101. // }
  102. /** @var HandInStorageService $handInStorageService */
  103. $handInStorageService=app('HandInStorageService');
  104. try {
  105. $result = $handInStorageService->fluxHandIn($info);
  106. if ($result)$this->success("收货成功");
  107. else $this->error("收货失败");
  108. } catch (\Exception $e) {
  109. app('LogService')->log(__METHOD__,'error_'.__FUNCTION__,json_encode($info).'|catch:'.$e->getMessage());
  110. }
  111. }
  112. /**
  113. * @param Request $request
  114. * 根据商品条码和跟踪号 获取要上架的任务列表
  115. */
  116. public function getTsk(Request $request)
  117. {
  118. $this->gate("入库管理-手持入库-上架");
  119. $barCode=$request->input('barCode');
  120. $trackNumber=$request->input('trackNumber');
  121. if(!$barCode)$this->error('条码不能为空');
  122. if(!$trackNumber)$this->error('容器号不能为空');
  123. /** @var HandInStorageService $handInStorageService */
  124. $handInStorageService=app('HandInStorageService');
  125. $tasks=$handInStorageService->getTsk($trackNumber,$barCode);
  126. if (count($tasks)>0)$this->success($tasks);
  127. else $this->error("该商品暂无上架任务");
  128. }
  129. /**
  130. * @throws \Throwable
  131. * 上架
  132. */
  133. public function handFluxPa(Request $request)
  134. {
  135. $this->gate("入库管理-手持入库-上架");
  136. $info=$request->input('info');
  137. if (!$info['location']||!$info['amount']||!$info['trackNumber']||!$info['barCode']) $this->error('参数错误');
  138. if (count($request->input('checkData'))==0) $this->error('请勾选要上架任务');
  139. $checkData=$request->input('checkData')[0];
  140. $location=OracleBasLocation::query()
  141. ->where('locationid',$info['location'])
  142. ->where('status','OK')
  143. ->first();
  144. if (!$location)$this->error('目标库位不存在');
  145. /** @var HandInStorageService $handInStorageService */
  146. $handInStorageService=app('HandInStorageService');
  147. try {
  148. $result = $handInStorageService->fluxHandPa($info, $checkData);
  149. if ($result)$this->success("上架成功");
  150. else $this->error("上架失败");
  151. } catch (\Exception $e) {
  152. app('LogService')->log(__METHOD__,'error_'.__FUNCTION__,json_encode($info).'|catch:'.$e->getMessage());
  153. }
  154. }
  155. }