HandInStorageController.php 5.2 KB

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