| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- <?php
- namespace App\Http\Controllers;
- use App\Components\AsyncResponse;
- use App\OracleBasLocation;
- use App\OracleDOCASNHeader;
- use App\Services\HandInStorageService;
- use Doctrine\DBAL\Exception\DatabaseObjectExistsException;
- use Illuminate\Http\Request;
- class HandInStorageController extends Controller
- {
- use AsyncResponse;
- /**
- * 搜索查詢asn
- */
- public function selectAsn(Request $request)
- {
- $this->gate("入库管理-手持入库-收货");
- /** @var HandInStorageService $handInStorageService */
- $handInStorageService=app('HandInStorageService');
- $asnno= $request->input('asnno');
- $asns =$handInStorageService->selectAsn($asnno);
- if (count($asns)>0){
- foreach ($asns as $asn){
- $asn->asnDetails=array();
- }
- $this->success($asns);
- }else{
- $this->error('无有效的ASN的订单');
- }
- }
- public function checkAsnOperation(Request $request)
- {
- $this->gate("入库管理-手持入库-收货");
- /** @var HandInStorageService $handInStorageService */
- $handInStorageService=app('HandInStorageService');
- $info= $request->input('info');
- $res=$handInStorageService->checkAsnOperation($info);
- if ($res===1)$this->error('无有效的ASN的订单');
- elseif ($res===2)$this->error('该asn无预约,暂不可收货');
- else $this->success($res);
- }
- /**
- * @param $asnno
- * 跳转到收货明细页面
- */
- public function receiveDetailPage($asnno,$customerid)
- {
- $this->gate("入库管理-手持入库-收货");
- /** @var HandInStorageService $handInStorageService */
- $handInStorageService=app('HandInStorageService');
- if (!$customerid||$customerid=='undefined')
- $customerid=OracleDOCASNHeader::query()->where('asnno',$asnno)->value('customerid');
- $qualityStatus=$handInStorageService->getQualityStatus();
- $attributeLocations=$handInStorageService->getAttributeLocation();
- return view('store.handInStorage.receiveDetailPage')
- ->with(['asnno'=>$asnno,'customerid'=>$customerid,'qualityStatus'=>$qualityStatus,'attributeLocations'=>$attributeLocations]);
- }
- /**
- * @param Request $request
- * 查询富勒asn_detail(集合)
- */
- public function selectAsnDetails(Request $request)
- {
- $this->gate("入库管理-手持入库-收货");
- $asnno= $request->input('asnno');
- $asnDetails =app('HandInStorageService')->selectAsnDetails($asnno);
- if (count($asnDetails)>0)$this->success($asnDetails);
- else $this->error('未查询到相应的asn明细');
- }
- /**
- * @param Request $request
- * 查询富勒bas_sku 并关联 bas_lotid
- */
- public function getBasSkuWithLot(Request $request): array
- {
- $customerid= $request->input('customerid');
- $skuOrBarcode= $request->input('sku');
- $asnno= $request->input('asnno');
- $asnDetail=app('HandInStorageService')->getAsnDetail($asnno,$skuOrBarcode);
- if (!$asnDetail)$this->error('无效条码');
- $basSku =app('HandInStorageService')->getBasSkuLotId($customerid,$asnDetail->sku);
- if (isset($basSku)&&isset($asnDetail))return ['success'=>true,'basSku'=>$basSku,'asnDetail'=>$asnDetail];
- else $this->error('无效条码');
- }
- /**
- * @throws \Throwable
- * 收货
- */
- public function fluxHandIn(Request $request)
- {
- $this->gate("入库管理-手持入库-收货");
- $info=$request->input('info');
- if (!$info['customerid']||!$info['sku']||!$info['asnno']) $this->error('参数错误');
- if ($info['amount']+$info['receivedqty']>$info['expectedqty'])$this->error('收货数大于预期数');
- // if ($info['location']){
- // $location=OracleBasLocation::query()
- // ->where('locationid',$info['location'])
- // ->where('status','OK')
- // ->first();
- // if (!$location)$this->error('目标库位不存在');
- // }
- /** @var HandInStorageService $handInStorageService */
- $handInStorageService=app('HandInStorageService');
- try {
- $result = $handInStorageService->fluxHandIn($info);
- if ($result)$this->success("收货成功");
- else $this->error("收货失败");
- } catch (\Exception $e) {
- app('LogService')->log(__METHOD__,'error_'.__FUNCTION__,json_encode($info).'|catch:'.$e->getMessage());
- }
- }
- /**
- * @param Request $request
- * 根据商品条码和跟踪号 获取要上架的任务列表
- */
- public function getTsk(Request $request)
- {
- $this->gate("入库管理-手持入库-上架");
- $barCode=$request->input('barCode');
- $trackNumber=$request->input('trackNumber');
- if(!$barCode)$this->error('条码不能为空');
- if(!$trackNumber)$this->error('容器号不能为空');
- /** @var HandInStorageService $handInStorageService */
- $handInStorageService=app('HandInStorageService');
- $tasks=$handInStorageService->getTsk($trackNumber,$barCode);
- if (count($tasks)>0)$this->success($tasks);
- else $this->error("该商品暂无上架任务");
- }
- /**
- * @throws \Throwable
- * 上架
- */
- public function handFluxPa(Request $request)
- {
- $this->gate("入库管理-手持入库-上架");
- $info=$request->input('info');
- if (!$info['location']||!$info['amount']||!$info['trackNumber']||!$info['barCode']) $this->error('参数错误');
- if (count($request->input('checkData'))==0) $this->error('请勾选要上架任务');
- $checkData=$request->input('checkData')[0];
- $location=OracleBasLocation::query()
- ->where('locationid',$info['location'])
- ->where('status','OK')
- ->first();
- if (!$location)$this->error('目标库位不存在');
- /** @var HandInStorageService $handInStorageService */
- $handInStorageService=app('HandInStorageService');
- try {
- $result = $handInStorageService->fluxHandPa($info, $checkData);
- if ($result)$this->success("上架成功");
- else $this->error("上架失败");
- } catch (\Exception $e) {
- app('LogService')->log(__METHOD__,'error_'.__FUNCTION__,json_encode($info).'|catch:'.$e->getMessage());
- }
- }
- }
|