Эх сурвалжийг харах

Merge branch 'waybill_ZD'

# Conflicts:
#	app/Http/Controllers/PackageController.php
LD 6 жил өмнө
parent
commit
d55154752c

+ 79 - 57
app/Http/Controllers/PackageController.php

@@ -4,7 +4,6 @@ namespace App\Http\Controllers;
 
 use App\Events\WeighedEvent;
 use App\Exports\WaybillExport;
-use App\Logistic;
 use App\Owner;
 use App\Package;
 use App\PaperBox;
@@ -16,6 +15,30 @@ use Maatwebsite\Excel\Facades\Excel;
 
 class PackageController extends Controller
 {
+
+    public function conditionQuery(Request $request,$packages){
+        $today=Carbon::now()->subDays(15);
+        if ($request->input('logistic_number')){
+            $packages=$packages->where('logistic_number','like','%'.$request->input('logistic_number').'%')->where('created_at','>',$today->format('Y-m-d'));
+        }
+        if ($request->input('delivery_number')){
+            $packages=$packages->where('delivery_number','like','%'.$request->input('delivery_number').'%')->where('created_at','>',$today->format('Y-m-d'));
+        }
+        if ($request->input('created_at_start')){
+            $packages=$packages->where('created_at','>=',$request->input('created_at_start'));
+        }
+        if ($request->input('created_at_end')){
+            $packages=$packages->where('created_at','<=',$request->input('created_at_end'));
+        }
+        if ($request->input('owner_id')){
+            $packages=$packages->where('owner_id',$request->input('owner_id'));
+        }
+        if ($request->input('batch_number')){
+            $packages=$packages->where('batch_number','like','%'.$request->input('batch_number').'%')->where('created_at','>',$today->format('Y-m-d'));
+        }
+        return $packages;
+    }
+
     /**
      * Display a listing of the resource.
      *
@@ -26,25 +49,8 @@ class PackageController extends Controller
         if(!Gate::allows('称重管理-查询')){ return redirect(url('/'));  }
         if ($request->input()){
             $packages=Package::orderBy('id','DESC');
-            $today=Carbon::now()->subDays(15);
-            if ($request->input('logistic_number')){
-                $packages=$packages->where('logistic_number','like','%'.$request->input('logistic_number').'%')->where('created_at','>',$today->format('Y-m-d'));
-            }
-            if ($request->input('delivery_number')){
-                $packages=$packages->where('delivery_number','like','%'.$request->input('delivery_number').'%')->where('created_at','>',$today->format('Y-m-d'));
-            }
-            if ($request->input('created_at_start')){
-                $packages=$packages->where('created_at','>=',$request->input('created_at_start'));
-            }
-            if ($request->input('created_at_end')){
-                $packages=$packages->where('created_at','<=',$request->input('created_at_end'));
-            }
-            if ($request->input('owner_id')){
-                $packages=$packages->where('owner_id',$request->input('owner_id'));
-            }
-            if ($request->input('batch_number')){
-                $packages=$packages->where('batch_number','like','%'.$request->input('batch_number').'%')->where('created_at','>',$today->format('Y-m-d'));
-            }
+
+            $packages=$this->conditionQuery($request,$packages);
             $packages=$packages->paginate($request->input('paginate')?$request->input('paginate'):50);
             $owners=Owner::select('id','name')->get();
             return view('weight.package.index',['packages'=>$packages,'owners'=>$owners]);
@@ -70,7 +76,7 @@ class PackageController extends Controller
      * Store a newly created resource in storage.
      *
      * @param  \Illuminate\Http\Request  $request
-     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
+     * @return \Illuminate\Http\Response
      */
     public function store(Request $request)
     {
@@ -78,30 +84,37 @@ class PackageController extends Controller
         $this->validator($request)->validate();
         $logistic_number=$request->input('logistic_number');
         $weight=$request->input('weight');
+        $batch_number=$request->input('batch_number');
         $paper_box_id=$request->input('paper_box_id');
         $package=Package::where('logistic_number',$logistic_number)->first();
-        if(!$package){
-
+        if (!$package && !$logistic_number)return redirect('package/create')->with('successError','录入失败!没有填写快递单号!');
+        if ($package){
+            $accomplishToWMS=new \App\Http\Controllers\Api\thirdPart\flux\PackageController();
+            $packageController=new \App\Http\Controllers\PackageController();
+            if ($package->batch_rule&&strstr($package->batch_rule,'组合')){
+                $packageController->syncBatch($package->batch_number,$weight,null,null,null,Carbon::now(),$paper_box_id);
+            }else{
+                $package->weight=$weight;
+                $package->paper_box_id=$paper_box_id;
+                $package->batch_number=$batch_number;
+                $result=$accomplishToWMS->accomplishToWMS($package);
+                if ($result['result']=='success'){
+                    if ($package->status=="记录异常")$package->status="已上传异常";
+                    else $package->status="已上传";
+                }else{
+                    $package->status="上传异常";
+                }
+            }
+        }else{
             $package=new Package([
                 'logistic_number'=>$logistic_number,
                 'weight'=>$weight,
-                'paper_box_id'=>$paper_box_id
+                'paper_box_id'=>$paper_box_id,
+                'batch_number'=>$batch_number
             ]);
-            event(new WeighedEvent($package));
-        }else{
-            $package['weight']=$weight;
-            $package['paper_box_id']=$paper_box_id;
-            $accomplishToWMS=new \App\Http\Controllers\Api\thirdPart\flux\PackageController();
-            $result=$accomplishToWMS->accomplishToWMS($package);
-            if ($result['result']=='success'){
-                if ($package->status=="记录异常")$package->status="已上传异常";
-                else $package->status="已上传";
-            }else{
-                $package->status="上传异常";
-            }
-            event(new WeighedEvent($package));
         }
         $package->save();
+        event(new WeighedEvent($package));
         return redirect('package/create')->with('successTip','新记录“'.$logistic_number.'”录入成功');
     }
 
@@ -154,28 +167,10 @@ class PackageController extends Controller
         if(!Gate::allows('称重管理-查询')){ return '没有权限';  }
         if ($id==-1){
             $id=[];
-            $today=Carbon::now()->subDays(15);
             ini_set('max_execution_time',2500);
             ini_set('memory_limit','1526M');
             $packages=Package::select('id');
-            if ($request->input('logistic_number')){
-                $packages=$packages->where('logistic_number','like','%'.$request->input('logistic_number').'%')->where('created_at','>',$today->format('Y-m-d'));
-            }
-            if ($request->input('delivery_number')){
-                $packages=$packages->where('delivery_number','like','%'.$request->input('delivery_number').'%')->where('created_at','>',$today->format('Y-m-d'));
-            }
-            if ($request->input('created_at_start')){
-                $packages=$packages->where('created_at','>=',$request->input('created_at_start'));
-            }
-            if ($request->input('created_at_end')){
-                $packages=$packages->where('created_at','<=',$request->input('created_at_end'));
-            }
-            if ($request->input('owner_id')){
-                $packages=$packages->where('owner_id',$request->input('owner_id'));
-            }
-            if ($request->input('batch_number')){
-                $packages=$packages->where('batch_number','like','%'.$request->input('batch_number').'%')->where('created_at','>',$today->format('Y-m-d'));
-            }
+            $packages=$this->conditionQuery($request,$packages);
             $packages=$packages->get();
             foreach ($packages as $package){
                 array_push($id,$package->id);
@@ -231,9 +226,10 @@ class PackageController extends Controller
     }
     protected function validator(Request $request){
         $validator=Validator::make($request->input(),[
-            'logistic_number'=>['required','max:50'],
+            'logistic_number'=>['nullable','max:50'],
             'weight'=>'required|min:0|max:999999|numeric',
             'paper_box_id'=>'nullable|integer',
+            'batch_number'=>'required_without:logistic_number'
         ],[
             'required'=>':attribute 为必填项',
             'max'=>':attribute 字符过多或输入值过大',
@@ -241,11 +237,37 @@ class PackageController extends Controller
             'min'=>':attribute 不得为负',
             'numeric'=>':attribute 应为数字',
             'unique'=>':attribute 已存在',
+            'required_without'=>':attribute 与快递单号至少填一项'
         ],[
             'logistic_number'=>'快递单号',
             'weight'=>'重量',
             'paper_box_id'=>'纸箱',
+            'batch_number'=>'波次号',
         ]);
         return $validator;
     }
+
+    public function syncBatch($batch_number,$weight,$max,$centre,$min,$date,$paperBox_id){
+        $accomplishToWMS=new \App\Http\Controllers\Api\thirdPart\flux\PackageController();
+        $packagesBatch=Package::where('batch_number',$batch_number)->get();
+        foreach ($packagesBatch as $packageBatch){
+            $packageBatch->weight=$weight;
+            if($max)$packageBatch->length=$max;
+            if($centre)$packageBatch->width=$centre;
+            if($min)$packageBatch->height=$min;
+            $packageBatch->bulk=$max*$centre*$min;
+            $packageBatch->weighed_at=$date;
+            if ($paperBox_id)$packageBatch->paper_box_id=$paperBox_id;
+            $packageBatch->status="未上传";
+            $result=$accomplishToWMS->accomplishToWMS($packageBatch);
+            if ($result['result']=='success'){
+                if ($packageBatch->status=="记录异常")$packageBatch->status="已上传异常";
+                else $packageBatch->status="已上传";
+            }else{
+                $packageBatch->status="上传异常";
+            }
+            $packageBatch->save();
+        }
+    }
+
 }

+ 30 - 3
app/Http/Controllers/StoreController.php

@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
 
 use App\Store;
 use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Validator;
 
 class StoreController extends Controller
 {
@@ -14,7 +15,8 @@ class StoreController extends Controller
      */
     public function index()
     {
-        //
+        $stores=Store::orderBy('id','DESC')->paginate(50);
+        return view('store.fast.index',['stores'=>$stores]);
     }
 
     /**
@@ -24,7 +26,7 @@ class StoreController extends Controller
      */
     public function create()
     {
-        //
+        return view('store.fast.create');
     }
 
     /**
@@ -35,7 +37,19 @@ class StoreController extends Controller
      */
     public function store(Request $request)
     {
-        //
+        $this->validator($request);
+        $store=Store::with('storeItems')->where('asn_code',$request->input('asn_code'))->first();
+        if (!$store)return redirect('store/fast/create')->with('successError','ASN编号不存在!');
+        $store->status='已入库';
+        $store->save();
+        if ($store->storeItems){
+            $quality=$request->input('quality');
+            $store->storeItems->each(function ($storeItem)use($quality){
+                $storeItem->status='已入库';
+                $storeItem->quality=$quality;
+                $storeItem->save();
+            });
+        }
     }
 
     /**
@@ -82,4 +96,17 @@ class StoreController extends Controller
     {
         //
     }
+
+    public function validator(Request $request){
+        $validator=Validator::make($request->input(),[
+            'asn_code'=>['required'],
+            'quality'=>['required']
+        ],[
+            'required'=>':attribute 为必填项',
+        ],[
+            'asn_code'=>'ASN编号',
+            'quality'=>'货物类型'
+        ])->validate();
+        return $validator;
+    }
 }

+ 10 - 18
app/Http/Controllers/WaybillFinancialExceptedController.php

@@ -11,10 +11,7 @@ use Illuminate\Support\Facades\Gate;
 
 class WaybillFinancialExceptedController extends Controller
 {
-    public function index(Request $request)
-    {
-        if(!Gate::allows('财务报表-查询')){ return redirect(url('/'));  }
-        $waybillFinancialSnapshots=WaybillFinancialExcepted::orderBy('id', 'DESC');
+    public function conditionQuery(Request $request,$waybillFinancialSnapshots){
         if ($request->input('created_at_start')){
             $waybillFinancialSnapshots=$waybillFinancialSnapshots->where('created_at','>',$request->input('created_at_start'));
         }
@@ -22,32 +19,27 @@ class WaybillFinancialExceptedController extends Controller
             $waybillFinancialSnapshots=$waybillFinancialSnapshots->where('created_at','<',$request->input('created_at_end'));
         }
         $waybillFinancialSnapshots=$waybillFinancialSnapshots->paginate(50);
+        return $waybillFinancialSnapshots;
+    }
+    public function index(Request $request)
+    {
+        if(!Gate::allows('财务报表-查询')){ return redirect(url('/'));  }
+        $waybillFinancialSnapshots=WaybillFinancialExcepted::orderBy('id', 'DESC');
+        $waybillFinancialSnapshots=$this->conditionQuery($request,$waybillFinancialSnapshots);
         return view('waybill.waybillFinancialSnapshot.index',['waybillFinancialSnapshots'=>$waybillFinancialSnapshots,'filterData'=>$request->input(),'type'=>'','excepted'=>true]);
     }
     public function indexZF(Request $request)
     {
         if(!Gate::allows('财务报表-查询')){ return redirect(url('/'));  }
         $waybillFinancialSnapshots=WaybillFinancialExcepted::orderBy('id', 'DESC')->where('json_content','like','%直发车%');
-        if ($request->input('created_at_start')){
-            $waybillFinancialSnapshots=$waybillFinancialSnapshots->where('created_at','>',$request->input('created_at_start'));
-        }
-        if ($request->input('created_at_end')){
-            $waybillFinancialSnapshots=$waybillFinancialSnapshots->where('created_at','<',$request->input('created_at_end'));
-        }
-        $waybillFinancialSnapshots=$waybillFinancialSnapshots->paginate(50);
+        $waybillFinancialSnapshots=$this->conditionQuery($request,$waybillFinancialSnapshots);
         return view('waybill.waybillFinancialSnapshot.index',['waybillFinancialSnapshots'=>$waybillFinancialSnapshots,'filterData'=>$request->input(),'type'=>'ZF','excepted'=>true]);
     }
     public function indexZX(Request $request)
     {
         if(!Gate::allows('财务报表-查询')){ return redirect(url('/'));  }
         $waybillFinancialSnapshots=WaybillFinancialExcepted::orderBy('id', 'DESC')->where('json_content','like','%专线%');
-        if ($request->input('created_at_start')){
-            $waybillFinancialSnapshots=$waybillFinancialSnapshots->where('created_at','>',$request->input('created_at_start'));
-        }
-        if ($request->input('created_at_end')){
-            $waybillFinancialSnapshots=$waybillFinancialSnapshots->where('created_at','<',$request->input('created_at_end'));
-        }
-        $waybillFinancialSnapshots=$waybillFinancialSnapshots->paginate(50);
+        $waybillFinancialSnapshots=$this->conditionQuery($request,$waybillFinancialSnapshots);
         return view('waybill.waybillFinancialSnapshot.index',['waybillFinancialSnapshots'=>$waybillFinancialSnapshots,'filterData'=>$request->input(),'type'=>'ZX','excepted'=>true]);
     }
 }

+ 10 - 18
app/Http/Controllers/WaybillFinancialSnapshotsController.php

@@ -12,10 +12,7 @@ use Maatwebsite\Excel\Facades\Excel;
 
 class WaybillFinancialSnapshotsController extends Controller
 {
-    public function index(Request $request)
-    {
-        if(!Gate::allows('财务报表-查询')){ return redirect(url('/'));  }
-        $waybillFinancialSnapshots=WaybillFinancialSnapshot::orderBy('id', 'DESC');
+    public function conditionQuery(Request $request,$waybillFinancialSnapshots){
         if ($request->input('created_at_start')){
             $waybillFinancialSnapshots=$waybillFinancialSnapshots->where('created_at','>',$request->input('created_at_start'));
         }
@@ -23,6 +20,13 @@ class WaybillFinancialSnapshotsController extends Controller
             $waybillFinancialSnapshots=$waybillFinancialSnapshots->where('created_at','<',$request->input('created_at_end'));
         }
         $waybillFinancialSnapshots=$waybillFinancialSnapshots->paginate(50);
+        return $waybillFinancialSnapshots;
+    }
+    public function index(Request $request)
+    {
+        if(!Gate::allows('财务报表-查询')){ return redirect(url('/'));  }
+        $waybillFinancialSnapshots=WaybillFinancialSnapshot::orderBy('id', 'DESC');
+        $waybillFinancialSnapshots=$this->conditionQuery($request,$waybillFinancialSnapshots);
         return view('waybill.waybillFinancialSnapshot.index',['waybillFinancialSnapshots'=>$waybillFinancialSnapshots,'filterData'=>$request->input(),'type'=>'']);
     }
 
@@ -30,13 +34,7 @@ class WaybillFinancialSnapshotsController extends Controller
     {
         if(!Gate::allows('财务报表-查询')){ return redirect(url('/'));  }
         $waybillFinancialSnapshots=WaybillFinancialSnapshot::orderBy('id', 'DESC')->where('json_content','like','%直发车%');
-        if ($request->input('created_at_start')){
-            $waybillFinancialSnapshots=$waybillFinancialSnapshots->where('created_at','>',$request->input('created_at_start'));
-        }
-        if ($request->input('created_at_end')){
-            $waybillFinancialSnapshots=$waybillFinancialSnapshots->where('created_at','<',$request->input('created_at_end'));
-        }
-        $waybillFinancialSnapshots=$waybillFinancialSnapshots->paginate(50);
+        $waybillFinancialSnapshots=$this->conditionQuery($request,$waybillFinancialSnapshots);
         return view('waybill.waybillFinancialSnapshot.index',['waybillFinancialSnapshots'=>$waybillFinancialSnapshots,'filterData'=>$request->input(),'type'=>'ZF']);
     }
 
@@ -44,13 +42,7 @@ class WaybillFinancialSnapshotsController extends Controller
     {
         if(!Gate::allows('财务报表-查询')){ return redirect(url('/'));  }
         $waybillFinancialSnapshots=WaybillFinancialSnapshot::orderBy('id', 'DESC')->where('json_content','like','%专线%');
-        if ($request->input('created_at_start')){
-            $waybillFinancialSnapshots=$waybillFinancialSnapshots->where('created_at','>',$request->input('created_at_start'));
-        }
-        if ($request->input('created_at_end')){
-            $waybillFinancialSnapshots=$waybillFinancialSnapshots->where('created_at','<',$request->input('created_at_end'));
-        }
-        $waybillFinancialSnapshots=$waybillFinancialSnapshots->paginate(50);
+        $waybillFinancialSnapshots=$this->conditionQuery($request,$waybillFinancialSnapshots);
         return view('waybill.waybillFinancialSnapshot.index',['waybillFinancialSnapshots'=>$waybillFinancialSnapshots,'filterData'=>$request->input(),'type'=>'ZX']);
     }
 

+ 44 - 102
app/Http/Controllers/WaybillsController.php

@@ -27,53 +27,57 @@ use Ramsey\Uuid\Uuid;
 
 class WaybillsController extends Controller
 {
+    public function conditionQuery(Request $request,$waybills){
+        $today=Carbon::now()->subDays(15);
+        if ($request->input('waybill_number')){
+            $waybills =$waybills->where('waybill_number','like','%'.$request->input('waybill_number').'%')->where('created_at','>',$today->format('Y-m-d'));
+        }
+        if ($request->input('carrier_bill')){
+            $waybills=$waybills->where('carrier_bill','like','%'.$request->input('carrier_bill').'%')->where('created_at','>',$today->format('Y-m-d'));
+        }
+        if ($request->input('carrier_id')){
+            $waybills=$waybills->where('carrier_id','=',$request->input('carrier_id'));
+        }
+        if ($request->input('owner_id')){
+            $waybills=$waybills->where('owner_id','=',$request->input('owner_id'));
+        }
+        if ($request->input('wms_bill_number')){
+            $waybills=$waybills->where('wms_bill_number','like','%'.$request->input('wms_bill_number').'%')->where('created_at','>',$today->format('Y-m-d'));
+        }
+        if ($request->input('origination')){
+            $waybills=$waybills->where('origination','like','%'.$request->input('origination').'%')->where('created_at','>',$today->format('Y-m-d'));
+        }
+        if ($request->input('destination')){
+            $waybills=$waybills->where('destination','like','%'.$request->input('destination').'%')->where('created_at','>',$today->format('Y-m-d'));
+        }
+        if ($request->input('created_at_start')){
+            $waybills=$waybills->where('created_at','>',$request->input('created_at_start'));
+        }
+        if ($request->input('created_at_end')){
+            $waybills=$waybills->where('created_at','<',$request->input('created_at_end'));
+        }
+        if ($request->input('status')){
+            $waybills=$waybills->where('status',$request->input('status'));
+        }
+        $waybills=$waybills->paginate($request->input('paginate')?$request->input('paginate'):50);
+        if (!$waybills&&$request->input('waybill_number')){
+            $waybills=Waybill::with(['owner', 'waybillAuditLogs' => function ($query) {
+                return $query->with('user');
+            }])->orderBy('id','DESC')->where('type','专线')->where('waybill_number',$request->input('waybill_number'))
+                ->paginate($request->input('paginate')?$request->input('paginate'):50);
+        }
+        return $waybills;
+    }
 
     public function index(Request $request)
     {
         if(!Gate::allows('运输管理-查询')){ return redirect(url('/'));  }
         $data=$request->input();
         if ($data != null ) {
-            $today=Carbon::now()->subDays(15);
             $waybills=Waybill::with(['owner', 'waybillAuditLogs' => function ($query) {
                 return $query->with('user');
             }])->orderBy('id','DESC');
-            if ($request->input('waybill_number')){
-                $waybills =$waybills->where('waybill_number','like','%'.$request->input('waybill_number').'%')->where('created_at','>',$today->format('Y-m-d'));
-            }
-            if ($request->input('carrier_bill')){
-                $waybills=$waybills->where('carrier_bill','like','%'.$request->input('carrier_bill').'%')->where('created_at','>',$today->format('Y-m-d'));
-            }
-            if ($request->input('carrier_id')){
-                $waybills=$waybills->where('carrier_id','=',$request->input('carrier_id'));
-            }
-            if ($request->input('owner_id')){
-                $waybills=$waybills->where('owner_id','=',$request->input('owner_id'));
-            }
-            if ($request->input('wms_bill_number')){
-                $waybills=$waybills->where('wms_bill_number','like','%'.$request->input('wms_bill_number').'%')->where('created_at','>',$today->format('Y-m-d'));
-            }
-            if ($request->input('origination')){
-                $waybills=$waybills->where('origination','like','%'.$request->input('origination').'%')->where('created_at','>',$today->format('Y-m-d'));
-            }
-            if ($request->input('destination')){
-                $waybills=$waybills->where('destination','like','%'.$request->input('destination').'%')->where('created_at','>',$today->format('Y-m-d'));
-            }
-            if ($request->input('created_at_start')){
-                $waybills=$waybills->where('created_at','>',$request->input('created_at_start'));
-            }
-            if ($request->input('created_at_end')){
-                $waybills=$waybills->where('created_at','<',$request->input('created_at_end'));
-            }
-            if ($request->input('status')){
-                $waybills=$waybills->where('status',$request->input('status'));
-            }
-            $waybills=$waybills->paginate($request->input('paginate')?$request->input('paginate'):50);
-            if (!$waybills&&$request->input('waybill_number')){
-                $waybills=Waybill::with(['owner', 'waybillAuditLogs' => function ($query) {
-                    return $query->with('user');
-                }])->orderBy('id','DESC')->where('type','专线')->where('waybill_number',$request->input('waybill_number'))
-                    ->paginate($request->input('paginate')?$request->input('paginate'):50);
-            }
+            $waybills=$this->conditionQuery($request,$waybills);
             $carries = Carrier::get();
             $owners = Owner::get();
             return view('waybill.index', ['waybills' => $waybills, 'carriers' => $carries, 'owners' => $owners,'filterData'=>$data,'uriType'=>'']);
@@ -92,41 +96,10 @@ class WaybillsController extends Controller
         if(!Gate::allows('运输管理-查询')){ return redirect(url('/'));  }
         $data=$request->input();
         if ($data != null ) {
-            $today=Carbon::now()->subDays(15);
             $waybills=Waybill::with(['owner', 'waybillAuditLogs' => function ($query) {
                 return $query->with('user');
             }])->orderBy('id','DESC')->where('type','直发车');
-            if ($request->input('waybill_number')){
-                $waybills =$waybills->where('waybill_number','like','%'.$request->input('waybill_number').'%')->where('created_at','>',$today->format('Y-m-d'));
-            }
-            if ($request->input('carrier_bill')){
-                $waybills=$waybills->where('carrier_bill','like','%'.$request->input('carrier_bill').'%')->where('created_at','>',$today->format('Y-m-d'));
-            }
-            if ($request->input('carrier_id')){
-                $waybills=$waybills->where('carrier_id','=',$request->input('carrier_id'));
-            }
-            if ($request->input('owner_id')){
-                $waybills=$waybills->where('owner_id','=',$request->input('owner_id'));
-            }
-            if ($request->input('wms_bill_number')){
-                $waybills=$waybills->where('wms_bill_number','like','$'.$request->input('wms_bill_number').'%')->where('created_at','>',$today->format('Y-m-d'));
-            }
-            if ($request->input('created_at_start')){
-                $waybills=$waybills->where('created_at','>',$request->input('created_at_start'));
-            }
-            if ($request->input('created_at_end')){
-                $waybills=$waybills->where('created_at','<',$request->input('created_at_end'));
-            }
-            if ($request->input('status')){
-                $waybills=$waybills->where('status',$request->input('status'));
-            }
-            $waybills=$waybills->paginate($request->input('paginate')?$request->input('paginate'):50);
-            if (!$waybills&&$request->input('waybill_number')){
-                $waybills=Waybill::with(['owner', 'waybillAuditLogs' => function ($query) {
-                    return $query->with('user');
-                }])->orderBy('id','DESC')->where('type','专线')->where('waybill_number',$request->input('waybill_number'))
-                    ->paginate($request->input('paginate')?$request->input('paginate'):50);
-            }
+            $waybills=$this->conditionQuery($request,$waybills);
             $carries = Carrier::get();
             $owners = Owner::get();
             return view('waybill.index', ['waybills' => $waybills, 'carriers' => $carries, 'owners' => $owners,'filterData'=>$data,'uriType'=>'ZF']);
@@ -145,41 +118,10 @@ class WaybillsController extends Controller
         if(!Gate::allows('运输管理-查询')){ return redirect(url('/'));  }
         $data=$request->input();
         if ($data != null ) {
-            $today=Carbon::now()->subDays(15);
             $waybills=Waybill::with(['owner', 'waybillAuditLogs' => function ($query) {
                 return $query->with('user');
             }])->orderBy('id','DESC')->where('type','专线');
-            if ($request->input('waybill_number')){
-                $waybills =$waybills->where('waybill_number','like','%'.$request->input('waybill_number').'%')->where('created_at','>',$today->format('Y-m-d'));
-            }
-            if ($request->input('carrier_bill')){
-                $waybills=$waybills->where('carrier_bill','like','%'.$request->input('carrier_bill').'%')->where('created_at','>',$today->format('Y-m-d'));
-            }
-            if ($request->input('carrier_id')){
-                $waybills=$waybills->where('carrier_id','=',$request->input('carrier_id'));
-            }
-            if ($request->input('owner_id')){
-                $waybills=$waybills->where('owner_id','=',$request->input('owner_id'));
-            }
-            if ($request->input('wms_bill_number')){
-                $waybills=$waybills->where('wms_bill_number','like','$'.$request->input('wms_bill_number').'%')->where('created_at','>',$today->format('Y-m-d'));
-            }
-            if ($request->input('created_at_start')){
-                $waybills=$waybills->where('created_at','>',$request->input('created_at_start'));
-            }
-            if ($request->input('created_at_end')){
-                $waybills=$waybills->where('created_at','<',$request->input('created_at_end'));
-            }
-            if ($request->input('status')){
-                $waybills=$waybills->where('status',$request->input('status'));
-            }
-            $waybills=$waybills->paginate($request->input('paginate')?$request->input('paginate'):50);
-            if (!$waybills&&$request->input('waybill_number')){
-                $waybills=Waybill::with(['owner', 'waybillAuditLogs' => function ($query) {
-                    return $query->with('user');
-                }])->orderBy('id','DESC')->where('type','专线')->where('waybill_number',$request->input('waybill_number'))
-                    ->paginate($request->input('paginate')?$request->input('paginate'):50);
-            }
+            $waybills=$this->conditionQuery($request,$waybills);
             $carries = Carrier::get();
             $owners = Owner::get();
             return view('waybill.index', ['waybills' => $waybills, 'carriers' => $carries, 'owners' => $owners,'filterData'=>$data,'uriType'=>'ZX']);

+ 1 - 1
app/Http/Controllers/api/thirdPart/flux/ReceiveController.php

@@ -263,7 +263,7 @@ class ReceiveController extends Controller
     }
     /**
      * 入库回传给WMS
-     * @param RejectedBill $rejectedBill
+     * @param Store $store
      * @return bool
      */
     static public function accomplishStoreToWMS(Store $store)

+ 4 - 23
app/Http/Controllers/api/thirdPart/weight/PackageController.php

@@ -67,6 +67,7 @@ class PackageController extends Controller
         }
         if ($package){
             $packagePaperBox=new Package();
+            $paperBox_id=null;
             if ($package->owner_id){
                 $paperBox_id=$packagePaperBox->checkPaperBox($max,$centre,$min,$package->owner_id);
                 if (!$paperBox_id)$this->log(__METHOD__,'weightApi(no paper box)'.__FUNCTION__,json_encode($request),null);
@@ -74,30 +75,10 @@ class PackageController extends Controller
                 $this->log(__METHOD__,'weightApi(no owner)'.__FUNCTION__,json_encode($request),null);
             }
             $accomplishToWMS=new \App\Http\Controllers\Api\thirdPart\flux\PackageController();
-
+            $packageController=new \App\Http\Controllers\PackageController();
             //处理活动波次
             if ($package->batch_rule&&strstr($package->batch_rule,'组合')){
-                $packagesBatch=Package::where('batch_number',$package->batch_number)->get();
-                foreach ($packagesBatch as $packageBatch){
-                    $packageBatch->measuring_machine_id=$measuringMachine->id;
-                    $packageBatch->weight=$request['weight'];
-                    $packageBatch->length=$max;
-                    $packageBatch->width=$centre;
-                    $packageBatch->height=$min;
-                    $packageBatch->bulk=$max*$centre*$min;
-                    $packageBatch->weighed_at=$reqDate;
-                    if (isset($paperBox_id))$packageBatch->paper_box_id=$paperBox_id;
-                    $packageBatch->status="未上传";
-                    $packageBatch->save();
-                    $result=$accomplishToWMS->accomplishToWMS($packageBatch);
-                    if ($result['result']=='success'){
-                        if ($package->status=="记录异常")$package->status="已上传异常";
-                        else $package->status="已上传";
-                    }else{
-                        $packageBatch->status="上传异常";
-                    }
-                    $packageBatch->save();
-                }
+                $packageController->syncBatch($package->batch_number,$request['weight'],$max,$centre,$min,$reqDate,$paperBox_id);
             }else{
                 $package->measuring_machine_id=$measuringMachine->id;
                 $package->weight=$request['weight'];
@@ -106,7 +87,7 @@ class PackageController extends Controller
                 $package->height=$min;
                 $package->bulk=$max*$centre*$min;
                 $package->weighed_at=$reqDate;
-                if (isset($paperBox_id))$package->paper_box_id=$paperBox_id;
+                if ($paperBox_id)$package->paper_box_id=$paperBox_id;
                 $package->status="未上传";
                 $this->log(__METHOD__,'Batch_'.__FUNCTION__,json_encode($package),null);
                 $package->save();

+ 29 - 0
app/Store.php

@@ -8,4 +8,33 @@ use Illuminate\Database\Eloquent\SoftDeletes;
 class Store extends Model
 {
     use SoftDeletes;
+
+    protected $fillable=[
+        'asn_code','warehouse_id','owner_id','stored_method','status','remark','deleted_at'
+    ];
+
+    protected $appends=[
+        'owner_name','warehouse_name'
+    ];
+
+    public function owner(){
+        return $this->belongsTo('App\Owner','owner_id','id');
+    }
+
+    public function warehouse(){
+        return $this->belongsTo('App\Warehouse','warehouse_id','id');
+    }
+    public function storeItems(){
+        return $this->hasMany('App\StoreItems','store_id','id');
+}
+
+    public function getOwnerNameAttribute()
+    {
+        return $this['owner']? $this['owner']['name']:null;
+    }
+
+    public function getWarehouseNameAttribute()
+    {
+        return $this['warehouse']?$this['warehouse']['name']:null;
+    }
 }

+ 0 - 1
database/migrations/2020_03_09_153510_create_stores_table.php

@@ -15,7 +15,6 @@ class CreateStoresTable extends Migration
     {
         Schema::create('stores', function (Blueprint $table) {
             $table->bigIncrements('id');
-            $table->bigInteger('id_owner')->index();
             $table->string('asn_code')->nullable()->unique()->comment('WMS的ASNNO单号');
             $table->integer('warehouse_id')->nullable()->comment('仓库ID');
             $table->integer('owner_id')->index()->nullable()->comment('货主ID');

+ 1 - 0
database/migrations/2020_03_09_172120_create_store_items_table.php

@@ -15,6 +15,7 @@ class CreateStoreItemsTable extends Migration
     {
         Schema::create('store_items', function (Blueprint $table) {
             $table->bigIncrements('id');
+            $table->bigInteger('store_id')->index()->comment('外键入库表');
             $table->string('asn_line_code')->nullable()->unique()->comment('来自WMS的ASN行号,唯一');
             $table->string('name')->nullable();
             $table->string('sku')->nullable()->index();

+ 50 - 0
resources/views/store/fast/create.blade.php

@@ -0,0 +1,50 @@
+@extends('layouts.app')
+@section('title')手动录入@endsection
+
+@section('content')
+    <div id="nav2">
+        @component('store.menu')@endcomponent
+        @component('store.fast.menuFast')@endcomponent
+    </div>
+    <div class="container-fluid mt-3" id="fast">
+        <div class="card col-md-8 offset-md-2">
+            <div class="card-body">
+                <form method="POST" action="{{ url('store/fast') }}">
+                    @if(Session::has('successError'))
+                        <div class="alert alert-danger h1">{{Session::get('successError')}}</div>
+                    @endif
+                    @csrf
+                    <div class="resource" v-for="num in sum">
+
+                        <div class="form-group row">
+                            <label for="asn_code" class="col-2 col-form-label text-right">ASN编号</label>
+                            <div class="col-8">
+                                <input type="text" class="form-control @error('asn_code') is-invalid @enderror"
+                                       name="asn_code" autocomplete="off" value="{{ old('asn_code')}}">
+                                @error('asn_code')
+                                <span class="invalid-feedback" role="alert">
+                                        <strong>{{ $errors->first('asn_code') }}</strong>
+                                </span>
+                                @enderror
+                            </div>
+                        </div>
+                        <div class="form-group row">
+                            <label for="quality" class="col-2 col-form-label text-right">货物类型</label>
+                            <div class="col-8 form-inline">
+                                <select name="quality" class="form-control @error('quality') is-invalid @enderror"  style="width: 30%;">
+                                    <option value="正品">正品</option>
+                                    <option value="残次">残次</option>
+                                </select>
+                            </div>
+                        </div>
+                    </div>
+                    <div class="form-group row">
+                        <div class="col-8 offset-2">
+                            <input type="submit" class="btn btn-success form-control">
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+@endsection

+ 149 - 0
resources/views/store/fast/index.blade.php

@@ -0,0 +1,149 @@
+@extends('layouts.app')
+@section('title')称重管理@endsection
+
+@section('content')
+    <span id="nav2">
+        @component('store.menu')@endcomponent
+        @component('store.fast.menuFast')@endcomponent
+    </span>
+    <div class="d-none" id="fast">
+        <div class="container-fluid mt-3">
+            <div class="">
+                <div>
+ {{--                   <form  method="GET" action="{{url('store/')}}" style="margin-top: 1%" id="optionSubmit">
+                        <table class="table  table-sm table-bordered text-nowrap ">
+                            <tr v-if="isBeingFilterConditions">
+                                <td colspan="10"><div class="col" style="padding:0">
+                                        <a  href="{{url('store')}}"><span class="btn btn-warning text-dark">清除过滤条件</span></a>
+                                    </div></td>
+                            </tr>
+                            <tr>
+                                <td>
+                                    <span class="text-muted">每页显示记录:</span>
+                                </td>
+                                <td  colspan="9">
+                                    <select name="paginate" v-model="filterData.paginate" class="tooltipTarget form-control-sm" style="vertical-align: middle" @change="setPaginate">
+                                        <option value="50">50行</option>
+                                        <option value="100">100行</option>
+                                        <option value="200">200行</option>
+                                        <option value="500">500行</option>
+                                        <option value="1000">1000行</option>
+                                    </select></td>
+                            </tr>
+                            <tr>
+                                <td rowspan="2">
+                                    <span class="text-muted">根据条件过滤:</span>
+                                </td>
+                                <td >
+                                    <label class="form-inline" style="width: 350px">时间:
+                                        <input style="width: 150px" name="created_at_start" type="date" v-model="filterData.created_at_start" class="form-control-sm">
+                                        <input style="width: 150px" type="date" name="created_at_end" v-model="filterData.created_at_end" class="form-control-sm">
+                                    </label>
+                                </td>
+                                --}}{{--<td > <label class="form-inline" style="width:200px;margin-left: 2%">货主:
+                                        <input class="form-control-sm" style="width: 80px" placeholder="搜索定位" @input="owner_seek">&nbsp;&nbsp;&nbsp;
+                                        <select name="owner_id" v-model="filterData.owner_id" class="form-control-sm"  @change="setOwner">
+                                            <option >    </option>
+                                            @foreach($owners as $owner)
+                                                <option value="{{$owner->id}}">{{$owner->name}}</option>
+                                            @endforeach
+                                        </select></label><input hidden type="submit" value="kk"></td>--}}{{--
+                                <td>
+                                    <label for="">客户:</label>
+                                    <input type="text" class="form-control-sm tooltipTarget" placeholder="查找"
+                                           style="width:70px" @input="owner_seek"
+                                           title="输入关键词快速定位下拉列表,回车确定">
+                                    <select name="owner_id" v-model="filterData.owner_id" @change="setOwner" class="form-control-sm tooltipTarget">
+                                        <option >    </option>
+                                        @foreach($owners as $owner)
+                                            <option value="{{$owner->id}}">{{$owner->name}}</option>
+                                        @endforeach
+                                    </select>
+                                    <input hidden type="submit" value="kk">
+                                </td>
+                                <td > <label class="form-inline" style="width:250px;margin-left: 2%">快递单号:
+                                        <input type="text" name="logistic_number" class="form-control-sm  " v-model="filterData.logistic_number" style="vertical-align: middle"></label></td>
+                                <td > <label  class="form-inline" style="width:250px;margin-left: 2%">发货单号:
+                                        <input type="text" name="delivery_number" class="form-control-sm  " v-model="filterData.delivery_number" style="vertical-align: middle"></label></td>
+                                <td colspan="5"></td>
+                            </tr>
+                            <tr>
+                                <td > <label class="form-inline" >波次号:
+                                        <input type="text" name="batch_number" class="form-control-sm  " v-model="filterData.batch_number" style="vertical-align: middle"></label></td>
+                            </tr>
+                            <tr>
+                                <td>
+                                    <span class="text-muted">操作选定记录:</span>
+                                </td>
+                                <td colspan="9">
+                                    <select @change="storeExport($event)" :class="[checkData>0?'btn-dark':'btn-outline-dark']"  class=" tooltipTarget form-control-sm" style=" vertical-align: middle"
+                                             title="导出所有页将会以搜索条件得到的过滤结果,将其全部记录(每一页)导出">
+                                        <option >导出Excel</option>
+                                        <option value="1">导出勾选内容</option>
+                                        <option value="2">导出所有页</option>
+                                    </select>
+                                    <input hidden type="submit" value="kk">
+                                </td>
+                            </tr>
+                        </table>
+                    </form>--}}
+                </div>
+            <div class="">
+                <table class="table table-striped table-sm text-nowrap table-hover">
+                    <tr>
+                        {{--<th>
+                            <label for="all">
+                                <input id="all" type="checkbox" @click="checkAll($event)">全选
+                            </label>
+                        </th>--}}
+                        <th>序号</th>
+                        <th>ID</th>
+                        <th>ASN编号</th>
+                        <th>仓库</th>
+                        <th>货主</th>
+                        <th>入库类型</th>
+                        <th>状态</th>
+                        <th>备注</th>
+                        <th>生成时间</th>
+                    </tr>
+                    <tr v-for="(store,i) in stores">
+                        {{--<td>
+                            <input class="checkItem" type="checkbox" :value="store.id" v-model="checkData">
+                        </td>--}}
+                        <td>@{{ i+1  }}</td>
+                        <td class="text-muted">@{{store.id}}</td>
+                        <td>@{{store.asn_code}}</td>
+                        <td>@{{store.warehouse_name}}</td>
+                        <td class="text-muted">@{{store.owner_name}}</td>
+                        <td class="text-muted">@{{store.stored_method}}</td>
+                        <td class="text-muted">@{{store.status}}</td>
+                        <td>@{{store.remark}}</td>
+                        <td class="text-muted">@{{store.created_at}}</td>
+                    </tr>
+                </table>
+                {{$stores->links()}}
+            </div>
+        </div>
+    </div>
+    </div>
+@endsection
+
+@section('lastScript')
+    <script>
+        new Vue({
+            el:'#fast',
+            data:{
+                stores:[
+                @foreach($stores as $store)
+                {!! $store !!},
+                @endforeach
+                ],
+            },
+            mounted:function(){
+                /*this.initInputs();
+                $(".tooltipTarget").tooltip({'trigger':'hover'});*/
+                $('#fast').removeClass('d-none');
+            },
+        });
+    </script>
+@endsection

+ 16 - 0
resources/views/store/fast/menuFast.blade.php

@@ -0,0 +1,16 @@
+<div id="nav2">
+    <div class="container-fluid">
+        <div class="card menu-third" style="background: #f9f0f0;transform: scale(0.95)">
+            <ul class="nav nav-pills">
+                @can('测量设备')
+                    <li class="nav-item">
+                        <a class="nav-link text-dark" href="{{url('store/fast')}}" :class="{active:isActive('',3)}">记录</a>
+                    </li> @endcan
+                @can('纸箱')
+                    <li class="nav-item">
+                        <a class="nav-link text-dark" href="{{url('store/fast/create')}}" :class="{active:isActive('create',3)}">录入</a>
+                    </li> @endcan
+            </ul>
+        </div>
+    </div>
+</div>

+ 1 - 1
resources/views/store/menu.blade.php

@@ -4,7 +4,7 @@
         <ul class="nav nav-pills">
             @can('入库管理-快速入库')
                 <li class="nav-item">
-                    <a class="nav-link" href="{{url('store/fast')}}" :class="{active:isActive('',2)}">快速入库</a>
+                    <a class="nav-link" href="{{url('store/fast')}}" :class="{active:isActive('fast',2)}">快速入库</a>
                 </li> @endcan
         </ul>
     </div>

+ 46 - 9
resources/views/weight/package/create.blade.php

@@ -13,16 +13,41 @@
                     @if(Session::has('successTip'))
                         <div class="alert alert-success h1">{{Session::get('successTip')}}</div>
                     @endif
-                    <div class="form-group row">
-                        <label for="name" class="col-2 col-form-label text-right">快递单号</label>
-                        <div class="col-8">
-                            <input type="text" class="form-control @error('logistic_number') is-invalid @enderror"
-                                   name="logistic_number" autocomplete="off" value="{{ old('logistic_number')}}" required>
-                            @error('logistic_number')
-                            <span class="invalid-feedback" role="alert">
+                    @if(Session::has('successError'))
+                        <div class="alert alert-danger h1">{{Session::get('successError')}}</div>
+                    @endif
+                    <div class="">
+                        <ul class="nav nav-tabs" >
+                            <li :class="windowStatus.logistic_input ? selectClass : notSelectClass" style="margin-left: 20%" @click="windowSwitchLogistic">快递单号</li>
+                            <li :class="windowStatus.batch_input ? selectClass : notSelectClass" style="margin-left: 20%"  @click="windowSwitchBatch">波次号</li>
+                        </ul>
+                        <div class="" v-if="windowStatus.logistic_input">
+                            <div class="form-group row">
+                                <label for="name" class="col-2 col-form-label text-right">快递单号</label>
+                                <div class="col-8">
+                                    <input type="text" class="form-control @error('logistic_number') is-invalid @enderror"
+                                           name="logistic_number" autocomplete="off" value="{{ old('logistic_number')}}">
+                                    @error('logistic_number')
+                                    <span class="invalid-feedback" role="alert">
                                     <strong>{{ $errors->first('logistic_number') }}</strong>
                             </span>
-                            @enderror
+                                    @enderror
+                                </div>
+                            </div>
+                        </div>
+                        <div class="text-primary" v-if="windowStatus.batch_input">
+                            <div class="form-group row">
+                                <label for="batch_number" class="col-2 col-form-label text-right">波次号</label>
+                                <div class="col-8">
+                                    <input type="text" class="form-control @error('batch_number') is-invalid @enderror"
+                                           name="batch_number" autocomplete="off" value="{{ old('batch_number')}}">
+                                    @error('batch_number')
+                                    <span class="invalid-feedback" role="alert">
+                                    <strong>{{ $errors->first('batch_number') }}</strong>
+                            </span>
+                                    @enderror
+                                </div>
+                            </div>
                         </div>
                     </div>
                     <div class="form-group row">
@@ -62,11 +87,14 @@
             el:"#package",
             data:{
                 paperBoxes:[
-                    @foreach($paperBoxes as $paperBox)
+                        @foreach($paperBoxes as $paperBox)
                     {id:'{{$paperBox->id}}',model:'{{$paperBox->model}}'},
                     @endforeach
                 ],
                 paperBox_id:'',
+                windowStatus:{logistic_input:true, batch_input:false},
+                selectClass:'nav-item btn btn-secondary',
+                notSelectClass:'nav-item btn btn-outline-secondary'
             },
             methods:{
                 paperBox_seek:function (e) {
@@ -80,6 +108,15 @@
                             }
                         });
                 },
+                windowSwitchLogistic:function (e) {
+                    this.windowStatus.logistic_input=true;
+                    this.windowStatus.batch_input=false;
+                },
+                windowSwitchBatch:function (e) {
+                    this.windowStatus.logistic_input=false;
+                    this.windowStatus.batch_input=true;
+                },
+
             },
         });
     </script>

+ 2 - 0
routes/web.php

@@ -99,3 +99,5 @@ Route::get('package/weightExcepted/indexIssued','WeighExceptedController@indexIs
 Route::get('package/weightExcepted/export/{id}','WeighExceptedController@export');
 Route::resource('package','PackageController');
 
+Route::resource('store/fast','StoreController');
+