Jelajahi Sumber

库存体积统计功能开发
订单管理-条码搜索BUG修复

Zhouzhendong 5 tahun lalu
induk
melakukan
d2c4107a4c

+ 1 - 3
app/Commodity.php

@@ -9,7 +9,7 @@ use App\Traits\ModelTimeFormat;
 class Commodity extends Model
 {
     use ModelTimeFormat;
-    protected $fillable=['name','sku','owner_id','created_at'];
+    protected $fillable=['name','sku','owner_id','created_at','length','width','height','volumn'];
     protected $appends=['barcode','owner_name','owner_code'];
 
     public function barcodes()
@@ -20,7 +20,6 @@ class Commodity extends Model
         return $this->belongsTo('App\Owner','owner_id','id');
     }
     public function getBarcodeAttribute(){
-//        return $this->barcodes()->first()['code'];
         return $this->barcodes[0]['code']??'';
     }
     public function getOwnerNameAttribute(){
@@ -64,7 +63,6 @@ class Commodity extends Model
         }
         foreach ($barcodes as $barcode){
             if(!trim($barcode))continue;
-//            if(preg_match('/[\x{4e00}-\x{9fa5}]/u',$barcode))continue;
             $commodityBarcode=CommodityBarcode::where('code',$barcode)->where('commodity_id',$commodity['id'])->first();
             if(!$commodityBarcode){
                 $commodityBarcode=new CommodityBarcode(['code'=>$barcode,'commodity_id'=>$commodity['id']]);

+ 135 - 0
app/Console/Commands/InventoryDailyLoggingOwner.php

@@ -0,0 +1,135 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\CommodityBarcode;
+use App\Services\CommodityService;
+use Illuminate\Console\Command;
+use App\InventoryDailyLoggingOwner as LoggingOwner;
+use Illuminate\Support\Facades\DB;
+
+class InventoryDailyLoggingOwner extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'InventoryDailyLoggingOwner';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = '监听指定货主记录';
+
+    /**
+     * Create a new command instance.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+    /**
+     * Execute the console command.
+     * @param CommodityService $commodityService
+     * @return int
+     */
+    public function handle(CommodityService $commodityService)
+    {
+        //获取需要查询的货主,键值对:code => id
+        $owners = $this->getLoggingOwners();
+        //计算数量,为0直接return
+        $let = count($owners);
+        if ($let == 0)return;
+        //拼接SQL,SELECT仅取指定字段
+        $sql = "SELECT INV_LOT.customerid,INV_LOT.sku,INV_LOT.qty,BAS_SKU.skulength,
+                BAS_SKU.skuwidth,BAS_SKU.skuhigh,BAS_SKU.cube,BAS_SKU.descr_c,BAS_SKU.alternate_sku1 
+                FROM INV_LOT
+                LEFT JOIN BAS_SKU ON INV_LOT.sku = BAS_SKU.sku AND INV_LOT.customerid = BAS_SKU.customerid
+                WHERE INV_LOT.customerid IN (";
+        $index = 1;
+        foreach ($owners as $code => $id){
+            $sql .= "'".$code."'";
+            if ($index != $let)$sql .= ",";
+            $index++;
+        }
+        $sql .= ")";
+        //执行获取结果:stdClass类型
+        $invLots = DB::connection('oracle')->select(DB::raw($sql));
+        //声明一个数组,作为第一次去重的容器
+        $inventoryDailyLogs = [];
+        foreach ($invLots as $invLot){
+            //以MAP形式记录进数组,货主code与商品sku作为联合主键唯一标识,如重复叠加其数量
+            if ($inventoryDailyLogs[$owners[$invLot->customerid].'-'.$invLot->sku] ?? false){
+                $inventoryDailyLogs[$owners[$invLot->customerid].'-'.$invLot->sku]['amount'] += $invLot->qty;
+            }else{
+                //符合的结果取此对象的关键信息存进第一个数组
+                $inventoryDailyLogs[$owners[$invLot->customerid].'-'.$invLot->sku] = [
+                    'commodity' => [
+                        'owner_id'=>$owners[$invLot->customerid],
+                        'sku'=>$invLot->sku,
+                        'name'=>$invLot->descr_c,
+                        'length'=>$invLot->skulength,
+                        'width'=>$invLot->skuwidth,
+                        'height'=>$invLot->skuhigh,
+                        'volumn'=>$invLot->cube,
+                        'code'=>$invLot->alternate_sku1,
+                    ],
+                    'amount' => $invLot->qty,
+                    'volumn_occupied' => 0,
+                ];
+            }
+        }
+        //第二个数组作为批量插入使用
+        $data = [];
+        //遍历第一个数组,此时已经去重完成,直接取对应参数push进data中
+        foreach ($inventoryDailyLogs as $inventoryDailyLog){
+            //寻找己方库中是否存在对应商品,存在更新其长宽高体积,不存在录入
+            $commodity = $inventoryDailyLog['commodity'];
+            $param = ['owner_id'=>$commodity['owner_id'],'sku'=>$commodity["sku"]];
+            //体积存在为0的情况,需再次计算一次,此处体积为m³
+            if (!$commodity['volumn'] || $commodity['volumn'] == "0"){
+                $commodity['volumn'] = $commodity['length']*$commodity['width']*$commodity['height'];
+            }
+            $column = [
+                'owner_id'=>$commodity['owner_id'],
+                'sku'=>$commodity['sku'],
+                'name'=>$commodity['name'],
+                'length'=>$commodity['length'],
+                'width'=>$commodity['width'],
+                'height'=>$commodity['height'],
+                'volumn'=>$commodity['volumn'],
+            ];
+            $result = $commodityService->updateOrCreate($param,$column);
+            $commodity_id = $result->id;
+            //寻找对应barcode是否存在,不存在录入
+            if ($commodity['code']) CommodityBarcode::query()->firstOrCreate(['commodity_id'=>$commodity_id,'code'=>$commodity['code']]);
+            //计算总体积,商品体积×该单数量
+            $volumn_occupied = $commodity['volumn']*$inventoryDailyLog["amount"];
+            array_push($data,[
+                "owner_id"=>$commodity['owner_id'],
+                "created_at"=>date('Y-m-d H:i:s'),
+                "commodity_id"=>$commodity_id,
+                "amount"=>$inventoryDailyLog['amount'],
+                "volumn_occupied"=>$volumn_occupied,
+            ]);
+        }
+        DB::table('inventory_daily_logs')->insert($data);
+    }
+
+    public function getLoggingOwners(){
+        $loggingOwners = LoggingOwner::with('owner')->select('id','owner_id')->where('status','启用')->get();
+        $owners = [];
+        foreach ($loggingOwners as $loggingOwner){
+            if ($loggingOwner->owner){
+                $owners[$loggingOwner->owner->code] = $loggingOwner->owner_id;
+            }
+        }
+        return $owners;
+    }
+}

+ 1 - 0
app/Console/Kernel.php

@@ -29,6 +29,7 @@ class Kernel extends ConsoleKernel
     protected function schedule(Schedule $schedule)
     {
         $schedule->command('LogExpireDelete')->dailyAt('00:01');
+        $schedule->command('InventoryDailyLoggingOwner')->dailyAt('08:00');
         $schedule->command('FluxOrderFix')->hourlyAt(1);
     }
 

+ 28 - 9
app/Http/Controllers/InventoryController.php

@@ -4,10 +4,12 @@ namespace App\Http\Controllers;
 
 use App\Exports\Export;
 use App\Inventory;
+use App\InventoryDailyLoggingOwner;
 use App\InventoryMission;
 use App\OracleBasCustomer;
 use App\Owner;
 use App\Services\InventoryService;
+use App\Services\OwnerService;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Gate;
@@ -197,15 +199,6 @@ class InventoryController extends Controller
         return ['success'=>true,'inventoryMission'=>$inventoryMission,'inventory'=>$inventory];
     }
 
-
-
-
-
-
-
-
-
-
     //盘点任务导出
     public function stockInventoryExport(Request $request){
         if (!Gate::allows('库存管理-盘点')){return redirect(url('/')); }
@@ -250,4 +243,30 @@ class InventoryController extends Controller
         }
         return Excel::download(new Export($row,$list),date('YmdHis', time()).'-盘点任务记录单.xlsx');
     }
