HandInStorageController.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Components\AsyncResponse;
  4. use App\OracleDOCASNHeader;
  5. use App\Services\HandInStorageService;
  6. use Carbon\Carbon;
  7. use Illuminate\Http\Request;
  8. class HandInStorageController extends Controller
  9. {
  10. use AsyncResponse;
  11. /**
  12. * 搜索查詢asn
  13. */
  14. public function selectAsn(Request $request)
  15. {
  16. $this->gate("入库管理-手持入库-收货");
  17. /** @var HandInStorageService $handInStorageService */
  18. $handInStorageService=app('HandInStorageService');
  19. $asnno= $request->input('asnno');
  20. $asns =$handInStorageService->selectAsn($asnno);
  21. if (count($asns)>0){
  22. foreach ($asns as $asn){
  23. $asn->asnDetails=array();
  24. }
  25. $this->success($asns);
  26. }else{
  27. $this->error('无有效的ASN的订单');
  28. }
  29. }
  30. public function checkAsnOperation(Request $request)
  31. {
  32. $this->gate("入库管理-手持入库-收货");
  33. /** @var HandInStorageService $handInStorageService */
  34. $handInStorageService=app('HandInStorageService');
  35. $info= $request->input('info');
  36. $res=$handInStorageService->checkAsnOperation($info);
  37. if ($res===1)$this->error('无有效的ASN的订单');
  38. elseif ($res===2)$this->error('该asn无预约,暂不可收货');
  39. else $this->success($res);
  40. }
  41. /**
  42. * @param $asnno
  43. * 跳转到收货明细页面
  44. */
  45. public function receiveDetailPage($asnno,$customerid)
  46. {
  47. $this->gate("入库管理-手持入库-收货");
  48. /** @var HandInStorageService $handInStorageService */
  49. $handInStorageService=app('HandInStorageService');
  50. if (!$customerid||$customerid=='undefined')
  51. $customerid=OracleDOCASNHeader::query()->where('asnno',$asnno)->value('customerid');
  52. $qualityStatus=$handInStorageService->getQualityStatus();
  53. $attributeLocations=$handInStorageService->getAttributeLocation();
  54. return view('store.handInStorage.receiveDetailPage')
  55. ->with(['asnno'=>$asnno,'customerid'=>$customerid,'qualityStatus'=>$qualityStatus,'attributeLocations'=>$attributeLocations]);
  56. }
  57. /**
  58. * @param Request $request
  59. * 查询富勒asn_detail(集合)
  60. */
  61. public function selectAsnDetails(Request $request)
  62. {
  63. $this->gate("入库管理-手持入库-收货");
  64. $asnno= $request->input('asnno');
  65. $asnDetails =app('HandInStorageService')->selectAsnDetails($asnno);
  66. if (count($asnDetails)>0)$this->success($asnDetails);
  67. else $this->error('未查询到相应的asn明细');
  68. }
  69. /**
  70. * @param Request $request
  71. * 查询富勒bas_sku 并关联 bas_lotid
  72. */
  73. public function getBasSkuWithLot(Request $request): array
  74. {
  75. $customerid= $request->input('customerid');
  76. $skuOrBarcode= $request->input('sku');
  77. $asnno= $request->input('asnno');
  78. $asnDetail=app('HandInStorageService')->getAsnDetail($asnno,$skuOrBarcode);
  79. if (!$asnDetail)$this->error('无效条码');
  80. $basSku =app('HandInStorageService')->getBasSkuLotId($customerid,$asnDetail->sku);
  81. if (isset($basSku)&&isset($asnDetail))return ['success'=>true,'basSku'=>$basSku,'asnDetail'=>$asnDetail];
  82. else $this->error('无效条码');
  83. }
  84. /**
  85. * @throws \Throwable
  86. * 收货
  87. */
  88. public function fluxHandIn(Request $request)
  89. {
  90. $this->gate("入库管理-手持入库-收货");
  91. $info=$request->input('info');
  92. if ($info['lotatt02']&&Carbon::now()->gt($info['lotatt02']))$this->error('失效日期超过入库效期');
  93. if (!$info['customerid']||!$info['sku']||!$info['asnno']) $this->error('参数错误');
  94. if ($info['amount']+$info['receivedqty']>$info['expectedqty'])$this->error('收货数大于预期数');
  95. /** @var HandInStorageService $handInStorageService */
  96. $handInStorageService=app('HandInStorageService');
  97. if ($info['customerid']=='ONKYO'||$info['customerid']=='ANMEILAI'||$info['customerid']=='FEIHE'){
  98. $res=$handInStorageService->checkWidthHeight($info);
  99. if ($res===1)$this->error('需要维护产品档案');
  100. if ($res===2)$this->error('需要维护该产品档案中的长宽高');
  101. }
  102. if ($info['customerid']=='TANGENBEI'||$info['customerid']=='ANMEILAI'){
  103. $result=$handInStorageService->checkCubicWeight($info);
  104. if ($result===1)$this->error('需要维护产品档案');
  105. if ($result===2)$this->error('需要维护该产品档案中的重量体积');
  106. }
  107. if ($handInStorageService->checkForwardingLoc($info)===1)$this->error('请维护拣货位');
  108. try {
  109. $result = $handInStorageService->fluxHandIn($info);
  110. if ($result)$this->success("收货成功");
  111. else $this->error("收货失败");
  112. } catch (\Exception $e) {
  113. app('LogService')->log(__METHOD__,'error_'.__FUNCTION__,json_encode($info).'|catch:'.$e->getMessage());
  114. }
  115. }
  116. /**
  117. * @param Request $request
  118. * 根据商品条码和跟踪号 获取要上架的任务列表
  119. */
  120. public function getTsk(Request $request)
  121. {
  122. $this->gate("入库管理-手持入库-上架");
  123. $barCode=$request->input('barCode');
  124. $trackNumber=$request->input('trackNumber');
  125. if(!$barCode)$this->error('条码不能为空');
  126. if(!$trackNumber)$this->error('容器号不能为空');
  127. /** @var HandInStorageService $handInStorageService */
  128. $handInStorageService=app('HandInStorageService');
  129. $tasks=$handInStorageService->getTsk($trackNumber,$barCode);
  130. if (count($tasks)>0)$this->success($tasks);
  131. else $this->error("该商品暂无上架任务");
  132. }
  133. /**
  134. * @throws \Throwable
  135. * 上架
  136. */
  137. public function handFluxPa(Request $request)
  138. {
  139. $this->gate("入库管理-手持入库-上架");
  140. $info=$request->input('info');
  141. if (!$info['location']||!$info['amount']||!$info['trackNumber']||!$info['barCode']) $this->error('参数错误');
  142. if (count($request->input('checkData'))==0) $this->error('请勾选要上架任务');
  143. $checkData=$request->input('checkData')[0];
  144. /** @var HandInStorageService $handInStorageService */
  145. $handInStorageService=app('HandInStorageService');
  146. //判断当前库位是否能放该商品
  147. $res=$handInStorageService->checkLocation($info,$checkData);
  148. if ($res===1)$this->error('库位不存在');
  149. if ($res===2)$this->error('库位:产品和批次不可混放');
  150. if ($res===3)$this->error('库位:不能混放批次');
  151. if ($res===4)$this->error('库位:产品不能混放');
  152. try {
  153. $result = $handInStorageService->fluxHandPa($info, $checkData);
  154. if ($result===true)$this->success("上架成功");
  155. if ($result===false) $this->error("上架失败");
  156. if ($result===1)$this->error("拣货区找到效期更新的同样货品,不能上架至存储区");
  157. } catch (\Exception $e) {
  158. app('LogService')->log(__METHOD__,'error_'.__FUNCTION__,json_encode($info).'|catch:'.$e->getMessage());
  159. }
  160. }
  161. }