Przeglądaj źródła

Merge branch 'Haozi'

zhouzhendong 4 lat temu
rodzic
commit
f562a6c726

+ 2 - 2
app/Events/GuardAuditEvent.php

@@ -4,11 +4,11 @@ namespace App\Events;
 
 use App\UserDutyCheck;
 use Illuminate\Broadcasting\Channel;
-use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
+use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
 use Illuminate\Queue\SerializesModels;
 
 
-class GuardAuditEvent implements ShouldBroadcast
+class GuardAuditEvent implements ShouldBroadcastNow
 {
     use  SerializesModels;
 

+ 6 - 0
app/Http/ApiControllers/WaybillController.php

@@ -113,6 +113,9 @@ class WaybillController
         $result = Waybill::query()->where("id",$request->input("id"))
             ->update($request->validated());
         if ($result==0)$this->response(false,204,"单据状态发生变化,修改失败");
+//        $startDate = "";
+//        $endDate = "";
+//        $res = ["2021-10-08"=>20,"2021-10-09"=>21];
         $this->response(true);
     }
 
@@ -142,6 +145,9 @@ class WaybillController
         $fee        = $request->input("fee");
         if (!$deliverAt || !$fee || !is_numeric($fee) || !$fee<0)
             $this->response(false,400,"非法参数或不满足需求");
+        $param=array('screenDate'=>$deliverAt,'billing'=>$fee);
+        $waybills=app('waybillService')->dailyBilling($param);
+        if ($waybills===0 || $waybills===1 || !isset($waybills)) $this->response(false);
         $this->response(true);
     }
 }

+ 32 - 9
app/Http/Controllers/HandInStorageController.php

@@ -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);
         }
     }
 

+ 2 - 1
app/Http/Controllers/WaybillController.php

@@ -1103,7 +1103,8 @@ SQL;
         && !Gate::allows('运输管理-承运商调度')){return ['success'=>false,'message'=>'没有权限'];}
         $dailyBilling=$request->input('param');
         $waybills=app('waybillService')->dailyBilling($dailyBilling);
-        if ($waybills=='无数据')return ['success'=>false,'message'=>'当前选定发货日期没有任何记录'];
+        if ($waybills===0)return ['success'=>false,'message'=>'请输入相应的发货日期和费用!'];
+        if ($waybills===1)return ['success'=>false,'message'=>'当前选定发货日期没有任何记录'];
         if (!isset($waybills))return ['success'=>false,'message'=>'该日有记录未填写重量'];
         return ['success'=>true,'data'=>$waybills];
     }

+ 5 - 2
app/Services/HandInStorageService.php

@@ -586,6 +586,7 @@ sql;
 
             // 6: flux 更新 asn_detail 和 asn_header 状态
             $result=$this->updateFluxAsn($info, $invlotatt, $time, $who,$asnDetail);
+            if ($result===1){$db->rollBack();return 1;}//超收
             if (!$result){$db->rollBack();return false;}
             $db->commit();
             return true;
@@ -617,10 +618,11 @@ sql;
      * @param array $invlotatt
      * @param $time
      * @param $who
-     * @return bool
+     * @param $asnDetail
+     * @return bool|int
      * 更新asn状态
      */