+
+    /*
+     *  库存体积
+     */
+    function dailyLog(Request $request,OwnerService $ownerService){
+        if (!Gate::allows('库存管理-库存体积')){return redirect(url('/')); }
+        $inventoryDailyLogs = app('inventoryService')->getInventoryDailyLog($request->input());
+        $owners = $ownerService->getSelection();
+        $param = $request->input();
+        return view('inventory.statement.dailyLog',compact('inventoryDailyLogs','owners','param'));
+    }
+
+    //获取记录监听货主
+    function getLoggingOwner(){
+        $loggingOwners = app('inventoryService')->getInventoryDailyLoggingOwner('owner_id');
+        return array_column($loggingOwners->toArray(),'owner_id');
+    }
+    //添加记录监听货主
+    function addLoggingOwner(Request $request){
+        if (!Gate::allows('库存管理-库存体积-管理监听货主')){return redirect(url('/')); }
+        $owner_id = $request->owner_id;
+        if (!$owner_id || !is_numeric($owner_id))return ['success'=>false,'data'=>'传递参数错误!'];
+        $loggingOwner = app('inventoryService')->firstOrCreate(['owner_id'=>$owner_id]);
+        if (!$loggingOwner)return ['success'=>false,'data'=>'录入失败!'];
+        return ['success'=>true,'data'=>$loggingOwner->owner_id];
+    }
 }

+ 33 - 3
app/Http/Controllers/OrderController.php

@@ -11,7 +11,6 @@ use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Auth;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Gate;
-use Illuminate\Support\Facades\Http;
 use Maatwebsite\Excel\Facades\Excel;
 
 class OrderController extends Controller
@@ -30,8 +29,26 @@ class OrderController extends Controller
         $notes=$request->input('notes');
         $addtime=$request->input('addtime');
         $waveno=$request->input('waveno');
+        $alternate_sku1=$request->input('alternate_sku1');
         $edisendflag2=$request->edisendflag2;
         $edisendflag=$request->edisendflag;
