|
|
@@ -6,7 +6,10 @@ use App\Components\AsyncResponse;
|
|
|
use App\OracleDOCASNHeader;
|
|
|
use App\Services\HandInStorageService;
|
|
|
use Carbon\Carbon;
|
|
|
+use Doctrine\DBAL\Exception;
|
|
|
use Illuminate\Http\Request;
|
|
|
+use Illuminate\Support\Facades\Auth;
|
|
|
+use Illuminate\Support\Facades\Cache;
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
class HandInStorageController extends Controller
|
|
|
@@ -81,15 +84,12 @@ class HandInStorageController extends Controller
|
|
|
*/
|
|
|
public function getBasSkuWithLot(Request $request): array
|
|
|
{
|
|
|
- $start=microtime(true);
|
|
|
$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);
|
|
|
- $end=microtime(true);
|
|
|
- if(($end-$start)>1)Log::warning('手持条码获取详情超时',$request->all());
|
|
|
if (isset($basSku)&&isset($asnDetail))return ['success'=>true,'basSku'=>$basSku,'asnDetail'=>$asnDetail];
|
|
|
else $this->error('无效条码');
|
|
|
}
|
|
|
@@ -100,12 +100,14 @@ class HandInStorageController extends Controller
|
|
|
*/
|
|
|
public function fluxHandIn(Request $request)
|
|
|
{
|
|
|
- $start=microtime(true);
|
|
|
$this->gate("入库管理-手持入库-收货");
|
|
|
$info=$request->input('info');
|
|
|
+ $isReceivedqty=$info['receivedqty']??false;
|
|
|
+ $isExpectedqty=$info['expectedqty']??false;
|
|
|
+ $isSku=$info['sku']??false;
|
|
|
if ($info['lotatt02']&&Carbon::now()->gt($info['lotatt02']))$this->error('失效日期超过入库效期');
|
|
|
- if (!$info['customerid']||!$info['sku']||!$info['asnno']) $this->error('参数错误');
|
|
|
- if ($info['amount']+$info['receivedqty']>$info['expectedqty'])$this->error('收货数大于预期数');
|
|
|
+ if (!$info['customerid']||$isSku===false||!$info['asnno']||$isReceivedqty===false||$isExpectedqty===false) $this->error('参数错误');
|
|
|
+ if ($info['amount'] + $info['receivedqty'] > $info['expectedqty']) $this->error('收货数大于预期数');
|
|
|
/** @var HandInStorageService $handInStorageService */
|
|
|
$handInStorageService=app('HandInStorageService');
|
|
|
if ($info['customerid']=='ONKYO'||$info['customerid']=='ANMEILAI'||$info['customerid']=='FEIHE'){
|
|
|
@@ -119,17 +121,26 @@ class HandInStorageController extends Controller
|
|
|
if ($result===2)$this->error('需要维护该产品档案中的重量体积');
|
|
|
}
|
|
|
if ($info['customerid']=='JIANSHANG'&&$handInStorageService->checkForwardingLoc($info)===1)$this->error('请维护拣货位');
|
|
|
+ $key = $info['asnno'] . '_' . $info['sku'] . '_' . Auth::id();
|
|
|
+ $ttl = 10;
|
|
|
try {
|
|
|
+ //缓存校验操作
|
|
|
+ if (Cache::has($key)){
|
|
|
+ $this->error('当前已操作');
|
|
|
+ }else{
|
|
|
+ Cache::put($key,true, $ttl);
|
|
|
+ }
|
|
|
+ //收货操作
|
|
|
$resultIn = $handInStorageService->fluxHandIn($info);
|
|
|
if ($resultIn===1)$this->error("超收");
|
|
|
if ($resultIn){
|
|
|
$asnQty=$handInStorageService->getAsnQty($info['asnno']);
|
|
|
- $end=microtime(true);
|
|
|
- if(($end-$start)>2)Log::warning('手持收货超时',$request->all());
|
|
|
$this->success($asnQty);
|
|
|
} else $this->error("收货失败");
|
|
|
} catch (\Exception $e) {
|
|
|
app('LogService')->log(__METHOD__,'error_'.__FUNCTION__,json_encode($info).'|catch:'.$e->getMessage());
|
|
|
+ } finally {
|
|
|
+ Cache::forget($key);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -181,7 +192,8 @@ class HandInStorageController extends Controller
|
|
|
{
|
|
|
$this->gate("入库管理-手持入库-上架");
|
|
|
$info=$request->input('info');
|
|
|
- if (!$info['location']||!$info['amount']||!$info['barCode']) $this->error('参数错误');
|
|
|
+ if (gettype($info['amount'])==='string')$info['amount']=(int)$info['amount'];
|
|
|
+ if (!$info['location']||!$info['amount']||!$info['barCode'] || gettype($info['amount'])==='string') $this->error('参数错误');
|
|
|
if (count($request->input('checkData'))==0) $this->error('请勾选要上架任务');
|
|
|
$checkData=$request->input('checkData')[0];
|
|
|
/** @var HandInStorageService $handInStorageService */
|
|
|
@@ -192,7 +204,16 @@ class HandInStorageController extends Controller
|
|
|
if ($res===2)$this->error('库位:产品和批次不可混放');
|
|
|
if ($res===3)$this->error('库位:不能混放批次');
|
|
|
if ($res===4)$this->error('库位:产品不能混放');
|
|
|
+ $key = $info['location'] . '_' . $info['barCode'] . '_' . Auth::id();
|
|
|
+ $ttl = 10;
|
|
|
try {
|
|
|
+ //缓存校验操作
|
|
|
+ if (Cache::has($key)){
|
|
|
+ $this->error('当前已操作');
|
|
|
+ }else{
|
|
|
+ Cache::put($key,true, $ttl);
|
|
|
+ }
|
|
|
+
|
|
|
$result = $handInStorageService->fluxHandPa($info, $checkData);
|
|
|
if ($result===true)$this->success("上架成功");
|
|
|
if ($result===false) $this->error("上架失败");
|
|
|
@@ -200,6 +221,8 @@ class HandInStorageController extends Controller
|
|
|
} catch (\Exception $e) {
|
|
|
$this->error($e->getMessage());
|
|
|
app('LogService')->log(__METHOD__,'error_'.__FUNCTION__,json_encode($info).'|catch:'.$e->getMessage());
|
|
|
+ }finally {
|
|
|
+ Cache::forget($key);
|
|
|
}
|
|
|
}
|
|
|
|