-    public function updateFluxAsn(array $info, array $invlotatt, $time, $who,$asnDetail): bool
+    public function updateFluxAsn(array $info, array $invlotatt, $time, $who,$asnDetail)
     {
         $db = DB::connection("oracle");
         $asn = OracleDOCASNHeader::query()
@@ -636,6 +638,7 @@ sql;
         $amount = (int) $info['amount'];                    // 当前收货数量
         $expectedQty = (int)$asnDetail['expectedqty'];     // 预期数量
 
+        if ($receivedQty+$amount>$expectedQty)return 1; //超收
         if ($receivedQty + $amount < $expectedQty) {
             // 已收货数量+当前收货数量 < 预期数量
             $db->update(DB::raw("UPDATE DOC_ASN_DETAILS SET receivedqty = receivedqty + ?,receivedqty_each = receivedqty_each + ?,linestatus = '30',holdrejectcode ='OK',

+ 2 - 1
app/Services/StorageService.php

@@ -493,9 +493,10 @@ COMPLETED_TRANSACTIONID = ?,OPENWHO = ?,OPENTIME = TO_DATE(?,'yyyy-mm-dd hh24:mi
  CLOSEWHO = ?,CLOSETIME = ?,EDITTIME = ?,EDITWHO = ?
  where taskid = ? AND TASKID_SEQUENCE = ?
 sql;
-            $db->update(DB::raw($sql),[
+            $result=$db->update(DB::raw($sql),[
                 $ide,'0',$trid,$who,date("Y-m-d H:i:s"),$who,date("Y-m-d H:i:s"),date("Y-m-d H:i:s"),$who,$task->taskid,$task->taskid_sequence
             ]);
+            if (!$result){$db->rollBack();return false;}
             $task->who = $who;
             $this->checkAsn($task,$who);
             $db->commit();

+ 6 - 3
app/Services/StoreItemService.php

@@ -208,9 +208,12 @@ class StoreItemService
         if (!$asnDetails) {
             return null;
         }
-        return StoreItem::query()->with('store')->whereIn('store_id', function ($query) use ($asnDetails) {
-            $query->from('stores')->select('id')->whereIn('asn_code', array_unique(data_get($asnDetails, '*.asnno')));
-        })->get();
+        $storeIds=Store::query()->whereIn('asn_code',array_unique(data_get($asnDetails, '*.asnno')))->pluck('id');
+        return StoreItem::query()->with('store')->whereIn('store_id',$storeIds)->get();
+
+//        return StoreItem::query()->with('store')->whereIn('store_id', function ($query) use ($asnDetails) {
+//            $query->from('stores')->select('id')->whereIn('asn_code', array_unique(data_get($asnDetails, '*.asnno')));
+//        })->get();
     }
 
     public function deleteStoreItem(array $delete_storeItems)

+ 6 - 5
app/Services/WaybillService.php

@@ -150,19 +150,20 @@ class WaybillService
         return $waybills->get();
     }
     public function dailyBilling(array $param){
+        if (($param['screenDate']??false)==false || ($param['billing']??false)==false) return 0; //入参错误
         $waybills = Waybill::query()->with(['owner','logistic','originationCity','destinationCity.parent',
             'uploadFiles','amountUnit','warehouseWeightUnit','carrierWeightUnit','district','order',
-            'warehouseWeightUnitOther','carrierWeightUnitOther','carType','uploadFiles','waybillAuditLogs.user'])
+            'warehouseWeightUnitOther','carrierWeightUnitOther','carType','waybillAuditLogs.user'])
             ->selectRaw('waybills.* ,waybill_on_tops.id top_id,waybill_on_tops.remark,waybill_on_tops.updated_at top_update')
             ->leftJoin('waybill_on_tops','waybill_on_tops.waybill_id','=','waybills.id')
             ->whereNull('waybill_on_tops.deleted_at')
             ->orderBy('waybill_on_tops.updated_at','desc')
             ->orderBy('waybills.id','desc')
             ->where('waybills.type','专线')
-            ->where('waybills.amount','>',0);
-        if ($param['screenDate'] ?? false)$waybills->where('waybills.deliver_at','like',$param['screenDate'].'%');
-        $waybills = $waybills->get();
-        if ($waybills->isEmpty()) return '无数据';
+            ->where('waybills.amount','>',0)
+            ->where('waybills.deliver_at','like',$param['screenDate'].'%')
+            ->get();
+        if ($waybills->isEmpty()) return 1;//无数据
         foreach ($waybills as $waybill){
             if (!$waybill['carrier_weight_other'] && !$waybill['carrier_weight']) return null;
             if (!$waybill['carrier_weight_other'] || $waybill['carrier_weight_other']<=0) $waybill['carrier_weight_other']=($waybill['carrier_weight']/0.25*100);

+ 1 - 1
resources/views/personnel/checking-in/importAndExportSuccess.blade.php

@@ -38,8 +38,8 @@
         },
         mounted(){
             initEcho();
-            let _this=this;
             Echo.channel('{{$laravelEchoPrefix}}userDutyCheck').listen('GuardAuditEvent',(e)=>{
+                let _this=this;
                 let userDutyCheck=e.userDutyCheck;
                 _this.userDutyCheck.verify_user_id=userDutyCheck.verify_user_id;
             });

+ 2 - 2
resources/views/rejected/edit.blade.php

@@ -468,8 +468,8 @@
                     axios.post(url,{barcode:barcode}).then(function (response) {
                         _this.cleanError();
                         if(response.data.success==='true'){
-                            if(response.data.name){
-                                _this.itemInputting.name_goods=response.data.name;
+                            if(response.data.commodity){
+                                _this.itemInputting.name_goods=response.data.commodity.name;
                             }
                         }else{
                             tempTip.setDuration(3000);