+        if ($alternate_sku1){
+            if ($request->checkAllSign) $detailsOrderno = $this->getOrdersNo($alternate_sku1,false);
+            else $detailsOrderno = $this->getOrdersNo($alternate_sku1,true, $request->page ?? 1, $request->paginate ?? 50);
+            if (count($detailsOrderno)>0){
+                $sql.=' AND orderno IN (';
+                foreach ($detailsOrderno as $index => $no){
+                    if ($index==0){
+                        $sql.="'".$no."'";
+                        continue;
+                    }
+                    $sql.=",'".$no."'";
+                }
+                $sql.=')';
+            }else{
+                $sql .= 'AND orderno IS NULL ';
+            }
+        }
         if ($orderdate_start && $orderdate_end && $addtime){
             $request->offsetUnset('orderdate_start');$request->offsetUnset('orderdate_end');
             $orderdate_start=null;
@@ -130,7 +147,6 @@ class OrderController extends Controller
         $paginate=$request->input('paginate')??50;
         $page=$request->input('page')??1;
         $checkData=$request->input('data');
-        $alternate_sku1=$request->input('alternate_sku1');
         $export=$request->input('checkAllSign');
         $sql="select ACT_ALLOCATION_DETAILS.picktotraceid,ACT_ALLOCATION_DETAILS.CHECKTIME,DOC_ORDER_HEADER.addtime,DOC_ORDER_HEADER.C_PROVINCE,DOC_ORDER_HEADER.C_CITY,DOC_ORDER_HEADER.C_DISTRICT,DOC_ORDER_HEADER.C_CONTACT,DOC_ORDER_HEADER.OrderNo,DOC_ORDER_HEADER.SOStatus,DOC_ORDER_HEADER.WAREHOUSEID,DOC_ORDER_HEADER.CustomerID
         ,DOC_ORDER_HEADER.C_Tel2,DOC_ORDER_HEADER.CarrierName,DOC_ORDER_HEADER.IssuePartyName,DOC_ORDER_HEADER.EDIREMARKS2,
@@ -174,7 +190,6 @@ class OrderController extends Controller
                       left join  BAS_SKU on DOC_Order_Details.CustomerID=BAS_SKU.CustomerID and DOC_Order_Details.SKU=BAS_SKU.SKU
                       left join ACT_ALLOCATION_DETAILS on DOC_Order_Details.orderno=ACT_ALLOCATION_DETAILS.orderno and
                       DOC_Order_Details.orderlineno=ACT_ALLOCATION_DETAILS.orderlineno";
-        if ($alternate_sku1)$sql.=" where BAS_SKU.Alternate_SKU1 like '".$alternate_sku1."%'";
         $orders=DB::connection('oracle')->select(DB::raw($sql));
         $commodities=[];
         $picktotraceids=[];
@@ -210,6 +225,21 @@ class OrderController extends Controller
         $codes=DB::connection('oracle')->table('BAS_CODES')->select('code','codename_c')->where('codeid','SO_STS')->orderBy('code','asc')->get();
         return view('order/index/delivering',compact('orders','customers','request','codes','commodities','page','picktotraceids'));
     }
+    //通过商品条码获取订单编号
+    public function getOrdersNo($alternate_sku1, $isPaging = true, $page = 1, $paginate = 50){
+        if ($isPaging){
+            $sql = "SELECT RESULT.ORDERNO FROM 
+                        (SELECT ROWNUM rn,DETAIL.ORDERNO as ORDERNO FROM
+                            (SELECT ORDERNO FROM DOC_ORDER_DETAILS WHERE SKU LIKE '".$alternate_sku1."' GROUP BY ORDERNO ORDER BY ORDERNO DESC)DETAIL
+                        WHERE ROWNUM<='".$page*$paginate."')RESULT 
+                    WHERE RESULT.rn>'".($page-1)*$paginate."'";
+        }else {
+            $sql = "SELECT ORDERNO FROM DOC_ORDER_DETAILS WHERE SKU LIKE '".$alternate_sku1."' GROUP BY ORDERNO ORDER BY ORDERNO DESC";
+        }
+        $orderDetails = DB::connection('oracle')->select(DB::raw($sql));
+        return array_column($orderDetails,'orderno');
+    }
+
     //批量备注追加
     public function batchComments(Request $request){
         if(!Gate::allows('订单管理-批量备注')){ return redirect(url('/'));  }

+ 4 - 0
app/Http/Controllers/TestController.php

@@ -272,6 +272,10 @@ class TestController extends Controller
     /*1*/
     function test(Request $request)
     {/**/
+        $a = new OrderController();
+        $alternate_sku1 = '8003340090276';
+        dd($a -> getOrdersNo($alternate_sku1));
+
         $units=ProcessesContent::with('signCommodity')->get();
         foreach ($units as $unit){
             if ($unit->sign_commodity_name_mark)dd($unit->sign_commodity_name_mark);

+ 20 - 0
app/InventoryDailyLog.php

@@ -0,0 +1,20 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class InventoryDailyLog extends Model
+{
+    public $timestamps=false;
+    protected $fillable=[
+        'owner_id','created_at','commodity_id','amount','volumn_occupied'
+    ];
+
+    public function owner(){
+        return $this->hasOne('App\Owner','id','owner_id')->select('id','name');
+    }
+    public function commodity(){
+        return $this->hasOne('App\Commodity','id','commodity_id');
+    }
+}

+ 16 - 0
app/InventoryDailyLoggingOwner.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class InventoryDailyLoggingOwner extends Model
+{
+    protected $fillable=[
+        "owner_id","status"
+    ];
+
+    public function owner(){
+        return $this->hasOne('App\Owner','id','owner_id');
+    }
+}

+ 18 - 0
app/Services/CommodityService.php

@@ -0,0 +1,18 @@
+<?php 
+
+namespace App\Services; 
+
+use App\Commodity;
+
+Class CommodityService
+{ 
+    public function firstOrCreate($param,$column = null){
+        if ($column) return Commodity::query()->firstOrCreate($param,$column);
+        return Commodity::query()->firstOrCreate($param);
+    }
+    public function updateOrCreate($param,$column = null){
+        if ($column) return Commodity::query()->updateOrCreate($param,$column);
+        return Commodity::query()->updateOrCreate($param);
+    }
+
+}

+ 35 - 1
app/Services/InventoryService.php

@@ -6,6 +6,8 @@ namespace App\Services;
 use App\Commodity;
 use App\Http\Controllers\Controller;
 use App\Inventory;
+use App\inventoryDailyLog;
+use App\InventoryDailyLoggingOwner;
 use App\InventoryMission;
 use App\OraccleBasCustomer;
 use App\OracleActTransactionLog;
@@ -26,7 +28,7 @@ class InventoryService
             'date_start' => ['alias' => 'created_at' , 'startDate' => ' 00:00:00'],
             'date_end' => ['alias' => 'created_at' , 'endDate' => ' 23:59:59'],
         ];
-        $inventories = app(QueryService::class)->query($request,$inventories,$columnQueryRules);
+        $inventories = app(QueryService::class)->query($request->input(),$inventories,$columnQueryRules);
         return $inventories;
     }
     public function paginate(Request $request){
@@ -192,5 +194,37 @@ class InventoryService
         return $inventory;
     }
 
+    //库存体积条件
+    function conditionQueryDailyLog(array $param){
+        $inventoryDailyLogs = InventoryDailyLog::query()->with(['owner','commodity'=>function($query){
+            $query->with('barcodes');
+        }])->orderByDesc('id');
+        $columnQueryRules=[
+            'owner_id' => ['multi' => ','],
+            'created_at_start' => ['alias' => 'created_at' , 'startDate' => ' 00:00:00'],
+            'created_at_end' => ['alias' => 'created_at' , 'endDate' => ' 23:59:59'],
+        ];
+        $inventoryDailyLogs = app(QueryService::class)->query($param,$inventoryDailyLogs,$columnQueryRules);
+        return $inventoryDailyLogs;
 
+    }
+
+    //库存体积
+    public function getInventoryDailyLog(array $param){
+        return $this->conditionQueryDailyLog($param)->paginate($param['paginate'] ?? 50);
+    }
+
+    //获取开启监听记录货主
+    public function getInventoryDailyLoggingOwner($column = ['id','owner_id'], $status = "启用"){
+        if (!is_array($column)) {
+            $column = [$column];
+        }
+        return InventoryDailyLoggingOwner::query()->select($column)->where('status',$status)->get();
+    }
+
+    //录入监听记录货主
+    public function firstOrCreate($param,$column = null){
+        if ($column)return InventoryDailyLoggingOwner::query()->firstOrCreate($param,$column);
+        return InventoryDailyLoggingOwner::query()->firstOrCreate($param);
+    }
 }

