HandInStorageController.php 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 Illuminate\Http\Request;
  8. class HandInStorageController extends Controller
  9. {
  10. use AsyncResponse;
  11. /**
  12. * 搜索查詢asn
  13. */
  14. public function selectAsn(Request $request)
  15. {
  16. /** @var HandInStorageService $handInStorageService */
  17. $handInStorageService=app('HandInStorageService');
  18. $asnno= $request->input('asnno');
  19. $asns =$handInStorageService->selectAsn($asnno);
  20. if ($asns->count()>0){
  21. $this->success($asns);
  22. }else{
  23. $this->error('未搜索到ASN单');
  24. }
  25. }
  26. /**
  27. * @param $asnno
  28. * 跳转到收货明细页面
  29. */
  30. public function receiveDetailPage($asnno,$customerid)
  31. {
  32. /** @var HandInStorageService $handInStorageService */
  33. $handInStorageService=app('HandInStorageService');
  34. if (!$customerid||$customerid=='undefined')
  35. $customerid=OracleDOCASNHeader::query()->where('asnno',$asnno)->value('customerid');
  36. $qualityStatus=$handInStorageService->getQualityStatus();
  37. $attributeLocations=$handInStorageService->getAttributeLocation();
  38. return view('store.handInStorage.receiveDetailPage')
  39. ->with(['asnno'=>$asnno,'customerid'=>$customerid,'qualityStatus'=>$qualityStatus,'attributeLocations'=>$attributeLocations]);
  40. }
  41. /**
  42. * @param Request $request
  43. * 查询富勒asn_detail(集合)
  44. */
  45. public function selectAsnDetails(Request $request)
  46. {
  47. $asnno= $request->input('asnno');
  48. $asnDetails =app('HandInStorageService')->selectAsnDetails($asnno);
  49. if ($asnDetails->count()>0)$this->success($asnDetails);
  50. else $this->error('未搜索到ASN详情单');
  51. }
  52. /**
  53. * @param Request $request
  54. * 查询富勒bas_sku 并关联 bas_lotid
  55. */
  56. public function getBasSkuWithLot(Request $request): array
  57. {
  58. $customerid= $request->input('customerid');
  59. $sku= $request->input('sku');
  60. $asnno= $request->input('asnno');
  61. $asnDetail=app('HandInStorageService')->getAsnDetail($asnno,$sku);
  62. $basSku =app('HandInStorageService')->getBasSkuLotId($customerid,$sku);
  63. if (isset($basSku)&&isset($asnDetail))return ['success'=>true,'basSku'=>$basSku,'asnDetail'=>$asnDetail];
  64. else $this->error('无效条码');
  65. }
  66. /**
  67. * @throws \Throwable
  68. */
  69. public function fluxHandIn(Request $request)
  70. {
  71. $info=$request->input('info');
  72. if (!$info['customerid']||!$info['sku']||!$info['asnno']) $this->error('参数错误');
  73. if ($info['amount']+$info['receivedqty']>$info['expectedqty'])$this->error('收货数大于预期数');
  74. if ($info['location']){
  75. $location=OracleBasLocation::query()->where('locationid',$info['location'])->first();
  76. if (!$location)$this->error('目标库位不存在');
  77. }
  78. /** @var HandInStorageService $handInStorageService */
  79. $handInStorageService=app('HandInStorageService');
  80. $result=$handInStorageService->fluxHandIn($info);
  81. if ($result)$this->success("收货成功");
  82. else $this->error("收货失败");
  83. }
  84. }