+ 1 - 1
app/Services/LaborReportService.php

@@ -43,7 +43,7 @@ class LaborReportService
             'created_at_end' => ['alias' => 'created_at' , 'endDate' => ' 23:59:59'],
             'identity_number' => ['timeLimit' => 15]
         ];
-        $laborReports = app(QueryService::class)->query($request,$laborReports,$columnQueryRules);
+        $laborReports = app(QueryService::class)->query($request->input(),$laborReports,$columnQueryRules);
         if(Gate::allows('人事管理-临时工报表-可见全部组')||Gate::allows('人事管理-门卫审核')){
             $laborReports->orWhereNull('user_workgroup_id');
         }

+ 1 - 1
app/Services/PackageService.php

@@ -17,7 +17,7 @@ Class PackageService
             'created_at_start' => ['alias' => 'created_at','startDate' => " 00:00:00"],
             'created_at_end' => ['alias' => 'created_at','endDate' => " 23:59:59"],
         ];
-        $packages = app(QueryService::class)->query($request,$packages,$columnQueryRules);
+        $packages = app(QueryService::class)->query($request->input(),$packages,$columnQueryRules);
         return $packages;
     }
 

+ 1 - 1
app/Services/ProcessService.php

@@ -43,7 +43,7 @@ Class ProcessService
             'code' => ['like' => ''],
             'owner_id' => ['multi' => ','],
         ];
-        $processes = app(QueryService::class)->query($request,$processes,$columnQueryRules);
+        $processes = app(QueryService::class)->query($request->input(),$processes,$columnQueryRules);
         return $processes;
     }
 

+ 1 - 1
app/Services/RejectedService.php

@@ -77,7 +77,7 @@ class RejectedService
                 $columnQueryRules['logistic_number_return'] = ['timeLimit' => 15];
             }
         }
-        $rejectedBills = app(QueryService::class)->query($request, $rejectedBills, $columnQueryRules);
+        $rejectedBills = app(QueryService::class)->query($request->input(), $rejectedBills, $columnQueryRules);
         return $rejectedBills;
     }
 

+ 1 - 1
app/Services/WaybillService.php

@@ -32,7 +32,7 @@ Class WaybillService
             'created_at_end' => ['alias' => 'created_at' , 'endDate' => ' 23:59:59'],
             'uriType' => ['alias' => 'type']
         ];
-        $waybills = app(QueryService::class)->query($request,$waybills,$columnQueryRules,"waybills");
+        $waybills = app(QueryService::class)->query($request->input(),$waybills,$columnQueryRules,"waybills");
         return $waybills;
     }
 

+ 14 - 14
app/Services/common/QueryService.php

@@ -12,23 +12,23 @@ Class QueryService
     /**
      * parameter - query(sql) - special column description
      *
-     * @param Request $request
+     * @param array $params
      * @param object $query
      * @param array $columnQueryRules
      * @param string $tableName
      * @return object
      */
-    public function query(Request $request,$query,array $columnQueryRules,$tableName = null)
+    public function query(array $params,$query,array $columnQueryRules,$tableName = null)
     {
         if ($tableName) $tableName .= ".";
-        foreach ($request->input() as $param => $value){
+        foreach ($params as $param => $value){
             if ($param === 'paginate' || $param === 'page')continue;
-            if (!$value || isset($columnQueryRules[$param]))continue;
+            if (!$value || $columnQueryRules[$param] ?? false)continue;
             $query = $query->where($tableName.$param,$value);
         }
         //rules: alias timeLimit startDate endDate like multi
         foreach ($columnQueryRules as $param => $rules){
-            if (!$request->input($param))continue;
+            if (!($params[$param] ?? false) || !$params[$param])continue;
             $isExecute = true;
             $column = $param;
             foreach ($rules as $rule => $value){
@@ -39,36 +39,36 @@ Class QueryService
                 if ($rule === 'timeLimit'){
                     $today=Carbon::now()->subDays($value);
                     $queryTemp=clone $query;
-                    $queryTemp=$queryTemp->where($tableName.$column,'like','%'.$request->input($param).'%')
+                    $queryTemp=$queryTemp->where($tableName.$column,'like','%'.$params[$param].'%')
                         ->where($tableName.'created_at','>',$today);
-                    if($queryTemp->count()==0 || $queryTemp->first()[$column]==$request->input($param)){
-                        $query=$query->where($tableName.$column,$request->input($param));
+                    if($queryTemp->count()==0 || $queryTemp->first()[$column]==$params[$param]){
+                        $query=$query->where($tableName.$column,$params[$param]);
                     }else{
-                        $query=$query->where($tableName.$column,'like','%'.$request->input($param).'%')
+                        $query=$query->where($tableName.$column,'like','%'.$params[$param].'%')
                             ->where($tableName.'created_at','>',$today);
                     }
                     $isExecute = true;
                 }
                 if ($rule === 'startDate'){
-                    $startDate = $request->input($param).$value;
+                    $startDate = $params[$param].$value;
                     $query = $query->where($tableName.$column,'>=',$startDate);
                     $isExecute = true;
                 }
                 if ($rule === 'endDate'){
-                    $endDate = $request->input($param).$value;
+                    $endDate = $params[$param].$value;
                     $query = $query->where($tableName.$column,'<=',$endDate);
                     $isExecute = true;
                 }
                 if ($rule === 'like'){
-                    $query = $query->where($tableName.$column,'like',$value.$request->input($param).$value);
+                    $query = $query->where($tableName.$column,'like',$value.$params[$param].$value);
                     $isExecute = true;
                 }
                 if ($rule === 'multi'){
-                    $query = $query->whereIn($tableName.$column,explode($value,$request->input($param)));
+                    $query = $query->whereIn($tableName.$column,explode($value,$params[$param]));
                     $isExecute = true;
                 }
             }
-            if (!$isExecute) $query = $query->where($tableName.$column,$request->input($param));
+            if (!$isExecute) $query = $query->where($tableName.$column,$params[$param]);
         }
         return $query;
     }

+ 46 - 0
database/migrations/2020_08_25_180030_create_inventory_daily_logs_table.php

@@ -0,0 +1,46 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateInventoryDailyLogsTable extends Migration
+{
+    protected $authNames=[
+        '库存管理-库存体积',
+        '库存管理-库存体积-管理监听货主',
+    ];
+
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('inventory_daily_logs', function (Blueprint $table) {
+            $table->id();
+            $table->bigInteger('owner_id')->index()->comment('外键货主表');
+            $table->timestamp('created_at')->index()->comment('记录时间');
+            $table->bigInteger('commodity_id')->index()->comment('外键商品表');
+            $table->integer('amount')->default(0)->comment('数量');
+            $table->decimal('volumn_occupied',11,3)->nullable()->default(null)->comment('占用体积');
+        });
+        foreach ($this->authNames as $name){
+            \App\Authority::query()->create(['name'=>$name,'alias_name'=>$name]);
+        }
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('inventory_daily_logs');
+        foreach ($this->authNames as $name){
+            \App\Authority::query()->where(['name'=>$name,'alias_name'=>$name])->delete();
+        }
+    }
+}

+ 33 - 0
database/migrations/2020_08_25_180623_create_inventory_daily_logging_owners_table.php

@@ -0,0 +1,33 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateInventoryDailyLoggingOwnersTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('inventory_daily_logging_owners', function (Blueprint $table) {
+            $table->id();
+            $table->bigInteger('owner_id')->unique()->comment('外键货主表');
+            $table->enum('status',['启用','禁用'])->default('启用')->comment('货主的日常记录状态');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('inventory_daily_logging_owners');
+    }
+}

+ 38 - 0
database/migrations/2020_08_25_180803_change_commodities_add_column_length_width_height_volumn.php

@@ -0,0 +1,38 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class ChangeCommoditiesAddColumnLengthWidthHeightVolumn extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('commodities', function (Blueprint $table) {
+            $table->decimal('length',11,3)->nullable()->comment('长度');
+            $table->decimal('width',11,3)->nullable()->comment('宽度');
+            $table->decimal('height',11,3)->nullable()->comment('高度');
+            $table->decimal('volumn',11,3)->nullable()->comment('体积');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('commodities', function (Blueprint $table) {
+            $table->dropColumn('length');
+            $table->dropColumn('width');
+            $table->dropColumn('height');
+            $table->dropColumn('volumn');
+        });
+    }
+}

+ 3 - 3
public/js/app.js

@@ -61867,7 +61867,7 @@ var tempTip = {
     this.inputType = type;
   },
   showSuccess: function showSuccess(text) {
-    var tiper = $("<div class='row' style='color:white;opacity:0.9;position:fixed;top:40%;transform:translateY(-50%);width:100%;'>" + "<div class='col-8 offset-2'><div class='card'><div class='card-body h4 bg-success text-center'>" + text + "</div></div></div></div>");
+    var tiper = $("<div class='row' style='color:white;opacity:0.9;position:fixed;top:40%;transform:translateY(-50%);z-index:" + this.index + ";width:100%;'>" + "<div class='col-8 offset-2'><div class='card'><div class='card-body h4 bg-success text-center'>" + text + "</div></div></div></div>");
     tiper.animate({
       opacity: '0'
     }, this.fadingDuration, 'swing', function () {
@@ -61974,8 +61974,8 @@ module.exports = tempTip;
 /*! no static exports found */
 /***/ (function(module, exports, __webpack_require__) {
 
-__webpack_require__(/*! D:\phpstudy_pro\WWW\bswas\resources\js\app.js */"./resources/js/app.js");
-module.exports = __webpack_require__(/*! D:\phpstudy_pro\WWW\bswas\resources\sass\app.scss */"./resources/sass/app.scss");
+__webpack_require__(/*! D:\Demo\bswas\resources\js\app.js */"./resources/js/app.js");
+module.exports = __webpack_require__(/*! D:\Demo\bswas\resources\sass\app.scss */"./resources/sass/app.scss");
 
 
 /***/ }),

+ 1 - 1
resources/js/utilities/tempTip.js

@@ -13,7 +13,7 @@ const tempTip={
         this.inputType=type;
     },
     showSuccess:function(text){
-        let tiper=$("<div class='row' style='color:white;opacity:0.9;position:fixed;top:40%;transform:translateY(-50%);width:100%;'>" +
+        let tiper=$("<div class='row' style='color:white;opacity:0.9;position:fixed;top:40%;transform:translateY(-50%);z-index:"+this.index+";width:100%;'>" +
             "<div class='col-8 offset-2'><div class='card'><div class='card-body h4 bg-success text-center'>" +
             text +
             "</div></div></div></div>");

+ 1 - 1
resources/views/inventory/statement/allInventory.blade.php

@@ -66,7 +66,7 @@
 
 @section('lastScript')
     <script type="text/javascript" src="{{asset('js/queryForm/export200818a.js')}}"></script>
-    <script type="text/javascript" src="{{asset('js/queryForm/queryForm200805b.js')}}"></script>
+    <script type="text/javascript" src="{{asset('js/queryForm/queryForm200818a.js')}}"></script>
     <script>
         $.cookie('xxx', 2223);
         new Vue({

+ 248 - 0
resources/views/inventory/statement/dailyLog.blade.php

@@ -0,0 +1,248 @@
+@extends('layouts.app')
+@section('title')库存管理-库存体积@endsection
+
+@section('content')
+    @component('inventory.statement.menu')@endcomponent
+    <div class="d-none card" id="container">
+        <div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="pasteDataTitle" aria-hidden="true">
+            <div class="modal-dialog modal-dialog-centered modal-lg" role="document">
+                <div class="modal-content">
+                    <div class="modal-header row form-inline">
+                        <input type="text" v-model="name" class="form-control form-control-sm col-5 offset-3" placeholder="搜索货主,点击下方块添加" />
+                        <button class="btn btn-sm btn-info col-2" @click="seekOwner()">搜索</button>
+                        <label class="col-2"></label>
+                    </div>
+                    <div class="modal-body container row" style="text-align:center">
+                        <div class="col-2 mt-2" v-for="owner in owners">
+                            <div style="border: 1px solid #aac7ea;height: 80px;text-align: center;line-height: 80px;border-radius: 4px;cursor: pointer"
+                                :style="[{'background': loggingOwners.includes(Number(owner.name)) ? '#00FF00' : ''},
+                                    {'box-shadow' : seekOwners.includes(owner.name) ? '0px 0px 10px 5px rgba(0,0,0,0.9)' : ''}]"
+                            @click="addLoggingOwner( owner.name,owner.value )">@{{ owner.value }}</div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+        <div class="card-header pt-0">
+            <div id="form"></div>
+        </div>
+        <div class="w-100 ml-4 mt-0 mb-0">
+            <span class="dropdown d-none">
+                <button class="btn btn-outline-dark btn-sm form-control-sm dropdown-toggle tooltipTarget" :class="[checkData.length>0?'btn-dark text-light':'']"
+                        data-toggle="dropdown" title="导出所有页将会以搜索条件得到的过滤结果,将其全部记录(每一页)导出">
+                    导出Excel
+                </button>
+                <div class="dropdown-menu">
+                    <a class="dropdown-item" @click="dailyLogExport(false)" href="javascript:">导出勾选内容</a>
+                    <a class="dropdown-item" @click="dailyLogExport(true)" href="javascript:">导出所有页</a>
+                </div>
+            </span>
+            @can('库存管理-库存体积-管理监听货主')<button class="btn btn-outline-info btn-sm tooltipTarget" @click="openModal()">添加监听货主</button>@endcan
+        </div>
+        <div class="card-body pt-1">
+            <label for="all" class="d-none" id="cloneCheckAll">
+                <input id="all" type="checkbox" @click="checkAll($event)">全选
+            </label>
+            <table class="table table-sm text-nowrap table-bordered d-none" id="headerRoll"></table>
+            <table class="table table-sm text-nowrap table-striped table-bordered m-0" id="headerParent">
+                <tr class="p-0" id="header"></tr>
+                <tr v-for="(inventoryDailyLog,i) in inventoryDailyLogs">
+                   <td>
+                       <input type="checkbox" :value="inventoryDailyLog.id" v-model="checkData">
+                   </td>
+                    <td>@{{ i+1 }}</td>
+                    <td>@{{ inventoryDailyLog.owner_name }}</td>
+                    <td>@{{ inventoryDailyLog.created_at }}</td>
+                    <td>@{{ inventoryDailyLog.commodity_name }}</td>
+                    <td>@{{ inventoryDailyLog.commodity_sku }}</td>
+                    <td>
+                        <span v-if="inventoryDailyLog.commodity_barcodes && inventoryDailyLog.commodity_barcodes.length>0">
+                            <span v-if="inventoryDailyLog.commodity_barcodes.length==1">
+                                @{{ inventoryDailyLog.commodity_barcodes[0].code }}
+                            </span>
+                            <span v-if="inventoryDailyLog.commodity_barcodes.length>1">
+                                <small v-for="barcode in inventoryDailyLog.commodity_barcodes">@{{ barcode.code }}<br></small>
+                            </span>
+                        </span>
+                    </td>
+                    <td>@{{ inventoryDailyLog.amount }}</td>
+                    <td>@{{ inventoryDailyLog.commodity_length }}</td>
+                    <td>@{{ inventoryDailyLog.commodity_width }}</td>
+                    <td>@{{ inventoryDailyLog.commodity_height }}</td>
+                    <td>@{{ inventoryDailyLog.commodity_volumn }}</td>
+                    <td>@{{ inventoryDailyLog.volumn_occupied }}</td>
+                </tr>
+            </table>
+            {{$inventoryDailyLogs->appends($param)->links()}}
+        </div>
+    </div>
+@endsection
+
+@section('lastScript')
+    <script type="text/javascript" src="{{asset('js/queryForm/export200818a.js')}}"></script>
+    <script type="text/javascript" src="{{asset('js/queryForm/queryForm200818a.js')}}"></script>
+    <script type="text/javascript" src="{{asset('js/queryForm/header200819.js')}}"></script>
+    <script>
+        let vue = new Vue({
+            el:"#container",
+            data:{
+                inventoryDailyLogs : [
+                    @foreach($inventoryDailyLogs as $inventoryDailyLog)
+                    {id:'{{$inventoryDailyLog->id}}',owner_name:'{{$inventoryDailyLog->owner ? $inventoryDailyLog->owner->name : ''}}',
+                        created_at:'{{$inventoryDailyLog->created_at}}', commodity_name:'{{$inventoryDailyLog->commodity ? $inventoryDailyLog->commodity->name : ''}}',
+                        commodity_sku:'{{$inventoryDailyLog->commodity ? $inventoryDailyLog->commodity->sku : ''}}',
+                        commodity_barcodes:[
+                            @foreach($inventoryDailyLog->commodity ? $inventoryDailyLog->commodity->barcodes ?? [] : [] as $barcode)
+                            {code:'{{$barcode->code}}'},
+                            @endforeach
+                        ],
+                        amount:'{{$inventoryDailyLog->amount}}', commodity_length:'{{$inventoryDailyLog->commodity ? $inventoryDailyLog->commodity->length : ''}}',
+                        commodity_width:'{{$inventoryDailyLog->commodity ? $inventoryDailyLog->commodity->width : ''}}',
+                        commodity_height:'{{$inventoryDailyLog->commodity ? $inventoryDailyLog->commodity->height : ''}}',
+                        commodity_volumn:'{{$inventoryDailyLog->commodity ? $inventoryDailyLog->commodity->volumn : ''}}',
+                        volumn_occupied:'{{$inventoryDailyLog->volumn_occupied}}'},
+                    @endforeach
+                ],
+                owners : [
+                    @foreach($owners as $owner)
+                    {name:"{{$owner->id}}",value:"{{$owner->name}}"},
+                    @endforeach
+                ],
+                checkData:[],
+                name : "",
+                loggingOwners : [],
+                seekOwners : [],
+            },
+            watch:{
+                checkData:{
+                    handler(){
+                        if (this.checkData.length === this.inventoryDailyLogs.length){
+                            document.querySelector('#all').checked = true;
+                            document.querySelector('#all_temp').checked = true;
+                        }else {
+                            document.querySelector('#all').checked = false;
+                            document.querySelector('#all_temp').checked = false;
+                        }
+                    },
+                    deep:true
+                }
+            },
+            mounted(){
+                $(".tooltipTarget").tooltip({'trigger': 'hover'});
+                $("#container").removeClass('d-none');
+                let data=[
+                    [
+                        {name:'created_at_start',type:'dateTime',tip:'选择创建日期的起始时间'},
+                        {
+                            name: 'owner_id', type: 'select_multiple_select', tip: ['输入关键词快速定位下拉列表,回车确定', '选择要显示的客户'],
+                            placeholder: ['货主', '定位或多选货主'], data: this.owners
+                        },
+                    ],
+                    [
+                        {name:'created_at_end',type:'dateTime',tip:'选择创建日期的结束时间'},
+                    ],
+                ];
+                this.form = new query({
+                    el:'#form',
+                    condition:data
+                });
+                this.form.init();
+                let column = [
+                    {name:'cloneCheckAll',customization:true,type:'checkAll',column:'id',
+                        dom:$('#cloneCheckAll').removeClass('d-none'), neglect: true},
+                    {name:'index',value: '序号', neglect: true},
+                    {name:'owner_name',value: '货主'},
+                    {name: 'created_at', value: '日期'},
+                    {name: 'commodity_name', value: '商品名称'},
+                    {name:'commodity_sku',value: '商品编码'},
+                    {name: 'commodity_barcodes', value: '商品条码', neglect: true},
+                    {name: 'amount', value: '在库数量', neglect: true},
+                    {name: 'commodity_length', value: '长', neglect: true},
+                    {name: 'commodity_width',value: '宽', neglect: true},
+                    {name: 'commodity_height', value: '高', neglect: true},
+                    {name: 'commodity_volumn', value: '体积', neglect: true},
+                    {name: 'volumn_occupied', value: '总占用体积', neglect: true},
+                ];
+                let _this = this;
+                setTimeout(function () {
+                    let header = new Header({
+                        el: "#header",
+                        column: column,
+                        data: _this.inventoryDailyLogs,
+                        restorationColumn: 'id',
+                        fixedTop:($('#form').height())+2,
+                        vue:vue
+                    });
+                    header.init();
+                },0);
+            },
+            methods:{
+                //全选事件
+                checkAll(e) {
+                    if (e.target.checked) {
+                        this.inventoryDailyLogs.forEach((el) => {
+                            if (!el.id) this.checkData.push(el.id);
+                            if (el.id && this.checkData.indexOf(el.id) === -1) {
+                                this.checkData.push(el.id);
+                            }
+                        });
+                    } else {
+                        this.checkData = [];
+                    }
+                },
+                dailyLogExport(type){
+
+                },
+                openModal(){
+                    let url = "{{url('inventory/statement/dailyLog/getLoggingOwner')}}";
+                    axios.post(url).then(res=>{
+                       this.loggingOwners = res.data;
+                        $("#modal").modal('show');
+                    });
+                },
+                seekOwner(){
+                    if (!this.name)return ;
+                    let name = this.name;
+                    let seekOwners = [];
+                    this.owners.forEach(function (owner) {
+                        if ((owner.value).indexOf(name) !== -1){
+                            seekOwners.push(owner.name);
+                        }
+                    });
+                    if (seekOwners.length > 0)this.seekOwners = seekOwners;
+                },
+                addLoggingOwner(owner_id,name){
+                    if (!owner_id){
+                        alert('选中记录异常!');
+                        return;
+                    }
+                    if (this.loggingOwners.includes(Number(owner_id))){
+                        return;
+                    }
+                    if (!confirm("确定要添加对“"+name+"”的监听吗?"))return;
+                    let url = "{{url('inventory/statement/dailyLog/addLoggingOwner')}}";
+                    axios.post(url,{
+                        owner_id:owner_id
+                    }).then(res=>{
+                        tempTip.setDuration(2000);
+                        tempTip.setIndex(1099);
+                        if (res.data.success){
+                            this.loggingOwners.push(Number(res.data.data));
+                            this.seekOwners = [];
+                            tempTip.showSuccess('成功添加对“'+name+"的记录监听");
+                            tempTip.setIndex(99);
+                            return;
+                        }
+                        tempTip.show(res.data.data);
+                        tempTip.setIndex(99);
+                    }).catch(err=>{
+                        tempTip.setDuration(3000);
+                        tempTip.setIndex(1099);
+                        tempTip.show('网络连接错误:'+err);
+                        tempTip.setIndex(99);
+                    });
+                }
+            },
+        });
+    </script>
+@endsection

+ 4 - 0
resources/views/inventory/statement/menu.blade.php

@@ -12,6 +12,10 @@
                     <li class="nav-item">
                         <a class="nav-link" href="{{url('inventory/statement/allInventory')}}" :class="{active:isActive('allInventory',3)}">全部库存</a>
                     </li> @endcan
+                @can('库存管理-库存体积')
+                    <li class="nav-item">
+                        <a class="nav-link" href="{{url('inventory/statement/dailyLog')}}" :class="{active:isActive('dailyLog',3)}">库存体积</a>
+                    </li> @endcan
             </ul>
         </div>
     </div>

+ 1 - 1
resources/views/inventory/stockInventory/mission.blade.php

@@ -74,7 +74,7 @@
 
 @section('lastScript')
     <script type="text/javascript" src="{{asset('js/queryForm/export200818a.js')}}"></script>
-    <script type="text/javascript" src="{{asset('js/queryForm/queryForm200805b.js')}}"></script>
+    <script type="text/javascript" src="{{asset('js/queryForm/queryForm200818a.js')}}"></script>
     <script>
         new Vue({
             el: "#list",

+ 1 - 1
resources/views/rejected/search/analyze.blade.php

@@ -61,7 +61,7 @@
 
 @section('lastScript')
     <script src="{{asset('js/queryForm/export200818a.js')}}"></script>
-    <script src="{{asset('js/queryForm/queryForm200803a.js')}}"></script>
+    <script src="{{asset('js/queryForm/queryForm200818a.js')}}"></script>
     <script type="text/javascript" src="{{asset('js/queryForm/header200819.js')}}"></script>
     <script>
         let vue = new Vue({

+ 6 - 0
routes/web.php

@@ -306,6 +306,12 @@ Route::group(['prefix'=>'inventory'],function (){
     //盘点任务导出
     Route::any('stockInventoryExport','InventoryController@stockInventoryExport');
     Route::any('stockInventory','InventoryController@stockInventory');
+    //库存体积
+    Route::get('statement/dailyLog','InventoryController@dailyLog');
+    //获取记录监听货主
+    Route::post('statement/dailyLog/getLoggingOwner','InventoryController@getLoggingOwner');
+    //添加记录监听货主
+    Route::post('statement/dailyLog/addLoggingOwner','InventoryController@addLoggingOwner');
 });
 
 /**